1 Section 9.1 Automatic Reasoning Recall that a wff W is valid iff ¬ W is unsatisfiable. Resolution is an inference rule used to prove unsatisfiability.

Slides:



Advertisements
Similar presentations
Resolution Proof System for First Order Logic
Advertisements

Biointelligence Lab School of Computer Sci. & Eng.
Inference Rules Universal Instantiation Existential Generalization
Knowledge & Reasoning Logical Reasoning: to have a computer automatically perform deduction or prove theorems Knowledge Representations: modern ways of.
Standard Logical Equivalences
Resolution.
First Order Logic Resolution
Inference and Reasoning. Basic Idea Given a set of statements, does a new statement logically follow from this. For example If an animal has wings and.
For Friday No reading Homework: –Chapter 9, exercise 4 (This is VERY short – do it while you’re running your tests) Make sure you keep variables and constants.
Resolution in Propositional and First-Order Logic.
© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Sixth Edition, Mc Graw-Hill, 2007 Chapter 1: (Part 2): The Foundations: Logic and Proofs.
Outline Recap Knowledge Representation I Textbook: Chapters 6, 7, 9 and 10.
Computability and Complexity 9-1 Computability and Complexity Andrei Bulatov Logic Reminder (Cnt’d)
Formal Logic Proof Methods Direct Proof / Natural Deduction Conditional Proof (Implication Introduction) Reductio ad Absurdum Resolution Refutation.
Computability and Complexity 8-1 Computability and Complexity Andrei Bulatov Logic Reminder.
Logic seminar 5 The resolution principle Slobodan Petrović.
AI - Week 16 Logic and Reasoning in AI: Resolution Refutation Lee McCluskey, room 2/07
Inference and Resolution for Problem Solving
Search in the semantic domain. Some definitions atomic formula: smallest formula possible (no sub- formulas) literal: atomic formula or negation of an.
Last time Proof-system search ( ` ) Interpretation search ( ² ) Quantifiers Equality Decision procedures Induction Cross-cutting aspectsMain search strategy.
The Semantic Web – WEEK 8: An automatic Proof technique.. The “Layer Cake” Model – [From Rector & Horrocks Semantic Web cuurse] You are here!
Introduction to Logic for Artificial Intelligence Lecture 2 Erik Sandewall 2010.
Knowledge & Reasoning Logical Reasoning: to have a computer automatically perform deduction or prove theorems Knowledge Representations: modern ways of.
Advanced Topics in FOL Chapter 18 Language, Proof and Logic.
Inference in First-Order logic Department of Computer Science & Engineering Indian Institute of Technology Kharagpur.
For Wednesday Read chapter 10 Prolog Handout 4. Exam 1 Monday Take home due at the exam.
Conjunctive normal form: any formula of the predicate calculus can be transformed into a conjunctive normal form. Def. A formula is said to be in conjunctive.
1 Chapter 8 Inference and Resolution for Problem Solving.
CSCE 4613 Artificial Inteligence
1 Section 7.2 Equivalent Formulas Two wffs A and B are equivalent, written A  B, if they have the same truth value for every interpretation. Property:
First Order Predicate Logic
ARTIFICIAL INTELLIGENCE [INTELLIGENT AGENTS PARADIGM] Professor Janis Grundspenkis Riga Technical University Faculty of Computer Science and Information.
CSE S. Tanimoto Horn Clauses and Unification 1 Horn Clauses and Unification Propositional Logic Clauses Resolution Predicate Logic Horn Clauses.
Chapter 1, Part II: Predicate Logic With Question/Answer Animations.
Unification Algorithm Input: a finite set Σ of simple expressions Output: a mgu for Σ (if Σ is unifiable) 1. Set k = 0 and  0 = . 2. If Σ  k is a singleton,
CS Introduction to AI Tutorial 8 Resolution Tutorial 8 Resolution.
Resolution Strategies One common strategy for applying resolution is called level saturation. Here you try to resolve every pair of clauses from the original.
Scope, free variable, closed wff §In  X(A) or  X(A), where A is a wff : X is called the variable quantified over; A is said to be (within) the scope.
Chapter 2 Logic 2.1 Statements 2.2 The Negation of a Statement 2.3 The Disjunction and Conjunction of Statements 2.4 The Implication 2.5 More on Implications.
1 Georgia Tech, IIC, GVU, 2006 MAGIC Lab Rossignac Lecture 02: QUANTIFIERS Sections 1.3 and 1.4 Jarek Rossignac CS1050:
Reasoning using First-Order Logic
The Law of Resolution Formal Aspects of Computer Science - Week 7 The Law of Resolution Lee McCluskey, room 2/07
第 1 6 章 谓词演算中的归结. 2 Outline Unification Predicate-Calculus Resolution Completeness and Soundness Converting Arbitrary wffs to Clause Form Using Resolution.
Instructor: Eyal Amir Grad TAs: Wen Pu, Yonatan Bisk Undergrad TAs: Sam Johnson, Nikhil Johri CS 440 / ECE 448 Introduction to Artificial Intelligence.
General resolution Method1 General Resolution method in FOL Lesson 8.
For Wednesday Finish reading chapter 10 – can skip chapter 8 No written homework.
1 Section 8.3 Higher-Order Logic A logic is higher-order if it allows predicate names or function names to be quantified or to be arguments of a predicate.
1 Section 6.2 Propositional Calculus Propositional calculus is the language of propositions (statements that are true or false). We represent propositions.
1 Section 8.2 Program Correctness (for imperative programs) A theory of program correctness needs wffs, axioms, and inference rules. Wffs (called Hoare.
1 Section 9.2 Logic Programming A logic program is a set of clauses with the restriction that there is exactly one positive literal in each clause. Such.
Mathematics for Comter I Lecture 3: Logic (2) Propositional Equivalences Predicates and Quantifiers.
1 Section 7.3 Formal Proofs in Predicate Calculus All proof rules for propositional calculus extend to predicate calculus. Example. … k.  x p(x) P k+1.
Converting arbitrary wffs to CNF A wff is in prenex form iff it consists of a string of quantifiers (called a prefix) followed by a quantifier free formula.
1 Hojjat Ghaderi, University of Toronto, Fall 2006 CSC384: Intro to Artificial Intelligence Knowledge Representation III ● Required Readings: 9.1, 9.2,
1 Section 7.1 First-Order Predicate Calculus Predicate calculus studies the internal structure of sentences where subjects are applied to predicates existentially.
1 Introduction to Artificial Intelligence LECTURE 9: Resolution in FOL Theorem Proving in First Order Logic Unification Resolution.
Introduction to Logic for Artificial Intelligence Lecture 2
Knowledge Representation and Reasoning
Proposition & Predicates
Horn Clauses and Unification
General Resolution method in FOL
Soundness of SLD-Resolution
Horn Clauses and Unification
Horn Clauses and Unification
Horn Clauses and Unification
Section 8.1 Equality A first-order theory is first-order predicate calculus applied to the formalization of some subject (i.e., decide on some axioms.
Horn Clauses and Unification
RESOLUTION.
Resolution Proof System for First Order Logic
Resolution Preliminaries
Presentation transcript:

1 Section 9.1 Automatic Reasoning Recall that a wff W is valid iff ¬ W is unsatisfiable. Resolution is an inference rule used to prove unsatisfiability in a “mechanical” way. To prove a wff is valid: negate the wff and convert it to CNF; write down the fundamental disjunctions as premises; use resolution to find a false statement. Example. Prove (p  q)  (q  r)  (p  r) is a tautology. Solution. Negate the wff and transform it into CNF: (¬ p  q)  (¬ q  r)  p  ¬ r. Now write down the fundamental disjunctions as premises to start the proof. 1.¬ p  q P 2.¬ q  r P 3.pP 4.¬ rP 5.q1, 3, R 6.r2, 5, R 7. [] 4, 6, R QED. Resolution for Propositional Logic The resolution rule for propositions is shown to the right, where A and B are disjunctions of literals. Notation: A – p denotes A with all occurrences of p removed and B – ¬ p denotes B with all occurrences of ¬ p removed. Notation: We denote false by a box []. In applying resolution, we assume A  B  B  A and A  []  A. If A and B are false, then the rule is simplified as shown.

2 Example/Quiz. Use resolution to prove that the following wff (an application of constructive dilemma) is a tautology. (A  B)  (A  C  D)  (B  E  F)  (C  D)  (E  F). Solution. Negate the wff and transform the result into CNF. (A  B)  (¬ A  C )  (¬ A  D)  (¬ B  E)  (¬ B  F)  (¬ C  ¬ D)  (¬ E  ¬ F). 1.A  B P 2.¬ A  C P 3.¬ A  D P 4.¬ B  E P 5.¬ B  F P 6.¬ C  ¬ D P 7.¬ E  ¬ FP 8.¬ A  ¬ C3, 6, R 9.¬ B  ¬ F4, 7, R 10.¬ B  ¬ B5, 9, R 11.¬ A  ¬ A2, 8, R 12.B1, 11, R 13. [] 10, 12, R QED. Question. Are there proofs that use less than 13 steps. Answer: Probably not since each of the 7 premises must be used. Why?

3 Resolution for First-Order Logic Example (to Show the Idea). Suppose some proof contains the following two lines, where we assume that the wffs (called clauses) are universally closed. 1.p(a, x)  q(x, y, a)P 2.¬ p(x, b)  r(x, y, b)P To apply resolution to the wffs on lines 1 and 2 several actions need to be taken: Change the names so the clauses have distinct variable names. In this case, we’ll keep line 1 as it is and change the names on line 2. 3.¬ p(v, b)  r(v, w, b)P Unify (i.e., match) p(a, x) on line 1 and p(v, b) on line 3 to get a substitution (i.e., a set of bindings)  = {v/a, x/b}. Apply  to clauses on lines 1 and 3. p(a, b)  q(b, y, a) ¬ p(a, b)  r(a, w, b) Apply resolution to the transformed wffs. 4. q(b, y, a)  r(a, w, b)1, 3, R,  = {v/a, x/b} So we need to discuss three things for first-order resolution. The clausal form of wffs Unification of atoms The inference rule.

4 Clausal Forms A clause is a disjunction of literals. (Recall a literal is an atom or its negation.) A clausal form is the universal closure of a conjunction of clauses. Notation. A clausal form is also represented as a set of its clauses. Example. The clausal form  x  y (p(x)  (q(x, y)  ¬ r(x))  (¬ p(x)  s(y))) Is represented by the set {p(x), q(x, y)  ¬ r(x), ¬ p(x)  s(y)}. Not every wff is equivalent to a clausal form. For example, the wff  x p(x) is not equivalent to a clausal form. But we have the following result of Skolem, which is sufficient for resolution. Skolem’s Algorithm Every wff can be associated with a clausal form in which the two are either both satisfiable or both unsatisfiable. 1. Construct the prenex CNF for the wff. 2. Replace all occurrences of each free variable by a new constant. 3. Eliminate the existential quantifiers by Skolem’s Rule: A. If  x W(x) is not inside the scope of a universal quantifier, then replace  x W(x) by W(c) for a new constant c. B.If  x W(x) is inside the scope of  x 1...  x n, then replace  x W(x) by W(ƒ(x 1, …, x n )) for a new function symbol ƒ.

5 Quiz. Find a clausal form for each wff. 1.  x A(x). 2.  x  y B(x, y). 3.  x  y  z C(x, y, z). 4.  x  y  z D(x, y, z). Answers. 1. A(c). 2.  x B(x, ƒ(x)). 3.  x  y C(x, y, g(x, y)). 4.  x D(x, ƒ(x), g(x)). Example/Quiz. Find a clausal form for the wff  y  x p(x, y)   z (q(x)  r(z)). Solution: Put the wff in prenex CNF.  y  x p(x, y)   z (q(w)  r(z))(renamed)  ¬  y  x p(x, y)   z (q(w)  r(z))(removed  )   y  x ¬ p(x, y)   z (q(w)  r(z))(moved ¬ inside)   y (  x ¬ p(x, y)   z (q(w)  r(z)))(moved  y outside)   y  x  z (¬ p(x, y)  (q(w)  r(z)))(moved  x and  z outside)   y  x  z ((¬ p(x, y)  q(w))  (¬ p(x, y)  r(z)))(constructed CNF) (replace free variable w by constant c)  y  x  z ((¬ p(x, y)  q(c))  (¬ p(x, y)  r(z))) Apply Skolem’s Rule to eliminate  x and  z.  y ((¬ p(ƒ(y), y)  q(c))  (¬ p(ƒ(y), y)  r(g(y))). So there are two clauses in the clausal form, which can be denoted by the set {¬ p(ƒ(y), y)  q(c), ¬ p(ƒ(y), y)  r(g(y)}.

6 Substitutions and Unification A binding of a variable x to a term t is denoted x/t and it means replace x by t. Applying a Binding to an Expression If x/t is a binding and E is an expression, then E(x/t) denotes the expression obtained from E by replacing all free occurrences of x with t. Examples. p(x, y, z)(x/y) = p(y, y, z) p(x, y, z)(y/ƒ(z)) = p(x, ƒ(z), z) A substitution is a finite set of bindings with distinct numerators. (Use lowercase greek letters for substitutions.) Example.  = {x/y, y/ƒ(z)} and  = {y/ƒ(a), z/b} are substitutions. Applying a Substitution to an Expression or a Set of Expressions If  is a substitution and E is an expression, then E  denotes the expression obtained from E by simultaneously applying the bindings in  to E. Example. If  = {x/y, y/ƒ(z)}, then p(x, y, z)  = p(x, y, z){x/y, y/ƒ(z)} = p(y, ƒ(z), z). If S is a set of expressions, then S  is the set of expresisons obtained from S by applying  to each expression of S. Example. If  = {x/y, y/ƒ(z)} and S = {p(x, y), q(y, g(z))}, then S  = {p(x, y) , q(y, g(z))  }= {p(y, ƒ(z)), q(ƒ(z), g(z))}.

7 Composing Substitutions If  and  are two substitutions, then the composition  is applied to an expression E by E(  ) = (E  ) . We can calculate  by applying it to an atom that contains all the numerator variables of the two substitutions. Then collect the bindings that result from the application. Example. Let  = {x/y, y/ƒ(z)} and  = {y/ƒ(a), z/b}. Since the numerator variables are x, y, and z, we calculate p(x, y, z)(  ) = (p(x, y, z)  )  = p(y, ƒ(z), z))  = p(ƒ(a), ƒ(b), b). So  = {x/ƒ(a), y/ƒ(b), z/b}. We can also calculate  by the following procedure, where  = {x i /t i } and  = {y i /s i }. 1. Construct {x i /(t i  }. 2. Delete any x i /x i from Step Delete y i /s i from  if y i is a numerator of .  is the union of the substitutions from Steps 2 and 3. Example. Let  = {x/y, y/ƒ(z)} and  = {y/ƒ(a), z/b}. Calculate . Step 1. Construct {x/y , y/ƒ(z)  } = {x/ƒ(a), y/ƒ(b)}. Step 2. No deletions. So no changes from Step 1. Step 3. Delete y/ƒ(a) from  (because y is a numerator of  ) to obtain {z/b}. Step 4. The union of sets from Steps 2 and 3 give  = {x/ƒ(a), y/ƒ(b), z/b}. Properties of Composition  =  and  =  =  where  =  {}.

8 A unifier of a set S of expressions is a substitution  such that S  is a singleton set. Example. {x/a} is a unifier of {p(x), p(a)} because {p(x), p(a)}{x/a} = {p(a)}. Example/Quiz. What are some unifiers of S = {p(x, a), p(y, z)}? Answer: Since a is a constant, any unifier must include the binding z/a. A unifier might also include x/y or y/x. So two unifiers of S are {x/y, z/a} and {y/x, z/a} because S{x/y, z/a} = {p(y, a)} and S{y/x, z/a} = {p(x, a)}. Notice also that {x/t, y/t, z/a} is a unifier of S for any term t because S{x/t, y/t, z/a} = {p(t, a)}. A most general unifier (mgu) of a set S of expressions is a unifier of  of S such that any other unifier  of S can be written as  =  for some substitution . Example. Let S = {p(x, a), p(y, z)} from the preceding example. The unifiers of S are {x/y, z/a} and {y/x, z/a} and {x/t, y/t, z/a} for any term t. The unifier {x/y, z/a} is an mgu for S because {y/x, z/a} = {x/y, z/a}{y/x} and {x/t, y/t, z/a} = {x/y, z/a}{y/t}. Quiz. Continue the example and show that, {y/x, z/a} is an mgu of S. Proof: {x/y, z/a} = {y/x, z/a}{x/y} and {x/t, y/t, z/a} = {y/x, z/a}{x/t}. QED. Quiz. Continue the example and show for a constant c that {x/c, y/c, z/a} is not an mgu of S. Proof: Assume, BWOC, that {x/c, y/c, z/a} is an mgu. Then {x/y, z/a} = {x/c, y/c, z/a}  for some substitution . But {x/c, y/c, z/a}  contains the subset {x/c, y/c, z/a}, so it can’t equal {x/y, z/a}. This contradiction tells us that {x/c, y/c, z/a} is not an mgu. QED.

9 Unification Algorithms Robinson: For a finite set S of atoms find whether S has an mgu. 1. k := 0;  0  :=  ; go to Step If S  k is a singleton then stop with mgu  k Otherwise construct D k (set of terms in leftmost position of disagreement); go to Step If D k has a variable v and a term t such that v does not occur in t then  k+1 :=  k {v/t}; k := k + 1; go to Step 2. Otherwise stop (S is not unifiable). Example. Trace the algorithm for S = {p(x, h(x, g(y)), y), p(x, h(a, z), b)}. 1.k := 0;  0  := . 2. S  0 = S  = {p(x, h(x, g(y)), y), p(x, h(a, z), b)} is not a singleton; D 0 = {x, a}. 3.  1 :=  0 {x/a} = {x/a}; k := S  1 = {p(a, h(a, g(y)), y), p(a, h(a, z), b)} is not a singleton; D 1 = {g(y), z}. 3.  2 :=  1 {z/g(y)} = {x/a, z/g(y)}; k := S  2 = {p(a, h(a, g(y)), y), p(a, h(a, g(y)), b)} is not a singleton; D 2 = {y, b}. 3.  3 :=  2 {y/b} = {x/a, z/g(b), y/b}; k := S  3 = {p(a, h(a, g(b)), b)} is a singleton; stop with mgu  3 = {x/a, z/g(b), y/b}. Quiz. Apply the algorithm to S = {p(x), p(ƒ(x))}. Answer. S is not unifiable because in the set D 0 = {x, ƒ(x))} x occurs in ƒ(x).

10 Martelli-Montanari: To see whether two atoms A and B have an mgu, form the set {A = B} and apply the following rules repeatedly in any order. (ƒ and g are either function or predicate symbols.) 1. Replace ƒ(s 1, …, s n ) = ƒ(t 1, …, t n ) with equations s 1 = t 1, …, s n = t n. 2. If ƒ(s 1, …, s n ) = g(t 1, …, t m ) with ƒ ≠ g or m ≠ n, then stop with failure. 3. Delete x = x. 4. Replace t = x, where t is not a variable, with x = t. 5. If x = t and x does not occur in t, apply {x/t} to the other equations that contain x. 6. If x = t and t is not a variable and x occurs in t, then stop with failure. If there is no failure and the rules cannot be applied, then transform {x i = t i } to mgu {x i /t i }. Example. Trace the algorithm for A = p(x, h(x, g(y)), y) and B = p(x, h(a, z), b). {p(x, h(x, g(y)), y) = p(x, h(a, z), b)}({A = B}) {x = x, h(x, g(y)) = h(a, z), y = b}(Rule 1) {h(x, g(y)) = h(a, z), y = b}(Rule 3) {x = a, g(y) = z, y = b}(Rule 1) {x = a, z = g(y), y = b}(Rule 4) {x = a, z = g(b), y = b}(Rule 5) Done. The mgu is {x/a, z/g(b), y/b}. Quiz. Apply the algorithm to the two atoms p(x, x) and p(y, ƒ(y)). Solution: {p(x, x) = p(y, ƒ(y))} and Rule 1 gives {x = y, x = ƒ(y)}. Apply Rule 5 to get {x = y, y = ƒ(y)}. Apply Rule 6 to get failure.

11 Resolution Rule (R) Given the following two clauses. L 1  …  L k  C and ¬ M 1  …  ¬ M n  D, where L i and M i are atoms and C and D are disjunctions of other literals. Assume also that 1. The clauses have distinct sets of variable names (rename if necessary). 2.  is the mgu of {L 1, …, L k, M 1, …, M n }. 3. N = L 1 , where {L 1, …, L k, M 1, …, M n }  = {N}. Then we have: Example.Given the two clauses in the following proof segment k.p(a, y)  p(a, z)  q(x, y, z) P k + 1.¬ p(w, ƒ(b))  r(w, v, g(w))  ¬ p(a, ƒ(b))P These two clauses have the form L 1  L 2  C and ¬ M 1  D. The two clauses have distinct sets of variables. The set of atoms {p(a, y), p(a, z), p(w, ƒ(b))} has mgu  = {w/a, y/ƒ(b), z/ƒ(b)}. Notice that {p(a, y), p(a, z), p(w, ƒ(b))}  = {p(a, ƒ(b))}. So the resolution rule can be applied to the two clauses to obtain the resolvant: k + 2.q(x, ƒ(b), ƒ(b))  r(a, v, g(a))k, k + 1, R, {w/a, y/ƒ(b), z/ƒ(b)}.

12 To prove a wff is valid: negate the wff and convert it to clausal form; write down the clauses as premises; use resolution to find a false statement. Example/Quiz. Use resolution to prove the following wff is valid.  x (  y p(x, y)   z q(x, z)   y (p(x, y)  q(x, y))). Solution: Negate the wff: ¬  x (  y p(x, y)   z q(x, z)   y (p(x, y)  q(x, y))). Convert it to clausal form: ¬  x (  y p(x, y)   z q(x, z)   w (p(x, w)  q(x, w)))(renamed variables)  x ((  y p(x, y)   z q(x, z))   w (¬ p(x, w)  ¬ q(x, w)))(removed  and moved ¬ right)  x  w ((  y p(x, y)   z q(x, z))  ¬ p(x, w)  ¬ q(x, w)) (moved  w left)  x  w  y  z ((p(x, y)  q(x, z))  ¬ p(x, w)  ¬ q(x, w))(moved  y and  z left)  x  y  z ((p(x, y)  q(x, z))  ¬ p(x, ƒ(x))  ¬ q(x, ƒ(x)))(removed  w by Skolem) So the set of clauses is {p(x, y)  q(x, z), ¬ p(x, ƒ(x)), ¬ q(x, ƒ(x)))}. Now do a resolution proof by making each the three clauses a premise (rename to get distinct variable names). 1. p(x, y)  q(x, z)P 2. ¬ p(u, ƒ(u))P 3. ¬ q(w, ƒ(w))P 4. q(u, z)1, 2, R, {x/u, y/ƒ(u)} 5. [] 3, 4, R, {w/u, z/ ƒ(u)} QED.