Relations. Functions. Bijection and counting. Cartesian products Cartesian product
Functions
Bijection Given two sets Inclusion-Exclusion A = 1, 2, 3 { } B = 1, 2, 3, 4 { } Their Cartesian product
A B = (1, 1), (2, 1), (3, 1), × { (1, 2), (2, 2), (3, 2), (1, 3), (2, 3), (3, 3), (1, 4), (2, 4), (3, 4) }
Question: What is the cartesian product of Z Z? × (Z is the set of all integers)
p. 2 2 Cartesian product Z Z = Z × Cartesian product Functions
Bijection y Inclusion-Exclusion
(1, 2) All pairs of 2 integers are in Z , x for exmaple ( 3, 0) Origin (0, 0) 2 − (1, 2) Z ∈
( 1, 3) − −
p. 3 Is it a Cartesian product? Cartesian product
Functions
Bijection y Inclusion-Exclusion
x
p. 4 Cartesian product of Z N × Cartesian product Functions
Bijection y Inclusion-Exclusion
x
p. 5 Is it a Cartesian product? Cartesian product
Functions
Bijection y Inclusion-Exclusion
x
p. 6 2 Cartesian product of N N = N × Cartesian product Functions
Bijection y Inclusion-Exclusion
x
p. 7 Is it a Cartesian product? Cartesian product
Functions
Bijection y Inclusion-Exclusion
x ( 2, 0) (2, 0) −
p. 8 Is it a Cartesian product? No Cartesian product
Functions
Bijection y Inclusion-Exclusion
x ( 2, 0) (2, 0) −
2 2 R = (x, y) Z max( x , y ) = 2 Z ∈ | | | | ⊆
p. 9 Is it a Cartesian product? No Cartesian product
Functions
Bijection y Inclusion-Exclusion
x ( 2, 0) (2, 0) −
A subsetR Z Z of a Cartesian product is⊆ called× a relation.
p. 10 Relations Cartesian product
Functions
Bijection
Inclusion-Exclusion
Given any two sets
A = , , , and B = 1, 2, 3, . . . {♠ ♣ ♥ ♦} { }
Def. A subset R of the Cartesian product A B is called a relation from the set A to the set B. ×
5 R = ( , 99), ( , 15), ( , 10 ), ( , 1), ( , 15) A B ♠ ♥ ♣ ♣ ♣ ⊆ ×
p. 11 Relations Cartesian product
Functions Example of a relation: Bijection Inclusion-Exclusion
S = set of students
C = set of classes R = (s, c) student s takes class c { | } Alice CS 150
Bob CS 235
Eve Math 254
Mark Hist 152
Zack
p. 12 Airline route map Cartesian product
Functions
Bijection
Inclusion-Exclusion
We connect two cities if the airline operates a flight from one to the other. Is it a relation? p. 13 Airline route map Cartesian product
Functions
Bijection
Inclusion-Exclusion
Routes Cities Cities
⊆ × p. 14 Airline route map Cartesian product
Functions
Bijection
Inclusion-Exclusion
p. 15 Any subset of A B is a relation × Cartesian product Functions
Bijection y Inclusion-Exclusion
x
R Z Z ⊆ × R = ( 1, 2), (1, 2), ( 1, 1), − − (1, 1), ( 2, 1), ( 1, 2), − − − − (0, 2), (1, 2), (2, 1) − − −
p. 16 Any subset of A B is a relation × Cartesian product Functions
Bijection y Inclusion-Exclusion
( 1, 1) − x
R R R 2 2 R =⊆ (×x, y) R R (x +1) +(y 1) 2 ∈ × | − ≤
p. 17 A function is a relation too! Cartesian product
Functions
Bijection
y Inclusion-Exclusion
x
R R R R =⊆ (×x, y) R R y = f (x) ∈ × |
p. 18 Relation (x, y) y = x { | | |} Cartesian product Z Z Functions → Bijection y Inclusion-Exclusion 3 3 − − 2 2 − − 1 1 − − 0 0 x 1 1
2 2
3 3
p. 19 Relation (x, y) y = x rem 3 { | } Cartesian product Z Z Functions → Bijection y Inclusion-Exclusion 3 3 − − 2 2 − − 1 1 − − 0 0 x 1 1
2 2
3 3
p. 20 Functions Cartesian product
Functions Def. A relation R A B is a function (a functional relation) if for Bijection every a A, there⊆ is at× most one b B so that (a, b) R. Inclusion-Exclusion ∈ ∈ ∈ A = 1, 2, 3 , B = 1, 2, 3, 4 { } { }
R1 = (1, 1), (2, 2), (3, 3) { } R2 = (1, 2), (1, 3), (1, 4), (2, 3), (2, 4), (3, 4) Not a function { } ← R3 = (1, 2), (2, 3), (3, 4) { }
4 4 4
3 3 3 3 3 3
2 2 2 2 2 2
1 1 1 1 1 1
p. 21 Functions Cartesian product
Functions
Bijection Functional relation R A B defines a unique way to map each Inclusion-Exclusion element from the set A⊆to an× element from the set B.
There is a well-known and convenient notation for functions:
f (a) = b where a A and b B ∈ ∈
It maps elements from A to B:
f : A B → f A B −→
p. 22 Functions Cartesian product
Functions Def. For the function f : A B, set A is called domain, and set B Bijection is called codomain. → Inclusion-Exclusion 4 f : A B → z 3 domain(f ) = A = x, y, z y 2 { } codomain(f ) = B = 1, 2, 3, 4 image f f A {2, 3 } x ( ) = ( ) = 1 { } Def. f (a) is the image of a pointa A. ∈ Def. The image of a functionf , denoted by f (A), is the set of all images of all points a A ∈ f (A) = x a A (f (a) = x) . { | ∃ ∈ } The image of a function is also called range.
p. 23 Onto Cartesian product
Functions
Bijection A function f : A B is called onto if and only if for every Def. Inclusion-Exclusion element b B there is an→ element a A with f (a) = b. ∈ ∈
In other words, the image f (A) is the whole codomain B.
f : A B is onto g : A B is not onto → → z 4 z 4
y 3 y 3
x 2 x 2
w 1 w 1
v v
p. 24 One-to-one Cartesian product
Functions
Bijection Def. A function f : A B is said to be one-to-one if and only if Inclusion-Exclusion f (x) = f (y) implies that→ x = y for all x, y A. ∈
f : A B is one-to-one g : B C is not one-to-one → → z 4 4
y 3 3 1/7
x 2 2 1/6
w 1 1 1/5
0 0
p. 25 Bijection Cartesian product
Functions
Bijection Def. The function f is a bijection (also called one-to-one correspon- Inclusion-Exclusion dence) if and only if it is both one-to-one and onto.
f : A B is a bijection g : A B is not a bijection → → z 4 z 4
y 3 y 3
x 2 x 2
w 1 w 1
v 0 v 0
p. 26 Bijection Cartesian product
Functions
Bijection
Inclusion-Exclusion f : A B is one-to-one, but g : C D is onto, but not → not onto →one-to-one
z 4 z
y 3 y 3
x 2 x 2
w 1 w 1
0 v 0
So, both functions are not bijections.
p. 27 Bijection. Observation Cartesian product
Functions
Bijection Bijection Rule. Given two sets A and B, if there exists a bijection Inclusion-Exclusion
f : A B, then A = B . → | | | |
z 4
y 3
x 2
w 1
v 0
We can count the size of the set A, instead of the size of B!
p. 28 Bijection Rule. Cartesian product
Functions
Bijection
Inclusion-Exclusion Consider two similar problems:
(a) How many bit strings contain exactly three 1s and two 0s?
11010
(b) How many strings can be composed of three ‘A’s and five ‘b’s so that an ‘A’ is always followed by a ‘b’?
AbAbbAbb
We show that this two problems are equivalent by constructing a bijection.
p. 29 Bijection Rule. Cartesian product
Functions
Bijection
Inclusion-Exclusion Let X be the set of bit strings
X = 11010, . . . { } and Y be the set of ‘A’ and ‘b’ strings
Y = AbAbbAbb,... { } We can construct a bijection f : X Y : → 1 gets replaced by Ab 0 gets replaced by b
p. 30 Bijection Rule. Cartesian product
Functions
Bijection
Inclusion-Exclusion f : 11100 Ab Ab Abbb 11010 7→ Ab Abb Abb 11001 7→ Ab Abbb Ab 10110 7→ Abb Ab Abb 10101 7→ Abb Abb Ab 10011 7→ Abbb Ab Ab 01110 7→ b Ab Ab Abb 01101 7→ b Ab Abb Ab 01011 7→ b Abb Ab Ab 00111 7→ b b Ab Ab Ab 7→ Function f is one-to-one and onto, so it is a bijection. Therefore, 5 the cardinalities of two sets are equal: X = Y = 3 = 10. | | | | p. 31 Bijection. Observation Cartesian product
Functions Observation For every bijection f : A B, exists an inverse function Bijection → Inclusion-Exclusion 1 f − : B A → f : A B1 → z 4
y 3
x 2
w 1
v 0
The inverse function is a bijection too.
p. 32 Bijection. Observation Cartesian product
Functions Observation For every bijection f : A B, exists an inverse function Bijection → Inclusion-Exclusion 1 f − : B A → 1 1 f : A B f − : B A → → z 4 4 z
y 3 3 y
x 2 2 x
w 1 1 w
v 0 0 v
The inverse function is a bijection too.
p. 33 Bijection. Observation Cartesian product
Functions Given two bijections f : A B and g : B C. Bijection Consider their composition→ → Inclusion-Exclusion
h(x) = g(f (x))
f : A B g : B C → → z 4 4 4/5
y 3 3 3/5
x 2 2 2/5
w 1 1 1/5
h : A C is a bijection, and therefore A = C . → | | | | p. 34 Bijection. Observation Cartesian product
Functions Given two bijections f : A B and g : B C. Bijection Consider their composition→ → Inclusion-Exclusion
h(x) = g(f (x))
f : A B g : B C h : A C → → → z 4 4 4/5 z 4/5
y 3 3 3/5 y 3/5
x 2 2 2/5 x 2/5
w 1 1 1/5 w 1/5
h : A C is a bijection, and therefore A = C . → | | | | p. 35 Bijection. Counting subsets Cartesian product
Functions
Bijection
Inclusion-Exclusion Please, count the number of subsets of a set
A = a, b, c, d, e { } by reducing the problem to counting bit strings. Let’s find a bijection between the power set
(A) = ∅, a , b ,... P { { } { } } and the set of bit stings of length 5:
5 0, 1 = 00000, 00001, 00010, 00011, . . . { } { }
p. 36 Bijection. Counting subsets Cartesian product
Functions
Bijection
Inclusion-Exclusion Please, count the number of subsets of a set
A = a, b, c, d, e { } by reducing the problem to counting bit strings. Let’s find a bijection f between the power set
(A) = ∅, a , b ,... P { { } { } } and the set of bit stings of length 5:
5 0, 1 = 00000, 00001, 00010, 00011, . . . { } { }
p. 37 Bijection. Counting subsets Cartesian product
Functions
Bijection 5 f : ( a, b, c, d, e ) 0, 1 Inclusion-Exclusion P { } → { } 0s and 1s encode the membership of the five elements of a, b, c, d, e { } f : ∅ 00000 7→ a 10000 The cardinality {b} 7→ 01000 5 5 a{, b} 7→ 11000 0, 1 = 2 = 32 { } { c} 7→ 00100 Therefore, by the bijection { } 7→ a, c 10100 rule, {b, c} 7→ 01100
A 5 a{, b, c} 7→ 11100 ( ) = 2 P { . .} .skipping 7→ um.. 23 subsets a, b, c, d, e 11111 { } 7→ p. 38 Inclusion-Exclusion principle Cartesian product
Functions
Bijection
Inclusion-Exclusion
We remember the subtraction rule for the union of two sets
A B = A + B A B | ∪ | | | | | − | ∩ | Can it be generalized for a union of n sets
A1 ... An = A1 + ... + An something ? | ∪ ∪ | | | | | − 〈 〉 Of course, it can!
p. 39 Inclusion-Exclusion principle Cartesian product
Functions
Bijection
Inclusion-Exclusion
We remember the subtraction rule for the union of two sets
A B = A + B A B | ∪ | | | | | − | ∩ | Can it be generalized for a union of n sets
A1 ... An = A1 + ... + An something ? | ∪ ∪ | | | | | − 〈 〉 Of course, it can!
p. 40 Inclusion-Exclusion principle Cartesian product
Functions
Bijection
Inclusion-Exclusion
Union of three sets
A1 A2 A3 = A1 + A2 + A3 | ∪ ∪ | | | | | | | A1 A2 A2 A3 A1 A3 − | ∩ | − | ∩ | − | ∩ | + A1 A2 A3 | ∩ ∩ |
1, 2, 3 2, 3, 4 3, 4, 1 = 3 + 3 + 3 2 2 2 + 1 = 4 |{ } ∪ { } ∪ { }| − − −
p. 41 Inclusion-Exclusion principle Cartesian product
Functions
Bijection
Inclusion-Exclusion
Union of n sets
A1 ... An = the sum of the sizes of the individual sets | ∪ ∪minus| the sizes of all two-way intersections plus the sizes of all three-way intersections minus the sizes of all four-way intersections plus the sizes of all five-way intersections etc.
p. 42