Presentation is loading. Please wait.

Presentation is loading. Please wait.

CSE 20: Discrete Mathematics for Computer Science Prof. Shachar Lovett.

Similar presentations


Presentation on theme: "CSE 20: Discrete Mathematics for Computer Science Prof. Shachar Lovett."— Presentation transcript:

1 CSE 20: Discrete Mathematics for Computer Science Prof. Shachar Lovett

2 Today’s Topics: 1. Functions and set sizes 2. Infinite set sizes 2

3 1. Functions and set sizes 3

4 Set sizes  Let X,Y be finite sets, f:X  Y a function  Theorem: If f is injective then |X|  |Y|.  Try and prove yourself first 4

5 Set sizes  Let X,Y be finite sets, f:X  Y a function  Theorem: If f is injective then |X|  |Y|.  Proof by picture (not really a proof, just for intuition): 5 XY

6 Set sizes  Let X,Y be finite sets, f:X  Y a function  Theorem: If f is injective then |X|  |Y|.  Actual proof:  Consider the set S={(x,f(x)): x  X}. This is called that “graph of f”.  Since f is a function, each x  X appears exactly once, hence |S|=|X|.  Since f is injective, the values of f(x) are all distinct, i.e. each value y  Y appears in at most one pair. Hence |S|  |Y|.  So, |X|  |Y|.  QED. 6

7 Set sizes  Let X,Y be finite sets, f:X  Y a function  Theorem: If f is surjective then |X|  |Y|.  Try and prove yourself first 7

8 Set sizes  Let X,Y be finite sets, f:X  Y a function  Theorem: If f is surjective then |X|  |Y|.  Proof by picture (not really a proof, just for intuition): 8 XY

9 Set sizes  Let X,Y be finite sets, f:X  Y a function  Theorem: If f is surjective then |X|  |Y|.  Proof:  Consider again the set S={(x,f(x)): x  X}.  Since f is a function, each x  X appears exactly once hence |S|=|X|.  Since f is surjective, all values y  Y appear in at least one pair. So |S|  |Y|.  So, |X|  |Y|.  QED. 9

10 Set sizes  Let X,Y be finite sets, f:X  Y a function  Theorem: If f is bijective then |X|=|Y|.  Try and prove yourself first 10

11 Set sizes  Let X,Y be finite sets, f:X  Y a function  Theorem: If f is bijective then |X|=|Y|.  Proof by picture (not really a proof, just for intuition): 11 XY

12 Set sizes  Let X,Y be finite sets, f:X  Y a function  Theorem: If f is bijective then |X|=|Y|.  Proof: f is bijective so it is both injective (hence |X|  |Y|) and surjective (hence |X|  |Y|). So |X|=|Y|. QED. 12

13 3. Infinite set sizes 13

14 Infinite set sizes  Let X,Y be infinite sets (e.g natural numbers, prime numbers, reals)  We want to define a notion of set size (called cardinality) which will make sense  Turns out, it is easier to just define which sets are smaller than other ones 14

15 Infinite set sizes  Let X,Y be infinite sets (e.g natural numbers, primes numbers, reals)  We define |X|  |Y| if there is an injective function f:X  Y  If Z=integers and E=even integers, is A. |Z|  |E| B. |E|  |Z| C. Both D. Neither 15

16 Infinite set sizes  |Z|=|E|  How do we prove this?  |E|  |Z| because we can define f:E  Z by f(x)=x. It is injective.  |Z|  |E| because we can define f:Z  E by f(x)=2x. It is injective. 16

17 Infinite set sizes  Interesting facts: |Z|=|E|=|prime numbers|=|N|  This “size”, or cardinality, is called countable and denoted as  0  It is the smallest infinite size  These are sets which you can list in a sequence  BUT! |reals|>|Z|  There are “really” more reals than integers  We will prove that! 17

18 Countable sets  Theorem: The rationals are countable, |Q|=  0  Proof: we need to show that we can list the rationals in a sequence  Bad idea: 1,1/2,1/3,1/4,1/5,1/6,…  This way we will never hit, say, 2/3 18

19 Countable sets  Theorem: The rationals are countable, |Q|=  0  Proof:  It’s enough to the list positive rationals, because if Q + ={x 1,x 2,x 3,…} then we have Q={0,x 1,-x 1,x 2,-x 2,x 3,-x 3,…}  Solution: list x/y by first enumerating s=x+y, then x=1,2,…,s 1/1, 1/2, 2/1, 1/3, 2/2, 3/1, 1/4, 2/3, 3/2, 4/1, … 19 X

20 Enumerating the rationals 20 1 1 2 34 1 2 3 4 x y 2 3 X 5 8 9 4 6 7

21 Reals are uncountable  Theorem : |R|>  0  Proof: by contradiction  Say we can list all the real numbers in [0,1] in a sequence x 1,x 2,x 3,…  For each number, write its representation in base 10, eg 0.12893453…  Let x i =0.b i,1 b i,2 b i,3 b i,4 … 21

22 Reals are uncountable  Theorem : |R|>  0  R={x 1,x 2,x 3,…}. Create a table: x 1 =0.b 1,1 b 1,2 b 1,3 b 1,4 … x 2 =0.b 2,1 b 2,2 b 2,3 b 2,4 … x 3 =0.b 3,1 b 3,2 b 3,3 b 1,4 … x 4 =0.b 4,1 b 4,2 b 4,3 b 4,4 … … 22

23 Reals are uncountable  Theorem : |R|>  0  R={x 1,x 2,x 3,…}. Create a table: x 1 =0.b 1,1 b 1,2 b 1,3 b 1,4 … x 2 =0.b 2,1 b 2,2 b 2,3 b 2,4 … x 3 =0.b 3,1 b 3,2 b 3,3 b 1,4 … x 4 =0.b 4,1 b 4,2 b 4,3 b 4,4 … …  Define a number x=0.c 1 c 2 c 3 c 4 … such that c i  b i,i for all i  c cannot be equal to any x i, since their i-th digits differ  Hence, c is a real number which is not in our list  A contradiction. The reals cannot be listed. 23

24 Diagonilaztion  This proof technique is called diagonilaztion  It is used to create an object different from all the element in our list  It is very powerful  For example, it can be used to show that it is generally impossible to know whether a computer code is correct, or even simpler questions, like if it loops forever or not 24


Download ppt "CSE 20: Discrete Mathematics for Computer Science Prof. Shachar Lovett."

Similar presentations


Ads by Google