CSE 415 -- (c) S. Tanimoto, 2008 Predicate Calculus II 1 Predicate Calculus 2 Outline: Unification: definitions, algorithm Formal interpretations and satisfiability.

Slides:



Advertisements
Similar presentations
Artificial Intelligence 8. The Resolution Method
Advertisements

CS4026 Formal Models of Computation Part II The Logic Model Lecture 1 – Programming in Logic.
Biointelligence Lab School of Computer Sci. & Eng.
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.
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),
Standard Logical Equivalences
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.
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.
Logic.
ARTIFICIAL INTELLIGENCE [INTELLIGENT AGENTS PARADIGM] Professor Janis Grundspenkis Riga Technical University Faculty of Computer Science and Information.
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.
Inference and Resolution for Problem Solving
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.
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.
CS1502 Formal Methods in Computer Science Lecture Notes 10 Resolution and Horn Sentences.
CSE 311 Foundations of Computing I Lecture 6 Predicate Logic, Logical Inference Spring
Prolog Programming Lecture Module 13. Objective ● What is Prolog? ● Prolog program ● Syntax of Prolog ● Prolog Control Strategy ● Execution of Prolog.
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.
Advanced Topics in FOL Chapter 18 Language, Proof and Logic.
Inference in First-Order logic Department of Computer Science & Engineering Indian Institute of Technology Kharagpur.
1 Chapter 8 Inference and Resolution for Problem Solving.
Advanced Topics in Propositional Logic Chapter 17 Language, Proof and Logic.
First Order Predicate Logic
CSE S. Tanimoto Horn Clauses and Unification 1 Horn Clauses and Unification Propositional Logic Clauses Resolution Predicate Logic Horn Clauses.
CS621: Artificial Intelligence Pushpak Bhattacharyya CSE Dept., IIT Bombay Lecture 28– Interpretation; Herbrand Interpertation 30 th Sept, 2010.
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,
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 Early AI explored how to automate 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 6 章 谓词演算中的归结. 2 Outline Unification Predicate-Calculus Resolution Completeness and Soundness Converting Arbitrary wffs to Clause Form Using Resolution.
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.
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.
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
CS201: Data Structures and Discrete Mathematics I
Horn Clauses and Unification
Horn Clauses and Unification
CSE (c) S. Tanimoto, 2004 Unification
CSE S. Tanimoto Unification
MA/CSSE 474 More Math Review Theory of Computation
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
Encoding Knowledge with First Order Predicate Logic
Encoding Knowledge with First Order Predicate Logic
CS201: Data Structures and Discrete Mathematics I
Chapter 4: Prolog (Substitution, Unification and Resolution)
Encoding Knowledge with First Order Predicate Logic
Presentation transcript:

CSE (c) S. Tanimoto, 2008 Predicate Calculus II 1 Predicate Calculus 2 Outline: Unification: definitions, algorithm Formal interpretations and satisfiability Horn clauses and PROLOG

CSE (c) S. Tanimoto, 2008 Predicate Calculus II 2 Unification Predicate calculus rules are sometimes so general that we need to create specializations of them in order to perform resolution. Suppose we have the rule If x is a working automobile, then x has an engine. P(x)  Q(x) and we have the fact Tim’s Chevy is a working automobile P(a) These cannot immediately be resolved because P(x) and P(a) don’t quite match. They must be “unified.”

CSE (c) S. Tanimoto, 2008 Predicate Calculus II 3 Modus Ponens and Resolution P  Q P Q Modus ponens is a special case of resolution:  P v Q P Q

CSE (c) S. Tanimoto, 2008 Predicate Calculus II 4 Modus Ponens in the Predicate Calculus P(a)  Q(a) P(a) Q(a) But we have P(x)  Q(x) So we create a substitution instance of it: P(a)  Q(a) using the substitution { a/x }

CSE (c) S. Tanimoto, 2008 Predicate Calculus II 5 Substitutions A substitution is a set of term/variable pairs. e.g., { a/x, f(a)/y, w/z } Each element of the set is an elementary substitution. A particular variable occurs at most once on the the right-hand side of any elementary subst. in a substitution. { a/x, b/x } is not an acceptable substitution. The empty set is an acceptable substitution. If E is a term or a formula of the predicate calculus, and S is a substitution, then S(E) is the result of applying S to E, i.e., replacing each variable of S that occurs in E by the corresponding term in S.

CSE (c) S. Tanimoto, 2008 Predicate Calculus II 6 Unifiers Given a pair of literals L1 and L2, if S is a substitution such that S(L1) = S(L2) or S(L1) =  S(L2), then S is a unifier for L1 and L2. Example: L1 =  P(x, f(a)) L2 = P(b, y) S = { b/x, f(a)/y } S(L1) =  P(b, f(a)) =  S(L2) Therefore S is a unifier for L1 and L2.

CSE (c) S. Tanimoto, 2008 Predicate Calculus II 7 The Occurs Check A unifier may not contain an elementary substitution of the form f(x)/x and may not cause an indefinite recursion. In general the term in a term/variable pair may not include that variable. P(x) and P(f(x)) cannot be unified, since f(x)/x is illegal. P(y, f(y)) and P(f(x), y) cannot be unified, since S = { f(x)/y, f(y)/x } leads to an indefinite recursion. Testing whether a variable appears in its corresponding term is called the “occurs check”. Some automated reasoning systems do not perform the occurs check in order to save time.

CSE (c) S. Tanimoto, 2008 Predicate Calculus II 8 Generality of Unifiers Some pairs of literals may have more than one possible unifier. P(x), P(y) is unified by each of { x/y }, { y/x }, { z/x, z/y }, { a/x, a/y}, { f(a)/x, f(a)/y } etc. Suppose S1 and S2 are unifiers for L1 and 12. Then S1(P1) = S1(P2) or S1(P1) = ~S1(P2) S2(P1) = S2(P2) or S2(P1) = ~S2(P2) S2 is less general than S1 if no S3 exists such that S3(S2(P1)) = S1(P1). { a/x, a/y } is less general than { y/x }.

CSE (c) S. Tanimoto, 2008 Predicate Calculus II 9 Most General Unifiers A unifier S1 for L1 and L2 is a most general unifier (MGU) for L1 and L2 provided that for any other unifier S2 of L1 and L2 there exists a substitution S3 such that S3(S1(L1)) = S2(L1). S1 = { y/x } is a most general unifier for P(x), P(y). S2 = { f(a)/x, f(a)/y } is not a MGU for P(x), P(y). S3 = { f(a)/y } S3(S1(P(x))) = P(f(a)) = S2(P(x)).

CSE (c) S. Tanimoto, 2008 Predicate Calculus II 10 Finding a Most-General Unifier 1. Given literals L1 and L2, place a cursor at the left end of each. Skip any negation sign. If the predicate symbols do not match, return NOT-UNIFIABLE. 2. Let S = { }. 3. Move the cursors right to the next term in each literal. If there are no terms left, return S as a MGU. Let t1 and t2 be the terms.

CSE (c) S. Tanimoto, 2008 Predicate Calculus II 11 Finding an MGU (Cont.) 4a. If t1 = t2, go to Step 3. 4b. Otherwise, if either t1 or t2 is a variable (call it v and call the other term t), then attempt to add t/v to S (see below). 4c. Otherwise if t1 and t2 both begin with function symbols, and these symbols are the same, move the cursors to the first argument of these symbols and go to step 4a. 4d. Otherwise, return NOT-UNIFIABLE.

CSE (c) S. Tanimoto, 2008 Predicate Calculus II 12 Finding an MGU (Cont.) When trying to add t/v to S, apply { t/v } to each term in S. If this results in any elementary substitution whose term includes its variable, return NOT- UNIFIABLE. Otherwise, replace each elementary substitution in S by the result of applying { t/v } and add t/v itself to S.

CSE (c) S. Tanimoto, 2008 Predicate Calculus II 13 Example L1: P(a, f(x, a)) L2: P(a, f(g(y), y)) S: { } S: { g(y)/x } S: { g(a)/x, a/y }

CSE (c) S. Tanimoto, 2008 Predicate Calculus II 14 Logical Inferences Per Second LIPS are sometimes used to describe the performance of a logical reasoning system. Can mean the number of successful unification operations per second. 1 successful unification  1 successful resolution step. Note: some unifiers are trivial to compute, yet there is no upper bound on the size of a unifier. Also, discovering that two literals are not unifiable can be arbitrarily costly.

CSE (c) S. Tanimoto, 2008 Predicate Calculus II 15 Formal Interpretations An interpretation for a given formula W consists of the following: A domain D of elements that can be referred to by terms. E.g., D = (0, 1, 2,... } An assignment that maps each constant symbol of W to an element of D. For each n-ary function symbol of W a mapping from n-tuples of elements of D to single elements of D. For each n-ary predicate symbol of W a mapping from n- tuples of elements of D to {T, F}.

CSE (c) S. Tanimoto, 2008 Predicate Calculus II 16 Example of Interpretation Let W = (  x) (P(a)  Q(x, a) ) An interpretation for W : D = { apple, peach } { a = apple } mapping for constants { } mappings for functions { P(apple) = T, P(peach) = T; mappings for predicates Q(apple,apple) = T, Q(apple, peach) = T, Q(peach,apple) = T, Q(peach, peach) = T }

CSE (c) S. Tanimoto, 2008 Predicate Calculus II 17 Satisfiability and Models A formula W is satisfiable iff there exists some interpretation of W that make W true. A formula W is unsatisfiable iff there does NOT exist any interpretation of W that make W true. Then W is inconsistent. W is a contradiction. If every interpretation of W satisfies W (makes W true), then W is a tautology. If I is an interpretation for W that satisfies W, then I is a model for W.

CSE (c) S. Tanimoto, 2008 Predicate Calculus II 18 Another Interpretation Let W = (  x) (P(a)  Q(x, a) ) An interpretation for W : D = { 0, 1, 2,... } { a = 0 } mapping for constants { } mappings for functions { P(n) iff n = 0; mappings for predicates Q(m,n) iff n > m. } Note that  Q(x, x). This interpretation fails to satisfy W. It’s not a model for W.

CSE (c) S. Tanimoto, 2008 Predicate Calculus II 19 The Basis of Proof by Resolution Resolution is used to prove that a given set of clauses is inconsistent. (i.e., it cannot have a model). Each time a resolvent is formed, it is added to the set of clauses. This does not change the consistency of the set. However, if the null clause is ever added to the set, then it becomes very obvious that the set is inconsistent.

CSE (c) S. Tanimoto, 2008 Predicate Calculus II 20 Horn Clauses: The basis for Logic Programming Examples of Horn clauses: P P V  Q  Q  Q V  R P V  Q V  R  P V  Q V  R [] A Horn clause is a clause in which at most one literal is unnegated Examples of non-Horn clauses: P V Q P V ~Q V R

CSE (c) S. Tanimoto, 2008 Predicate Calculus II 21 Horn Clauses: Goal-oriented form P V  Q V  RStandard mathematical form (Q  R)  PEquivalent conditional form P  (Q V R)Goal-oriented form p :- q, r.Edinburgh PROLOG syntax head :- body. goal :- subgoal1, subgoal2,..., subgoalN.

CSE (c) S. Tanimoto, 2008 Predicate Calculus II 22 Prolog: Horn Clauses + Resolution + Backward Chaining grandparent(X, Y) :- parent(X, Z), parent(Z, Y). parent(X, Y) :- father(X, Y). parent(X, Y) :- mother(X, Y). father(abe, bev). mother(bev, carl). mother(bev, mary). ?- grandmother(A, B). A = abe, B = carl; A = abe, B = mary; no