Professional Documents
Culture Documents
Sets
Sets
A B
C
This Lecture
• Basic Definitions
• Operations on Sets
• Set Identities
• Russell’s Paradox
Defining Sets
e.g.
Examples of Sets
Other examples:
The set of all polynomials with degree at most three: {1, x, x 2, x3, 2x+3x2,…}.
Later we will study how to determine the size of the following sets:
• the set of poker hands which are “full house”.
• the set of n-bit strings without three consecutive ones.
• the set of valid ways to add n pairs of parentheses
Subset
A B
not a subset
• If A={4, 8, 12, 16} and B={2, 4, 6, 8, 10, 12, 14, 16}, then but
• If A is the set of prime numbers and B is the set of odd numbers, then
A B
Fact: If A = B, then |A| = |B|.
Exercises
1. ?
2. {3} {5,7,3}?
3. every set?
5. {a} = {{a}}?
6. If A B and B C, then A C?
7. If A B and B C, then A C?
This Lecture
• Basic Definitions
• Operations on Sets
• Set Identities
• Russell’s Paradox
Basic Operations on Sets
Let A, B be two subsets of a universal set U
(depending on the context U could be R, Z, or other sets).
intersection:
e.g. Let A be the set of odd numbers, and B be the set of even numbers.
Then A and B are disjoint.
union:
Fact:
Basic Operations on Sets
difference:
Fact:
complement:
Fact: If , then
Examples
Then {A1, A2} is not a partition of A, because A 1 and A2 are not disjoint,
Fact (to be explained later): If A has n elements, then pow(A) has 2 n elements.
Cartesian Products
Using the above examples, AxAxA is the set of strings with three letters.
1. Let A be the set of prime numbers, and let B be the set of even numbers.
What is A B and |A B|?
3. Let A be the set of all n-bit binary strings, A i be the set of all n-bit
• Basic Definitions
• Operations on Sets
• Set Identities
• Russell’s Paradox
Set Identities
Some basic properties of sets, which are true for all sets.
Set Identities
(2)
A B A B
C C
(1) (2)
Set Identities
Distributive Law:
L.H.S
S1 S2
S3
A B
S4
S5 S6
R.H.S.
S7
C
Set Identities
De Morgan’s Law:
Set Identities
De Morgan’s Law:
Disproof
A B A B
C C
L.H.S R.H.S
Disproof
1 2 3 1 2 3
A B A B
4 5 6 4 5 6
7 7
C C
by distributive law
Exercises
This Lecture
• Basic Definitions
• Operations on Sets
• Set Identities
• Russell’s Paradox
Russell’s Paradox (Optional)
Is W in W?
What’s wrong???
Barber’s Paradox (Optional)
What’s wrong???
Solution to Russell’s Paradox (Optional)
A man either shaves himself or does not shave himself.
A barber neither shaves himself nor not shaves himself.
Perhaps such a barber does not exist?
Actually that’s the way out of this paradox.
The halting problem: Can we write a program which detects an infinite loop?
Note that the program H can not just simulate the program P on input I;
• if P halts on I, then H can return halt successfully;
• but if P loops forever on I, then H will also loop forever.
Halting Problem
Proof by contradiction:
Loop forever
output If H(P,P)=halt
Input for K(P) P:=P
H(P,I)
H(P,P) If H(P,P)=
program P loop forever
I:=P halt
K(P)
Halting Problem
Loop forever
output If H(P,P)=halt
Input for K(P) P:=P
H(P,I)
H(P,P) If H(P,P)=
program P loop forever
I:=P halt
K(P)
Halting Problem
Case 1: Suppose H(K,K) says “halt”, that is H determines K(K) will “halt”.
But then K(K) will “loop forever”, which is exactly the opposite to the answer.
Loop forever
output If H(K,K)=halt
Input for K(K) P:=K
H(P,I)
H(K,K) If H(K,K)=
program K loop forever
I:=K halt
K(K)
Halting Problem
Case 2: Suppose H(K,K) says “loop forever”, that is H determines K(K) will “loop”,
But then K(K) will “halt”, which is exactly the opposite to the answer.
Loop forever
output If H(K,K)=halt
Input for K(K) P:=K
H(P,I)
H(K,K) If H(K,K)=
program K loop forever
I:=K halt
K(K)
Halting Problem
The proof is due to Alan Turing (1936); you will see more of such
arguments in a later class.
Remarks and References
The argument used in the halting problem is called the “diagonalization” method.
This was originally used by Cantor to prove that real numbers are “more” than
Integers.
This method has many other applications in theoretical computer science.