Sets & Set Operations

advertisement
Discussion #21
Sets & Set Operations;
Tuples & Relations
Discussion #21
1
Topics

Sets and Set Operations
 Definitions
 Operations
 Set
Laws
 Derivations, Equivalences, Proofs

Tuples and Relations
 pairs & n-tuples
 Cartesian Product
 Relations  subset of the cross product
 Tuples
Discussion #21
2
Sets
Sets are collections


The things in a collection are called elements or members
 Sets have no duplicates.

Notation { }





Special sets




N natural numbers {0, 1, 2, …} (some exclude 0 from this set)
Z integers; R reals
“set builder” notation



Enumerate: {1, 2, 3}
Ellipsis: {1, 2, …} or {1, 2, … , 100}
Universe: U, universe of discorse
Empty set: { } or  i.e. set with no elements
{ x | P(x)} all elements in U that satisfy predicate P
{ x | x>5  x<10} = {6, 7, 8, 9} when U = N
Element of: x  A
Cardinality

|A| or #A

both denote the number of elements in A, e.g. |{a,b}| = 2
Discussion #21
3
Set Equality, Subsets, Supersets
Set Equality
A = B if A and B have the same elements
A = B  xA  xB
 Subsets

 B  xA  xB (subset or equal)
 A  B  A  B  x(xB  xA) (proper subset)
A

Supersets
A  B if B  A
A  B if B  A
Discussion #21
4
Proofs about Set Equality
and the Empty Set

Prove: A = B iff A  B  B  A
A=B
 xA  xB
definition of set equality
 (xA  xB)  (xB  xA) P  Q  (P  Q)  (Q  P)
ABBA
definition of subset

Prove:   A (i.e.  is a subset of every set.)
A
 x  xA definition of subset
 F  xA
x   is false (for if not there is an element of U
T
Discussion #21
in the empty set, contrary to the defintion)
5
Set Operations: Intersection
Intersection
A  B  {x | xA  xB}
{1, 2, 3}  {2, 3, 4} = {2, 3}
A
B
Prove: A  B  A
By definition, A  B  A  xAB  xA
1. xA
2. xAB
3. xA  xB
4. xA
5. xA  xA
6. F
Discussion #21
assume negation of conclusion
premise
def of 
3, simplification
1&4, conjunction
5, contradiction
6
Set Operations: Intersection
Intersection
A  B  {x | xA  xB}
{1, 2, 3}  {2, 3, 4} = {2, 3}
A
B
Prove: A  B  A
By definition, A  B  A  xAB  xA
1. xA
2. xAB
3. xA  xB
4. xA
5. xA  xA
6. F
Discussion #21
assume negation of conclusion
premise
A simpler proof.
def of 
3, simplification
1&4, conjunction
5, contradiction
7
Set Operations: Union
Union
A  B  {x | xA  xB}
{1, 2, 3}  {2, 3, 4} = {1, 2, 3, 4}
No duplicates!
A
B
Prove: A  A  B
By definition, A  AB  xA  xA  xB
1. xA
2. xA  xB
Discussion #21
premise
1, law of addition
8
Set Operations: Set Difference
Difference (minus)
A – B  {x | xA  xB}
{1, 2, 3} – {2, 3, 4} = {1}
Remove elements of B from A
A
B
Prove: A – B  A
By definition, A – B  A  xA–B  xA
1. x  A – B
premise
2. x  A  x  B
definition
3. x  A
simplification
Discussion #21
9
Set Operations: Complement
Complement
~ A  U – A  {x | xU  xA}
~{1, 2, 3} = {4} if U = {1, 2, 3, 4}
A
Prove: A  ~A = 
A  ~A = 
 A  ~A      A  ~A
set equality
 A  ~A    T  is a subset of every set
 A  ~A  
identity
 x  A  x  ~A  x  
def of  and 
 x  A  x  U  x  A  x   def of ~
Fx
comm., contradict., dominat.
T
Note: Unary operators have precedence over binary operators. Use
parentheses for the rest. Possible to define precedence: ~, , , .
Discussion #21
10
Basic Set Identities
Set Algebra
Name
A  ~A = U
A  ~A = 
AU=A
A=A
Complementation law
Exclusion law
Identity laws
AU=U
A=
Domination laws
AA=A
AA=A
Idempotent laws
Duals:  and E
Discussion #21
11
Basic Set Identities (continued…)
Set Algebra
Name
~(~A) = A
Double
Complement
Commutative laws
AB=BA
AB=BA
(A  B)  C = A  (B  C)
(A  B)  C = A  (B  C)
Associative laws
A  (B  C) = (A  B)  (A  C)
A  (B  C) = (A  B)  (A  C)
~ (A  B) = ~A  ~B
~ (A  B) = ~A  ~B
Distributive laws
Discussion #21
De Morgan’s laws
12
Example: Set Laws

Absorption
A  (A  B) = A
A  (A  B) = A

A
B
Venn Diagram “Proof”
Prove: A  (A  B) = A
A  (A  B)
= (A  )  (A  B)
= A  (  B)
=A
=A
Discussion #21
ident.
distrib.
dominat.
ident.
13
Tuples


Things (usually a small number of things) arranged
in order
2-tuples
 pairs (x, y)
 ordered (x,


y)  (y, x) unless x = y
n-tuples = (x1, x2, …, xn)
Typically, elements in tuples are taken from known
sets
x
 females, y  males
(Mary, Jim) e.g. might mean: Mary and Jim are a married couple
x
 people, y  cars
(Mary, red sports car17) e.g. might mean: Mary owns red sports car17
 x,
y, z  integers
(3, 4, 7) e.g. might mean: 3 + 4 = 7
Discussion #21
14
Cartesian Product
A  B = {(x, y) | xA  yB}
e.g. A = {1, 2}
B = {a, b, c}
A  B = {(1, a), (1, b), (1, c),
(2, a), (2, b), (2, c)}
 |A  B| = |A| · |B| = 2 · 3 = 6

Discussion #21
15
Cartesian Product (continued…)


n-fold Cartesian Product
A1  …  An = {(x1, …, xn) | xA1  …  xnAn}
e.g. A = {1, 2}
B = {a, b, c}
C = {, }
A  B  C = {(1,a,), (1,a,), (1,b,), (1,b,), (1,c,), (1,c,),
(2,a,), (2,a,), (2,b,), (2,b,), (2,c,), (2,c,)}
Can get large:
A = set of students at BYU
(30,000)
B = set of BYU student addresses
(10,000)
C = set of BYU student phone#’s
(60,000)
|A|  |B|  |C| = 1.8  1013
Discussion #21
16
Relations

Relation
 Subset
of the cross product
 Not necessarily a proper subset
 R  A  B or R  A  B  C

Examples:
A
= {1, 2} & B = {a, b, c}
R = {(1, a), (2, b), (2, c)}
 A = {1, 2} & B = {a, b, c} & C = {, }
R = {(1, a, ), (2, c, )}
 Marriage: subset of the cross product of
males and females
Discussion #21
17
Download