1 / 37

Expert Systems

Expert Systems. Using First Order Logic. Outline. Syntax & Semantics Examples Wumpus World Example. Syntax. Constants: 2, apple, .. Predicates: >, <, Brother … Functions: Sqrt, Max, .. Variables: x, y, a , b, ... Connectives: ,, , =>, <=> Equality: = Quantifiers: , .

abel-spence
Download Presentation

Expert Systems

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. Expert Systems Using First Order Logic

  2. Outline • Syntax & Semantics • Examples • Wumpus World Example

  3. Syntax • Constants: 2, apple, .. • Predicates: >, <, Brother … • Functions: Sqrt, Max, .. • Variables: x, y, a , b, ... • Connectives: ,,, =>, <=> • Equality: = • Quantifiers: , 

  4. Atomic Sentences • Atomic Sentence = • predicate(Term1, … , Termn) • or term1 = term2 • Term = • function(term1, …, termn) • or constant or variable • e.g. • Sqrt(x) > min( x, 1/x)

  5. Complex Sentences • made from atomic sentences using connectives • ( S1), S1  S2… • e.g. Brother( John, Richard) => • Brother( Richard, John)

  6. Truth in first-order logic • Sentences are true or false with respect to a model and an interpretation • Model has objects and relations among them • Interpretation maps • constant symbols -> objects • predicate symbols -> relations • function symbols -> functional relations

  7. Universal Quantification •  <variables> <sentence> • Everyone at Massey is smart •  x At(x, Massey) => Smart(x) • The FOR_ALL x is actually a shorthand for writing all possible instantiations of x • e.g. At(Chris, Massey)=>Smart(Chris)AND At(John, Massey)=>Smart(John)

  8. Existential Quantification •  <variables> <sentence> • Someone at Auckland is smart •  x At(x, Auckland) => Smart(x) • The THERE_EXISTS x is a shorthand for writing all possible instantiations of x • e.g. At(Alan, Auckland)=>Smart(Alan)OR At(Jack, Auckland)=>Smart(Jack)

  9. Properties of Quantifiers •  x  y • same as  y  x •  x  y • same as  y  x •  x  y • NOT same as  y  x

  10. Quantifier Duality • FOR_ALL can be expressed as a THERE_EXISTS and vice-versa • FOR_ALL x Likes(x, IceCream) •  x  Likes(x, IceCream) • THERE_EXISTS x Likes(x, broccoli) •  x  Likes(x, broccoli)

  11. Examples • Brothers are siblings • Sibling is reflexive • One’s mother is one’s female parent

  12. Equality • term1 = term2 under a given interpretation if and only if term1 and term2 refer to the same object • In this way it is possible to restrict the number of possible labels for the same object • FOR_ALL x, y P(x) AND P(y) => x = y

  13. FOL KB Overview • Diagnostic Rules • Causal Rules • Effect Axioms • Frame Problem • Qualification Problem • Ramification Problem

  14. FOL Knowledge Bases • Additional facts added • TELL( KB, Percept[S, B, NG]) • smell, breeze & no glitter • Query Knowledge base • ASK(KB, THERE_EXIST a, Action(a)) • ASK(KB, S) returns some or all substitutions (sigma) so that KB |= S/sigma

  15. Deduction • Hidden properties deduced by diagnostic and causal rules • Diagnostic rule:- infer cause from effect • FOR_ALL y Breezy(y) => • THERE_EXIST x, Pit(x) AND Adjacent(x,y) • Causal rule:- infer effect from cause • FOR_ALL x,y Pit(x) AND Adjacent(x,y) => • Breezy(y)

  16. Situation Calculus • Facts often only hold at some time • SC:- add a time argument to each non eternal argument • Holding(Gold, now) • Situations connected by results of actions • s1=Result (a, s0),result of action a applied to s0

  17. Changing states

  18. Describing Actions • Effect axioms • FOR_ALL s AtGold(s) AND a=grab => • Holding(Gold, Result(Grab,s)) • Frame axioms, describe no changes • FOR_ALL s HoldingGold(s) AND a=grab => • Holding(Gold, Result(Grab,s))

  19. Describing Action Cont • Frame problem:- • find elegant way to handle non changes • representation- avoid frame axioms • inference- avoid repeated copy overs • Qualification problem:- • realistic descriptions require endless additional details • Ramification problem:- • realistic problems have endless secondary consequences

  20. Successor state axioms • Each axiom about a predicate • P true afterwards <=> • [an action made P true OR • [P already true AND no action made P false]] • FOR_ALL a, s Holding(Gold, Result(a,s)) <=> • [(a=Grab AND AtGold(s)) OR • [Holding(Gold,s) AND a != Release]]

  21. Making Plans • Initial Conditions:- At(Agent, [1,1], s0) • At(Gold, [1,2], s0) • Query: • ASK(KB,  s Holding(Gold,s)) • Answer: • {s/Result(Grab, Result(Forward,s0))}

  22. Plans Extended • Plans are action sequences [a1, a2, .., an] • PlanResult(p,s) • is the result of executing p in s • Query: • ASK(KB,  p • Holding(Gold,PlanResult(p,s0)) • Answer • {p/ [Forward, Grab]}

  23. Summary • FOL • objects and relations are semantic primitives • syntax: constants, functions, predicates, equality and quantifiers • Situation calculus • actions and change in FOL • planning as inference on a situation calculus knowledge base

  24. Inference • Proofs • Unification • Generalized Modus Ponens • Forward and Backward chaining

  25. Proofs • Sound Inference: • find alpha such that KB |= alpha • Proof process is search, operators are inference rules

  26. Inference Rules • Modus Ponens:- • alpha, alpha => beta / beta • And Introduction:- • alpha, beta / alphabeta • Universal Elimination: •  x alpha / alpha{x/ t}

  27. Inference Rules cont. • Existential Elimination:- •  x alpha / alpha{x/ t’} • Existential Introduction • alpha /  x alpha{ t/x}

  28. Example Proof • Bob is a buffalo:- • 1. Buffalo(Bob) • Pat is a Pig:- • 2. Pig(Pat) • Buffaloes outrun pigs:- • 3.  x, y Buffalo(x)  Pig(y) => Faster(x,y) • Bob outruns Pat

  29. Example cont • And Introduction (1 & 2 ):- • 4. Buffalo(Bob)  Pig(Pat) • Universal Elimination (3), {x/Bob, y/Pat} • 5. Buffalo(Bob)  Pig(Pat) => Faster(Bob, Pat) • Modus Ponens (6&7):- • Faster(Bob, Pat)

  30. Search with primitive inference rules • Operators are inference rules • States are sets of sentences • Goal test checks state to see if it contains query sentence • AI, UE, MP is a common inference pattern • Problem:- a huge branching factor especially for UE • NEED a substitution that makes the rule premise match some known facts

  31. Unification • A substitution sigma unifies atomic sentences p and q if p/sigma = q/sigma p Knows(John, x) Knows(John, x) Knows(John, x) q Knows(John, Jane) Knows(y,Jane) Knows(y, Mother(y)) sigma

  32. Generalised Modus Ponens • p1’, p2’, … pn’, (p1 p2 ….  Pn => q) • --------------------------------------------- • q/ sigma • where pi’/ sigma = pi/ sigma • GMP used with KB of definite clauses: • a single atomic sentence • (conjunction of atomic sentences) => • (atomic sentence)

  33. Example • p1’ = Faster(Bob, Pat), • p2’ = Faster(pat,Steve) • p1  p2 => q = • Faster(x, y)  Faster(y, z) => Faster(x,z) • sigma = {x/Bob, y/Pat, z/Steve} • q/sigma = Faster(Bob, Steve)

  34. Forward Chaining • When a new fact p is added to KB • for each rule that p unifies with a premise • if other premises are known then add the conclusion to KB and continue chaining • Forward chaining is data driven • inferring properties and categories from percepts

  35. Forward chaining example • 1. Buffalo(x)  Pig(y) => Faster(x,y) • 2. Pig (y)  Slug(z) => Faster(y,z) • 3. Faster(x, y)  Faster(y, z) => Faster(x,z) • 4. Buffalo(Bob) [1a, x] • 5. Pig(Pat) [1b, ][2a, x] -> • 6. Faster(Bob, Pat) [3a,x], [3b,x] • 7. Slug(Steve)[2b, ]-> • 8. Faster (pat, Steve) [3a, x][3b, ]-> • Faster(Bob, Steve) [3a,x][3b,x]

  36. Backward chaining • When a query q is added to KB • If a matching fact q’ is known, return the unifier • for each rule whose consequent q’ matches q • attempt to prove each premise by backward chaining • Backward chaining is query driven • can try to find one solution or all solutions • Basis of logic programming, e.g. Prolog

  37. Faster( y, z) 1 2 Pig(y) Slug(z) Slimy(z) Creeps(z) Backward chaining example • 1. Pig(y)  Slug(z) => Faster(y,z) • 2. Slimy(z)  Creeps(z) => Slug(z) • 3. Pig(Pat) 4. Slimy(Steve) 5.Creeps(Steve) {y/Pat, Z/Steve} {z/Steve} 3 {y/Pat} 4 {z/Steve} 5 {z/Steve}

More Related