Inference in First-Order Logic

Similar documents
Objectives. Logical Reasoning Systems. Proofs. Outline. Example proof. Example proof. You should

Inference in first-order logic

Syntax of FOL: Basic elements

Inference in first-order logic

CS 561: Artificial Intelligence

Inference in First-Order Logic

CS 771 Artificial Intelligence. First Order Logic Inference

7.5.2 Proof by Resolution

Inference Methods In Propositional Logic

Outline. Reducing first-order inference to propositional inference Unification. Forward chaining Backward chaining

Introduction to Artificial Intelligence 2 nd semester 2016/2017. Chapter 9: Inference in First-Order Logic

Inference Methods In Propositional Logic

Inference in first-order logic

Inference in first-order logic

Knowledge base (KB) = set of sentences in a formal language Declarative approach to building an agent (or other system):

Inf2D 11: Unification and Generalised Modus Ponens

Inference in first-order logic

Artificial Intelligence Chapter 9: Inference in First-Order Logic

Logical Inference. Artificial Intelligence. Topic 12. Reading: Russell and Norvig, Chapter 7, Section 5

Set 8: Inference in First-order logic. ICS 271 Fall 2013 Chapter 9: Russell and Norvig

Inference in first-order logic

Set 8: Inference in First-order logic. ICS 271 Fall 2017 Chapter 9: Russell and Norvig

Chapter 7 R&N ICS 271 Fall 2017 Kalev Kask

Title: Logical Agents AIMA: Chapter 7 (Sections 7.4 and 7.5)

Inference in first-order logic

CSC242: Intro to AI. Lecture 13. Thursday, February 28, 13

CS 380: ARTIFICIAL INTELLIGENCE

Inference in first-order logic

Logical Agents. Chapter 7

Intelligent Agents. Pınar Yolum Utrecht University

Artificial Intelligence Chapter 7: Logical Agents

Inference in first-order logic

COMP9414: Artificial Intelligence Propositional Logic: Automated Reasoning

Proof Methods for Propositional Logic

CS 380: ARTIFICIAL INTELLIGENCE PREDICATE LOGICS. Santiago Ontañón

Outline. Inference in first- order logic: just a taste. Universal instan8a8on (UI) Inference with Quan8fiers. Reduc8on to proposi8onal inference

CS 730/730W/830: Intro AI

Propositional Logic: Methods of Proof (Part II)

Artificial Intelligence

Logical Agent & Propositional Logic

EE562 ARTIFICIAL INTELLIGENCE FOR ENGINEERS

Propositional Logic: Methods of Proof (Part II)

Logical Inference 2 rule based reasoning

Inf2D 13: Resolution-Based Inference

CSC242: Intro to AI. Lecture 11. Tuesday, February 26, 13

The Wumpus Game. Stench Gold. Start. Cao Hoang Tru CSE Faculty - HCMUT

Propositional Logic: Methods of Proof. Chapter 7, Part II

The only sets are the empty set and those made by adjoining something to a set: s: Set(s) s = Ø x, s 2 : Set(s 2 ) s = { x s 2 }.

Deliberative Agents Knowledge Representation I. Deliberative Agents

Guest Speaker. CS 416 Artificial Intelligence. First-order logic. Diagnostic Rules. Causal Rules. Causal Rules. Page 1

First-Order Logic. Peter Antal

Artificial Intelligence

[1] Describe with examples, the three inference rules involving quantifiers

Logical Agent & Propositional Logic

Lecture 10: Even more on predicate logic" Prerequisites for lifted inference: Skolemization and Unification" Inference in predicate logic"

Deductive Systems. Lecture - 3

Outline. First-order logic. Atomic sentences. Intelligent Systems and HCI D7023E. Syntax of FOL: Basic elements. Pros and cons of propositional logic

7. Logical Agents. COMP9414/ 9814/ 3411: Artificial Intelligence. Outline. Knowledge base. Models and Planning. Russell & Norvig, Chapter 7.

CS 730/830: Intro AI. 3 handouts: slides, asst 6, asst 7. Wheeler Ruml (UNH) Lecture 12, CS / 16. Reasoning.

Inference in first-order logic

CSCI-495 Artificial Intelligence. Lecture 17

Inference in Propositional Logic

Propositional Reasoning

CS:4420 Artificial Intelligence

First Order Logic (FOL) and Inference

EE562 ARTIFICIAL INTELLIGENCE FOR ENGINEERS

Logic in AI Chapter 7. Mausam (Based on slides of Dan Weld, Stuart Russell, Subbarao Kambhampati, Dieter Fox, Henry Kautz )


Logical agents. Chapter 7. Chapter 7 1

Logic. Introduction to Artificial Intelligence CS/ECE 348 Lecture 11 September 27, 2001

Artificial Intelligence

CS 771 Artificial Intelligence. Propositional Logic

Logic and Inferences

Knowledge based Agents

Outline. Logical Agents. Logical Reasoning. Knowledge Representation. Logical reasoning Propositional Logic Wumpus World Inference

Advanced Topics in LP and FP

Resolution (14A) Young W. Lim 8/15/14

Inference in first-order logic

Revised by Hankui Zhuo, March 21, Logical agents. Chapter 7. Chapter 7 1

CS 520: Introduction to Artificial Intelligence. Review

Propositional Logic. Logic. Propositional Logic Syntax. Propositional Logic

Logical agents. Chapter 7. Chapter 7 1

Rational Agents. Paolo Turrini. Introduction to Artificial Intelligence 2nd Part. Department of Computing, Imperial College London

COMP9414: Artificial Intelligence First-Order Logic

Propositional Logic: Review

TDT4136 Logic and Reasoning Systems

Logical Agents (I) Instructor: Tsung-Che Chiang

Rules Build Arguments Rules Building Arguments

Outline. Logical Agents. Logical Reasoning. Knowledge Representation. Logical reasoning Propositional Logic Wumpus World Inference

Inference in First Order Logic

Resolution: Motivation

AI Programming CS S-09 Knowledge Representation

Propositional Logic: Methods of Proof (Part II)

KE/Tableaux. What is it for?

Propositional inference, propositional agents

INF5390 Kunstig intelligens. Logical Agents. Roar Fjellheim

Logical Inference and Reasoning Agents. Foundations of Artificial Intelligence

Logical Agents: Propositional Logic. Chapter 7

Logic. Knowledge Representation & Reasoning Mechanisms. Logic. Propositional Logic Predicate Logic (predicate Calculus) Automated Reasoning

Propositional Resolution

Transcription:

Inference in First-Order Logic Dr. Richard J. Povinelli rev 1.0, 10/7/2001 Page 1

Objectives You should! be able to analyze and employ logical inference in first-order logic. rev 1.0, 10/7/2001 Page 2

Outline Reducing first-order inference to propositional inference Unification Generalized Modus Ponens Forward and backward chaining Logic programming Resolution rev 1.0, 10/7/2001 AIMA Slides Stuart Russell and Peter Norvig, 1998 Page 3

A brief history of reasoning 450B.C. Stoics: propositional logic, inference (maybe) 322B.C. Aristotle: syllogisms (inference rules), quantifiers 1565 Cardano: probability theory (propositional logic + uncertainty) 1847 Boole: propositional logic (again) 1879 Frege: first-order logic 1922 Wittgenstein: proof by truth tables 1930 Gödel: complete algorithm for FOL 1930 Herbrand complete algorithm for FOL (reduce to propositional) 1931 Gödel: complete algorithm for arithmetic 1960 Davis/Putnam practical algorithm for propositional logic 1965 Robinson: practical algorithm for FOL resolution rev 1.0, 10/7/2001 AIMA Slides Stuart Russell and Peter Norvig, 1998 Page 4

Proofs Sound inference: find α such that KB = α. Proof process is a search, operators are inference rules. Modus Ponens (MP) And-Introduction (AI) Universal Elimination (UE) τ must be a ground term (i.e., no variables) rev 1.0, 10/7/2001 AIMA Slides Stuart Russell and Peter Norvig, 1998 Page 5

Example proof Bob is a buffalo Pat is a pig Buffaloes outrun pigs Prove:Bob outruns Pat 1. Buffalo(Bob) 2. Pig(Pat) 3. x, y Buffalo(x) Pig(y) Faster(x,y) rev 1.0, 10/7/2001 AIMA Slides Stuart Russell and Peter Norvig, 1998 Page 6

Example proof Bob is a buffalo Pat is a pig Buffaloes outrun pigs Prove:Bob outruns Pat AI 1 & 2 1. Buffalo(Bob) 2. Pig(Pat) 3. x, y Buffalo(x) Pig(y) Faster(x,y) 4. Buffalo(Bob) Pig(Pat) rev 1.0, 10/7/2001 AIMA Slides Stuart Russell and Peter Norvig, 1998 Page 7

Example proof Bob is a buffalo Pat is a pig Buffaloes outrun pigs Prove:Bob outruns Pat AI 1 & 2 UE 3, {x/bob, y/pat} 1. Buffalo(Bob) 2. Pig(Pat) 3. x, y Buffalo(x) Pig(y) Faster(x,y) 4. Buffalo(Bob) Pig(Pat) 5. Buffalo(Bob) Pig(Pat) Faster(Bob, Pat) rev 1.0, 10/7/2001 AIMA Slides Stuart Russell and Peter Norvig, 1998 Page 8

Example proof Bob is a buffalo Pat is a pig Buffaloes outrun pigs Prove:Bob outruns Pat AI 1 & 2 UE 3, {x/bob, y/pat} MP 4 & 5 1. Buffalo(Bob) 2. Pig(Pat) 3. x, y Buffalo(x) Pig(y) Faster(x,y) 4. Buffalo(Bob) Pig(Pat) 5. Buffalo(Bob) Pig(Pat) Faster(Bob, Pat) 6. Faster(Bob,Pat) rev 1.0, 10/7/2001 AIMA Slides Stuart Russell and Peter Norvig, 1998 Page 9

CAT Prove It Given! 1. Giraffe(Tom)! 2. Lion(Fred)! 3. x, y Giraffe(x) Lion(y) Taller(x,y) Prove that Tom is bigger than Fred Work with a partner for 5 minutes. rev 1.0, 10/7/2001 Page 10

Universal instantiation (UI) Every instantiation of a universally quantified sentence is entailed by it: α Subst ({ v g}, α ) for any variable v and ground term g ( ) ( ) ( ) E. g., x King x Greedy x Evil x yields ( ) ( ) ( ) ( ) ( ) ( ) ( ( )) ( ( )) ( ( )) King John Greedy John Evil John King Richard Greedy Richard Evil Richard King Father John Greedy Father John Evil Father John rev 1.0, 10/7/2001 Page 11

Existential instantiation (EI) For any sentence α, variable v, and constant symbol k that does not appear elsewhere in the knowledge base: v α Subst E. g., x Crown x OnHead x, John yields y ( ) ({ v k }, α ) ( ) ( ) ( ) (, ) Crown C OnHead C John y ( ) y Another example: from x d x dy = x we obtain d e dy = e 1 1 provided C is a new constant symbol, called a Skolem constant 1 y provided e is a new constant symbol rev 1.0, 10/7/2001 Page 12

Existential instantiation cont. UI can be applied several times to add new sentences; the new KB is logically equivalent to the old EI can be applied once to replace the existential sentence; the new KB is not equivalent to the old, but is satisfiable iff the old KB was satisfiable rev 1.0, 10/7/2001 Page 13

Reduction to propositional inference Suppose the KB contains just the following: x King ( x ) Greedy ( x ) Evil ( x ) King ( John ) Greedy ( John ) Brother ( Richard, John ) Instantiating the universal sentence in all possible ways, we have King ( John ) Greedy ( John ) Evil ( John ) King ( Richard ) Greedy ( Richard ) Evil ( Richard ) King ( John ) Greedy ( John ) Brother ( Richard, John ) The new KB is propositionalized: proposition symbols are King ( John ), Greedy ( John ), Evil ( John ), King ( Richard ),etc. rev 1.0, 10/7/2001 Page 14

Reduction cont. Claim: a ground sentence* is entailed by new KB iff entailed by original KB Claim: every FOL KB can be propositionalized so as to preserve entailment Idea: propositionalize KB and query, apply resolution, return result Problem: with function symbols, there are infinitely many ground terms,! e.g., Father(Father(Father(John))) Theorem: Herbrand (1930). If a sentence α is entailed by an FOL KB, it is entailed by a finite subset of the propositional KB Idea: For n = 0 to do! create a propositional KB by instantiating with depth-n terms! see if α is entailed by this KB Problem: works if α is entailed, loops if α is not entailed Theorem: Turing (1936), Church (1936), entailment in FOL is semidecidable rev 1.0, 10/7/2001 Page 15

Problems with propositionalization Propositionalization seems to generate lots of irrelevant sentences. E.g., from ( ) ( ) ( ) ( ) ( ) (, ) x King x Greedy x Evil x King John y Greedy y Brother Richard John it seems obvious that Evil(John), but propositionalization produces lots of facts such as Greedy(Richard) that are irrelevant With p k-ary predicates and n constants, there are pn k instantiations! rev 1.0, 10/7/2001 Page 16

Search with primitive inference rules Operators are inference rules States are sets of sentences Goal test checks state to see if it contains query sentence AI, UE, MP is a common inference pattern Problem: branching factor huge, esp. for UE Idea: find a substitution that makes the rule premise match some known facts a single, more powerful inference rule rev 1.0, 10/7/2001 AIMA Slides Stuart Russell and Peter Norvig, 1998 Page 17

Unification A substitution σ unifies atomic sentences p and q if pσ = qσ p Knows(John, x) Knows (John, x) Knows (John, x) q Knows (John, Jane) Knows (y, OJ) Knows (y, Mother(y)) σ rev 1.0, 10/7/2001 AIMA Slides Stuart Russell and Peter Norvig, 1998 Page 18

Unification A substitution σ unifies atomic sentences p and q if pσ = qσ p Knows(John, x) Knows (John, x) Knows (John, x) q Knows (John, Jane) Knows (y, OJ) Knows (y, Mother(y)) σ {x/jane} {x/john; y/oj } {y/john;x/mother(john)} Idea: Unify rule premises with known facts, apply unifier to conclusion Example: if we know q and Knows(John, x) Likes(John, x) then we conclude! Likes(John, Jane)! Likes(John, OJ)! Likes(John, Mother(John)) rev 1.0, 10/7/2001 AIMA Slides Stuart Russell and Peter Norvig, 1998 Page 19

Generalized Modus Ponens (GMP) Example! p 1 = Faster(Bob,Pat)! p 2 = Faster(Pat,Steve) ( ) p 1, p2,, pn, p1 p2 pn q q, θ! p 1 p 2 q = Faster(x, y) Faster(y, z) Faster(x, z)! σ = {x/bob, y/pat, z/steve}! qσ = Faster(Bob, Steve) GMP used with KB of definite clauses (exactly one positive literal): either a single atomic sentence or (conjunction of atomic sentences) (atomic sentence) All variables assumed universally quantified where p θ = pθ for all i i i rev 1.0, 10/7/2001 AIMA Slides Stuart Russell and Peter Norvig, 1998 Page 20

Soundness of GMP Need to show that! p 1,, p n, (p 1 p n q)! qθ! provided that p i σ = p i σ for all i Lemma: For any definite clause p, we have p! pθ by UE 1. (p 1 p n q)! (p 1 p n q)θ = (p 1 θ p n θ) qθ ) 2. p 1,, p n! p 1 p n! p 1 θ p n θ 3. From 1 and 2, qθ follows by simple MP rev 1.0, 10/7/2001 AIMA Slides Stuart Russell and Peter Norvig, 1998 Page 21

Forward chaining When a new fact p is added to the KB! for each rule such that p unifies with a premise " if the other premises are known " then add the conclusion to the KB and continue chaining Forward chaining is data-driven! inferring properties and categories from percepts rev 1.0, 10/7/2001 AIMA Slides Stuart Russell and Peter Norvig, 1998 Page 22

Forward chaining example Add facts 1, 2, 3, 4, 5, 7 in turn. Number in [] = unification literal; indicates rule firing 1. Buffalo(x) Pig(y) Faster(x, y) 2. Pig(y) Slug(z) Faster(y, z) 3. Faster(x, y) Faster(y, z) Faster(x, z) 4. Buffalo(Bob) [1a, ] 5. Pig(Pat) [1b, ], [2a, ] 6. Faster(Bob, Pat) [3a, ], [3b, ] 7. Slug(Steve) [2b, ] 8. Faster(Pat, Steve) [3a, ], [3b, ] 9. Faster(Bob, Steve) [3a, ], [3b, ] rev 1.0, 10/7/2001 AIMA Slides Stuart Russell and Peter Norvig, 1998 Page 23

Backward chaining When a query q is asked! if a matching fact q is known, return the unifier! for each rule whose consequent q matches q attempt to prove each premise of the rule by backward chaining Some added complications in keeping track of the unifiers More complications help to avoid infinite loops Two versions: find any solution, find all solutions Backward chaining is the basis for logic programming, e.g., Prolog rev 1.0, 10/7/2001 AIMA Slides Stuart Russell and Peter Norvig, 1998 Page 24

Backward chaining example 1. Pig(y) Slug(z) Faster(y, z) 2. Slimy(z) Creeps(z) Slug(z) 3. Pig(Pat) 4. Slimy(Steve) 5. Creeps(Steve) rev 1.0, 10/7/2001 AIMA Slides Stuart Russell and Peter Norvig, 1998 Page 25

Completeness in FOL Procedure i is complete if and only if! KB - i α whenever KB! α Forward and backward chaining are complete for Horn KBs, but incomplete for general first-order logic Example from! PhD(x) HighlyQualified(x)! PhD(x) EarlyEarnings(x)! HighlyQualified(x) Rich(x)! EarlyEarnings(x) Rich(x) should be able to infer Rich(Me) rev 1.0, 10/7/2001 AIMA Slides Stuart Russell and Peter Norvig, 1998 Page 26

CAT Infer Rich(Me) Given! PhD(x) HighlyQualified(x)! PhD(x) EarlyEarnings(x)! HighlyQualified(x) Rich(x)! EarlyEarnings(x) Rich(x) Infer Rich(Me) using forward and backward chaining Work with a partner for 5 minutes. rev 1.0, 10/7/2001 Page 27

Completeness in FOL Were you able to infer Rich(Me)? Does a complete algorithm exist? rev 1.0, 10/7/2001 Page 28

Resolution Entailment in first-order logic is only semidecidable:! can find a proof of α if KB = α! cannot always prove that KB α Cf. Halting Problem: proof procedure may be about to terminate with success or failure, or may go on for ever Resolution is a refutation procedure:! to prove KB = ff, show that KB α is unsatisfiable Resolution uses KB, α in CNF (conjunction of clauses) Resolution inference rule combines two clauses to make a new one: Inference continues until an empty clause is derived (contradiction) rev 1.0, 10/7/2001 AIMA Slides Stuart Russell and Peter Norvig, 1998 Page 29

Resolution inference rule Basic propositional version: Full first-order version: For example rev 1.0, 10/7/2001 AIMA Slides Stuart Russell and Peter Norvig, 1998 Page 30

Conjunctive Normal Form Literal = (possibly negated) atomic sentence, e.g., Rich(Me) Clause = disjunction of literals, e.g., Rich(Me) Unhappy(Me) The KB is a conjunction of clauses Any FOL KB can be converted to CNF as follows: 1. Replace P Q by P Q 2. Move inwards, e.g., x P becomes x P 3. Standardize variables apart, e.g., x P x Q becomes x P y Q 4. Move quantifiers left in order, e.g., x P y Q becomes x y P Q 5. Eliminate by Skolemization (next slide) 6. Drop universal quantifiers 7. Distribute over e.g., (P Q) R becomes (P Q) (P R) rev 1.0, 10/7/2001 AIMA Slides Stuart Russell and Peter Norvig, 1998 Page 31

Skolemization x Rich(x) becomes Rich(G1) where G1 is a new Skolem constant More tricky when is inside Example Everyone has a heart x Person(x ) y Heart(y) Has(x, y) Incorrect:! x Person(x ) Heart(H1) Has(x, H1) Correct:! x Person(x ) Heart(H (x)) Has(x, H (x))! where H is a new symbol ( Skolem function ) Skolem function arguments: all enclosing universally quantified variables rev 1.0, 10/7/2001 AIMA Slides Stuart Russell and Peter Norvig, 1998 Page 32

Resolution proof To prove α:! negate it! convert to CNF! add to CNF KB! infer contradiction Example: to prove Rich(me), add Rich(me) to the CNF KB! PhD(x) HighlyQualified(x)! PhD(x) EarlyEarnings(x)! HighlyQualified(x) Rich(x)! EarlyEarnings(x) Rich(x) rev 1.0, 10/7/2001 AIMA Slides Stuart Russell and Peter Norvig, 1998 Page 33

Resolution proof rev 1.0, 10/7/2001 AIMA Slides Stuart Russell and Peter Norvig, 1998 Page 34