Artificial Intelligence 8. The Resolution Method

Slides:



Advertisements
Similar presentations
Artificial Intelligence 9. Resolution Theorem Proving
Advertisements

Some Prolog Prolog is a logic programming language
Resolution Proof System for First Order Logic
First-Order Logic.
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
First-Order Logic (FOL) aka. predicate calculus. First-Order Logic (FOL) Syntax User defines these primitives: – Constant symbols (i.e., the "individuals"
Resolution.
Inference in first-order logic Chapter 9. Outline Reducing first-order inference to propositional inference Unification Generalized Modus Ponens Forward.
UIUC CS 497: Section EA Lecture #2 Reasoning in Artificial Intelligence Professor: Eyal Amir Spring Semester 2004.
Automated Reasoning Systems For first order Predicate Logic.
Artificial Intelligence
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.
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 CPSC 386 Artificial Intelligence Ellen Walker Hiram College.
Logic.
F22H1 Logic and Proof Week 7 Clausal Form and Resolution.
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.
Knoweldge Representation & Reasoning
Inference in FOL Copyright, 1996 © Dale Carnegie & Associates, Inc. Chapter 9 Fall 2004.
Artificial Intelligence
Artificial Intelligence Chapter 14 Resolution in the Propositional Calculus Artificial Intelligence Chapter 14 Resolution in the Propositional Calculus.
Inference in FOL Copyright, 1996 © Dale Carnegie & Associates, Inc. Chapter 9 Spring 2005.
Propositional Logic Reasoning correctly computationally Chapter 7 or 8.
INFERENCE IN FIRST-ORDER LOGIC IES 503 ARTIFICIAL INTELLIGENCE İPEK SÜĞÜT.
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.
1 Chapter 8 Inference and Resolution for Problem Solving.
Logical Agents Logic Propositional Logic Summary
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.
Logical Agents Chapter 7. Knowledge bases Knowledge base (KB): set of sentences in a formal language Inference: deriving new sentences from the KB. E.g.:
Computing & Information Sciences Kansas State University Lecture 14 of 42 CIS 530 / 730 Artificial Intelligence Lecture 14 of 42 William H. Hsu Department.
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 Early AI explored how to automate several reasoning tasks – these were solved by what we might call weak problem solving methods as.
Computing & Information Sciences Kansas State University Monday, 25 Sep 2006CIS 490 / 730: Artificial Intelligence Lecture 14 of 42 Monday, 25 September.
CPSC 386 Artificial Intelligence Ellen Walker Hiram College
Artificial Intelligence 7. Making Deductive Inferences Course V231 Department of Computing Imperial College, London Jeremy Gow.
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.
Dr. Shazzad Hosain Department of EECS North South Universtiy Lecture 04 – Part B Propositional Logic.
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.
Logical Agents. Outline Knowledge-based agents Logic in general - models and entailment Propositional (Boolean) logic Equivalence, validity, satisfiability.
Introduction to Logic for Artificial Intelligence Lecture 2
Logical Inference: Through Proof to Truth
Biointelligence Lab School of Computer Sci. & Eng.
CS 416 Artificial Intelligence
Prolog IV Logic, condensed.
Methods of Proof Chapter 7, second half.
RESOLUTION.
Presentation transcript:

Artificial Intelligence 8. The Resolution Method Course V231 Department of Computing Imperial College, London Jeremy Gow

Soundness & Completeness Want to prove theorem T from Axioms Ax Chosen a set of inference rules R A B means B is entailed by A A B means B is derived from A using R R should be sound: if A B then A B Want R to be complete: if A B then A B

Choose Your Search Space Soundness and completeness of R isn’t enough We want a reasonable search space R determines operators, so influences the space Can I see where I’m going? (Heuristic measure) Can I restrict options at each state? (Branching) Three main approaches Forwards chaining: no heuristic guidance Backwards chaining: large branching (many things entail KB) Proof by refutation: clear goal (false), forwards inference

Proof by Refutation Proof by contradiction, reductio ad absurdum Negate the theorem & add to axioms (¬T,Ax) Use rules of inference to derive the False So sentences (¬T,Ax) can’t all be true (unsatisfiable) But the axioms Ax are true Hence the negated theorem ¬T must be false Hence the theorem T must be true

The Resolution Method Proof by refutation with a single inference rule No need to worry about choice of rule Just how we apply the one rule Resolution is complete for FOL Refutation-complete [Robinson 1965] If (¬T,Ax) unsatisfiable it will derive a contradiction So if will prove any true theorem of FOL Even so, it might take a long time (> universe) Even fairly trivial theorems can take a long time Can use search heuristics to speed it up (next lecture) No guarantees if it’s not a theorem

Binary Resolution (Propositional) Unit resolution rule (last lecture) AB, ¬B A Binary resolution rule AB, ¬BC AC The literals B and ¬B are resolved

Binary Resolution (First-Order) Binary resolution rule AB, ¬CD Subst(, AD) if substitution  s.t. Subst(,B) = Subst(,C) The literals B and ¬C are resolved B and C have been made the same by 

Resolution in FOL (This Lecture) What if KB contains non-disjuncts? Preprocessing step: rewrite to CNF How do we find substitution ? The unification algorithm But what if more than two disjuncts? Extend binary resolution to full resolution

Conjunctive Normal Form A conjunction of clauses Each clause is a disjunction of literals Prop. literal: proposition or negated proposition FO literal: predicate or negated predicate No quantifiers (all variables implicitly universal) Example FO clause likes(george, X)  ¬likes(tony, houseof(george))  ¬is_mad(maggie) Any FO sentence can be rewritten as CNF

Converting FOL to CNF (see notes) Eliminate implication/equivalence (rewrite) Move ¬ inwards (rewrite) Rename variables apart (substitution) Move quantifiers outwards (rewrite) Skolemise existential variables (substitution) Distribute  over  (rewrite) Flatten binary connectives (rewrite) (Optional: Reintroduce implications)

Example CNF Conversion Propositional example (B  (A  C))  (B  ¬A) 1. Remove implication: ¬(B  (A  C))  (B  ¬A) 2. Move ¬ inwards (De Morgan’s x 2): (¬B  ¬(A  C))  (B  ¬A) (¬B  (¬A  ¬C))  (B  ¬A) (Skip 3 to 5 as no variables.)

Example CNF Conversion (Contd) (¬B  (¬A  ¬C))  (B  ¬A) 6. Distribute  over : (¬B  (B  ¬A))  ((¬A  ¬C)  (B  ¬A)) 7. Flatten connectives (¬B  B  ¬A)  (¬A  ¬C  B  ¬A) Drop 1st clause (¬B  B), remove duplicate from 2nd: ¬A  ¬C  B

¬A  ¬C  B becomes (A  C)  B Kowalski Normal Form Can reintroduce  to CNF, e.g. ¬A  ¬C  B becomes (A  C)  B Kowalski form (A1 … An)  (B1 … Bn) Binary resolution… AB, BC AC Resembles Horn clauses (basis for Prolog)

Skolemisation Replace V with a ‘something’ term If no preceeding U use fresh Skolem constant Otherwise fresh Skolem function parameterised by all preceeding U X Y (person(X)  has(X, Y)  heart(Y)) to person(X)  has(X, f(X))  heart(f(X)) (The particular heart f(X) depends on person X)

Substitutions & Inference Rules Propositional inference rules used in first-order logic But in FOL we can make substitutions Sometimes a substitution can allow a rule to be applied cf. FO binary resolution knows(john, X)  hates(john, X) knows(john, mary) Substitution + Modus Ponens: infer hates(john, mary) Need to find substitution that makes literals equal Known as a unifier

Unifying Predicates We unified these two predicates: knows(john, X) and knows(john, mary) By saying that X should be substituted by mary Why? Because john = john and can {X\mary} For knows(jack, mary) and knows(john, X) john doesn’t match jack So we cannot unify the two predicates Hence we cannot use the rule of inference

Unification Want an algorithm which: Example: Takes two FOL sentences as input Outputs a substitution {X/mary, Y/Z, etc.} Which assigns terms to variables in the sentences So that the first sentence looks exactly like the second Or fails if there is no way to unify the sentences Example: Unify(“knows(john, X)”, “knows(john,mary)”) = {X/mary} Unify(“knows(john, X)”, “knows(jack,mary)”) = Fail

Functions Within the Unify Algorithm isa_variable(x) checks whether x is a variable isa_list(x) checks whether x is a list head(x) outputs the head of a list (first term) e.g., head([a,b,c]) = a tail(x) outputs the elements other than the head in a list e.g., tail([a,b,c]) = [b,c]

More Internal Functions (Compound Expressions) isa_compound(x) checks whether x is compound expression (either a predicate, a function or a connective) args(x) finds the subparts of the compound expression x arguments of a predicate, function or connective Returns the list of arguments op(x) predicate name/function name/connective symbol

Two Parts of the Unification Algorithm Algorithm is recursive (it calls itself) Passes around a set of substitutions, called mu Making sure that new substitutions are consistent with old ones unify(x,y) = unify_internal(x,y,{}) x and y are either a variable, constant, list, or compound unify_internal(x,y,mu) x and y are sentences, mu is a set of substitutions finds substitutions making x look exactly like y unify_variable(var,x,mu) var is a variable finds a single substitution (which may be in mu already)

unify_internal unify_internal(x,y,mu) ---------------------- Cases 1.if (mu=failure) then return failure 2.if (x=y) then return mu. 3.if (isa_variable(x)) then return unify_variable(x,y,mu) 4.if (isa_variable(y)) then return unify_variable(y,x,mu) 5.if (isa_compound(x) and isa_compound(y)) then return unify_internal(args(x),args(y),unify_internal(op(x),op(y),mu)) 6.if (isa_list(x) and isa_list(y)) then return unify_internal(tail(x),tail(y),unify_internal(head(x),head(y),mu)) 7.return failure

unify_variable unify_variable(var,x,mu) ------------------------ Cases 1. if (a substitution var/val is in mu) then return unify_internal(val,x,mu) 2. if (a substitution x/val is in mu) then return unify_internal(var,val,mu) 3. if (var occurs anywhere in x) return failure 4. add var/x to mu and return

Notes on the Unification Algorithm unify_internal will not match a constant to a constant, unless they are equal (case 2) Case 5 in unify_internal checks that two compound operators are the same (e.g. same predicate name) Case 6 in unify_internal causes the algorithm to recursivly unify the whole list Cases 1 and 2 in unify_variable check that neither inputs have already been substituted

The Occurs Check Suppose we needed to substitute X with f(X,Y) This would give us f(X,Y) instead of X But there is still an X in there, so the substitution isn’t complete: we need f(f(X,Y),Y), then f(f(f(X,Y),Y),Y) and so on We need to avoid this situation Otherwise the algorithm won’t stop Case 3 in unify_variable checks this Known as the “occurs check” Occurs check slows the algorithm down Order (n2), where n is size of expressions being unified

An Example Unification Suppose we want to unify these sentences: 1. p(X,tony)  q(george,X,Z) 2. p(f(tony),tony)  q(B,C,maggie) By inspection, this is a good substitution: {X/f(tony), B/george, C/f(tony), Z/maggie} This makes both sentences become: p(f(tony),tony)  q(george, f(tony), maggie) Note that we want to substitute X for C But we have substituted f(tony) for X already See the notes for this as a worked example Using the unification algorithm Requires five iterations!

Binary Resolution (First-Order) Binary resolution rule (using unification) AB, ¬CD Subst(, AD) if Unify(B, C) =  Unification algorithm finds Most General Unifier (MGU)  Don’t substitute any more than need to

The Full Resolution Rule If Unify(Pj, ¬Qk) =  (¬ makes them unifiable) P1  …  Pm, Q1  …  Qn Subst(, P1  … (no Pj) …  Pm  Q1  … (no Qk) ... Qn) Pj and Qk are resolved Arbitrary number of disjuncts Relies on preprocessing into CNF

Using Full Resolution Sentences already in CNF Pick two clauses Pick positive literal P from first Pick negative literal N from second Find MGU  of ¬P and N Write both clauses as one big disjunction With P and N missing Apply  to the new clause

Resolution Proof Search Keep on resolving clause pairs Eventually result in zero-length clause This indicates that some literal K was true at the same time as the literal ¬K Only way to reduce sentence to be empty Hence there was an inconsistency Which proves the theorem Topic of the next lecture

Coursework: War of Life http://www.doc.ic.ac.uk/~sgc/teaching/v231/ Two player version of Game of Life Implement several strategies in Prolog Run a tournament On CATE this afternoon Submit via CATE (more to follow…) Deadline: 3 weeks today