50
DISCRETE MATHEMATICS I LECTURES CHAPTER 6 Dr. Adam Anthony Spring 2011 Some material adapted from lecture notes provided by Dr. Chungsim Han and Dr. Sam Lomonaco

Discrete Mathematics I Lectures Chapter 6

Embed Size (px)

DESCRIPTION

Discrete Mathematics I Lectures Chapter 6. Some material adapted from lecture notes provided by Dr. Chungsim Han and Dr. Sam Lomonaco. Dr. Adam Anthony Spring 2011. … and now for something completely different…. Set Theory. - PowerPoint PPT Presentation

Citation preview

Page 1: Discrete Mathematics I Lectures Chapter 6

DISCRETE MATHEMATICS ILECTURES CHAPTER 6Dr. Adam Anthony

Spring 2011

Some material adapted from lecture notes provided by Dr. Chungsim Han and Dr. Sam Lomonaco

Page 2: Discrete Mathematics I Lectures Chapter 6

… and now for something completely different…

Set TheoryActually, you will see that logic

and set theory are very closely related.

Page 3: Discrete Mathematics I Lectures Chapter 6

Set Theory

• Set: Collection of objects (“elements”)

• aA “a is an element of A” “a is a member of A”

• aA “a is not an element of A”

• A = {a1, a2, …, an} “A contains…”

• Order of elements is meaningless

• It does not matter how often the same element is listed – repeats are OK!.

Page 4: Discrete Mathematics I Lectures Chapter 6

Set Equality

Sets A and B are equal if and only if they contain exactly the same elements.

Examples:• A = {9, 2, 7, -3}, B = {7, 9, -3, 2} :

A = B

• A = {dog, cat, horse}, B = {cat, horse, squirrel, dog} :

A B

• A = {dog, cat, horse}, B = {cat, horse, dog, dog} : A = B

Page 5: Discrete Mathematics I Lectures Chapter 6

Examples for Sets

“Standard” Sets:• Natural numbers N = {0, 1, 2, 3, …}• Integers Z = {…, -2, -1, 0, 1, 2, …} • Positive Integers Z+ = {1, 2, 3, 4, …}• Real Numbers R = {47.3, -12, , …}• Rational Numbers Q = {1.5, 2.6, -3.8, 15,

…}(correct definition will follow)

Page 6: Discrete Mathematics I Lectures Chapter 6

Examples for Sets

• A = “empty set/null set” • A = {z} Note: zA, but z {z}• A = {{b, c}, {c, x, d}}• A = {{x, y}}

Note: {x, y} A, but {x, y} {{x, y}}• A = {x | P(x)}

“set of all x such that P(x)”• A = {x | xN x > 7} = {8, 9, 10, …}

“set builder notation”

Page 7: Discrete Mathematics I Lectures Chapter 6

Examples for Sets

We are now able to define the set of rational numbers Q:Q = {a/b | aZ bZ+}

or Q = {a/b | aZ bZ b0}

And how about the set of real numbers R?

R = {r | r is a real number}That is the best we can do.

Page 8: Discrete Mathematics I Lectures Chapter 6

Exercise 1

What are the members of the following sets? A = {x| x R x2 = 5}

B = {n | n Z n 2}

Use set-builder notation to describe the following sets: The set of all positive integers that are

divisible by 3 The set of all animals with black and white

stripes

Page 9: Discrete Mathematics I Lectures Chapter 6

Why Sets?

Sets add another layer of notational convenience

Call it Logic 3.0! We can use sets to simplify logic expressions

Let BW = {x | x is an animal and x has black and white stripes}

All animals with black and white stripes are easy to see a BW, easy-to-see(a)

There exists an animal without black and white stripes that is easy to see aBW, easy-to-see(a)

Page 10: Discrete Mathematics I Lectures Chapter 6

Subsets

A B “A is a subset of B”A B if and only if every element of A is also an element of B.We can completely formalize this:A B x (xA xB)

Examples:A = {3, 9}, B = {5, 9, 1, 3}, A B ?

true

A = {3, 3, 3, 9}, B = {5, 9, 1, 3}, A B ?

false

true

A = {1, 2, 3}, B = {2, 3, 4}, A B ?

Page 11: Discrete Mathematics I Lectures Chapter 6

Subsets

Useful rules:• A = B (A B) (B A) • (A B) (B C) A C (see Venn

Diagram)U

AB

C

Page 12: Discrete Mathematics I Lectures Chapter 6

Subsets

Useful rules:• A for any set A • A A for any set A

Proper subsets: A B “A is a proper subset of B” A B x (xA xB) x (xB xA) or A B x (xA xB) x (xB xA)

Page 13: Discrete Mathematics I Lectures Chapter 6

Exercise 2

Is 3A? Is {3} A? Is {3} A? Is 3 A? Is 3 B? Is 3 B?

Is A B? Is A D? Is C A? Is D A? Is A = C? Is A = D?

Let A = {1,3,4}, B = {1,2,4}, C = {4,3,1,1}, D = {1,2,3,4}

Page 14: Discrete Mathematics I Lectures Chapter 6

Exercise 3

Let A = {a | a Z a -3}, B = {b | b Z bk = 5 for some k

Z+}, C = {c | c Z c is prime 7 < c <

10} Describe A, B and C by listing their

elements

Is B A? Is A B? Is C A?

Page 15: Discrete Mathematics I Lectures Chapter 6

Cardinality of Sets

If a set S contains n distinct elements, nN,we call S a finite set with cardinality n.

Examples:A = {Mercedes, BMW, Porsche}, |A| = 3

B = {1, {2, 3}, {4, 5}, 6} |B| = 4C = |C| = 0

D = { xN | x 7000 } |D| = 7001

E = { xN | x 7000 } E is infinite!

Page 16: Discrete Mathematics I Lectures Chapter 6

The Power Set

(A) “power set of A” (A) = {B | B A} (contains all subsets of A)

Examples:

A = {x, y, z} (A) = {, {x}, {y}, {z}, {x, y}, {x, z}, {y, z}, {x,

y, z}}

A = (A) = {} Note: |A| = 0, | (A)| = 1

Page 17: Discrete Mathematics I Lectures Chapter 6

The Power Set

Cardinality of power sets: | (A) | = 2|A|

• Imagine each element in A has an “on/off” switch• Each possible switch configuration in A

corresponds to one element in 2A

zzzzzzzzz

yyyyyyyyy

xxxxxxxxx

87654321A

• For 3 elements in A, there are 222 = 8 elements in P(A)

Page 18: Discrete Mathematics I Lectures Chapter 6

Exercise 4

Find the power sets ({1,2}) and ({1,2,3})

Page 19: Discrete Mathematics I Lectures Chapter 6

Ordered Pairs

We are familiar with ordered pairs in algebra when we plot on a Cartesian coordinate system:

The pair (x,y) is ordered so that we know how to plot it on the axes

Important: (a,b) = (c,d) a = c and b = d The order matters!

(x,y)

Page 20: Discrete Mathematics I Lectures Chapter 6

Cartesian Product

The ordered n-tuple (a1, a2, a3, …, an) is an ordered

collection of objects. Just a general version of the ordered pair:

Two ordered n-tuples (a1, a2, a3, …, an) and

(b1, b2, b3, …, bn) are equal if and only if they contain exactly

the same elements in the same order, i.e. ai = bi for 1 i n.

The Cartesian product of two sets is defined as:AB = {(a, b) | aA bB}Example: A = {x, y}, B = {a, b, c}AB = {(x, a), (x, b), (x, c), (y, a), (y, b), (y, c)}

Page 21: Discrete Mathematics I Lectures Chapter 6

Cartesian Product

The Cartesian product of two sets is defined as: AB = {(a, b) | aA bB}Example:A = {good, bad}, B = {student, prof}

AB = {(good, student), (good, prof), (bad, student), (bad, prof)}

(student, good), (prof, good), (student, bad), (prof, bad)} BA = {

Page 22: Discrete Mathematics I Lectures Chapter 6

Cartesian Product

Note that:• A = • A = • For non-empty sets A and B: AB AB BA• |AB| = |A||B|

The Cartesian product of two or more sets is defined as:A1A2…An = {(a1, a2, …, an) | aiA for 1 i n}

Page 23: Discrete Mathematics I Lectures Chapter 6

Set Operations

Union: AB = {x | xA xB}

Example: A = {a, b}, B = {b, c, d} AB = {a, b, c, d}

Intersection: AB = {x | xA xB}

Example: A = {a, b}, B = {b, c, d} AB = {b}

Page 24: Discrete Mathematics I Lectures Chapter 6

Set Operations

Two sets are called disjoint if their intersection is empty, that is, they share no elements:

AB = If a set C = A B and A and B are disjoint, then the set P = {A,B} is referred to as a partition of C

The difference between two sets A and B contains exactly those elements of A that are not in B:A-B = {x | xA xB}Example: A = {a, b}, B = {b, c, d}, A-B = {a}

Page 25: Discrete Mathematics I Lectures Chapter 6

Set Operations

Given a Universe identified by the set U, the complement of a set A contains exactly those elements under consideration that are not in A: Ac = U-A

Example: U = N, B = {250, 251, 252, …} Bc = {0, 1, 2, …, 248, 249}

Page 26: Discrete Mathematics I Lectures Chapter 6

Exercise 5

Let the Universe U = {0,1,2,3,…,9} and: A = {0,2,4,6,8}B = {1, 2, 4, 7}C = {1,5,7}

Find the following: A B A B Bc

A - B

(A B)c

A (B C) (A B) C Ac Bc

Page 27: Discrete Mathematics I Lectures Chapter 6

Exercise 6

Let A = {1,2,3,4,5,6,7} Which collections form a partition of A? P1 = {1,3}, {2,5}, {4,6,7} P2 ={1}, {2,4,6}, {3,5} P3 ={1,3,5,7}, {2,4,6}, {3,6}

Let B = {x | x R x -2 }, C = {x | x R -2 < x 4}, D = {x | x R x > 4} Is P4 = {B,C,D} a partition of R?

Page 28: Discrete Mathematics I Lectures Chapter 6

Venn Diagrams of Operations NOTE: The amount that A and B overlap

is not always guaranteed

A B

Page 29: Discrete Mathematics I Lectures Chapter 6

Venn Diagrams of Operations A

A B

Page 30: Discrete Mathematics I Lectures Chapter 6

Venn Diagrams of Operations B

A B

Page 31: Discrete Mathematics I Lectures Chapter 6

Venn Diagrams of Operations A B

A B

Page 32: Discrete Mathematics I Lectures Chapter 6

Venn Diagrams of Operations A B

Page 33: Discrete Mathematics I Lectures Chapter 6

Venn Diagrams of Operations A - B

Page 34: Discrete Mathematics I Lectures Chapter 6

Venn Diagrams of Operations Ac

Page 35: Discrete Mathematics I Lectures Chapter 6

Exercise 7

Draw a Venn Diagram to represent the following expressions over the sets A,B and C: A B = A B = A and C B C A B Ac – C A B and A C and B C BUT

A B C

Page 36: Discrete Mathematics I Lectures Chapter 6

Section 6.2,6.3: Properties of Sets Unifying Logic and Sets Proofs with sets Set identities

Page 37: Discrete Mathematics I Lectures Chapter 6

Logic and Sets

We can interpret our set operations logically: A B x A x B (Set-based implication) A B x A x B (Set-based OR) A B x A x B (Set-based AND) x Ac x A (Set-based Negation) A – B x A x B (NEW expressive

power!) (x,y) A x B x A y B (NEW expressive

power!)

Page 38: Discrete Mathematics I Lectures Chapter 6

Element Arguments

Prove that for all sets A and B, A B A Normal starting Point: “Suppose A and B are arbitrarily

chosen sets” Where does this get us?

We make more progress using an ‘element argument’: Note that A B A translates to “If x A B then x A” From this, we get the statement: “Suppose A and B are

arbitrarily chosen sets and x A B” Idea: focusing on a single arbitrary element in a set

lets us prove something about every single element in the set!

Page 39: Discrete Mathematics I Lectures Chapter 6

Transitivity Revisited

Prove, using logical interpretations, the transitive property for subsets: For all sets A, B and C, if A B and B C,

then A C.

Page 40: Discrete Mathematics I Lectures Chapter 6

Proving Equality

How can we Prove A(BC) = (AB)(AC)?

Recall: A = B A B B A To prove A = B, you must show both subset

claims are true So an equality proof really requires

2 element proofs!

Page 41: Discrete Mathematics I Lectures Chapter 6

Prove A(BC) = (AB)(AC).

1. Prove that A(BC) (AB)(AC): Suppose that x is an arbitrarily chosen element of A(BC). There are 2 cases for x: x A or x (BC)Case 1: x A

Since x A, by definition of union, x (A B) and x (A C). Therefore, by definition, x (AB)(AC).

Case 2: x (BC). By definition of intersection, x B and x C. By definition of union, x (AB) and x (AC).Therefore, by definition of intersection, x (AB)(AC)

Page 42: Discrete Mathematics I Lectures Chapter 6

Prove A(BC) = (AB)(AC).

2. Prove that (AB)(AC) A(BC) Drawing a Venn diagram might help us think this through…Suppose that x is an arbitrarily chosen element of (AB)(AC). We’ll analyze this one element in two cases: x A and x A. Case 1: x A

It immediately follows that x A(BC) by definition of union. Case 2: x A

Since x (AB)(AC), it must be true that x (AB) and x (AC). Since x A in this case, it must follow that x B and x C or else x would not be a member of (AB)(AC).

Therefore, by definition of intersection, x (BC) and by definition of Union, x A(BC)

Page 43: Discrete Mathematics I Lectures Chapter 6

OR…Use logic instead!

How can we prove A(BC) = (AB)(AC)?

Suppose x is an arbitrary element of A(BC). Then by definition, the following statements are true:

x(A(BC))Û (xA) (x(BC))Û (xA) (xB xC)Û (xA xB) (xA xC)

(distributive law for logical expressions)Û (x(AB)) (x(AC))Û x((AB)(AC))

Since each statement is a biconditional with the one before it, x(A(BC)) x((AB)(AC)) and x((AB)(AC)) x(A(BC)) . So by definition, (A(BC)) ((AB)(AC)) and ((AB)(AC)) (A(BC)). Therefore, A(BC) = (AB)(AC)

Page 44: Discrete Mathematics I Lectures Chapter 6

Which method to use?

You may use an element argument or logic conversions to prove set identities on assignments and exams

Which one you choose depends on your strengths

Neither approach is ‘easier’ than the other

Element arguments provide more direction about where you’re headed

Logic arguments have less direction, but tend to be more concise

Page 45: Discrete Mathematics I Lectures Chapter 6

Set Identities—Look Familiar?

Page 46: Discrete Mathematics I Lectures Chapter 6

Exercise 1

Use Venn Diagrams to verify the following set-theoretic DeMorgan’s law:

(A B)c = Ac Bc

Page 47: Discrete Mathematics I Lectures Chapter 6

Exercise 2

Recall that two sets are disjoint if their intersection is the empty set (A B = ). Draw venn diagrams for the sets A – B and

B – A

Use Theorem 6.2.2 to construct a proof that A – B and B – A are disjoint

Page 48: Discrete Mathematics I Lectures Chapter 6

Exercise 3

Use Theorem 6.2.2 to prove the following:

(A (B C) ((A B) – C) = A B

Page 49: Discrete Mathematics I Lectures Chapter 6

A Technology Tie-In

Don’t forget your set theory—You’ll use it in Databases!

Each ‘table’ in a database is called a relation, filled with tuples Database theory

says that a relation is actually a subset of the universe of all possible tuples

sid sname rating age28 yuppy 9 35.031 lubber 8 55.544 guppy 5 35.058 rusty 10 35.0

Sailors

Page 50: Discrete Mathematics I Lectures Chapter 6

A Technology Tie-In

SQL (structured query language): Select SID, SNAME, RATING, AGE FROM SAILORS WHERE AGE > 40

S = {X SAILORS | AGE > 40}

See the similarity? Remembering set-theory will really help you work with databases

sid sname rating age28 yuppy 9 35.031 lubber 8 55.544 guppy 5 35.058 rusty 10 35.0

Sailors