You are on page 1of 24

Set Operations

Chapter 2

The University of Texas at Dallas www.utdallas.edu


Cartesian

The University of Texas at Dallas www.utdallas.edu


Example

The University of Texas at Dallas www.utdallas.edu


Equality

The University of Texas at Dallas www.utdallas.edu


Definitions

The University of Texas at Dallas www.utdallas.edu


More Definitions

The University of Texas at Dallas www.utdallas.edu


Example

The University of Texas at Dallas www.utdallas.edu


Venn Diagrams

The University of Texas at Dallas www.utdallas.edu


Venn Diagrams Examples

What about intersection?


The University of Texas at Dallas www.utdallas.edu
Venn Diagrams Examples

What about complement?


The University of Texas at Dallas www.utdallas.edu
Venn Diagrams Examples

What about set difference?

The University of Texas at Dallas www.utdallas.edu


Venn Diagrams Examples

What about symmetric difference?

The University of Texas at Dallas www.utdallas.edu


Venn Diagrams Examples

Can you express symmetric difference using only union, intersection, and complement?

The University of Texas at Dallas www.utdallas.edu


Set Identities
Identity Name

A   A Identity Laws
A U  A

Domination Laws
A   
A U  U

Idempotent Laws
A A  A
A A  A

( A)  A Complement Laws

A B  B  A Commutative Laws
A B  B  A

The University of Texas at Dallas www.utdallas.edu


some more …
Identity Name

A  ( B  C )  ( A  B)  C Associative laws
A  ( B  C )  ( A  B)  C

A  ( B  C )  ( A  B)  ( A  C ) Distributive laws
A  ( B  C )  ( A  B)  ( A  C )

A B  A B DeMorgan’s laws
A B  A B

A  ( A  B)  A Absorption laws
A  ( A  B)  A

A A U Complement laws
A A 

15
The University of Texas at Dallas www.utdallas.edu
How to prove set identities?

• Several methods:
– Use basic definition of sets, and apply logic

– Use existing set identities

– Use set table membership

The University of Texas at Dallas www.utdallas.edu


Example with definitions and logic

The University of Texas at Dallas www.utdallas.edu


continued…

• We will use “universal generalization”


– We will perform our proof of P(x) using an
“arbitrary” x
– Since we did not assume anything specific about x,
we can then conclude that
• x P(x)

The University of Texas at Dallas www.utdallas.edu


𝑥 ∈𝐴∪𝐵 Def. of complement
≡ 𝑥 ∉ (𝐴 ∪ 𝐵) Def. of ∉
≡ ¬ 𝑥 ∈ (𝐴 ∪ 𝐵) Def. of union
≡¬ 𝑥 ∈𝐴∨𝑥 ∈𝐵 DeMorgan’s Laws
≡ ¬(𝑥 ∈ 𝐴) ∧ ¬(𝑥 ∈ 𝐵) Def. of ∉
≡𝑥 ∉𝐴∧𝑥 ∉𝐵 Def. of complement
≡ 𝑥 ∈ 𝐴ҧ ∧ 𝑥 ∈ 𝐵ത Def. of intersection
≡ 𝑥 ∈ (𝐴ҧ ∩ 𝐵)

The University of Texas at Dallas www.utdallas.edu


Example using set identities
Show that A – B = A   A  B 

A  A  B De Morgan’s laws
= A  ( A  B) Distributive Rule
= ( A  A )  ( A  B) Complement Law
=   ( A  B) Identity Law
= ( A  B) Definition of difference
= A B

20
The University of Texas at Dallas www.utdallas.edu
Membership Table

A B A B A B A B AB
1 1 1 0 0 0 0
1 0 1 0 1 0 0
0 1 1 1 0 0 0
0 0 0 1 1 1 1

The University of Texas at Dallas www.utdallas.edu


Computer Representation

• Assume that the universal set U is finite


and a reasonable size n.
• Order the set.
• Represent a subset A of U to be the bit
string of length n which has a 1 in the ith
position if the ith element in the ordering
is in set A and a 0 otherwise.

The University of Texas at Dallas www.utdallas.edu


Example

• U = {1,2,3,4,5,6,7,8,9,10} be ordered in the


usual fashion.
• The set S = {1,5,8}
• Has the representation
1000100100

The University of Texas at Dallas www.utdallas.edu


Union and Intersection of Indexed Collections

The University of Texas at Dallas www.utdallas.edu

You might also like