02 sets and logic

79
Chapter 2 - Sets

Upload: alex-bernier

Post on 26-Jan-2016

247 views

Category:

Documents


0 download

DESCRIPTION

f

TRANSCRIPT

Page 1: 02 Sets and Logic

Chapter 2 - Sets

Page 2: 02 Sets and Logic

Definition

• Universal Set – everything you can choose from

• Set – “Well defined” collection of objects from the

universal set– Usually denoted with capital letter (A)

• Element– an object within a set– Denoted with lower case letter (x)

Page 3: 02 Sets and Logic

Well Defined

• The set of positive integers < 25• The set of all smart students in class• The set of odd numbers• The set of odd numbers divisible by 10• The set of letters in the word superstars• The set of blonde people at App.

Page 4: 02 Sets and Logic

Well Defined

• The set of positive integers < 25– Well defined

• The set of all smart students in class– Not well defined? How could we fix it?

• The set of odd numbers divisible by 10– Well defined

• The set of letters in the word superstars– Well defined

• The set of blonde people at App.– Not well defined. How could we fix this?

Page 5: 02 Sets and Logic

Set Notation

• xA – read “x is an element of A”

(x is considered to be a MEMBER of A)• x A– read “x is not an element of A”

• If P is the set of prime numbers101 P24 P

Page 6: 02 Sets and Logic

Describe a Set

• List all elementX={3, 6, 8, 12, 17}

• Describe the elementsP={x:x is a prime number}

• List enough elements to give an ideaZ={0,1,-1,2,-2,3,-3,…} ellipsis means “and so on”

• Specify multiple constraints• C = {y:y is an integer, 3<y<9}

Page 7: 02 Sets and Logic

Describe a Set

• P={x:x is a prime number}read “the set of all x where x is a prime number”

• C = {y:y is an integer, 3y<9}read “the set of all y where y is an integer and y is greater than or equal to 3 and y is less than 9”

Page 8: 02 Sets and Logic

Properties of Sets

• Order is not important– Order does help reader see a pattern

• Lists cannot have duplicates• Two sets are equal if they have the same

elements

{2, 3, 4, 2} = {2, 3, 4} = {4, 3, 2, 4, 4}

Page 9: 02 Sets and Logic

Write the following sets

• {x:x is an odd integer, 5 x 93}

• {x:x is a perfect square, x 225

• {y:y is a positive integer, y is a multiple of 3}

Page 10: 02 Sets and Logic

Write the following sets

• {x:x is an odd integer, 5 x 93}{5,7,9,11,…,91,93}

• {x:x is a perfect square, x 225{0,1,4,9,16,25,…,225}

• {y:y is a positive integer, y is a multiple of 3}{3,6,9,12,15,…}

Page 11: 02 Sets and Logic

P = {x: x is a prime number}Z = {0,3,-3,5,-5,7,-7,…}C={e: e is an integer -8 y < 5B={11,13,15,17,19}

• List the 7 smallest elements of P• What are the next 4 elements of Z• Describe Z using the property format• Describe B using the property format• Describe C using the list format• Which sets are infinite?

Page 12: 02 Sets and Logic

Empty Set or Null Set

• An Empty Set has no elements– Shown as {} or

• The set of odd numbers divisible by 10• Numbers greater than 5 and less than 3• Humans who can run the mile in less than 2

minutes

Page 13: 02 Sets and Logic

Sets can contain other sets

• A={{1},{2},{3}}

• B={1, {2}, 3, {4} }

• C= { 1, 2, {3,4}, {5,6,7}, {{8},{9}} }

Page 14: 02 Sets and Logic

Cardinality

• Cardinality is the number of elements in a set• Written with bars on either side | |

A={1,2,3}|A| = 3

B={1, {2}, 3, {4} }|B| = 4

C= { 1, 2, {3,4}, {5,6,7}, {{8},{9}} } |C| = ?

Page 15: 02 Sets and Logic

Some Defined Sets

• N = {0,1,2,…} - Natural (0 is iffy)• N+ = {1, 2, 3, …} - Positive Natural• Z = {0,1,-1,2,-2,3,-3,…} - Integers• Q = {x: x=a/b, a Z, b Z, b 0 } - Rational• R = {x:x is any point on a number line} - Real

Page 16: 02 Sets and Logic

Singleton

• Set with cardinality of 1• A= {1}• B={ {1,2} }• C={ Number of people in this room right now

with a first name of Joel }

• What about the followingD={}

Page 17: 02 Sets and Logic

Subsets

• If a second set contains many or all of the elements of a first set, and contains no elements that are not in the first set, that second set is called a subset.

• X={1,2,3,5}• Y={2,3}• Y is a subset of X

Written: Y X• X is not a subset of Y, X is a superset of Y• is always a subset of any set

Page 18: 02 Sets and Logic

Proper Subsets

Subset• A B

Proper Subset • A B

Page 19: 02 Sets and Logic

Proper Subsets• A proper subset has at least one element missing

from it's superset.• A = {1,2,3,4}

{1,2} is a proper subset{1,2,4} is a proper subset{1,2,3,4} is not a proper subset

• Proper subset symbol

• Improper subset symbol

Page 20: 02 Sets and Logic

Proper Subsets

Subset• A={1,2,3,5}• B={1,2,3,5}• A B • B A• A = B (Can be equal)• A subset includes the

possibility that all elements are the same. Proper subsets do not.

Proper Subset • X={1,2,3,5}• Y={2,3}• Y X (and Y X)• If Y is a proper subset of X that

means that X contains elements that Y does not.

• X Y (Can never be equal)• The book uses this symbol for

both types of subsets• A Proper subset is also a

subset

Page 21: 02 Sets and Logic

Membership vs Subset

• A = { 1, 2, 3 }• 1 is a element of A, but 1 is not a subset of A• {1} is a subset of A, but {1} is not an element of A• {} is a subset of A but is not an element of A

Page 22: 02 Sets and Logic

Power Set

• Collection of all possible subsets• Denoted P () • A = {1, 2, 3}• P (A)= { {}, {1},{2},{3},{1,2}, {1,3}, {2,3}, {1,2,3}}• If the set A has n elements then P (A) has 2n

elements.

Page 23: 02 Sets and Logic

Power Set1 2 3 Set Members0 0 0 {} No Element

0 0 1 {3}

0 1 0 {2}

0 1 1 {2,3}

1 0 0 {1}

1 0 1 {1,3}

1 1 0 {1,2}

1 1 1 {1,2,3} All Elements

• A = {1, 2, 3}• P (A)= { {}, {1},{2},{3},{1,2}, {1,3}, {2,3}, {1,2,3}}

Page 24: 02 Sets and Logic

• We can use the definition of subset to more precisely define set equality. Two sets are equal if and only if they are each a subset of the other.

• To prove that set A is a subset of set B, you have two choices. – If set A is very small you can take each of its elements

one at a time and show that that element is in set B. – If set A is large, show that for any arbitrary element

of A that can be selected, that element must be in set B. In other words, say something like "Let x be any element of A" to begin your proof.

Page 25: 02 Sets and Logic

• To show that set A is not a subset of set B, find one element that is in A and that is not in B.

• To show that set A equals set B, show that A is a subset of B and that B is a subset of A.

Page 26: 02 Sets and Logic

Venn Diagrams

• U = Universal Set = N• A = {1,2,4}• B = {2, 8, 16}

A B

U

Page 27: 02 Sets and Logic

Venn Diagrams

• U = Universal Set = N• A = {1,2,4}• B = {2, 4}• B A

A B

U

Page 28: 02 Sets and Logic

Venn Diagrams

• U = Universal Set = N• A = {1,2,4}• B = {1,2,4}• B A

AB

U

Page 29: 02 Sets and Logic

Venn Diagrams

• U = Universal Set = N• A = {1,2,4}• B = {1,2,4}• B A• A B

A B

U

AB

U

Page 30: 02 Sets and Logic

Venn Diagrams

• U = Universal Set = N• A = {1,2,4,9}• B = {2,4,6}• C = {1, 2, 5, 9)

A

B

U

C

Page 31: 02 Sets and Logic

Venn Diagrams

• U = Universal Set = N• A = {1,2,4,9}• B = {2,4,6}• C = {1, 2, 5, 9}• D= { 1, 6, 7, 10}• Where does 6 go?

A

B

U

C

D

Page 32: 02 Sets and Logic

Venn Diagram Problems• U = Universal Set = {1,2,3,…,15}• A = {2,4,6,8,10}• B = {5,10,15}• C = {3,5,7,11}• Draw the Venn diagram

Page 33: 02 Sets and Logic

Venn Diagram Problems

• U = Universal Set = {1,2,3,…,15}• A = {2,4,6,8,10}• B = {5,10,15}• C = {3,5,7,11}

A

B

U

C

2 4 6 8

53 7 11

10

15

1 9 12 13 14

Page 34: 02 Sets and Logic

Intersection Union Complement

• A B Intersection – common to both– A B {x:xA, x B}

• A B Union – In either or both– A B {x:xA or x B}

• A’ Complement – Not in A– A’ = {x:xU, xA}

Page 35: 02 Sets and Logic

Intersection Union Complement

A B Intersection – common to bothA B Union – In either or bothA’ Complement – Not in A

U={1,2,3,…,10} A={1,3,7,8,9} B={2,3,6,7,10} C={1,5,6,8}

– A B = { }– A C = { }– B’ = { }– A C’ = { }– A’ B’ = { }

Page 36: 02 Sets and Logic

Construct Venn Diagrams

• U={1,2,3,…,10} A={1,3,7,8,9} B={2,3,6,7,10} C={1,5,6,8}– A B– A’ B– B’– (A B)’– A’ B’

Page 37: 02 Sets and Logic

Properties

• S1. (A B) C = A (B C) (Associative Unions)• S2. (A B) C = A (B C) (Associative Intersections)

• S3. A B = B A (Commutative Unions)

• S4. A B = B A (Commutative Intersections)

• S5. (A’)’ = A • S6. A (B C) = (A B)(A C) (Distributive)

• S7. A (B C) = (A B) (A C) (Distributive)

• S8. (A B)’ = A’ B’ (De Morgan)

• S9. (A B)’ = A’ B’ (De Morgan)

Page 38: 02 Sets and Logic

More Properties

A = AA = A U = AA A = AA A = AA U = UA B iff A B = BA B iff A B = B

’ = UU’ = A A’ = A A’ = U

Page 39: 02 Sets and Logic

• Regions for (A B) C

– A regions 2, 3, 5, 6– B regions 2, 4, 5, 7– (A B) regions 2, 3, 4, 5,

6, 7– C regions 5, 6, 7, 8– (A B) C regions 2, 3, 4,

5, 6, 7, 8

A BU

C

1

2 3 4

56 7

8

• Regions for A (B C)

– B regions 2, 4, 5, 7– C regions 5, 6, 7, 8– (B C) regions 2,4,5,7,8– A regions 2, 3, 5, 6– A (B C) regions 2, 3, 4,

5, 6, 7, 8

Verify S1. (A B) C = A (B C )

Page 40: 02 Sets and Logic

Verify S2

• S2. (A B) C = A (B C)

Page 41: 02 Sets and Logic

Difference

• A – B is the set of element that are in A, but are not in B

• A – B = {x: x A, x B}

• A = {1,2,5,8}• B = {3,5,8,9}• A-B = {1, 2}

Page 42: 02 Sets and Logic

Symmetric Difference

• A B (or A B)• All elements in A plus all Elements in B minus

the elements in both.• A B = (A B) – (A B )• A B = (A B) (A B )’ • A B = {x: x A or x B, x (A B )}

Page 43: 02 Sets and Logic

Principle of inclusion/exclusion

• Two sets|A B| = |A| + |B| - |A B|

• Three sets|A B C| =

|A| + |B| + |C| - |A B| - |A C| - |B C| + |A B C|

Page 44: 02 Sets and Logic

Word Problems

• A survey of 78 students is conducted. Of that number, 54 students own either a cat or a dog (or both). 46 students own a dog and 26 students own a cat. How many students own both a dog and a cat? How many dog owners do not own a cat? How many cat owners do not own a dog? How many students own only one kind of pet?

Page 45: 02 Sets and Logic

Word Problem

|D| = 46|C| = 26|C D| = 54

|C D| = |C| + |D| - |C D| 54 = 26 + 46 - |C D||C D| = 26 + 46 - 54 = 18 Own Cat and Dog

Page 46: 02 Sets and Logic

Chapter 2 - Logic

Page 47: 02 Sets and Logic

Logic

• Read Sections 2.5 through 2.7 of your textbook• Logic deals with the concepts of true and false• Statement – declarative sentence that is true or false

and may correspond to a mathematical statement• Variables – used to represent statements• Logical Operators - modify and/or connect

statements and variables• Truth Table – A visual means of showing all possible

combinations for a statement.

Page 48: 02 Sets and Logic

The Conjunction Operator• Conjunction – represented by “”– read as “and”– p q read as “p and q” – means p and q are both true– truth table

p q p qT T TT F FF T FF F F

Page 49: 02 Sets and Logic

Conjunction Example

• I have a piece of chalk in my hand AND I have an eraser in my hand.– If both phrases are true the whole statement is true.– If either phrase is false the whole statement is false. – What if both phrases are false?– p = I have a piece of

chalk in my hand– q = I have an eraser

in my hand

p q p qT T TT F FF T FF F F

Page 50: 02 Sets and Logic

The Disjunction Operator

• Disjunction– represented by “”– read as “or”– p q read as “p or q” – means either p or q (or both) is true– truth table

p q p qT T TT F TF T TF F F

Page 51: 02 Sets and Logic

Disjunction Example

• I have a piece of chalk in my hand OR I have an eraser in my hand.– If either phrase is true the whole statement is true.– Both phrases must be false for the whole statement to

be considered false. – What if both phrases are true?– p = I have a piece of

chalk in my hand– q = I have an eraser

in my hand

p q p q

T T TT F TF T TF F F

Page 52: 02 Sets and Logic

The Negation Operator

• Negation– represented by “~” or “”– read as “not”– p read as “not p”– means true if p is false– truth table

p pT FF T

Page 53: 02 Sets and Logic

Negation Example

• The sun is not cold. (True or False?) p = The sun is cold. (False)~p = The sun is not cold. (True)

• Water is not wet. (True or False?) p = Water is wet. (True)~p = Water is not wet. (False)

Page 54: 02 Sets and Logic

The Implication Operator

• Implication– represented by "->"– read as "implies" or "if – then"– p -> q read as "p implies q"

or "if p then q"– p = hypothesis– q = conclusion– truth table

p q p →qT T TT F FF T TF F T

Page 55: 02 Sets and Logic

The Implication Operator 2

• Implication– p is sufficient for q– q is necessary for p– q if p– p only if q– if not q then not p

p q p → qT T TT F FF T TF F T

Page 56: 02 Sets and Logic

Implication Example

• If I was a professor then I could give lots of quizzes.• If I was a professor then I would be able to fly.• If I was magic then I could eat cake.• If I was magic then I could disappear.

p q p →qT T TT F FF T TF F T

Page 57: 02 Sets and Logic

Operators

• If p is true q must be true for the implication to be true.

• If p is false can't really tell what the outcome would be. If you start with a false assumption, you can prove anything. p q p → q

T T TT F FF T TF F T

Page 58: 02 Sets and Logic

The Biconditional Operator

• Biconditional– represented by “<->”– read as “if and only if”– p <-> q read as “p is true if and only if q is true” – truth table

p q p qT T TT F FF T FF F T

Page 59: 02 Sets and Logic

Biconditional Examples

• Biconditional– I sleep if and only if I am tired– means• if I am asleep then I am tired• AND if I am tired the I am asleep.

– also• If I am NOT sleeping, then I am NOT tired.• If I am NOT tired, then I am NOT sleeping.

p q p q

T T T

T F F

F T F

F F T

Page 60: 02 Sets and Logic

Implication and Biconditional

• If it is raining, then I am indoors.– I may still be indoors even if it is not raining

• I am indoors if and only if it is raining.– The only way I am indoors is if it is raining.

Page 61: 02 Sets and Logic

Order of Operation

• Operations are executed in the following order Negation Conjunction Disjunction→ Implication Biconditional

Page 62: 02 Sets and Logic

Compound Statements

• Connecting variables together with operators create compound statementsp qp q(p q ) r

Page 63: 02 Sets and Logic

Creating Truth Tables

• You will have 2n rows where n is the number of variables in the statement.

• (p q ) r• Three variables so n=3• rows = 2n = 23 = 8

Page 64: 02 Sets and Logic

Creating Truth Tables

• Add columns for each variable (3)• Add rows as calculated (8)• Fill in true/false values as shown in text on Figure 2.8

p q r

T T T

T T F

T F T

T F F

F T T

F T F

F F T

F F F

Page 65: 02 Sets and Logic

Creating Truth Tables

• Order of operation– Parenthesis first– Negation before Conjunction – Conjunction before Disjunction– Disjunction before Implication or Bidirectional

– (p q ) r– The order of operations is

• p q first because of parenthesis• negation next (r)• (p q ) (r) finally the conjunction

– List these in order on your truth table

Page 66: 02 Sets and Logic

Creating Truth Tables

• (p q ) (r)p q r r p q (p q ) (r)

T T T

T T F

T F T

T F F

F T T

F T F

F F T

F F F

Page 67: 02 Sets and Logic

Creating Truth Tables• (p q ) (r) • Fill in each column by looking at other columns and applying operators.• r is the opposite of what is in r

p q r r p q (p q ) (r)

T T T F

T T F T

T F T F

T F F T

F T T F

F T F T

F F T F

F F F T

Page 68: 02 Sets and Logic

Creating Truth Tables• (p q ) (r) • Fill in each column by looking at other columns and applying operators.• p q is true when either p or q is true (or both)

p q r r p q (p q ) (r)

T T T F T

T T F T T

T F T F T

T F F T T

F T T F T

F T F T T

F F T F F

F F F T F

Page 69: 02 Sets and Logic

Creating Truth Tables• (p q ) (r) • The last column is an AND of the two previous columns• AND says both must be true for the result to be true

p q r r p q (p q ) (r)

T T T F T F

T T F T T T

T F T F T F

T F F T T T

F T T F T F

F T F T T T

F F T F F F

F F F T F F

Page 70: 02 Sets and Logic

Construct the Truth Table

• p q• (p ^ q)• p q is logically equivalent to (p ^ q)

because they have the same result column in the truth table

• Written:p q ≡ (p ^ q)

Page 71: 02 Sets and Logic

De Morgan's Laws and Negation

• You can use De Morgan's Law to say the same thing in a different way

• De Morgan ( p q ) ≡ p q ( p q ) ≡ p q

• A phrase with a negation can be rewritten using De MorganI do not speak either Spanish or German (negation)

I do not speak Spanish and I do not speak German (demorgan)

I do not drink and driveI do not drink or I do not drive

Page 72: 02 Sets and Logic

Tautology

• Always true– Construct truth table– If all true results in right hand column, tautology

(pq)(pq)p p p ppp(p q) (p q)

Page 73: 02 Sets and Logic

Contradiction

• Always false– Construct truth table– If all false results in right hand column,

contradiction

p (p q)p pp p( p p)

Page 74: 02 Sets and Logic

Contrapositive Converse Inverse

• statement: if p then q• contrapositive: if not q then not p• converse: if q then p• inverse: if not p then not q

• If a statement is true, the contrapositive is also true. • If the converse is true, the inverse is also true

because the inverse is the contrapositive of the converse.

Page 75: 02 Sets and Logic

Contrapositive Converse Inverse

• If Appalachian won, then the students are happy (Sentence)

• If the students are happy, then Appalachian won (converse)

• If the students are not happy, then Appalachian did not win (contrapositive)

• If Appalachian did not win, then the students are not happy (inverse)

Page 76: 02 Sets and Logic

Contrapositive Converse Inverse

• Assume the top sentence is true, do the rest have to be true?– If Appalachian won, then the students are happy

(Sentence)– If the students are happy, then Appalachian won

(converse)– If the students are not happy, then Appalachian did

not win (contrapositive)– If Appalachian did not win, then the students are

not happy (inverse)

Page 77: 02 Sets and Logic

Contrapositive Converse Inverse

• Assume the top sentence is true, do the rest have to be true?– If Appalachian won, then the students are happy

(Sentence)– If the students are not happy, then Appalachian

did not win (contrapositive)Yes. A win would have moved the students into the happy state, if they are not in that state they did not win.

Page 78: 02 Sets and Logic

Contrapositive Converse Inverse

• Assume the top sentence is true, do the rest have to be true?– If Appalachian won, then the students are happy

(Sentence)– If the students are happy, then Appalachian won

(converse)No. The students could have been moved to a happy state because of some other reason. Just because the students are happy DOES NOT mean that Appalachian won.

Page 79: 02 Sets and Logic

Contrapositive Converse Inverse

• Assume the top sentence is true, do the rest have to be true?– If Appalachian won, then the students are happy

(Sentence)– If Appalachian did not win, then the students are

not happy (inverse)No. The top sentence said a win makes the students happy. It DID NOT say a loss makes them unhappy.