Upload
hester-nash
View
214
Download
0
Embed Size (px)
Citation preview
1
Annoucement
Skills you need:
(1) (In Thinking) You think and move by• Logic• Definitions• Mathematical properties (Basic algebra etc.)
(2) (In Exploration) You understand by:• Trying examples• Drawing diagrams
– For relations, 3 visualization tools have been given to you. Be flexible in using your alternatives.
(3) Using (1) and (2) to understand new things.
2
Lecture 3 (part 1)
FunctionsReading: Epp Chp 7.1, 7.3, 7.5
3
Overview
Functions– Definition– Visualization Tool– Examples– Notation– Identity Function
Definitions– Domain, codomain,
range– Image, inverse image– Let f:A B and let S A
and T B.• S InvImgf(Imgf(S))
• Imgf(InvImgf(T)) T
Operations on Functions– Set related (,,):
1. If fg is a function, then f = g2. If fg is a function, then f = g3. If fg is a function, then fg=
– Inverse– Composition– Theorems
1. G o f is a function.
2. F o idA idB o f f3. (h o g) o f = h o (g o f)4. (g o f)-1 = f-1 o g-1
Special Kinds of Functions– Injective, Surjective,
Bijective– Theorems
• Preservation under ‘o’.• On inverses
Multi-argument functions
4
1. Definition: Function
Given a relation R from a set A to a set B, R is a function iff1. xA, yB, x R y
2. xA, y1,y2B, x R y1 x R y2 y1 = y2.
5
1. Definition: Function
Given a relation R from a set A to a set B, R is a function iff1. xA, yB, x R y
2. xA, y1,y2B, x R y1 x R y2 y1 = y2.
A function is a relation. It’s just a special kind of relation – a relation with 2 restrictions.
6
1. Definition: Function
Given a relation R from a set A to a set B, R is a function iff1. xA, yB, x R y
2. xA, y1,y2B, x R y1 x R y2 y1 = y2.
1. Every element in A must be associated with AT LEAST one element in B.
Extract the meaning from the logical expression.
A BR
7
1. Definition: Function
Given a relation R from a set A to a set B, R is a function iff1. xA, yB, x R y
2. xA, y1,y2B, x R y1 x R y2 y1 = y2.
2. An element in A can only be associated with AT MOST one element in B.
Extract the meaning from the logical expression.
A BR
8
1. Definition: Function
Given a relation R from a set A to a set B, R is a function iff1. xA, yB, x R y
2. xA, y1,y2B, x R y1 x R y2 y1 = y2.
1 and 2 taken together: Every element in A can only be associated with EXACTLY ONE element in B.
Extract the meaning from the logical expression.
A BR
9
2. Visualisation Tool: Arrow Diagram
Given a relation R from a set A to a set B, R is a function iff1. xA, yB, x R y
2. xA, y1,y2B, x R y1 x R y2 y1 = y2.
A Bf
Not a function
10
2. Visualisation Tool: Arrow Diagram
Given a relation R from a set A to a set B, R is a function iff1. xA, yB, x R y
2. xA, y1,y2B, x R y1 x R y2 y1 = y2.
Yes, it’s a function.
A Bf
11
2. Visualisation Tool: Arrow Diagram
Given a relation R from a set A to a set B, R is a function iff1. xA, yB, x R y
2. xA, y1,y2B, x R y1 x R y2 y1 = y2.
Not a function
A Bf
12
3. Examples
Given a relation R from a set A to a set B, R is a function iff1. xA, yB, x R y
2. xA, y1,y2B, x R y1 x R y2 y1 = y2.
Example 1:
Is R a function?
No. (Cond 1)
No. (Cond 2)
Yes.
R = {(1,2)}
R A x BA
{1,2,3}
B
{1,2,3}
R = {(1,2),(2,3),(1,3)}{1,2,3} {1,2,3}
R = {(1,1),(2,1),(3,1)}{1,2,3} {1,2,3}
{1,2,3,4} {1,2,3} R = {(1,1),(2,2),(3,3)} No. (Cond 1)
{1,2,3} {1,2,3,4} R = {(1,1),(2,2),(3,3)} Yes.
13
3. Examples
Given a relation R from a set A to a set B, R is a function iff1. xA, yB, x R y
2. xA, y1,y2B, x R y1 x R y2 y1 = y2.
Example 2: Let R Q x Z such that…
(i) x R y iff x = y.
Q: Is R a function?
A: No (1st Condition: ½ maps to nothing)
Q Z
½ ?
(ii) (a/b) R c iff a.b = c.
Q: Is R a function?
A: Yes
14
3. Examples
Given a relation R from a set A to a set B, R is a function iff1. xA, yB, x R y
2. xA, y1,y2B, x R y1 x R y2 y1 = y2.
Example 3: Let R Z x Z such that…
(i) x R y iff y = x2.
Q: Is R a function?
A: Yes.
(ii) x R y iff x = y2.
Q: Is R a function?
A: No. (1st and 2nd Condition violated)
Z Z
3 ?
1 1
-1
15
3. Examples
Functions in real life:1. Hamming distance function (p351).
2. Encoding/decoding functions (p351).
3. Boolean functions (p352).
4. A program is a function.
16
Eg. 3: F Z x {0,1}, a F b iff (a is even b=1) (a is odd b=0)
4. Notation
We usually use “f,g,h,F,G,H” to denote functions. If the relation f A x B is a function, we write it as:
f : A B If there is a way to compute yB from any given
xA, we usually write ‘f(x)’ in place of ‘y’.
We will write it as:Eg. 1: F Z x Z , x F y iff y = x2. ‘F’ is a function.
F : Z Z, F(x) = x2
We will write it as:Eg. 2: F Z x Z , x F y iff y = x2 + 2x + 1
F : Z Z, F(x) = x2 + 2x + 1
F : Z {0,1}, F(x) =
1, if x is even
0, otherwise
17
4. Notation
We usually use “f,g,h,F,G,H” to denote functions. If the relation f A x B is a function, we write it as:
f : A B If there is a way to compute yB from any given
xA, we usually write ‘f(x)’ in place of ‘y’.
Therefore, the definitions instead of…
1. xA, yB, x R y
2. xA, y1,y2B, x R y1 x R y2 y1=y2.
1. xA, yB, y = f(x)
2. xA, y1,y2B, y1=f(x) y2=f(x) y1=y2.
… can be also expressed as…
18
5. The identity function.
The identity function on any given set, is a function that maps every element to itself.
idA : A A, xA, idA(x) = x
19
Overview
Functions– Definition– Visualization Tool– Examples– Notation– Identity Function
Definitions– Domain, codomain,
range– Image, inverse image– Let f:A B and let S A
and T B.• S InvImgf(Imgf(S))
• Imgf(InvImgf(T)) T
Operations on Functions– Set related (,,):
1. If fg is a function, then f = g2. If fg is a function, then f = g3. If fg is a function, then fg=
– Inverse– Composition– Theorems
1. g f is a function.
2. f idA idB f f3. (h g) f = h (g f)4. (g f)-1 = f-1 g-1
Special Kinds of Functions– Injective, Surjective,
Bijective– Theorems
• Preservation under ‘’.• On inverses
Multi-argument functions
20
6. Definition: domain, codomain, range
Given a function: f : A B,– The set A is known as the domain of f.– The set B is known as the codomain of f.– The set { yB | xA, y=f(x)} is known as the
range of f.
A Bf
21
6. Definition: domain, codomain, range
Given a function: f : A B,– The set A is known as the domain of f.– The set B is known as the codomain of f.– The set { yB | xA, y=f(x)} is known as the
range of f.
A Bf
Domain(f)
22
6. Definition: domain, codomain, range
Given a function: f : A B,– The set A is known as the domain of f.– The set B is known as the codomain of f.– The set { yB | xA, y=f(x)} is known as the
range of f.
A Bf
Codomain(f)
23
6. Definition: domain, codomain, range
Given a function: f : A B,– The set A is known as the domain of f.– The set B is known as the codomain of f.– The set { yB | xA, y=f(x)} is known as the
range of f.
A Bf
Range(f)
NOTE:
range(f) codomain(f)
24
6. Definition: domain, codomain, range
Given a function: f : A B,– The set A is known as the domain of f.– The set B is known as the codomain of f.– The set { yB | xA, y=f(x)} is known as the
range of f.
Example 1: f : Z Z+, f(x) = |2x|
a. domain(f) = Z
b. codomain(f) = Z+
c. range(f) = positive even numbers: {2x | x Z+}
25
6. Definition: domain, codomain, range
Given a function: f : A B,– The set A is known as the domain of f.– The set B is known as the codomain of f.– The set { yB | xA, y=f(x)} is known as the
range of f.
Example 2:
Let f : Z Z, f(x) = 2x + 1; g : Z Z, g(x) = 2x - 1
Then range(f) = range(g).
Range(f) = 2x+1 = 2(x+1) – 1 = Range(g)
xZ, f(x) = g(x+1)
26
7. Definition: Image, Inverse Image.
Given a function: f : A B, and S A– The image of S is defined as:
Imgf(S) = { yB | xS, y=f(x)}
A Bf
27
7. Definition: Image, Inverse Image.
Given a function: f : A B, and S A– The image of S is defined as:
Imgf(S) = { yB | xS, y=f(x)}
S
Image of S
NOTE: Imgf(S) range(f) codomain(f)
A Bf
28
7. Definition: Image, Inverse Image.
Given a function: f : A B, and S A– The image of S is defined as:
Imgf(S) = { yB | xS, y=f(x)} Given a function: f : A B, and T B
– The inverse image of T is defined as:
InvImgf(T) = { xA | yT, y=f(x)}
Inverse image of T
TA B
f
29
7. Definition: Image, Inverse Image.
Given a function: f : A B, and S A– The image of S is defined as:
Imgf(S) = { yB | xS, y=f(x)} Given a function: f : A B, and T B
– The inverse image of T is defined as:
InvImgf(T) = { xA | yT, y=f(x)}
Example: f : Z Z+, f(x) = |x|
a. Imgf({10,-20}) = {10,20}
b. InvImgf({10,20}) = {10, 20, -10, -20}
30
7. Definition: Image, Inverse Image.
Given a function: f : A B, and S A– The image of S is defined as:
Imgf(S) = { yB | xS, y=f(x)}or
yImgf(S) iff xS and y=f(x)
Given a function: f : A B, and T B– The inverse image of T is defined as:
InvImgf(T) = { xA | yT, y=f(x)}or
xInvImgf(T) iff yT and y=f(x)
Axiomatic definition
31
7.1 Theorem: Image, Inverse Image.
Given any function: f : A B, S A, T B1. S InvImgf(Imgf(S))
2. Imgf(InvImgf(T)) T
A Bf
Proof of (1): (Use diagrams to help visualise!)
32
7.1 Theorem: Image, Inverse Image.
A Bf
S
Proof of (1): (Use diagrams to help visualize!)
Given any function: f : A B, S A, T B1. S InvImgf(Imgf(S))
2. Imgf(InvImgf(T)) T
33
7.1 Theorem: Image, Inverse Image.
A Bf
S
Proof of (1):
Given any function: f : A B, S A, T B1. S InvImgf(Imgf(S))
2. Imgf(InvImgf(T)) T
Assume xS
Therefore xInvImgf(Imgf(S))
Then yB such that y = f(x) (Since f is a function)
Therefore yImgf(S) (Defn: yImgf(S) iff xS and y=f(x))
xy
Therefore yImgf(S) and y = f(x)
Imgf(S)
34
7.1 Theorem: Image, Inverse Image.
A Bf
Imgf(S)
Proof of (1):
Given any function: f : A B, S A, T B1. S InvImgf(Imgf(S))
2. Imgf(InvImgf(T)) T
Assume xS
Therefore xInvImgf(Imgf(S))
Then yB such that y = f(x) (Since f is a function)
Therefore yImgf(S) (Defn: yImgf(S) iff xS and y=f(x))
Therefore yImgf(S) and y = f(x)
(Defn:xInvImgf(T) iff
yT and y=f(x))
xy
35
7.1 Theorem: Image, Inverse Image.
…Proof of (2) left as an exercise…
(Again, the skill that you must pick up is that you must use diagrams wherever
possible, to help visualize the problem and use it to help you reason about proofs)
Given any function: f : A B, S A, T B1. S InvImgf(Imgf(S))
2. Imgf(InvImgf(T)) T
36
Overview
Functions– Definition– Visualization Tool– Examples– Notation– Identity Function
Definitions– Domain, codomain,
range– Image, inverse image– Let f:A B and let S A
and T B.• S InvImgf(Imgf(S))
• Imgf(InvImgf(T)) T
Operations on Functions– Set related (,,):
1. If fg is a function, then f = g2. If fg is a function, then f = g3. If fg is a function, then fg=
– Inverse– Composition– Theorems
1. g f is a function.
2. f idA idB f f3. (h g) f = h (g f)4. (g f)-1 = f-1 g-1
Special Kinds of Functions– Injective, Surjective,
Bijective– Theorems
• Preservation under ‘’.• On inverses
Multi-argument functions
37
8. Operations on Functions.
A function is a (special) relation. A relation is a set (of ordered pairs). Therefore, all definitions and operations
on sets and relations are extended over to functions.
38
8.1 Equality of Functions
Given 2 functions, f : A B, g : A B,
f = g iff f g and g f Or, in cases where y can be computed directly
from x:
f = g iff
xA, y1=f(x) y2=g(x) y1=y2
Which is equivalent to:
f = g iff xA, f(x) = g(x)
39
8.2 Union, Intersection, Difference
Given 2 functions, f : A B, g : A B, f g, f g, fg are defined as accordingly in set theory (since functions are sets).…Or, in cases where y can be computed directly from x:– (fg)(x) = y iff y = f(x) or y g(x)
– (fg)(x) = y iff y = f(x) and y g(x)
– (fg)(x) = y iff y = f(x) and y g(x)
NOTE: f g, f g, fg need not necessarily be functions. At most, one can only conclude that f g, f g, fg are relations. In order to assert that they are functions, one must prove that the 2 conditions necessary for functions are true.
40
8.2 Union, Intersection, Difference
Theorem: Given 2 functions f and g from A to B,1. If f g is a function, then f = g2. If f g is a function, then f = g3. If fg is a function, then f g =
Proof of (1): (Direct proof: f = g iff xA, f(x) = g(x)
A Bf
x
A Bg
x
A Bf g
x
y1
y2
y2
y1But fg is a function!
Defn:y1= (fg)(x) and y2= (fg)(x) then y1=y2.
41
8.2 Union, Intersection, Difference
Theorem: Given 2 functions f and g from A to B,1. If f g is a function, then f = g2. If f g is a function, then f = g3. If fg is a function, then f g =
Proof of (1): (Direct proof: f = g iff xA, f(x) = g(x)Let xA.
Since f is a function, then y1B, y1= f(x), (x,y1)f
Since g is a function, then y2B, y2= g(x), (x,y2)g
Therefore (x,y1) f g and (x,y2) f g.
i.e. y1f g)(x) and y2 f g)(x)
But since fg is a function, then y1=y2 .
Therefore f(x) = g(x) (By definition of function equality)
42
8.2 Union, Intersection, Difference
Theorem: Given 2 functions f and g from A to B,1. If f g is a function, then f = g2. If f g is a function, then f = g3. If fg is a function, then f g =
Proof of (3): (By contradiction)
A Bf g
x y
A B f
x y
A B g
x y
A B f-g
x
43
8.2 Union, Intersection, Difference
Theorem: Given 2 functions f and g from A to B,1. If f g is a function, then f = g2. If f g is a function, then f = g3. If fg is a function, then f g =
Proof of (3): (By contradiction)
Assume that f g
Then by definition, (x,y) f g
That means that (x,y) f and (x,y) g
That means that (x,y) (f – g).
But f – g is a function! xA, yB, y = (f – g)(x). So there must be a (x,y) (f – g) =>
Contradiction!
Therefore f g .
44
8.2 Union, Intersection, Difference
Theorem: Given 2 functions f and g from A to B,1. If f g is a function, then f = g2. If f g is a function, then f = g3. If fg is a function, then f g =
Proof of (2) left as an exercise
Similar to Proof of (1).
45
8.3 Definition: Inverse of a function
Given a function, f : A B, the inverse of a function is defined in the same way as that of a relation:
f-1 = { (y,x) | (x,y) f }
NOTE: f-1 need not necessarily be a function. It is first and foremost, a relation. In order to assert that they are functions, one must prove that the 2 conditions necessary for functions are true. So
f-1 B x A
If f-1 is a function, then we write:
f-1 : B A
… and then say that:
f(x) = y iff f-1(y) = x
46
8.3 Definition: Inverse of a function
Find the inverse of the function f(x) = (1+x)/(1-x).
Ans:– Let y = (1+x)/(1-x). Express x in terms of y.
– Therefore: y – yx = 1 + x
– Therefore: y – 1 = yx + x
– Therefore: x(y+1) = y–1
– Therefore: x = (y–1)/(y+1)
– Therefore: f-1(y) = (y–1)/(y+1)
– i.e. f-1(x) = (x–1)/(x+1)
47
8.4 Definition: Composition of functions
Given 2 functions, f : A B, g : B C, then the composition of function ‘g o f’ is defined (in the same way as relation composition) as:
g o f = { (x,z) | yB, (x,y)f (y,z)g}
Or,
z = (g o f)(x) iff yB, y = f(x) z = g(y)
And since f and g are functions, y if it exists, must be unique. So:
(g o f)(x) = g(f(x))
48
8.5 Properties of function composition
Given any functions, f : A B, g : B C, h : C D,1. g o f is a function. (o preserves function property)
2. f o idA idB o f f3. (h o g) o f = h o (g o f) (From relations: o is associative)4. (g o f)-1 = f-1 o g-1 (From relations)
Since a function is a relation, there’s no need to prove (3) and (4) since the properties of (3) and (4) are proven in the lecture on relations.
49
8.5 Properties of function composition
Given any functions, f : A B, g : B C, h : C D,1. g o f is a function. ( o preserves function property)
2. f o idA idB o f f3. (h o g) o f = h o (g o f) (From relations: o is associative)4. (g o f)-1 = f-1 o g-1 (From relations)
Proof of (1): Let f : A B, g : B C. Is g o f a function?
Proof of condition 1: xA, zC, z = (g o f)(x) Let xA. Then yB, y = f(x) (Since f is a function) Also, zC, z = g(y) (Since g is a function) Therefore zC, z = g(f(x)) Therefore zC, z = (g o f)(x)
50
8.5 Properties of function composition
Given any functions, f : A B, g : B C, h : C D,1. g o f is a function. (o preserves function property)
2. f o idA idB o f f3. (h o g) o f = h o (g o f) (From relations: o is associative)4. (g o f)-1 = f-1 o g-1 (From relations)
Proof of (1): Let f : A B, g : B C. Is g o f a function?
Proof of condition 2:
xA, z1=(g o f)(x) z2=(g o f)(x) z1=z2.
Let z1=(g o f)(x) z2=(g o f)(x)
z1=g(f(x)) z2=g(f(x)) (Defn of composition)
z1=g(y) z2=g(y) (Since f is a function)
z1=z2. (Since g is a function)Yes, g o f Is a function.
51
8.5 Properties of function composition
Given any functions, f : A B, g : B C, h : C D,1. g o f is a function. (o preserves function property)2. f o idA idB o f f3. (h o g) o f = h o (g o f) (From relations: o is associative)4. (g o f)-1 = f-1 o g-1 (From relations)
Proof of (2):
(f o idA)(x) = f (idA(x)) (since aA, idA(a) = a)
= f(x)
(idB o f )(x)= idB(f(x)) (since bB, idB(b) = b)
= f(x)
Therefore f o idA idB o f f.
52
Overview
Functions– Definition– Visualization Tool– Examples– Notation– Identity Function
Definitions– Domain, codomain,
range– Image, inverse image– Let f:A B and let S A
and T B.• S InvImgf(Imgf(S))
• Imgf(InvImgf(T)) T
Operations on Functions– Set related (,,):
1. If fg is a function, then f = g2. If fg is a function, then f = g3. If fg is a function, then fg=
– Inverse– Composition– Theorems
1. G o f is a function.
2. F o idA idB o f f3. (h o g) o f = h o (g o f)4. (g o f)-1 = f-1 o g-1
Special Kinds of Functions– Injective, Surjective,
Bijective– Theorems
• Preservation under ‘o’.• On inverses
Multi-argument functions
53
9. Special Kinds of functions
Three types of functions:– Injective (1-1)– Surjective (onto)– Bijective (1-1 correspondence)
54
9.1 Injective (1-1) Functions
Definition: Let f : A B. f is injective (or one-to-one) iff
x1,x2A, f(x1) = f(x2) x1 = x2
A Bf
x1
x2
55
9.1 Injective (1-1) Functions
Definition: Let f : A B. f is injective (or one-to-one) iff
x1,x2A, f(x1) = f(x2) x1 = x2
A Bf
x1
x2
An element in B can only receive from at most one element in A.
56
9.1 Injective (1-1) Functions
Definition: Let f : A B. f is injective (or one-to-one) iff
x1,x2A, f(x1) = f(x2) x1 = x2
NOTE: This is different from saying:
x1,x2A, x1 = x2 f(x1) = f(x2)
A Bf
x1x2
57
9.1 Injective (1-1) Functions
Definition: Let f : A B. f is injective (or one-to-one) iff
x1,x2A, f(x1) = f(x2) x1 = x2
NOTE: This is different from saying:
x1,x2A, x1 = x2 f(x1) = f(x2)
A Bf
x1x2
An element in A can only send to at most one element in B.
(2nd cond of function)
58
9.1 Injective (1-1) Functions
Definition: Let f : A B. f is injective (or one-to-one) iff
x1,x2A, f(x1) = f(x2) x1 = x2
Q: Is f an injection?
A: No.
BA
x1
x2
f
Examples:
59
9.1 Injective (1-1) Functions
Definition: Let f : A B. f is injective (or one-to-one) iff
x1,x2A, f(x1) = f(x2) x1 = x2
Q: Is f an injection?
A: Yes.
A
x1
x2
Bf
Examples:
60
9.1 Injective (1-1) Functions
Definition: Let f : A B. f is injective (or one-to-one) iff
x1,x2A, f(x1) = f(x2) x1 = x2
Examples:
f : Z Z, f(x) = x2
Q: Is f an injection?
A: No.
A
1
-1
Bf
1F(1) = F(-1) but 1 -1
61
9.1 Injective (1-1) Functions
Definition: Let f : A B. f is injective (or one-to-one) iff
x1,x2A, f(x1) = f(x2) x1 = x2
Examples:
Q: Is f an injection?
A: No.
f : Z Z, f(x) =
x – 1 if x >= 0
x if x<0
A-2
Bf
0-1012
1
-1F(0) = F(-1) but 0 1
62
9.1 Injective (1-1) Functions
Definition: Let f : A B. f is injective (or one-to-one) iff
x1,x2A, f(x1) = f(x2) x1 = x2
Examples:
f : Z Z, f(x) = 3x+2
Q: Is f an injection?
A: Yes. Proof:
Assume f(a) = f(b)3a+2 = 3b+2a=b A Bf
-1012
-1258
63
9.2 Surjective (onto) Functions
Definition: Let f : A B. f is surjective (or onto) iff
yB, xA, f(x) = y
A B
f
Again, note that this is different from saying:
xA, yB, f(x) = y
(This is 1st condition of a function)
(“Every girl is loved by some boy”)
(“Every boy loves some girl”)
(Boys) (Girls)
64
9.2 Surjective (onto) Functions
Definition: Let f : A B. f is surjective (or onto) iff
yB, xA, f(x) = y Or,
Codomain(f) = Range(f)
Q: Is f a surjection?
A: No.
Examples:
A
a
b
Bf
65
9.2 Surjective (onto) Functions
Definition: Let f : A B. f is surjective (or onto) iff
yB, xA, f(x) = y Or,
Codomain(f) = Range(f)
Q: Is f a surjection?
A: Yes.
A
a
b
Bf
Examples:
66
9.2 Surjective (onto) Functions
Definition: Let f : A B. f is surjective (or onto) iff
yB, xA, f(x) = y Or,
Codomain(f) = Range(f)
Examples:
f : Z Z, f(x) = x2
Q: Is f a surjection?
A: No.
yB, xA, f(x) y. Take y = -1.
-1?
67
9.2 Surjective (onto) Functions
Definition: Let f : A B. f is surjective (or onto) iff
yB, xA, f(x) = y Or,
Codomain(f) = Range(f)
Examples:
f : Z Znonneg, f(x) = x2
Q: Is f a surjection?
A: No.
yB, xA, f(x) y. Take y = 3.
3?1
24
1
68
9.2 Surjective (onto) Functions
Definition: Let f : A B. f is surjective (or onto) iff
yB, xA, f(x) = y Or,
Codomain(f) = Range(f)
Examples:
Q: Is f a surjection?
A: No.
yB, xA, f(x) y. Take y = 0.
0?-1
01
-1
f : Z Z, f(x) =x+1 if x>=0
x otherwise
69
9.2 Surjective (onto) Functions
Definition: Let f : A B. f is surjective (or onto) iff
yB, xA, f(x) = y Or,
Codomain(f) = Range(f)
Examples:
f : R R, f(x) = 4x-1
Take any y, where y = 4x + 1.
There exist an x, where x = (y-1)/4 (which is in R)
Q: Is f a surjection?
A: Yes.
70
9.2 Surjective (onto) Functions
Definition: Let f : A B. f is surjective (or onto) iff
yB, xA, f(x) = y Or,
Codomain(f) = Range(f)
Examples:
f : Z Z, f(x) = 4x-10?
-1
03
-5
yB, xA, f(x) y. Take y = 0.
Q: Is f a surjection?
A: No.
71
9.2 Surjective (onto) Functions
Application– Pigeon-Hole Principle (Later)– Hashing
• Static Hashing• Dynamic Hashing
– Linear Hashing– Extendible Hashing
(Database Management Systems Course)
72
9.3 Bijective Functions
Definition: Let f : A B. f is bijective (or 1-1 correspondence) iff– f is injective (1-1); and– f is surjective (onto)
Not injective, Not surjective
Injective, but not surjective
Not injective, but surjective
Injective AND surjective = bijective
73
9.3 Bijective Functions
Application:– Cardinality (Next lecture)
74
9.4.1 Theorem (preservation under composition)
Theorem (preservation under composition): Given f : AB and g : BC,
1. If f and g are injective, then (g o f) is injective.
2. If f and g are surjective, then (g o f) is surjective.
3. If f and g are bijective, then (g o f) is bijective.
4. The converse of the above 3 statements is not true
Proof of (1): x1,x2A, (g o f)(x1) = (g o f)(x2) x1 = x2
(g o f)(x1) = (g o f)(x2)g(f(x1))= g(f(x2)) (By defn of composition)f(x1) = f(x2) (Since g is injective)x1 = x2 (Since f is injective)
75
9.4.1 Theorem (preservation under composition)
Theorem (preservation under composition): Given f : AB and g : BC,
1. If f and g are injective, then (g o f) is injective.
2. If f and g are surjective, then (g o f) is surjective.
3. If f and g are bijective, then (g o f) is bijective.
4. The converse of the above 3 statements is not true
f g
g o f
Converse of (1) is not true.
g o f is injective.
But g is not injective.
76
9.4.1 Theorem (preservation under composition)
Theorem (preservation under composition): Given f : AB and g : BC,
1. If f and g are injective, then (g o f) is injective.
2. If f and g are surjective, then (g o f) is surjective.
3. If f and g are bijective, then (g o f) is bijective.
4. The converse of the above 3 statements is not true
Proof of (2): (cC, aA, (g o f)(a) = c)
Let cC
Since g is surjective, then bB, g(b) = c
Since f is surjective, then aA, f(a) = b
Therefore aA, bB, f(a) = b and g(b) = c
Therefore aA, g(f(a)) = c
Therefore aA, (g o f)(a) = c
77
9.4.1 Theorem (preservation under composition)
Theorem (preservation under composition): Given f : AB and g : BC,
1. If f and g are injective, then (g o f) is injective.
2. If f and g are surjective, then (g o f) is surjective.
3. If f and g are bijective, then (g o f) is bijective.
4. The converse of the above 3 statements is not true
f g
g o f
Converse of (2) is not true.
g o f is surjective
But f is not surjective.
78
9.4.1 Theorem (preservation under composition)
Theorem (preservation under composition): Given f : AB and g : BC,
1. If f and g are injective, then (g o f) is injective.
2. If f and g are surjective, then (g o f) is surjective.
3. If f and g are bijective, then (g o f) is bijective.
4. The converse of the above 3 statements is not true
Proof of (3):
Since f and g are both bijective, then by definition, f and g are both injective and surjective.
By previous two theorems, g o f is injective.and also g o f is surjective
Therefore, g o f is bijective.
(The converse is not true. It follows from the previous 2 counter-examples.)
79
9.4.2 Theorem (On inverses)
Theorem: Given f : A B,
If f is a bijection, then f-1 is a function from B to A.
Proof:
(a) To show 1st condition: Every element in B must map to some element in A.
Assume any y B,
Since f is surjective (due to the fact that f is bijective), then xA such that f(x) = y.
So xA such that x = f-1(y)
A B
80
9.4.2 Theorem (On inverses)
Theorem: Given f : A B,
If f is a bijection, then f-1 is a function from B to A.
Proof:
(b) To show 2nd condition: An element in B must map to at most one element in A.
Assume f-1(y) = x1 and f-1(y) = x2
Then f(x1) = y and f(x2) = y
Since f is injective (due to the fact that f is bijective), then x1 = x2
A B
81
9.4.3 Theorem (On inverses)Theorem: Given f : A B,
1. If f is a bijection, then f-1 is a bijection.2. If f is a bijection, then
a. f-1 o f = idA
b. f o f-1 = idB
Proof of (1):
(a) To show is f-1 injective (1-1)
Assume f-1(y1) = f-1(y2) = x
Then x = f-1(y1) and x = f-1(y2)
Therefore f(x) = y1 and f(x) = y2
Therefore y1 = y2 (Since f is a function)
82
9.4.3 Theorem (On inverses)Theorem: Given f : A B,
1. If f is a bijection, then f-1 is a bijection.2. If f is a bijection, then
a. f-1 o f = idA
b. f o f-1 = idB
Proof of (1):
(b) To show is f-1 surjective (onto)
(aA, bB, f-1(b) = a)
Assume aA
Since f is a function, therefore bB, f(a) = b
bB, f-1(b) = a.
83
9.4.3 Theorem (On inverses)Theorem: Given f : A B,
1. If f is a bijection, then f-1 is a bijection.2. If f is a bijection, then
a. f-1 o f = idA
b. f o f-1 = idB
Proof of (2a):
(f-1 o f)(x) = f-1(f(x))
Let x’ = f-1(f(x)).
Then f(x’) = f(x) (Since f-1(b) = a iff f(a) = b)
So x’ = x (Since f is a bijection)
Therefore x = f-1(f(x)). Meaning that: (f-1 o f)(x) = x.
So f-1 o f = idA
84
9.4.3 Theorem (On inverses)Theorem: Given f : A B,
1. If f is a bijection, then f-1 is a bijection.2. If f is a bijection, then
a. f-1 o f = idA
b. f o f-1 = idB
Proof of (2b):
(f o f-1)(x) = f (f-1(x))
Let y’ = f (f-1(y)).
Then f-1(y) = f-1(y’) (Since f-1(b) = a iff f(a) = b)
So y = y’ (Since f-1 is a bijection)
Therefore y = f (f-1(y)). Meaning that: (f o f-1)(y) = y.
So f o f-1 = idB
85
10. Multi-argument functions
In general, a function can take in more than 1 argument.
f : (A x B) C Example:
f : (Z x Z) Z , where f(x,y) = 2x + 3y f is a function:
– Condition 1: Every element in (Z x Z) is mapped to some element in Z.
– Condition 2: The mapping is a unqiue mapping: if f(x,y) = j and f(x,y) = k, then it must be true that j = k.
86
10. Multi-argument functions
Example:
f : (Z x Z) Z , where f(x,y) = 2x + 3y
(0,0)(0,1)(1,0)
(0,-1)
123
0-1-2
87
10. Multi-argument functions
Multi-argument functions can be expressed as functions to functions.
Example:
f : Z (Z Z) , where f x y = 2x + 3y
012
-1 01
-103
-3
01
-125
-1
88
10. Multi-argument functions
Multi-argument functions can be expressed as functions to functions.
Example:
f : Z (Z Z) , where f x y = 2x + 3y
The result of a applying a function to an argument is another function!!!
Expressing multi-argument functions in this way is known as ‘currying’.
Taught in courses on programming language theory
89
End of Lecture