Lecture 9: Resolution in First Order Logic Heshaam Faili University of Tehran Theorem Proving in First Order Logic Unification Resolution.

Slides:



Advertisements
Similar presentations
Artificial Intelligence 8. The Resolution Method
Advertisements

Resolution Proof System for First Order Logic
Biointelligence Lab School of Computer Sci. & Eng.
Inference Rules Universal Instantiation Existential Generalization
10 October 2006 Foundations of Logic and Constraint Programming 1 Unification ­An overview Need for Unification Ranked alfabeths and terms. Substitutions.
1 A formula in predicate logic An atom is a formula. If F is a formula then (~F) is a formula. If F and G are Formulae then (F /\ G), (F \/ G), (F → G),
Knowledge & Reasoning Logical Reasoning: to have a computer automatically perform deduction or prove theorems Knowledge Representations: modern ways of.
Standard Logical Equivalences
Resolution.
ITCS 3153 Artificial Intelligence Lecture 15 First-Order Logic Chapter 9 Lecture 15 First-Order Logic Chapter 9.
Inference in first-order logic Chapter 9. Outline Reducing first-order inference to propositional inference Unification Generalized Modus Ponens Forward.
Automated Reasoning Systems For first order Predicate Logic.
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.
We have seen that we can use Generalized Modus Ponens (GMP) combined with search to see if a fact is entailed from a Knowledge Base. Unfortunately, there.
Methods of Proof Chapter 7, second half.. Proof methods Proof methods divide into (roughly) two kinds: Application of inference rules: Legitimate (sound)
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.
Logic Use mathematical deduction to derive new knowledge.
13 Automated Reasoning 13.0 Introduction to Weak Methods in Theorem Proving 13.1 The General Problem Solver and Difference Tables 13.2 Resolution.
Methods of Proof Chapter 7, Part II. Proof methods Proof methods divide into (roughly) two kinds: Application of inference rules: Legitimate (sound) generation.
Logic.
Resolution in Propositional and First-Order Logic.
Prolog IV Logic, condensed. 2 Propositional logic Propositional logic consists of: The logical values true and false ( T and F ) Propositions: “Sentences,”
1 Applied Computer Science II Resolution in FOL Luc De Raedt.
Outline Recap Knowledge Representation I Textbook: Chapters 6, 7, 9 and 10.
Formal Logic Proof Methods Direct Proof / Natural Deduction Conditional Proof (Implication Introduction) Reductio ad Absurdum Resolution Refutation.
Proof methods Proof methods divide into (roughly) two kinds: –Application of inference rules Legitimate (sound) generation of new sentences from old Proof.
Inference in FOL Copyright, 1996 © Dale Carnegie & Associates, Inc. Chapter 9 Spring 2004.
1 Automated Reasoning Introduction to Weak Methods in Theorem Proving 13.1The General Problem Solver and Difference Tables 13.2Resolution Theorem.
Inference and Resolution for Problem Solving
Methods of Proof Chapter 7, second half.
Search in the semantic domain. Some definitions atomic formula: smallest formula possible (no sub- formulas) literal: atomic formula or negation of an.
Knoweldge Representation & Reasoning
Last time Proof-system search ( ` ) Interpretation search ( ² ) Quantifiers Equality Decision procedures Induction Cross-cutting aspectsMain search strategy.
Artificial Intelligence
Introduction to Logic for Artificial Intelligence Lecture 2 Erik Sandewall 2010.
Proof Systems KB |- Q iff there is a sequence of wffs D1,..., Dn such that Dn is Q and for each Di in the sequence: a) either Di is in KB or b) Di can.
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.
UIUC CS 497: Section EA Lecture #3 Reasoning in Artificial Intelligence Professor: Eyal Amir Spring Semester 2004.
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.
Logical Inference 2 rule based reasoning
First Order Predicate Logic
ARTIFICIAL INTELLIGENCE [INTELLIGENT AGENTS PARADIGM] Professor Janis Grundspenkis Riga Technical University Faculty of Computer Science and Information.
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.
Automated Reasoning Early AI explored how to automated several reasoning tasks – these were solved by what we might call weak problem solving methods as.
Automated Reasoning Systems For first order Predicate Logic.
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.
第 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.
© Copyright 2008 STI INNSBRUCK Intelligent Systems Propositional Logic.
For Wednesday Finish reading chapter 10 – can skip chapter 8 No written homework.
CSE (c) S. Tanimoto, 2008 Predicate Calculus II 1 Predicate Calculus 2 Outline: Unification: definitions, algorithm Formal interpretations and satisfiability.
Inference in First Order Logic. Outline Reducing first order inference to propositional inference Unification Generalized Modus Ponens Forward and backward.
Lecture 9a: Resolution Strategies Heshaam Faili University of Tehran Restriction strategies for resolution Horn clauses.
1 Propositional Logic Limits The expressive power of propositional logic is limited. The assumption is that everything can be expressed by simple facts.
Logical Agents Chapter 7. Outline Knowledge-based agents Propositional (Boolean) logic Equivalence, validity, satisfiability Inference rules and theorem.
Proof Methods for Propositional Logic CIS 391 – Intro to Artificial Intelligence.
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.
Logical Agents. Outline Knowledge-based agents Logic in general - models and entailment Propositional (Boolean) logic Equivalence, validity, satisfiability.
EA C461 Artificial Intelligence
Introduction to Logic for Artificial Intelligence Lecture 2
Logical Inference 2 Rule-based reasoning
Prolog IV Logic, condensed.
Resolution Proof System for First Order Logic
Resolution Preliminaries
Presentation transcript:

Lecture 9: Resolution in First Order Logic Heshaam Faili University of Tehran Theorem Proving in First Order Logic Unification Resolution

FOL Decidability (1) If a proof procedure is always guaranteed to find a proof of a particular sentence or of its negation, then the question of logical implication for the sentence is said to be decidable. To see if KB |= c, we generate all possible inferences from , stopping when we get  or ~c.

FOL Decidability (2) In general, neither  nor ~c may be logically implied by KB. In this case, the proof procedure will never stop. The question of logical implication in this case is thus semidecidable: If KB |= c or KB |= ~c, the proof procedure will eventually discover that. Otherwise, the procedure will run forever.

4 FOL -- Inference Rules for quantifiers Universal and Existential Elimination Existential Introduction

Resolution in FOL Mechanical proof procedure with a single rule Invented by J. A. Robinson in 1965 Three main steps: 1. Clause form: transform all clauses to uniform format 2. Unification: find a variable assignment so that two clauses can be resolved 3. Resolution: rule to obtain new conclusions

1. Clause Form We want a uniform representation for our logical propositions, so that we can use a simple uniform proof procedure. Clausal form expresses all logical propositions using literals (atomic sentences or negated atomic sentences) and clauses (sets of literals representing their disjunction). Ex: all the following in a single form: a => b ~a  b b  ~a ~(~a  ~b)

Any set of sentences in predicate calculus can be converted to clausal form. Eight-step procedure for conversion: 1. Replace implications 2. Distribute negations 3. Standardize variables 4. Replace existential 5. Remove universals 6. Distribute disjunctions 7. Replace operators 8. Rename variables Clause Form Conversion

1. Replace implications Any sentence of the form:  becomes    at all levels 2. Distribute negations Repeatedly do the following: ~~  becomes     becomes       becomes      V  becomes  V     V  becomes  V  

3. Standardize variables Rename variables to ensure that each quantifier has its own unique variable. Ex: (  X p(X))  (  X q(X)) becomes (  X p(X))  (  Y q(Y)) 4. Replace existential Consider: (  Y  X p(X,Y)) The identity of X depends on the value of Y. We can replace X by a function of Y: (  Y p(g(X),Y)) where g is a Skolem function

Skolemization Replace each occurrence of an existentially quantified variable by a Skolem function. The function’s arguments are the universally quantified variables that are bound by universal quantifiers whose scope includes the scope of the existential quantifier being eliminated. The Skolem functions must be new, i.e., not already present in any other sentences. If the existential quantifier is not within a universal quantifier, use a Skolem function of no arguments, i.e., a constant.

Examples of Skolemization 1.  X p(X) becomes p(g) 2.  Y  X p(X,Y) becomes  Y p(g(Y),Y) 3.  X  Y p(X,Y) becomes  Y p(g,Y) 4.  Y  X (((q(X)  p(X,Y))   Z  W(r(W))) becomes  Y (((q(f(Y))  p(f(Y),Y))   Z (r(g(Y,Z))) where f and g are Skolem functions

12 5. Remove universal quantifiers Throw away  ’s and assume all variables are universally quantified.  X  Y  Z q(h(Y))  p(h(Y),X)  r(X,Z) becomes q(h(Y))  p(h(Y),X)  r(X,Z) 6. Distribute disjunctions Write the formula in conjunctive normal form (the conjunction of sets of disjunctions) with:      becomes (       

7. Replace operators Replace the conjunction S 1  S 2  ….  S n with the set of clausesS 1, S 2, …, S n Convert each S i into a set of literals (that is, get rid of the disjunctions symbols “  ”, and write them in clause notation. Ex: (p(X)  q(Y))  (p(X)  ~r(X,Y)) becomes two clauses: {p(X), q(Y)} {p(X), ~r(X,Y)}

8. Rename variables Change variable names so that no variable symbol appears in more than one clause: Ex: {p(X), q(Y)} and {p(X), ~r(X,Y)} becomes {p(X), q(Y)} and {p(Z), ~r(Z,W)} we can do this because:  X  Y(p(X)  q(Y))  (p(X)  ~r(X,Y)) is equivalent to  X  Y(p(X)  q(Y))   Z  W(p(Z)  ~r(Z,W))

Example of entire conversion (1)  X (p(X) => ((  Y p(Y) => (p(f(X,Y)))  (~  Y (~q(X,Y)  p(Y)))) 1.  X (~p(X)  ((  Y ~p(Y)  (p(f(X,Y)))  (~  Y (~q(X,Y)  p(Y)))) 2.  X (~p(X)  ((  Y ~p(Y)  (p(f(X,Y))  (  Y (q(X,Y)  ~p(Y)))) 3.  X (~p(X)  ((  Y ~p(Y)  (p(f(X,Y)))  (  W (q(X,W)  ~p(W))))

Example of entire conversion (2) 4.  X (~p(X)  ((  Y ~p(Y)  (p(f(X,Y)))  (q(X,g(X))  ~p(g(X))))) 5. ~p(X)  ((~p(Y)  (p(f(X,Y)))  (q(X,g(X))  ~p(g(X))))) 6. (~p(X)  ~p(Y))  (p(f(X,Y)))  (~p(X)  (q(X,g(X)))  (~p(X)  ~p(g(X)))))

Example of entire conversion (3) 7. {~p(X), ~p(Y)), p(f(X,Y))}, {~p(X), q(X,g(X)))}, {~p(X), ~p(g(X))} 8. {~p(X1), ~p(Y1)), p(f(X1,Y1))}, {~p(X2), q(X2,g(X2)))}, {~p(X3), ~p(g(X3))}

Unification -- Substitution Unification is the process of determining whether two expressions can be made identical by appropriate substitutions for their variables. The substitution applies to variables of both expressions and makes them syntactically equivalent. The result is a substitution instance Example of a unifying substitution S 1 : p(X,f(b),Z) S 2 : p(a,Y,W) U = {X/a Y/f(b), Z/W} S 1 [U] = S 2 [U] = p(a,f(b),W) substitution instance

19 Properties of the substitution 1. Each variable is associated with at most one expression; 2. No variable with an associated expression occurs within any associated expression. That is, no “left side” appears on a “right side”: U = {X/a, Y/f(X), Z/Y} is not a legal substitution

A set of expressions {S 1,S 2,….S n } is unifiable if there is a substitution U that makes them identical: S 1 [U] = S 2 [U] =… = S n [U] Ex: U = {X/a, Y/b, Z/c} unifies the expressions p(a,Y,Z) and p(X,b,Z) and p(a,Y,c) Unification of sentences

21

Two expressions can have more that one unifier that makes them equivalent: S 1 = p(X,Y,Y) and S 2 = p(a,Z,Z) are unified by U 1 ={X/a,Y/Z} and U 2 ={X/a,Y/b, Z/b} S 1 [ U 1 ] = S 2 [ U 1 ] = p(a,Z,Z) S 1 [ U 2 ] = S 2 [ U 2 ] = p(a,b,b) Unifiers are not unique!

23 Partial order between unifiers Some unifiers are more general than others: U 1 is more general than U 2 if there exists a unifier U 3 such that U 1 U 3 = U 2 Example: U 1 = {X/f(Y),Z/W,R/c} is more general that U 2 = {X/f(a),Z/b, R/c} since U 3 = {Y/a,W/b} U 1 U 3 ={X/f(Y),Z/W,R/c}{Y/a,W/b} = U 2 Unifiers form a partial order

24 Most general unifier (MGU) For each set of sentences, there exists a most general unifier (mgu) that is unique up to variable renaming Ex: for S 1 = p(X,Y,f(Z)) and S 2 = p(a,W,R) U={X/a,Y/W,R/f(Z)} is the mgu For the resolution procedure, we want to find the most general unifier of literals: a constant, variable, or a functional object of length n.

25 Basic functions for MGU procedure Constant(exp) returns true if exp is a constant Ex: a, f(g(a,b,c)) are constants Variable(exp) returns true if exp is a simple variable Length(exp) returns the number of items in a function Ex: f(a,g(Y)) is an object of length 2. MguVar(Var, exp) returns false if Var is included in exp {Var/exp} otherwise

26 Recursive procedure for MGU function Mgu(exp1,exp2) returns unifier if exp1 = exp2 return {} if Variable(exp1) then return MguVar(exp1,exp2) if Variable(exp2) then return MguVar(exp2,exp1) if Constant(exp1) or Constant(exp1) return false if not(Length(exp1) = Length(exp2) return false unifier := {} for i := 1 to Length(exp1) do s := Mgu(Part(exp1,i),Part(exp2,i)) if s is false return false unifier := Compose(unifier,s) exp1 := Substitute(exp1,unifier) exp2 := Substitute(exp2,unifier) return unifier; end

Find the mgu unifier for p(f(X,g(a,Y)), g(a,Y)) and p(f(X,Z),Z). 1. Mgu is called on p and p, returns {} 2. Mgu is called recursively on f(X, g(a,Y)) and f(X,Z) 3. Mgu is called on f and f, returns {} 4. Mgu is called on X and X, returns {} 5. Mgu is called on g(a,Y) and Z; since Z is a variable, it returns (via Mguvar) {Z/g(a,Y)} after checking that Z is not in g(a,Y). Example of MGU trace (1)

28 Example of MGU trace (2) 6. {Z/g(a,Y)} is composed with the previous (empty) substitution 7. The entire substitution is applied to both expressions, yieldingf(X, g(a,Y)) 8. Since i = 3, Mgu returns {Z/g(a,Y)}, which is then applied to the top level expressions. All other checks show equality. The result is p(f(X,g(a,Y)),g(a,Y))

29 Performance Issues Predicate Indexing: Storing the answers of some queries Knows(John, x) : store all x (in a hash table) which John knows Using subsumption lattice to be more efficient

30 Subsumption Lattice

Given a clause containing the literal  and another clause the literal ~ , we can infer the clause consisting of all the literals of both clauses without  and ~ . Ex:1. {p, q}  2. {~q, r}  3. {p, r}1,2 3. Resolution

Why does this work? Consider the two clauses {winter, summer} {~winter, cold} At any point, winter is either true or false. If it is true, then cold must be true to guarantee the truth of clause 2. If winter is false, then summer must be true to guarantee the truth of clause 1. So regardless of winter's truth value, either cold or summer must be true, i.e., we can conclude: {cold, summer}

Other Resolution Examples 1. {p, q}  2. {~p, q}  3. {q}1,2 1. {~p, q}  2. {p}  3. {q} 1,2 1. {p}  2. {~p}  3. {}1,2 merge the q's much like Modus Ponens We can derive the empty clause, showing that the KB has a contradiction

For clauses containing variables, we can resolve  in one clause with ~  in another clause, as long as  and  have a mgu U. The resulting clause is the union of the original 2 clauses, with  and ~  removed, and with U applied to the remaining literals.   and   [U],  [U]} where  [U] =  [U] Resolution Rule

Ex1: 1. {p(X), q(X,Y)}  2. {~p(a), r(b,Z)}  3. {q(a,Y), r(b,Z)}1,2 Ex2: Two clauses may resolve in more than one way since  and ~  may be chosen in different ways: 1. {p(X,X), q(X), r(X)}  2. {~p(a,Z), ~q(b)}  3. {q(a), r(a),~q(b)}1,2 4. {p(b,b), r(b), ~p(a,Z)}1,2 Examples of Resolutions

A resolution deduction of a clause  from a data base  is a sequence of clauses in which 1.  is an element of the sequence; 2. Each element is either a member of  or the result of applying the resolution principle to clauses earlier in the sequence. Resolution Deduction

Resolution procedure with nondeterministic choices function Resolution(KB) returns answer while not(Empty_Clause(KB)) do c1 := Choose_Clause(KB) c2 := Choose_Clause(KB) res := Choose_Resolvents(c1,c2) KB := KB U {res} end return true end

Ex: Resolution deduction of the empty clause 1. { p }  2. {~p, q }  3. { ~q, r }   ~r }  5. {q}1, 2 6. { ~q}3, 4 7. { }5, 6

{p}{~p,q}{~q,r}{~r} {q} {~p,r} {~q} {r} { }{~p} A “resolution trace” is a linear form of the graph All possible resolutions (to 3 levels)

As for Propositional Logic, we will use refutation resolution as the single rule for proving sentences about a KB We will use it to prove the unsatisfiability of a set of clauses, i.e., they contain a contradiction if we can derive the empty clause. Resolution refutation: to prove c, prove that KB U {~c} |= 0like a “proof by contradiction” Rule is refutation-complete. Resolution Refutation

41 Answering questions with Refutation-Resolution True/False questions: we want to know if a conclusion follows from KB: Ex:father(art, jon) father(bob, kim) father(X, Y) => parent(X, Y) Is art the parent of jon? Queries: fill-in-the blank: we want to know also what instantiation makes it true: Who is the parent of jon?

42 True/False by Refutation Resolution 1. {father(art, jon)}  2. {father(bob, kim)}  3. {~father(X,Y), parent(X,Y)}  4. {~parent(art,jon)} 5. {parent(art,jon)}1, 3 6. {parent(bob, kim)}2, 3 7. {~father(art, jon)}3, 4 8. { }4, 5 9. { }1, 7 negated goal clause

43

To obtain one instantiation that makes the conclusion true (if any), form a disjunction of the negation of the goal c and its “answer literal”: a term of form ans(X 1,X 2,…X n ) where the variables X 1,X 2,…X n are the free variables in c. Ex: Add to the previous KB the clause {~parent(X, jon), ans(X)} Resolution halts when it derives a clause containing only the ans literal Fill-in-the-blank (Green’s method)

Example of fill-the-blank derivation 1. {father(art, jon)}  2. {father(bob, kim)}  3. {~father(X,Y), parent(X,Y)}  4. {~parent(Z,jon), ans(Z)}c 5. {parent(art, jon)}1, 3 6. {parent(bob, kim)}2, 3 7. {~father(w,jon), ans(W)}3, 4 8. {ans(art) }4, 5 9. {ans(art) }1, 7

The answer may not be unique: several different answers may result from the proof, depending on the clauses that were chosen for resolution. We may also get an answer of the form {ans(a), ans(b) } where one of the answers is right, but the clause doesn’t tell us which one. 1. {father(art,jon), father(bob,jon)} KB 2. {~ father(X,jon),ans(X)} c 3. {father(bob,jon),ans(art)} 1, 2 4. {ans(art),ans(bob)} 2, 3 Properties of Fill-in-the-blank

47 Forward Chaining

48 Example of Forward Chaining

49 Completeness of FC k : number of predicate argument p: number of predicates n: number of constant symbols pn k distinct ground facts Propositional logic with above facts

50 Efficient FC Problems of simple FC Inner loop involve pattern matching Algorithm rechecks every rule in each loop Might generate many irrelevant facts Should be addressed these problems

51 Pattern Matching and CSP Every finite-domain CSP can be expressed as a single definite clause together with some associated ground facts.

52 Incremental FC Every new fact inferred on iteration t must be derived from at least — one new fact inferred on iteration t - 1. Retain the partial matching of any rule inorder to use it next iterations

53 Irrelevant facts 3 ways to avoid: Use backward chaining Restrict subset of rules Use magic set, some information about the goal in order to ignore irrelevant facts …

54 Backward Chaining

55 BC example

56 Logic Programming Algorithm = Logic + Control Prolog = Programming in Logic

57 ?