Announcements CS311H: Discrete Mathematics First Order Logic, Rules of Inference Instructor: Işıl Dillig Homework 1 is due now! Homework 2 is handed out today Homework 2 is due next Wednesday Instructor: Işıl Dillig, CS311H: Discrete Mathematics First Order Logic, Rules of Inference 1/38 Instructor: Işıl Dillig, CS311H: Discrete Mathematics First Order Logic, Rules of Inference 2/38 Satisfiability, Validity in FOL An FOL formula F is satisfiable if there exists some domain and some interpretation such that F evaluates to true Example: Prove that x.(p(x) Q(x)) is satisfiable. D = { }, P( ) = true, Q( ) = true Example Is the following formula valid, unsat, or contingent? Prove your answer. (() ( x.q(x))) ( x.(p(x) Q(x))) An FOL formula F is valid if, for all domains and all interpretations, F evaluates to true Prove that x.(p(x) Q(x)) is not valid. D = { }, P( ) = true, Q( ) = false Formulas that are satisfiable, but not valid are contingent, e.g., x.(p(x) Q(x)) Instructor: Işıl Dillig, CS311H: Discrete Mathematics First Order Logic, Rules of Inference 3/38 Instructor: Işıl Dillig, CS311H: Discrete Mathematics First Order Logic, Rules of Inference 4/38 Equivalence Two formulas F 1 and F 2 are equivalent if F 1 F 2 is valid In PL, we could prove equivalence using truth tables, but not possible in FOL However, we can still use known equivalences to rewrite one formula as the other Example: Prove that ( x. (P(x) Q(x))) and x. (P(x) Q(x)) are equivalent. Example: Prove that x. y.p(x, y) and x. y. P(x, y) are equivalent. Rules of Inference We can prove validity in FOL by using proof rules Proof rules are written as rules of inference: An example inference rule: Hypothesis1 Hypothesis2... Conclusion All men are mortal Socrates is a man Socrates is mortal We ll learn about more general inference rules that will allow constructing formal proofs Instructor: Işıl Dillig, CS311H: Discrete Mathematics First Order Logic, Rules of Inference 5/38 Instructor: Işıl Dillig, CS311H: Discrete Mathematics First Order Logic, Rules of Inference 6/38 1
Modus Ponens Example Uses of Modus Ponens Most basic inference rule is modus ponens: Modus ponens applicable to both propositional logic and first-order logic Application of modus ponens in propositional logic: p q (p q) r r Application of modus ponens in first-order logic: P(a) P(a) Q(b) Q(b) Instructor: Işıl Dillig, CS311H: Discrete Mathematics First Order Logic, Rules of Inference 7/38 Instructor: Işıl Dillig, CS311H: Discrete Mathematics First Order Logic, Rules of Inference 8/38 Modus Tollens Example Uses of Modus Tollens Application of modus tollens in propositional logic: Second imporant inference rule is modus tollens: p (q r) (q r) p Application of modus tollens in first-order logic: Q(a) P(a) Q(a) P(a) Instructor: Işıl Dillig, CS311H: Discrete Mathematics First Order Logic, Rules of Inference 9/38 Instructor: Işıl Dillig, CS311H: Discrete Mathematics First Order Logic, Rules of Inference 10/38 Hypothetical Syllogism (HS) Or Introduction and Elimination φ 3 φ 3 Basically says implication is transitive Example: P(a) Q(b) Q(b) R(c) P(a) R(c) Or introduction: Example application: Socrates is a man. Therefore, either Socrates is a man or there are red elephants on the moon. Or elimination: Example application: It is either a dog or a cat. It is not a dog. Therefore, it must be a cat. Instructor: Işıl Dillig, CS311H: Discrete Mathematics First Order Logic, Rules of Inference 11/38 Instructor: Işıl Dillig, CS311H: Discrete Mathematics First Order Logic, Rules of Inference 12/38 2
And Introduction and Elimination And introduction: Example application: It is Tuesday. It s the afternoon. Therefore, it s Tuesday afternoon. And elimination: Example application: It is Tuesday afternoon. Therefore, it is Tuesday. Resolution Final inference rule: resolution φ 3 φ 3 To see why this is correct, observe is either true or false. Suppose is true. Then, is false. Therefore, by second hypothesis, φ 3 must be true. Suppose is false. Then, by 1st hypothesis, must be true. In any case, either or φ 3 must be true; φ 3 Instructor: Işıl Dillig, CS311H: Discrete Mathematics First Order Logic, Rules of Inference 13/38 Instructor: Işıl Dillig, CS311H: Discrete Mathematics First Order Logic, Rules of Inference 14/38 Resolution Example Example 1: Example 2: P(a) Q(b) Q(b) R(c) P(a) R(c) p q q p q Summary Name Rule of Inference Modus ponens Modus tollens Hypothetical syllogism φ 3 φ 3 Or introduction Or elimination And introduction And elimination Resolution φ 3 φ 3 Instructor: Işıl Dillig, CS311H: Discrete Mathematics First Order Logic, Rules of Inference 15/38 Instructor: Işıl Dillig, CS311H: Discrete Mathematics First Order Logic, Rules of Inference 16/38 Using the Rules of Inference Encoding in Logic Assume the following hypotheses: 1. It is not sunny today and it is colder than yesterday. First, encode hypotheses and conclusion as logical formulas. To do this, identify propositions used in the argument: 2. We will go to the lake only if it is sunny. 3. If we do not go to the lake, then we will go hiking. 4. If we go hiking, then we will be back by sunset. Show these lead to the conclusion: We will be back by sunset. s = It is sunny today c= It is colder than yesterday l = We ll go to the lake h = We ll go hiking b= We ll be back by sunset Instructor: Işıl Dillig, CS311H: Discrete Mathematics First Order Logic, Rules of Inference 17/38 Instructor: Işıl Dillig, CS311H: Discrete Mathematics First Order Logic, Rules of Inference 18/38 3
Encoding in Logic, cont. Formal Proof Using Inference Rules It s not sunny today and colder than yesterday. s c We will go to the lake only if it is sunny l s If we do not go to the lake, then we will go hiking. l h If we go hiking, then we will be back by sunset. h b Conclusion: We ll be back by sunset b 1. s c Hypothesis 2. l s Hypothesis 3. l h Hypothesis 4. h b Hypothesis 5. s And Elim (1) 6. l Modus tollens (2,5) 7. l b Hypothetical syllogism (3,4) 8. b Modus ponens (6,7) Instructor: Işıl Dillig, CS311H: Discrete Mathematics First Order Logic, Rules of Inference 19/38 Instructor: Işıl Dillig, CS311H: Discrete Mathematics First Order Logic, Rules of Inference 20/38 Another Example Encoding in Logic Assume the following hypotheses: 1. It is not raining or Kate has her umbrella 2. Kate does not have her umbrella or she does not get wet First, encode hypotheses and conclusion as logical formulas. To do this, identify propositions used in the argument: r = It is raining 3. It is raining or Kate does not get wet 4. Kate is grumpy only if she is wet Show these lead to the conclusion: Kate is not grumpy. u= Kate has her umbrella w = Kate is wet g = Kate is grumpy Instructor: Işıl Dillig, CS311H: Discrete Mathematics First Order Logic, Rules of Inference 21/38 Instructor: Işıl Dillig, CS311H: Discrete Mathematics First Order Logic, Rules of Inference 22/38 Encoding in Logic, cont. Formal Proof Using Inference Rules It is not raining or Kate has her umbrella. r u Kate does not have her umbrella or she does not get wet u w It is raining or Kate does not get wet. r w Kate is grumpy only if she is wet. g w Conclusion: Kate is not grumpy. g 1. r u Hypothesis 2. u w Hypothesis 3. r w Hypothesis 4. g w Hypothesis 5. r w Resolution 1,2 6. w w Resolution 3,5 7. w Idempotence 8. g Modus tollens 4,7 Instructor: Işıl Dillig, CS311H: Discrete Mathematics First Order Logic, Rules of Inference 23/38 Instructor: Işıl Dillig, CS311H: Discrete Mathematics First Order Logic, Rules of Inference 24/38 4
Additional Inference Rules for Quantified Formulas Universal Instantiation Inference rules we learned so far are sufficient for reasoning about quantifier-free statements Four more inference rules for making deductions from quantified formulas These come in pairs for each quantifier (universal/existential) One is called generalization, the other one called instantiation If we know something is true for all members of a group, we can conclude it is also true for a specific member of this group This idea is formally called universal instantiation: (for any c) If we know All CS classes at UT are hard, universal instantiation allows us to conclude CS311 is hard! Instructor: Işıl Dillig, CS311H: Discrete Mathematics First Order Logic, Rules of Inference 25/38 Instructor: Işıl Dillig, CS311H: Discrete Mathematics First Order Logic, Rules of Inference 26/38 Example Universal Generalization Consider predicates man(x) and mortal(x) and the hypotheses: 1. All men are mortal: x.(man(x) mortal(x)) 2. Socrates is a man: man(socrates) Using rules of inference, prove mortal(socrates) 3. man(socrates) mortal(socrates) -inst. (1) 4. mortal(socrates) Modus ponens (1), (3) Suppose we can prove a claim for an arbitrary element in the domain. Since we ve made no assumptions about this element, proof should apply to all elements in the domain. This correct reasoning is captured by universal generalization for arbitrary c Instructor: Işıl Dillig, CS311H: Discrete Mathematics First Order Logic, Rules of Inference 27/38 Instructor: Işıl Dillig, CS311H: Discrete Mathematics First Order Logic, Rules of Inference 28/38 Example Caveat About Universal Generalization Prove x.q(x) from the hypotheses: 1. x. (P(x) Q(x)) Hypothesis 2. x. P(x) Hypothesis 3. Q(c) -inst (1) 4. -inst (2) When using universal generalization, need to ensure that c is truly arbitrary! If you prove something about a specific person Mary, you cannot make generalizations about all people 5. Q(c) Modus ponens (3), (4) 6. x.q(x) -gen (5) Instructor: Işıl Dillig, CS311H: Discrete Mathematics First Order Logic, Rules of Inference 29/38 Instructor: Işıl Dillig, CS311H: Discrete Mathematics First Order Logic, Rules of Inference 30/38 5
Existential Instantiation Example Using Existential Instantiation Consider formula. We know there is some element, say c, in the domain for which is true. This is called existential instantiation: (for unused c) Here, c is a fresh name (i.e., not used before in proof). Otherwise, can prove non-sensical things such as: There exists some animal that can fly. Thus, rabbits can fly! Consider the hypotheses and x. P(x). Prove that we can derive a contradiction (i.e., false) from these hypotheses. 1. Hypothesis 2. x. P(x) Hypothesis 3. instantiation 1, c fresh 4. instantiation 1 5. -intro 6. false Negation law Instructor: Işıl Dillig, CS311H: Discrete Mathematics First Order Logic, Rules of Inference 31/38 Instructor: Işıl Dillig, CS311H: Discrete Mathematics First Order Logic, Rules of Inference 32/38 Existential Generalization Example Using Existential Generalization Suppose we know is true for some constant c Then, there exists an element for which P is true Thus, we can conlude This inference rule called existential generalization: Consider the hypotheses atut (George) and smart(george). Prove x. (atut (x) smart(x)) 1. atut (George) Hypothesis 2. smart(george) Hypothesis 3. atut (George) smart(george) intro, 1,2 4. x.(atut (x) smart(x)) generalization, 3 Instructor: Işıl Dillig, CS311H: Discrete Mathematics First Order Logic, Rules of Inference 33/38 Instructor: Işıl Dillig, CS311H: Discrete Mathematics First Order Logic, Rules of Inference 34/38 Summary of Inference Rules for Quantifiers Example I Prove that these hypotheses imply x.(p(x) B(x)): Name Universal Instantiation Universal Generalization Existential Instantiation Existential Generalization Rule of Inference (anyc) (for arbitraryc) for fresh c 1. x. (C (x) B(x)) (Hypothesis) 2. x. (C (x) P(x)) (Hypothesis) 3. C (a) B(a) ( -inst, 1) 4. C (a) ( -elim, 3 ) 5. B(a) ( -elim, 3 ) 6. C (a) P(a) ( -inst, 2) 7. P(a) (Modus ponens, 4, 6) 8. P(a) B(a) ( -intro, 5,7) 9. x.(p(x) B(x)) ( -gen, 8) Instructor: Işıl Dillig, CS311H: Discrete Mathematics First Order Logic, Rules of Inference 35/38 Instructor: Işıl Dillig, CS311H: Discrete Mathematics First Order Logic, Rules of Inference 36/38 6
Example II Prove the below hypotheses are contradictory by deriving false 1. x.(p(x) (Q(x) S(x))) (Hypothesis) 2. x.(p(x) R(x)) (Hypothesis) 3. x.( R(x) S(x)) (Hypothesis) 4. R(a) S(a) ( -inst, 3) 5. P(a) R(a) ( -inst, 2) Example III Prove x. father(x, Evan) from the following premises: 1. x. y. ((parent(x, y) male(x)) father(x, y)) 2. parent(tom, Evan) 3. male(tom) 6. P(a) ( -elim, 5) 7. R(a) ( -elim, 5) 8. S(a) (Resolution, 4, 7) 9. P(a) Q(a) S(a) ( -inst, 1) 10. Q(a) S(a) (Modus ponens, 6, 9) 11. S(a) -elim, 10 12. S(a) S(a) false ( -intro, 8, 11; double negation) Instructor: Işıl Dillig, CS311H: Discrete Mathematics First Order Logic, Rules of Inference 37/38 Instructor: Işıl Dillig, CS311H: Discrete Mathematics First Order Logic, Rules of Inference 38/38 7