fall 2013 foundations of logic

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

Upload: aubrey-fitzgerald

Post on 18-Jan-2018

224 views

Category:

Documents


0 download

DESCRIPTION

Two Logical Systems: Propositional logic Predicate logic (extends 1. ) Fall 2013 Two Logical Systems: Propositional logic Predicate logic (extends 1. ) Many other logical calculi exist, but they all resemble these two CS2013 Univ of Aberdeen

TRANSCRIPT

Page 1: Fall 2013 Foundations of Logic

Propositional Logic

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

Page 2: Fall 2013 Foundations of Logic

Foundations of Logic

Mathematical Logic is a tool for handling compound statements. It includes:– A formal language for expressing them.– A methodology for reasoning about their truth

or falsity. (A “calculus”)

The ultimate foundation for proofs throughout mathematics

CS2013 Univ of Aberdeen 2

Page 3: Fall 2013 Foundations of Logic

Two Logical Systems:

1.1. Propositional logicPropositional logic2.2. Predicate logicPredicate logic (extends (extends 1.1. ) )

Many other logical calculi exist, Many other logical calculi exist, but they all resemble these twobut they all resemble these two

CS2013 Univ of Aberdeen 3

Page 4: Fall 2013 Foundations of Logic

Propositional Logic (§1.1)

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.

Some applications in computer science:Some applications in computer science:• 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.

George Boole(1815-1864)

Chrysippus of Soli(ca. 281 B.C. – 205 B.C.)CS2013 Univ of Aberdeen 4

Page 5: Fall 2013 Foundations of Logic

Propositions in natural language

In propositional logic, a In propositional logic, a propositionproposition is simply: is simply:• a a statement statement ((i.e.i.e., a declarative sentence), a declarative sentence)

– with some definite meaningwith some definite meaning• having a having a truth valuetruth value that that’’s either s either truetrue ( (TT) or ) or falsefalse

((FF). Only values statements can have.). Only values statements can have.– Never both, or somewhere Never both, or somewhere ““in betweenin between””. .

However, you might not However, you might not knowknow the the truth valuetruth value

CS2013 Univ of Aberdeen 5

Page 6: Fall 2013 Foundations of Logic

Examples of NL Propositions

• ““It is raining.It is raining.”” (In a given situation.)(In a given situation.)• ““Beijing is the capital of China, and 1 + 2 = 2Beijing is the capital of China, and 1 + 2 = 2””

The following are The following are NOTNOT propositions: propositions:• ““WhoWho’’s there?s there?”” (interrogative: no truth value)(interrogative: no truth value)• ““x := x+1x := x+1”” (imperative: no truth value)(imperative: no truth value)• ““1 + 21 + 2”” (term: no truth value)(term: no truth value)

CS2013 Univ of Aberdeen 6

Page 7: Fall 2013 Foundations of Logic

Propositions in Propositional Logic

• Atoms: Atoms: pp, , qq, , rr, …, …(Corresponds with simple English sentences, e.g.(Corresponds with simple English sentences, e.g.‘‘I had salad for lunchI had salad for lunch’’))

• Complex propositions : built up from atoms using Complex propositions : built up from atoms using operators: operators: ppqq (Corresponds with compound English sentences, (Corresponds with compound English sentences, e.g., e.g., ““I had salad for lunch I had salad for lunch andand I had steak for I had steak for dinner.dinner.””))

CS2013 Univ of Aberdeen 7

Page 8: Fall 2013 Foundations of Logic

Defining Propositions

• Logic defines notions of atomic and Logic defines notions of atomic and complex propositions and what complex complex propositions and what complex propositions “propositions “mean”mean”

CS2013 Univ of Aberdeen 8

Page 9: Fall 2013 Foundations of Logic

A A connectiveconnective combines with combines with nn arguments arguments to to form a larger expression.form a larger expression.

• UnaryUnary connectives take 1 operand; connectives take 1 operand;• Binary Binary connectives take 2 operands.connectives take 2 operands.

Connectives (also called operators)

CS2013 Univ of Aberdeen 9

Page 10: Fall 2013 Foundations of Logic

Common Boolean Operators

Formal NameFormal Name NicknameNickname ArityArity SymbolSymbol

Negation operatorNegation operator NOTNOT UnaryUnary ¬¬Conjunction operatorConjunction operator ANDAND BinaryBinary Disjunction operatorDisjunction operator OROR BinaryBinary Exclusive-OR operatorExclusive-OR operator XORXOR BinaryBinary Implication operatorImplication operator IMPLIESIMPLIES BinaryBinary Biconditional operatorBiconditional operator IFFIFF BinaryBinary ↔↔

CS2013 Univ of Aberdeen 10

Page 11: Fall 2013 Foundations of Logic

The syntax of propositional logic

• Atoms: p1, p2, p3, ..Atoms: p1, p2, p3, ..• Formulas:Formulas:

– All atoms are formulasAll atoms are formulas– For all For all , if , if is a formula then is a formula then ¬ ¬ is a is a

formulaformula– For all For all and and , if , if and and are formulas then the are formulas then the

following are formulas: (following are formulas: ( ), (), ( ), (), ( ) ) (etc.)(etc.)

CS2013 Univ of Aberdeen 11

Page 12: Fall 2013 Foundations of Logic

The language of propositional logic defined more properly (i.e., as a formal language)

• Which of these are formulas, according to Which of these are formulas, according to this strict definition?this strict definition?

• p1 p1 ¬¬ p2 p2 • (p1 (p1 ¬¬ p2) p2) • ¬ ¬ ¬¬ ¬ ¬(p9 (p9 p8) p8)• (p(p11 p2 p2 p3) p3)• (p(p11 (p2 (p2 p3)) p3))

CS2013 Univ of Aberdeen 12

Page 13: Fall 2013 Foundations of Logic

The language of propositional logic defined more properly (i.e., as a formal language)

• Which of these are formulas, Which of these are formulas, according to according to this strict definitionthis strict definition??

• p1 p1 ¬¬ p2 p2 NoNo• (p1 (p1 ¬¬ p2) p2) YesYes• ¬ ¬ ¬¬ ¬ ¬(p9 (p9 p8) p8) YesYes• (p(p11 p2 p2 p3) p3) NoNo• (p(p11 (p2 (p2 p3)) p3)) YesYes

CS2013 Univ of Aberdeen 13

Page 14: Fall 2013 Foundations of Logic

Simplifying conventions

• Convention 1: Convention 1: outermost brackets may be outermost brackets may be omitted,:omitted,:p1 p1 ¬¬ p2, p2, ¬ ¬ ¬¬ ¬ ¬(p9 (p9 p8), p p8), p11 (p2 (p2 p3) p3)

• Convention 2: Convention 2: associativity allows us to associativity allows us to omit even more brackets, e.g.:omit even more brackets, e.g.:pp11 p2 p2 p3, p3, pp1 1 p2 p2 p3 p3

CS2013 Univ of Aberdeen 14

Page 15: Fall 2013 Foundations of Logic

The language of propositional logic defined more properly (i.e., as a formal language)

• Which of these are formulas, Which of these are formulas, when using when using these two conventionsthese two conventions??

• p1 p1 ¬¬ p2 p2 YesYes• (p1 (p1 ¬¬ p2) p2) YesYes• ¬ ¬ ¬¬ ¬ ¬(p9 (p9 p8) p8) YesYes• (p(p11 p2 p2 p3) p3) NoNo• (p(p11 (p2 (p2 p3)) p3)) YesYes

CS2013 Univ of Aberdeen 15

Page 16: Fall 2013 Foundations of Logic

The semantics of Propositional Logic

CS2013 Univ of Aberdeen 16

Page 17: Fall 2013 Foundations of Logic

Propositional Logic is a very simplePropositional Logic is a very simpleformalism, becauseformalism, because

The meaning of a proposition can only be The meaning of a proposition can only be expressed in terms of the expressed in terms of the truth values truth values True (also: T, 1) and False (also: F, 0).True (also: T, 1) and False (also: F, 0).

This may not always always allow you toThis may not always always allow you tosay what you would want to say say what you would want to say

Remember when reading definitions of connectives

CS2013 Univ of Aberdeen 17

Page 18: Fall 2013 Foundations of Logic

The Negation Operator

The unary The unary negation operatornegation operator ““¬¬”” ( (NOTNOT) ) combines with one prop, transforming the combines with one prop, transforming the prop into its prop into its negationnegation..

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.””

The The truth tabletruth table for NOT: for NOT: p p T F F T

T :≡ True; F :≡ False“:≡” means “is defined as”

Operandcolumn

ResultcolumnCS2013 Univ of Aberdeen 18

Page 19: Fall 2013 Foundations of Logic

Truth-functionality

• The meaning of a connective is a The meaning of a connective is a functionfunction from (one or more) truth values to truth from (one or more) truth values to truth values values

• Truth table expresses truth/falsity of Truth table expresses truth/falsity of ¬¬pp in in terms of truth/falsity of pterms of truth/falsity of p

• This not possible for the operator This not possible for the operator ‘tomorrow’, or `probably’: ‘tomorrow’, or `probably’: – ‘‘Tomorrow p’ is true iff p is ….’??Tomorrow p’ is true iff p is ….’??

CS2013 Univ of Aberdeen 19

Page 20: Fall 2013 Foundations of Logic

Truth-functionality• Truth table expresses truth/falsity of Truth table expresses truth/falsity of ¬¬pp in terms of in terms of

truth/falsity of p.truth/falsity of p.• Each horizontal line of the table expresses some alternative Each horizontal line of the table expresses some alternative

context.context.• Truth-functional operator: an operator that is a Truth-functional operator: an operator that is a functionfunction

from the truth values of the component expressions to a from the truth values of the component expressions to a truth value.truth value.

• NOT is truth functional. Yesterday is not.NOT is truth functional. Yesterday is not.• Propositional logic is only about truth-functional Propositional logic is only about truth-functional

operatorsoperators..• We can compute the values of the complex expressions.We can compute the values of the complex expressions.

CS2013 Univ of Aberdeen 20

Page 21: Fall 2013 Foundations of Logic

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.I will have salad for lunch.”” and and q=q=““I will have steak for dinner.I will have steak for dinner.””, then , then ppqq==““I I will have salad for lunch will have salad for lunch andand I will have steak for dinner.I will have steak for dinner.””

CS2013 Univ of Aberdeen 21

Page 22: Fall 2013 Foundations of Logic

• 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.

• Also: ¬ and Also: ¬ and operations together can express operations together can express anyany Boolean truth table! Boolean truth table!

Conjunction Truth TableOperand columns

CS2013 Univ of Aberdeen 22

more later

Page 23: Fall 2013 Foundations of Logic

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==““My car has a bad engine.My car has a bad engine.””q=q=““My car has a bad carburator.My car has a bad carburator.””ppqq==““Either my car has a bad engine, Either my car has a bad engine, oror

my car has a bad carburetor.my car has a bad carburetor.””

CS2013 Univ of Aberdeen 23

Page 24: Fall 2013 Foundations of Logic

• 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

Notedifferencefrom AND

CS2013 Univ of Aberdeen 24

Page 25: Fall 2013 Foundations of Logic

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 hehe’’s s ggrownrown or or II’’ve ve sshrunkhrunk..”” = = ff ( (gg ss))((ff gg) ) ss would mean something different would mean something differentff gg ss would be ambiguous would be ambiguous

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

CS2013 Univ of Aberdeen 25

Page 26: Fall 2013 Foundations of Logic

Logic as shorthand for NL

Let Let pp==““It rained last nightIt 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.””

¬¬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.

CS2013 Univ of Aberdeen 26

Page 27: Fall 2013 Foundations of Logic

Some important ideas:

• Distinguishing between semantically Distinguishing between semantically different kinds of formulasdifferent kinds of formulas

• Some formulas that look different may Some formulas that look different may express the same informationexpress the same information

CS2013 Univ of Aberdeen 27

Page 28: Fall 2013 Foundations of Logic

Tautologies

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?]

CS2013 Univ of Aberdeen 28

Page 29: Fall 2013 Foundations of Logic

Tautologies

• When every row of the truth table gives When every row of the truth table gives T..

• Example: p Example: p pp T T TT FT FT F F TT TF TF

CS2013 Univ of Aberdeen 29

Page 30: Fall 2013 Foundations of Logic

Contradictions

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

CS2013 Univ of Aberdeen 30

Page 31: Fall 2013 Foundations of Logic

Contradictions

• When every row of the truth table gives FWhen every row of the truth table gives F

• Example: p Example: p pp T T FF FT FT F F FF TF TF

CS2013 Univ of Aberdeen 31

Page 32: Fall 2013 Foundations of Logic

Contingencies

All other props. are All other props. are contingenciescontingencies::

Some rows give T, others give FSome rows give T, others give F

Now: formulas that have the same meaningNow: formulas that have the same meaning

CS2013 Univ of Aberdeen 32

Page 33: Fall 2013 Foundations of Logic

Propositional Equivalence

Two syntactically different propositions may be Two syntactically different propositions may be semantically semantically identical (have the same meaning). identical (have the same meaning). We call them We call them logically equivalentlogically equivalent. .

Notation: … Notation: … … …

CS2013 Univ of Aberdeen 33

Page 34: Fall 2013 Foundations of Logic

Logical Equivalence

Compound proposition Compound proposition pp is is logically logically equivalent equivalent to compound proposition to compound proposition qq, , written written ppqq, , IFFIFF pp and and q q contain the same truth values contain the same truth values in in allall rows of their truth tables rows of their truth tablesThey express the same They express the same truth function truth function (= the same function (= the same function fromfrom values for atoms values for atoms toto values for the whole formula). values for the whole formula).

CS2013 Univ of Aberdeen 34

Page 35: Fall 2013 Foundations of Logic

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

CS2013 Univ of Aberdeen 35

Shows that OR is equivalent to a combination of NOT and AND.

Page 36: Fall 2013 Foundations of Logic

Before introducing more connectives

• … … let us step back and ask a few questions let us step back and ask a few questions about truth tablesabout truth tables

CS2013 Univ of Aberdeen 36

Page 37: Fall 2013 Foundations of Logic

1.1. What does each line of the table "mean"?What does each line of the table "mean"?2.2. Consider a conjunction Consider a conjunction pp11 pp2 2 pp33

How many rows are there in its truth table?How many rows are there in its truth table?3.3. Consider a conjunctionConsider a conjunction

pp11 pp2 2 … … ppnn of of nn propositions. propositions.How many rows are there in its truth table?How many rows are there in its truth table?

4.4. Explain why ¬ and Explain why ¬ and together are sufficient to together are sufficient to express express anyany Boolean truth table Boolean truth table

Questions for you to think about

CS2013 Univ of Aberdeen 37

Page 38: Fall 2013 Foundations of Logic

1.1. Consider a conjunction Consider a conjunction pp11 pp2 2 pp33How many rows are there in its truth table? 8How many rows are there in its truth table? 8 pp11 pp2 2 pp33 1 1 11 1 1 1 1 0 1 1 0 1 0 1 1 0 1 1 0 0 1 0 0 0 1 1 0 1 1 0 1 0 0 1 0 0 0 1 0 0 1 0 0 0 0 0 0

Questions for you to think about

CS2013 Univ of Aberdeen 38

Two truth values (0,1) and three propositions:

23 = 8.

Page 39: Fall 2013 Foundations of Logic

2. Consider 2. Consider pp11 pp2 2 … … ppnn How many rows are there in its truth How many rows are there in its truth table?table?

2*2*2* … *2 (n factors)2*2*2* … *2 (n factors)Hence 2Hence 2n n (This grows exponentially!)(This grows exponentially!)

Questions for you to think about

CS2013 Univ of Aberdeen 39

Page 40: Fall 2013 Foundations of Logic

3. Explain why ¬ and 3. Explain why ¬ and together are sufficient together are sufficient to express to express anyany other complex expression other complex expression in propositional logic.in propositional logic.

Questions for you to think about

CS2013 Univ of Aberdeen 40

Page 41: Fall 2013 Foundations of Logic

3.3. Explain why ¬ and Explain why ¬ and together are sufficient together are sufficient to express to express anyany other complex expression in other complex expression in propositional logic.propositional logic.

• Obviously, if we add new connectivesObviously, if we add new connectives(like (like ) ) we can write new formulas.we can write new formulas.

• CLAIM: these formulas would always be CLAIM: these formulas would always be equivalent with ones that only use equivalent with ones that only use ¬ and ¬ and (This is what we need to prove).(This is what we need to prove).

Questions for you to think about

CS2013 Univ of Aberdeen 41

Page 42: Fall 2013 Foundations of Logic

• Saying this in a different way: if we add new Saying this in a different way: if we add new connectives, we can write new formulas, but connectives, we can write new formulas, but these formulas will always only express truth these formulas will always only express truth functions that can already be expressed by functions that can already be expressed by formulas that only use formulas that only use ¬ and ¬ and ..

• That is, they will be equivalent.That is, they will be equivalent.• Example of writing a disjunction in another Example of writing a disjunction in another

form (equivalence shown before): form (equivalence shown before):

p p q q ¬(¬p ¬(¬p ¬q) ¬q)

Relating AND and OR

CS2013 Univ of Aberdeen 42

Page 43: Fall 2013 Foundations of Logic

Mystery Operator

PQRPQR Formula (containing P,Q,R)Formula (containing P,Q,R)1 1 1 01 1 1 01 1 0 11 1 0 11 0 1 11 0 1 11 0 0 01 0 0 00 1 1 00 1 1 00 1 0 00 1 0 00 0 1 00 0 1 00 0 0 0 0 0 0 0

CS2013 Univ of Aberdeen 43

Suppose, given the truth values of P, Q, and R, we construct a Formula with the given resulting truth value. This is our 'mystery' operator . Can it be written equivalently with NOT and AND?

Page 44: Fall 2013 Foundations of Logic

3. Explain why ¬ and 3. Explain why ¬ and together are sufficient together are sufficient to express to express anyany Boolean truth table Boolean truth table

• Suppose precisely two rows give T.Suppose precisely two rows give T.For exampleFor example, the rows where, the rows where

– P=T, Q=T, R=F. This is P P=T, Q=T, R=F. This is P Q Q ¬R ¬R– P=T, Q=F, R=T. This is P P=T, Q=F, R=T. This is P ¬Q ¬Q R R

T-values in Conjunction

CS2013 Univ of Aberdeen 44

Page 45: Fall 2013 Foundations of Logic

Suppose precisely two rows give T.Suppose precisely two rows give T.For exampleFor example, the rows where, the rows where

– P=T, Q=T, R=F. This is P P=T, Q=T, R=F. This is P Q Q ¬R ¬R– P=T, Q=F, R=T. This is P P=T, Q=F, R=T. This is P ¬Q ¬Q R R

• We’ve proven our claim if we can express We’ve proven our claim if we can express the disjunction of these two rows: the disjunction of these two rows: (P (P Q Q ¬R) ¬R) (P (P ¬Q ¬Q R) R)

Table as a disjunction of T-rows

CS2013 Univ of Aberdeen 45

Page 46: Fall 2013 Foundations of Logic

• We’ve arrived if we can express their We’ve arrived if we can express their disjunction: disjunction: (P (P Q Q ¬R) ¬R) (P (P ¬Q ¬Q R) R)

• But we’ve seen that disjunction can be expressed But we’ve seen that disjunction can be expressed using using and ¬: and ¬: A A B B ¬(¬A ¬(¬A ¬B) ¬B)

• So: So: (P (P Q Q ¬R) ¬R) (P (P ¬Q ¬Q R) R) ¬(¬ (P ¬(¬ (P Q Q ¬R) ¬R) (P (P ¬Q ¬Q R)) R))

• We’ve only used We’ve only used and and ..

Disjoining rows of the table

CS2013 Univ of Aberdeen 46

Page 47: Fall 2013 Foundations of Logic

(P (P Q Q ¬R) ¬R) (P (P ¬Q ¬Q R) R) ¬(¬ (P ¬(¬ (P Q Q ¬R) ¬R) (P (P ¬Q ¬Q R)) R)) 1 1 0 01 0 1 01 0 1 0 1 1 1 0 01 1 1 1 01 0 11 1 0 01 0 1 01 0 1 0 1 1 1 0 01 1 1 1 01 0 1 1 1 1 10 1 1 01 0 0 1 0 1 1 1 10 0 1 1 01 0 01 1 1 10 1 1 01 0 0 1 0 1 1 1 10 0 1 1 01 0 0 1 0 0 01 1 1 10 1 1 1 1 1 0 0 01 0 0 1 10 1 11 0 0 01 1 1 10 1 1 1 1 1 0 0 01 0 0 1 10 1 1 1 0 0 10 0 1 10 0 0 0 1 1 0 0 10 1 1 1 10 0 01 0 0 10 0 1 10 0 0 0 1 1 0 0 10 1 1 1 10 0 0 0 1 0 01 0 0 01 0 1 0 1 0 1 0 01 1 1 0 01 0 10 1 0 01 0 0 01 0 1 0 1 0 1 0 01 1 1 0 01 0 1 0 1 0 10 0 0 01 0 0 0 1 0 1 0 10 1 1 0 01 0 00 1 0 10 0 0 01 0 0 0 1 0 1 0 10 1 1 0 01 0 0 0 0 0 01 0 0 10 0 1 0 1 0 0 0 01 1 1 0 10 0 10 0 0 01 0 0 10 0 1 0 1 0 0 0 01 1 1 0 10 0 1 0 0 0 10 0 0 10 0 0 0 1 0 0 0 10 1 1 0 10 0 00 0 0 10 0 0 10 0 0 0 1 0 0 0 10 1 1 0 10 0 0

Check

CS2013 Univ of Aberdeen 47

Page 48: Fall 2013 Foundations of Logic

About this proof …

• We’ve made our task a bit easier, assuming We’ve made our task a bit easier, assuming that there were only 2 rows resulting in Tthat there were only 2 rows resulting in T

• But the case with 1 or 3 or 4 or …. rows is But the case with 1 or 3 or 4 or …. rows is analogous (and there are always only analogous (and there are always only finitely many rows.)finitely many rows.)

• So, the proof can be made preciseSo, the proof can be made precise

CS2013 Univ of Aberdeen 48

Page 49: Fall 2013 Foundations of Logic

Having proved this …

• We can express every possible truth-functional operator in We can express every possible truth-functional operator in propositional logic in terms of AND and NOTpropositional logic in terms of AND and NOT

• This is sometimes called This is sometimes called functional completeness.functional completeness. Also Also universality.universality.

• Reduce other operators to other more basic operators.Reduce other operators to other more basic operators.

CS2013 Univ of Aberdeen 49

Page 50: Fall 2013 Foundations of Logic

Let’s introduce some additional connectives

• A variant of disjunctionA variant of disjunction• The conditionalThe conditional• The biconditionalThe biconditional

CS2013 Univ of Aberdeen 50

Page 51: Fall 2013 Foundations of Logic

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 logical ““exclusive orexclusive or””..

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 in this course, I will either earn an A in this course,

or I will drop it (but not both!)or I will drop it (but not both!)””

CS2013 Univ of Aberdeen 51

Page 52: Fall 2013 Foundations of Logic

• 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 Note

differencefrom OR.

CS2013 Univ of Aberdeen 52

Page 53: Fall 2013 Foundations of Logic

Note that Note that EnglishEnglish ““oror”” can be can be ambiguousambiguous regarding the regarding the ““bothboth”” case! case!

Need context to disambiguate the meaning!Need context to disambiguate the meaning!For this class, assume For this class, assume ““oror”” means means inclusiveinclusive..

Natural Language is Ambiguous

p q p "or" qF F FF T TT F TT T ?

CS2013 Univ of Aberdeen 53

Page 54: Fall 2013 Foundations of Logic

Test your understanding of the two types of disjunction

1.1. Suppose p Suppose p q is true. q is true.Does it follow that pDoes it follow that pqq is true?is true?

2.2. Suppose Suppose ppqq is true.is true.Does it follow that Does it follow that p p q is true?q is true?

CS2013 Univ of Aberdeen 54

Page 55: Fall 2013 Foundations of Logic

Test your understanding of the two types of disjunction

1.1. Suppose p Suppose p q is true. q is true.Does it follow that pDoes it follow that pqq is true?is true?NoNo: consider p TRUE, q TRUE: consider p TRUE, q TRUE

2.2. Suppose Suppose ppqq is true. Does it follow is true. Does it follow that that p p q is true? q is true? YesYes. Check each . Check each of the two assignments that make pof the two assignments that make pqq true: true: a) p TRUE, q FALSE a) p TRUE, q FALSE (makes (makes p p q true) q true) b) p FALSE, q TRUE b) p FALSE, q TRUE (makes (makes p p q true) q true)

CS2013 Univ of Aberdeen 55

Page 56: Fall 2013 Foundations of Logic

The Implication Operator

The The implicationimplication p p qq states that states that pp implies implies q.q.I.e.I.e., If , If pp is true, then is true, then qq is true; but if is true; but if pp is not is not

true, then true, then qq could be either true or false. could be either true or false.E.g.E.g., let , let p p = = ““You study hard.You study hard.””

q q = = ““You will get a good grade.You will get a good grade.””p p q = q = ““If you study hard, then you will get If you study hard, then you will get

a good grade.a good grade.””

antecedent consequent

CS2013 Univ of Aberdeen 56

Page 57: Fall 2013 Foundations of Logic

Implication Truth Table

• p p q q is is falsefalse onlyonly when when((pp is true but is true but qq is is notnot true) true)

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

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

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

p q p q F F T F T T T F F T T T

The onlyFalsecase!

CS2013 Univ of Aberdeen 57

Page 58: Fall 2013 Foundations of Logic

Implication Truth Table

• Suppose you know Suppose you know that that qq is is TT. What . What do you know aboutdo you know aboutppqq ??

p q p q F F T F T T T F F T T T

CS2013 Univ of Aberdeen 58

Page 59: Fall 2013 Foundations of Logic

Implication Truth Table

• Suppose you know Suppose you know that that qq is is TT. What . What do you know aboutdo you know aboutppqq ??

• The conditional The conditional must be must be TT

p q p q F F T F T T T F F T T T

CS2013 Univ of Aberdeen 59

Page 60: Fall 2013 Foundations of Logic

Implication Truth Table

• Suppose you knowSuppose you knowthat that pp is is FF. What. Whatdo you know aboutdo you know aboutppqq ??

• The conditionalThe conditionalmust be must be TT

p q p q F F T F T T T F F T T T

CS2013 Univ of Aberdeen 60

Page 61: Fall 2013 Foundations of Logic

Implication Truth Table

• Suppose you knowSuppose you knowthat that pp is is TT..

• What do you know aboutWhat do you know aboutppqq ? ? T or FT or F..

• What do you know aboutWhat do you know about q? q? T or FT or F..

p q p q F F T F T T T F F T T T

CS2013 Univ of Aberdeen 61

Page 62: Fall 2013 Foundations of Logic

Implications between real sentencs

• ““If this lecture ever ends, then the sun has If this lecture ever ends, then the sun has risen this morning.risen this morning.”” TrueTrue or or FalseFalse??

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

• ““If 1+1=6, then Bush is president.If 1+1=6, then Bush is president.”” TrueTrue or or FalseFalse??

• ““If the moon is made of green cheese, then If the moon is made of green cheese, then 1+1=7.1+1=7.”” True True oror False False??

CS2013 Univ of Aberdeen 62

Page 63: Fall 2013 Foundations of Logic

Why does this seem wrong?

• Recall Recall ““If [you study hard] then [youIf [you study hard] then [you’’ll get ll get a good grade]a good grade]””

• In normal English, this asserts a causal In normal English, this asserts a causal connection between the two propositions. connection between the two propositions. The connective The connective does not capture this does not capture this connection.connection.

CS2013 Univ of Aberdeen 63

Page 64: Fall 2013 Foundations of Logic

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!Thus, Thus, p p q q means ¬(means ¬(p p qq))

• p p q q does does not not implyimplythat that pp and and qq are true, are true, or that either of them causes the other.or that either of them causes the other.

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

CS2013 Univ of Aberdeen 64

Page 65: Fall 2013 Foundations of Logic

Consider ...

The truth of p The truth of p q, where q, where1.1. p= p= Scotland is in the UKScotland is in the UK

q= q= 2+2 =42+2 =42.2. p= p= Scotland is not in the UKScotland is not in the UK

q= q= 2+2 =52+2 =53.3. p= p= Scotland is in the UKScotland is in the UK

q= q= Wales is not in the UKWales is not in the UK

CS2013 Univ of Aberdeen 65

Page 66: Fall 2013 Foundations of Logic

Consider ...

The truth of p The truth of p q, where q, where• p= p= Scotland is in the UKScotland is in the UK

q= q= 2+2 =4 2+2 =4 TRUETRUE• p= p= Scotland is not in the UKScotland is not in the UK

q= q= 2+2 =5 2+2 =5 TRUETRUE• p= p= Scotland is in the UKScotland is in the UK

q= q= Wales is not in the UK Wales is not in the UK FALSEFALSE

CS2013 Univ of Aberdeen 66

Page 67: Fall 2013 Foundations of Logic

Contrapositive

Some terminology, for an implication Some terminology, for an implication p p qq::• Its Its converseconverse is: is: q q pp..• Its Its contrapositivecontrapositive:: ¬¬q q ¬ ¬ p.p.

• Which of these two has/have the Which of these two has/have the same same meaningmeaning (express same truth function) (express same truth function) as as pp q q? Prove it.? Prove it.

CS2013 Univ of Aberdeen 67

Page 68: Fall 2013 Foundations of Logic

Contrapositive

Proving the equivalence of Proving the equivalence of p p q q and its and its contrapositive, using truth tables:contrapositive, using truth tables:p q q p p q q p F F T T T T F T F T T T T F T F F F T T F F T T

CS2013 Univ of Aberdeen 68

Page 69: Fall 2013 Foundations of Logic

For you to think about:

1.1. Can you think of yet another 2-place Can you think of yet another 2-place connective?connective?How many possible connectives do there How many possible connectives do there exist? exist?

CS2013 Univ of Aberdeen 69

Page 70: Fall 2013 Foundations of Logic

For you to think about:

1.1. How many possible connectives do there exist? How many possible connectives do there exist? p connective qp connective q

T ? T T ? T T ? F T ? F F ? T F ? T F ? F F ? FEach question mark can be T or F, henceEach question mark can be T or F, hence2*2*2*2=16 connectives 2*2*2*2=16 connectives

CS2013 Univ of Aberdeen 70

Page 71: Fall 2013 Foundations of Logic

Example of another connective

p connective q p connective q compare: compare: p and q p and q T F T TT F T T

T T F FT T F FF T T FF T T FF T F FF T F F

Names: NAND, Sheffer strokeNames: NAND, Sheffer stroke

CS2013 Univ of Aberdeen 71

Page 72: Fall 2013 Foundations of Logic

Some Alternative Notations

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

CS2013 Univ of Aberdeen 72

Page 73: Fall 2013 Foundations of Logic

Tautologies revisited

• We’ve introduced the notion of a tautology We’ve introduced the notion of a tautology using the example using the example p p pp

• Now, you know more operators, so can Now, you know more operators, so can formulate many more tautologies, e.g.,formulate many more tautologies, e.g.,the following are tautologies:the following are tautologies:((ppq)q) ((p p qq))((ppq) q) ( (¬¬q q ¬ ¬ p), and so onp), and so on

CS2013 Univ of Aberdeen 73

Page 74: Fall 2013 Foundations of Logic

Equivalence Laws

• Similar to arithmetic identities in algebraSimilar to arithmetic identities in algebra• Patterns that can be used to match (part of) Patterns that can be used to match (part of)

another propositionanother proposition• Abbreviation: Abbreviation: TT stands for an arbitrary stands for an arbitrary

tautology; tautology; FF an arbitrary contradiction an arbitrary contradiction

CS2013 Univ of Aberdeen 74

Page 75: Fall 2013 Foundations of Logic

Equivalence Laws - Examples

• IdentityIdentity: : ppT T p pp pF F pp• DominationDomination: : ppT T T T ppF F FF• IdempotenceIdempotence: : ppp p p pp pp p pp• Double negation: Double negation: p p pp• Commutativity: Commutativity: ppq q qqp pp pq q qqpp• Associativity: Associativity: ((ppqq))rr pp((qqrr))

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

CS2013 Univ of Aberdeen 75

Page 76: Fall 2013 Foundations of Logic

More Equivalence Laws

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

• De MorganDe Morgan’’ss::((ppqq) ) p p qq

((ppqq) ) p p qq • Trivial tautology/contradictionTrivial tautology/contradiction::

pp pp TT pp pp FFAugustus

De Morgan(1806-1871)

CS2013 Univ of Aberdeen 76

Page 77: Fall 2013 Foundations of Logic

Defining Operators via Equivalences

Some equivalences can be thought of as Some equivalences can be thought of as definitionsdefinitions of one operator in terms of others:of one operator in terms of others:

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

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

ppq q ((ppqq))

CS2013 Univ of Aberdeen 77

Page 78: Fall 2013 Foundations of Logic

How you may use equivalence laws: Example (1)

• Use equivalences to prove that Use equivalences to prove that ((r r ss) ) ss rr..

CS2013 Univ of Aberdeen 78

Page 79: Fall 2013 Foundations of Logic

How you may use equivalence laws: Example (1)

((r r ss) ) (De Morgan) (De Morgan)r r s s (Commutativity) (Commutativity)ss r r ( (2x2x Double Negation) Double Negation)ss rr..

CS2013 Univ of Aberdeen 79

Page 80: Fall 2013 Foundations of Logic

Summary

• In practice, Propositional Logic In practice, Propositional Logic equivalences are seldom strung together equivalences are seldom strung together into long proofs: using truth tables is into long proofs: using truth tables is usually easier.usually easier.

CS2013 Univ of Aberdeen 80