AR for Horn clause logic Introducing: Unification.

Slides:



Advertisements
Similar presentations
Artificial Intelligence
Advertisements

Artificial Intelligence 8. The Resolution Method
CS4026 Formal Models of Computation Part II The Logic Model Lecture 1 – Programming in Logic.
First Order Logic Logic is a mathematical attempt to formalize the way we think. First-order predicate calculus was created in an attempt to mechanize.
Some Prolog Prolog is a logic programming language
Resolution Proof System for First Order Logic
First-Order Logic.
Biointelligence Lab School of Computer Sci. & Eng.
Inference Rules Universal Instantiation Existential Generalization
SLD-resolution Introduction Most general unifiers SLD-resolution
10 October 2006 Foundations of Logic and Constraint Programming 1 Unification ­An overview Need for Unification Ranked alfabeths and terms. Substitutions.
Logic Programming Automated Reasoning in practice.
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.
Introduction to PROLOG ME 409 Lab - 1. Introduction to PROLOG.
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.
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.
13 Automated Reasoning 13.0 Introduction to Weak Methods in Theorem Proving 13.1 The General Problem Solver and Difference Tables 13.2 Resolution.
Artificial Intelligence Chapter 14. Resolution in the Propositional Calculus Artificial Intelligence Chapter 14. Resolution in the Propositional Calculus.
Simple Example {i = 0} j := i * i {j < 100} Can we ‘verify’ this triple? Only if we know the semantics of assignment.
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.
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.
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.
Catriel Beeri Pls/Winter 2004/5 type reconstruction 1 Type Reconstruction & Parametric Polymorphism  Introduction  Unification and type reconstruction.
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.
Artificial Intelligence
PLANNING Partial order regression planning Temporal representation 1 Deductive planning in Logic Temporal representation 2.
Propositional Logic Reasoning correctly computationally Chapter 7 or 8.
INFERENCE IN FIRST-ORDER LOGIC IES 503 ARTIFICIAL INTELLIGENCE İPEK SÜĞÜT.
Notes for Chapter 12 Logic Programming The AI War Basic Concepts of Logic Programming Prolog Review questions.
Propositional Resolution Computational LogicLecture 4 Michael Genesereth Spring 2005.
Inference in First-Order logic Department of Computer Science & Engineering Indian Institute of Technology Kharagpur.
Propositional Calculus Composed of symbols –P – some true statement P might represent something like “It is Monday” or “the car is red” And sentences –a.
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.
14/10/04 AIPP Lecture 7: The Cut1 Controlling Backtracking: The Cut Artificial Intelligence Programming in Prolog Lecturer: Tim Smith Lecture 7 14/10/04.
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.
CSE S. Tanimoto Horn Clauses and Unification 1 Horn Clauses and Unification Propositional Logic Clauses Resolution Predicate Logic Horn Clauses.
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.
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.
1 Inference in First Order Logic CS 171/271 (Chapter 9) Some text and images in these slides were drawn from Russel & Norvig’s published material.
Reasoning using First-Order Logic
1 Knowledge Based Systems (CM0377) Lecture 6 (last modified 20th February 2002)
Chapter 1 Logic and proofs
AR for Horn clause logic Introducing: Unification.
Logical Inference 2 Rule-based reasoning
Chapter 7: Beyond Definite Knowledge
Logical Inference 2 Rule-based reasoning
Propositional Resolution
Prolog syntax + Unification
Unification Algorithm ChuChen
Horn Clauses and Unification
Presentation transcript:

AR for Horn clause logic Introducing: Unification

2 How to deal with variables?  Example:  p lot_maint(house(p))  big(house(p))  p lot_maint(house(p))  big(house(p)) false  lot_maint(house(Bos))  We would like to conclude:  by means of generalized modus ponens. false  big(house(Bos)) Principle: use instantiations of the 2 Horn clauses, such that these DO ‘match’.

3 More examples:  We drop the universal quantification, since all variables are universally quantified anyway.  Some examples using standard modus ponens: related(x,y)  parent(x,y) parent(John,Mary) parent(John,Mary) related(John,Mary) loves(John,x)  related(John,x) related(y,father(y)) related(y,father(y)) loves(John,father(John)) Unification !!

4 Substitutions:  Examples:  ={ x / h(g(A)), y / g(A), z / w}  = { x / g(z), y / B}  A substitution is a finite set of pairs of the form variable / term, such that all variables at the left- hand sides of the pairs are distinct.  In our substitutions we will NOT allow that some variable that occurs left also occurs in some term at the right.

5 Applying substitutions:  Substitutions can be applied to simple expressions (atoms or terms), by replacing all occurrences of the left-side variables in the expression by the corresponding terms.  = { x / g(z), y / B} p(x, f(y, z))  = p(g(z), f(B, z))  ={ x / h(g(A)), y / g(A), z / w} p(x, f(y, z))  =p(h(g(A)), f(g(A), w)) p(x, f(y, z))  = p(h(g(A)), f(g(A), w))  Examples:

6 Remember the motivation:  We want substitutions that make atoms equal. lot_maint(house(p))  big(house(p)) lot_maint(house(p))  big(house(p)) false  lot_maint(house(Bos))  The two atoms in the clauses:  must be made equal.

7 “Unifiers”  Example: S = {related(John,x), related(y, father(y))}  = {y / John, x / father(John)} is a unifier for S S  = {related(John,father(John))}  Given a set of simple expressions S, we call a substitution  a unifier for S if: S  is a singleton

8 One more refinement:  For deduction step: related(x,y)  parent(x,y) parent(John,z) parent(John,z)  we have: S = {parent(x,y), parent(John,z)}  and there are several unifiers:  = {x / John, y / z}  = {x / John, y / Mary, z / Mary} etc.  Only the most general one, , allows to derive the strongest conclusion: related(John,z)

9 Relation between these?  Example: S = {parent(x,y), parent(John,z)}  = {x / John, y / z} S  = {parent(John,z)}  = {x / John, y / Mary, z / Mary} S  = {parent(John,Mary)} There exists a third substitution:  = {z / Mary} with S  = ( S  ) 

10 Most general unifier:  Given a set of simple expressions S, a most general unifier  for S is a unifier for S, such that for all other unifiers  for S, there exists a third substitution  such that: S  = (S  )   Key-idea: create minimal instantiation changes!  Notation:  = mgu(S), or  = mgu(A, B) for S = {A,B}

11 Generalized modus ponens for Horn clauses A  B1  B2  …  Bi  …  Bn Bi’  C1  C2  …  Cm  (A  B1  B2  …  C1  C2  …  Cm  …  Bn)   Generalized modus ponens must be further extended as:  where  = mgu( Bi, Bi’)  Note: Bi and Bi’ must have the same predicate.  Correctness: due to correctness for all ground instances of this derivation.

12 Example: a few steps  Observe: we will always provide the variables with new names in order to avoid ‘accidental’ clashes of names. false  lot_maint(house(x)) lot_maint(house(y))  big(house(y)) false  big(house(y)) false  showm(z)  belg(z) showm(Bos) false  belg(Bos)  Another step, much later:

13 Backward procedure for Horn clauses Goal := false  B1  B2  …  Bn ; Repeat Select some Bi atom from the body of Goal Select some clause Bi’  C1  C2  …  Cm from Select some clause Bi’  C1  C2  …  Cm from T such that  = mgu(Bi, Bi’) exists T such that  = mgu(Bi, Bi’) exists Goal := false  (B1  …  Bi-1  C1  C2  …  Cm Goal := false  (B1  …  Bi-1  C1  C2  …  Cm  Bi+1  …  Bn)   Bi+1  …  Bn)  Until Goal = false  or no more Selections possible  Again: concrete versions of this generic scheme should allow for backtracking over previous selections,  or they should treat the problem as a general search problem through the space of derivable goals.

14 The example again: false  lot_maint(house(x)) european(x)  belg(x) rich(x)  showm(x)  european(x) big(house(x))  rich(x) lot_maint(house(x))  big(house(x)) false  lot_maint(house(x)) showm(Bos) belg(Bos) lot_maint(house(x1))  big(house(x1))  = { x1 / x} false  big(house(x))  = { x2 / x} big(house(x2))  rich(x2) false  rich(x)  = { x3 / x } rich(x3)  showm(x3)  european(x3) false  showm(x)  european(x) false  showm(x)  belg(x) european(x4)  belg(x4)  = { x4 / x } belg(Bos)  = { x / Bos } false  showm(Bos) showm(Bos)  = { } false 

15 Why rename variables? false  p(x) p(y)  q(z,y) false  q(z,y)  = {x/y } false  p(x) p(y)  q(x,y) false  q(y,y)  = {x/y }  Consider the derivation step:  Problem: p(y)  q(x,y) is equivalent with p(y)  q(z,y) so that alternatively we could perform the step:  Which gives us a strictly stronger conclusion !  Always first rename variables apart !!

16 Another example: anc(x,y)  parent(x,y) (1) anc(x,y)  parent(x,z)  anc(z,y) (2) parent(A,B) (3) parent(B,C) (4) false  anc(u,v) false  parent(x1,z1)  anc(z1,y1) (2) {u/x1,v/y1} false  anc(B,y1) (3) {x1/A,z1/B} false  parent(B,y1) (1) {x2/B,y2/y1} false  (4) {y1/C} false  parent(x1,y1) (1) {u/x1,v/y1} false  (3) {x1/A,y1/B} false  (4) {x1/B,y1/C} Several different proofs are possible !

17 Completeness:  Backward generalized modus ponens, using a complete search method to search the space of derived goals and with renaming of variables is complete.  Remark that it can only be semi-deciding, because the search space of goals may be infinitely large.  thus, in general, this cannot help us to decide whether false  is derivable.

18 An infinite derivation:  Example: nat(s(x))  nat(x) false  nat(u) false  nat(x1) {u/s(x1)} false  nat(x2) {x1/s(x2)}...

19 Using a complete search we do get an answer for:  Example: nat(0) nat(s(x))  nat(x) false  nat(u) false  nat(x1) {u/s(x1)} false  nat(x2) {x1/s(x2)}... false  {u/0}{u/0}{u/0}{u/0} {x1/0}

Unification A basic algorithm in Automated Reasoning

21 A unification algorithm :={ s = t }; mgu:= { s = t }; Stop:= false; Case: t is a variable, s is not a variable: Case: t is a variable, s is not a variable: replace s = t by t = s in mgu; replace s = t by t = s in mgu; Case: s is a variable, t is the SAME variable: Case: s is a variable, t is the SAME variable: delete s = t from mgu; delete s = t from mgu; Case: s is a variable, t is not a variable and Case: s is a variable, t is not a variable and contains s : contains s : Stop:= true; Stop:= true; While not(Stop) and mgu still contains s = t of

22 Unification algorithm (2) If Stop = false : Report mgu ! Case: s is a variable, t is not identical to nor Case: s is a variable, t is not identical to nor contains s and s occurs elsewhere in mgu: contains s and s occurs elsewhere in mgu: replace all other occurrences of s in mgu by t ; replace all other occurrences of s in mgu by t ;... Case: s is of the form f(s1,…,sn), t of g(t1,…,tm): if f  g or n  m : Stop := true; if f  g or n  m : Stop := true; else replace s = t in mgu by else replace s = t in mgu by s1 = t1, s2 = t2, …, sn = tn ; s1 = t1, s2 = t2, …, sn = tn ;End_while

23 Example 1:  Unify: p(B,y) and p(x,f(x)) :  Init: mgu:= { p(B,y) = p(x,f(x))}  Case 5: mgu:= {B = x, y = f(x) }  Case 1: mgu:= {x = B, y = f(x) }  Case 4: mgu:= {x = B, y = f(B) }  No more cases applicable !  p(B,y) and p(x,f(x)) are unifiable  mgu = { x/B, y/f(B) }  result: p(B, f(B))

24 Example 2 & 3:  Unify: p(A) and p(f(x)) :  Init: mgu:= { p(A) = p(f(x))}  Case 5: mgu:= {A = f(x) }  Case 5: Stop:= true NOT unifiable!  Unify: x and f(x) :  Init: mgu:= { x = f(x)}  Case 3: Stop:= true NOT unifiable!

25 Termination of the algorithm:  Stop = true  no unifier  expressions are not unifiable  No more cases applicable:  mgu contains a set of equalities of the form:  {x1 = t1, …, xn = tn} with  all x1,…,xn mutually distinct variables !  The substitution {x1/t1,…,xn/tn} is a most general unifier for the initial s and t.  Martelli-Montanari algorithm.  Extendable for more than 2 expressions.

26 Deducing with unification  Example: is implied: mgu = {u/point(1,z)} is implied: mgu = {u/y,v/y } vertical(segment(point(x,y),point(x,z))) horizontal(segment(point(x,y),point(z,y )))  u vertical(segment(point(1,2),u))  u,v horizontal(segment(point(1,u),point(2,v)))

27 Representation-power of Horn clauses  Most predicate logic formulae can easily be rewritten in Horn clauses.  Examples:  x cat(x)  dog(x)  pet(x)  x poodle(x)  dog(x)  small(x) pet(x)  cat(x) pet(x)  dog(x) dog(x)  poodle(x) small(x)  poodle(x)  BUT:  x human(x)  male(x)  female(x)  x dog(x)  ~abnormal(x)  has_4_legs(x) ????