SLD-resolution Introduction Most general unifiers SLD-resolution

Slides:



Advertisements
Similar presentations
CS4026 Formal Models of Computation Part II The Logic Model Lecture 1 – Programming in Logic.
Advertisements

Some Prolog Prolog is a logic programming language
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.
2005conjunctive-ii1 Query languages II: equivalence & containment (Motivation: rewriting queries using views)  conjunctive queries – CQ’s  Extensions.
AR for Horn clause logic Introducing: Unification.
Knowledge & Reasoning Logical Reasoning: to have a computer automatically perform deduction or prove theorems Knowledge Representations: modern ways of.
Standard Logical Equivalences
Resolution.
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.
1 Logic Logic in general is a subfield of philosophy and its development is credited to ancient Greeks. Symbolic or mathematical logic is used in AI. In.
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.
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.
Logic.
1 Applied Computer Science II Resolution in FOL Luc De Raedt.
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.
CSE (c) S. Tanimoto, 2008 Propositional Logic
Constraint Logic Programming Ryan Kinworthy. Overview Introduction Logic Programming LP as a constraint programming language Constraint Logic Programming.
1 Automated Reasoning Introduction to Weak Methods in Theorem Proving 13.1The General Problem Solver and Difference Tables 13.2Resolution Theorem.
Logic in Computer Science Transparency No Chapter 3 Propositional Logic 3.6. Propositional Resolution.
Inference and Resolution for Problem Solving
Catriel Beeri Pls/Winter 2004/5 type reconstruction 1 Type Reconstruction & Parametric Polymorphism  Introduction  Unification and type reconstruction.
Winter 2004/5Pls – inductive – Catriel Beeri1 Inductive Definitions (our meta-language for specifications)  Examples  Syntax  Semantics  Proof Trees.
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.
Chapter 3 Propositional Logic
Artificial Intelligence
Plan for the rest of the quarter TuesdayThursday Week 7ResolutionProof carrying code Week 8No class (Sorin in DC for workshop) Predicate abstraction (Mystery.
Artificial Intelligence Chapter 17 Knowledge-Based Systems Biointelligence Lab School of Computer Sci. & Eng. Seoul National University.
Proof by Deduction. Deductions and Formal Proofs A deduction is a sequence of logic statements, each of which is known or assumed to be true A formal.
INFERENCE IN FIRST-ORDER LOGIC IES 503 ARTIFICIAL INTELLIGENCE İPEK SÜĞÜT.
Formal Models of Computation Part II The Logic Model
Notes for Chapter 12 Logic Programming The AI War Basic Concepts of Logic Programming Prolog Review questions.
MATH 224 – Discrete Mathematics
1 Knowledge Based Systems (CM0377) Lecture 4 (Last modified 5th February 2001)
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.
Advanced Topics in Propositional Logic Chapter 17 Language, Proof and 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.
© Kenneth C. Louden, Chapter 11 - Functional Programming, Part III: Theory Programming Languages: Principles and Practice, 2nd Ed. Kenneth C. Louden.
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.
Ch. 13 Ch. 131 jcmt CSE 3302 Programming Languages CSE3302 Programming Languages (notes?) Dr. Carter Tiernan.
Web Science & Technologies University of Koblenz ▪ Landau, Germany Procedural Semantics Soundness of SLD-Resolution.
Automated Reasoning Systems For first order Predicate Logic.
Of 38 lecture 13: propositional logic – part II. of 38 propositional logic Gentzen system PROP_G design to be simple syntax and vocabulary the same as.
CSE (c) S. Tanimoto, 2008 Predicate Calculus II 1 Predicate Calculus 2 Outline: Unification: definitions, algorithm Formal interpretations and satisfiability.
1 Knowledge Based Systems (CM0377) Lecture 6 (last modified 20th February 2002)
Answer Extraction To use resolution to answer questions, for example a query of the form  X C(X), we must keep track of the substitutions made during.
Logic Programming Lecture 2: Unification and proof search.
COMP 412, FALL Type Systems C OMP 412 Rice University Houston, Texas Fall 2000 Copyright 2000, Robert Cartwright, all rights reserved. Students.
Introduction to Logic for Artificial Intelligence Lecture 2
Completeness of the SLD-Resolution
Resolution in the Propositional Calculus
Knowledge-Based Systems Chapter 17.
Prolog syntax + Unification
Unification Algorithm ChuChen
Logic: Top-down proof procedure and Datalog
Soundness of SLD-Resolution
Soundness of SLD-Resolution
Presentation transcript:

SLD-resolution Introduction Most general unifiers SLD-resolution Soundness Completeness

Proof of A = refutation of A  : true (any valid formula)  : false (any unsatisfiable formula) Fact 1 P |= A iff P  { A} |=  Fact 2 if P  { A} |-  then P  { A} |=  supposing the inference rules are sound ’if and only if’ if they are sound and complete  idea of ‘proof by refutation’ start from P and A apply inference rules until  is produced if so, we know that P |= A

Refutation proofs with clauses Definite clauses F can be read as F    G1, ..., Gm    G1, ..., Gm ‘empty clause’       Refutation proofs start from P and   G1,...,Gm try to derive the ‘empty clause’  example pp. 34-35: a sort of generalized Modus Ponens

How to automate refutations? G =  G1, ...,Gm select some Gi = p(t1, ..., tn) look for clauses ‘defining’ p/n H  B1, ..., Bk (we may have several such) make Gi and H syntactically identical reason: Modus Ponens requires it  find substitution (unifier)  such that H = Gi if such  exists, apply it to (B1,...,Bk) and the rest of G new goal: ( G1, ..., B1, ..., Bk, ... Gm) continue until G is empty (if possible)

What did we just compute? G: ( (G1  ...  Gm))  ( G1  ...  Gm) if G lead to contradiction then we have the conclusion that  G1  ...  Gm holds Derivation: any chain of inference steps Refutation of G: finite derivation of falsity starting from G consists of k inferences with k unifications i (1  i  k)  (( G1  ...  Gm) 1... k) was shown to be unsatisfiable fact: p(X) is unsatisfiable iff some instance of p(X) is Thus: P |= (G1  ...  Gm) 1 ... k 1 ... k is the counter-example or the answer to our question if some variables are left unbound we may assume the universal closure

Troubles in the computation Selections: deterministic or not? goal literals program clauses unifiers Computations:success/fail/infinite? dead ends (no matching clauses) infinite number of solutions (several unifiers) loops (p  p)

Most general unifiers Algorithmic solution to the ‘matching’ problem deterministic & efficient Vocabulary predicate symbols & functors: constructors atoms, terms: structures principal symbol, direct substructures size of a structure (# of symbols)

Unifier (definition) Let s1, s2 be structures and  a substitution if s1 = s2 then  is a unifier of s1 and s2 Notes if s contains X then X and s have no unifier proof: size(s) > size(X)  size(s) > size(X) whatever  is unifier  may leave (some) variables free composition of  with any substitution  yields another unifier each of them is ‘more specific’ than 

Generality of unifiers let  and  be unifiers of s and t  =  :  is more general than  any s is an instance of s Note: generality is not antisymmetric … … but the following holds if  is more general than  and vice versa then s and s are identical up to the renaming of variables

Most general unifier(s), mgu substitution  is a mgu of s & t if  is a unifier of s & t  is more general than any other unifier of s & t Thm: mgus are unique up to renaming! mgus are the substitutions we are looking for in the matching problem: how to find them effectively

(yet) Some (more) terminology Set of equations {X1=t1,…,Xn=tn} is in solved form iff X1,…,Xn are distinct variables, and none of X1,…,Xn appear in t1,…,tn Proposition If E = {X1=t1,…,Xn=tn} is in solved form then  = {X1/t1,…,Xn/tn} is a mgu of E Definition: E1 and E2 are equivalent both have the same set of unifiers consequently same solutions in Herbr. interpretations

Unification algorithm Several implementations exist simple O(min(size(s), size(t))) presented with ‘occurs check’: quadratic time Basic ideas if s is a variable, bind it to t (and vice versa) if both are structures (or constants) principal symbols must be the same direct substructures must unify (use recursion) note: bindings may ‘spread’ elsewhere in terms same variable may have several occurrences

Our algorithm (p. 40) To unify s & t Theorem: Algorithm returns try to transform {s = t} into an equivalent one in solved form if this succeeds, the result gives also a mgu of s & t if this fails, no unifier exists note: constants are treated as 0-ary functors Theorem: Algorithm returns the equivalent solved form of s = t or ‘failure’ if no such exists

Resolution rule Inference rule for definite clauses & goals From ( (G1,...,Gi,...,Gm)) and ( H  B1,...,Bk) such that Gi and H have a mgu  derive ( (G1,...,B1,...,Bk,...,Gm))

Procedural view FROM SUCH THAT DERIVE query G and clause C subgoal Gi of G and the head H of C unify DERIVE a new query G’ with Gi replaced with body of C and mgu of H and Gi applied to the result

Resolution: technicalities (i) Both premises universally closed scopes of the quantifiers are disjoint Conclusion is universally closed variables in the premises must be disjoint What to do? rename variables in clauses before inference e.g. attach the # of the inference step to all variables allows multiple uses of the same clause essential with recursive clauses

Resolution: technicalities (ii) Selection of subgoals abstraction: assume some selection function  a.k.a. computation rule SLD-resolution Linear resolution for Definite clauses with Selection function linear resolution P1 is always the query created in the previous step P2 is always a program clause

Using SLD-resolution G0 =  A1,...,Am (G0) = Ai apply resolution to Ai and a (renamed copy of a) program clause C construct new goal G1, then G2, ... computations end (at some goal Gi) when (Gi) does not unify with any clause head or Gi = false (empty goal) infinite computations possible, too

Formalizing resolution proofs SLD-derivation From Gi & (a copy of) Ci, determine G(i+1) Note: Gi,  & Ci determine (i+1) reason: mgus are unique (up to var. names)  no need to state  separately in derivations including s improves the readability, though G(i+1) is said to be derived from Gi & Ci Gi & Ci resolve into G(i+1) special notation (jagged arrow, p. 44) Each derivation G0,...,Gn yields a computed substitution 1…n Example 3.13 p. 45

Successful derivations Finite and end to the empty goal SLD-refutation of G answer substitution = computed substitution of a refutation Theorem (independence of the computation rule) If G has a SLD-refutation with some rule 1 then G has one with the same answer with any other rule 2, and the refutation ‘2’ is obtained by permuting the clauses used in the refutation ‘1’ proof intuitive reason all subgoals are selected sooner or later same clauses are used to refute each of them

Classifying derivations Successful lead to false Failed lead to some goal Gi such that (Gi) does no unify with any clause head note: it doesn’t matter if there are some other subgoals than the selected one which unify with some clause head, we are stuck with the selected one anyway Infinite Complete derivation: any of the above ’taken to the extreme’, continued as long as possible

SLD-trees... Consider alternative clauses for a selected subgoal (Gi) may unify with several clauses  Gi may have several (and different) complete derivations with rule  SLD-trees formalize the set of all such derivations nodes: goals (G0 at the root) edges are labeled with the clause used in inference descendant: the resulting new goal Each path represents some derivation some may fail, some succeed, some may be infinite Definition 3.18.

...SLD-trees SLD-trees are (usually) distinct for different selection functions Finite tree with 1 & infinite with 2 possible! Independence of computation rule tells that refutations in tree T1 (using 1) are also found in T2 (using 2) and are permutations of the paths in T1 Note there may exist other failing or infinite paths for which the above does not hold but they don’t interest us that much anyway it is enough that the successful derivations are found

Soundness of SLD-resolution Final conclusion for a give goal G try to find a refutation of  G if found, apply the answer substitution to G this step is actually an additional inference rule  SLD-resolution gives answers  p(X), …, empty goal,  = {X/tom,…} reasoning is sound, if P |= p(tom) Answer = computed substitution restricted on query variables negative answer is possible, too Soundness (or correctness) Shown w.r.t. computed answer substitutions Reason: user is not (usually) interested in individual resolution steps, but the final answer

Soundness theorem (Clark -79) Let P be a definite program  a selection function  a -computed answer for goal  A1,…,Am Then P |= ( (A1  …  Am) ) Note Requires ‘occurs-check’ in unification see example 3.21

Completeness theorem... Does SLD-resolution compute all logical consequences? strictly speaking NOT, but practically YES, since every correct answer is an instance of some computed answer Let P,  A1,…,Am, and  be as before If P |=  (A1  …  Am) Then there exists a refutation of  A1,…,Am with answer  such that (A1  …  Am) is an instance of (A1  …  Am) See Example 3.23

...Completeness theorem Most general unifiers are used in inference steps  refutations give the most general answers necessity for completeness theorem to hold Thm. confirms only the existence of a refutation does not tell how to find one in practice, we have to systematically search in the SLD-tree for the successful derivations

Search in SLD-trees Prolog systems Breadth-first? Textual ordering of clauses  ordering of edges Depth-first –search in this order Backtrack from leaf nodes Solutions are reported at empty leaves Property: the above is complete for finite SLD-trees Infinite trees  infinite paths  infinite search Breadth-first? theoretically better makes implementation (memory management) much more complicated too slow for practical applications

Proof trees Structural representations for SLD-derivations like derivation trees in CF grammars each clause represents an elementary tree derivation tree = combination of elementary trees joint nodes labeled with equations for clause head & corresponding body atom above proof tree a complete derivation tree, i.e. all leaf nodes are constants true

Proof trees… Alternative view proof tree = collection of equations (joint nodes) consistent tree: equation set has a solved form not all derivation trees are consistent Note: works also in other interpretations i.e. no matter what the ‘equality’ stands for Extension: use (atomic) goals as the root solved form = an answer for the goal Simplification of proof trees apply the substitution induced by the solved form to the tree collapse identical equations into one node simplified tree shows (clearly) the consistence

Searching for a consistent proof tree Two (possibly) interleaved processes combination of elementary trees given this subgoal, try out this clause simplification of nodes not necessary to simplify the whole tree at once In which order to simplify? construct the whole tree & check then check while building check the whole set of equations when new ones are added simplify the tree as new equations are introduced Prolog approach build tree in depth-first manner simplify immediately

Derivations and proof trees Many derivations may map to the same proof tree Clear due to the independence of computation rule computation rule tells the order in which equations are solved the final result stays the same