Sets and Set Operations

Sets - Section 2.1

Section Summary

  • Definition of sets

  • Describing Sets

    • Roster Method

    • Set-Builder Notation

  • Some Important Sets in Mathematics

  • Empty Set and Universal Set

  • Subsets and Set Equality

  • Cardinality of Sets

  • Tuples

  • Cartesian Product

Introduction

  • Sets are basic building blocks in discrete mathematics.

  • Important for counting.

  • Programming languages have set operations.

  • Set theory is an important branch of mathematics.

  • Many different systems of axioms have been used to develop set theory.

  • Here we are not concerned with a formal set of axioms for set theory. Instead, we will use what is called naïve set theory.

Sets

  • A set is an unordered collection of objects.

    • Example: the students in this class, the chairs in this room.

  • The objects in a set are called the elements, or members of the set.

  • A set is said to contain its elements.

  • The notation aAa ∈ A denotes that a is an element of the set A.

  • If a is not a member of A, write aAa ∉ A

Describing a Set: Roster Method

  • S=a,b,c,dS = {a,b,c,d}

  • Order is not important: S=a,b,c,d=b,c,a,dS = {a,b,c,d} = {b,c,a,d}

  • Each distinct object is either a member or not; listing more than once does not change the set.

    • S=a,b,c,d=a,b,c,b,c,dS = {a,b,c,d} = {a,b,c,b,c,d}

  • Ellipses (…) may be used to describe a set without listing all of the members when the pattern is clear.

    • S=a,b,c,d,,zS = {a,b,c,d, ……,z }

Roster Method Examples

  • Set of all vowels in the English alphabet: V=a,e,i,o,uV = {a,e,i,o,u}

  • Set of all odd positive integers less than 10: O=1,3,5,7,9O = {1,3,5,7,9}

  • Set of all positive integers less than 100: S=1,2,3,..,99S = {1,2,3,……..,99}

  • Set of all integers less than 0: S=.,3,2,1S = {…., -3,-2,-1}

Some Important Sets

  • N\mathbb{N} = natural numbers = 0,1,2,3{0,1,2,3…}

  • Z\mathbb{Z} = integers = ,3,2,1,0,1,2,3,{…,-3,-2,-1,0,1,2,3,…}

  • Z+\mathbb{Z^+} = positive integers = 1,2,3,..{1,2,3,…..}

  • R\mathbb{R} = set of real numbers

  • R+\mathbb{R^+} = set of positive real numbers

  • C\mathbb{C} = set of complex numbers.

  • Q\mathbb{Q} = set of rational numbers

Set-Builder Notation

  • Specify the property or properties that all members must satisfy:

    • S=xx is a positive integer less than 100S = {x | x \text{ is a positive integer less than 100}}

    • O=xx is an odd positive integer less than 10O = {x | x \text{ is an odd positive integer less than 10}}

    • O = {x ∈ \mathbb{Z^+} | x \text{ is odd and } x < 10}

  • A predicate may be used:

    • S=xP(x)S = {x | P(x)} Example: S=xPrime(x)S = {x | Prime(x)}

  • Positive rational numbers:

    • Q+=xRx=p/q, for some positive integers p,q\mathbb{Q^+} = {x ∈ \mathbb{R} | x = p/q, \text{ for some positive integers } p,q}

Interval Notation

  • closed interval [a,b]=xaxb[a,b] = {x | a ≤ x ≤ b}

  • open interval (a,b) = {x | a < x < b}

  • [a,b) = {x | a ≤ x < b}

    (a,b] = {x | a < x ≤ b}

Universal Set and Empty Set

  • The universal set U is the set containing everything currently under consideration.

    • Sometimes implicit

    • Sometimes explicitly stated.

    • Contents depend on the context.

  • The empty set is the set with no elements. Symbolized ∅, but {} also used.

  • Venn Diagram

Some things to remember

  • Sets can be elements of sets. 1,2,3,a,b,c{{1,2,3},a, {b,c}}, N,Z,Q,R{N,Z,Q,R}

  • The empty set is different from a set containing the empty set. ∅ ≠ { ∅ }

Set Equality

  • Definition: Two sets are equal if and only if they have the same elements.

    • Therefore if A and B are sets, then A and B are equal if and only if x,(xAxB)\forall x, (x ∈ A ↔ x ∈ B)

  • We write A = B if A and B are equal sets.

    • 1,3,5=3,5,1{1,3,5} = {3, 5, 1}

    • 1,5,5,5,3,3,1=1,3,5{1,5,5,5,3,3,1} = {1,3,5}

Subsets

  • Definition: The set A is a subset of B, if and only if every element of A is also an element of B.

    • The notation ABA ⊆ B is used to indicate that A is a subset of the set B.

    • ABA ⊆ B holds if and only if x,(xAxB)\forall x, (x ∈ A → x ∈ B) is true.

    1. Because aa ∈ ∅ is always false, S∅ ⊆ S,for every set S.

    2. Because aSaSa ∈ S → a ∈ S, SSS ⊆ S, for every set S.

Showing a Set is or is not a Subset of Another Set

  • Showing that A is a Subset of B:

    • To show that ABA ⊆ B, show that if x belongs to A, then x also belongs to B.

  • Showing that A is not a Subset of B:

    • To show that A is not a subset of B, ABA ⊈ B, find an element xAx ∈ A with xBx ∉ B. (Such an x is a counterexample to the claim that xAx ∈ A implies xBx ∈ B.)

  • Examples:

    1. The set of all computer science majors at your school is a subset of all students at your school.

    2. The set of integers with squares less than 100 is not a subset of the set of nonnegative integers.

Another look at Equality of Sets

Recall that two sets A and B are equal, denoted by A = B, iff x,(xAxB)\forall x, (x ∈ A ↔ x ∈ B)

Using logical equivalences we have that A = B iff x([xAxB][xBxA])\forall x ([x ∈ A → x ∈ B] ∧ [x ∈ B → x ∈ A] )

This is equivalent to ABA ⊆ B and BAB ⊆ A

Proper Subsets

  • Definition: If ABA ⊆ B, but ABA ≠B, then we say A is a proper subset of B, denoted by ABA ⊂ B.

  • If ABA ⊂ B, then x(xAxB)x(xBxA)\forall x (x ∈ A → x ∈ B) ∧ ∃ x (x ∈ B ∧ x ∉ A) is true.

  • Venn Diagram

Set Cardinality

  • Definition: If there are exactly n distinct elements in S where n is a nonnegative integer, we say that S is finite. Otherwise it is infinite.

  • Definition: The cardinality of a finite set A, denoted by |A|, is the number of (distinct) elements of A.

  • Examples:

    1. |ø| = 0

    2. Let S be the letters of the English alphabet. Then |S| = 26

    3. 1,2,3=3{|{1,2,3}| = 3}

    4. ø=1{|{ø}| = 1}

    5. The set of integers is infinite.

Power Sets

  • Definition: The set of all subsets of a set A, denoted P(A), is called the power set of A.

  • Example: If A = {a,b} then P(A)=ø,a,b,a,bP(A) = {ø, {a},{b},{a,b}}

  • If a set has n elements, then the cardinality of the power set is 2n2^n. (In Chapters 5 and 6, we will discuss different ways to show this.)

Tuples

  • The ordered n-tuple (a<em>1,a</em>2,..,a<em>n)(a<em>1,a</em>2,…..,a<em>n) is the ordered collection that has a</em>1a</em>1 as its first element and a<em>2a<em>2 as its second element and so on until a</em>na</em>n as its last element.

  • Two n-tuples are equal if and only if their corresponding elements are equal.

  • 2-tuples are called ordered pairs.

  • The ordered pairs (a,b) and (c,d) are equal if and only if a = c and b = d.

Cartesian Product 1

  • Definition: The Cartesian Product of two sets A and B, denoted by A × B is the set of ordered pairs (a,b) where aAa ∈ A and bBb ∈ B.

  • Example: A = {a,b}, B = {1,2,3} A×B=(a,1),(a,2),(a,3),(b,1),(b,2),(b,3)A × B = {(a,1),(a,2),(a,3), (b,1),(b,2),(b,3)}

  • Definition: A subset R of the Cartesian product A × B is called a relation from the set A to the set B. (Relations will be covered in depth in Chapter 9.)

  • A×B=(a,b)aAbBA × B = {(a,b) | a ∈ A ∧ b ∈ B}

Cartesian Product 2

  • Definition: The cartesian products of the sets A1,A2,……,An, denoted by A1 × A2 × …… × An , is the set of ordered n-tuples (a<em>1,a</em>2,,a<em>n)(a<em>1,a</em>2,……,a<em>n) where a</em>ia</em>i belongs to Ai for i = 1, … n.

  • Example: What is A × B × C where A = {0,1}, B = {1,2} and C = {0,1,2}

  • Solution: A × B × C = {(0,1,0), (0,1,1), (0,1,2),(0,2,0), (0,2,1), (0,2,2),(1,1,0), (1,1,1), (1,1,2), (1,2,0), (1,2,1), (1,2,2)}

  • (a<em>1,a</em>2,,a<em>n)a</em>iAi for i=1,2,,n{(a<em>1,a</em>2,……,a<em>n) | a</em>i ∈ A_i \text{ for } i = 1,2,…,n}

Truth Sets of Quantifiers

Given a predicate P and a domain D, we define the truth set of P to be the set of elements in D for which P(x) is true. The truth set of P(x) is denoted by xDP(x){x ∈ D | P(x)}

Example: The truth set of P(x) where the domain is the integers and P(x) is “|x| = 1” is the set {-1,1}

Set Operations - Section 2.2

Section Summary

  • Set Operations

    • Union

    • Intersection

    • Complementation

    • Difference

  • More on Set Cardinality

  • Set Identities

  • Proving Identities

  • Membership Tables

Union

  • Definition: Let A and B be sets. The union of the sets A and B, denoted by A ∪ B, is the set: xxAxB{x | x ∈ A ∨ x ∈ B}

  • Example: What is {1,2,3} ∪ {3, 4, 5}? Solution: {1,2,3,4,5}

  • Venn Diagram for A ∪ B

Intersection

  • Definition: The intersection of sets A and B, denoted by A ∩ B, is xxAxB{x|x ∈ A ∧ x ∈ B}

  • Note if the intersection is empty, then A and B are said to be disjoint.

  • Example: What is? {1,2,3} ∩ {3,4,5} ? Solution: {3}

  • Example:What is? {1,2,3} ∩ {4,5,6} ? Solution: ∅

  • Venn Diagram for A ∩B

Complement

  • Definition: If A is a set, then the complement of the A (with respect to U), denoted by AˉĀ is the set U - A (The complement of A is sometimes denoted by AcA^c .)

  • Example: If U is the positive integers less than 100, what is the complement of {x | x > 70}

  • Solution :{x | x <= 70}

  • Venn Diagram for Complement

  • Aˉ=xUxAĀ = {x ∈ U|x ∉ A}

Difference

  • Definition: Let A and B be sets. The difference of A and B, denoted by A – B, is the set containing the elements of A that are not in B. The difference of A and B is also called the complement of B with respect to A.

  • Venn Diagram for A − B

  • 𝐴𝐵=xx𝐴x𝐵=𝐴𝐵𝐴 – 𝐵 = {x|x ∈ 𝐴 ∧ x ∉ 𝐵} = 𝐴 ∩ \overline{𝐵}

The Cardinality of the Union of Two Sets

  • Inclusion-Exclusion

  • AB=A+BAB|A ∪ B| = |A| + | B| − |A ∩ B|

  • Example: Let A be the math majors in your class and B be the CS majors. To count the number of students who are either math majors or CS majors, add the number of math majors and the number of CS majors, and subtract the number of joint CS/math majors.

  • We will return to this principle in Chapter 6 and Chapter 8 where we will derive a formula for the cardinality of the union of n sets, where n is a positive integer.

  • Venn Diagram for A, B, A ∩ B, A ∪ B

Review Questions

  • Example: U = {0,1,2,3,4,5,6,7,8,9,10}, A = {1,2,3,4,5}, B ={4,5,6,7,8}

    1. A ∪ B Solution: {1,2,3,4,5,6,7,8}

    2. A ∩ B Solution: {4,5}

    3. Ā Solution: {0,6,7,8,9,10}

    4. overline𝐵overline{𝐵} Solution: {0,1,2,3,9,10}

    5. A – B Solution: {1,2,3}

    6. B – A Solution: {6,7,8}

Symmetric Difference (optional)

  • Definition: The symmetric difference of A and B, denoted by ABA ⊕ B is the set (AB)(BA)(A - B) ∪ (B - A)

  • Example: U = {0,1,2,3,4,5,6,7,8,9,10}, A = {1,2,3,4,5} ,B ={4,5,6,7,8}

  • What is ABA ⊕ B? Solution: {1,2,3,6,7,8}

  • Venn Diagram

Set Identities 1

  • Identity laws

    • A=AA ∪ ∅ = A

    • AU=AA ∩ U = A

  • Domination laws

    • AU=UA ∪ U = U

    • A=A ∩ ∅ = ∅

  • Idempotent laws

    • AA=AA ∪ A = A

    • AA=AA ∩ A = A

  • Complementation law

    • overline(A)=Aoverline{(\overline A)} = A

Set Identities 2

  • Commutative laws

    • AB=BAA ∪ B = B ∪ A

    • AB=BAA ∩ B = B ∩ A

  • Associative laws

    • (AB)C=A(BC)(A ∪ B) ∪ C = A ∪ (B ∪ C)

    • (AB)C=A(BC)(A ∩ B) ∩ C = A ∩ (B ∩ C)

  • Distributive laws

    • A(BC)=(AB)(AC)A ∩ (B ∪ C) = (A ∩ B) ∪ (A ∩ C)

    • A(BC)=(AB)(AC)A ∪ (B ∩ C) = (A ∪ B) ∩ (A ∪ C)

Set Identities 3

  • De Morgan’s laws

    • overline(AB)=ABoverline{(A ∪ B)} = \overline A ∩ \overline B

    • overline(AB)=ABoverline{(A ∩ B)} = \overline A ∪ \overline B

  • Absorption laws

    • A(AB)=AA ∪ (A ∩ B) = A

    • A(AB)=AA ∩ (A ∪ B) = A

  • Complement laws

    • AA=UA ∪ \overline A = U

    • AA=A ∩ \overline A = ∅

Proving Set Identities

Different ways to prove set identities:

  1. Prove that each set (side of the identity) is a subset of the other.

  2. Use set builder notation and propositional logic.

  3. Membership Tables: Verify that elements in the same combination of sets always either belong or do not belong to the same side of the identity. Use 1 to indicate it is in the set and a 0 to indicate that it is not

Proof of Second De Morgan Law1

  • Example: Prove that overline(AB)=ABoverline{(A ∩ B)} = \overline A ∪ \overline B

  • Solution: We prove this identity by showing that:

    1. overline(AB)ABoverline{(A ∩ B)} ⊆ \overline A ∪ \overline B

    2. overlineABoverline(AB)overline A ∪ \overline B ⊆ overline{(A ∩ B)}

Proof of Second De Morgan Law2

These steps show that: overline(AB)ABoverline{(A ∩ B)} ⊆ \overline A ∪ \overline B

(x(AB))(x ∈ \overline{(A ∩ B)} ) by assumption

(x(AB))(x ∉ (A ∩ B)) by defn. of complement

¬(xAxB)¬ (x ∈ A ∧ x ∈ B) by defn. of intersection

(¬xA¬xB)(¬ x ∈ A ∨ ¬ x ∈ B) by 1st De Morgan law for Prop Logic

(xAxB)(x ∉ A ∨ x ∉ B) defn. of negation

(xAxB)(x ∈ \overline A ∨ x ∈ \overline B) defn. of complement

(x(AB))(x ∈ (\overline A ∪ \overline B)) by defn. of union

Proof of Second De Morgan Law3

These steps show that: overlineABoverline(AB)overline A ∪ \overline B ⊆ overline{(A ∩ B)}

x(AB)x ∈ (\overline A ∪ \overline B) by assumption

xAxBx ∈ \overline A ∨ x ∈ \overline B by defn. of union

xAxBx ∉ A ∨ x ∉ B defn. of complement

¬(xA)¬(xB)¬ (x ∈ A) ∨ ¬ (x ∈ B) defn. of negation

¬(xAxB)¬ (x ∈ A ∧ x ∈ B) 1st De Morgan law for Prop Logic

¬(x(AB))¬ (x ∈ (A ∩ B)) defn. of intersection

x(AB)x ∈ \overline{(A ∩ B)} defn. of complement

Set-Builder Notation: Second De Morgan Law

xx(AB){x | x ∈ \overline{(A ∩ B)}} by defn. of complement

x¬(AB){x | ¬ ∈ (A ∩ B)} by defn. of does not belong symbol

x¬(xAxB){x | ¬ (x ∈ A ∧ x ∈ B)} by defn. of intersection

x(¬xA¬xB){x | (¬ x ∈ A ∨ ¬ x ∈ B)} by 1st De Morgan law for Prop Logic

x(xAxB){x | (x ∉ A ∨ x ∉ B)} by defn. of not belong symbol

xxAxB{x | x ∈ \overline A ∨ x ∈ \overline B} by defn. of complement

xx(AB){x | x ∈ (\overline A ∪ \overline B)} by defn. of union

overlineAB{overline A ∪ \overline B} by meaning of notation

Membership Table Example

  • Example: Construct a membership table to show that the distributive law A(BC)=(AB)(AC)A ∪ (B ∩ C) = (A ∪ B) ∩ (A ∪ C) holds.

A

B

C

B∩C

A∪ (B∩C)

A∪B

A∪C

(A∪B) ∩ (A∪C)

1

1

1

1

1

1

1

1

1

1

0

0

1

1

1

1

1

0

1

0

1

1

1

1

1

0

0

0

1

1

1

1

0

1

1

1

1

1

1

1

0

1

0

0

0

1

0

0

0

0

1

0

0

0

1

0

0

0

0

0

0

0

0

0