Upload
phamkiet
View
217
Download
0
Embed Size (px)
Citation preview
Sets
Ordered pair
p. 2
Sets
The set theory is a branch of mathematical logic thatwas created by Georg Cantor in 1870s.
Def. A set is a unordered collection of objects beingregarded as a single object.
Examples:A= {1, 2,3, 4,5}
B = {x ∈ A | (x ≥ 3)∧ (x is odd)}
C = {∅, {A}, {B}, {A, B}}
N= {0, 1,2, 3, . . .}
Sets
Ordered pair
p. 3
Sets
If x belongs to a set A, we say that it is a member (or an element)of A and write
x ∈ A.
If x is not a member of A, we write
x /∈ A.
Empty set, denoted by ∅ or ;, has no members:
∀x (x /∈∅).
Sets
Ordered pair
p. 4
Sets
Two sets A and B are equal, A = B, iff they have exactly the sameelements:
∀x (x ∈ A↔ x ∈ B)
For any two objects x and y , we can make a set containing exactlythese two objects
{x , y}
If those two objects are identical, x = y , we get a singleton set,
{x , x}= {x}.
Notice that these sets are not equal:
∅, {∅}, {∅, {∅}}
Sets
Ordered pair
p. 5
Sets
Set-builder notation.
A set of all objects that satisfy the property P:
A= {x | P(x)}
Examples:B = {x ∈ Z | x is even}
C = {x ∈ Z | ∃k ∈ Z (x = 2k)}
D = {x | (x ∈ Z)∧ (∃k ∈ Z (x = 2k))}
E = {0,2,−2,4,−4, 6,−6, . . .}
In naive set theory, any definable collection is a valid set. And usu-ally it works fine.
However, it leads to contradictions, such as Russell’s paradox.
Sets
Ordered pair
p. 6
Russell’s paradox
Let R be the set of all sets that are not members of themselves:
R= {x | x /∈ x}
It is legal to ask, is R a member of itself or not.
There are only two cases, either R ∈ R, or R /∈ R.
So, where is the paradox?
Sets
Ordered pair
p. 7
Russell’s paradox
R= {x | x /∈ x}
(a) If R is a member of itself, then by its definition, R /∈ R,
R ∈ R→ R /∈ R.
(b) Otherwise, if R is not a member of itself, then R ∈ R,
R /∈ R→ R ∈ R.
Therefore, we get a contradiction, R ∈ R↔ R /∈ R.
There exist several axiomatic systems that rule out such pathologi-cal cases. For example, Zermelo-Fraenkel set theory with the Axiomof Choice (ZFC).
Sets
Ordered pair
p. 8
Union and Intersection
Union of two sets A and B,
A∪ B = {x | (x ∈ A)∨ (x ∈ B)}
{1,2} ∪ {2, 3}= {1,2, 3}
Intersection of two sets A and B,
A∩ B = {x | (x ∈ A)∧ (x ∈ B)}
{1, 2} ∩ {2, 3}= {2}
Sets
Ordered pair
p. 9
Difference
Difference between two sets A and B,
A\ B = {x | (x ∈ A)∧ (x /∈ B)}
A B
{1, 2} \ {2, 3}= {1}
Sets
Ordered pair
p. 10
Complement
If there is a universal set U of all possible objects, then the comple-ment of a set A is
A= U \ A= {x ∈ U | x /∈ A}= {x ∈ U | ¬(x ∈ A)}
AA
U
Exmaple: When U = Z:
Odd = {x ∈ Z | x is odd}
Even= Odd = Z \Odd
Sets
Ordered pair
p. 11
Set identities
Given the universal set U , sets with respect to union, intersection,and complement satisfy the same identities as propositions withrespect to ∧, ∨, and ¬
Sets: A∩ B A∪ B A U ∅Propositions: p ∧ q p ∨ q ¬p T F
A = A
A∪ B = A∩ B
A∩ B = A∪ BA∩ (B ∩ C) = (A∩ B)∩ CA∪ (B ∪ C) = (A∪ B)∪ CA∩ (B ∪ C) = (A∩ B)∪ (A∩ C)A∪ (B ∩ C) = (A∪ B)∩ (A∪ C)
See the full list in Rosen’s book.
Sets
Ordered pair
p. 12
Set identities
Let’s prove De Morgan’s law for sets:
A∪ B = A∩ B
(x ∈ A∪ B) = ¬(x ∈ A∪ B)= ¬((x ∈ A)∨ (x ∈ B))
(x ∈ A∩ B) = (x ∈ A)∧ (x ∈ B)= ¬(x ∈ A)∧¬(x ∈ B)= ¬((x ∈ A)∨ (x ∈ B))
The propositions in the right hand sides of the equations are equal,therefore, the left hand sides are equal too.
Sets
Ordered pair
p. 13
Subset
A is a subset of B iff every element of A is an element of B:
A⊆ B ↔�
∀x((x ∈ A)→ (x ∈ B))�
{1,2} ⊆ {1,2, 3}
{1, 2,3} ⊆ {1, 2,3}
∅ ⊆ {1, 2,3}
A is a proper subset of B iff A is a subset of B, but it’s not equal to B
A( B ↔�
∀x((x ∈ A)→ (x ∈ B)) ∧ ∃x((x ∈ B)∧ (x /∈ A))�
{1,2} ( {1,2, 3}
∅ ( {1, 2,3}
Proper subset A is strictly “smaller” than B.
Sets
Ordered pair
p. 14
Power set
Def. The set of all subsets of A is called a power set of A, denotedby P (A).
Examples:
P ({0, 1}) =�
∅, {0}, {1}, {0, 1}
P ({0, 1, 2}) =�
∅, {0}, {1}, {2}, {0,1}, {0, 2}, {1, 2}, {0,1, 2}
Sets
Ordered pair
p. 15
Power set
Def. The set of all subsets of A is called a power set of A, denotedby P (A).
Examples:
P ({0, 1}) =�
∅, {0}, {1}, {0, 1}
P ({0, 1, 2}) =�
∅, {0}, {1}, {2}, {0,1}, {0, 2}, {1, 2}, {0,1, 2}
Sets
Ordered pair
p. 16
Cardinality
Def. The cardinality of a finite set A is equal to the number of ele-ments in A. It’s denoted by |A|.
|∅|= 0
|{0,1, 2,3, 4}|= 5
We already know the subtraction rule for the cardinality of a union:
|A∪ B|= |A|+ |B| − |A∩ B|
Sets
Ordered pair
p. 17
Question
Compute the cardinality of the power set P (A) if |A|= n.
In other words, since the power set is the set of all subsets, the task isto count the number of subsets of a set with n elements.
|P (A)|= 2|A| = 2n
Sets
Ordered pair
p. 18
Question
Compute the cardinality of the power set P (A) if |A|= n.
In other words, since the power set is the set of all subsets, the taskis to count the number of subsets of a set with n elements.
|P (A)|= 2|A| = 2n
Sets
Ordered pair
p. 19
Question
Compute the cardinality of the power set P (A) if |A|= n.
In other words, since the power set is the set of all subsets, the taskis to count the number of subsets of a set with n elements.
|P (A)|= 2|A| = 2n
Sets
Ordered pair
p. 20
Generalized union and intersection
Union of a finite set of sets:⋃
{A0}= A0
⋃
{A0, A1, . . . An}=n⋃
i=0
Ai = A0 ∪ A1 ∪ . . .∪ An
Intersection of a finite set of sets:⋂
{A0}= A0
⋂
{A0, A1, . . . An}=n⋂
i=0
Ai = A0 ∩ A1 ∩ . . .∩ An
Sets
Ordered pair
p. 21
Ordered pair
Def. The ordered pair of a ∈ A and b ∈ B is an ordered collection(a, b).
Two ordered pairs are equal
(a, b) = (c, d) if and only if (a = c)∧ (b = d).
Observe that this property implies that
(a, b) 6= (b, a)
unless a = b. So, the order matters. This is why it is called theordered pair, and (a, b) is not equivalent to a set {a, b}.
(1, 2) = (1, 2)(1, 2) 6= (1, 3)(1, 2) 6= (2, 1)
Sets
Ordered pair
p. 22
Ordered pair
More examples of ordered pairs:
(1, 2)({1}, {2})(1, {2, 3,4, 5})
((1, 2),∅)
If a ∈ A and b ∈ B, what is the set of all ordered pairs (a, b)?
Sets
Ordered pair
p. 23
Cartesian product
Def. Let A and B be sets. The Cartesian product of A and B, denotedby A×B, is the set of all ordered pairs (a, b), where a ∈ A and b ∈ B.Hence,
A× B = {(a, b) | a ∈ A∧ b ∈ B}.
(Named after Rene Decartes)
Question. Given two sets A= {1, 2,3} and B = {C , D}, what is theirCartesian product A× B?
A× B = {(1, C), (2, C), (3, C),(1, D), (2, D), (3, D)}
Sets
Ordered pair
p. 24
Cartesian product
Def. Let A and B be sets. The Cartesian product of A and B, denotedby A×B, is the set of all ordered pairs (a, b), where a ∈ A and b ∈ B.Hence,
A× B = {(a, b) | a ∈ A∧ b ∈ B}.
(Named after Rene Decartes)
Question. Given two sets A= {1, 2,3} and B = {C , D}, what is theirCartesian product A× B?
A× B = {(1, C), (2, C), (3, C),(1, D), (2, D), (3, D)}
Sets
Ordered pair
p. 25
Cartesian product
Question. If the |A| = n, and |B| = m, what is the cardinality ofA× B?
Sets
Ordered pair
p. 26
Building a list
Ordered pair is fundamental for defining data types.Question. How to implement the list data type using only orderedpairs?
Example of a list:[1, 2,3, 4]
Interface:construct ( 1, [2, 3,4] ) = [1, 2,3, 4]
head ( [1, 2,3, 4] ) = 1
tail ( [1, 2,3, 4] ) = [2, 3,4]
Possible implementation:(1, (2, (3,4)))
construct ( h, t )= (h, t)head ( (h, t) )= h
tail ( (h, t) )= t
Sets
Ordered pair
p. 27
Building a list
Ordered pair is fundamental for defining data types.Question. How to implement the list data type using only orderedpairs?
Example of a list:[1, 2,3, 4]
Interface:construct ( 1, [2, 3,4] ) = [1, 2,3, 4]
head ( [1, 2,3, 4] ) = 1
tail ( [1, 2,3, 4] ) = [2, 3,4]
Possible implementation:(1, (2, (3,4)))
construct ( h, t ) = (h, t)head ( (h, t) ) = h
tail ( (h, t) ) = t
Sets
Ordered pair
p. 28
Ordered n-tuple
Def. The ordered n-tuple of is an ordered collection (a1, a2, . . . , an).
It is just an extension of an ordered pair for joining n elementstogether.
Def. The Cartesian product of the sets A1, . . . An, is the set of alln-tuples such that
A1 × . . .× An = {(a1, . . . , an) | ai ∈ Ai for i = 1, . . . , n}
If all sets Ai are equal, that is, A1 = . . . = An = A, then their Carte-sian product is denoted by An
A1 × . . .× An = A× . . .× A︸ ︷︷ ︸
n times
= An