Relations.. and counting.
s Given two sets A = {,, } B = {,,, 4} Their A B = {(, ), (, ), (, ), (, ), (, ), (, ), (, ), (, ), (, ), (, 4), (, 4), (, 4)} Question: What is the cartesian product of? ( is the set of all integers) p.
= (, ) (, 0) Origin (0, 0) All pairs of integers are in, for emaple (, ) (, ) p.
Is it a? p. 4
of p. 5
Is it a? p. 6
of = p. 7
Is it a? (, 0) (, 0) p. 8
Is it a? No (, 0) (, 0) R = (, ) ma(, ) = p. 9
Is it a? No (, 0) (, 0) A subset R of a Cartesian product is called a relation. p. 0
Relations Given an two sets A = {,,, } and B = {,,,...} Def. A subset R of the A B is called a relation from the set A to the set B. R = (, 99), (, 5), (, 0 5 ), (, ), (, 5) A B p.
Relations Eample of a relation: S = set of students C = set of classes R = {(s, c) student s takes class c} Alice Bob Eve Mark CS 50 CS 5 Math 54 Hist 5 Zack p.
Airline route map We connect two cities if the airline operates a flight from one to the other. Is it a relation? p.
Airline route map Routes Cities Cities p. 4
Airline route map p. 5
An subset of A B is a relation R R = (, ), (, ), (, ), (, ), (, ), (, ), (0, ), (, ), (, ) p. 6
An subset of A B is a relation (, ) R R = (, ) ( +) +( ) p. 7
A function is a relation too! R R = (, ) = f () p. 8
Relation {(, ) = } 0 0 p. 9
Relation {(, ) = rem } 0 0 p. 0
Def. A relation R A B is a function (a functional relation) if for ever a A, there is at most one b B so that (a, b) R. A = {,, }, B = {,,, 4} R = {(, ), (, ), (, )} R = {(, ), (, ), (, 4), (, ), (, 4), (, 4)} R = {(, ), (, ), (, 4)} Not a function 4 4 4 p.
Functional relation R A B defines a unique wa to map each 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 A f B p.
Def. For the function f : A B, set A is called domain, and set B is called codomain. 4 f : A B z domain(f ) = A = {,, z} codomain(f ) = B = {,,, 4} image(f ) = f (A) = {, } Def. f (a) is the image of a point a A. Def. The image of a function f, denoted b f (A), is the set of all images of all points a A f (A) = { a A (f (a) = )}. The image of a function is also called range. p.
Onto Def. A function f : A B is called onto if and onl if for ever 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 w w v v p. 4
One-to-one Def. A function f : A B is said to be one-to-one if and onl if f () = f () implies that = for all, A. f : A B is one-to-one g : B C is not one-to-one z 4 4 /7 /6 w /5 0 0 p. 5
Def. The function f is a bijection (also called one-to-one correspondence) if and onl 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 w w v 0 v 0 p. 6
f : A B is one-to-one, but not onto g : C D is onto, but not one-to-one z 4 z w w 0 v 0 So, both functions are not bijections. p. 7
. Observation Rule. Given two sets A and B, if there eists a bijection f : A B, then A = B. z w v 4 0 We can count the size of the set A, instead of the size of B! p. 8
Rule. Consider two similar problems: (a) How man bit strings contain eactl three s and two 0s? 00 (b) How man strings can be composed of three A s and five b s so that an A is alwas followed b a b? AbAbbAbb We show that this two problems are equivalent b constructing a bijection. p. 9
Rule. Let X be the set of bit strings X = {00,...} and Y be the set of A and b strings Y = {AbAbbAbb,...} We can construct a bijection f : X Y : gets replaced b Ab 0 gets replaced b b p. 0
Rule. f : 00 Ab Ab Ab b b 00 Ab Ab b Ab b 00 Ab Ab b b Ab 00 Ab b Ab Ab b 00 Ab b Ab b Ab 00 Ab b b Ab Ab 00 b Ab Ab Ab b 00 b Ab Ab b Ab 00 b Ab b Ab Ab 00 b b Ab Ab Ab Function f is one-to-one and onto, so it is a bijection. Therefore, the cardinalities of two sets are equal: X = Y = 5 = 0. p.
. Observation Observation For ever bijection f : A B, eists an inverse function f : B A f : A B z w v 4 0 The inverse function is a bijection too. p.
. Observation Observation For ever bijection f : A B, eists an inverse function f : B A f : A B f : B A z 4 4 z w w v 0 0 v The inverse function is a bijection too. p.
. Observation Given two bijections f : A B and g : B C. Consider their composition h() = g(f ()) f : A B g : B C z 4 4 4/5 /5 /5 w /5 h : A C is a bijection, and therefore A = C. p. 4
. Observation Given two bijections f : A B and g : B C. Consider their composition h() = g(f ()) f : A B g : B C h : A C z 4 4 4/5 z 4/5 /5 /5 /5 /5 w /5 w /5 h : A C is a bijection, and therefore A = C. p. 5
. Counting subsets Please, count the number of subsets of a set A = {a, b, c, d, e} b reducing the problem to counting bit strings. Let s find a bijection between the power set (A) = {, {a}, {b},...} and the set of bit stings of length 5: {0, } 5 = {00000, 0000, 0000, 000,...} p. 6
. Counting subsets Please, count the number of subsets of a set A = {a, b, c, d, e} b reducing the problem to counting bit strings. Let s find a bijection f between the power set (A) = {, {a}, {b},...} and the set of bit stings of length 5: {0, } 5 = {00000, 0000, 0000, 000,...} p. 7
. Counting subsets f : ({a, b, c, d, e}) {0, } 5 0s and s encode the membership of the five elements of {a, b, c, d, e} f : 00000 {a} 0000 {b} 0000 {a, b} 000 {c} 0000 {a, c} 000 {b, c} 000 {a, b, c} 00...skipping um.. subsets {a, b, c, d, e} The cardinalit {0, } 5 = 5 = Therefore, b the bijection rule, (A) = 5 p. 8
principle 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 Of course, it can! A... A n = A +... + A n something? p. 9
principle 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 Of course, it can! A... A n = A +... + A n something? p. 40
principle Union of three sets A A A = A + A + A A A A A A A + A A A {,, } {,, 4} {, 4, } = + + + = 4 p. 4
principle Union of n sets A... A n = the sum of the sizes of the individual sets minus the sizes of all two-wa intersections plus the sizes of all three-wa intersections minus the sizes of all four-wa intersections plus the sizes of all five-wa intersections etc. p. 4