Download Document

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Birkhoff's representation theorem wikipedia , lookup

Fundamental theorem of algebra wikipedia , lookup

Transcript
4
Functions
Before studying functions we will first quickly define a more
general idea, namely the notion of a relation. A function
turns out to be a special type of relation.
Definition: Let S and T be sets. A binary relation on SxT
is any subset of SxT . A binary relation on S is any subset of
SxS.
Note: Often the word “binary” is omitted and we simply use
the term relation.
Definition: An n-ary relation is a subset of A1xA2x . . . An.
Representations of Relations
Example: Let A = {a1, a2, a3, a4} and B = {b1, b2}.
Define a relation on AxB by
R = {(a1 , b2), (a2, b1), (a2 , b2), (a4 , b2)}.
41
Tabular Representation:
Graphical Representation:
Example: S = {1, 2, 3, 4}
R1 = “<” on S i.e.,
R1 = {(1, 2), (1, 3), (1, 4), (2, 3), (2, 4), (3, 4)}
R2 = “≤” on S.
42
We now define a special class of relations, namely functions.
Definition: A function f : A → B is a binary relation Rf on
AxB such that for each a ∈ A ∃! b ∈ B such that (a, b) ∈ Rf .
The book’s definition is equivalent: A function f from a
set X to a set Y is a relation between the elements of X
and Y with the property that each element of X is related to
a unique element of Y .
More definitions: X is called the domain of f and Y is
called the co-domain of f . The set {f (x) | x ∈ X} is called
the range of f or the image of X under f .
Notation:
f (x) = y
f : x → y.
Examples of Functions
First some special types of functions.
• successor function
f :Z → Z
n → n+1
43
• constant function
Example:
f :Z → Z
n → 3
• identity function
iX : X → X
x → x
More functions:
1.
f :R → R
x → 0
2.
f :R → R
x → x2
44
3.
f : R → R+ ∪ {0}
x → x2
Technically, 3 is a different function from 2 since 3 has a
different co-domain.
4.
f :R → R
x → x3 + 2x2
5.
45
6.
7.
8.
Definition: A function f : A → B is 1-1 or an injection if
a1 6= a2 ⇒ f (a1) 6= f (a2 ) ∀ a1, a2 ∈ A.
Equivalently,
f (a1) = f (a2) in B ⇒ a1 = a2 in A.
Examples: (6) and (8) are 1-1.
46
Theorem 4.1 Let f : R → R be given by f (x) = 4x − 1.
Then f is 1-1.
Proof: Suppose f (x1) = f (x2). We must show that
x1 = x2 . But clearly we have
4x1 − 1 = 4x2 − 1
4x1 = 4x2
x1 = x2.
Question: Is the following function 1-1?
f :Z → Z
n → n4
Answer: No, since f (1) = 1 and f (−1) = 1.
Definition: A function f : A → B is onto or a surjection
if
∀b ∈ B ∃a ∈ A such that f (a) = b.
Examples: (3), (4), (7) and (8) are onto.
Note: If a function is onto, then its range equals its co-domain.
Note: f : Z → Z given by f (n) = 4n − 1 is not onto. To be
onto, there would have to be an integer n such that 4n−1 = 0.
This is clearly not the case.
47
Theorem 4.2 Let f : R → R be given by f (x) = 4x − 1.
Then f is onto.
Proof: For any real number y, 4x − 1 = y iff x =
y+1
is a real number we are done.
Since
4
y+1
.
4
Definition: A function f : A → B is a bijection if it is both
1-1 and onto. It is also called a 1-1 correspondence.
Definition: A bijection f : X → X is called a permutation
of X.
Note: We will prove (at least part of) the following theorem
later by induction.
Theorem 4.3 Let X be a finite set and f : X → X. Then
f is 1-1 iff f is onto.
Note: The theorem is false if X is infinite.
48
Example:
f :N → N
n → 2n
f is 1-1 but not onto.
Definition: The inverse of a function f : A → B is the
relation (subset of BxA) given by
f −1 = {(b, a) | (a, b) ∈ Rf }.
Note: f −1 is not necessarily a function.
Example:
f −1 is not a function.
Definition: A function f : A → B is invertible if
f −1 : B → A is a function. In this case, f −1 is called the
inverse of f .
Theorem 4.4 A function f : A → B is invertible iff it is
a bijection.
Note: In this case f −1 is also a bijection.
49
Before studying the Pigeonhole Principle we consider a few
special functions.
1. A partial function with domain A and co-domain B is
0
0
any function from A to B, where A ⊆ A.
0
Note: For x ∈ A − A , f (x) is undefined.
Example:
f :R → R
1
x →
x
is a partial function (not defined for x = 0).
Example:
f :R → R
√
x → x
is a partial function (not defined for x < 0).
50
0
2. Suppose A ⊆ A. The characteristic function of A
is given by χA0 : A → {0, 1}, where



0
0
0 if a ∈
/A
0
1 if a ∈ A
χA0 (a) = 

0
Example: A = N A = {n | n ≡ 0(mod 3)} . Thus
χA0 (5) = 0 and χA0 (6) = 1.
0
Example: A = [0, 1] and A = [1/4, 3/4].
51
Pigeonhole Principle
Pigeonhole Principle: Let A and B be finite sets.
If f : A → B and |A| > |B| ≥ 1, then there exists a1 6=
a2 ∈ A such that f (a1) = f (a2), i.e., there does not exist an
injection from A to B.
Note: Actually, A can be infinite.
Simple examples:
1. If there are 5 pigeons in 4 pigeonholes then at least one
pigeonhole contains 2 or more pigeons.
2. In any group of thirteen people at least 2 were born in the
same month.
3. A drawer contains 10 black socks and 10 white socks.
What is the least number of socks you must pull out to be
sure to get a matched pair?
Answer: 3
4. If five points are chosen from a unit square, then some pair
1
are distance at most √ apart.
2
5. At any party there are always at least two people with the
same number of acquaintances.
52
Reason: Let A be the set of n people at the party. Let
B = {0, 1, . . . , n − 1} be the set representing the possible
number of acquaintances of any person at the party. Let f
be the function that assigns, for each person at the party,
the number of acquaintances of that person. If we let If
denote the image of f , then it is not possible to have both
0 and n − 1 in If , since if a person knows everyone it is
not possible for some other person to know no one. Hence
|If | ≤ n − 1. Since |A| = n, by the pigeonhole principle,
f can not be a 1 − 1 function. Hence at least 2 people at
the party must have the same number of acquaintances.
53
6. Let A = {1, 2, 3, 4, 5, 6, 7, 8}. If 5 integers are selected
from A, then at least one pair of the integers must sum to
nine.
Reason: This follows since A can be partitioned into the
4 sets
{1, 8}, {2, 7}, {3, 6}, {4, 5}.
For 1 ≤ i ≤ 4, let Bi = {i, 9 − i}. Let S be any set of
5 integers from A and B be the 4 element set consisting
of the sets Bi , 1 ≤ i ≤ 4. Finally, consider the function
f : S → B which takes an element of S to the set containing that element. Since |S| = 5 and there are only 4
sets, by the pigeonhole principle, f is not a 1 − 1 function.
Hence 2 of the elements of S are sent to the same set Bi
and these elements sum to 9.
Note: If only 4 integers are chosen, then it is possible that
no 2 of them will add up to 9.
54
We now look at a much more difficult application.
Theorem 4.5 In any sequence of n2 + 1 distinct integers
there exists either
1. an increasing subsequence of length at least n + 1 or
2. a decreasing subsequence of length at least n + 1.
The proof uses the pigeonhole principle. Before giving the
proof we illustrate what the theorem is saying.
Example: Let n = 3 and consider the sequence
3 1 2 10 4 14 9 7 8 6.
1 2 4 7 8 is an increasing subsequence of length 5.
14 9 8 6 is a decreasing subsequence of length 4.
Example: Let n = 2 and consider the sequence
2 1 5 4 3.
5 4 3 is a decreasing subsequence of length 3.
There is no increasing subsequence of length 3.
55
Proof: By contradiction (using the pigeonhole principle).
Let a1 , a2, . . . , an2 +1 be a sequence of distinct integers and
assume the theorem is false. Assign to each ak an ordered pair
(xk , yk ), where
1. xk is the length of a longest increasing subsequence starting at ak .
2. yk is the length of a longest decreasing subsequence starting at ak .
e.g.
2 1 5 4 3.
a1 = (2, 2), a2 = (2, 1), a3 = (1, 3), a4 = (1, 2), a5 = (1, 1).
Note: Since we are assuming the theorem is false, there are at
most n2 distinct (xk , yk ) pairs that are possible.
Let
• A = {ak } |A| = n2 + 1.
• B = {(xk , yk )} |B| = n2.
Let f : A → B be the function that represents the above
assignment.
56
Since |A| > |B|, by the pigeonhole principle we must have
f (ai) = f (aj ) for some i 6= j, i.e., (xi , yi) = (xj , yj ).
Assume, without loss of generality, that i < j. Either ai < aj
or aj < ai .
Case 1: ai < aj .
Then xi > xj , a contradiction.
Case 2: ai > aj .
Then yi > yj , a contradiction.
2
57
Composition of Functions
Definition: Let f : X → Y and g : Y → Z. The composition of f and g is
gof : X → Z
x → g(f (x))
Example: f : {0, 1, 2, 3} → {a, b, c}
{A, B, C}.
g : {a, b, c} →
gof : {0, 1, 2, 3} → {A, B, C}.
Note: In order for the composition to work, the range of f
must be a subset of the domain of g.
58
Example:
f :N → N
n → n
g : {0, 1, 2} → N
n → n
Here gof is not defined, e.g., what is gof (10)? However f og
is defined, and in fact f og = g.
59
Example:
f :N → N
n → n/2 if n is even
n → 0 if n is odd.
g:N → N
n → 2n
Now
gof : N → N
n → n if n is even
n → 0 if n is odd.
f og : N → N
n → n
Note: In general, f og 6= gof .
60
Theorem 4.6 Suppose f : A → B and g : B → C. If
1. f and g are surjective, then gof is surjective.
2. f and g are injective, then gof is injective.
3. f and g are bijective, then gof is bijective.
Proof: First note that (3) easily follow from (1) and (2).
1. Let c ∈ C. Since g is onto ∃b ∈ B such that g(b) = c.
But since f is onto ∃a ∈ A such that f (a) = b. Hence
gof (a) = g(b) = c.
Thus gof is surjective.
2. Suppose a1 6= a2 ∈ A. Since f is 1-1, f (a1) 6= f (a2). Now
since g is 1-1, g(f (a1)) 6= g(f (a2)). Hence gof is 1-1. 2
61
The composition of functions is associative.
Theorem 4.7 If f : X → Y, g : Y → Zand h : Z → W ,
then ho(gof ) = (hog)of .
Example:
62
Definition: Let f : X → X be a function. Then
f2 : X → X
x → f (f (x))
In general, we define f n(x) as follows:
f 0(x) = x
f n(x) = f (f n−1(x))
Example: Consider the permutation ρ : X → X, where X =
{0, 1, 2, 3, 4}.
Theorem 4.8 ρ : X → X is a permutation iff ρ2 : X →
X is a permutation.
Note: We have already proved (⇒) since ρ2 = ρoρ.
63
Set Mappings
0
Definition: Let f : A → B be a function and A ⊆ A. Then
0
0
0
f (A ) = {f (x) | x ∈ A } is called the image of A under f .
Note: f : A → B implicitly defines another function
F : P (A) → P (B). Even though F 6= f , we usually write f
instead of F .
0
Definition: Let f : A → B be a function and B ⊆ B. Then
0
0
f −1(B ) = {x ∈ A | f (x) ∈ B } is called the inverse image
0
of B under f .
Example:
f ({1, 2}) = {b, c}
f −1({b}) = {0, 2, 4}
64
Example:
f :N → N
n → n mod 3
1. f ({1, 7, 13}) = {1}
2. f ({1, 4, 5}) = {1, 2}
3. f −1({0}) = {m | m = 3k for some k ∈ N}
Theorem 4.9 Let f : A → B with A1, A2 ⊆ A. Then
1. f (A1 ∪ A2) = f (A1) ∪ f (A2)
2. f (A1 ∩ A2) ⊆ f (A1) ∩ f (A2).
Proof of (1): (⊆) Let b ∈ f (A1 ∪ A2 ). Then b = f (a),
where a ∈ A1 ∪ A2.
If a ∈ A1, b ∈ f (A1). If a ∈ A2, b ∈ f (A2).
In either case b ∈ f (A1) ∪ f (A2).
(⊇) Let b ∈ f (A1) ∪ f (A2).
If b ∈ f (A1), then b = f (a), where a ∈ A1. But then
a ∈ A1 ∪A2 and hence b ∈ f (A1 ∪A2). Similarly if b ∈ f (A2).
2
Note: The above theorem holds for arbitrary (more than 2)
unions.
65
5
Cardinality
Suppose A and B are finite sets and we wish to determine
which is the larger set. Here are two ways this can be done.
1. Count the elements in A and then count the elements in
B.
2. Create a correspondence between the elements of A and
B, i.e., let the first element of A correspond to the first element of B, then the second, etc. The set having elements
“left over” is the larger set.
Note: If A and B are infinite sets, then (1) can not be done.
However (2) can still be done, and that is in fact how we compare the size (or cardinality) of the sets.
Definition: We say the elements of set A are in a 1-1 correspondence with the elements of set B if there exists a 1-1,
onto function between A and B. If this is the case we say A
and B have the same cardinality or have the same size.
Definition: A set is finite if it is either empty or it can be
put into a 1-1 correspondence with a set of the form
[n] = {1, 2, . . . , n}. Otherwise the set is infinite.
66
Example: A = {a, b, c} and [3] = {1, 2, 3} have the same
cardinality.
a ↔ 1
b ↔ 2
c ↔ 3
Definition: A set A is called countably infinite if it has
the same cardinality as the set of positive integers Z +. A set
is called countable if it is either finite or countably infinite.
Note: An equivalent definition, and one that appears in many
other books, is that a set is countably infinite if there is a
1-1 correspondence between it and the natural numbers
N = {0, 1, 2, . . .}. We will use Z +, but either can be used to
show a set is countably infinite.
Example: Z + and N have the same cardinality.
1
2
3
...
↔
↔
↔
↔
67
0
1
2
...
Example: The set of nonnegative even integers forms a countably infinite set.
0
1
2
...
↔
↔
↔
↔
0
2
4
...
Example: The set of all integers (Z) is a countably infinite set.
The function f : Z + → Z gives the 1-1 correspondence.







f (n) := 





n
if n is an even positive integer
2
1−n
if n is an odd positive integer
2
We get
f (1)
f (2)
f (3)
f (4)
f (5)
f (6)
...
=
=
=
=
=
=
=
0
1
−1
2
−2
3
...
Example: The set of all positive rationals, denoted Q+, is a
countably infinite set.
68
1/1 2/1 3/1 4/1 5/1 . . .
1/2 2/2 3/2 4/2 5/2 . . .
1/3 2/3 3/3 4/3 5/3 . . .
1/4 2/4 3/4 4/4 5/4 . . .
1/5 2/5 3/5 4/5 5/5 . . .
...
The correspondence is obtained by first listing the rationals
whose numerator and denominator sum to 2. Then 3, 4, 5, . . ..
If a rational has already appeared on the list, do not list it
again. We get
f (1)
f (2)
f (3)
f (4)
f (5)
f (6)
f (7)
f (8)
f (9)
...
=
=
=
=
=
=
=
=
=
=
69
1
2
1/2
3
1/3
4
3/2
2/3
1/4
...
Notation: The cardinality of a set A is given by |A|. We use
χ0 to denote the cardinality of Z +.
Note: Intuitively, any set whose elements can be “listed” in
some way is a countably infinite set.
Question: Are there infinite sets that are not countably infinite?
Answer: Yes. The set of all real numbers between 0 and 1
(J = [0, 1]) is not a countably infinite set. We call such sets
uncountably infinite.
Theorem 5.1 J = [0, 1] is uncountably infinite.
Proof: We will assume J is countably infinite and reach a
contradiction.
We first must decide how a number x ∈ J will be represented. We will represent such a number as a decimal, i.e.,
x = .a1a2 a3 . . .. We will not allow our decimals to end with
an infinite sequence of 90s, i.e., we use .25000 . . . instead of
.24999 . . .. Now every number in J has a unique decimal expansion.
Now suppose it is possible to list the numbers in J, i.e., that
J is countably infinite and such a list can be described. We
will produce a number x ∈ J that is not on the list.
70
Let ai,j represent the j th digit of the ith number on the list
e. g.
1.
.2 3 1 2 4 7 . . .
2.
.3 1 4 6 7 7 . . .
3.
.2 9 8 6 4 1 . . .
4.
.3 7 1 1 4 2 . . .
5.
.6 6 1 2 6 3 . . .
6.
.7 1 2 3 4 5 . . .
...
Thus a2,3 = 4 and a5,6 = 3.
We now construct a number x as follows. If the ith digit of
number i is not 1, then the ith digit of x is 1. If the ith digit of
number i is 1, then the ith digit of x is 2. Using the example
above, x = .121211 . . ..
Thus x always differs from number i in the ith digit. Hence
x ∈ J is not on the list. This is a contradiction. 2
71
Notation: |J| = c
Notation: S = {x ∈ R | 0 < x < 1}.
Note: A proof similar to the one above shows that
|S| = |J| = c.
Theorem 5.2 |R| = c, i.e., the cardinality of the entire
real line is the same as the cardinality of J or S.
Outline of Proof: Imagine taking S and bending it into
a circle. Then place the circle tangent to R at the point zero.
Since S does not contain either 0 or 1, the topmost point of
the circle is omitted. The figure below indicates how to obtain
a 1-1 correspondence between S and R.
72
Application to Computer Science
Let L be a fixed computer language.
Question: How many different computer programs can be
written in L?
Theorem 5.3 The set of all programs that can be written
in any language L is countable.
Proof: Each symbol in a computer language is translated
into a string of 0’s and 1’s. Hence any program can be thought
of as a long string of 0’s and 1’s. To show that this is a countable set we must find a way to list these sequences of 0’ and 1’s.
The first thing to do is to list them by length. If two strings
have the same length, they should be ordered in ascending order according to the binary number they represent. Thus 0010
precedes 1010 in the ordering.
Since all the programs in L are on the list, there are countably
many such programs. 2
We now use this result to show that there are noncomputable
functions. Let T be the set of all functions f : Z + → {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}.
We will show that T is uncountably infinite. Thus, since the
set of all programs in any computer language L is countably
infinite, there are not enough programs to compute every function in T .
73
Theorem 5.4 Let T be the set of all functions f : Z + →
{0, 1, 2, 3, 4, 5, 6, 7, 8, 9}. Then T is uncountably infinite.
The proof of the theorem assumes the following “intuitive” result.
Theorem 5.5 Any subset of a countable set is countable.
Proof of Theorem 5.4:
Again let S = {x ∈ R | 0 < x < 1}. As before we can
represent any number in S uniquely as a decimal .a1a2 a3 . . .,
provided we do not use decimals that end in an infinite sequence of 9’s. Now define a function F from S to a subset
of T by letting F (.a1 a2a3 . . .) = the function that sends each
positive integer n to an. Define the co-domain of F to be the
subset of T that makes F onto. Now F is 1-1 and onto. Thus,
since S is uncountable, so is the co-domain of F . But then T
has an uncountable subset and so must also be uncountable.
2
74