discrete mathematics cs 2610 january 27, 2009 - part 2

15
Discrete Mathematics CS 2610 January 27, 2009 - part 2

Upload: jodie-robbins

Post on 06-Jan-2018

219 views

Category:

Documents


2 download

DESCRIPTION

3 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) Is it commutative ?

TRANSCRIPT

Page 1: Discrete Mathematics CS 2610 January 27, 2009 - part 2

Discrete Mathematics CS 2610

January 27, 2009 - part 2

Page 2: Discrete Mathematics CS 2610 January 27, 2009 - part 2

2

AgendaPreviously: Set theory Subsets (proper subsets) & set equality Set cardinality Power sets n-Tuples & Cartesian product Set operations

Union, Intersection, Complement, Difference Venn diagrams

Now Symmetric difference Proving properties about sets Sets as bit-strings Functions

Page 3: Discrete Mathematics CS 2610 January 27, 2009 - part 2

3

Symmetric DifferenceThe 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)

Is it commutative ?

Page 4: Discrete Mathematics CS 2610 January 27, 2009 - part 2

4

Set IdentitiesIdentity:

A = A , A U = A

Domination: A U = U , A =

Idempotent: A A = A = A A

Double complement:

Commutative: A B = B A , A B = B A

Associative: A (B C) = (A B) C A (B C) = (A B) C

AA =)(

Page 5: Discrete Mathematics CS 2610 January 27, 2009 - part 2

5

Set IdentitiesAbsorption:

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)

Page 6: Discrete Mathematics CS 2610 January 27, 2009 - part 2

6

De Morgan’s Rules De Morgan’s I

DeMorgan’s II

(A U B) = A B

(A B) = A U B

Page 7: Discrete Mathematics CS 2610 January 27, 2009 - part 2

7

Generalized Union

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

Ai

i1

n

U A1 A2 An

Page 8: Discrete Mathematics CS 2610 January 27, 2009 - part 2

8

Generalized Intersection

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

Ai

i1

n

A1 A2 An

Page 9: Discrete Mathematics CS 2610 January 27, 2009 - part 2

9

Proving Set IdentitiesHow 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.

Page 10: Discrete Mathematics CS 2610 January 27, 2009 - part 2

10

Proof Using Logical Equivalences

Prove thatProof: 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).

(A U B) = A B

Page 11: Discrete Mathematics CS 2610 January 27, 2009 - part 2

11

Proof Using Membership Table

Using membership tables

1 : means x is in the Set0 : means x is not in the Set

(A U B) = A B

1000

1000

0111

A U BA B

1010B

100110001011

A U BABA

The two columns are the same. Therefore, x (A U B) iff x A B – i.e., the equality holds.

Page 12: Discrete Mathematics CS 2610 January 27, 2009 - part 2

12

Sets as Bit-StringsFor a finite universal set U = {a1, a2, …,an} 1. Assign an arbitrary order to the elements of U.2. Represent a subset A of U as a string of n bits, B = b1b2…bn

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

A a if1A a if0

bi

ii

Page 13: Discrete Mathematics CS 2610 January 27, 2009 - part 2

13

Sets as Bit-StringsSet theoretic operations

A BA BA B

BA

00100111010110010101

Bit-wise ORBit-wise AND

11001Bit-wise XOR

Page 14: Discrete Mathematics CS 2610 January 27, 2009 - part 2

14

Functions (Section 2.3)Let A and B be nonempty sets.

A function f from A to B is an assignment of exactly one element of B to each element of A. We write f(a) = b if b is the unique element of B assigned 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.

Page 15: Discrete Mathematics CS 2610 January 27, 2009 - part 2

15

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

Let f:A B where f(a) means father of a.

Can grandmother of a be a function ?

Mike Mario

Kim Joe Jill

John SmithEdward GrothRichard Boon

f

A B