First-Order Logic ECE457 Applied Artificial Intelligence Fall 2007 Lecture #7.

Slides:



Advertisements
Similar presentations
Artificial Intelligence
Advertisements

Artificial Intelligence 8. The Resolution Method
First-Order Logic.
Inference Rules Universal Instantiation Existential Generalization
Standard Logical Equivalences
First-Order Logic (FOL) aka. predicate calculus. First-Order Logic (FOL) Syntax User defines these primitives: – Constant symbols (i.e., the "individuals"
ITCS 3153 Artificial Intelligence Lecture 15 First-Order Logic Chapter 9 Lecture 15 First-Order Logic Chapter 9.
Inference in first-order logic Chapter 9. Outline Reducing first-order inference to propositional inference Unification Generalized Modus Ponens Forward.
Automated Reasoning Systems For first order Predicate Logic.
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.
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.
Methods of Proof Chapter 7, second half.. Proof methods Proof methods divide into (roughly) two kinds: Application of inference rules: Legitimate (sound)
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.
Logic Use mathematical deduction to derive new knowledge.
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.
Logic.
Resolution in Propositional and First-Order Logic.
F22H1 Logic and Proof Week 7 Clausal Form and Resolution.
First-Order Logic Chapter 8.
First-Order Logic (FOL) aka. predicate calculus. First-Order Logic (FOL) Syntax User defines these primitives: –Constant symbols (i.e., the "individuals"
Predicate Calculus Russell and Norvig: Chapter 8,9.
First-Order Logic ECE457 Applied Artificial Intelligence Spring 2007 Lecture #7.
Outline Recap Knowledge Representation I Textbook: Chapters 6, 7, 9 and 10.
Proof methods Proof methods divide into (roughly) two kinds: –Application of inference rules Legitimate (sound) generation of new sentences from old Proof.
Inference in FOL Copyright, 1996 © Dale Carnegie & Associates, Inc. Chapter 9 Spring 2004.
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
Methods of Proof Chapter 7, second half.
Knoweldge Representation & Reasoning
Artificial Intelligence
Propositional Logic Agenda: Other forms of inference in propositional logic Basics of First Order Logic (FOL) Vision Final Homework now posted on web site.
INFERENCE IN FIRST-ORDER LOGIC IES 503 ARTIFICIAL INTELLIGENCE İPEK SÜĞÜT.
Inference in First-Order logic Department of Computer Science & Engineering Indian Institute of Technology Kharagpur.
 Predicate: A sentence that contains a finite number of variables and becomes a statement when values are substituted for the variables. ◦ Domain: the.
Propositional Calculus Composed of symbols –P – some true statement P might represent something like “It is Monday” or “the car is red” And sentences –a.
Logical Agents Logic Propositional Logic Summary
Tasks Task 41 Solve Exercise 12, Chapter 2.
ARTIFICIAL INTELLIGENCE [INTELLIGENT AGENTS PARADIGM] Professor Janis Grundspenkis Riga Technical University Faculty of Computer Science and Information.
Inference in FOL Compared to predicate logic, more abstract reasoning and specific conclusions.
An Introduction to Artificial Intelligence – CE Chapter 7- Logical Agents Ramin Halavati
CS Introduction to AI Tutorial 8 Resolution Tutorial 8 Resolution.
Logical Agents Chapter 7. Knowledge bases Knowledge base (KB): set of sentences in a formal language Inference: deriving new sentences from the KB. E.g.:
Logical Agents ECE457 Applied Artificial Intelligence Spring 2007 Lecture #6.
Computing & Information Sciences Kansas State University Lecture 14 of 42 CIS 530 / 730 Artificial Intelligence Lecture 14 of 42 William H. Hsu Department.
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.
1 Logical Inference Algorithms CS 171/271 (Chapter 7, continued) Some text and images in these slides were drawn from Russel & Norvig’s published material.
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.
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.
For Wednesday Read chapter 9, sections 1-3 Homework: –Chapter 7, exercises 8 and 9.
Reasoning using First-Order Logic
Instructor: Eyal Amir Grad TAs: Wen Pu, Yonatan Bisk Undergrad TAs: Sam Johnson, Nikhil Johri CS 440 / ECE 448 Introduction to Artificial Intelligence.
For Wednesday Finish reading chapter 10 – can skip chapter 8 No written homework.
CSCI 5582 Fall 2006 CSCI 5582 Artificial Intelligence Lecture 11 Jim Martin.
ECE457 Applied Artificial Intelligence R. Khoury (2007)Page 1 Implication Truth Table If α is true, then β must be true for the implication to be true.
Inference in First Order Logic. Outline Reducing first order inference to propositional inference Unification Generalized Modus Ponens Forward and backward.
First-Order Logic Reading: C. 8 and C. 9 Pente specifications handed back at end of class.
Dr. Shazzad Hosain Department of EECS North South Universtiy Lecture 04 – Part B Propositional Logic.
Instructor: Eyal Amir Grad TAs: Wen Pu, Yonatan Bisk Undergrad TAs: Sam Johnson, Nikhil Johri CS 440 / ECE 448 Introduction to Artificial Intelligence.
Logical Agents Chapter 7. Outline Knowledge-based agents Propositional (Boolean) logic Equivalence, validity, satisfiability Inference rules and theorem.
Resolution Theorem Proving in Predicate Calculus Lecture No 10 By Zahid Anwar.
Logical Agents ECE457 Applied Artificial Intelligence Spring 2008 Lecture #6.
Proof Methods for Propositional Logic CIS 391 – Intro to Artificial Intelligence.
Logical Agents. Outline Knowledge-based agents Logic in general - models and entailment Propositional (Boolean) logic Equivalence, validity, satisfiability.
ECE457 Applied Artificial Intelligence Fall 2007 Lecture #6
EA C461 Artificial Intelligence
Artificial Intelligence
RESOLUTION.
Presentation transcript:

First-Order Logic ECE457 Applied Artificial Intelligence Fall 2007 Lecture #7

ECE457 Applied Artificial Intelligence R. Khoury (2007)Page 2 Outline First-order logic (FOL) Sentences Russell & Norvig, chapter 8 Inference Russell & Norvig, chapter 9

ECE457 Applied Artificial Intelligence R. Khoury (2007)Page 3 First-Order Logic Propositional logic is limited Cannot represent information concisely We want something more expressive First-order logic Allows the representation of objects, functions on objects and relations between objects Allows us to represent almost any English sentence

ECE457 Applied Artificial Intelligence R. Khoury (2007)Page 4 New Symbols in FOL Constant symbol An individual object in the world Bob, James, Hat Predicate symbol A relation between two objects that can be true or false Brother(Bob, James), OnHead(Hat, Bob) Function symbol Special type of relation that maps one object to another Head(Bob) All symbols begin with uppercase letters

ECE457 Applied Artificial Intelligence R. Khoury (2007)Page 5 New Variables in FOL Begin with lowercase letters Stand-in for any symbol Brother(x,y) x is the brother of y

ECE457 Applied Artificial Intelligence R. Khoury (2007)Page 6 New Quantifiers in FOL Universal quantifier   x means “For all x…” Always true Usually used with   x means “Not all x…” Existential quantifier   x means “There exists an x…” True for at least one interpretation Usually used with   x means “There exists no x…”

ECE457 Applied Artificial Intelligence R. Khoury (2007)Page 7 Properties of New Quantifiers Nesting  x  y P(x,y) same as  y  x P(x,y)  x  y P(x,y) same as  y  x P(x,y)  x  y P(x,y) not same as  y  x P(x,y) Duality  x P(x) same as  x  P(x)  x P(x) same as  x  P(x)

ECE457 Applied Artificial Intelligence R. Khoury (2007)Page 8 Sentences in FOL Term Constant symbol, function symbol, or variable Atom (atomic sentence) Predicate symbol with value true or false Represents a relation between terms Sentence (complex sentence) Atom(s) joined together using logical connectives and/or quantifiers

ECE457 Applied Artificial Intelligence R. Khoury (2007)Page 9 Example Sentences Purple mushrooms are poisonous Purple(x)  Mushroom(x)  Poisonous(x) Some purple mushrooms are poisonous  x Purple(x)  Mushroom(x)  Poisonous(x) (bad!)  x Purple(x)  Mushroom(x)  Poisonous(x) No purple mushrooms are poisonous  x Purple(x)  Mushroom(x)  Poisonous(x)  x Purple(x)  Mushroom(x)   Poisonous(x) There are exactly two purple mushrooms  x  y  z Purple(x)  Mushroom(x)  Purple(y)  Mushroom(y)   (x=y)  Purple(z)  Mushroom(z)  (x=z)  (y=z)

ECE457 Applied Artificial Intelligence R. Khoury (2007)Page 10 Implication Truth Table If α is true, then β must be true for the implication to be true If α is false, then we have no information about β β might be true or false without affecting the implication β is not necessarily true If implication is true and α is true, then β must be true (Modus Ponens) αβ α  β TTT TFF FTT FFT

ECE457 Applied Artificial Intelligence R. Khoury (2007)Page 11 Universal Implication x = {,, } All purple mushrooms are poisonous  x Purple(x)  Mushroom(x)  Poisonous(x) Universal: all three implications are true is purple and a mushroom  is poisonous But the first one is the only one where the premise is true, therefore the only one where we know the consequent is true (Modus Ponens) Otherwise, we don’t know whether x is poisonous

ECE457 Applied Artificial Intelligence R. Khoury (2007)Page 12 Existential Implication x = {,, } Some purple mushrooms are poisonous  x Purple(x)  Mushroom(x)  Poisonous(x) Existential: at least one implication is true is purple and a mushroom  is poisonous But all those where the premise is false are true The existential implication doesn’t give us any information

ECE457 Applied Artificial Intelligence R. Khoury (2007)Page 13 Existential Conjunction x = {,, } Some purple mushrooms are poisonous  x Purple(x)  Mushroom(x)  Poisonous(x) Existential: at least one statement is true is purple and a mushroom and is poisonous The first statement is true, the other two are false The existential quantifier is satisfied The situation is consistent with our original meaning

ECE457 Applied Artificial Intelligence R. Khoury (2007)Page 14 Universal Conjunction x = {,, } All purple mushrooms are poisonous  x Purple(x)  Mushroom(x)  Poisonous(x) Universal: all three statements are true is purple and a mushroom and is poisonous “Everything is a poisonous purple mushroom” This is false, and not the original meaning of our sentence

ECE457 Applied Artificial Intelligence R. Khoury (2007)Page 15 Summary Universal quantifier  Usually used with  to create universal rules Using it with  makes blanket statements about all objects in the world Existential quantifier  Usually used with  to list properties of an object Using it with  creates sentences that do not say much

ECE457 Applied Artificial Intelligence R. Khoury (2007)Page 16 Example Sentences You can fool some people all the time  x  y Person(x)  Time(y)  CanBeFooled(x,y) Everyone who loves all animals is loved by someone  x  y Animal(y)  Love(x,y)   z Love(z,x) No living man can kill the Witch-King  x Living(x)  Man(x)  CanKill(x, Witch-King)

ECE457 Applied Artificial Intelligence R. Khoury (2007)Page 17 Wumpus World in FOL Predicate to represent adjacent rooms  x,y,a,b Adjacent([x,y],[a,b])  [a,b]  {[x+1,y], [x-1,y], [x,y+1], [x,y-1]} Sentences to represent the relationship between breezy rooms and pits  r Breeze(r)   s Adjacent(r,s)  Pit(s)  s Pit(s)  (  r Adjacent(r,s)  Breeze(r))

ECE457 Applied Artificial Intelligence R. Khoury (2007)Page 18 Inference in FOL We know how to do inference in propositional logic Can we reduce FOL to propositional logic and infer from there? Propositionalization Eliminate universal quantifiers Eliminate existential quantifiers

ECE457 Applied Artificial Intelligence R. Khoury (2007)Page 19 Universal Instantiation A universal variable x in a true sentence P(x) can be substituted by any (and all) ground terms g without variables in the domain of x, and P(g) will be true SUBST({x/g},P(x)) = P(g) Example x  {Bob, James, Tom}  x Strong(x)  Fast(x)  Athlete(x) Strong(Bob)  Fast(Bob)  Athlete(Bob) Strong(James)  Fast(James)  Athlete(James) Strong(Tom)  Fast(Tom)  Athlete(Tom)

ECE457 Applied Artificial Intelligence R. Khoury (2007)Page 20 Existential Instantiation Any existential variable x in a true sentence P(x) can be replaced by a constant symbol not already in the KB Skolem constant Example  x Purple(x)  Mushroom(x)  Poisonous(x) Purple(C)  Mushroom(C)  Poisonous(C)

ECE457 Applied Artificial Intelligence R. Khoury (2007)Page 21 Inference Example We know the following All of Bob’s dogs are brown. Fido is a dog. Bob owns Fido. Can we infer that Fido is brown? Translate into FOL KB  x Dog(x)  Own(Bob,x)  Brown(x) Dog(Fido) Own(Bob,Fido) Apply inference rules Universal Instantiation with {x/Fido}: Dog(Fido)  Own(Bob,Fido)  Brown(Fido) And-Introduction: Dog(Fido)  Own(Bob,Fido) Modus Ponens: Brown(Fido)

ECE457 Applied Artificial Intelligence R. Khoury (2007)Page 22 The set of ground substitution can be infinite Function symbols can be nested infinitely Example: Father(x) = Father(Bob), Father(Father(Bob)), Father(Father(Father(Bob))), … Algorithms can prove sentence is entailed Search every depth successively until sentence is found Algorithms cannot prove sentence is not entailed Will search deeper and deeper, forever Entailment in FOL is semidecidable Problem with Propositionalization

ECE457 Applied Artificial Intelligence R. Khoury (2007)Page 23 Problem with Propositionalization Modify the previous example  x Dog(x)  Own(Bob,x)  Brown(x) Dog(Fido), Dog(Barky), Dog(Dogbert), Dog(Princess), Dog(Lassie), Dog(K-9) Own(Bob,Fido) Inference with Propositionalization Universal Instantiation: Dog(Fido)  Own(Bob,Fido)  Brown(Fido) Dog(Barky)  Own(Bob,Barky)  Brown(Barky) Dog(Dogbert)  Own(Bob,Dogbert)  Brown(Dogbert) Dog(Princess)  Own(Bob,Princess)  Brown(Princess) Dog(Lassie)  Own(Bob,Lassie)  Brown(Lassie) Dog(K-9)  Own(Bob,K-9)  Brown(K-9) And-Introduction: Dog(Fido)  Own(Bob,Fido) Modus Ponens: Brown(Fido)

ECE457 Applied Artificial Intelligence R. Khoury (2007)Page 24 Problem with Propositionalization Brown(Fido) is obvious to us Universal Instantiation generates a lot of useless substitutions which are obviously unnecessary (to us) Recall Modus Ponens: (α  β), α β

ECE457 Applied Artificial Intelligence R. Khoury (2007)Page 25 Generalized Modus Ponens Combine And-Introduction, Universal Elimination, and Modus Ponens p 1 ’, p 2 ’,…, p n ’, (p 1  p 2  …  p n  q) SUBST( , q) p 1 = Dog(x) p 2 = Own(Bob,x) q = Brown(x) p 1 ’ = Dog(Fido) p 2 ’ = Own(Bob,Fido)  = {x/Fido} SUBST( , q) = Brown(Fido)

ECE457 Applied Artificial Intelligence R. Khoury (2007)Page 26 Inference Example FOL KB  x Dog(x)  Own(Bob,x)  Brown(x) Dog(Fido), Dog(Barky), Dog(Dogbert), Dog(Princess), Dog(Lassie), Dog(K-9) Own(Bob,Fido) Inference with Generalized Modus Ponens Dog(Fido), Own(Bob,Fido), Dog(x)  Own(Bob,x)  Brown(x)  = {x/Fido} Brown(Fido) Requires some form of pattern matching to discover 

ECE457 Applied Artificial Intelligence R. Khoury (2007)Page 27 Unification Unification algorithm takes two sentences p and q Returns the substitutions to make both sentences match, or failure if none is possible UNIFY(p,q) = , where  is the list of substitutions in p and q Find the matching that places the least restrictions on the variables Most general unifier (MGU)

ECE457 Applied Artificial Intelligence R. Khoury (2007)Page 28 Unification Given sentences p and q,  is empty Scan p and q left to right If they disagree on terms r and s If r is a variable If s is a complex term and r occurs in s Fail Else Add r/s to  Else if s is a variable (but r is a complex term) If s occurs in r Fail Else Add s/r to  Else (both r and s are complex term) Apply unification to r and s

ECE457 Applied Artificial Intelligence R. Khoury (2007)Page 29 Unification Rules Function symbols and predicate symbols unify with function symbols and predicate symbols that have identical names and number of arguments Constant symbols can only unify with identical constant symbols Variables can unify with other variables, constant symbols, or function symbols Variables cannot unify with a term in which that variable occurs. x cannot unify with P(x), as that leads to P(P(P(P(…P(x)…)))) That is an occur check error

ECE457 Applied Artificial Intelligence R. Khoury (2007)Page 30 Unification Examples p = Parents(x, Father(x), Mother(Bob)) q = Parents(Bob, Father(Bob), y) Consider first term of each sentence r = Parents(x, Father(x), Mother(Bob)) s = Parents(Bob, Father(Bob), y) Disagreement r and s are predicate symbols with identical names and number of arguments, so unification is possible Unify arguments r = x, s = Bob, x/Bob r = Father(Bob), s = Father(Bob), no substitution r = Mother(Bob), s = y, y/Mother(Bob)  = {x/Bob, y/Mother(Bob)}

ECE457 Applied Artificial Intelligence R. Khoury (2007)Page 31 Unification Examples p = Parents(x, Father(x), Mother(Bob)) q = Parents(Bob, Father(y), z) Unify arguments r = x, s = Bob, x/Bob r = Father(Bob), s = Father(y), y/Bob r = Mother(Bob), s = z, z/Mother(Bob)  = {x/Bob, y/Bob, z/Mother(Bob)}

ECE457 Applied Artificial Intelligence R. Khoury (2007)Page 32 Unification Examples p = Parents(x, Father(x), Mother(Jane)) q = Parents(Bob, Father(y), Mother(y)) Unify arguments r = x, s = Bob, x/Bob r = Father(Bob), s = Father(y), y/Bob r = Mother(Jane), s = Mother(Bob), Fail Fail

ECE457 Applied Artificial Intelligence R. Khoury (2007)Page 33 Unification Exercises p = Parents(x, Father(x), Mother(x)) q = Parents(Bob, SpermDonor(y), Mother(Bob)) Fail p = Parents(x, Father(x), Mother(x)) q = Parents(Anakin, Mother(Anakin)) Fail p = Parents(Bob, x, Mother(y)) q = Parents(Bob, Father(y), Mother(Bob)) {x/Father(Bob), y/Bob} p = Parents(Bob, x, Mother(y)) q = Parents(Bob, Father(x), Mother(Bob)) Fail

ECE457 Applied Artificial Intelligence R. Khoury (2007)Page 34 Forward / Backward Chaining Unification algorithm finds  that unifies (p 1 ’, …, p n ’) and (p 1  …  p n ) Makes Generalized Modus Ponens possible Recall from Propositional Logic Inference using Modus Ponens Either forward chaining or backward chaining We have Generalized Modus Ponens for FOL Inference is possible! Forward chaining or backward chaining

ECE457 Applied Artificial Intelligence R. Khoury (2007)Page 35 Forward / Backward Chaining Forward chaining Data-driven reasoning Start with known symbols Infer new symbols and add to KB Use new symbols to infer more new symbols Repeat until query proven or no new symbols can be inferred Backward chaining Goal-driven reasoning Start with query, try to infer it If there are unknown symbols in the premise of the query, infer them first If there are unknown symbols in the premise of these symbols, infer those first Repeat until query proven or its premise cannot be inferred

ECE457 Applied Artificial Intelligence R. Khoury (2007)Page 36 Resolution Recall from Propositional Logic ) (α  β), (¬β  γ) (α  γ) Resolution rule is both sound and complete Proof by contradiction Convert KB to conjunctive normal form (CNF) Add negation of query Then perform inference until we reach a contradiction resulting from the negated query Reaching contradiction means query is true

ECE457 Applied Artificial Intelligence R. Khoury (2007)Page 37 Resolution Steps 1. Convert problem into FOL KB 2. Convert FOL statements in KB to CNF 3. Add negation of query (in CNF) in KB 4. Use FOL resolution rule to infer new clauses from KB 5. Produce a contradiction that proves our query

ECE457 Applied Artificial Intelligence R. Khoury (2007)Page 38 Conversion to CNF Three new steps (4, 5, 6) & rules in step 3 1. Eliminate biconditionals: (α  β)  ((α  β)  (β  α)) 2. Eliminate implications: (α  β)  (¬α  β) 3. Move/Eliminate negations: ¬(¬α)  α, ¬(α  β)  (¬α  ¬β), ¬(α  β)  (¬α  ¬β), ¬  x P(x)   x ¬P(x), ¬  x P(x)   x ¬P(x) 4. Standardize variables:  x P(x)   x Q(x)   x P(x)   y Q(y) 5. Skolemize:  x P(x)  P(C) 6. Drop universal quantifiers:  x P(x)  P(x) 7. Distribute  over  : (α  (β  γ))  ((α  β)  (α  γ))

ECE457 Applied Artificial Intelligence R. Khoury (2007)Page 39 Conversion to CNF Everyone who loves all animals is loved by someone  x [  y Animal(y)  Love(x,y)]   y Love(y,x)  x ¬[  y Animal(y)  Love(x,y)]   y Love(y,x)  x  y ¬[Animal(y)  Love(x,y)]   y Love(y,x)  x  y ¬Animal(y)  ¬Love(x,y)   y Love(y,x)  x  y ¬Animal(y)  ¬Love(x,y)   z Love(z,x)  x ¬Animal(C 1 )  ¬Love(x,C 1 )  Love(C 2,x) ¬Animal(C 1 )  ¬Love(x,C 1 )  Love(C 2,x)

ECE457 Applied Artificial Intelligence R. Khoury (2007)Page 40 Conversion to CNF There is a book which everyone buys only if there is a class that requires it  x Book(x)  [  y Buy(y,x)]  [  y Class(y)  Requires(y,x)]  x Book(x)  {[  y Buy(y,x)]  [  y Class(y)  Requires(y,x)]}  {[  y Class(y)  Requires(y,x)]  [  y Buy(y,x)]}  x Book(x)  {¬[  y Buy(y,x)]  [  y Class(y)  Requires(y,x)]}  {¬[  y Class(y)  Requires(y,x)]  [  y Buy(y,x)]}  x Book(x)  {[  y ¬Buy(y,x)]  [  y Class(y)  Requires(y,x)]}  {[  y ¬Class(y)  ¬Requires(y,x)]  [  y Buy(y,x)]}  x Book(x)  {  y ¬Buy(y,x)  [  z Class(z)  Requires(z,x)]}  {[  z ¬Class(z)  ¬Requires(z,x)]   y Buy(y,x)} Book(C 1 )  {¬Buy(C 2,C 1 )  [Class(C 3 )  Requires(C 3,C 1 )]}  {[  z ¬Class(z)  ¬Requires(z,C 1 )]   y Buy(y,C 1 )} Book(C 1 )  {¬Buy(C 2,C 1 )  [Class(C 3 )  Requires(C 3,C 1 )]}  {¬Class(z)  ¬Requires(z,C 1 )  Buy(y,C 1 )} Book(C 1 )  [¬Buy(C 2,C 1 )  Class(C 3 )]  [¬Buy(C 2,C 1 )  Requires(C 3,C 1 )]  [¬Class(z)  ¬Requires(z,C 1 )  Buy(y,C 1 )]

ECE457 Applied Artificial Intelligence R. Khoury (2007)Page 41 FOL Resolution ) (α  β’), (¬β  γ) SUBST( , α  γ)  = UNIFY(β’, ¬β) Example Animal(Dog(x))  Love(Bob,x) ¬Love(y,z)  ¬Hunt(y,z)  = {y/Bob, z/x} Animal(Dog(x))  ¬Hunt(Bob,x)

ECE457 Applied Artificial Intelligence R. Khoury (2007)Page 42 Example of Resolution Consider the story Anyone passing their ECE457 exam and winning the lottery is happy. Anyone who studies or is lucky can pass all their exams. Bob did not study but is lucky. Anyone who’s lucky can win the lottery. Is Bob happy?

ECE457 Applied Artificial Intelligence R. Khoury (2007)Page 43 Example of Resolution Convert to FOL Anyone passing their ECE457 exam and winning the lottery is happy.  x Pass(x, ECE457)  Win(x,Lottery)  Happy(x) Anyone who studies or is lucky can pass all their exams.  x  y Study(x)  Lucky(x)  Pass(x,y) Bob did not study but is lucky. ¬Study(Bob)  Lucky(Bob) Anyone who’s lucky can win the lottery.  x Lucky(x)  Win(x,Lottery) Is Bob happy? Happy(Bob)

ECE457 Applied Artificial Intelligence R. Khoury (2007)Page 44 Example of Resolution Convert to CNF  x Pass(x, ECE457)  Win(x,Lottery)  Happy(x)  x ¬(Pass(x, ECE457)  Win(x,Lottery))  Happy(x)  x ¬Pass(x, ECE457)  ¬Win(x,Lottery)  Happy(x) ¬Pass(x, ECE457)  ¬Win(x,Lottery)  Happy(x)  x  y Study(x)  Lucky(x)  Pass(x,y)  x  y ¬(Study(x)  Lucky(x))  Pass(x,y)  x  y (¬Study(x)  ¬Lucky(x))  Pass(x,y) (¬Study(x)  ¬Lucky(x))  Pass(x,y) (¬Study(x)  Pass(x,y))  (¬Lucky(x)  Pass(x,y))

ECE457 Applied Artificial Intelligence R. Khoury (2007)Page 45 Example of Resolution Convert to CNF ¬Study(Bob)  Lucky(Bob)  x Lucky(x)  Win(x,Lottery)  x ¬Lucky(x)  Win(x,Lottery) ¬Lucky(x)  Win(x,Lottery) Negation of query for resolution ¬Happy(Bob)

ECE457 Applied Artificial Intelligence R. Khoury (2007)Page 46 Example of Resolution Content of KB ¬Pass(x 1, ECE457)  ¬Win(x 1,Lottery)  Happy(x 1 ) ¬Study(x 2 )  Pass(x 2,y 1 ) ¬Lucky(x 3 )  Pass(x 3,y 2 ) ¬Study(Bob) Lucky(Bob) ¬Lucky(x 4 )  Win(x 4,Lottery) ¬Happy(Bob)

ECE457 Applied Artificial Intelligence R. Khoury (2007)Page 47 Example of Resolution (¬Pass(x 1, ECE457)  ¬Win(x 1,Lottery)  Happy(x 1 ))  (¬Study(x 2 )  Pass(x 2,y 1 ))  (¬Lucky(x 3 )  Pass(x 3,y 2 ))  ¬Study(Bob)  Lucky(Bob)  (¬Lucky(x 4 )  Win(x 4,Lottery))  ¬Happy(Bob) {x 1 /Bob} (¬Pass(Bob, ECE457)  ¬Win(Bob,Lottery))  (¬Study(x 2 )  Pass(x 2,y 1 ))  (¬Lucky(x 3 )  Pass(x 3,y 2 ))  ¬Study(Bob)  Lucky(Bob)  (¬Lucky(x 4 )  Win(x 4,Lottery))  ¬Happy(Bob) {x 4 /Bob}

ECE457 Applied Artificial Intelligence R. Khoury (2007)Page 48 Example of Resolution (¬Pass(Bob, ECE457)  ¬Lucky(Bob))  (¬Study(x 2 )  Pass(x 2,y 1 ))  (¬Lucky(x 3 )  Pass(x 3,y 2 ))  ¬Study(Bob)  Lucky(Bob)  ¬Happy(Bob) No substitution needed ¬Pass(Bob, ECE457)  (¬Study(x 2 )  Pass(x 2,y 1 ))  (¬Lucky(x 3 )  Pass(x 3,y 2 ))  ¬Study(Bob)  Lucky(Bob)  ¬Happy(Bob) {x 3 /Bob, y 2 /ECE457} ¬Pass(Bob, ECE457)  (¬Study(x 2 )  Pass(x 2,y 1 ))  ¬Lucky(Bob)  ¬Study(Bob)  Lucky(Bob)  ¬Happy(Bob) No substitution needed