Inference in First-Order Logic Chapter 9

Slides:



Advertisements
Similar presentations
Resolution Proof System for First Order Logic
Advertisements

First-Order Logic.
Inference Rules Universal Instantiation Existential Generalization
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.
CS.462 Artificial Intelligence SOMCHAI THANGSATHITYANGKUL Lecture 06 : First Order Logic Resolution Prove.
Standard Logical Equivalences
Resolution.
Inference in first-order logic Chapter 9. Outline Reducing first-order inference to propositional inference Unification Generalized Modus Ponens Forward.
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.
Resolution
13 Automated Reasoning 13.0 Introduction to Weak Methods in Theorem Proving 13.1 The General Problem Solver and Difference Tables 13.2 Resolution.
Chapter 6 Logical Reasoning Xiu-jun GONG (Ph. D) School of Computer Science and Technology, Tianjin University
Artificial Intelligence Chapter 14. Resolution in the Propositional Calculus Artificial Intelligence Chapter 14. Resolution in the Propositional Calculus.
Automated reasoning and theorem proving Introduction: logic in AI Automated reasoning: ResolutionUnificationNormalization.
Using Predicate Logic Chapter 5.
Predicate Logic Terms represent specific objects in the world and can be constants, variables or functions. Predicate Symbols refer to a particular relation.
1 Applied Computer Science II Resolution in FOL Luc De Raedt.
Inference in FOL Copyright, 1996 © Dale Carnegie & Associates, Inc. Chapter 9 Spring 2004.
Inference in FOL Copyright, 1996 © Dale Carnegie & Associates, Inc. Chapter 9.
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
Inference in FOL Copyright, 1996 © Dale Carnegie & Associates, Inc. Chapter 9 Fall 2004.
1 Knowledge Representation and Reasoning. 2 Knowledge Representation & Reasoning How knowledge about the world can be represented How knowledge about.
Inference in FOL Copyright, 1996 © Dale Carnegie & Associates, Inc. Chapter 9 Spring 2005.
Knowledge & Reasoning Logical Reasoning: to have a computer automatically perform deduction or prove theorems Knowledge Representations: modern ways of.
Inference in first-order logic I CIS 391 – Introduction to Artificial Intelligence AIMA Chapter (through p. 278) Chapter 9.5 (through p. 300)
1 Inference in first-order logic Chapter 9. 2 Outline Reducing first-order inference to propositional inference Unification Generalized Modus Ponens Forward.
UNIVERSITI TENAGA NASIONAL 1 CSNB234 ARTIFICIAL INTELLIGENCE Chapter 3 Propositional Logic & Predicate Logic Chapter 3 Propositional Logic & Predicate.
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.
First-Order Logic Semantics Reading: Chapter 8, , FOL Syntax and Semantics read: FOL Knowledge Engineering read: FOL.
ARTIFICIAL INTELLIGENCE [INTELLIGENT AGENTS PARADIGM] Professor Janis Grundspenkis Riga Technical University Faculty of Computer Science and Information.
Logical Representations and Resolution. Boolean Logic Conjunctive normal form Resolution.
1CS3754 Class Notes 14B, John Shieh, Figure 2.5: Further steps in the unification of (parents X (father X) (mother bill)) and (parents bill.
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.
An Introduction to Artificial Intelligence – CE Chapter 9 - Inference in first-order logic Ramin Halavati In which we define.
Prolog Conversion to clause form Reference: Artificial Intelligence, by Elaine Rich and Kevin Knight.
For Wednesday Finish reading chapter 10 – can skip chapter 8 No written homework.
Inference in First Order Logic. Outline Reducing first order inference to propositional inference Unification Generalized Modus Ponens Forward and backward.
1 Example: The following knowledge is given :The following knowledge is given : 1. Marcus was a man. 2. Marcus was a Pompeian. 3. All Pompeians were Romans.
CIT 856 – Artificial Intelligence
Inference in First-Order Logic Chapter 9. Outline Reducing first-order inference to propositional inference Unification Generalized Modus Ponens Forward.
Conversion to Conjunctive Normal Form. Assertion All Romans who know Marcus either hate Caesar or think than anyone who hates anyone is crazy. All Romans.
Inference in first-order logic
Inference in First-Order Logic
Resolution in the Propositional Calculus
A I (Artificial Intelligence)
Predicate Logic Lecture 7.
Horn Clauses and Unification
Inference in First-Order Logic
Inference in first-order logic part 1
Artificial intelli-gence 1:Inference in first-order logic
Knowledge & Reasoning Logical Reasoning: to have a computer automatically perform deduction or prove theorems Knowledge Representations: modern ways of.
Artificial intelligence: Inference in first-order logic
Artificial Intelligence Inference in First Order Logic
Notes 9: Inference in First-order logic
Logic Use mathematical deduction to derive new knowledge.
Inference in first-order logic
Inference in first-order logic part 1
Biointelligence Lab School of Computer Sci. & Eng.
Horn Clauses and Unification
Biointelligence Lab School of Computer Sci. & Eng.
CSNB234 ARTIFICIAL INTELLIGENCE
RESOLUTION.
Resolution Proof System for First Order Logic
Presentation transcript:

Inference in First-Order Logic Chapter 9

Some Basic Definitions A free variable is a variable that isn't bound by a quantifier. $y Likes(x,y) x is free, y is bound A sentence is a well-formed formula where all variables are quantified. CLICK EACH SUB

Rules of Inference x P(x) __________  P(c) if cU Universal instantiation P(c) for an arbitrary cU ___________________  x P(x) Universal generalization x P(x) ______________________  P(c) for some element cU Existential instantiation P(c) for some element cU ____________________  x P(x) Existential generalization

An example of U.G. x(Ontable(x, T1)  Upturned(x, T2)) xy(Upturned(x, y)  Empty(x, y))

An example of U.G. Ontable(b2, T1) Assumption Ontable(b2, T1)  Upturned(b2, T2) -  , 1 Upturned (b2, T2) -  , 3, 4 Upturned(b2, T2)  Empty(b2, T2) -  , 2 Empty(b2, T2) -  , 5, 6 Ontable(b2, T1)  Empty(b2, T2) +  , 7 x(Ontable(x, T1)  Empty(x, T2)) +  , 8

An example of E.I. b1 b2 b3 b1 b2 b3 T1 T2 x(Bottle(x,T1)  Upturned(x, T2)) xy(Upturned(x, y)  Empty(x, y)) x(Full(x, T1) & Empty(x, T2)  Wet(Floor)) x (Bottle(x, T1) & Full(x, T1))

An example of E.I. Bottle(b1, T1) & Full(b1, T1)) - EI assumption Upturned (b1, T2) -  , 1 , -  , 6 Empty(b1, T2) -  , 2 , -  , 7 Full(b1, T1) & Empty (b1, T2) + & , 7, 9 Wet(Floor) -  , 3, -  , 10 Wet(Floor) - EI conclusion

Prove (x(P(x)  Q))  (xP(x)  Q) x(P(x)  Q) Assumption xP(x) Assumption P(x) -  Ass. P(x)  Q +  , 1 Q -  3, 4 Q -  Conc. xP(x)  Q +  2, 6 (x(P(x)  Q))  (xP(x)  Q) +  1, 7

Prove (xP(x)  Q)  (x(P(x)  Q)) (xP(x)  Q) Assumption P(x) Assumption xP(x) +  Q -  1, 3 P(x) Q -  2, 4 x(P(x)  Q) +  5 (xP(x)  Q)  (x(P(x)  Q)) +  1, 6

Unification Can we find a substitution  such that King(x) and Greedy(x) match King(John) and Greedy(y)  = {x/John,y/John} is such a substitution Unify( ,) =  if  =  p q  Knows(John,x) Knows(John,Jane) Knows(John,x) Knows(y,OJ) Knows(John,x) Knows(y,Mother(y)) Knows(John,x) Knows(x,OJ) Standardizing apart eliminates overlap of variables, e.g., Knows(z17,OJ)

Unification Can we find a substitution  such that King(x) and Greedy(x) match King(John) and Greedy(y)  = {x/John,y/John} is such a substitution Unify( ,) =  if  =  p q  Knows(John,x) Knows(John,Jane) {x/Jane} Knows(John,x) Knows(y,OJ) Knows(John,x) Knows(y,Mother(y)) Knows(John,x) Knows(x,OJ) Standardizing apart eliminates overlap of variables, e.g., Knows(z17,OJ)

Unification Can we find a substitution  such that King(x) and Greedy(x) match King(John) and Greedy(y)  = {x/John,y/John} is such a substitution Unify( ,) =  if  =  p q  Knows(John,x) Knows(John,Jane) {x/Jane} Knows(John,x) Knows(y,OJ) {x/OJ,y/John} Knows(John,x) Knows(y,Mother(y)) Knows(John,x) Knows(x,OJ) Standardizing apart eliminates overlap of variables, e.g., Knows(z17,OJ)

Unification Can we find a substitution  such that King(x) and Greedy(x) match King(John) and Greedy(y)  = {x/John,y/John} is such a substitution Unify( ,) =  if  =  p q  Knows(John,x) Knows(John,Jane) {x/Jane} Knows(John,x) Knows(y,OJ) {x/OJ,y/John} Knows(John,x) Knows(y,Mother(y)) {y/John,x/Mother(John)} Knows(John,x) Knows(x,OJ) Standardizing apart eliminates overlap of variables, e.g., Knows(z17,OJ)

Unification Can we find a substitution  such that King(x) and Greedy(x) match King(John) and Greedy(y)  = {x/John,y/John} is such a substitution Unify( ,) =  if  =  p q  Knows(John,x) Knows(John,Jane) {x/Jane} Knows(John,x) Knows(y,OJ) {x/OJ,y/John} Knows(John,x) Knows(y,Mother(y)) {y/John,x/Mother(John)} Knows(John,x) Knows(x,OJ) {fail} Standardizing apart eliminates overlap of variables, e.g., Knows(z17,OJ)

Unification To unify Knows(John,x) and Knows(y,z), θ = {y/John, x/z } or θ = {y/John, x/John, z/John} The first unifier is more general than the second. There is a single most general unifier (MGU) that is unique up to renaming of variables. MGU = { y/John, x/z }

The unification algorithm

The unification algorithm

Example Knowledge Base Mark was a man. Mark was a Pompeian. All Pompeians were Romans. Caesar was a ruler. All Romans were either loyal to Caesar or hated him. Everyone is loyal to someone. People only try to assassinate rulers they are not loyal to. Mark tried to assassinate Caesar.

Example Knowledge Base (1) Mark was a man. man(Mark) Was Mark loyal to Caesar? (2) Mark was a Pompeian. Pompeian(Mark) (3) All Pompeians were Romans. x (Pompeian(x)  Roman(x)) (4) Caesar was a ruler. ruler(Caesar) (5) All Romans were either loyal to Caesar or hated him. x (Roman(x)  loyalto(x, Caesar)  hate(x, Caesar)) (6) Everyone is loyal to someone. x y loyalto(x, y) (7) People only try to assassinate rulers they are not loyal to. x y (person(x)  ruler(y)  tryassassinate(x, y)  loyalto(x, y)) (8) Mark tried to assassinate Caesar. tryassassinate(Mark, Caesar)

Reasoning Backward loyalto(Mark, Caesar) (x/Mark) (y/Caesar) (1) man(Mark) (2) Pompeian(Mark) (3) x (Pompeian(x)  Roman(x)) (4) ruler(Caesar) (5) x (Roman(x)  loyalto(x, Caesar)  hate(x, Caesar)) (6) x y loyalto(x, y) (7) x y (person(x)  ruler(y)  tryassassinate(x, y)  loyalto(x, y)) (8) tryassassinate(Mark, Caesar) loyalto(Mark, Caesar) (x/Mark) (y/Caesar) person(Mark) ruler(Caesar) tryassassinate(Mark, Caesar)

Reasoning Backward loyalto(Mark, Caesar) (x/Mark) (y/Caesar) (1) man(Mark) (2) Pompeian(Mark) (3) x (Pompeian(x)  Roman(x)) (4) ruler(Caesar) (5) x (Roman(x)  loyalto(x, Caesar)  hate(x, Caesar)) (6) x y loyalto(x, y) (7) x y (person(x)  ruler(y)  tryassassinate(x, y)  loyalto(x, y)) (8) tryassassinate(Mark, Caesar) (9) x (man(x)  person(x)) loyalto(Mark, Caesar) (x/Mark) (y/Caesar) person(Mark) ruler(Caesar) tryassassinate(Mark, Caesar) (x/Mark) Man(Mark)

Functions and Predicates (1) Mark was a man. man(Mark) (2) Mark was a Pompeian. Pompeian(Mark) (3) Mark was born in 40 A.D. born(Mark, 40) (4) All men are mortal. x (man(x)  mortal(x)) (5) A volcano erupted in 79 A.D. erupted(volcano, 79) (6) AllPompeians died in 79 A.D. x (Pompeian(x)  died(x,79)) (7) No mortal lives longer than 150 years. x t1 t2 (mortal(x)  born(x, t1)  gt(t2-t1, 150)  dead(x, t2)) (8) It is now 2010. now = 2010 Is Mark alive?

Functions and Predicates (1) man(Mark) (2) Pompeian(Mark) (3) born(Mark, 40) (4) x (man(x)  mortal(x)) (5) erupted(volcano, 79) (6) x (Pompeian(x)  died(x,79)) (7) x t1 t2 (mortal(x)  born(x, t1)  gt(t2-t1, 150)  dead(x, t2)) (8) now = 2010  alive(Mark, now)

Functions and Predicates - Filling in the Blanks (1) man(Mark) (2) Pompeian(Mark) (3) born(Mark, 40) (4) x (man(x)  mortal(x)) (5) erupted(volcano, 79) (6) x (Pompeian(x)  died(x,79)) (7) x t1 t2 (mortal(x)  born(x, t1)  gt(t2-t1, 150)  dead(x, t2)) (8) now = 2010 (9a) x t (dead(x,t)  alive(x, t)) (9b) x t (alive(x, t)  dead(x, t)) (10) x t1 t2 (died(x, t1)  gt(t2, t1)  dead(x, t2))  alive(Mark, now) 24 24

Showing that Mark is Not Alive  alive(Mark, now) (9a) (x/Mark) (t/now) dead(Mark, now) (10)(x/Mark)(t2/now) (7) (Mark/x)(now/t2) died(Mark, t1) gt(now, t1) mortal(Mark) born(Mark, t1) gt(now-t1,150) (6)(x/Mark) (t1/79) (4) (x/Mark) (3) (t1/40) Pompeian(Mark) gt(now, 79) man(Mark) born(Mark, 40) gt(now-40,150) (2) subst (1) subst T gt(2010, 79) T T gt(2010-40,150) eval eval T T 25 25

A Harder One Given: x [Roman(x)  know(x, Mark)]  [hate(x, Caesar)  (y (z hate(y, z))  thinkcrazy(x, y))] Roman(Isaac) hate(Isaac, Caesar) hate(Paulus, Mark) thinkcrazy(Isaac, Paulus) Prove: know(Isaac, Mark) 26 26

Clause Form Simplifies the Process Standard: x [Roman(x)  know(x, Mark)]  [hate(x, Caesar)  (y (z hate(y, z))  thinkcrazy(x, y))] Clausal: Roman(x)  know(x, Mark)  hate(x, Caesar)  hate(y, z)  thinkcrazy(x, z)

Conversion to Clause Form - Step 1 1. Eliminate , using the fact that a  b is equivalent to a  b x [Roman(x)  know(x, Mark)]  [hate(x, Caesar)  (y (z hate(y, z))  thinkcrazy(x, y))] x  [Roman(x)  know(x, Mark)]  [hate(x, Caesar)  (y (z hate(y, z))  thinkcrazy(x, y))]

Conversion to Clause Form - Step 2 2. Reduce the scope of each  to a single term, using: (p) = p deMorgan’s laws x P(x)  x P(x) x P(x)  x P(x) x  [Roman(x)  know(x, Mark)]  [hate(x, Caesar)  (y (z hate(y, z))  thinkcrazy(x, y))] x [ Roman(x)   know(x, Mark)]  [hate(x, Caesar)  (y z  hate(y, z)  thinkcrazy(x, y))]

Conversion to Clause Form - Step 3 3. Standardize variables so that each quantifier binds a unique variable. x P(x)  x Q(x) x P(x)  y Q(y)

Conversion to Clause Form - Step 4 4. Move all quantifiers to the left without changing their relative order. x [ Roman(x)   know(x, Mark)]  [hate(x, Caesar)  (y z  hate(y, z)  thinkcrazy(x, y))] x y z [ Roman(x)   know(x, Mark)]  [hate(x, Caesar)  ( hate(y, z)  thinkcrazy(x, y))] At this point, we have prenex normal form.

Conversion to Clause Form - Step 5 5. Eliminate existential quantifiers through the use of Skolem functions and constants. x Roman(x) Roman(S1) x z father-of(x, z) x father-of(x, S2(x))

Conversion to Clause Form - Step 6 6. Drop the prefix since all remaining quantifiers are universal. x y z [ Roman(x)   know(x, Mark)]  [hate(x, Caesar)  ( hate(y, z)  thinkcrazy(x, y))] [ Roman(x)   know(x, Mark)] 

Conversion to Clause Form - Step 7 7. Convert the matrix into a conjunction of disjuncts by using: Associative properties of  and . [ Roman(x)   know(x, Mark)]  [hate(x, Caesar)  ( hate(y, z)  thinkcrazy(x, y))]  Roman(x)   know(x, Mark)  hate(x, Caesar)  ( hate(y, z)  thinkcrazy(x, y)) Distribution of  over . (P(x)  Q(x))  T(x) (P(x)  T(x))  (Q(x))  T(x))

Conversion to Clause Form - Step 8 8. Create a separate clause for each conjunct. (P(x)  T(x))  (Q(x)  T(x)) (P(x)  T(x)) (Q(x)  T(x))

Conversion to Clause Form - Step 9 9. Standardize apart the variables. (P(x)  T(x)) (Q(x)  T(x)) (Q(y)  T(y))

Resolution in Predicate Logic p’ v q ~p v r (q v r) p(x) v q(x) ~p(a) v r(b) (q(x) v r(b)) [x/a] => q(a) v r(b) All variables assumed universally quantified. where p' = p where  = [x/a] 37 37

Importance of Standardizing Variables Apart Consider: 1. father(x, y)  woman(x) {father(x, y) woman(x)} 2. mother(x, y)  woman(x) {mother(x, y)  woman(x)} 3. mother(Chris, Mary) 4. father(Chris, Bill) 1 2 * father(x, y)  mother(x, y) 3 x/Chris, y/Mary father(Chris, Mary)

Back to Mark (1) man(Mark) (2) Pompeian(Mark) (3) Pompeian(x1)  Roman(x1) (4) ruler(Caesar) (5) Roman(x2)  loyalto(x2, Caesar)  hate(x2, Caesar) (6) loyalto(x3, S1(x3)) (7) man(x4)  ruler(y1)  tryassassinate(x4, y1)  loyalto(x4, y1) (8) tryassassinate(Mark, Caesar)

Proving Mark Not Loyal to Caesar loyalto(M, C)  man(x4)  ruler(y1)  tryassassinate(x4, y1)  loyalto(x4, y1) (x4/M)(y1/C)  man(M)  ruler(C)  tryassassinate(M,C) man(M) ruler(C)  tryassassinate(M,C) ruler(C) tryassassinate(M,C) tryassassinate(M,C) nil

Does Isaac Know Mark? Given: 1. x [Roman(x)  know(x, Mark)]  [hate(x, Caesar)  (y (z hate(y, z))  thinkcrazy(x, y))] Roman(x)   know(x, Mark)  hate(x, Caesar)   hate(y, z)  thinkcrazy(x, y) 2. Roman(Isaac) 3. hate(Isaac, Caesar) 4. hate(Paulus, Mark) 5. thinkcrazy(Isaac, Paulus) Prove: know(Isaac, Mark) * know(Isaac, Mark)

Proving Issac Doesn’t know Mark know(Isaac, Mark) 1 (x/I) Roman(I)  hate(I, C)   hate(y, z)  thinkcrazy(I, y) 2: Roman(I) hate(I, C)   hate(y, z)  thinkcrazy(I, y) 3: hate(I, C)  hate(y, z)  thinkcrazy(I, y) 4: hate(P, M) (y/P)(z/M) thinkcrazy(I, P) 5: thinkcrazy(I, P) nil 42

Question Answering When did Mark die? died(Mark, ??) Mark must have died sometime, so we could try to prove: x died(Mark, x) by adding to the KB: x died(Mark, x). Converting to clause form: x died(Mark, x)

When Did Mark Die? But how do we retrieve the answer 79? died(Mark, x) Pompeian(x1)  died(x1,79) (x1/Mark)(x/79) Pompeian(Mark) Pompeian(Mark) nil But how do we retrieve the answer 79?

When Did Mark Die? died(Mark, x)  died(Mark, x) Pompeian(x1)  died(x1,79) (x1/Mark)(x/79) Pompeian(Mark)  died(Mark, 79) Pompeian(Mark) died(Mark, 79) The underlined literal will get carried along and collect all the substitutions. We stop when we generate a clause that contains only it.

Resolution Strategies Unit Preference: prefer to do resolutions where 1 sentence is a single literal, a unit clause goal is to produce the empty clause, focus search by producing resolvents that are shorter complete but too slow for medium sized problems Unit Resolution: requires at least 1 to be a unit clause complete for Horn Clauses

Unit Resolution Example (1) 1. p  q KB 2. ~p  r KB 3. ~q  r KB 4. ~r S 5. ~p 2, 4 6. ~q 3, 4 7. q 1, 5 8. p 1, 6 9. r 3, 7 10. nil 6, 7 11. r 2, 8 12. nil 5, 8

Unit Resolution Example(2) 1. p  q 2. ~p  q 3. p  ~q 4. ~p  ~q Cannot perform a single unit resolution since all clauses are of size 2!

Resolution Strategies (Cont.) Set-of-Support (SoS): identify some subset of sentences, called SoS P and Q can be resolved if one is from SoS resolvent is added to the SoS common approach: ~query is the initial SoS, resolvents are added assumes KB is satisfiable complete if KB-SoS is satisfiable

Set of Support resolution example 1. p  q KB 2. ~p  r KB 3. ~q  r KB 4. ~r S 5. ~p 2, 4 add to S 6. ~q 3, 4 add to S 7. q 1, 5 add to S 8. p 1, 6 add to S 9. r 3, 7 10. nil 6, 7 11. r 2, 8 12. nil 5, 8

Resolution Strategies (Cont.) Input Resolution: P and Q can be resolved if at least one is from the set of original clauses, i.e., KB and ~query complete for Horn Clauses Linear Resolution: a slight generalization of input resolution P and Q can be resolved if: P is from the set of the original clauses, or P is an ancestor of Q, in the proof tree complete

Input Resolution 2. ~p  q KB 3. p  ~q KB 4. ~p  ~q KB Ex: 1. p  q KB 2. ~p  q KB 3. p  ~q KB 4. ~p  ~q KB Cannot perform input resolution!

Linear Resolution p  q ~p  q p  ~q ~p  ~q q p ~q nil

Natural Deduction vs. Resolution CNF is simpler to work with But, we loose readability and some useful control information x(judge(x) & ~crooked(x)  educated(x)) ~judge(x) v crooked(x) v educated(x)