27
CSE 20: Discrete Mathematics Daniele Micciancio Spring 2018 Daniele Micciancio CSE 20: Discrete Mathematics

CSE 20: Discrete Mathematics · 2018. 4. 10. · Introductiontoproofs CheckingatautologyorequivalenceusingtheTruthTablemethod canbeverytimeconsumingwhentherearemanypropositional variables

  • Upload
    others

  • View
    1

  • Download
    0

Embed Size (px)

Citation preview

Page 1: CSE 20: Discrete Mathematics · 2018. 4. 10. · Introductiontoproofs CheckingatautologyorequivalenceusingtheTruthTablemethod canbeverytimeconsumingwhentherearemanypropositional variables

CSE 20: Discrete Mathematics

Daniele Micciancio

Spring 2018

Daniele Micciancio CSE 20: Discrete Mathematics

Page 2: CSE 20: Discrete Mathematics · 2018. 4. 10. · Introductiontoproofs CheckingatautologyorequivalenceusingtheTruthTablemethod canbeverytimeconsumingwhentherearemanypropositional variables

Summary

Last time:

Truth tables,TautologiesLogical equivalence

Today:

Proofs in propositional logicDemos! . . . if time permits . . .Reading: Chap. 1.6, (1.7, 1.8)

Next time: - Predicate Logic - Reading: Chap. 1.4, 1.5

Daniele Micciancio CSE 20: Discrete Mathematics

Page 3: CSE 20: Discrete Mathematics · 2018. 4. 10. · Introductiontoproofs CheckingatautologyorequivalenceusingtheTruthTablemethod canbeverytimeconsumingwhentherearemanypropositional variables

Introduction to proofs

Checking a tautology or equivalence using the Truth Table methodcan be very time consuming when there are many propositionalvariables. E.g., if you have 20 atomic propositions p1, p2, . . . , p20,the truth table would have 220 > 1, 000, 000 rows!

Alternatively, we can:

Use truth table method to establish a number of valid inferencerules, or reasoning patternsEstablish the final goal by applying a sequence of inferencerules, or proof steps

Daniele Micciancio CSE 20: Discrete Mathematics

Page 4: CSE 20: Discrete Mathematics · 2018. 4. 10. · Introductiontoproofs CheckingatautologyorequivalenceusingtheTruthTablemethod canbeverytimeconsumingwhentherearemanypropositional variables

Inferece Rules and Theorems

Propositions: H1, H2, . . . , Hn, T

Theorem: If H1, H2, . . . , Hn are true, then T is also true.

H1, . . . , Hn: premises or hypothesesT : conclusion or thesis

Validity: An inference rule is valid if H1 ∧ . . . ∧ Hn → T is atautology.

Terminology: Axiom, Inference Rule, Theorem, Lemma, Corollary,Proposition.

Inference rules:

Usually written [H1, . . . , Hk ] =⇒ T or [H1, . . . , Hk ] ` TNotice: comma “,” often used for logical ∧ operation

Daniele Micciancio CSE 20: Discrete Mathematics

Page 5: CSE 20: Discrete Mathematics · 2018. 4. 10. · Introductiontoproofs CheckingatautologyorequivalenceusingtheTruthTablemethod canbeverytimeconsumingwhentherearemanypropositional variables

Empty conjunction

For any list of statements H1, . . . , Hk , define the conjunctionCk = ((H1 ∧ H2) ∧ H3 . . .) ∧ Hk

Notice: if k = 1, then C1 = H1 is just the first statement.

What if k = 0? How would you define an empty conjunction?

(A) C0 = False; (B) C0 = True; (C) C0 = H0; (D) C0 is undefined

Answer: (B)

Justification:

For every k ≥ 1, we have Ck+1 = Ck ∧ Hk+1For k = 0, C1 = C0 ∧ H1 = H1 if C0 = TrueSame reason empty sum (sum of no numbers) is defined as zeroZero is the neutral element for +. True is the neutral elementfor ∧

Daniele Micciancio CSE 20: Discrete Mathematics

Page 6: CSE 20: Discrete Mathematics · 2018. 4. 10. · Introductiontoproofs CheckingatautologyorequivalenceusingtheTruthTablemethod canbeverytimeconsumingwhentherearemanypropositional variables

Empty conjunction

For any list of statements H1, . . . , Hk , define the conjunctionCk = ((H1 ∧ H2) ∧ H3 . . .) ∧ Hk

Notice: if k = 1, then C1 = H1 is just the first statement.

What if k = 0? How would you define an empty conjunction?

(A) C0 = False; (B) C0 = True; (C) C0 = H0; (D) C0 is undefined

Answer: (B)

Justification:

For every k ≥ 1, we have Ck+1 = Ck ∧ Hk+1For k = 0, C1 = C0 ∧ H1 = H1 if C0 = TrueSame reason empty sum (sum of no numbers) is defined as zeroZero is the neutral element for +. True is the neutral elementfor ∧

Daniele Micciancio CSE 20: Discrete Mathematics

Page 7: CSE 20: Discrete Mathematics · 2018. 4. 10. · Introductiontoproofs CheckingatautologyorequivalenceusingtheTruthTablemethod canbeverytimeconsumingwhentherearemanypropositional variables

Inference rules and Axioms

Consider an inference rule [H1, . . . , Hk ] =⇒ P with no premises(k = 0): [] =⇒ P or True =⇒ P

Question: The statement True → P is logically equivalent to

(A) P; (B) ¬P; (C) P → False; (D) None of the above

Answer: (A). Check using the Truth Table method

So, inference rules with no premises simply assert that astatement P is trueP is usually called an axiom

Daniele Micciancio CSE 20: Discrete Mathematics

Page 8: CSE 20: Discrete Mathematics · 2018. 4. 10. · Introductiontoproofs CheckingatautologyorequivalenceusingtheTruthTablemethod canbeverytimeconsumingwhentherearemanypropositional variables

Inference rules and Axioms

Consider an inference rule [H1, . . . , Hk ] =⇒ P with no premises(k = 0): [] =⇒ P or True =⇒ P

Question: The statement True → P is logically equivalent to

(A) P; (B) ¬P; (C) P → False; (D) None of the above

Answer: (A). Check using the Truth Table method

So, inference rules with no premises simply assert that astatement P is trueP is usually called an axiom

Daniele Micciancio CSE 20: Discrete Mathematics

Page 9: CSE 20: Discrete Mathematics · 2018. 4. 10. · Introductiontoproofs CheckingatautologyorequivalenceusingtheTruthTablemethod canbeverytimeconsumingwhentherearemanypropositional variables

Implication, Contrapositive, Converse

Implication P → Q ≡ ¬P ∨ Q.

Contrapositive of P → Q:

Contrapositive ¬Q → ¬PEquivalent to P → Q.Proof: truth table method, orP → Q ≡ ¬P ∨ Q ≡ Q ∨ ¬P ≡ ¬¬Q ∨ ¬P ≡ ¬Q → ¬P

Converse of P → Q:

Converse: Q → Pnot eguivalent to P → QTogether with P → Q, it yields the double implication P ↔ Q.

Daniele Micciancio CSE 20: Discrete Mathematics

Page 10: CSE 20: Discrete Mathematics · 2018. 4. 10. · Introductiontoproofs CheckingatautologyorequivalenceusingtheTruthTablemethod canbeverytimeconsumingwhentherearemanypropositional variables

Quiz TimeWhat is the contrapositive of “If x < 5 then x2 < 25”?

(A) If x ≥ 5 then x2 ≥ 25(B) If x2 < 25 then x < 5(C) If x2 ≥ 25 then x ≥ 5(D) It is not true that “If x < 5 then x2 < 25”(E) This is true only if x ≥ 0 or |x | < 5.

Answer: (C)

Remember: the contrapositive of is just a different (butequivalent) way to write an implication P → Q.

(B) is called the “converse”, and it is not equivalent to thecontrapositive

(D) is called the “negation”

(E) is true, but not the correct answer. Contrapositive and converseare well defined regardless of the validity of P → Q

Daniele Micciancio CSE 20: Discrete Mathematics

Page 11: CSE 20: Discrete Mathematics · 2018. 4. 10. · Introductiontoproofs CheckingatautologyorequivalenceusingtheTruthTablemethod canbeverytimeconsumingwhentherearemanypropositional variables

Quiz TimeWhat is the contrapositive of “If x < 5 then x2 < 25”?

(A) If x ≥ 5 then x2 ≥ 25(B) If x2 < 25 then x < 5(C) If x2 ≥ 25 then x ≥ 5(D) It is not true that “If x < 5 then x2 < 25”(E) This is true only if x ≥ 0 or |x | < 5.

Answer: (C)

Remember: the contrapositive of is just a different (butequivalent) way to write an implication P → Q.

(B) is called the “converse”, and it is not equivalent to thecontrapositive

(D) is called the “negation”

(E) is true, but not the correct answer. Contrapositive and converseare well defined regardless of the validity of P → Q

Daniele Micciancio CSE 20: Discrete Mathematics

Page 12: CSE 20: Discrete Mathematics · 2018. 4. 10. · Introductiontoproofs CheckingatautologyorequivalenceusingtheTruthTablemethod canbeverytimeconsumingwhentherearemanypropositional variables

Some common Inference Rules

Modus ponens: P, (P → Q) =⇒ Q

Moduls tollens: ¬Q, (P → Q) =⇒ ¬PSame as modus ponens, using contrapositive ¬Q → ¬P

AND-eliminationleft: P ∧ Q =⇒ Pright: P ∧ Q =⇒ Q

AND-introduction: P, Q =⇒ P ∧ Q

OR-introductionleft: P =⇒ P ∨ Qright: Q =⇒ P ∨ Qalso called weakening or addition

OR-elimination: P → R, Q → R, P ∨ Q =⇒ RAlso called “proof by cases”

Daniele Micciancio CSE 20: Discrete Mathematics

Page 13: CSE 20: Discrete Mathematics · 2018. 4. 10. · Introductiontoproofs CheckingatautologyorequivalenceusingtheTruthTablemethod canbeverytimeconsumingwhentherearemanypropositional variables

Logic PuzzleAssume you know:

It is not sunny this afternoon and it is colder than yesterdayWe go swimming only if it is sunnyIf we do not go swimming, we go hikingIf we go hiking, we will be home by sunset

Can you conclude that “We will go home by sunset” ?

Atomic propositions:

s = “It is sunny this afternoon”c = “It is colder than yesterday”w = “We will go swimming”h = “We will go hiking”t = “We will be home by sunset”

Premises: (¬s ∧ c), (w → s), ¬w → h, h→ t.

Conclusion: tDaniele Micciancio CSE 20: Discrete Mathematics

Page 14: CSE 20: Discrete Mathematics · 2018. 4. 10. · Introductiontoproofs CheckingatautologyorequivalenceusingtheTruthTablemethod canbeverytimeconsumingwhentherearemanypropositional variables

Using inference rules:

Theorem: If (¬s ∧ c), (w → s), ¬w → h and h→ t are true, thent is also true.

Proof:1. (¬s ∧ c) (premise)2. (w → s) (premise)3. ¬w → h (premise)4. h→ t (premise)

5. ¬s (AND-elim 1)6. ¬w (modus tollens 2,5)7. h (modus ponens 3,6)8. t (modus ponens 4,7)

So, t follows from the premises. If all premises are satisfied, we willgo home by sunset.

Daniele Micciancio CSE 20: Discrete Mathematics

Page 15: CSE 20: Discrete Mathematics · 2018. 4. 10. · Introductiontoproofs CheckingatautologyorequivalenceusingtheTruthTablemethod canbeverytimeconsumingwhentherearemanypropositional variables

Using inference rules:

Theorem: If (¬s ∧ c), (w → s), ¬w → h and h→ t are true, thent is also true.

Proof:1. (¬s ∧ c) (premise)2. (w → s) (premise)3. ¬w → h (premise)4. h→ t (premise)5. ¬s (AND-elim 1)

6. ¬w (modus tollens 2,5)7. h (modus ponens 3,6)8. t (modus ponens 4,7)

So, t follows from the premises. If all premises are satisfied, we willgo home by sunset.

Daniele Micciancio CSE 20: Discrete Mathematics

Page 16: CSE 20: Discrete Mathematics · 2018. 4. 10. · Introductiontoproofs CheckingatautologyorequivalenceusingtheTruthTablemethod canbeverytimeconsumingwhentherearemanypropositional variables

Using inference rules:

Theorem: If (¬s ∧ c), (w → s), ¬w → h and h→ t are true, thent is also true.

Proof:1. (¬s ∧ c) (premise)2. (w → s) (premise)3. ¬w → h (premise)4. h→ t (premise)5. ¬s (AND-elim 1)6. ¬w (modus tollens 2,5)

7. h (modus ponens 3,6)8. t (modus ponens 4,7)

So, t follows from the premises. If all premises are satisfied, we willgo home by sunset.

Daniele Micciancio CSE 20: Discrete Mathematics

Page 17: CSE 20: Discrete Mathematics · 2018. 4. 10. · Introductiontoproofs CheckingatautologyorequivalenceusingtheTruthTablemethod canbeverytimeconsumingwhentherearemanypropositional variables

Using inference rules:

Theorem: If (¬s ∧ c), (w → s), ¬w → h and h→ t are true, thent is also true.

Proof:1. (¬s ∧ c) (premise)2. (w → s) (premise)3. ¬w → h (premise)4. h→ t (premise)5. ¬s (AND-elim 1)6. ¬w (modus tollens 2,5)7. h (modus ponens 3,6)

8. t (modus ponens 4,7)

So, t follows from the premises. If all premises are satisfied, we willgo home by sunset.

Daniele Micciancio CSE 20: Discrete Mathematics

Page 18: CSE 20: Discrete Mathematics · 2018. 4. 10. · Introductiontoproofs CheckingatautologyorequivalenceusingtheTruthTablemethod canbeverytimeconsumingwhentherearemanypropositional variables

Using inference rules:

Theorem: If (¬s ∧ c), (w → s), ¬w → h and h→ t are true, thent is also true.

Proof:1. (¬s ∧ c) (premise)2. (w → s) (premise)3. ¬w → h (premise)4. h→ t (premise)5. ¬s (AND-elim 1)6. ¬w (modus tollens 2,5)7. h (modus ponens 3,6)8. t (modus ponens 4,7)

So, t follows from the premises. If all premises are satisfied, we willgo home by sunset.

Daniele Micciancio CSE 20: Discrete Mathematics

Page 19: CSE 20: Discrete Mathematics · 2018. 4. 10. · Introductiontoproofs CheckingatautologyorequivalenceusingtheTruthTablemethod canbeverytimeconsumingwhentherearemanypropositional variables

Proof structure

Theorem:

Premises: H1, . . . , HkConclusion: T .

Proof: a sequence of logical statements S1, . . . , Sn (propositions)ending in Sn = T such that each Si is

either one of the theorem premises Si = Hj , oran axiom, i.e., an inference rule with no premisesit is obtained from previous statements Sj (with j < i) using avalid inference rule Hj1 , . . . , Hjk =⇒ Si

Meta-theorem: If all the inference rules used in the proof of atheorem are valid, then the theorem is also valid, i.e.,(H1 ∧ . . . ∧ Hk)→ T is a tautology.

Daniele Micciancio CSE 20: Discrete Mathematics

Page 20: CSE 20: Discrete Mathematics · 2018. 4. 10. · Introductiontoproofs CheckingatautologyorequivalenceusingtheTruthTablemethod canbeverytimeconsumingwhentherearemanypropositional variables

Example: Frege system

Logical connectites: ¬,→. (Other connectives are defined interms of ¬,→.)

Only one inference rule: P, P → Q =⇒ Q (modus ponens)

AxiomsA→ (B → A)¬¬A→ AA→ ¬¬A(A→ B)→ (¬B → ¬A)(A→ (B → C))→ ((A→ B)→ (A→ C))

Completeness: all valid theorems (tautologies) can be proved usingFrege system

There are several other classic proof systems for propositionalcalculus: Hilbert, Russell, Lukasievicz and Tarski, etc.

Daniele Micciancio CSE 20: Discrete Mathematics

Page 21: CSE 20: Discrete Mathematics · 2018. 4. 10. · Introductiontoproofs CheckingatautologyorequivalenceusingtheTruthTablemethod canbeverytimeconsumingwhentherearemanypropositional variables

Defining conjunctions and disjunctions

Can you define “∨” using only “→” and “¬”?

P ∨ Q is logically equivalent to(A) ¬(Q → P)(B) P → ¬Q(C) ¬P → Q(D) None of the above

Answer (C): ¬P → Q. Check using Truth Table method.

What about P ∧ Q?

Using De Morgan Law:

P ∧ Q ≡ ¬(¬P ∨ ¬Q) ≡ ¬(P → ¬Q).

Check using Truth Table method.

Daniele Micciancio CSE 20: Discrete Mathematics

Page 22: CSE 20: Discrete Mathematics · 2018. 4. 10. · Introductiontoproofs CheckingatautologyorequivalenceusingtheTruthTablemethod canbeverytimeconsumingwhentherearemanypropositional variables

Defining conjunctions and disjunctions

Can you define “∨” using only “→” and “¬”?

P ∨ Q is logically equivalent to(A) ¬(Q → P)(B) P → ¬Q(C) ¬P → Q(D) None of the above

Answer (C): ¬P → Q. Check using Truth Table method.

What about P ∧ Q?

Using De Morgan Law:

P ∧ Q ≡ ¬(¬P ∨ ¬Q) ≡ ¬(P → ¬Q).

Check using Truth Table method.

Daniele Micciancio CSE 20: Discrete Mathematics

Page 23: CSE 20: Discrete Mathematics · 2018. 4. 10. · Introductiontoproofs CheckingatautologyorequivalenceusingtheTruthTablemethod canbeverytimeconsumingwhentherearemanypropositional variables

Defining conjunctions and disjunctions

Can you define “∨” using only “→” and “¬”?

P ∨ Q is logically equivalent to(A) ¬(Q → P)(B) P → ¬Q(C) ¬P → Q(D) None of the above

Answer (C): ¬P → Q. Check using Truth Table method.

What about P ∧ Q?

Using De Morgan Law:

P ∧ Q ≡ ¬(¬P ∨ ¬Q) ≡ ¬(P → ¬Q).

Check using Truth Table method.

Daniele Micciancio CSE 20: Discrete Mathematics

Page 24: CSE 20: Discrete Mathematics · 2018. 4. 10. · Introductiontoproofs CheckingatautologyorequivalenceusingtheTruthTablemethod canbeverytimeconsumingwhentherearemanypropositional variables

Defining conjunctions and disjunctions

Can you define “∨” using only “→” and “¬”?

P ∨ Q is logically equivalent to(A) ¬(Q → P)(B) P → ¬Q(C) ¬P → Q(D) None of the above

Answer (C): ¬P → Q. Check using Truth Table method.

What about P ∧ Q?

Using De Morgan Law:

P ∧ Q ≡ ¬(¬P ∨ ¬Q) ≡ ¬(P → ¬Q).

Check using Truth Table method.

Daniele Micciancio CSE 20: Discrete Mathematics

Page 25: CSE 20: Discrete Mathematics · 2018. 4. 10. · Introductiontoproofs CheckingatautologyorequivalenceusingtheTruthTablemethod canbeverytimeconsumingwhentherearemanypropositional variables

Formal vs informal proofs

Formal proofs are seldom natural and intuitive. Especially sowhen statements use only ¬ and →

Formal proofs are easy for a computer to check, but can behard for a human to understand

Mathematicians usually describe their proofs informally, in anatural language like English.

Logic can be used to explain and justify reasoning patterns

Example:

Formal: [A, B]→ (A ∧ B)English (informal): “In order to prove (A ∧ B), I will first proveA and then prove B.”

Daniele Micciancio CSE 20: Discrete Mathematics

Page 26: CSE 20: Discrete Mathematics · 2018. 4. 10. · Introductiontoproofs CheckingatautologyorequivalenceusingtheTruthTablemethod canbeverytimeconsumingwhentherearemanypropositional variables

Natural deduction

Formal proof system, but somehow closer to informal “natural”proofs.

Use all connectives ∧,∨,→,¬,↔Each connective is associated with introduction and eliminationrules

Example: AND (∧)

Introduction: A, B =⇒ A ∧ B.“In order to prove A ∧ B one needs to prove A and B”Elimination: A ∧ B =⇒ A and A ∧ B =⇒ B “From A ∧ B,one can deduce both A and B”

Also used by most modern automated theorem provers. Closelyrelated to programming languages and type checking.

Daniele Micciancio CSE 20: Discrete Mathematics

Page 27: CSE 20: Discrete Mathematics · 2018. 4. 10. · Introductiontoproofs CheckingatautologyorequivalenceusingtheTruthTablemethod canbeverytimeconsumingwhentherearemanypropositional variables

Demos: What do you want to prove today?

The Incredible Proof Machine!

Fun educational projecthttp://incredible.pm/

The LEAN theorem prover

State of the art theorem prover under development atMicrosoft Researchhttps://leanprover.github.io/

You will NOT be tested on this

Daniele Micciancio CSE 20: Discrete Mathematics