350 likes | 514 Views
Counting Sets. Functions. A function is called one-to-one if every element of B is mapped to at most one element of A. b 1. a 1. A. B . a 2. b 2. a 3. b 3. b 4. Functions. A function is called onto if every element of B is mapped to at least one element of A. b 1. a 1. A. B .
E N D
Functions • A function is called one-to-one if every element of B is mapped to at most one element of A. b1 a1 A B a2 b2 a3 b3 b4
Functions • A function is called onto if every element of B is mapped to at least one element of A. b1 a1 A B a2 b2 a3 b3 a4
Functions • If a function is both one-to-one and onto then every element of B is mapped to exactly one element of A. a1 b1 A B a2 b2 a3 b3
Counting sets • Two sets A, B are of the same size if they have an equal number of elements. We denote this as |A| = |B|. There is an 1-1 and onto function mapping each element of A to an element of B iff |A| = |B|.
Counting infinite sets • We say that two infinite sets A, B are of the same size if there is an one to one and onto function from A to B (or from B to A) |A| = |B| a1 b1 A B a2 b2 a3 b3 … …
Countable Sets • A set is countable if you can find an one to one and onto correspondence with the natural numbers (intuitively this means that it has the same size as the natural numbers) 1 a 2 b A N 3 c 4 d 5 e … …
The set of the even numbers is countable • There is an one to one an onto function from E (the even numbers) to N: f(n) = n/2 f 0 0 1 2 N 2 4 E 3 6 4 8 … …
N x N is countable . . . (0,0) (0,1) (0,2) (0,3) (0,4) (1,0) (1,1) (1,2) (1,3) (1,4) (2,0) (2,1) (2,2) (2,3) (2,4) (3,0) (3,1) (3,2) (3,3) (3,4) (4,0) (4,1) (4,2) (4,3) (4,4) . . . . . .
N x N is countable . . . 0 1 8 9 24 3 2 7 10 23 5 6 4 11 22 15 14 13 12 21 17 18 19 20 16 . . . . . .
Q is countable . . . 0/0 0/1 0/2 0/3 0/4 1/0 1/1 1/2 1/3 1/4 2/0 2/1 2/2 2/3 2/4 3/0 3/1 3/2 3/3 3/4 4/0 4/1 4/2 4/3 4/4 . . . . . .
Q is countable . . . 0/0 0/1 0/2 0/3 0/4 1/0 1/1 1/2 1/3 1/4 2/0 2/1 2/2 2/3 2/4 3/0 3/1 3/2 3/3 3/4 4/0 4/1 4/2 4/3 4/4 . . . . . .
Q is countable . . . 0/1 1/1 1/2 1/3 1/4 2/1 2/3 3/1 3/2 3/4 4/1 4/3 . . . . . .
Q is countable . . . 0 0/1 1/1 1/2 1/3 1/4 1 3 4 11 2 5 2/1 2/3 7 6 10 3/1 3/2 3/4 8 9 4/1 4/3 . . . . . .
Try it yourself • The set Z of integers is countable
Try it yourself • The set Z of integers is countable The following function f: Z ⟶ N is 1-1 and onto … -4 -3 -1 0 1 2 3 4 … -2
Try it yourself • The set Z of integers is countable The following function f: Z ⟶ N is 1-1 and onto … -4 7 -3 5 -1 1 0 0 2 1 2 4 6 3 4 8 … -2 3
The set of Turing Machines is countable • Every Turing Machine can be given a unique number in binary as follows: • Give to the states a number: q0 is 1, q1 is 11 etc… • Give to the symbols of the tape a unique number: a is 1, b is 11, c is 111 etc… • Assign 1 to L, 11 to R and 111 to S • For each δ(q, a) = (q’, b, H) give the binary number 11…1011...1011…1011…1011…1 q a q’ b H where H is L, R or S.
The set of Turing Machines is countable • Every Turing Machine can be given a unique number in binary as follows: • To obtain the number of the machine combine the number of the transitions together (separated with 00). • The number starts with q0 00 qf 00 • The number associated with the Turing Machine M is denoted as <M>
Example • The Turing Machine MP that computes the Predicate n = 0 has the following number <MP> = 100110010101101011 ? qf □ → □, R q0
Uncountable Sets • Countable sets are infinite. • However there are some sets that are considered “even larger”. • There is no way to enumerate them.
Diagonalization • Suppose that there is an enumeration of all the elements of the uncountable set. • Obtain a new element by changing the ith place of the ith element. • The new element is different than any other in the list. • The new element is not in the enumeration. Contradiction!!!
The set of numbers in [0,1) is uncountable • Suppose that it was countable. An enumeration would be the following: n0 = 0.534103… n1 =0.920531… n2 =0.423327… n3 =0.832739… n4 = 0.392098… …
The set of numbers in [0,1) is uncountable • Create a new number n by adding 1 mod 10 to the ith decimal digit of the (i-1)th number: n0 = 0.534103… n1 =0.920531… n2 =0.423327… n3 =0.832739… n4 = 0.392098… … n = 0.63480…
The set of numbers in [0,1) is uncountable • The number n is different than any other number in the list. n0 = 0.534103… ≠ 0.63480… n1 =0.920531… ≠ 0.63480… n2 =0.423327… ≠ 0.63480… n3 =0.832739… ≠ 0.63480… n4 = 0.392098… ≠ 0.63480… … n = 0.63480…
The set of numbers in [0,1) is uncountable • Since n is a number in [0,1) it should be in the enumeration. • Suppose that n = ni. • This can’t be true because n and ni differ in the (i+1)th decimal digit. Contradiction! There is no possible enumeration for the numbers in [0,1), which means that: The set of numbers in [0,1) is uncountable.
R is uncountable The set of real numbers contains the set [0,1). Thus it is uncountable.
The set of predicates is not countable Suppose that it was. An enumeration of all the predicate would be the following: p0 p1 p2 p3 …
The set of predicates is not countable Suppose that it was. An enumeration of all the predicate would be the following: pi(0) pi(1) pi(2) pi(3) … p0 0 0 1 0 p10 1 0 0 p2 1 0 1 0 p30 1 1 1 … … … … …
The set of predicates is not countable Construct a predicate p as follows: Change the 0 with 1 and vice versa in pi(i) [ p(i) = 1-pi(i) ] pi(0) pi(1) pi(2) pi(3) … p00 0 1 0 … p10 1 0 0 … p2 1 0 1 0 … p30 1 1 1 … … … … … … p 1 0 0 0 …
The set of predicates is not countable Predicate p is not in the list since p(i) is different than pi(i) for every i. pi(0) pi(1) pi(2) pi(3) … p00 0 1 0 … p10 1 0 0 … p2 1 0 1 0 … p30 1 1 1 … … … … … … p 1 0 0 0 …
Try it yourself • Is the set of functions from N to {0,1,2} countable? Why?
Try it yourself • Is the set of functions from N to {0,1,2} countable? Why? No. The set of functions from N to {0,1,2} contains the set of predicates. Can you prove this by using diagonalization?
Not all predicates are computable • Turing Machines are countable • Predicates are uncountable Thus there is a predicate for which there is no Turing Machine that decides it.