CS311H: Discrete Mathematics First Order Logic, Rules of Inference
Total Page:16
File Type:pdf, Size:1020Kb
Review of Last Lecture CS311H: Discrete Mathematics First Order Logic, I What are the building blocks in FOL? Rules of Inference I What is an interpretation for a FOL formula? Instructor: I¸sıl Dillig I What is DeMorgan’s law for quantifiers? Instructor: I¸sıl Dillig, CS311H: Discrete Mathematics First Order Logic, Rules of Inference 1/40 Instructor: I¸sıl Dillig, CS311H: Discrete Mathematics First Order Logic, Rules of Inference 2/40 Translating First-Order Logic into English Translating English into First-Order Logic Given predicates student(x), atUT (x), and friends(x, y), what do the following formulas say in English? Given predicates student(x), atUT (x), and friends(x, y), how do we express the following in first-order logic? I x. ((atUT(x) student(x)) ( y.(friends(x, y) atUT (y)))) ∀ ∧ → ∃ ∧ ¬ I ”Every UT student has a friend” I x.((student(x) atUT(x)) y.friends(x, y)) ∀ ∧ ¬ → ¬∃ I ”At least one UT student has no friends” I x. y.((student(x) student(y) friends(x, y)) I ”All UT students are friends with each other” ∀ ∀ (atUT(x) ∧atUT(y))) ∧ → ∧ Instructor: I¸sıl Dillig, CS311H: Discrete Mathematics First Order Logic, Rules of Inference 3/40 Instructor: I¸sıl Dillig, CS311H: Discrete Mathematics First Order Logic, Rules of Inference 4/40 Satisfiability, Validity in FOL Example I Is the following formula valid, unsat, or contingent? Prove I An FOL formula F is satisfiable if there exists some your answer. interpretation such that F evaluates to true (( x.P(x)) ( x.Q(x))) ( x.(P(x) Q(x))) ∃ ∧ ∃ → ∃ ∧ I Example: Prove that x.(P(x) Q(x)) is satisfiable. ∀ → I An FOL formula F is valid if, for all interpretations, F evaluates to true I Prove that x.(P(x) Q(x)) is not valid. ∀ → I Formulas that are satisfiable, but not valid are contingent, e.g., x.(P(x) Q(x)) ∀ → Instructor: I¸sıl Dillig, CS311H: Discrete Mathematics First Order Logic, Rules of Inference 5/40 Instructor: I¸sıl Dillig, CS311H: Discrete Mathematics First Order Logic, Rules of Inference 6/40 1 Equivalence Rules of Inference I We can prove validity in FOL by using proof rules I Two formulas F1 and F2 are equivalent if F1 F2 is valid ↔ I Proof rules are written as rules of inference: I In PL, we could prove equivalence using truth tables, but not Hypothesis1 possible in FOL Hypothesis2 ... I However, we can still use known equivalences to rewrite one Conclusion formula as the other I An example inference rule: I Example: Prove that ( x. (P(x) Q(x))) and ¬ ∀ → x. (P(x) Q(x)) are equivalent. All men are mortal ∃ ∧ ¬ Socrates is a man I Example: Prove that x. y.P(x, y) and x. y. P(x, y) are Socrates is mortal ¬∃ ∀ ∀ ∃ ¬ ∴ equivalent. I We’ll learn about more general inference rules that will allow constructing formal proofs Instructor: I¸sıl Dillig, CS311H: Discrete Mathematics First Order Logic, Rules of Inference 7/40 Instructor: I¸sıl Dillig, CS311H: Discrete Mathematics First Order Logic, Rules of Inference 8/40 Modus Ponens Example Uses of Modus Ponens I Application of modus ponens in propositional logic: I Most basic inference rule is modus ponens: p q ∧ φ (p q) r 1 ∧ → φ φ 1 → 2 φ2 I Application of modus ponens in first-order logic: I Modus ponens applicable to both propositional logic and P(a) first-order logic P(a) Q(b) → Instructor: I¸sıl Dillig, CS311H: Discrete Mathematics First Order Logic, Rules of Inference 9/40 Instructor: I¸sıl Dillig, CS311H: Discrete Mathematics First Order Logic, Rules of Inference 10/40 Modus Tollens Example Uses of Modus Tollens I Application of modus tollens in propositional logic: p (q r) I Second imporant inference rule is modus tollens: → ∨ (q r) ¬ ∨ φ φ 1 → 2 φ ¬ 2 φ I Application of modus tollens in first-order logic: ¬ 1 Q(a) P(a) Q(a) ¬ → ¬ Instructor: I¸sıl Dillig, CS311H: Discrete Mathematics First Order Logic, Rules of Inference 11/40 Instructor: I¸sıl Dillig, CS311H: Discrete Mathematics First Order Logic, Rules of Inference 12/40 2 Hypothetical Syllogism (HS) Or Introduction and Elimination I Or introduction: φ1 φ1 φ2 → φ1 φ2 φ2 φ3 ∨ → φ1 φ3 I Example application: ”Socrates is a man. Therefore, either → Socrates is a man or there are red elephants on the moon.” I Basically says ”implication is transitive” I Or elimination: φ φ I Example: 1 ∨ 2 P(a) Q(b) φ2 → ¬ Q(b) R(c) φ → 1 I Example application: ”It is either a dog or a cat. It is not a dog. Therefore, it must be a cat.” Instructor: I¸sıl Dillig, CS311H: Discrete Mathematics First Order Logic, Rules of Inference 13/40 Instructor: I¸sıl Dillig, CS311H: Discrete Mathematics First Order Logic, Rules of Inference 14/40 And Introduction and Elimination Resolution I Final inference rule: resolution φ1 φ2 I And introduction: ∨ φ1 φ3 φ1 ¬ ∨ φ φ φ2 2 ∨ 3 φ φ 1 ∧ 2 I To see why this is correct, observe φ1 is either true or false. I And elimination: φ1 φ2 I Suppose φ is true. Then, φ is false. Therefore, by second ∧ 1 ¬ 1 φ1 hypothesis, φ3 must be true. I Suppose φ1 is false. Then, by 1st hypothesis, φ2 must be true. I In any case, either φ or φ must be true; φ φ 2 3 ∴ 2 ∨ 3 Instructor: I¸sıl Dillig, CS311H: Discrete Mathematics First Order Logic, Rules of Inference 15/40 Instructor: I¸sıl Dillig, CS311H: Discrete Mathematics First Order Logic, Rules of Inference 16/40 Resolution Example Summary Name Rule of Inference φ1 φ1 φ2 Modus ponens → φ2 φ1 φ2 → φ2 I Example 1: Modus tollens ¬ φ1 ¬ P(a) Q(b) φ1 φ2 → ∨ ¬ φ2 φ3 Q(b) R(c) Hypothetical syllogism → ∨ φ1 φ3 → φ1 Or introduction φ1 φ2 ∨ I φ1 φ2 Example 2: ∨ φ2 p q Or elimination ¬ ∨ φ1 q p ∨ ¬ φ1 φ2 And introduction φ1 φ2 ∧ φ1 φ2 And elimination ∧ φ1 φ1 φ2 ∨ φ1 φ3 Resolution ¬ ∨ φ2 φ3 ∨ Instructor: I¸sıl Dillig, CS311H: Discrete Mathematics First Order Logic, Rules of Inference 17/40 Instructor: I¸sıl Dillig, CS311H: Discrete Mathematics First Order Logic, Rules of Inference 18/40 3 Using the Rules of Inference Encoding in Logic Assume the following hypotheses: I First, encode hypotheses and conclusion as logical formulas. 1. It is not sunny today and it is colder than yesterday. I To do this, identify propositions used in the argument: I s = ”It is sunny today” 2. We will go to the lake only if it is sunny. I c= ”It is colder than yesterday” 3. If we do not go to the lake, then we will go hiking. I l = ”We’ll go to the lake” 4. If we go hiking, then we will be back by sunset. I h = ”We’ll go hiking” Show these lead to the conclusion: ”We will be back by sunset.” I b= ”We’ll be back by sunset” Instructor: I¸sıl Dillig, CS311H: Discrete Mathematics First Order Logic, Rules of Inference 19/40 Instructor: I¸sıl Dillig, CS311H: Discrete Mathematics First Order Logic, Rules of Inference 20/40 Encoding in Logic, cont. Formal Proof Using Inference Rules I ”It’s not sunny today and colder than yesterday.” 1. s c Hypothesis I ”We will go to the lake only if it is sunny” ¬ ∧ 2. l s Hypothesis → 3. l h Hypothesis I ”If we do not go to the lake, then we will go hiking.” ¬ → 4. h b Hypothesis → I ”If we go hiking, then we will be back by sunset.” I Conclusion: ”We’ll be back by sunset” Instructor: I¸sıl Dillig, CS311H: Discrete Mathematics First Order Logic, Rules of Inference 21/40 Instructor: I¸sıl Dillig, CS311H: Discrete Mathematics First Order Logic, Rules of Inference 22/40 Another Example Encoding in Logic Assume the following hypotheses: I First, encode hypotheses and conclusion as logical formulas. 1. It is not raining or Kate has her umbrella I To do this, identify propositions used in the argument: 2. Kate does not have her umbrella or she does not get wet I r = ”It is raining” 3. It is raining or Kate does not get wet I u= ”Kate has her umbrella” 4. Kate is grumpy only if she is wet I w = ”Kate is wet” I g = ”Kate is grumpy” Show these lead to the conclusion: ”Kate is not grumpy.” Instructor: I¸sıl Dillig, CS311H: Discrete Mathematics First Order Logic, Rules of Inference 23/40 Instructor: I¸sıl Dillig, CS311H: Discrete Mathematics First Order Logic, Rules of Inference 24/40 4 Encoding in Logic, cont. Formal Proof Using Inference Rules I ”It is not raining or Kate has her umbrella.” 1. r u Hypothesis I ”Kate does not have her umbrella or she does not get wet” ¬ ∨ 2. u w Hypothesis ¬ ∨ ¬ 3. r w Hypothesis I ”It is raining or Kate does not get wet.” ∨ ¬ 4. g w Hypothesis → I ” Kate is grumpy only if she is wet.” I Conclusion: ”Kate is not grumpy.” Instructor: I¸sıl Dillig, CS311H: Discrete Mathematics First Order Logic, Rules of Inference 25/40 Instructor: I¸sıl Dillig, CS311H: Discrete Mathematics First Order Logic, Rules of Inference 26/40 Additional Inference Rules for Quantified Formulas Universal Instantiation I Inference rules we learned so far are sufficient for reasoning I If we know something is true for all members of a group, we about quantifier-free statements can conclude it is also true for a specific member of this group I Four more inference rules for making deductions from I This idea is formally called universal instantiation: quantified formulas x.P(x) ∀ (for any c) P(c) I These come in pairs for each quantifier (universal/existential) I If we know ”All CS classes at UT are hard”, universal I One is called generalization, the other one called instantiation instantiation allows us to conclude ”CS311 is hard”! Instructor: I¸sıl Dillig, CS311H: Discrete Mathematics First Order Logic, Rules of Inference 27/40 Instructor: I¸sıl Dillig, CS311H: Discrete Mathematics First Order Logic, Rules of Inference 28/40 Example Universal Generalization I Suppose we can prove a claim for an arbitrary element in the I Consider predicates man(x) and mortal(x) and the hypotheses: domain.