1 / 57

CS3243: Introduction to Artificial Intelligence

CS3243: Introduction to Artificial Intelligence. Semester 2, 2017/2018. Inference in First-Order Logic (FOL). AIMA Chapter 9.1 – 9.3, 9.4.1, 9.5.1 – 9.5.3. Outline. Reduction to propositional inference Unification Generalized Modus Ponens Forward chaining Backward chaining Resolution.

connieg
Download Presentation

CS3243: Introduction to Artificial Intelligence

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CS3243: Introduction to Artificial Intelligence Semester 2, 2017/2018

  2. Inference in First-Order Logic (FOL) AIMA Chapter 9.1 – 9.3, 9.4.1, 9.5.1 – 9.5.3

  3. Outline • Reduction to propositional inference • Unification • Generalized Modus Ponens • Forward chaining • Backward chaining • Resolution

  4. Converting from First Order to Propositional Logic • Convert a universal quantifier to a list of propositional rules: becomes • Convert an existential quantifier by adding a new constant (not appearing in KB!) – also known as Skolem constant becomes ; the variable is new.

  5. First Order to Propositional Logic Rules:, , , ,. Atomic sentences (e.g. , ) are now symbols Rules:, , , ,,.

  6. Reduction to Propositional Inference • Every FOL can be propositionalized so as to preserve entailment • A ground sentence is entailed by new KBiff entailed by original KB • Idea:propositionalizeKB and query, apply resolution, return result • Problem: with function symbols, there are infinitely many ground-term substitutions • e.g., • would convert to

  7. Theorem (Herbrand, 1930). If a sentence is entailed by FOL , then it is entailed by a finite subset of the propositionalized Does this remind you of any other algorithm? • Idea: For to do • create a propositionalized by instantiating with depth- terms • see if is entailed by this • What happens if is not entailed? Entailment for FOL is semi-decidable (algorithms exist that say yes to every entailed sentence, but no algorithm exists that also says no to every non-entailed sentence). Similar to the halting problem (Turing, 1936)

  8. Problems with Propositionalization • Generates irrelevant things:Easily implies that … but we will also add the irrelevant • Exponential blowup: a-ary predicate has instantiations with constants. We don’t need all of them!

  9. AIMA uses notation Unification • We can get the inference immediately if we can find a substitution such that and match and Unifier works • outputs a var. substitution s.t. • Standardizing aparteliminates variable name clashes

  10. Unification – Multiple Unifiers • To unify and , or • The first unifier is more general than the second • There is a single most general unifier (MGU) that is unique up to renaming and substitution of variables

  11. Unification Algorithm

  12. Unification Algorithm Given two sentences , find a variable assignment such that • Input: ( is empty at first) • If or if return • If one of the inputs is a variable (say, ), we need to unify a variable with a sentence given . • Otherwise, break up the compound function/list and process their parts recursively.

  13. The UNIFY-VAR function Given a variable , a sentence , and • If has been assigned a value (consult ), return ; if has a value , return . • If appears in return FAIL • If does not appear in return

  14. Unification Example Input:

  15. Generalized Modus Ponens (GMP) • Original Modus Ponens: • Generalized (lifted) Modus Ponens: • There is some substitution such that the premise and the implication are the same (namely ) • … then we can infer that

  16. Generalized Modus Ponens (GMP) These sentences have variables in their universal quantifiers (the elements) • We are given a set of FOL sentences and an implication rule • If there exists some substitution over the variables such that • … then holds!

  17. Soundness of GMP Assume: • there exists a substitution such that for all . • hold, and that We need to prove that holds as well.

  18. s.t.. hold, and Lemma: if then for any substitution Proof: by universal instantiation • By Lemma: • and • We know that • hold, and that • Apply Propositional Logic’s Modus Ponens!

  19. Example KB in FOL “The law says that it is a crime for an American to sell weapons to hostile nations. The country Nono, an enemy of America, has some missiles, and all of its missiles were sold to it by Colonel West, who is American.”

  20. Example KB in FOL “The law says that it is a crime for an American to sell weapons to hostile nations. The country Nono, an enemy of America, has some missiles, and all of its missiles were sold to it by Colonel West, who is American.”

  21. Example KB in FOL “The law says that it is a crime for an American to sell weapons to hostile nations. The country Nono, an enemy of America, has some missiles, and all of its missiles were sold to it by Colonel West, who is American.”

  22. Example KB in FOL “The law says that it is a crime for an American to sell weapons to hostile nations. The country Nono, an enemy of America, has some missiles, and all of its missiles were sold to it by Colonel West, who is American.” Existential Instantiation

  23. Example KB in FOL “The law says that it is a crime for an American to sell weapons to hostile nations. The country Nono, an enemy of America, has some missiles, and all of its missiles were sold to it by Colonel West, who is American.”

  24. Example KB in FOL “The law says that it is a crime for an American to sell weapons to hostile nations. The country Nono, an enemy of America, has some missiles, and all of its missiles were sold to it by Colonel West, who is American.”

  25. Example KB in FOL Additional Facts • Missiles are weapons: • Enemies are hostile:

  26. Example KB in FOL

  27. Example KB in FOL Want to prove that

  28. Forward Chaining Algorithm

  29. Forward Chaining Algorithm • Input: • – a knowledge base coded in FOL • – an FOL sentence • Output: • A variable substitution so that • … or FALSE if no such exists. • At every round, add all newly inferred atomic sentences to . • Repeat until • One of these sentences is • No new sentences can be inferred.

  30. Properties of Forward Chaining • Sound and complete for first-order definite clauses • FC terminates for KB in finite number of iterations if it contains no functions. • May not terminate in general (i.e., with functions) if is not entailed • This is unavoidable: entailment with definite clauses is semidecidable

  31. Inefficiencies of Forward Chaining Matching rules and known facts is costly

  32. Matching Rule Premises to Known Facts is Costly Predicate indexing: constant time to retrieve known facts • : find all facts (e.g., ) that unify with . Conjunct ordering problem: apply minimum-remaining-values heuristic of CSP • e.g., if there are many objects owned by and very few missiles, it may be better to start with conjunct

  33. Inefficiencies of Forward Chaining Redundant rule matching

  34. Redundant Rule Matchings • Incremental forward chaining: Match rule at iteration only if a conjunct in its premise unifies with new fact inferred at iteration • e.g., matches against again in 2nd iteration; but, is already known. • Rete (“Ree-Tee”) algorithm:Instead of discarding partially matched rules, keep track of conjuncts matched against new facts to avoid duplicate work. e.g., is partially matched against in first iteration.

  35. Inefficiencies of Forward Chaining Generating Irrelevant Facts

  36. Backward Chaining Algorithm At least one of the rules in the needs to imply All elements of need to be true

  37. Backward Chaining: Proof Tree Call FOL-BC-OR on and FETCH-RULE on

  38. Backward Chaining: Proof Tree Unify and , result in

  39. Backward Chaining: Proof Tree Call FOL-BC-AND on the list of rules

  40. Backward Chaining: Proof Tree gets unified with in the with existing substitution

  41. Backward Chaining: Proof Tree gets unified with in the with existing substitution

  42. Backward Chaining: Proof Tree We call FOL-BC-OR on and fetch the rule

  43. Backward Chaining: Proof Tree Unifying we get

  44. Backward Chaining: Proof Tree Unify on and outputs .

  45. Backward Chaining: Proof Tree Fetch UNIFY to get and

  46. Backward Chaining: Proof Tree no contradiction with so we are good!

  47. Backward Chaining: Proof Tree Fetch UNIFY to get

  48. Backward Chaining: Proof Tree UNIFY with , get no contradiction with current assignment to .

  49. Properties of Backward Chaining • Depth-first search: space is linear in size of proof • Incomplete due to infinite loops: fix by checking current goal against every goal on stack • Inefficient due to repeated subgoals (both success and failure): fix by caching solutions to previous subgoals • Widely used for logic programming

More Related