Cooperating Intelligent Systems Inference in first-order logic Chapter 9, AIMA.

Slides:



Advertisements
Similar presentations
Inference in First-Order Logic
Advertisements

First-Order Logic.
Inference Rules Universal Instantiation Existential Generalization
Inference in first-order logic Chapter 9. Outline Reducing first-order inference to propositional inference Unification Generalized Modus Ponens Forward.
We have seen that we can use Generalized Modus Ponens (GMP) combined with search to see if a fact is entailed from a Knowledge Base. Unfortunately, there.
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.
1 Resolution in First Order Logic CS 171/271 (Chapter 9, continued) Some text and images in these slides were drawn from Russel & Norvig’s published material.
Inference in FOL All rules of inference for propositional logic apply to first-order logic We just need to reduce FOL sentences to PL sentences by instantiating.
First-Order Logic Inference
1 FOL CS 331/531 Dr M M Awais Unification “It is an algorithm for determining the substitutions needed to make two predicate calculus expressions match”
1 FOL Resolution based Inferencing Resolution based rules studied earlier can lead to inferences, rules such as modus ponen, unit resolution etc… Other.
CSCE 580 Artificial Intelligence Ch.9: Inference in First-Order Logic
Inference in FOL Copyright, 1996 © Dale Carnegie & Associates, Inc. Chapter 9 Spring 2004.
Cooperating Intelligent Systems Inference in first-order logic Chapter 9, AIMA.
Inference in FOL Copyright, 1996 © Dale Carnegie & Associates, Inc. Chapter 9.
Inference in first-order logic Chapter 9. Outline Reducing first-order inference to propositional inference Unification Generalized Modus Ponens Forward.
Inference in First-Order Logic
1 CS 4700: Foundations of Artificial Intelligence Carla P. Gomes Module: FOL Inference (Reading R&N: Chapter 8)
Cooperating Intelligent Systems Inference in first-order logic Chapter 9, AIMA.
Inference in FOL Copyright, 1996 © Dale Carnegie & Associates, Inc. Chapter 9 Fall 2004.
Inference in FOL Copyright, 1996 © Dale Carnegie & Associates, Inc. Chapter 9 Spring 2005.
Start with atomic sentences in the KB and apply Modus Ponens, adding new atomic sentences, until “done”.
Inference in First-Order Logic Inference Rules with Quantifiers The three new inference rules are as follows: Universal Elimination: For any sentence ,
1 Inference in First-Order Logic. 2 Outline Reducing first-order inference to propositional inference Unification Generalized Modus Ponens Forward chaining.
Predicate Logic or FOL Chapter 8. Syntax See text for formal rules. All of propositional + quantifiers, predicates, functions, and constants. Variables.
CHAPTER 9 Oliver Schulte Inference in First-Order Logic.
Inference in First-Order Logic CS 271: Fall 2007 Instructor: Padhraic Smyth.
CS 4100 Artificial Intelligence Prof. C. Hafner Class Notes Jan 26, 2012.
Logic review A summary of chapters 7, 8, 9 of Artificial Intelligence: A modern approach by Russel and Norving.
1 CS 2710, ISSP 2160 Chapter 9 Inference in First-Order Logic.
Inference in first-order logic I CIS 391 – Introduction to Artificial Intelligence AIMA Chapter (through p. 278) Chapter 9.5 (through p. 300)
Inference in First-Order logic Department of Computer Science & Engineering Indian Institute of Technology Kharagpur.
1 Inference in first-order logic Chapter 9. 2 Outline Reducing first-order inference to propositional inference Unification Generalized Modus Ponens Forward.
Inference in first-order logic Chapter 9. Outline Reducing first-order inference to propositional inference Unification Generalized Modus Ponens Forward.
CS 416 Artificial Intelligence Lecture 12 First-Order Logic Chapter 9 Lecture 12 First-Order Logic Chapter 9.
Inference in first- order logic. Outline Reducing first-order inference to propositional inference Unification Generalized Modus Ponens Forward chaining.
Computing & Information Sciences Kansas State University Friday, 29 Sep 2006CIS 490 / 730: Artificial Intelligence Lecture 16 of 42 Friday, 29 September.
Inference in First-Order Logic 부산대학교 전자전기컴퓨터공학과 인공지능연구실 김민호
CS Introduction to AI Tutorial 8 Resolution Tutorial 8 Resolution.
Computing & Information Sciences Kansas State University Lecture 14 of 42 CIS 530 / 730 Artificial Intelligence Lecture 14 of 42 William H. Hsu Department.
1 Inference in First-Order Logic CS 271: Fall 2009.
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.
5/18/2005EE562 EE562 ARTIFICIAL INTELLIGENCE FOR ENGINEERS Lecture 13, 5/18/2005 University of Washington, Department of Electrical Engineering Spring.
1 First Order Logic (Syntax, Semantics and Inference)
An Introduction to Artificial Intelligence – CE Chapter 9 - Inference in first-order logic Ramin Halavati In which we define.
1 First Order Logic CS 171/271 (Chapters 8 and 9) Some text and images in these slides were drawn from Russel & Norvig’s published material.
1/19 Inference in first-order logic Chapter 9- Part2 Modified by Vali Derhami.
For Wednesday Finish reading chapter 10 – can skip chapter 8 No written homework.
Inference in first-order logic
Inference in First Order Logic. Outline Reducing first order inference to propositional inference Unification Generalized Modus Ponens Forward and backward.
Inference in First-Order Logic Chapter 9. Outline Reducing first-order inference to propositional inference Unification Generalized Modus Ponens Forward.
1 Chaining in First Order Logic CS 171/271 (Chapter 9, continued) Some text and images in these slides were drawn from Russel & Norvig’s published material.
Inference in first-order logic
School of Computer Science & Engineering
Inference in First-Order Logic
Knowledge Representation & Reasoning
Introduction to Artificial Intelligence
Inference in First-Order Logic
Inference in first-order logic part 1
Artificial intelli-gence 1:Inference in first-order logic
Artificial Intelligence
Introduction to Artificial Intelligence
Artificial intelligence: Inference in first-order logic
Artificial Intelligence Inference in First Order Logic
Inference in first-order logic
Inference in first-order logic part 1
Inference in First Order Logic (1)
First-Order Logic Inference
First-Order Logic Prof. Dr. Widodo Budiharto 2018
Presentation transcript:

Cooperating Intelligent Systems Inference in first-order logic Chapter 9, AIMA

Reduce to propositional logic Reduce the first order logic sentences to propositional (boolean) logic. Use the inference systems in propositional logic. We need a system for transfering sentences with quantifiers to sentences without quantifiers 

FOL inference rules All the propositional rules (Modus Ponens, And Elimination, And introduction, etc.) plus:the propositional rules Universal Instantiation (UI) Where the variable x is replaced by the ground term a everywhere in the sentence w. Example: ∀ x P(x,f(x),B) ⇒ P(A,f(A),B) Existential Instantiation (EI) Where the variable x is replaced by a ground term a (that makes the sentence true) in the sentence w. Example: ∃ x Q(x,g(x),B) ⇒ Q(A,g(A),B) A must be a new symbol. Ground term = a term without variables

FOL inference rules All the propositional rules (Modus Ponens, And Elimination, And introduction, etc.) plus: Universal Instantiation (UI) Where the variable x is replaced by the ground term a everywhere in the sentence w. Example: ∀ x P(x,f(x),B) ⇒ P(A,f(A),B) Existential Generalization (EG) Where the ground term a is replaced by the variable x everywhere in the sentence w. Example: ∀ y Q(A,g(A),y) ⇒ ∃ x ∀ y Q(x,g(x),y) Ground term = a term without variables

Example: Kings... UI: (Universal Instantiation) ∀ x (King(x) ∧ Greedy(x)) ⇒ Evil(x) King(John) ∧ Greedy(John) ⇒ Evil(John) King(Richard) ∧ Greedy(Richard) ⇒ Evil(Richard) ∶ EI: (Existential Instantiation) ∃ x (Crown(x) ∧ OnHead(x,John)) Crown(C) ∧ OnHead(C,John) C is called a Skolem constant Making up names is called skolemization

Example: Kings... UI: (Universal Instantiation) ∀ x (King(x) ∧ Greedy(x)) ⇒ Evil(x) King(John) ∧ Greedy(John) ⇒ Evil(John) King(Richard) ∧ Greedy(Richard) ⇒ Evil(Richard) ∶ EI: (Existential Instantiation) ∃ x (Crown(x) ∧ OnHead(x,John)) Crown(C) ∧ OnHead(C,John) C is called a Skolem constant Making up names is called skolemization

Propositionalization Apply Universal Instantiation (UI) and Existential Instantiation (EI) so that every FOL KB is made into a propositional KB. ⇒ We can use the tools from propositional logic to prove theorems. Problem with function constants: Father(A), Father(Father(A)), Father(Father(Father(A))), etc. ad infinitum...infinite number of sentences...how can we prove this in finite time? Theorem: We can find every entailed sentence [Gödel, Herbrand], but the search is not guaranteed to stop for nonentailed sentences. (”Solution”: negation-as-failure, stop after a certain time and assume the sentence is false) Inefficient...generalized (lifted) inference rules better

Notation: Substitution Subst() = Apply the substitution  to the sentence . Example: = {x/John} (replace x with John)  = (King(x) ∧ Greedy(x)) ⇒ Evil(x) (King(John) ∧ Greedy(John)) ⇒ Evil(John) General form:  = {v/g} where v is a variable and g is a ground term.

Generalized (lifted) Modus Ponens For atomic sentences p i, q i, and r where there exists a substitution  such that Subst(,p i ) = Subst(,q i ) for all i ∀ x (King(x) ∧ Greedy(x) ⇒ Evil(x)) r = Evil(x)  = {x/John} q 2 = Greedy(x)p 2 = Greedy(John) q 1 = King(x)p 1 = King(John) KB

Generalized (lifted) Modus Ponens For atomic sentences p i, q i, and r where there exists a substitution  such that Subst(,p i ) = Subst(,q i ) for all i ∀ x (King(x) ∧ Greedy(x) ⇒ Evil(x)) r = Evil(x)  = {x/John} q 2 = Greedy(x)p 2 = Greedy(John) q 1 = King(x)p 1 = King(John) KB

Generalized (lifted) Modus Ponens For atomic sentences p i, q i, and r where there exists a substitution  such that Subst(,p i ) = Subst(,q i ) for all i ⇒ Evil(John) King(John), Greedy(John) ∀ x (King(x) ∧ Greedy(x) ⇒ Evil(x)) Subst(,r) = Evil(John) r = Evil(x)  = {x/John} q 2 = Greedy(x)p 2 = Greedy(John) q 1 = King(x)p 1 = King(John) KB Lifted inference rules make only the necessary substitutions

Example: Arms dealer (1) ∀ x (American(x) ∧ Weapon(y) ∧ Hostile(z) ∧ Sells(x,y,z) ⇒ Criminal(x)) (2) Owns(NoNo,M) (3) Missile(M) (4) ∃ x (Missile(x) ∧ Owns(NoNo,x) ⇒ Sells(West,x,NoNo)) (5) ∀ x (Missile(x) ⇒ Weapon(x)) (6) ∀ x (Enemy(x,America) ⇒ Hostile(x)) (7) American(West) (8) Enemy(NoNo,America) KB in Horn Form

Example: Arms dealer (1) ∀ x (American(x) ∧ Weapon(y) ∧ Hostile(z) ∧ Sells(x,y,z) ⇒ Criminal(x)) (2) Owns(NoNo,M) (3) Missile(M) (4) ∃ x (Missile(x) ∧ Owns(NoNo,x) ⇒ Sells(West,x,NoNo)) (5) ∀ x (Missile(x) ⇒ Weapon(x)) (6) ∀ x (Enemy(x,America) ⇒ Hostile(x)) (7) American(West) (8) Enemy(NoNo,America) KB in Horn Form Facts

Owns(NoNo,M)Missile(M)American(West)Enemy(NoNo,America) Forward chaining: Arms dealer Hostile(NoNo) Enemy(x,America) ⇒ Hostile(x)  = {x/NoNo} Sells(West,M,NoNo)Weapon(M) Missile(x) ⇒ Weapon(x)  = {x/M} Missile(x) ∧ Owns(NoNo,x) ⇒ Sells(West,x,NoNo)  = {x/M} Criminal(West) American(x) ∧ Weapon(y) ∧ Hostile(z) ∧ Sells(x,y,z) ⇒ Criminal(x)  = {x/West, y/M, z/NoNo} Forward chaining generates all inferences (also irrelevant ones) We have proved that West is a criminal

Example: Financial advisor KB in Horn Form 1)SavingsAccount(Inadequate) ⇒ Investments(Bank) 2)SavingsAccount(Adequate) ∧ Income(Adequate) ⇒ Investments(Stocks) 3)SavingsAccount(Adequate) ∧ Income(Inadequate) ⇒ Investments(Mixed) 4)∀ x (AmountSaved(x) ∧ ∃ y (Dependents(y) ∧ Greater(x,MinSavings(y))) ⇒ SavingsAccount(Adequate)) 5)∀ x (AmountSaved(x) ∧ ∃ y (Dependents(y) ∧ ¬ Greater(x,MinSavings(y))) ⇒ SavingsAccount(Inadequate)) 6)∀ x (Earnings(x,Steady) ∧ ∃ y (Dependents(y) ∧ Greater(x,MinIncome(y))) ⇒ Income(Adequate)) 7)∀ x (Earnings(x,Steady) ∧ ∃ y (Dependents(y) ∧ ¬ Greater(x,MinIncome(y))) ⇒ Income(Inadequate)) 8)∀ x (Earnings(x,UnSteady) ⇒ Income(Inadequate)) 9)AmountSaved($22000) 10)Earnings($25000,Steady) 11)Dependents(3) Example from G.F. Luger, ”Artificial Intelligence” 2002 MinSavings(x) ≡ $5000 x MinIncome(x) ≡ $ ($4000 x)

Dependents(3)Earnings($25000,Steady)AmountSaved($22000) MinIncome = $27000 MinSavings = $15000 ¬ Greater($25000,MinIncome) Income(Inadequate) SavingsAccount(Adequate) Greater($22000,MinSavings) Investments(Mixed) FC financial advisor

FOL CNF (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) (implication elimination) 2.Move ¬ inwards, e.g., ¬∀ x P(x) becomes ∃ x ¬ P(x) 3.Standardize variables apart, e.g., ( ∀ x P(x) ∨ ∃ x Q(x)) becomes ( ∀ x P(x) ∨ ∃ y Q(y)) 4.Move quantifiers left, e.g., ( ∀ x P(x) ∨ ∃ y Q(y)) becomes ∀ x ∃ y (P(x) ∨ Q(y)) 5.Eliminate ∃ by Skolemization 6.Drop universal quantifiers 7.Distribute ∧ over ∨, e.g., (P ∧ Q) ∨ R becomes (P ∨ R) ∧ (Q ∨ R) Slide from S. Russel

CNF example ∀ x [ ∀ y Animal(y) ⇒ Loves(x,y)] ⇒ ∃ y Loves(y,x) Implication elimination ∀ x ¬ [ ∀ y ¬ Animal(y) ∨ Loves(x,y)] ∨ ∃ y Loves(y,x) Move ¬ inwards ( ¬∀ y P becomes ∃ y ¬ P) ∀ x [ ∃ y ¬ ( ¬ Animal(y) ∨ Loves(x,y))] ∨ ∃ y Loves(y,x) ∀ x [ ∃ y (Animal(y) ∧ ¬ Loves(x,y))] ∨ ∃ y Loves(y,x) ∀ x [ ∃ y Animal(y) ∧ ¬ Loves(x,y)] ∨ ∃ y Loves(y,x) Standardize variables individually ∀ x [ ∃ y Animal(y) ∧ ¬ Loves(x,y)] ∨ ∃ z Loves(z,x) Skolemize (Replace ∃ with constants) ∀ x [Animal(F(x)) ∧ ¬ Loves(x,F(x))] ∨ Loves(G(x),x) Why not ∀ x [Animal(A) ∧ ¬ Loves(x,A)] ∨ Loves(B,x) ?? Drop ∀ [Animal(F(x)) ∧ ¬ Loves(x,F(x))] ∨ Loves(G(x),x) Distribute ∨ over ∧ [Animal(F(x)) ∨ Loves(G(x),x)] ∧ [ ¬ Loves(x,F(x)) ∨ Loves(G(x),x)] ”Everyone who loves all animals is loved by someone”

Notation: Unification Unify(p,q) =  means that Subst(,p) = Subst(,q)

FOL resolution inference rule First-order literals are complementary if one unifies with the negation of the other Where Unify( l i, ¬ m j ) = . [Animal(F(x)) ∨ Loves(G(x),x)], [ ¬ Loves(u,v) ∨ ¬ Kills(u,v)] Subst({u/G(x),v/x}, [Animal(F(x)) ∨ ¬ Kills(u,v)]) Which produces resolvent [Animal(F(x)) ∨ ¬ Kills(G(x),x)] Note that l i and m j are removed

Resolution proves KB ⊨  by proving (KB ∧ ¬  ) is unsatisfiable Arms dealer example ¬ Start from the top

Resolution proves KB ⊨  by proving (KB ∧ ¬  ) is unsatisfiable Arms dealer example ¬ ∀ x (American(x) ∧ Weapon(y) ∧ Hostile(z) ∧ Sells(x,y,z) ⇒ Criminal(x)) Translate to CNF: ∀ x ( ¬ (American(x) ∧ Weapon(y) ∧ Hostile(z) ∧ Sells(x,y,z)) ∨ Criminal(x)) ∀ x (( ¬ American(x) ∨ ¬ Weapon(y) ∨ ¬ Hostile(z) ∨ ¬ Sells(x,y,z)) ∨ Criminal(x)) ∀ x ( ¬ American(x) ∨ ¬ Weapon(y) ∨ ¬ Hostile(z) ∨ ¬ Sells(x,y,z) ∨ Criminal(x)) ¬ American(x) ∨ ¬ Weapon(y) ∨ ¬ Hostile(z) ∨ ¬ Sells(x,y,z) ∨ Criminal(x) Any FOL KB can be converted to CNF as follows: 1. Replace (P ⇒ Q) by (¬P ∨ Q) (implication elimination) 2. Move ¬ inwards, e.g., ¬ ∀ x P(x) becomes ∃ x ¬P(x) 3. Standardize variables apart, e.g., ( ∀ x P(x) ∨ ∃ x Q(x)) becomes ( ∀ x P(x) ∨ ∃ y Q(y)) 4. Move quantifiers left, e.g., ( ∀ x P(x) ∨ ∃ y Q(y)) becomes ∀ x ∃ y (P(x) ∨ Q(y)) 5. Eliminate ∃ by Skolemization 6. Drop universal quantifiers 7. Distribute ∧ over ∨, e.g., (P ∧ Q) ∨ R becomes (P ∨ R) ∧ (Q ∨ R)

Resolution proves KB ⊨  by proving (KB ∧ ¬  ) is unsatisfiable Arms dealer example ¬ ∀ x (American(x) ∧ Weapon(y) ∧ Hostile(z) ∧ Sells(x,y,z) ⇒ Criminal(x)) Translate to CNF: ∀ x ( ¬ (American(x) ∧ Weapon(y) ∧ Hostile(z) ∧ Sells(x,y,z)) ∨ Criminal(x)) ∀ x (( ¬ American(x) ∨ ¬ Weapon(y) ∨ ¬ Hostile(z) ∨ ¬ Sells(x,y,z)) ∨ Criminal(x)) ∀ x ( ¬ American(x) ∨ ¬ Weapon(y) ∨ ¬ Hostile(z) ∨ ¬ Sells(x,y,z) ∨ Criminal(x)) ¬ American(x) ∨ ¬ Weapon(y) ∨ ¬ Hostile(z) ∨ ¬ Sells(x,y,z) ∨ Criminal(x) Any FOL KB can be converted to CNF as follows: 1. Replace (P ⇒ Q) by (¬P ∨ Q) (implication elimination) 2. Move ¬ inwards, e.g., ¬ ∀ x P(x) becomes ∃ x ¬P(x) 3. Standardize variables apart, e.g., ( ∀ x P(x) ∨ ∃ x Q(x)) becomes ( ∀ x P(x) ∨ ∃ y Q(y)) 4. Move quantifiers left, e.g., ( ∀ x P(x) ∨ ∃ y Q(y)) becomes ∀ x ∃ y (P(x) ∨ Q(y)) 5. Eliminate ∃ by Skolemization 6. Drop universal quantifiers 7. Distribute ∧ over ∨, e.g., (P ∧ Q) ∨ R becomes (P ∨ R) ∧ (Q ∨ R)

Resolution proves KB ⊨  by proving (KB ∧ ¬  ) is unsatisfiable Arms dealer example ¬ Where Unify( l i, ¬ m j ) = .

Resolution proves KB ⊨  by proving (KB ∧ ¬  ) is unsatisfiable Arms dealer example ¬ l 1 = ¬ American(x) l 2 = ¬ Weapon(y) l 3 = ¬ Sells(x,y,z) l 4 = ¬ Hostile(z) l 5 = Criminal(x) m 1 = Criminal(West) Where Unify( l i, ¬ m j ) = . Unify( l 5, ¬ m 1 ) =  = {x/West} Subst(   l 1 ∨ l 2 ∨ l 3 ∨ l 4 ) =...

Resolution proves KB ⊨  by proving (KB ∧ ¬  ) is unsatisfiable Arms dealer example ¬

Resolution proves KB ⊨  by proving (KB ∧ ¬  ) is unsatisfiable Arms dealer example ¬ l 1 = ¬ American(x) l 2 = ¬ Weapon(y) l 3 = ¬ Sells(x,y,z) l 4 = ¬ Hostile(z) l 5 = Criminal(x) m 2 = American(West) Unify( l 1, ¬ m 2 ) =  = {x/West} Subst(   l 2 ∨ l 3 ∨ l 4 ) =...

Resolution proves KB ⊨  by proving (KB ∧ ¬  ) is unsatisfiable Arms dealer example ¬

Resolution proves KB ⊨  by proving (KB ∧ ¬  ) is unsatisfiable Arms dealer example ¬

Resolution proves KB ⊨  by proving (KB ∧ ¬  ) is unsatisfiable Arms dealer example ¬ ?

Resolution proves KB ⊨  by proving (KB ∧ ¬  ) is unsatisfiable Arms dealer example ¬ l 2 = ¬ Weapon(y) l 3 = ¬ Sells(x,y,z) l 4 = ¬ Hostile(z) m 3 = Weapon(x) m 4 = Missile(x) Unify( l 2, ¬ m 3 ) =  = {y/x} Subst(   l 2 ∨ l 3 ∨ l 4 ∨ m 4 ) =...

Resolution proves KB ⊨  by proving (KB ∧ ¬  ) is unsatisfiable Arms dealer example ¬ ?

Resolution proves KB ⊨  by proving (KB ∧ ¬  ) is unsatisfiable Arms dealer example ¬

Resolution proves KB ⊨  by proving (KB ∧ ¬  ) is unsatisfiable Arms dealer example ¬

Resolution proves KB ⊨  by proving (KB ∧ ¬  ) is unsatisfiable Arms dealer example ¬

Resolution proves KB ⊨  by proving (KB ∧ ¬  ) is unsatisfiable Arms dealer example ¬

Resolution proves KB ⊨  by proving (KB ∧ ¬  ) is unsatisfiable Arms dealer example ¬ ∅