1 / 55

CS 541: Artificial Intelligence

CS 541: Artificial Intelligence. Lecture V: Inference First Order Logic. Re-cap of Lecture IV – Part I. Logical agents apply inference to a knowledge base to derive new information and make decisions Basic concepts of logic: Syntax : formal structure of sentences

seanna
Download Presentation

CS 541: 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. CS 541: Artificial Intelligence Lecture V: Inference First Order Logic

  2. Re-cap of Lecture IV – Part I • Logical agents apply inference to a knowledge base to derive new information and make decisions • Basic concepts of logic: • Syntax: formal structure of sentences • Semantics: truth of sentences wrt models • Entailment: necessary truth of one sentence given another • Inference: deriving sentences from other sentences • Soundness: derivations produce only entailed sentences • Completeness: derivations can produce all entailed sentences • Wumpus world requires the ability to represent partial and negated information, reason by cases, etc. • Forward, backward chaining are linear-time, complete for Horn clauses • Resolution is complete for propositional logic • Propositional logic lacks expressive power

  3. Re-cap of Lecture IV – Part II • First-order logic: • Objects and relations are semantic primitives • Syntax: constants, functions, predicates, equality, quantiers • Increased expressive power: sufficient to define wumpus world • Situation calculus: • Conventions for describing actions and change in FOL • Can formulate planning as inference on a situation calculus KB

  4. Inference in First-Order Logic Lecture IV

  5. Outline • Reducing first-order inference to propositional inference • Unification • Generalized Modus Ponens • Forward and backward chaining • Logic programming • Resolution

  6. 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 Godelcomplete algorithm for FOL • 1930 Herbrand complete algorithm for FOL (reduce to propositional) • 1931 Godelcomplete algorithm for arithmetic • 1960 Davis/Putnam “practical” algorithm for propositional logic • 1965 Robinson “practical” algorithm for FOL|resolution

  7. Reducing first-order inference to propositional inference

  8. Universal instantiation (UI) • Every instantiation of a universally quantified sentence is entailed by it: for any variable and ground term • E.g., yields

  9. Existential instantiation (EI) • For any sentence , variable , and constant symbol that does not appear elsewhere in the knowledge base: • E.g., yields provided that is a new constant symbol, called a Skolem constant • Another example: from we obtain provided is a new constant symbol

  10. Instantiation • Universal Instantiation (UI) can be applied several times to add new sentences • The new KB is logically equivalent to the old • Existential instantiation (EI) can be applied once to replace the existential sentence; • The new KB is not equivalent to the old, but is satisfiableiff the old KB was satisfiable

  11. Reduction to propositional inference • Suppose the KB contains just the following: • Instantiating the universal sentence in all possible ways, we have • The new KB is propositionalized: proposition symbols are , , , etc.

  12. Reduction to propositional inference • Claim: a ground sentence is entailed by new KB iff it is 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., • 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 to do • Create a propositional KB by instantiating with depth- terms • Check 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

  13. Problems with propositionalization • Propositionalization seems to generate lots of irrelevant sentences • E.g. from • It seems obvious that , but propositionalization produces lots of facts such as that are irrelevant • With -ary predicates and constants there are instantiations • With function symbols, it gets much much worse!!

  14. Unification

  15. Unification • We can get the inference immediately if we can find a substitution such that and match and • works • if

  16. Unification • We can get the inference immediately if we can find a substitution such that and match and • works • if

  17. Unification • We can get the inference immediately if we can find a substitution such that and match and • works • if

  18. Unification • We can get the inference immediately if we can find a substitution such that and match and • works • if • Standardizing apart eliminates overlap of variables, e.g.,

  19. Generalized Modus Ponens

  20. Generalized Modus Ponens (GMP) • where for all • is is • is is • is is • is • GMP used with KB of definite clauses (exactly one positive literal) • All variables assumed universally quantified

  21. Soundness of GMP • Need to show that provided that for all • Lemma: For any definite clause , we have by UI • from the above two, follows by ordinary Modus Ponens

  22. Example knowledge base • … it is a crime for an American to sell weapons to hostile nations:

  23. Example knowledge base • … it is a crime for an American to sell weapons to hostile nations:

  24. Example knowledge base • … it is a crime for an American to sell weapons to hostile nations: • Nono… has some missiles

  25. Example knowledge base • … it is a crime for an American to sell weapons to hostile nations: • Nono … has some missiles • and • All of its missiles were sold to it by Colonel West

  26. Example knowledge base • … it is a crime for an American to sell weapons to hostile nations: • Nono … has some missiles • and • All of its missiles were sold to it by Colonel West • Missiles are weapons:

  27. Example knowledge base • … it is a crime for an American to sell weapons to hostile nations: • Nono … has some missiles • and • All of its missiles were sold to it by Colonel West • Missiles are weapons: • An enemy of America counts as “hostile”:

  28. Example knowledge base • … it is a crime for an American to sell weapons to hostile nations: • Nono … has some missiles • and • All of its missiles were sold to it by Colonel West • Missiles are weapons: • An enemy of America counts as “hostile”: • West, who is American … • The country Nono, an enemy of America …

  29. Forward and backward chaining

  30. Forward chaining algorithm

  31. Forward chaining proof

  32. Forward chaining proof

  33. Forward chaining proof

  34. Properties of forward chaining • Sound and complete for first-order definite clauses • (proof similar to propositional proof) • Datalog = first-order definite clauses + no functions (e.g., crime KB) • FC terminates for Datalog in poly iterations: at most literals • May not terminate in general if is not entailed • This is unavoidable: entailment with definite clauses is semidecidable

  35. Efficiency of forward chaining • Simple observation: • No need to match a rule on iteration k if a premise wasn't added on iteration k-1, match each rule whose premise contains a newly added literal • Matching itself can be expensive • Database indexing allows O(1) retrieval of known facts, e.g., query Missile(x) retrieves Missile(M1) • Matching conjunctive premises against known facts is NP-hard • Forward chaining is widely used in deductive databases

  36. Hard matching example • Colorable() is inferred iff the CSP has a solution • CSPs include 3SAT as a special case • hence matching is NP-hard

  37. Backward chaining algorithm

  38. Backward chaining example

  39. Backward chaining example

  40. Backward chaining example

  41. Backward chaining example

  42. Backward chaining example

  43. Backward chaining example

  44. Backward chaining example

  45. Properties of backward chaining • Depth-first recursive proof 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 using caching of previous results (extra space!) • Widely used (without improvements!) for logic programming

  46. Logic programming

  47. Logic programming • Sound bite: computation as inference on logical KBs • Logic programming Ordinary programming • 1. Identify problem Identify problem • 2. Assemble information Assemble information • 3. Tea break Figure out solution • 4. Encode information in KB Program solution • 5. Encode problem instance as facts Encode problem instance as data • 6. Ask queries Apply program to data • 7. Find false facts Debug procedural errors • Should be easier to debug Capital(NewYork, US) than x:=x+2 !

  48. Prolog systems • Basis: backward chaining with Horn clauses + bells & whistles • Widely used in Europe, Japan (basis of 5th Generation project) • Compilation techniques approaching a billion LIPS • Program = set of clauses = head :- literal1, … literaln. • criminal(X) :- american(X), weapon(Y), sells(X,Y,Z), hostile(Z). • Efficient unification by open coding • Efficient retrieval of matching clauses by direct linking • Depth-first, left-to-right backward chaining • Built-in predicates for arithmetic etc., e.g., X is Y*Z+3 • Closed-world assumption (“negation as failure”) • e.g., given alive(X) :- not dead(X). • alive(joe) succeeds if dead(joe) fails

  49. Prolog examples • Depth-rst search from a start state X: • dfs(X) :- goal(X). • dfs(X) :- successor(X,S),dfs(S). • No need to loop over S: successor succeeds for each • Appending two lists to produce a third: • append([],Y,Y). • append([X|L],Y,[X|Z]) :- append(L,Y,Z). • query: append(A,B,[1,2]) ? • answers: A=[] B=[1,2] • A=[1] B=[2] • A=[1,2] B=[]

  50. Resolution

More Related