1 propositional logic rosen 5 th ed., § 1.1-1.2 2 foundations of logic: overview propositional...

38
1 Propositional Logic Rosen 5 Rosen 5 th th ed., § 1.1-1.2 ed., § 1.1-1.2

Upload: albert-payne

Post on 11-Jan-2016

214 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: 1 Propositional Logic Rosen 5 th ed., § 1.1-1.2 2 Foundations of Logic: Overview Propositional logic:Propositional logic: –Basic definitions. –Equivalence

1

Propositional Logic

Rosen 5Rosen 5thth ed., § 1.1-1.2 ed., § 1.1-1.2

Page 2: 1 Propositional Logic Rosen 5 th ed., § 1.1-1.2 2 Foundations of Logic: Overview Propositional logic:Propositional logic: –Basic definitions. –Equivalence

2

Foundations of Logic: Overview

• Propositional logic:Propositional logic:– Basic definitions. Basic definitions. – Equivalence rules & derivations. Equivalence rules & derivations.

• Predicate logic Predicate logic – Predicates.Predicates.– Quantified predicate expressions.Quantified predicate expressions.– Equivalences & derivations.Equivalences & derivations.

Bebis
Main course objective: improve math reasoning- logic is the basis of math reasoning- to understand math, we must undertand what makes up a correct math argument (proof)- the rules of logic give precise meanining to math statements (proof)- using the rules of logic we can distinguish between valid and invalid math arguments- math logic serves as the foundation for discussing methods of proof- using the rules of logic, we can constrcut correct math arguments
Page 3: 1 Propositional Logic Rosen 5 th ed., § 1.1-1.2 2 Foundations of Logic: Overview Propositional logic:Propositional logic: –Basic definitions. –Equivalence

3

Propositional Logic

Propositional LogicPropositional Logic is the logic of compound is the logic of compound statements built from simpler statements statements built from simpler statements using using BooleanBoolean connectives.connectives.

Applications:Applications:

• Design of digital electronic circuits.Design of digital electronic circuits.

• Expressing conditions in programs.Expressing conditions in programs.

• Queries to databases & search engines.Queries to databases & search engines.

Page 4: 1 Propositional Logic Rosen 5 th ed., § 1.1-1.2 2 Foundations of Logic: Overview Propositional logic:Propositional logic: –Basic definitions. –Equivalence

4

Definition of a Proposition

A A propositionproposition ( (pp, , qq, , rr, …) is simply a , …) is simply a statement statement ((i.e.i.e., a declarative sentence), a declarative sentence) with with a definite meaninga definite meaning, having a , having a truth valuetruth value that’s either that’s either truetrue (T) or (T) or falsefalse (F) ( (F) (nevernever both, neither, or somewhere in between).both, neither, or somewhere in between).

[In [In probability theory,probability theory, we assign we assign degrees of certaintydegrees of certainty to propositions. For now: True/False only!]to propositions. For now: True/False only!]

Bebis
proposition: basic building block of logic
Page 5: 1 Propositional Logic Rosen 5 th ed., § 1.1-1.2 2 Foundations of Logic: Overview Propositional logic:Propositional logic: –Basic definitions. –Equivalence

5

Examples of Propositions

• ““It is raining.” (Given a situation.)It is raining.” (Given a situation.)• ““Beijing is the capital of China.” Beijing is the capital of China.” • ““1 + 2 = 3”1 + 2 = 3”

The following are The following are NOTNOT propositions: propositions:• ““Who’s there?” (interrogative, question)Who’s there?” (interrogative, question)• ““La la la la la.” (meaningless interjection)La la la la la.” (meaningless interjection)• ““Just do it!” (imperative, command)Just do it!” (imperative, command)• ““Yeah, I sorta dunno, whatever...” (vague)Yeah, I sorta dunno, whatever...” (vague)• ““1 + 2” (expression with a non-true/false value)1 + 2” (expression with a non-true/false value)

Page 6: 1 Propositional Logic Rosen 5 th ed., § 1.1-1.2 2 Foundations of Logic: Overview Propositional logic:Propositional logic: –Basic definitions. –Equivalence

6

An An operatoroperator or or connectiveconnective combines one or combines one or more more operand operand expressions into a larger expressions into a larger expression. (expression. (E.g.E.g., “+” in numeric exprs.), “+” in numeric exprs.)

UnaryUnary operators take 1 operand ( operators take 1 operand (e.g.,e.g., -3); -3); binary binary operators take 2 operands (operators take 2 operands (egeg 3 3 4). 4).

PropositionalPropositional or or BooleanBoolean operators operate on operators operate on propositions or truth values instead of on propositions or truth values instead of on numbers.numbers.

Operators / Connectives

Bebis
Many math statements are constructed by combining one or more propositions using Boolean connectives
Page 7: 1 Propositional Logic Rosen 5 th ed., § 1.1-1.2 2 Foundations of Logic: Overview Propositional logic:Propositional logic: –Basic definitions. –Equivalence

7

The Negation Operator

The unary The unary negation operatornegation operator “¬” ( “¬” (NOTNOT) ) transforms a prop. into its logicaltransforms a prop. into its logical negation negation..

E.g.E.g. If If pp = “I have brown hair.” = “I have brown hair.”

then ¬then ¬pp = “I do = “I do notnot have brown hair.” have brown hair.”

Truth tableTruth table for NOT: for NOT: p pT FF T

Page 8: 1 Propositional Logic Rosen 5 th ed., § 1.1-1.2 2 Foundations of Logic: Overview Propositional logic:Propositional logic: –Basic definitions. –Equivalence

8

The Conjunction Operator

The binary The binary conjunction operatorconjunction operator “ “” (” (ANDAND) ) combines two propositions to form their combines two propositions to form their logical logical conjunctionconjunction..

E.g.E.g. If If pp=“I will have salad for lunch.” and =“I will have salad for lunch.” and q=q=“I will have steak for dinner.”, then “I will have steak for dinner.”, then ppqq=“I will have salad for lunch =“I will have salad for lunch andand I will have steak for dinner.”I will have steak for dinner.”

Page 9: 1 Propositional Logic Rosen 5 th ed., § 1.1-1.2 2 Foundations of Logic: Overview Propositional logic:Propositional logic: –Basic definitions. –Equivalence

9

• Note that aNote that aconjunctionconjunctionpp11 pp2 2 … … ppnn

of of nn propositions propositionswill have 2will have 2nn rows rowsin its truth table.in its truth table.

• ¬ and ¬ and operations together are universal, operations together are universal, i.e., sufficient to express i.e., sufficient to express anyany truth table! truth table!

Conjunction Truth Table

p q p qF F FF T FT F FT T T

Page 10: 1 Propositional Logic Rosen 5 th ed., § 1.1-1.2 2 Foundations of Logic: Overview Propositional logic:Propositional logic: –Basic definitions. –Equivalence

10

The Disjunction Operator

The binary The binary disjunction operatordisjunction operator “ “” (” (OROR) ) combines two propositions to form their combines two propositions to form their logical logical disjunctiondisjunction..

pp=“That car has a bad engine.”=“That car has a bad engine.”

q=q=“That car has a bad carburetor.”“That car has a bad carburetor.”

ppqq=“Either that car has a bad engine, =“Either that car has a bad engine, oror that car has a bad carburetor.”that car has a bad carburetor.”

Page 11: 1 Propositional Logic Rosen 5 th ed., § 1.1-1.2 2 Foundations of Logic: Overview Propositional logic:Propositional logic: –Basic definitions. –Equivalence

11

• Note that Note that ppq q meansmeansthat that pp is true, or is true, or qq is istrue, true, or bothor both are true! are true!

• So this operation isSo this operation isalso called also called inclusive or,inclusive or,because it because it includesincludes the thepossibility that both possibility that both pp and and qq are true. are true.

• ““¬” and “¬” and “” together are also universal.” together are also universal.

Disjunction Truth Table

p q p qF F FF T TT F TT T T

Page 12: 1 Propositional Logic Rosen 5 th ed., § 1.1-1.2 2 Foundations of Logic: Overview Propositional logic:Propositional logic: –Basic definitions. –Equivalence

12

A Simple Exercise

Let Let pp=“It rained last night”, =“It rained last night”, qq=“The sprinklers came on last night,” =“The sprinklers came on last night,” rr=“The lawn was wet this morning.”=“The lawn was wet this morning.”

Translate each of the following into English:Translate each of the following into English:

¬¬pp = =

rr ¬ ¬pp = =

¬ ¬ r r pp q =q =

“It didn’t rain last night.”“The lawn was wet this morning, andit didn’t rain last night.”“Either the lawn wasn’t wet this morning, or it rained last night, or the sprinklers came on last night.”

Page 13: 1 Propositional Logic Rosen 5 th ed., § 1.1-1.2 2 Foundations of Logic: Overview Propositional logic:Propositional logic: –Basic definitions. –Equivalence

13

The Exclusive Or Operator

The binary The binary exclusive-or operatorexclusive-or operator “ “” (” (XORXOR) ) combines two propositions to form their combines two propositions to form their logical “exclusive or” (exjunction?).logical “exclusive or” (exjunction?).

pp = “I will earn an A in this course,” = “I will earn an A in this course,”

qq = = “I will drop this course,”“I will drop this course,”

pp q q = “I will either earn an A for this = “I will either earn an A for this course, or I will drop it (but not both!)”course, or I will drop it (but not both!)”

Page 14: 1 Propositional Logic Rosen 5 th ed., § 1.1-1.2 2 Foundations of Logic: Overview Propositional logic:Propositional logic: –Basic definitions. –Equivalence

14

• Note that Note that ppq q meansmeansthat that pp is true, or is true, or qq is istrue, but true, but not bothnot both!!

• This operation isThis operation iscalled called exclusive or,exclusive or,because it because it excludesexcludes the thepossibility that both possibility that both pp and and qq are true. are true.

• ““¬” and “¬” and “” together are ” together are notnot universal. universal.

Exclusive-Or Truth Table

p q pqF F FF T TT F TT T F

Page 15: 1 Propositional Logic Rosen 5 th ed., § 1.1-1.2 2 Foundations of Logic: Overview Propositional logic:Propositional logic: –Basic definitions. –Equivalence

15

Note that Note that EnglishEnglish “or” is “or” is by itself by itself ambiguous ambiguous regarding the “both” case!regarding the “both” case!

““Pat is a singer orPat is a singer orPat is a writer.” -Pat is a writer.” -

““Pat is a man orPat is a man orPat is a woman.” -Pat is a woman.” -

Need context to disambiguate the meaning!Need context to disambiguate the meaning!

For this class, assume “or” means For this class, assume “or” means inclusiveinclusive..

Natural Language is Ambiguous

p q p or qF F FF T TT F TT T undef.

Page 16: 1 Propositional Logic Rosen 5 th ed., § 1.1-1.2 2 Foundations of Logic: Overview Propositional logic:Propositional logic: –Basic definitions. –Equivalence

16

The Implication Operator

The The implicationimplication p p qq states that states that pp implies implies q.q.

It is FALSE It is FALSE onlyonly in the case that p is TRUE in the case that p is TRUE but q is FALSE.but q is FALSE.

E.g.E.g., , pp=“I am elected.”=“I am elected.”qq=“I will lower taxes.”=“I will lower taxes.”

p p q = q = “If I am elected, then I will lower “If I am elected, then I will lower taxes” taxes” (else it could go either way)(else it could go either way)

Bebis
Think of it as an obligation or contractDifferent from conditional statements used in programming
Page 17: 1 Propositional Logic Rosen 5 th ed., § 1.1-1.2 2 Foundations of Logic: Overview Propositional logic:Propositional logic: –Basic definitions. –Equivalence

17

Implication Truth Table

• p p q q is is falsefalse only when only whenpp is true but is true but qq is is notnot true. true.

• p p q q does does not not implyimplythat that pp causescauses qq!!

• p p q q does does not not implyimplythat that pp or or qq are ever trueare ever true!!

• E.g.E.g. “(1=0) “(1=0) pigs can fly” is TRUE! pigs can fly” is TRUE!

p q p qF F TF T TT F FT T T

Bebis
In English, there is always a relationship between p and q (not always in math -- see last example)
Page 18: 1 Propositional Logic Rosen 5 th ed., § 1.1-1.2 2 Foundations of Logic: Overview Propositional logic:Propositional logic: –Basic definitions. –Equivalence

18

Examples of Implications

• ““If this lecture ends, then the sun will rise If this lecture ends, then the sun will rise tomorrow.” tomorrow.” TrueTrue or or FalseFalse??

• ““If Tuesday is a day of the week, then I am If Tuesday is a day of the week, then I am a penguin.” a penguin.” TrueTrue or or FalseFalse??

• ““If 1+1=6, then George passed the exam.” If 1+1=6, then George passed the exam.” TrueTrue or or FalseFalse??

• ““If the moon is made of green cheese, then I If the moon is made of green cheese, then I am richer than Bill Gates.” am richer than Bill Gates.” True True oror False False??

Page 19: 1 Propositional Logic Rosen 5 th ed., § 1.1-1.2 2 Foundations of Logic: Overview Propositional logic:Propositional logic: –Basic definitions. –Equivalence

19

Inverse, Converse, Contrapositive

Some terminology:Some terminology:

• The The inverse inverse of of p p q q is: ¬ is: ¬ p p ¬ ¬q q

• The The converseconverse of of p p q q is: is: q q pp..

• The The contrapositivecontrapositive of of p p q q is: ¬is: ¬q q ¬ ¬ p.p.

• One of these has the One of these has the same meaningsame meaning (same (same truth table) as truth table) as pp q q. Can you figure out . Can you figure out which?which?

Page 20: 1 Propositional Logic Rosen 5 th ed., § 1.1-1.2 2 Foundations of Logic: Overview Propositional logic:Propositional logic: –Basic definitions. –Equivalence

20

How do we know for sure?

Proving the Proving the equivalenceequivalence of of p p q q and its and its contrapositive using truth tables:contrapositive using truth tables:

p q q p p q q pF F T T T TF T F T T TT F T F F FT T F F T T

Page 21: 1 Propositional Logic Rosen 5 th ed., § 1.1-1.2 2 Foundations of Logic: Overview Propositional logic:Propositional logic: –Basic definitions. –Equivalence

21

The biconditional operator

The The biconditionalbiconditional p p q q states that states that pp is true is true if if and only ifand only if (IFF) q(IFF) q is true. is true.

It is TRUE when both It is TRUE when both p p q q and and q q p p are are TRUE.TRUE.

p p = “It is raining.”= “It is raining.”qq = = “The home team wins.”“The home team wins.”p p q = q = “If and only if it is raining, the home “If and only if it is raining, the home

team wins.”team wins.”

Page 22: 1 Propositional Logic Rosen 5 th ed., § 1.1-1.2 2 Foundations of Logic: Overview Propositional logic:Propositional logic: –Basic definitions. –Equivalence

22

Biconditional Truth Table

• p p q q means that means that pp and and qqhave the have the samesame truth value. truth value.

• Note this truth table is theNote this truth table is theexact exact oppositeopposite of of ’s!’s! p p q q means ¬(means ¬(p p qq))

• p p q q does does not not implyimplypp and and qq are true, or cause each other. are true, or cause each other.

p q p qF F TF T FT F FT T T

Page 23: 1 Propositional Logic Rosen 5 th ed., § 1.1-1.2 2 Foundations of Logic: Overview Propositional logic:Propositional logic: –Basic definitions. –Equivalence

23

Boolean Operations Summary

• We have seen 1 unary operator (4 possible)We have seen 1 unary operator (4 possible)and 5 binary operators (16 possible).and 5 binary operators (16 possible).p q p p q p q pq p q pqF F T F F F T TF T T F T T T FT F F F T T F FT T F T T F T T

Page 24: 1 Propositional Logic Rosen 5 th ed., § 1.1-1.2 2 Foundations of Logic: Overview Propositional logic:Propositional logic: –Basic definitions. –Equivalence

24

Precedence of Logical Operators

¬¬ 11

22

33

44

55

Operator Precedence

Page 25: 1 Propositional Logic Rosen 5 th ed., § 1.1-1.2 2 Foundations of Logic: Overview Propositional logic:Propositional logic: –Basic definitions. –Equivalence

25

Nested Propositional Expressions

• Use parentheses to Use parentheses to group sub-expressionsgroup sub-expressions::““I just saw my old I just saw my old ffriendriend, and either , and either he’s he’s ggrownrown or or I’ve I’ve sshrunkhrunk.” = .” = ff ( (gg ss))– ((ff gg) ) ss would mean something different would mean something different– ff gg ss would be ambiguous would be ambiguous

• By convention, “¬” takes By convention, “¬” takes precedenceprecedence over over both “both “” and “” and “”.”.– ¬¬s s ff means (¬ means (¬ss)) f f , , not not ¬ (¬ (s s ff))

Page 26: 1 Propositional Logic Rosen 5 th ed., § 1.1-1.2 2 Foundations of Logic: Overview Propositional logic:Propositional logic: –Basic definitions. –Equivalence

26

Some Alternative Notations

Name: notandorxorimplies iffPropositional logic: Boolean algebra: ppq+C/C++/Java (wordwise):!&&||!= ==C/C++/Java (bitwise): ~&|^Logic gates:

Page 27: 1 Propositional Logic Rosen 5 th ed., § 1.1-1.2 2 Foundations of Logic: Overview Propositional logic:Propositional logic: –Basic definitions. –Equivalence

30

Tautologies and Contradictions

A A tautologytautology is a compound proposition that is is a compound proposition that is truetrue no matter whatno matter what the truth values of its the truth values of its atomic propositions are!atomic propositions are!

Ex.Ex. p p pp [What is its truth table?] [What is its truth table?]

A A contradiction contradiction is a comp. prop. that is is a comp. prop. that is falsefalse no matter what! no matter what! Ex.Ex. p p p p [Truth table?][Truth table?]

Other comp. props. are Other comp. props. are contingenciescontingencies..

Page 28: 1 Propositional Logic Rosen 5 th ed., § 1.1-1.2 2 Foundations of Logic: Overview Propositional logic:Propositional logic: –Basic definitions. –Equivalence

31

Propositional Equivalence

Two Two syntacticallysyntactically ( (i.e., i.e., textually) different textually) different compound propositions may be compound propositions may be semantically semantically identical (identical (i.e., i.e., have the same have the same meaning). We call them meaning). We call them equivalentequivalent. Learn:. Learn:

• Various Various equivalence rules equivalence rules oror laws laws..

• How to How to proveprove equivalences using equivalences using symbolic symbolic derivationsderivations..

Bebis
In math arguments, we often replace a statement with another one, having the same truth valueA proposition in a compound proposition can be replaced by one that is logically equivalent to it without changing the truth value of the compound proposition
Page 29: 1 Propositional Logic Rosen 5 th ed., § 1.1-1.2 2 Foundations of Logic: Overview Propositional logic:Propositional logic: –Basic definitions. –Equivalence

32

Proving Equivalences

Compound propositions Compound propositions pp and and q q are logically are logically equivalent to each other equivalent to each other IFFIFF pp and and q q contain the same truth values as each other contain the same truth values as each other in in allall rows of their truth tables. rows of their truth tables.

Compound proposition Compound proposition pp is is logically logically equivalent equivalent to compound proposition to compound proposition qq, , written written ppqq, , IFFIFF the compound the compound proposition proposition ppq q is a tautology.is a tautology.

Page 30: 1 Propositional Logic Rosen 5 th ed., § 1.1-1.2 2 Foundations of Logic: Overview Propositional logic:Propositional logic: –Basic definitions. –Equivalence

33

Ex.Ex. Prove that Prove that ppqq ((p p qq).).

p q pp qq pp qq pp qq ((pp qq))F FF TT FT T

Proving Equivalencevia Truth Tables

FT

TT

T

T

T

TTT

FF

F

F

FFF

F

TT

Page 31: 1 Propositional Logic Rosen 5 th ed., § 1.1-1.2 2 Foundations of Logic: Overview Propositional logic:Propositional logic: –Basic definitions. –Equivalence

34

Equivalence Laws

• These are similar to the These are similar to the arithmetic identitiesarithmetic identities you may have learned in algebra, but for you may have learned in algebra, but for propositional equivalences instead.propositional equivalences instead.

• They provide a They provide a pattern or templatepattern or template that can that can be used to match much more complicated be used to match much more complicated propositions and to find equivalences for propositions and to find equivalences for them.them.

Page 32: 1 Propositional Logic Rosen 5 th ed., § 1.1-1.2 2 Foundations of Logic: Overview Propositional logic:Propositional logic: –Basic definitions. –Equivalence

35

Equivalence Laws - Examples

• IdentityIdentity: : ppT T p pp pF F pp

• DominationDomination: : ppT T T T ppF F FF

• IdempotentIdempotent: : ppp p p pp pp p pp

• Double negation: Double negation: p p pp

• Commutative: pCommutative: pq q qqp pp pq q qqpp• Associative: Associative: ((ppqq))rr pp((qqrr))

( (ppqq))rr pp((qqrr))

Page 33: 1 Propositional Logic Rosen 5 th ed., § 1.1-1.2 2 Foundations of Logic: Overview Propositional logic:Propositional logic: –Basic definitions. –Equivalence

36

More Equivalence Laws

• DistributiveDistributive: : pp((qqrr) ) ( (ppqq))((pprr)) pp((qqrr) ) ( (ppqq))((pprr))

• De Morgan’sDe Morgan’s::((ppqq) ) p p qq

((ppqq) ) p p qq

Page 34: 1 Propositional Logic Rosen 5 th ed., § 1.1-1.2 2 Foundations of Logic: Overview Propositional logic:Propositional logic: –Basic definitions. –Equivalence

37

More Equivalence Laws

• AbsorptionAbsorption::pp((ppqq) ) pp

p p ((p p qq) ) pp

• Trivial tautology/contradictionTrivial tautology/contradiction:: pp pp TT pp pp FF

Page 35: 1 Propositional Logic Rosen 5 th ed., § 1.1-1.2 2 Foundations of Logic: Overview Propositional logic:Propositional logic: –Basic definitions. –Equivalence

38

Defining Operators via Equivalences

Using equivalences, we can Using equivalences, we can definedefine operators operators in terms of other operators.in terms of other operators.

• Implication: Implication: ppq q p p qq• Biconditional: Biconditional: ppq q ( (ppqq)) ( (qqpp))

ppq q ((ppqq))

• Exclusive or: Exclusive or: ppqq ( (ppqq))((ppqq)) ppqq ( (ppqq))((qqpp))

Page 36: 1 Propositional Logic Rosen 5 th ed., § 1.1-1.2 2 Foundations of Logic: Overview Propositional logic:Propositional logic: –Basic definitions. –Equivalence

39

An Example Problem

• Check using a symbolic derivation whether Check using a symbolic derivation whether ((p p qq) ) ( (pp rr)) p p qq rr..

((p p qq) ) ( (pp rr)) [Expand definition of [Expand definition of ] ] ((p p qq) ) ( (pp rr)) [Defn. of [Defn. of ] ] ((p p qq) ) ( (((pp rr) ) ((pp rr)))) [DeMorgan’s Law][DeMorgan’s Law] ((pp qq)) (( ((pp rr) ) ((pp rr))))

Page 37: 1 Propositional Logic Rosen 5 th ed., § 1.1-1.2 2 Foundations of Logic: Overview Propositional logic:Propositional logic: –Basic definitions. –Equivalence

40

Example Continued...

((p p qq) ) (( ((pp rr) ) ((pp rr)))) [ [ commutes] commutes] ((qq pp)) (( ((pp rr) ) ((pp rr)))) [[ associative] associative] qq ((pp (( ((pp rr) ) ((pp rr))) [distrib. ))) [distrib. over over ]] qq ((( (((pp ( (pp rr)) )) ( (pp ((pp rr))))))[assoc.] [assoc.] qq (( ((((pp pp) ) rr) ) ( (pp ((pp rr))))))[trivial taut.] [trivial taut.] qq (( ((TT rr) ) ( (pp ((pp rr))))))[domination][domination] q q ( (TT ( (pp ((pp rr)))))) [identity] [identity] qq ( (pp ((pp rr)))) cont.cont.

Page 38: 1 Propositional Logic Rosen 5 th ed., § 1.1-1.2 2 Foundations of Logic: Overview Propositional logic:Propositional logic: –Basic definitions. –Equivalence

41

End of Long Example

qq ( (pp ((pp rr))))

[DeMorgan’s] [DeMorgan’s] qq ( (pp ( (pp rr))))

[Assoc.] [Assoc.] qq (( ((pp pp) ) rr))

[Idempotent] [Idempotent] qq ( (pp rr))

[Assoc.] [Assoc.] ( (qq pp) ) r r

[Commut.] [Commut.] p p qq r r

Q.E.D. (quod erat demonstrandum)Q.E.D. (quod erat demonstrandum)