Chapter 4: Prolog (Substitution, Unification and Resolution)

Slides:



Advertisements
Similar presentations
Resolution Proof System for First Order Logic
Advertisements

SLD-resolution Introduction Most general unifiers SLD-resolution
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.
ARTIFICIAL INTELLIGENCE [INTELLIGENT AGENTS PARADIGM] Professor Janis Grundspenkis Riga Technical University Faculty of Computer Science and Information.
Computability and Complexity 9-1 Computability and Complexity Andrei Bulatov Logic Reminder (Cnt’d)
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
September 24, 2009Theory of Computation Lecture 6: Primitive Recursive Functions II 1 Homework Questions Question 1: Write a program P that computes 
CSE (c) S. Tanimoto, 2007 Unification 1 Unification Predicate calculus rules are sometimes so general that we need to create specializations of.
CSE (c) S. Tanimoto, 2005 Logic Programming 1 Logic Programming Outline: Motivation Examples: The Grandmother relation Formulation in Prolog Logic,
Logic Programming Part 2: Semantics James Cheney CS 411.
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.
Software Verification 1 Deductive Verification Prof. Dr. Holger Schlingloff Institut für Informatik der Humboldt Universität und Fraunhofer Institut.
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
First Order Predicate Logic
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,
Unification We can represent any substitution by a set of ordered pairs: s = { t 1 /v 1, t 2 /v 2, …, t n /v n } where: t i /v i means that the term i.
Automated Reasoning Early AI explored how to automated several reasoning tasks – these were solved by what we might call weak problem solving methods as.
Web Science & Technologies University of Koblenz ▪ Landau, Germany Procedural Semantics Soundness of SLD-Resolution.
3 DERIVATIVES.  Remember, they are valid only when x is measured in radians.  For more details see Chapter 3, Section 4 or the PowerPoint file Chapter3_Sec4.ppt.
Natural Deduction for Predicate Logic Bound Variable: A variable within the scope of a quantifier. – (x) Px – (  y) (Zy · Uy) – (z) (Mz  ~Nz) Free Variable:
Discrete Mathematics CS 2610 August 22, Agenda Last class Propositional logic Logical equivalences This week Predicate logic & rules of inference.
The Law of Resolution Formal Aspects of Computer Science - Week 7 The Law of Resolution Lee McCluskey, room 2/07
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.
General resolution Method1 General Resolution method in FOL Lesson 8.
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)
Section 1.5 and 1.6 Predicates and Quantifiers. Vocabulary Predicate Domain Universal Quantifier Existential Quantifier Counterexample Free variable Bound.
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.
CPSC 433 Artificial Intelligence Unification & Resolution Examples Andrew Kuipers Please include [CPSC433] in the subject line.
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.
CSE (c) S. Tanimoto, 2001 Logic Programming
Introduction to Logic for Artificial Intelligence Lecture 2
CSE 341, S. Tanimoto Logic Programming -
Horn Clauses and Unification
General Resolution method in FOL
Prolog syntax + Unification
Unification Algorithm ChuChen
Soundness of SLD-Resolution
1st-order Predicate Logic (FOL)
Horn Clauses and Unification
Horn Clauses and Unification
CSE (c) S. Tanimoto, 2004 Unification
CSE S. Tanimoto Unification
Horn Clauses and Unification
CSE (c) S. Tanimoto, 2002 Unification
CSE (c) S. Tanimoto, 2004 Logic Programming
CSE (c) S. Tanimoto, 2002 Logic Programming
Horn Clauses and Unification
Chapter 1: Propositional and First-Order Logic
Encoding Knowledge with First Order Predicate Logic
Encoding Knowledge with First Order Predicate Logic
RESOLUTION.
Encoding Knowledge with First Order Predicate Logic
Resolution Proof System for First Order Logic
Soundness of SLD-Resolution
Resolution Preliminaries
Proofs (2.7) (How to compute logical consequences of a KB rather that
Logical Inference 4 wrap up
1st-order Predicate Logic (FOL)
Presentation transcript:

Chapter 4: Prolog (Substitution, Unification and Resolution) DM552: Part 2 Programing Logic Chapter 4: Prolog (Substitution, Unification and Resolution) Dr Youcef Djenouri djenouri@imada.sdu.dk 2017-2018

Substitution: Definition (1/2) Substitution θ is an operation allowing to replace some variables occurring in a formula with terms. The goal of applying a substitution is to make a certain formula more specific so that it matches another formula. Substitutions allow for unification of formulae (or terms).

Substitution: Definition (2/2) A substitution is any finite mapping of variables into terms of the form: θ: V ⇒ TER Any (finite) substitution θ can be presented as θ={t1/X1, t2/X2… tn/Xn} ti is the term to be substituted for a variable Xi, i= 1…n. No two elements in the set have the same variable after the / symbol,

Substitution: Example { y/X, f(y)/Z } is a substitution. { a/Y, b/X} is a substitution. {a/X, b/X} is not a substitution. {X/f(Y)} is not a substitution.

Instance (1/2) Let θ ={t1/X1, t2/X2… tn/Xn} be a substitution and let E be an expression. Then Eθ is an expression obtained by replacing all occurrences of every vi in E with the corresponding term ti, Eθ is an instance of E.

Instance (2/2) θ ={ a/X, f(b)/Y, c/Z} , E=P(X, Y, Z) Eθ= P(a, f(b), c) is an instance of E. θ ={f(f(a))/X, X/Y} , E=(P(X ) ∨ Q(Y)) Eθ= (P(f(f(a))) ∨ Q(X)) is an instance of E. θ ={ Y/X, a/Y} , E=(P(X ) ∨ Q(Y)) Eθ= (P(Y) ∨ Q(a)) is an instance of E.

Composition of substitutions Let θ= {t1/X1, t2/X2… tn/Xn} and Γ={u1/Y1, u2/Y2… um/Ym} be two substitutions. The composition of θ and Γ is denoted by θ o Γ, and it is obtained by building the set {t1 Γ /X1, t2 Γ /X2… tn Γ /Xn, u1/Y1, u2/Y2… um/Ym} Remove the following elements: tj Γ/ Xj such that tj Γ = Xj ui/ Yj such that Yj is in {X1, X2… Xn}

Example θ= {t1/X1, t2/X2}= {f(Y)/X, Z/Y} Γ={u1/Y1, u2/Y2,u3/Y3}= {a/X, b/Y, Y/Z} {t1 Γ /X1, t2 Γ /X2, u1/Y1, u2/Y2,u3/Y3}={f(b)/X, Y/Y, a/X, b/Y, Y/Z} θ o Γ ={f(b)/X, Y/Z}

Classwork Consider θ = {f(Y)/X} and µ = {f(Z)/Y} Compute θ o µ and µ o θ ?

Unification A substitution θ is called a unifier for a set {E1…Ek} if and only if: E1θ =E2θ = E3θ =…= Ekθ The set {E1…Ek} is unifiable if and only if there exists a unifier for it. A unifier θ is a most general unifier for a set {E1…Ek} if and only if for each unifier Γ there exisits a substitution μ such that Γ= θ o μ.

θ o μ= {f(f(Z))/X, f(Z)/Y}= Γ Example E1=P(X), E2= P(f(Y)) are unifiable by Γ={f(f(Z))/X, f(Z)/Y} E1 Γ = E2 Γ = P(f(f(Z))). θ= {f(Y)/X} is a most general unifier, we can find μ ={f(Z)/Y} such that θ o μ= {f(f(Z))/X, f(Z)/Y}= Γ

Classwork Prove that the following expressions are all unifiers by θ = {f(b)/X, b/Y, u/Z} E = f(X, b, g(Z)). F = f(f(Y), Y, g(u)).

Resolution: Used to prove a consequence from a set of logical formulae States: Sets of clauses L1 …  Lm Initially: The consequence we want to prove is negated and added to the set of clauses representing the initial state Goal: Derive the empty clause ()

Example (1/6) ¬P(X)  P(f(X)) ¬Q(a, Y)  ¬R(Y, X)  P(X) R(b, g(a, Z)) Q(a, b) Goal: P(f(g(a, c)))

Example (2/6) Negate goal, add to formulas 1. ¬P(X)  P(f(X)) 2. ¬Q(a, Y)  ¬R(Y, X)  P(X) 3. R(b, g(a, Z)) 4. Q(a, b) 5. ¬P(f(g(a, c)))

Example (3/6) Resolve (4) and (2) by applying {b/Y} 1. ¬P(X)  P(f(X)) 2. ¬Q(a, Y)  ¬R(Y, X)  P(X) 3. R(b, g(a, Z)) 4. Q(a, b) 5. ¬P(f(g(a, c))) ¬R(b, X)  P(X)

Example (4/6) Resolve (6) and (3) by applying {g(a,Z)/X} 1. ¬P(X)  P(f(X)) 2. ¬Q(a, Y)  ¬R(Y, X)  P(X) 3. R(b, g(a, Z)) 4. Q(a, b) 5. ¬P(f(g(a, c))) 6. ¬R(b, X)  P(X) P(X)

Example (5/6) Resolve (7) and (1) by applying {g(a,Z)/X} 1. ¬P(X)  P(f(X)) 2. ¬Q(a, Y)  ¬R(Y, X)  P(X) 3. R(b, g(a, Z)) 4. Q(a, b) 5. ¬P(f(g(a, c))) 6. ¬R(b, X)  P(X) 7. P(g(a, Z)) P(f(X))

□ Example (6/6) Resolve (8) and (5) by applying {g(a,c)/ X} 1. ¬P(X)  P(f(X)) 2. ¬Q(a, Y)  ¬R(Y, X)  P(X) 3. R(b, g(a, Z)) 4. Q(a, b) 5. ¬P(f(g(a, c))) 6. ¬R(b, X)  P(X) 7. P(g(a, Z)) 8. P(f(X)) □

SLDTree Facts: grand_father(jacob, X) father(john, merry). father(jacob, jones). father(jones, sylia). father(jacob, Z), father(Z, X ) father(jacob, Z), mother(Z, X) mother(sylia, anes). mother(merry, relly). Rules: father(jacob, jones), father(jones, X) Exit grand_father (X, Y) :-father(X, Z), father(Z, Y). grand_father(X, Y) :-father(X, Z), mother(Z, Y). Question: grand_father(jacob, X) father(jacob, jones), father(jones, sylia)