<<

Discrete CS 2610 January 27, 2009 - part 2 Agenda Previously: theory „ (proper subsets) & set equality „ StSet cardilitdinality „ Power sets „ n- & „ Set operations Š , Intersection, , Difference „ Venn diagrams Now „ Symmetric difference „ Proving properties about sets „ Sets as bit-strings „ Functions

2 Symmetric Difference

The symmetric difference, A ⊕ B, is: A ⊕ B = { x | (x ∈ A ∧ x ∉ B) v (x ∈ B ∧ x ∉ A)}

(i.e., x is in one or the other, but not in both)

IitIs it commu tti?tative ?

3 Set Identities

Identity: „ A ∪∅= A , A ∩ U = A Domination:

„ A ∪ U = U , A ∩∅= ∅

Idempotent:

„ A ∪ A = A = A ∩ A

DblDouble complement :

„ ( A ) = A Commutative: „ A ∪ B = B ∪ A , A ∩ B = B ∩ A

Associative:

„ A ∪ (B ∪ C) = (A ∪ B) ∪ C „ A ∩ (B ∩ C) = (A ∩ B) ∩ C 4 Set Identities

Absorption:

„ A ∪ (A ∩ B) = A

„ A ∩ (A ∪ B) = A

Complement:

„ A ∪ A¯ = U

„ A ∩ A¯ = ∅

Distributive:

„ A ∩ (B ∪ C) = (A ∩ B) ∪ (A ∩ C) „ A ∪ (B ∩ C) = (A ∪ B) ∩ (A ∪ C)

5 De Morgan’s Rules

De Morgan’s I (A U B) = A ∩ B

DeMorgan’s II (A ∩ B) = A U B

6 Generalized Union

n UAi = A1 ∪ A2 ∪... ∪ An i=1

The union of a collection of sets contains those elements that belong to at least one set in the collec tion.

7 Generalized Intersection

n ∩Ai = A1 ∩ A2 ∩... ∩ An i=1

The intersection of a collection of sets contains those elements that belong to all the sets in the collec tion.

8 Proving Set Identities

How would we prove set identities of the form

S1 = S2

Where S1 and S2 are sets?

1. Prove S1 ⊆ S2 and S2 ⊆ S1 separately. „ Use previously proven set identities.

„ Use logical equivalences to prove equivalent set definitions.

2. Use a membership table.

9 Proof Using Logical Equivalences

Prove that (A U B) = A ∩ B Proof: First show (A U B) ⊆ A ∩ B, then the reverse. Let c ∈ (A U B) c ∈ {x | x ∈ A ∨ x ∈ B} (Def. of union) ¬ (c ∈ A ∨ c ∈ B) (Def. of complement) ¬ (c ∈ A) ∧¬(c ∈ B) (De Morgan’s rule) (c ∉ A) ∧ (c ∉ B) (Def. of ∉) (c ∈ A) ∧ (c ∈ B) (Def. of complement) c ∈ {x | x ∈ A ∧ x ∈ B} (Set builder notation) c ∈ A ∩ B (Def. of intersection) Therefore, (A U B) ⊆ A ∩ B. Each step above is reversible, therefore A ∩ B ⊆ (A U B).

10 Proof Using Membership Table

Using membership tables

(A U B) = A ∩ B

1 : means x is in the Set 0 : means x is not in th e Set

A B A BAA ∩ B U BA U B

1 1 0 0 0 1 0 1 0 0 1 0 1 0 0 1 1 0 0 1 0 0 0 1 1 1 0 1 The two columns are the same. Therefore, x ∈ (A U B) iff x ∈ A ∩ B – i.e., the equality holds. 11 Sets as Bit-Strings

For a finite U = {a1, a2, …,an} 1. Assign an arbitrary to the elements of U. 2. Represent a A of U as a string of n bits,

B = b1b2…bn

⎧0 if a i ∉ A bi = ⎨ ⎩1 if a i ∈A

Example: U = {a1, a2, …, a5}, A = {a1, a3, a4 } B = 10110

12 Sets as Bit-Strings

Set theoretic operations

A 1 0 1 0 1 B 0 0 1 1 0 Bit-wise OR A ∪ B 1 0 1 1 1 Bit-wise AND A ∩ B 0 0 1 0 0 Bit-wise XOR A ⊕ B 1 0 0 1 1

13 Functions (Section 2.3)

Let A and B be nonempty sets.

A function f from A to B is an assignment of exactly one of B to each element of A. We write f( )a ) = b if b is the unique e le me nt o f B assig ne d by the function f to the element a in A. If f is a function from A to B, we write f : A . → B Functions are sometimes called mappings.

14 Example

A = {Mike, Mario, Kim, Joe, Jill} B = {John Smith, Edward Groth, Jim Farrow}

Let f:A where f(a) means father of a. → B f Mike John Smith Mario Edward Groth Kim Richard Boon Joe Jill

A B

Can grandmother of a be a function ? 15