<<

Sets. Ordered pairs. Sets Sets

Ordered pair

The theory is a branch of that was created by in 1870s.

Def. A set is a unordered collection of objects being regarded 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, . . . { }

p. 2 Sets Sets

Ordered pair

If x belongs to a set A, we say that it is a member (or an ) 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 / ∅). ∀ ∈

p. 3 Sets Sets

Ordered pair

Two sets A and B are equal, A = B, iff they have exactly the same elements: x (x A x B) ∀ ∈ ↔ ∈ For any two objects x and y, we can make a set containing exactly these two objects x, y { } If those two objects are identical, x = y, we get a set,

x, x = x . { } { } Notice that these sets are not equal:

∅, ∅ , ∅, ∅ { } { { }}

p. 4 Sets Sets

Ordered pair 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 , any definable collection is a valid set. And usu- ally it works fine. However, it leads to contradictions, such as Russell’s paradox.

p. 5 Russell’s paradox Sets

Ordered pair

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?

p. 6 Russell’s paradox Sets

Ordered pair

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 of Choice (ZFC).

p. 7 and Intersection Sets

Ordered pair

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 { } ∩ { } { }

p. 8 Difference Sets

Ordered pair

Difference between two sets A and B,

A B = x (x A) (x / B) \ { | ∈ ∧ ∈ }

A B

1, 2 2, 3 = 1 { }\{ } { }

p. 9 Sets

Ordered pair If there is a universal setU of all possible objects, then the comple- ment of a set A is

A = U A = x U x / A = x U (x A) \ { ∈ | ∈ } { ∈ | ¬ ∈ }

U A A

Exmaple: When U = Z:

Odd = x Z x is odd { ∈ | } Even = Odd = Z Odd \ p. 10 Set identities Sets

Ordered pair Given the U, sets with respect to union, intersection, and complement satisfy the same identities as with respect to , , and ∧ ∨ ¬ Sets: A BA B AU ∅ Propositions: p ∩ q p ∪ q pTF ∧ ∨ ¬

A = A A B = A B ∪ ∩ A B = A B ∩ ∪ A (B C) = (A B) C ∩ ∩ ∩ ∩ A (B C) = (A B) C ∪ ∪ ∪ ∪ A (B C) = (A B) (A C) ∩ ∪ ∩ ∪ ∩ A (B C) = (A B) (A C) ∪ ∩ ∪ ∩ ∪ See the full list in Rosen’s book. p. 11 Set identities Sets

Ordered pair

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.

p. 12 Sets

Ordered pair 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. ( p. 13 Sets

Ordered pair

Def. The set of all of A is called a power set of A, denoted by (A). P Examples:  ( 0, 1 ) = ∅, 0 , 1 , 0, 1 P { }  { } { } { } ( 0, 1, 2 ) = ∅, 0 , 1 , 2 , 0, 1 , 0, 2 , 1, 2 , 0, 1, 2 P { } { } { } { } { } { } { } { }

p. 14 Power set Sets

Ordered pair

Def. The set of all subsets of A is called a power set of A, denoted by (A). P Examples:  ( 0, 1 ) = ∅, 0 , 1 , 0, 1 P { }  { } { } { } ( 0, 1, 2 ) = ∅, 0 , 1 , 2 , 0, 1 , 0, 2 , 1, 2 , 0, 1, 2 P { } { } { } { } { } { } { } { }

p. 15 Sets

Ordered pair

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 | ∪ | | | | | − | ∩ |

p. 16 Question Sets

Ordered pair

Compute the cardinality of the power set (A) if A = n. P | | In other words, since the power set is the set of all subsets, the task is to count the number of subsets of a set with n elements.

A n (A) = 2| | = 2 |P |

p. 17 Question Sets

Ordered pair

Compute the cardinality of the power set (A) if A = n. P | | In other words, since the power set is the set of all subsets, the task is to count the number of subsets of a set with n elements.

A n (A) = 2| | = 2 |P |

p. 18 Question Sets

Ordered pair

Compute the cardinality of the power set (A) if A = n. P | | In other words, since the power set is the set of all subsets, the task is to count the number of subsets of a set with n elements.

A n (A) = 2| | = 2 |P |

p. 19 Generalized union and intersection Sets

Ordered pair

Union of a finite set of sets: [ A0 = A0 { } n [ [ A0, A1,... An = Ai = A0 A1 ... An { } i=0 ∪ ∪ ∪

Intersection of a finite set of sets: \ A0 = A0 { } n \ \ A0, A1,... An = Ai = A0 A1 ... An { } i=0 ∩ ∩ ∩

p. 20 Ordered pair Sets

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) (a = c) (b = d). ∧ Observe that this property implies that

(a, b) = (b, a) 6 unless a = b. So, the order matters. This is why it is called the ordered pair, and (a, b) is not equivalent to a set a, b . { } (1, 2) = (1, 2) (1, 2) = (1, 3) 6 (1, 2) = (2, 1) 6

p. 21 Ordered pair Sets

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)? ∈ ∈

p. 22 Cartesian Sets

Ordered pair

Def. Let A and B be sets. The of A and B, denoted by 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 their Cartesian product A B? { } { } × A B = (1, C), (2, C), (3, C), × { (1, D), (2, D), (3, D) }

p. 23 Cartesian product Sets

Ordered pair

Def. Let A and B be sets. The Cartesian product of A and B, denoted by 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 their Cartesian product A B? { } { } × A B = (1, C), (2, C), (3, C), × { (1, D), (2, D), (3, D) }

p. 24 Cartesian product Sets

Ordered pair

Question. If the A = n, and B = m, what is the cardinality of A B? | | | | ×

p. 25 Building a list Sets

Ordered pair Ordered pair is fundamental for defining data types. Question. How to implement the list data type using only ordered pairs? 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 p. 26 Building a list Sets

Ordered pair Ordered pair is fundamental for defining data types. Question. How to implement the list data type using only ordered pairs? 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 p. 27 Ordered n- Sets

Ordered pair

Def. The ordered n-tuple of is an ordered collection (a1, a2,..., an).

It is just an of an ordered pair for joining n elements together.

Def. The Cartesian product of the sets A1,... An, is the set of all n- 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

n A1 ... An = A ... A = A | {z } × × ×n times×

p. 28