chapter 1: (part 2): the foundations: logic and proofs

40
© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Sixth Edition, Mc Graw-Hill, 2007 Chapter 1: Chapter 1: (Part 2): (Part 2): The Foundations: Logic and The Foundations: Logic and Proofs Proofs Propositional Propositional Equivalence Equivalence (Section 1.2) (Section 1.2) Predicates & Predicates & Quantifiers Quantifiers (Section 1.3) (Section 1.3)

Upload: chipo

Post on 24-Jan-2016

65 views

Category:

Documents


2 download

DESCRIPTION

Chapter 1: (Part 2): The Foundations: Logic and Proofs. Propositional Equivalence (Section 1.2) Predicates & Quantifiers (Section 1.3). Propositional Equivalences (1.2). A tautology is a proposition which is always true . Classic Example: P V  P - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Chapter 1:  (Part 2):  The Foundations: Logic and Proofs

© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Sixth Edition, Mc Graw-Hill, 2007

Chapter 1:Chapter 1: (Part 2): (Part 2): The Foundations: Logic and The Foundations: Logic and ProofsProofs

Propositional Propositional EquivalenceEquivalence

(Section 1.2)(Section 1.2)

Predicates & Predicates & QuantifiersQuantifiers

(Section 1.3)(Section 1.3)

Page 2: Chapter 1:  (Part 2):  The Foundations: Logic and Proofs

CS 210, Ch.1 (part 2): The foundations: Logic & Proof, Sets, and Functions

2Propositional Equivalences Propositional Equivalences (1.2)(1.2)

A A tautologytautology is a proposition which is always is a proposition which is always truetrue . .Classic Example:Classic Example: P V P V PP

A A contradictioncontradiction is a proposition which is is a proposition which is always always falsefalse . .Classic Example:Classic Example: P P PP

A A contingencycontingency is a proposition which neither a is a proposition which neither a tautology nor a contradiction.tautology nor a contradiction.Example:Example: (P V Q) (P V Q) RR

Page 3: Chapter 1:  (Part 2):  The Foundations: Logic and Proofs

CS 210, Ch.1 (part 2): The foundations: Logic & Proof, Sets, and Functions

3Propositional Equivalences (1.2) Propositional Equivalences (1.2) (cont.)(cont.)

Two propositions P and Q are Two propositions P and Q are logically logically equivalentequivalent if if

P P Q is a tautology. We write: Q is a tautology. We write:

P P Q Q

Page 4: Chapter 1:  (Part 2):  The Foundations: Logic and Proofs

CS 210, Ch.1 (part 2): The foundations: Logic & Proof, Sets, and Functions

4Propositional Equivalences (1.2) Propositional Equivalences (1.2) (cont.)(cont.)

Example:Example:(P (P Q) Q) (Q (Q P) P) (P (P Q) Q)

Proof: Proof: The left side and the right side must have the The left side and the right side must have the

same truth values independent of the truth value same truth values independent of the truth value of the component propositions.of the component propositions.

To show a proposition is not a tautology: use an To show a proposition is not a tautology: use an abbreviated truth tableabbreviated truth table

try to find a counter example or to disprove the try to find a counter example or to disprove the assertion.assertion.

search for a case where the proposition is falsesearch for a case where the proposition is false

Page 5: Chapter 1:  (Part 2):  The Foundations: Logic and Proofs

CS 210, Ch.1 (part 2): The foundations: Logic & Proof, Sets, and Functions

5Propositional Equivalences (1.2) Propositional Equivalences (1.2) (cont.)(cont.)

Case 1:Case 1: Try left side false, right side trueTry left side false, right side true

Left side false: only one of PLeft side false: only one of PQ or QQ or Q P P need be false.need be false.

1a. Assume P1a. Assume PQ = F.Q = F.Then P = T , Q = F. But then right side PThen P = T , Q = F. But then right side PQ Q

= F. Wrong guess.= F. Wrong guess.

1b. Try Q1b. Try Q P = F. Then Q = T, P = F. Then P = F. Then Q = T, P = F. Then PPQ = F. Another wrong guess.Q = F. Another wrong guess.

Page 6: Chapter 1:  (Part 2):  The Foundations: Logic and Proofs

CS 210, Ch.1 (part 2): The foundations: Logic & Proof, Sets, and Functions

6

Propositional Equivalences (1.2)Propositional Equivalences (1.2)

Case 2.Case 2. Try left side true, right side falseTry left side true, right side false

If right side is false, P and Q cannot have the same truthIf right side is false, P and Q cannot have the same truthvalue.value.2a. Assume P =T, Q = F.2a. Assume P =T, Q = F.Then PThen PQ = F and the conjunction must be false so the Q = F and the conjunction must be false so the

left side cannot be true in this case. Another wrong left side cannot be true in this case. Another wrong guess.guess.

2b. Assume Q = T, P = F.2b. Assume Q = T, P = F.Again the left side cannot be true. We have exhausted all Again the left side cannot be true. We have exhausted all

possibilities and not found a counterexample. The two possibilities and not found a counterexample. The two propositions must be logically equivalent.propositions must be logically equivalent.

Note:Note: Because of this equivalence, Because of this equivalence, if and onlyif and only if or if or iffiff is isalso stated as is a necessary and sufficient condition for.also stated as is a necessary and sufficient condition for.

Page 7: Chapter 1:  (Part 2):  The Foundations: Logic and Proofs

CS 210, Ch.1 (part 2): The foundations: Logic & Proof, Sets, and Functions

7

EquivalenceEquivalence NameNameP P T T P P

P V F P V F P PIdentity LawsIdentity Laws

P V T P V T T T

P P F F F FDomination LawsDomination Laws

P V P P V P P P

P P P P P PIdempotent LawsIdempotent Laws

(( P) P) P P Double Negation Double Negation LawLaw

P V Q P V Q Q V P Q V P

P P Q Q Q Q P PCommutative LawCommutative Law

Page 8: Chapter 1:  (Part 2):  The Foundations: Logic and Proofs

CS 210, Ch.1 (part 2): The foundations: Logic & Proof, Sets, and Functions

8EquivalenceEquivalence NameName

(P V Q) V R (P V Q) V R

P V (Q V R)P V (Q V R)Associative LawAssociative Law

P V (Q P V (Q R) R)

(P V Q) (P V Q) (P V R) (P V R) Distributive LawDistributive Law

(P (P Q) Q) P V P V QQ

(P V Q) (P V Q) P P QQDe Morgan’s LawsDe Morgan’s Laws

P P Q Q P V QP V Q Implication Implication EquivalenceEquivalence

P P Q Q Q Q P P Contrapositive LawContrapositive Law

Note:Note: equivalent expressions can always be substituted for each other in a more equivalent expressions can always be substituted for each other in a more complex expression - useful for simplification.complex expression - useful for simplification.

Page 9: Chapter 1:  (Part 2):  The Foundations: Logic and Proofs

CS 210, Ch.1 (part 2): The foundations: Logic & Proof, Sets, and Functions

9Propositional Equivalences (1.2) Propositional Equivalences (1.2) (cont.)(cont.)

Normal or Canonical FormsNormal or Canonical Forms

Unique representations of a propositionUnique representations of a proposition

Examples:Examples: Construct a simple proposition Construct a simple proposition of two variables which is true only whenof two variables which is true only when

P is true and Q is false: P P is true and Q is false: P QQ P is true and Q is true: P P is true and Q is true: P Q Q P is true and Q is false or P is true and Q is true:P is true and Q is false or P is true and Q is true:

(P (P Q) V (P Q) V (P Q) Q)

Page 10: Chapter 1:  (Part 2):  The Foundations: Logic and Proofs

CS 210, Ch.1 (part 2): The foundations: Logic & Proof, Sets, and Functions

10Propositional Equivalences (1.2) Propositional Equivalences (1.2) (cont.)(cont.)

A disjunction of conjunctions whereA disjunction of conjunctions where

every variable or its negation is represented once every variable or its negation is represented once in each conjunction (a in each conjunction (a mintermminterm))

each minterms appears only onceeach minterms appears only once

Disjunctive Normal FormDisjunctive Normal Form (DNF) (DNF)

Important in switching theory, simplification in the Important in switching theory, simplification in the design of circuits.design of circuits.

Page 11: Chapter 1:  (Part 2):  The Foundations: Logic and Proofs

CS 210, Ch.1 (part 2): The foundations: Logic & Proof, Sets, and Functions

11Propositional Equivalences (1.2) Propositional Equivalences (1.2) (cont.)(cont.)

Method: To find the minterms of the DNF.Method: To find the minterms of the DNF.

Use the rows of the truth table where the Use the rows of the truth table where the proposition is 1 or Trueproposition is 1 or True

If a zero appears under a variable, use the If a zero appears under a variable, use the negation of the propositional variable in the negation of the propositional variable in the mintermminterm

If a one appears, use the propositional variable.If a one appears, use the propositional variable.

Page 12: Chapter 1:  (Part 2):  The Foundations: Logic and Proofs

CS 210, Ch.1 (part 2): The foundations: Logic & Proof, Sets, and Functions

12Propositional Equivalences (1.2) Propositional Equivalences (1.2) (cont.)(cont.)

Example: Find the DNF of (P V Q)Example: Find the DNF of (P V Q) RR

PP QQ RR (P V Q)(P V Q) RR

00

00

00

00

11

11

11

11

00

00

11

11

00

00

11

11

00

11

00

11

00

11

00

11

11

11

11

00

11

00

11

00

Page 13: Chapter 1:  (Part 2):  The Foundations: Logic and Proofs

CS 210, Ch.1 (part 2): The foundations: Logic & Proof, Sets, and Functions

13Propositional Equivalences (1.2) Propositional Equivalences (1.2) (cont.)(cont.)

There are 5 cases where the proposition is true, There are 5 cases where the proposition is true, hence 5 minterms. Rows 1,2,3, 5 and 7 produce hence 5 minterms. Rows 1,2,3, 5 and 7 produce the following disjunction of minterms:the following disjunction of minterms:

(P V Q)(P V Q) RR

((P P Q Q R) V (R) V (P P Q Q R) V ( R) V (P P Q Q R)R)

V (P V (P Q Q R) V (P R) V (P Q Q R)R)

Note that you get a Note that you get a Conjunctive Normal Form Conjunctive Normal Form (CNF)(CNF) if you negate a DNF and use DeMorgan’s if you negate a DNF and use DeMorgan’s Laws.Laws.

Page 14: Chapter 1:  (Part 2):  The Foundations: Logic and Proofs

CS 210, Ch.1 (part 2): The foundations: Logic & Proof, Sets, and Functions

14

Predicates & Quantifiers (1.3)Predicates & Quantifiers (1.3) A generalization of propositions - A generalization of propositions -

propositional functionspropositional functions or or predicates predicates: : propositions which contain variablespropositions which contain variables

Predicates become propositions once every Predicates become propositions once every variable is bound- byvariable is bound- by

assigning it a value from the assigning it a value from the Universe of DiscourseUniverse of Discourse UU

oror

quantifying itquantifying it

Page 15: Chapter 1:  (Part 2):  The Foundations: Logic and Proofs

CS 210, Ch.1 (part 2): The foundations: Logic & Proof, Sets, and Functions

15

Predicates & Quantifiers (1.3) (cont.)Predicates & Quantifiers (1.3) (cont.)

Examples:Examples:

Let U = Z, the integers = {. . . -2, -1, 0 , 1, 2, 3, . . .}Let U = Z, the integers = {. . . -2, -1, 0 , 1, 2, 3, . . .}

P(x): x > 0 is the predicate. It has no truth value until the P(x): x > 0 is the predicate. It has no truth value until the variable x is bound.variable x is bound.

Examples of propositions where x is assigned a Examples of propositions where x is assigned a value:value:

P(-3) is false,P(-3) is false, P(0) is false,P(0) is false, P(3) is true.P(3) is true.

The collection of integers for which P(x) is true are The collection of integers for which P(x) is true are the positive integers.the positive integers.

Page 16: Chapter 1:  (Part 2):  The Foundations: Logic and Proofs

CS 210, Ch.1 (part 2): The foundations: Logic & Proof, Sets, and Functions

16

Predicates & Quantifiers (1.3) (cont.)Predicates & Quantifiers (1.3) (cont.)

P(y) V P(y) V P(0) is not a proposition. The variable P(0) is not a proposition. The variable y has not been bound. However, P(3) V y has not been bound. However, P(3) V P(0) P(0) is a proposition which is true.is a proposition which is true.

Let R be the three-variable predicate R(x, y Let R be the three-variable predicate R(x, y z): z): x + y = zx + y = z

Find the truth value ofFind the truth value of

R(2, -1, 5), R(3, 4, 7), R(x, 3, z)R(2, -1, 5), R(3, 4, 7), R(x, 3, z)

Page 17: Chapter 1:  (Part 2):  The Foundations: Logic and Proofs

CS 210, Ch.1 (part 2): The foundations: Logic & Proof, Sets, and Functions

17

Predicates & Quantifiers (1.3) (cont.)Predicates & Quantifiers (1.3) (cont.)

QuantifiersQuantifiers

UniversalUniversal

P(x) is true P(x) is true for every xfor every x in the universe of discourse. in the universe of discourse.Notation: Notation: universal quantifieruniversal quantifier

x P(x)x P(x)

‘‘For all x, P(x)’, ‘For every x, P(x)’For all x, P(x)’, ‘For every x, P(x)’

The variable x is bound by the universal quantifierThe variable x is bound by the universal quantifierproducing a proposition.producing a proposition.

Page 18: Chapter 1:  (Part 2):  The Foundations: Logic and Proofs

CS 210, Ch.1 (part 2): The foundations: Logic & Proof, Sets, and Functions

18

Predicates & Quantifiers (1.3) (cont.)Predicates & Quantifiers (1.3) (cont.)

Example:Example: U = {1, 2, 3} U = {1, 2, 3}

x P(x) x P(x) P(1) P(1) P(2) P(2) P(3) P(3)

Page 19: Chapter 1:  (Part 2):  The Foundations: Logic and Proofs

CS 210, Ch.1 (part 2): The foundations: Logic & Proof, Sets, and Functions

19

Predicates & Quantifiers (1.3) (cont.)Predicates & Quantifiers (1.3) (cont.)

Quantifiers Quantifiers (cont.)(cont.)

ExistentialExistential

P(x) is true P(x) is true for some xfor some x in the universe of discourse. in the universe of discourse.Notation: Notation: existential quantifierexistential quantifier

x P(x)x P(x)

‘‘There is an x such that P(x),’ ‘For some x, P(x)’, There is an x such that P(x),’ ‘For some x, P(x)’, ‘For at least one x, P(x)’, ‘I can find an x such ‘For at least one x, P(x)’, ‘I can find an x such that P(x).’that P(x).’

Example:Example: U={1,2,3} U={1,2,3}x P(x) x P(x) P(1) P(1) VV P(2) P(2) VV P(3) P(3)

Page 20: Chapter 1:  (Part 2):  The Foundations: Logic and Proofs

CS 210, Ch.1 (part 2): The foundations: Logic & Proof, Sets, and Functions

20

Predicates & Quantifiers (1.3) (cont.)Predicates & Quantifiers (1.3) (cont.)

Quantifiers Quantifiers (cont.)(cont.)

Unique ExistentialUnique Existential

P(x) is true P(x) is true for one and only one xfor one and only one x in the universe in the universe of discourse.of discourse.

Notation: Notation: unique existential quantifierunique existential quantifier!x P(x)!x P(x)

‘‘There is a unique x such that P(x),’ ‘There is one There is a unique x such that P(x),’ ‘There is one and only one x such that P(x),’ ‘One can find and only one x such that P(x),’ ‘One can find only one x such that P(x).’only one x such that P(x).’

Page 21: Chapter 1:  (Part 2):  The Foundations: Logic and Proofs

CS 210, Ch.1 (part 2): The foundations: Logic & Proof, Sets, and Functions

21

Predicates & Quantifiers (1.3) (cont.)Predicates & Quantifiers (1.3) (cont.)

Example:Example: U = {1, 2, 3, 4} U = {1, 2, 3, 4}

P(1)P(1) P(2)P(2) P(3)P(3) !xP(x)!xP(x)

00

00

00

00

11

11

11

11

00

00

11

11

00

00

11

11

00

11

00

11

00

11

00

11

00

11

11

00

11

00

00

00

How many How many minterms minterms are in the are in the DNF?DNF?

Page 22: Chapter 1:  (Part 2):  The Foundations: Logic and Proofs

CS 210, Ch.1 (part 2): The foundations: Logic & Proof, Sets, and Functions

22

Predicates & Quantifiers (1.3) (cont.)Predicates & Quantifiers (1.3) (cont.)

REMEMBER!REMEMBER!

A predicate is A predicate is notnot a proposition until a proposition until allall variables have been bound either by variables have been bound either by quantification or assignment of a value!quantification or assignment of a value!

Page 23: Chapter 1:  (Part 2):  The Foundations: Logic and Proofs

CS 210, Ch.1 (part 2): The foundations: Logic & Proof, Sets, and Functions

23

Predicates & Quantifiers (1.3) (cont.)Predicates & Quantifiers (1.3) (cont.)

Equivalences involving the negation operatorEquivalences involving the negation operator((x P(x )) x P(x )) x x P(x)P(x)((x P(x)) x P(x)) x x P(x)P(x)

Distributing a negation operator across a Distributing a negation operator across a quantifier changes a universal to an quantifier changes a universal to an existential and vice versa.existential and vice versa.

((x P(x)) x P(x)) (P(x(P(x11) ) P(x P(x22) ) … … P(x P(xnn)))) P(xP(x11) V ) V P(xP(x22) V … V ) V … V P(xP(xnn)) x x P(x)P(x)

Page 24: Chapter 1:  (Part 2):  The Foundations: Logic and Proofs

CS 210, Ch.1 (part 2): The foundations: Logic & Proof, Sets, and Functions

24

Predicates & Quantifiers (1.3) (cont.)Predicates & Quantifiers (1.3) (cont.)

Multiple Quantifiers: read left to right . . .Multiple Quantifiers: read left to right . . .

Example:Example: Let U = R, the real numbers, Let U = R, the real numbers,P(x,y): xy= 0P(x,y): xy= 0

x x y P(x, y)y P(x, y)x x y P(x, y)y P(x, y)x x y P(x, y)y P(x, y)x x y P(x, y)y P(x, y)

The only one that is false is the first one.The only one that is false is the first one.What’s about the case when P(x,y) is the What’s about the case when P(x,y) is the

predicate x/y=1?predicate x/y=1?

Page 25: Chapter 1:  (Part 2):  The Foundations: Logic and Proofs

CS 210, Ch.1 (part 2): The foundations: Logic & Proof, Sets, and Functions

25

Predicates & Quantifiers (1.3) (cont.)Predicates & Quantifiers (1.3) (cont.) Multiple Quantifiers: read left to right . . .Multiple Quantifiers: read left to right . . .

Example:Example: Let U = {1,2,3}. Find an expression Let U = {1,2,3}. Find an expression equivalent to equivalent to x x y P(x, y) where the variables are y P(x, y) where the variables are bound by substitution instead:bound by substitution instead:

Expand from inside out or outside in.Expand from inside out or outside in.

Outside in:Outside in:

y P(1, y) y P(1, y) y P(2, y) y P(2, y) y P(3, y)y P(3, y)[P(1,1) V P(1,2) V P(1,3)] [P(1,1) V P(1,2) V P(1,3)] [P(2,1) V P(2,2) V P(2,3)] [P(2,1) V P(2,2) V P(2,3)] [P(3,1) V P(3,2) V P(3,3)][P(3,1) V P(3,2) V P(3,3)]

Page 26: Chapter 1:  (Part 2):  The Foundations: Logic and Proofs

CS 210, Ch.1 (part 2): The foundations: Logic & Proof, Sets, and Functions

26

Predicates & Quantifiers (1.3) (cont.)Predicates & Quantifiers (1.3) (cont.)

Converting from English (Can be very difficult!)Converting from English (Can be very difficult!)

““Every student in this class has studied calculus”Every student in this class has studied calculus” transformed into:transformed into:

“For every student in this class, that student has “For every student in this class, that student has studiedstudied

calculus”calculus”

C(x): “x has studied calculus”C(x): “x has studied calculus”x C(x)x C(x)

This is one way of converting from English!This is one way of converting from English!

Page 27: Chapter 1:  (Part 2):  The Foundations: Logic and Proofs

CS 210, Ch.1 (part 2): The foundations: Logic & Proof, Sets, and Functions

27

Predicates & Quantifiers (1.3) (cont.)Predicates & Quantifiers (1.3) (cont.)

Multiple Quantifiers: read left to right . . . Multiple Quantifiers: read left to right . . . (cont.)(cont.)

Example:Example:

F(x): x is a fleegleF(x): x is a fleegle

S(x): x is a snurdS(x): x is a snurd

T(x): x is a thingamabobT(x): x is a thingamabob

U={fleegles, snurds, thingamabobs}U={fleegles, snurds, thingamabobs}

(Note: the equivalent form using the existential quantifier is (Note: the equivalent form using the existential quantifier is also given)also given)

Page 28: Chapter 1:  (Part 2):  The Foundations: Logic and Proofs

CS 210, Ch.1 (part 2): The foundations: Logic & Proof, Sets, and Functions

28

Predicates & Quantifiers (1.3) (cont.)Predicates & Quantifiers (1.3) (cont.)

Everything is a fleegleEverything is a fleeglex F( x)x F( x)

((x x F(x))F(x))

Nothing is a snurd.Nothing is a snurd.x x S(x) S(x)

((x S( x))x S( x))

All fleegles are snurds.All fleegles are snurds.x [F(x)x [F(x)S(x)]S(x)]

x [x [F(x) V S(x)]F(x) V S(x)]

x x [F(x) [F(x) S(x)]S(x)]

((x [F(x) V x [F(x) V S(x)])S(x)])

Page 29: Chapter 1:  (Part 2):  The Foundations: Logic and Proofs

CS 210, Ch.1 (part 2): The foundations: Logic & Proof, Sets, and Functions

29

Predicates & Quantifiers (1.3) (cont.)Predicates & Quantifiers (1.3) (cont.)

Some fleegles are thingamabobs.Some fleegles are thingamabobs.

x [F(x) x [F(x) T(x)] T(x)]

((x [x [F(x) V F(x) V T(x)])T(x)])

No snurd is a thingamabob.No snurd is a thingamabob.

x [S(x)x [S(x) T(x)]T(x)]

((x [S(x ) x [S(x ) T(x)]) T(x)])

If any fleegle is a snurd then it's also a If any fleegle is a snurd then it's also a thingamabobthingamabob

x [(F(x) x [(F(x) S(x)) S(x)) T(x)] T(x)]

((x [F(x) x [F(x) S(x) S(x) T( x)])T( x)])

Page 30: Chapter 1:  (Part 2):  The Foundations: Logic and Proofs

CS 210, Ch.1 (part 2): The foundations: Logic & Proof, Sets, and Functions

30

Predicates & Quantifiers (1.3) (cont.)Predicates & Quantifiers (1.3) (cont.)

Extra Definitions:Extra Definitions:

An assertion involving predicates is An assertion involving predicates is validvalid if it is if it is true for every universe of discourse.true for every universe of discourse.

An assertion involving predicates is An assertion involving predicates is satisfiablesatisfiable if if there is a universe and an interpretation for which there is a universe and an interpretation for which the assertion is true. Else it is the assertion is true. Else it is unsatisfiableunsatisfiable..

The scope of a quantifier is the part of an The scope of a quantifier is the part of an assertion in which variables are bound by the assertion in which variables are bound by the quantifierquantifier

Page 31: Chapter 1:  (Part 2):  The Foundations: Logic and Proofs

CS 210, Ch.1 (part 2): The foundations: Logic & Proof, Sets, and Functions

31

Predicates & Quantifiers (1.3) (cont.)Predicates & Quantifiers (1.3) (cont.)

Examples:Examples:

Valid: Valid: x x S(x) S(x) [[x S( x)]x S( x)]

Not valid but satisfiable: Not valid but satisfiable: x [F(x) x [F(x) T(x)] T(x)]

Not satisfiable: Not satisfiable: x [F(x) x [F(x) F(x)]F(x)]

Scope: Scope: x [F(x) V S( x)] vs. x [F(x) V S( x)] vs. x [F(x)] V x [F(x)] V x [S(x)]x [S(x)]

Page 32: Chapter 1:  (Part 2):  The Foundations: Logic and Proofs

CS 210, Ch.1 (part 2): The foundations: Logic & Proof, Sets, and Functions

32

Predicates & Quantifiers (1.3) (cont.)Predicates & Quantifiers (1.3) (cont.)

Dangerous situations:Dangerous situations:

Commutativity of quantifiersCommutativity of quantifiersx x y P(x, y) y P(x, y) y y x P( x, y)?x P( x, y)? YES!YES!x x y P(x, y) y P(x, y) y y x P(x, y)?x P(x, y)? NO!NO!DIFFERENT MEANING!DIFFERENT MEANING!

Distributivity of quantifiers over operatorsDistributivity of quantifiers over operatorsx [P(x) x [P(x) Q(x)] Q(x)] x P( x) x P( x) x Q( x)?x Q( x)? YES!YES!x [P( x) x [P( x) Q( x)] Q( x)] [[x P(x) x P(x) x Q( x)]?x Q( x)]? NO!NO!

Page 33: Chapter 1:  (Part 2):  The Foundations: Logic and Proofs

CS 210, Ch.1 (part 2): The foundations: Logic & Proof, Sets, and Functions

33

Sets (1.6)Sets (1.6)

A set is a collection or group of objects or A set is a collection or group of objects or elementselements or or membersmembers.. (Cantor 1895) (Cantor 1895)

A set is said to contain its elements.A set is said to contain its elements.

There must be an underlying universal set U, There must be an underlying universal set U, either specifically stated or understood.either specifically stated or understood.

Page 34: Chapter 1:  (Part 2):  The Foundations: Logic and Proofs

CS 210, Ch.1 (part 2): The foundations: Logic & Proof, Sets, and Functions

34

Sets (1.6) (cont.)Sets (1.6) (cont.)

Notation:Notation:

list the elements between braces:list the elements between braces:S = {a, b, c, d}={b, c, a, d, d}S = {a, b, c, d}={b, c, a, d, d}

(Note: listing an object more than once does not change (Note: listing an object more than once does not change the set. Ordering means nothing.)the set. Ordering means nothing.)

specification by predicates:specification by predicates:S= {x| P(x)},S= {x| P(x)},

S contains all the elements from U which make the S contains all the elements from U which make the predicate P true.predicate P true.

brace notation with ellipses:brace notation with ellipses:S = { . . . , -3, -2, -1},S = { . . . , -3, -2, -1},

the negative integers.the negative integers.

Page 35: Chapter 1:  (Part 2):  The Foundations: Logic and Proofs

CS 210, Ch.1 (part 2): The foundations: Logic & Proof, Sets, and Functions

35

Sets (1.6) (cont.)Sets (1.6) (cont.)

Common Universal SetsCommon Universal Sets

R = realsR = reals N = natural numbers = {0,1, 2, 3, . . . }, the N = natural numbers = {0,1, 2, 3, . . . }, the

countingcounting numbers numbers Z = all integers = {. . , -3, -2, -1, 0, 1, 2, 3, 4, . .}Z = all integers = {. . , -3, -2, -1, 0, 1, 2, 3, 4, . .} ZZ++ is the set of positive integers is the set of positive integers

Notation:Notation:x is a member of S or x is an element of S:x is a member of S or x is an element of S:

x x S. S.x is not an element of S:x is not an element of S:

x x S. S.

Page 36: Chapter 1:  (Part 2):  The Foundations: Logic and Proofs

CS 210, Ch.1 (part 2): The foundations: Logic & Proof, Sets, and Functions

36

Sets (1.6) (cont.)Sets (1.6) (cont.) SubsetsSubsets

Definition:Definition: The set A is a The set A is a subsetsubset of the set B, denoted of the set B, denoted A A B, iff B, iff

x [x x [x A A x x B] B]

Definition:Definition: The The voidvoid set, the set, the nullnull set, the set, the emptyempty set, set, denoted denoted , is the set with no members., is the set with no members.

Note:Note: the assertion x the assertion x is is alwaysalways false. Hence false. Hencex [x x [x x x B] B]

is always true(vacuously). Therefore, is always true(vacuously). Therefore, is a subset of is a subset of every set.every set.

Note:Note: A set B is always a subset of itself. A set B is always a subset of itself.

Page 37: Chapter 1:  (Part 2):  The Foundations: Logic and Proofs

CS 210, Ch.1 (part 2): The foundations: Logic & Proof, Sets, and Functions

37

Sets (1.6) (cont.)Sets (1.6) (cont.)

Definition:Definition: If A If A B but A B but A B the we say A is a B the we say A is a properproper subset of B, denoted A subset of B, denoted A B (in some texts). B (in some texts).

Definition:Definition: The set of all subset of a set A, denoted The set of all subset of a set A, denoted P(A), is called the P(A), is called the power setpower set of A. of A.

Example:Example: If A = {a, b} then If A = {a, b} thenP(A) = {P(A) = {, {a}, {b}, {a,b}}, {a}, {b}, {a,b}}

Page 38: Chapter 1:  (Part 2):  The Foundations: Logic and Proofs

CS 210, Ch.1 (part 2): The foundations: Logic & Proof, Sets, and Functions

38

Sets (1.6) (cont.)Sets (1.6) (cont.)

Definition:Definition: The number of (distinct) elements in A, The number of (distinct) elements in A, denoted |A|, is called the denoted |A|, is called the cardinalitycardinality of A. of A.

If the cardinality is a natural number (in N), then If the cardinality is a natural number (in N), then the set is called the set is called finitefinite, else , else infiniteinfinite..

Example: Example: A = {a, b},A = {a, b},

|{a, b}| = 2,|{a, b}| = 2,

|P({a, b})| = 4.|P({a, b})| = 4.

A is finite and so is P(A).A is finite and so is P(A).

Useful Fact: |A|=n implies |P(A)| = 2Useful Fact: |A|=n implies |P(A)| = 2nn

Page 39: Chapter 1:  (Part 2):  The Foundations: Logic and Proofs

CS 210, Ch.1 (part 2): The foundations: Logic & Proof, Sets, and Functions

39

Sets (1.6) (cont.)Sets (1.6) (cont.) N is infinite since |N| is not a natural number. It is called a N is infinite since |N| is not a natural number. It is called a

transfinite cardinal numbertransfinite cardinal number..

Note:Note: Sets can be both Sets can be both membersmembers and and subsetssubsets of other sets. of other sets.

Example:Example:A = {A = {,{,{}}.}}.A has two elements and hence four subsets:A has two elements and hence four subsets:, {, {}, {{}, {{}}. {}}. {,{,{}}}}Note that Note that is both a member of A and a subset of A! is both a member of A and a subset of A!

Russell's paradox:Russell's paradox: Let S be the set of all sets which are not Let S be the set of all sets which are not members of themselves. Is S a member of itself?members of themselves. Is S a member of itself?

Another paradox:Another paradox: Henry is a barber who shaves all people Henry is a barber who shaves all people who do not shave themselves. Does Henry shave himself?who do not shave themselves. Does Henry shave himself?

Page 40: Chapter 1:  (Part 2):  The Foundations: Logic and Proofs

CS 210, Ch.1 (part 2): The foundations: Logic & Proof, Sets, and Functions

40

Sets (1.6) (cont.)Sets (1.6) (cont.)

Definition:Definition: The The Cartesian productCartesian product of A with B, denoted of A with B, denotedA x B, is the set of A x B, is the set of ordered pairsordered pairs {<a, b> | a {<a, b> | a A A b b B} B}

Notation: Notation:

Note: The Cartesian product of anything with Note: The Cartesian product of anything with is is . (why?). (why?)

Example:Example:

A = {a,b}, B = {1, 2, 3}A = {a,b}, B = {1, 2, 3}

AxB = {<a, 1>, <a, 2>, <a, 3>, <b, 1>, <b, 2>, <b, 3>}AxB = {<a, 1>, <a, 2>, <a, 3>, <b, 1>, <b, 2>, <b, 3>}

What is BxA? AxBxA?What is BxA? AxBxA?

If |A| = m and |B| = n, what is |AxB|?If |A| = m and |B| = n, what is |AxB|?

iin21i

n

1iAaa,...,a,aA