CS1502 Formal Methods in Computer Science Lecture Notes 3 Consequence Rules Boolean Connectives.

27
CS1502 Formal Methods CS1502 Formal Methods in Computer Science in Computer Science Lecture Notes 3 Lecture Notes 3 Consequence Rules Consequence Rules Boolean Connectives Boolean Connectives

Transcript of CS1502 Formal Methods in Computer Science Lecture Notes 3 Consequence Rules Boolean Connectives.

Page 1: CS1502 Formal Methods in Computer Science Lecture Notes 3 Consequence Rules Boolean Connectives.

CS1502 Formal Methods in CS1502 Formal Methods in Computer ScienceComputer Science

Lecture Notes 3Lecture Notes 3

Consequence RulesConsequence Rules

Boolean ConnectivesBoolean Connectives

Page 2: CS1502 Formal Methods in Computer Science Lecture Notes 3 Consequence Rules Boolean Connectives.

Symmetry of IdentitySymmetry of Identity

a = ba = b

1)

2)

3)

a = a = Introduction

b = a = Elimination 1, 2

Page 3: CS1502 Formal Methods in Computer Science Lecture Notes 3 Consequence Rules Boolean Connectives.
Page 4: CS1502 Formal Methods in Computer Science Lecture Notes 3 Consequence Rules Boolean Connectives.

Example Informal ProofExample Informal Proof

Prove: If a is smaller than b and c is identical to b then c is larger than a.

Since we are given that a is smaller than b, it follows that b must be larger than a. Moreover, since c is identical to b, it follows that c must be larger than a. QED

Page 5: CS1502 Formal Methods in Computer Science Lecture Notes 3 Consequence Rules Boolean Connectives.

Consequence RulesConsequence Rules

There are three consequence “rules” in FitchThere are three consequence “rules” in Fitch– Tautological Consequence (Taut Con)Tautological Consequence (Taut Con)– First-order Consequence (FO Con)First-order Consequence (FO Con)– Analytic Consequence (Ana Con)Analytic Consequence (Ana Con)

Cons rules are proof seekers that work behind the Cons rules are proof seekers that work behind the scenes. Success is indicated by the beloved blue scenes. Success is indicated by the beloved blue check mark . Failure is indicated by the infamous red check mark . Failure is indicated by the infamous red XX..

Page 6: CS1502 Formal Methods in Computer Science Lecture Notes 3 Consequence Rules Boolean Connectives.

Taut ConTaut Con

Weakest of the three Cons “rules”Weakest of the three Cons “rules”

Attempts to prove if the current step Attempts to prove if the current step follows from the cited statements by virtue follows from the cited statements by virtue of the of the truth-functional connectivestruth-functional connectives. E.g., p . E.g., p ^ q can be replaced by p v q.^ q can be replaced by p v q.

Page 7: CS1502 Formal Methods in Computer Science Lecture Notes 3 Consequence Rules Boolean Connectives.

FO ConFO Con

More powerful than Taut Con but weaker More powerful than Taut Con but weaker than Ana Conthan Ana Con

Attempts to prove if the current step Attempts to prove if the current step follows from the cited steps by virtue of the follows from the cited steps by virtue of the truth-functional connectives, truth-functional connectives, the the quantifiers, and the identity predicatequantifiers, and the identity predicate. E.g., . E.g., a=b ^ b=c can be replaced by a=c.a=b ^ b=c can be replaced by a=c.

Page 8: CS1502 Formal Methods in Computer Science Lecture Notes 3 Consequence Rules Boolean Connectives.

Ana ConAna Con

Most powerful Cons “rule”Most powerful Cons “rule”Attempts to prove if the current step Attempts to prove if the current step follows from the cited steps by virtue of the follows from the cited steps by virtue of the truth-functional connectives, the truth-functional connectives, the quantifiers, the identity predicate and quantifiers, the identity predicate and the the meanings predicates of Tarski’s World. meanings predicates of Tarski’s World.

E.g., Cube(a) v Tet(a) v Dodec(a) is true under E.g., Cube(a) v Tet(a) v Dodec(a) is true under Ana ConAna Con

Page 9: CS1502 Formal Methods in Computer Science Lecture Notes 3 Consequence Rules Boolean Connectives.

Example Formal ProofExample Formal Proof

Larger(a,b)Larger(a,b) c = b c = b

Smaller(b,a) Ana Con 1

c = c = Introduction

b = c = Elim 2, 4

Smaller(c,a) = Elim 5, 3

1)2)

3)

4)

5)

6)

Prove: c is smaller than a

Page 10: CS1502 Formal Methods in Computer Science Lecture Notes 3 Consequence Rules Boolean Connectives.

Explicit Proof of an Ana Con StepExplicit Proof of an Ana Con Step

Proof performed by the system, behind the scenes

Page 11: CS1502 Formal Methods in Computer Science Lecture Notes 3 Consequence Rules Boolean Connectives.

Showing Non-consequenceShowing Non-consequence

To show Q is not a consequence of premises PTo show Q is not a consequence of premises P11, , PP22, …, P, …, Pnn, create a world where the premises , create a world where the premises are all true and the conclusion Q is false.are all true and the conclusion Q is false.

Page 12: CS1502 Formal Methods in Computer Science Lecture Notes 3 Consequence Rules Boolean Connectives.

Invalid ArgumentInvalid Argument

1. SameRow(b,c)1. SameRow(b,c) 2. SameRow(a,d) 2. SameRow(a,d) 3. SameRow(d,f) 3. SameRow(d,f) 4. LeftOf(a,b) 4. LeftOf(a,b)

5. LeftOf(f,c) 5. LeftOf(f,c)

Page 13: CS1502 Formal Methods in Computer Science Lecture Notes 3 Consequence Rules Boolean Connectives.
Page 14: CS1502 Formal Methods in Computer Science Lecture Notes 3 Consequence Rules Boolean Connectives.

Boolean ConnectivesBoolean Connectives

Negation Negation Conjunction Conjunction Disjunction Disjunction

These are These are truth-functional connectivestruth-functional connectives

It is not the case that

And, but, moreover

Or

Page 15: CS1502 Formal Methods in Computer Science Lecture Notes 3 Consequence Rules Boolean Connectives.

NegationNegation

PP PP

TT FF

FF TT

Page 16: CS1502 Formal Methods in Computer Science Lecture Notes 3 Consequence Rules Boolean Connectives.

Negation FactsNegation Facts

One translation of One translation of P is P is It is not the case that P.It is not the case that P.

(a = b) is equivalent to a (a = b) is equivalent to a b b

PP is equivalent to is equivalent to PP

PP PP PP

TT FF TT

FF TT FF

Page 17: CS1502 Formal Methods in Computer Science Lecture Notes 3 Consequence Rules Boolean Connectives.

The GameThe Game

Used to understand the truth value of a Used to understand the truth value of a complex sentencecomplex sentence

Strategy: Given a sentence of the form Strategy: Given a sentence of the form P that you believe to be True P that you believe to be True ((FalseFalse) implies ) implies P is False ( P is False (TrueTrue))implies implies P is True ( P is True (FalseFalse))implies P is False (implies P is False (TrueTrue))

Page 18: CS1502 Formal Methods in Computer Science Lecture Notes 3 Consequence Rules Boolean Connectives.

Assessment is incorrect

Page 19: CS1502 Formal Methods in Computer Science Lecture Notes 3 Consequence Rules Boolean Connectives.

Conjunction and DisjunctionConjunction and Disjunction

PP QQ P P Q Q P P Q Q

TT TT TT TT

TT FF FF TT

FF TT FF TT

FF FF FF FF

Page 20: CS1502 Formal Methods in Computer Science Lecture Notes 3 Consequence Rules Boolean Connectives.

Game RevisitedGame Revisited

If you believe If you believe P P Q is true you will be asked to Q is true you will be asked to select the disjunct that is true.select the disjunct that is true.

If you believe If you believe P P Q is false Tarski’s World will Q is false Tarski’s World will attempt to find a disjunct that is true.attempt to find a disjunct that is true.

If you believe If you believe P P Q is true Tarski’s World will Q is true Tarski’s World will attempt to find a conjunct that is false.attempt to find a conjunct that is false.

If you believe If you believe P P Q is false you will be asked Q is false you will be asked to select a conjunct that is false.to select a conjunct that is false.

Page 21: CS1502 Formal Methods in Computer Science Lecture Notes 3 Consequence Rules Boolean Connectives.

Game ExampleGame Example

In lectureIn lecture

Page 22: CS1502 Formal Methods in Computer Science Lecture Notes 3 Consequence Rules Boolean Connectives.

TranslationTranslation

Both A and BBoth A and B

Either A or BEither A or B

Neither A nor BNeither A nor B

A B

A B

(A B)

Both c and e are cubes. Cube(c) Cube(e)

Either c or e is a cube. Cube(c) Cube(e)

Neither c nor e is a cube. (Cube(c) Cube(e))

Page 23: CS1502 Formal Methods in Computer Science Lecture Notes 3 Consequence Rules Boolean Connectives.

TranslationTranslation

John entered the car and drove to his homeJohn entered the car and drove to his homeEntered ^ Drove(john,car(john),house(john))Entered ^ Drove(john,car(john),house(john))– OK?OK?

No – the truth functional connectives connect sentences, No – the truth functional connectives connect sentences, not predicatesnot predicatesEntered(john,car(john)) ^ Drove(john,house(john))Entered(john,car(john)) ^ Drove(john,house(john))– This is OKThis is OK

English sentences often convey more information than English sentences often convey more information than their straightforward logical meanings, e.g., temporal their straightforward logical meanings, e.g., temporal order in “John entered the car and drove home”order in “John entered the car and drove home”That’s OK: in this class, you can just give the That’s OK: in this class, you can just give the straightforward translation into logicstraightforward translation into logic

Page 24: CS1502 Formal Methods in Computer Science Lecture Notes 3 Consequence Rules Boolean Connectives.

TranslationTranslation

I will vote for Smith or I will vote for JonesI will vote for Smith or I will vote for Jones

Straightforward literal translation:Straightforward literal translation:

Vote(I,smith) v Vote(I,jones) Vote(I,smith) v Vote(I,jones)

Logic “or” is inclusive or.Logic “or” is inclusive or.

But “or” in our English sentence is exclusive or – I’ll vote But “or” in our English sentence is exclusive or – I’ll vote for one of them but not bothfor one of them but not both

We can define exclusive or using ^ and v:We can define exclusive or using ^ and v:

P xor Q equiv: (P ^ ~Q) v (Q ^ ~P)P xor Q equiv: (P ^ ~Q) v (Q ^ ~P)(Vote(I,smith) ^ ~Vote(I,jones)) v (Vote(I,jones) ^ ~Vote(I,smith))(Vote(I,smith) ^ ~Vote(I,jones)) v (Vote(I,jones) ^ ~Vote(I,smith))

Unless the text says otherwise, assume inclusive “or” (even when it Unless the text says otherwise, assume inclusive “or” (even when it says “Either A or B”)says “Either A or B”)

Page 25: CS1502 Formal Methods in Computer Science Lecture Notes 3 Consequence Rules Boolean Connectives.

Avoid AmbiguityAvoid Ambiguity

A B C(A B) C Both either A or B and C

A (B C) Either A or both B and C

A B C(A B) C Either both A and B or C

A (B C) Both A and either B or C

Either both Max is at home and Claire is tall or Carl is happy.[Home(Max) Tall(Claire)] Happy(Carl)

Page 26: CS1502 Formal Methods in Computer Science Lecture Notes 3 Consequence Rules Boolean Connectives.

Avoid AmbiguityAvoid Ambiguity

Let’s look at that example again; Let’s look at that example again;

Either both Max is at home and Claire is Either both Max is at home and Claire is tall or Carl is happytall or Carl is happy

[Home(max) ^ Tall(claire)] v Happy(carl)[Home(max) ^ Tall(claire)] v Happy(carl)

Home(max) ^ (Tall(claire) v Happy(carl)) Home(max) ^ (Tall(claire) v Happy(carl)) Translation:Translation:

Both Max is at home and either Claire is Both Max is at home and either Claire is tall or Carl is happy.tall or Carl is happy.

Page 27: CS1502 Formal Methods in Computer Science Lecture Notes 3 Consequence Rules Boolean Connectives.

EquivalencesEquivalences

Two FOL sentences Two FOL sentences PP and and QQ mean the same thing (are mean the same thing (are logicallylogically equivalentequivalent, written, written P P Q Q) iff they have the same truth value in all ) iff they have the same truth value in all situations. If two sentences are logically equivalent, you can situations. If two sentences are logically equivalent, you can substitute one for the other.substitute one for the other.Identity LawsIdentity Laws: P ^ T : P ^ T P; P v F P; P v F P PDomination LawsDomination Laws: P v T : P v T T; P ^ F T; P ^ F F FIdempotent LawsIdempotent Laws: P v P : P v P P; P ^ P P; P ^ P P PDouble NegationDouble Negation: ~~P : ~~P P PCommutative LawsCommutative Laws: P v Q : P v Q Q v P; P ^ Q Q v P; P ^ Q Q ^ P Q ^ PAssociative LawsAssociative Laws: (P v Q) v R : (P v Q) v R P v (Q v R)P v (Q v R)

(P ^ Q) ^ R (P ^ Q) ^ R P ^ (Q ^ R) P ^ (Q ^ R)Distributive LawsDistributive Laws: P v (Q ^ R) : P v (Q ^ R) (P v Q) ^ (P v R) (P v Q) ^ (P v R)

P ^ (Q v R) P ^ (Q v R) (P ^ Q) v (P ^ R) (P ^ Q) v (P ^ R) DeMorgan’s LawsDeMorgan’s Laws: ~(P ^ Q) : ~(P ^ Q) ~P v ~Q ~P v ~Q

~(P v Q) ~(P v Q) ~P ^ ~Q ~P ^ ~Q