logical agents
play

Logical Agents CE417: Introduction to Artificial Intelligence - PowerPoint PPT Presentation

Logical Agents CE417: Introduction to Artificial Intelligence Sharif University of Technology Spring 2018 Soleymani Artificial Intelligence: A Modern Approach , 3 rd Edition, Chapter 7 Wumpus world Wumpus Pitts Gold Wumpus


  1. Entailment by enumeration (model checking) function π‘ˆπ‘ˆ_πΉπ‘‚π‘ˆπ΅π½π‘€π‘‡? (𝐿𝐢, 𝛽) returns 𝑒𝑠𝑣𝑓 or π‘”π‘π‘šπ‘‘π‘“ inputs : 𝐿𝐢 , the knowledge base, a sentence in propositional logic 𝛽 , the query, a sentence in propositional logic π‘‘π‘§π‘›π‘π‘π‘šπ‘‘ ← a list of the proposition symbols in 𝐿𝐢 and 𝛽 return π‘ˆπ‘ˆ_𝐷𝐼𝐹𝐷𝐿_𝐡𝑀𝑀(𝐿𝐢, 𝛽 , π‘‘π‘§π‘›π‘π‘π‘šπ‘‘, {}) function π‘ˆπ‘ˆ_𝐷𝐼𝐹𝐷𝐿_𝐡𝑀𝑀(𝐿𝐢, 𝛽, π‘‘π‘§π‘›π‘π‘π‘šπ‘‘, π‘›π‘π‘’π‘“π‘š) returns 𝑒𝑠𝑣𝑓 or π‘”π‘π‘šπ‘‘π‘“ if πΉπ‘π‘„π‘ˆπ‘? ( π‘‘π‘§π‘›π‘π‘π‘šπ‘‘) then if 𝑄𝑀_π‘ˆπ‘†π‘‰πΉ? (𝐿𝐢, π‘›π‘π‘’π‘“π‘š) then return 𝑄𝑀_π‘ˆπ‘†π‘‰πΉ? (𝛽, π‘›π‘π‘’π‘“π‘š) else return 𝑒𝑠𝑣𝑓 else 𝑄 ← πΊπ½π‘†π‘‡π‘ˆ(π‘‘π‘§π‘›π‘π‘π‘šπ‘‘) 𝑠𝑓𝑑𝑒 ← π‘†πΉπ‘‡π‘ˆ(π‘‘π‘§π‘›π‘π‘π‘šπ‘‘) return π‘ˆπ‘ˆ_𝐷𝐼𝐹𝐷𝐿_𝐡𝑀𝑀(𝐿𝐢, 𝛽, 𝑠𝑓𝑑𝑒, π‘›π‘π‘’π‘“π‘šβ‹ƒ{𝑄 = 𝑒𝑠𝑣𝑓}) and π‘ˆπ‘ˆ_𝐷𝐼𝐹𝐷𝐿_𝐡𝑀𝑀(𝐿𝐢, 𝛽, 𝑠𝑓𝑑𝑒, π‘›π‘π‘’π‘“π‘šβ‹ƒ{𝑄 = π‘”π‘π‘šπ‘‘π‘“}) 33

  2. Entailment by enumeration: properties  Depth-first enumeration of all models is sound and complete (when finite models).  For π‘œ symbols, time complexity is 𝑃(2 π‘œ ) , space complexity is 𝑃(π‘œ) . 34

  3. Satisfiability  A sentence is satisfiable if it is true in some models  e.g., 𝑄 οƒš 𝑅  Determining the satisfiability of sentences in propositional logic (SAT problem) is NP-complete  Satisfiability and validity are connected.  𝛽 is valid or tautology iff ¬𝛽 is unsatisfiable.  𝛽 is satisfiable iff ¬𝛽 is not valid. 𝛽 ⊨ 𝛾 iff ( 𝛽 ∧ ¬𝛾) is unsatisfiable Proof by contradiction 35

  4. The DPLL (Davis, Putnam, Logemann, Loveland) algorithm  Improvements over truth table enumeration (simple DFS):  Early termination  A clause is true if any literal is true.  A sentence is false if any clause is false.  Pure symbol heuristic  Pure symbol: always appears with the same "sign" in all clauses.  e.g., In (𝐡 οƒšοƒ˜ 𝐢) ∧ (¬𝐢 οƒš οƒ˜ 𝐷) ∧ (𝐷 οƒš 𝐡) , 𝐡 and 𝐢 are pure, 𝐷 is impure.  Make a pure symbol literal true.  In determining purity, we can ignore clauses already known to be true  Unit clause heuristic Unit clause: all literals except to one already assigned false by model.   The only literal in a unit clause will be assigned true.  Many tricks can be used to enable SAT solvers to scale up. 36

  5. The DPLL algorithm Determining satisfiability of an input propositional logic sentence (in CNF) 37

  6. Entailment by using inference rule  Propositional theorem proving  Searching proofs can be more efficient than model checking.  Can ignore irrelevant propositions.  When the number of models is large but the length of proof is short, entailment by theorem proving is useful. 38

  7. Inference rules  Some samples:  Modus Ponens: Ξ±β‡’Ξ², Ξ± Ξ²  And elimination: π›½βˆ§π›Ύ 𝛾 𝛽⇔𝛾  Biconditional elimination: (𝛽⇒𝛾)∧(𝛾⇒𝛽) 39

  8. Valid implication  Deduction theorem: 𝛽 ⊨ 𝛾 iff 𝛽 β‡’ 𝛾 is valid.  Every valid implication describes a legitimate inference.  Modus Ponens: Ξ±β‡’Ξ², Ξ± is equivalent to valid implication Ξ² Ξ± β‡’ Ξ² ∧ Ξ± β‡’ Ξ² is valid   All logical entailments can be used as inference rules. 40

  9. Logical equivalence  Using logical equivalence we can find many inference rules  Two sentences are logically equivalent iff they are true in the same models 𝛽 ≑ 𝛾 iff 𝛽 ⊨ 𝛾 and 𝛾 ⊨ 𝛽 41

  10. Example of inference  𝑆 1 : οƒ˜ 𝑄 1,1  𝑆 2 : 𝐢 1,1 ⇔ 𝑄 1,2 ∨ 𝑄 2,1  𝑆 3 : 𝐢 2,1 ⇔ 𝑄 1,1 ∨ 𝑄 2,2 ∨ 𝑄 3,1  𝑆 4 : οƒ˜ 𝐢 1,1  𝑆 5 : 𝐢 2,1  Can we infer from 𝑆 1 through 𝑆 5 to prove οƒ˜ 𝑄 1,2 ? [biconditional elim. to 𝑆 2 ]  𝑆 6 : 𝐢 1,1 β‡’ 𝑄 1,2 ∨ 𝑄 2,1 ∧ 𝑄 1,2 ∨ 𝑄 2,1 β‡’ 𝐢 1,1 [and elim. to 𝑆 6 ]  𝑆 7 : 𝑄 1,2 ∨ 𝑄 2,1 β‡’ 𝐢 1,1 [ (𝑄 β‡’ 𝑅) ≑ (¬𝑅 β‡’ ¬𝑄) ]  𝑆 8 : ¬𝐢 1,1 β‡’ Β¬ 𝑄 1,2 ∨ 𝑄 2,1 [Modus Ponens with 𝑆 8 and 𝑆 4 ]  𝑆 9 : Β¬ 𝑄 1,2 ∨ 𝑄 2,1 [De Morgan ’ rule]  𝑆 10 : ¬𝑄 1,2 ∧ ¬𝑄 2,1 42

  11. Finding a proof as a search problem  π½π‘‚π½π‘ˆπ½π΅π‘€_π‘‡π‘ˆπ΅π‘ˆπΉ : the initial knowledge base  π΅π·π‘ˆπ½π‘ƒπ‘‚π‘‡ : all inference rules applied to all the sentences that match their top line  π‘†πΉπ‘‡π‘‰π‘€π‘ˆ : add the sentence in the bottom line of the used inference rule to the current ones  𝐻𝑃𝐡𝑀 : a state containing the sentence we are trying to prove. 43

  12. Monotonicity property  The set of entailed sentences can only grow as information is added to 𝐿𝐢 .  Inference rules can be applied where premises are found in KB (regardless of what else is in KB)  If 𝐿𝐢 ⊨ 𝛽 then 𝐿𝐢 ∧ 𝛾 ⊨ 𝛽 (for any 𝛽 and 𝛾 )  The assertion 𝛾 can not invalidate any conclusion 𝛽 already inferred. 44

  13. Resolution  Inference rules are sound.  Is a set of rules complete?  Are the available inference rules adequate?  Resolution: a single inference rule that yields a complete inference algorithm (when couples with any complete search algorithm). 45

  14. Resolution  U nit resolution: π‘š 𝑗 and 𝑛 are complementary literals π‘š 1 ∨ π‘š 2 ∨ β‹― ∨ π‘š 𝑙 , 𝑛 π‘š 1 ∨ … ∨ π‘š π‘—βˆ’1 ∨ π‘š 𝑗+1 ∨ β‹― ∨ π‘š 𝑙  Full resolution rule: π‘š 𝑗 and 𝑛 π‘˜ are complementary literals π‘š 1 ∨ π‘š 2 ∨ β‹― ∨ π‘š 𝑙 , 𝑛 1 ∨ 𝑛 2 ∨ β‹― ∨ 𝑛 π‘œ π‘š 1 ∨ … ∨ π‘š π‘—βˆ’1 ∨ π‘š 𝑗+1 ∨ β‹― ∨ π‘š 𝑙 ∨ 𝑛 1 ∨ … ∨ 𝑛 π‘˜βˆ’1 ∨ 𝑛 π‘˜+1 ∨ β‹― ∨ 𝑛 π‘œ  It resolution rule sound.Why?  A resolution-based theorem prover can (for any sentences 𝛽 and 𝛾 in propositional logic) decide whether 𝛽 ⊨ 𝛾  Is 𝛽 ∧ ¬𝛾 unsatisfiable?  CNF (Conjunctive Normal Form) 46

  15. CNF Grammar π·π‘‚πΊπ‘‡π‘“π‘œπ‘’π‘“π‘œπ‘‘π‘“ β†’ π·π‘šπ‘π‘£π‘‘π‘“ 1 ∧ β‹― ∧ π·π‘šπ‘π‘£π‘‘π‘“ π‘œ π·π‘šπ‘π‘£π‘‘π‘“ β†’ π‘€π‘—π‘’π‘“π‘ π‘π‘š 1 ∨ β‹― ∨ π‘€π‘—π‘’π‘“π‘ π‘π‘š 𝑛 π‘€π‘—π‘’π‘“π‘ π‘π‘š β†’ π‘‡π‘§π‘›π‘π‘π‘š | Β¬π‘‡π‘§π‘›π‘π‘π‘š π‘‡π‘§π‘›π‘π‘π‘š β†’ 𝑄 𝑅 𝑆 | … 47

  16. Example of resolution 𝑄 1,1 ∨ 𝑄 3,1 , ¬𝑄 1,1 ∨ ¬𝑄 2,2 𝑄 3,1 ∨ ¬𝑄 2,2 48

  17. Resolution algorithm  To show 𝐿𝐢 ⊨ 𝛽 , we show 𝐿𝐢 ∧ ¬𝛽 is unsatisfiable function PL-RESOLUTION(KB, Ξ± ) returns 𝑒𝑠𝑣𝑓 or π‘”π‘π‘šπ‘‘π‘“ input : 𝐿𝐢 , the knowledge base (a sentence in propositional logic) 𝛽, the query (a sentence in propositional logic) π‘‘π‘šπ‘π‘£π‘‘π‘“π‘‘ ← the set of clauses in the CNF representation of 𝐿𝐢  ¬𝛽 π‘œπ‘“π‘₯ ← {} loop do for each pair of clauses 𝐷 𝑗 , 𝐷 π‘˜ in π‘‘π‘šπ‘π‘£π‘‘π‘“π‘‘ do π‘ π‘“π‘‘π‘π‘šπ‘€π‘“π‘œπ‘’π‘‘ ← 𝑄𝑀_π‘†πΉπ‘‡π‘ƒπ‘€π‘ŠπΉ (𝐷𝑗, 𝐷 π‘˜ ) if π‘ π‘“π‘‘π‘π‘šπ‘€π‘“π‘œπ‘’π‘‘ contains the empty clause then return 𝑒𝑠𝑣𝑓 π‘œπ‘“π‘₯ ← π‘œπ‘“π‘₯ βˆͺ π‘ π‘“π‘‘π‘π‘šπ‘€π‘“π‘œπ‘’π‘‘ if π‘œπ‘“π‘₯ βŠ† π·π‘šπ‘π‘£π‘‘π‘“π‘‘ then return π‘”π‘π‘šπ‘‘π‘“ π‘‘π‘šπ‘π‘£π‘‘π‘“π‘‘ ← π‘‘π‘šπ‘π‘£π‘‘π‘“π‘‘ βˆͺ π‘œπ‘“π‘₯ 49

  18. Resolution algorithm  To show 𝐿𝐢 ⊨ 𝛽 , we show 𝐿𝐢 ∧ ¬𝛽 is unsatisfiable function PL-RESOLUTION(KB, Ξ± ) returns 𝑒𝑠𝑣𝑓 or π‘”π‘π‘šπ‘‘π‘“ input : 𝐿𝐢 , the knowledge base (a sentence in propositional logic) 𝛽, the query (a sentence in propositional logic) π‘‘π‘šπ‘π‘£π‘‘π‘“π‘‘ ← the set of clauses in the CNF representation of 𝐿𝐢  ¬𝛽 π‘œπ‘“π‘₯ ← {} loop do for each pair of clauses 𝐷 𝑗 , 𝐷 π‘˜ in π‘‘π‘šπ‘π‘£π‘‘π‘“π‘‘ do Each pair containing complementary literals is resolved and the resulted clause is added to the set if it is not already present. π‘ π‘“π‘‘π‘π‘šπ‘€π‘“π‘œπ‘’π‘‘ ← 𝑄𝑀_π‘†πΉπ‘‡π‘ƒπ‘€π‘ŠπΉ (𝐷𝑗, 𝐷 π‘˜ ) if π‘ π‘“π‘‘π‘π‘šπ‘€π‘“π‘œπ‘’π‘‘ contains the empty clause then return 𝑒𝑠𝑣𝑓 The process continues until one of these happens: π‘œπ‘“π‘₯ ← π‘œπ‘“π‘₯ βˆͺ π‘ π‘“π‘‘π‘π‘šπ‘€π‘“π‘œπ‘’π‘‘ No new clauses ( 𝐿𝐢 ⊭ 𝛽 ) - if π‘œπ‘“π‘₯ βŠ† π·π‘šπ‘π‘£π‘‘π‘“π‘‘ then return π‘”π‘π‘šπ‘‘π‘“ - Two clauses resolve to yield the empty clause ( 𝐿𝐢 ⊨ 𝛽 ) π‘‘π‘šπ‘π‘£π‘‘π‘“π‘‘ ← π‘‘π‘šπ‘π‘£π‘‘π‘“π‘‘ βˆͺ π‘œπ‘“π‘₯ Sound and complete inference algorithm 50

  19. Resolution example 𝐢 1,1  𝑄 1,2 οƒš 𝑄 2,1 οƒ™οƒ˜ 𝐢 1,1 𝐿𝐢 = OK? 𝛽 = ¬𝑄 1,2  Convert 𝐿𝐢 ∧ ¬𝛽 into CNF ( οƒ˜ 𝐢 1,1 οƒš 𝑄 1,2 οƒš 𝑄 2,1 )  ( οƒ˜ 𝑄 1,2 οƒš 𝐢 1,1 )  ( οƒ˜ 𝑄 2,1 οƒš 𝐢 1,1 )  ( οƒ˜ 𝐢 1,1 ) οƒ™οƒ˜ 𝑄 1,2 Contradiction 51

  20. Completeness of resolution  Resolution closure 𝑆𝐷(𝑇) : a set of clauses derivable by repeated application of resolution rule to clauses in 𝑇 or their derivatives.  𝑆𝐷(𝑇) is finite. Thus 𝑄𝑀_ onstructed out of 𝑄 1 , 𝑄 2 , … , 𝑄 𝑙 that appear in 𝑇 . π‘†πΉπ‘‡π‘ƒπ‘€π‘‰π‘ˆπ½π‘ƒπ‘‚ terminates.  Finite distinct clauses can be c  Ground resolution theorem: If a set of clauses 𝑇 is unsatisfiable then 𝑆𝐷(𝑇) contains the empty clause.  If 𝑆𝐷(𝑇) does not contain the empty clause, we can find an assignment of values to the symbols that satisfies 𝑆𝐷(𝑇) and thus 𝑇 52

  21. Horn clauses & definite clauses  Some real-world KBs satisfy restrictions on the form of sentences  We can use more restricted and efficient inference algorithms  Definite clause: a disjunction of literals of which exactly one is positive literal. 1 ∨ ¬𝑄 2 ∨ … ∨ ¬𝑄 𝑙 ∨ 𝑄 𝑙+1 ⇔ (𝑄 1 ∧ 𝑄 2 ∧ … ∧ 𝑄 𝑙 ) β‡’ 𝑄 𝑙+1 ¬𝑄  Horn clause: a disjunction of literals of which at most one is positive literal.  Closed under resolution 53

  22. Grammar π‘‡π‘§π‘›π‘π‘π‘š β†’ 𝑄 𝑅 𝑆 | … πΌπ‘π‘ π‘œπ·π‘šπ‘π‘£π‘‘π‘“ β†’ πΈπ‘“π‘”π‘—π‘œπ‘—π‘’π‘“π·π‘šπ‘π‘£π‘‘π‘“ | π»π‘π‘π‘šπ·π‘šπ‘π‘£π‘‘π‘“ πΈπ‘“π‘”π‘—π‘œπ‘—π‘’π‘“π·π‘šπ‘π‘£π‘‘π‘“ β†’ π‘‡π‘§π‘›π‘π‘π‘š 1 ∧ β‹― ∧ π‘‡π‘§π‘›π‘π‘π‘š π‘š β‡’ π‘‡π‘§π‘›π‘π‘π‘š π»π‘π‘π‘šπ·π‘šπ‘π‘£π‘‘π‘“ β†’ (π‘‡π‘§π‘›π‘π‘π‘š 1 ∧ β‹― ∧ π‘‡π‘§π‘›π‘π‘π‘š π‘š ) β‡’ πΊπ‘π‘šπ‘‘π‘“ 54

  23. Forward and backward chaining  Inference with Horn clauses can be done through forward chaining or backward chaining.  These algorithms are very natural and run in time that is linear in the size of KB.  They are bases of logic programming  Prolog: backward chaining 55

  24. Forward chaining  Repeated application of Modus Ponens until reaching goal  Fire any rule whose premises are satisfied in the KB  add its conclusion to the KB , until query is found Arcs show conjunctions 56

  25. Forward chaining algorithm function 𝑄𝑀_𝐺𝐷_πΉπ‘‚π‘ˆπ΅π½π‘€π‘‡? (𝐿𝐢, π‘Ÿ) returns 𝑒𝑠𝑣𝑓 or π‘”π‘π‘šπ‘‘π‘“ inputs : 𝐿𝐢 , the knowledge base (a set of propositional definite clauses) π‘Ÿ , the query (a propositional symbol) π‘‘π‘π‘£π‘œπ‘’ ← a table where π‘‘π‘π‘£π‘œπ‘’[𝑑] is the number of symbols in 𝑑 ’ s premise π‘—π‘œπ‘”π‘“π‘ π‘ π‘“π‘’ ← a table, where π‘—π‘œπ‘”π‘“π‘ π‘ π‘“π‘’[𝑑] is initially false for all symbols π‘π‘•π‘“π‘œπ‘’π‘ ← a queue of symbols, initially symbols known to be true in 𝐿𝐢 Begin with known facts (positive while π‘π‘•π‘“π‘œπ‘’π‘ β‰  {} do literals) in KB π‘ž ← 𝑄𝑃𝑄(π‘π‘•π‘“π‘œπ‘’π‘) if π‘ž = π‘Ÿ then return 𝑒𝑠𝑣𝑓 if π‘—π‘œπ‘”π‘“π‘ π‘ π‘“π‘’[π‘ž] = π‘”π‘π‘šπ‘‘π‘“ then The process continues π‘—π‘œπ‘”π‘“π‘ π‘ π‘“π‘’[π‘ž] ← 𝑒𝑠𝑣𝑓 until q is added or no for each clause 𝑑 in 𝐿𝐢 where π‘ž is in 𝑑. 𝑄𝑆𝐹𝑁𝐽𝑇𝐹 do further inference π‘‘π‘π‘£π‘œπ‘’[𝑑] = π‘‘π‘π‘£π‘œπ‘’[𝑑] -1 if π‘‘π‘π‘£π‘œπ‘’[𝑑] = 0 then add 𝑑. 𝐷𝑃𝑂𝐷𝑀𝑉𝑇𝐽𝑃𝑂 to π‘π‘•π‘“π‘œπ‘’π‘ return false 57

  26. Forward chaining: example 𝑄 β‡’ 𝑅 𝑀 ∧ 𝑁 β‡’ 𝑄 𝐢 ∧ 𝑀 β‡’ 𝑁 𝐡 ∧ 𝑄 β‡’ 𝑀 𝐡 ∧ 𝐢 β‡’ 𝑀 𝐡 𝐢 58

  27. Forward chaining: example 𝑄 β‡’ 𝑅 𝑀 ∧ 𝑁 β‡’ 𝑄 𝐢 ∧ 𝑀 β‡’ 𝑁 𝐡 ∧ 𝑄 β‡’ 𝑀 𝐡 ∧ 𝐢 β‡’ 𝑀 𝐡 𝐢 59

  28. Forward chaining: example 𝑄 β‡’ 𝑅 𝑀 ∧ 𝑁 β‡’ 𝑄 𝐢 ∧ 𝑀 β‡’ 𝑁 𝐡 ∧ 𝑄 β‡’ 𝑀 𝐡 ∧ 𝐢 β‡’ 𝑀 𝐡 𝐢 60

  29. Forward chaining: example 𝑄 β‡’ 𝑅 𝑀 ∧ 𝑁 β‡’ 𝑄 𝐢 ∧ 𝑀 β‡’ 𝑁 𝐡 ∧ 𝑄 β‡’ 𝑀 𝐡 ∧ 𝐢 β‡’ 𝑀 𝐡 𝐢 61

  30. Forward chaining: example 𝑄 β‡’ 𝑅 𝑀 ∧ 𝑁 β‡’ 𝑄 𝐢 ∧ 𝑀 β‡’ 𝑁 𝐡 ∧ 𝑄 β‡’ 𝑀 𝐡 ∧ 𝐢 β‡’ 𝑀 𝐡 𝐢 62

  31. Forward chaining: example 𝑄 β‡’ 𝑅 𝑀 ∧ 𝑁 β‡’ 𝑄 𝐢 ∧ 𝑀 β‡’ 𝑁 𝐡 ∧ 𝑄 β‡’ 𝑀 𝐡 ∧ 𝐢 β‡’ 𝑀 𝐡 𝐢 63

  32. Forward chaining: example 𝑄 β‡’ 𝑅 𝑀 ∧ 𝑁 β‡’ 𝑄 𝐢 ∧ 𝑀 β‡’ 𝑁 𝐡 ∧ 𝑄 β‡’ 𝑀 𝐡 ∧ 𝐢 β‡’ 𝑀 𝐡 𝐢 64

  33. Forward chaining: example 𝑄 β‡’ 𝑅 𝑀 ∧ 𝑁 β‡’ 𝑄 𝐢 ∧ 𝑀 β‡’ 𝑁 𝐡 ∧ 𝑄 β‡’ 𝑀 𝐡 ∧ 𝐢 β‡’ 𝑀 𝐡 𝐢 65

  34. Forward chaining  Assumption: KB of definite clauses  Sound?  Every inference is an application of Modus Ponens.  Complete?  Every entailed atomic sentence will be derived?  Humans keep forward chaining under careful control (to avoid irrelevant consequences) 66

  35. Proof of completeness 1. Consider the final state of the inferred table (fixed point where no new atomic sentences are derived) 2. Consider the final state as a model 𝑛 , assigning 𝑒𝑠𝑣𝑓 to inferred symbols and π‘”π‘π‘šπ‘‘π‘“ to others 3. Every definite clause in the original KB is true in 𝑛 If β€œ 𝑏 1 ∧ β‹― ∧ 𝑏 π‘œ β‡’ 𝑐 ” is false then 𝑏 1 ∧ β‹― ∧ 𝑏 π‘œ is true and 𝑐 is false. But it contradicts with reaching a fixed point. 4. Thus, 𝑛 is a model of KB 5. If 𝐿𝐢 ⊨ π‘Ÿ , atomic sentence π‘Ÿ is true in every model of KB , including 𝑛 67

  36. Backward chaining  Idea: work backwards from the query π‘Ÿ :  To prove π‘Ÿ : if π‘Ÿ is known to be true then no work is needed else Find those rule concluding π‘Ÿ If all premises of one of them can be proved (by backward chaining) then π‘Ÿ is true  Avoid loops: check if new subgoal is already on the goal stack  Avoid repeated work: check if new subgoal has already been proved true or failed 68

  37. Backward chaining example 𝑄 β‡’ 𝑅 𝑀 ∧ 𝑁 β‡’ 𝑄 𝐢 ∧ 𝑀 β‡’ 𝑁 𝐡 ∧ 𝑄 β‡’ 𝑀 𝐡 ∧ 𝐢 β‡’ 𝑀 𝐡 𝐢 69

  38. Backward chaining example 𝑄 β‡’ 𝑅 𝑀 ∧ 𝑁 β‡’ 𝑄 𝐢 ∧ 𝑀 β‡’ 𝑁 𝐡 ∧ 𝑄 β‡’ 𝑀 𝐡 ∧ 𝐢 β‡’ 𝑀 𝐡 𝐢 70

  39. Backward chaining example 𝑄 β‡’ 𝑅 𝑀 ∧ 𝑁 β‡’ 𝑄 𝐢 ∧ 𝑀 β‡’ 𝑁 𝐡 ∧ 𝑄 β‡’ 𝑀 𝐡 ∧ 𝐢 β‡’ 𝑀 𝐡 𝐢 71

  40. Backward chaining example 𝑄 β‡’ 𝑅 𝑀 ∧ 𝑁 β‡’ 𝑄 𝐢 ∧ 𝑀 β‡’ 𝑁 𝐡 ∧ 𝑄 β‡’ 𝑀 𝐡 ∧ 𝐢 β‡’ 𝑀 𝐡 𝐢 72

  41. Backward chaining example 𝑄 β‡’ 𝑅 𝑀 ∧ 𝑁 β‡’ 𝑄 𝐢 ∧ 𝑀 β‡’ 𝑁 𝐡 ∧ 𝑄 β‡’ 𝑀 𝐡 ∧ 𝐢 β‡’ 𝑀 𝐡 𝐢 73

  42. Backward chaining example 𝑄 β‡’ 𝑅 𝑀 ∧ 𝑁 β‡’ 𝑄 𝐢 ∧ 𝑀 β‡’ 𝑁 𝐡 ∧ 𝑄 β‡’ 𝑀 𝐡 ∧ 𝐢 β‡’ 𝑀 𝐡 𝐢 74

  43. Backward chaining example 𝑄 β‡’ 𝑅 𝑀 ∧ 𝑁 β‡’ 𝑄 𝐢 ∧ 𝑀 β‡’ 𝑁 𝐡 ∧ 𝑄 β‡’ 𝑀 𝐡 ∧ 𝐢 β‡’ 𝑀 𝐡 𝐢 75

  44. Backward chaining example 𝑄 β‡’ 𝑅 𝑀 ∧ 𝑁 β‡’ 𝑄 𝐢 ∧ 𝑀 β‡’ 𝑁 𝐡 ∧ 𝑄 β‡’ 𝑀 𝐡 ∧ 𝐢 β‡’ 𝑀 𝐡 𝐢 76

  45. Backward chaining example 𝑄 β‡’ 𝑅 𝑀 ∧ 𝑁 β‡’ 𝑄 𝐢 ∧ 𝑀 β‡’ 𝑁 𝐡 ∧ 𝑄 β‡’ 𝑀 𝐡 ∧ 𝐢 β‡’ 𝑀 𝐡 𝐢 77

  46. Backward chaining example 𝑄 β‡’ 𝑅 𝑀 ∧ 𝑁 β‡’ 𝑄 𝐢 ∧ 𝑀 β‡’ 𝑁 𝐡 ∧ 𝑄 β‡’ 𝑀 𝐡 ∧ 𝐢 β‡’ 𝑀 𝐡 𝐢 78

  47. Forward vs. backward chaining  Forward chaining is data-driven, automatic, unconscious processing  May do lots of work that is irrelevant to the goal  Backward chaining is goal-driven, appropriate for problem- solving  Only relevant facts are considered.  Complexity of BC can be much less than linear in size of KB 79

  48. Efficient propositional inference  Efficient algorithms for general propositional inference:  We introduced DPLL algorithm as a systematic search method  Backtracking search algorithms  Now, we will introduceWalkSAT algorithm as a local search algorithm 80

  49. WalkSAT  It tests entailment 𝐿𝐢 ⊨ 𝛽 by testing unsatisfiability of 𝐿𝐢 ∧ ¬𝛽 .  Local search algorithms (hill climbing, SA, … )  state space: complete assignments  evaluation function: number of unsatisfied clauses  WalkSat  Simple & effective  Balance between greediness and randomness  To escape from local minima 81

  50. WalkSAT If max _π‘”π‘šπ‘—π‘žπ‘‘ = ∞ and π‘ž > 0 , WalkSAT will find a model (if any exists) If max _π‘”π‘šπ‘—π‘žπ‘‘ = ∞ , it never terminates for unsatisfiable sentences. 82

  51. WalkSAT  Failure may mean: The sentence is unsatisfiable. 1) The algorithm needs more time. 2)  It can not detect unsatisfiability.  Cannot be reliably used for deciding entailment. 83

  52. Knowledge-based agents  Knowledge-based agents  Reasoning operates on internal representation of knowledge  Logic as a general class of representation  Propositional logic  First-order logic 84

  53. A generic knowledge-based agent function KB_AGENT(π‘žπ‘“π‘ π‘‘π‘“π‘žπ‘’) returns an π‘π‘‘π‘’π‘—π‘π‘œ persistent : 𝐿𝐢 , a knowledge base 𝑒, 𝑏 counter for time, initially 0 TELL(𝐿𝐢, MAKE_PERCEPT_SENTENCE(π‘žπ‘“π‘ π‘‘π‘“π‘žπ‘’, 𝑒)) π‘π‘‘π‘’π‘—π‘π‘œ ← ASK(𝐿𝐢, MAKE_ACTION_QUERY(𝑒)) TELL(𝐿𝐢, MAKE_ACTION_SENTENCE(π‘π‘‘π‘’π‘—π‘π‘œ, 𝑒)) 𝑒 ← 𝑒 + 1 β€’ Makes a sentence asserting that the agent return π‘π‘‘π‘’π‘—π‘π‘œ perceived the given percept at the given time. β€’ Makes a sentence that asks what action should be done at the current time.  The agent must be able to: β€’ Makes a sentence asserting that the chosen  Represent states, actions, percepts, … . action was executed.  Incorporate new percepts  Update internal representations of the world  Deduce hidden properties of the world  Deduce appropriate actions 85

  54. Knowledge Base (KB)  KB = a set of sentences expressed in a knowledge representation language  TELL : adds new sentences to the knowledge base  ASK : asks a question of KB  the answer follows from previously TELL ed sentences to the KB  Inference: derives new sentences from old ones  Basis of TELL and ASK operations 86

  55. Wumpus world PEAS description  Performance measure  +1000 for garbing gold  -1000 for death  -1 for each action  -10 for using up the arrow  Game ends when the agent dies or climbs out of the cave  Environment  4Γ—4 grid  Agent starts in [1,1] while facing to the right  Gold and wumpus are located randomly in the squares except to [1,1]  Each square other than [1,1] can be a pit with probability 0.2 87

  56. Wumpus world PEAS description  Sensors: Stench, Breeze, Glitter, Bump, Scream  In the squares adjacent to wumpus, agent perceives a Stench  It the squares adjacent to a pit, agent perceives a Breeze  In the gold square, agent perceives a Glitter  When walking into a wall, agent perceives a Bump  When Wumpus is killed, agent perceives a Scream  Actuators: Forward, TurnLeft, TurnRight, Shoot, Grab, Climb  Forward,TurnLeft,TurnRight: moving and rotating face actions.  Moving to a square containing a pit or a live wumpus causes death.  If an agent tries to move forward and bumps into a wall then it does not move.  Shoot: to fire an arrow in a straight line in the facing direction of the agent  Shooting kills wumpus if the agent is facing it (o.w. the arrow hits a wall) The first shoot action has any effect (the agent has only one arrow)   Grab: to pick up the gold if it is in the same square as the agent .  Climb: climb out of the cave but only from [1,1] 88

  57. Wumpus world example: propositional symbols  Atemporal variables that may be needed  𝑄 𝑗,π‘˜ is true if there is a pit in [𝑗, π‘˜] . 𝑗,π‘˜ is true if there is a wumpus in [𝑗, π‘˜] , dead or alive.  𝑋  𝐢 𝑗,π‘˜ is true if the agent perceives a breeze in [𝑗, π‘˜] .  𝑇 𝑗,π‘˜ is true if the agent perceives a stench in [𝑗, π‘˜] .  Some of the temporal variables that may be needed  Variables for percepts and actions 𝑒 , πΊπ‘π‘‘π‘—π‘œπ‘•πΉπ‘π‘‘π‘’ 𝑒 , πΊπ‘π‘‘π‘—π‘œπ‘•π‘‹π‘“π‘‘π‘’ 𝑒 , πΊπ‘π‘‘π‘—π‘œπ‘•π‘‚π‘π‘ π‘’β„Ž 𝑒 , πΊπ‘π‘‘π‘—π‘œπ‘•π‘‡π‘π‘£π‘’β„Ž 𝑒  𝑀 𝑗,π‘˜  𝐼𝑏𝑀𝑓𝐡𝑠𝑠𝑝π‘₯ 𝑒  π‘‹π‘£π‘›π‘žπ‘£π‘‘π΅π‘šπ‘—π‘€π‘“ 𝑒 89

  58. Wumpus world example: axioms on atemporal aspect of the world  Axioms: general knowledge about how the world works  General rules on atemporal variables οƒ˜ 𝑄 1,1 οƒ˜ 𝑋 1,1 𝐢 𝑦,𝑧  (𝑄 𝑦,𝑧+1 οƒš 𝑄 𝑦,π‘§βˆ’1 οƒš 𝑄 𝑦+1,𝑧 οƒš 𝑄 π‘¦βˆ’1,𝑧 ) A distinct rule is needed for each square 𝑇 𝑦,𝑧  (𝑋 𝑦,𝑧+1 οƒš 𝑋 𝑦,π‘§βˆ’1 οƒš 𝑋 𝑦+1,𝑧 οƒš 𝑋 π‘¦βˆ’1,𝑧 ) 1,1 οƒš 𝑋 1,2 οƒš … οƒš 𝑋 𝑋 4,4 οƒ˜ 𝑋 1,1 οƒš οƒ˜ 𝑋 1,2 οƒ˜ 𝑋 1,1 οƒš οƒ˜ 𝑋 1,3 … 90

  59. Wumpus world example: perceptions & actions  Perceptions are converted to facts and are Telled to KB  𝑁𝐡𝐿𝐹_π‘„πΉπ‘†π·πΉπ‘„π‘ˆ_π‘‡πΉπ‘‚π‘ˆπΉπ‘‚π·πΉ 𝐢𝑠𝑓𝑓𝑨𝑓, π‘‡π‘’π‘“π‘œπ‘‘β„Ž, π‘‚π‘π‘œπ‘“, π‘‚π‘π‘œπ‘“, π‘‚π‘π‘œπ‘“ , 𝑒 𝐢𝑠𝑓𝑓𝑨𝑓 𝑒 , π‘‡π‘’π‘“π‘œπ‘‘β„Ž 𝑒 are added to KB   Selected action is converted to a fact and is Telled to KB  𝑁𝐡𝐿𝐹_π΅π·π‘ˆπ½π‘ƒπ‘‚_π‘‡πΉπ‘‚π‘ˆπΉπ‘‚π·πΉ 𝐺𝑝𝑠π‘₯𝑏𝑠𝑒, 𝑒  𝐺𝑝𝑠π‘₯𝑏𝑠𝑒 𝑒 is added to KB 91

  60. Wumpus world example: transition model  Changing aspect of world (Temporal variables)  They are also called as fluents or state variables  Initial KB includes the initial status of some of the temporal variables: 0 , πΊπ‘π‘‘π‘—π‘œπ‘•πΉπ‘π‘‘π‘’ 0 , 𝐼𝑏𝑀𝑓𝐡𝑠𝑠𝑝π‘₯ 0 , π‘‹π‘£π‘›π‘žπ‘£π‘‘π΅π‘šπ‘—π‘€π‘“ 0  𝑀 1,1  Percepts are connected to fluents describing the properties of squares β‡’ (𝐢𝑠𝑓𝑓𝑨𝑓 𝑒 ⇔ 𝐢 𝑦,𝑧 ) 𝑒  𝑀 𝑦,𝑧 β‡’ π‘‡π‘’π‘“π‘œπ‘‘β„Ž 𝑒 ⇔ 𝑇 𝑦,𝑧 𝑒  𝑀 𝑦,𝑧  …  Transition model: fluents can change as the results of agent ’ s actions 92

  61. Wumpus world example: transition model Frame problem  Transition model: ∧ πΊπ‘π‘‘π‘—π‘œπ‘•πΉπ‘π‘‘π‘’ 0 ∧ 𝐺𝑝𝑠π‘₯𝑏𝑠𝑒 0 β‡’ (𝑀 2,1 1 ) 0 1 𝑀 1,1 ∧ ¬𝑀 1,1 ∧ πΊπ‘π‘‘π‘—π‘œπ‘•πΉπ‘π‘‘π‘’ 0 ∧ π‘ˆπ‘£π‘ π‘œπ‘€π‘“π‘”π‘’ 0 β‡’ (𝑀 1,1 ∧ πΊπ‘π‘‘π‘—π‘œπ‘•π‘‚π‘π‘ π‘’β„Ž 1 ∧ Β¬πΊπ‘π‘‘π‘—π‘œπ‘•πΉπ‘π‘‘π‘’ 1 ) 0 1 𝑀 1,1 …  After doing 𝐺𝑝𝑠π‘₯𝑏𝑠𝑒 action at time 0:  𝐡𝑇𝐿 𝐿𝐢, 𝐼𝑏𝑀𝑓𝐡𝑠𝑠𝑝π‘₯ 1 = π‘”π‘π‘šπ‘‘π‘“  Why?  Frame problem: representing the effects of actions without having to represent explicitly a large number of intuitively obvious non-effects 93

  62. Wumpus world example Solution to frame problem: successor-state axioms  A Solution to frame problem: Successor-state axioms Instead of writing axioms about actions, we write axioms about fluents  𝐺 𝑒+1 ⇔ π΅π‘‘π‘’π‘—π‘π‘œπ·π‘π‘£π‘‘π‘“π‘‘πΊ 𝑒 ∨ (𝐺 𝑒 ∧ Β¬π΅π‘‘π‘’π‘—π‘π‘œπ·π‘π‘£π‘‘π‘“π‘‘π‘‚π‘π‘’πΊ 𝑒 ) 𝐼𝑏𝑀𝑓𝐡𝑠𝑠𝑝π‘₯ 𝑒+1 ⇔ 𝐼𝑏𝑀𝑓𝐡𝑠𝑠𝑝π‘₯ 𝑒 ∧ Β¬π‘‡β„Žπ‘π‘π‘’ 𝑒 𝑒+1 ⇔ (𝑀 1,1 ∧ (¬𝐺𝑝𝑠π‘₯𝑏𝑠𝑒 𝑒 ∨ πΆπ‘£π‘›π‘ž 𝑒+1 )) 𝑒 𝑀 1,1 ∧ (πΊπ‘π‘‘π‘—π‘œπ‘•π‘‡π‘π‘£π‘’β„Ž 𝑒 ∧ 𝐺𝑝𝑠π‘₯𝑏𝑠𝑒 𝑒 )) 𝑒 ∨ (𝑀 1,2 ∧ (πΊπ‘π‘‘π‘—π‘œπ‘•π‘‹π‘“π‘‘π‘’ 𝑒 ∧ 𝐺𝑝𝑠π‘₯𝑏𝑠𝑒 𝑒 )) 𝑒 ∨ (𝑀 2,1 94

  63. A hybrid agent for the wumpus world  Basic concepts:  Safeness of [𝑦, 𝑧] square: 𝑒 𝑦,𝑧 ∧ π‘‹π‘£π‘›π‘žπ‘£π‘‘π΅π‘šπ‘—π‘€π‘“ 𝑒 )  𝑃𝐿 𝑦,𝑧 ⇔ ¬𝑄 𝑦,𝑧 ∧ Β¬(𝑋  Set of safe squares: 𝑒  𝑑𝑏𝑔𝑓 ← 𝑦, 𝑧 : 𝐡𝑇𝐿 𝐿𝐢, 𝑃𝐿 𝑦,𝑧 = 𝑒𝑠𝑣𝑓  Set of unvisited squares: = π‘”π‘π‘šπ‘‘π‘“ 𝑔𝑝𝑠 π‘π‘šπ‘š 𝑒 β€² ≀ 𝑒 𝑒 β€²  π‘£π‘œπ‘€π‘—π‘‘π‘—π‘’π‘“π‘’ ← 𝑦, 𝑧 : 𝐡𝑇𝐿 𝐿𝐢, 𝑀 𝑦,𝑧 95

  64. function 𝐼𝑍𝐢𝑆𝐽𝐸_𝑋𝑉𝑁𝑄𝑉𝑇_π΅π»πΉπ‘‚π‘ˆ(π‘žπ‘“π‘ π‘‘π‘“π‘žπ‘’) returns an action sequence inputs : π‘žπ‘“π‘ π‘‘π‘“π‘žπ‘’ , a list, 𝑐𝑠𝑓𝑓𝑨𝑓, π‘‘π‘’π‘“π‘œπ‘‘β„Ž, π‘•π‘šπ‘—π‘’π‘’π‘“π‘ , π‘π‘£π‘›π‘ž, 𝑑𝑑𝑠𝑓𝑏𝑛 persistent : 𝐿𝐢 , initially the atemporal β€œ wumpus physics ” 𝑒 , a time counter, initially 0 π‘žπ‘šπ‘π‘œ , an action sequence, initially empty TELL(𝐿𝐢, 𝑁𝐡𝐿𝐹_π‘„πΉπ‘†π·πΉπ‘„π‘ˆ_π‘‡πΉπ‘‚π‘ˆπΉπ‘‚π·πΉ π‘žπ‘“π‘ π‘‘π‘“π‘žπ‘’, 𝑒 ) TELL the 𝐿𝐢 the temporal β€œ physics ” sentences for time 𝑒 𝑒 𝑑𝑏𝑔𝑓 ← 𝑦, 𝑧 : 𝐡𝑇𝐿 𝐿𝐢, 𝑃𝐿 𝑦,𝑧 = 𝑒𝑠𝑣𝑓 if 𝐡𝑇𝐿(𝐿𝐢, π»π‘šπ‘—π‘’π‘’π‘“π‘  𝑒 ) = 𝑒𝑠𝑣𝑓 then π‘žπ‘šπ‘π‘œ ← 𝐻𝑠𝑏𝑐 + 𝑄𝑀𝐡𝑂_π‘†π‘ƒπ‘‰π‘ˆπΉ π‘‘π‘£π‘ π‘ π‘“π‘œπ‘’, 1,1 , 𝑑𝑏𝑔𝑓 + [π·π‘šπ‘—π‘›π‘] if π‘žπ‘šπ‘π‘œ = {} then = π‘”π‘π‘šπ‘‘π‘“ 𝑔𝑝𝑠 π‘π‘šπ‘š 𝑒 β€² ≀ 𝑒 𝑒 β€² π‘£π‘œπ‘€π‘—π‘‘π‘—π‘’π‘“π‘’ ← 𝑦, 𝑧 : 𝐡𝑇𝐿 𝐿𝐢, 𝑀 𝑦,𝑧 π‘žπ‘šπ‘π‘œ ← 𝑄𝑀𝐡𝑂_π‘†π‘ƒπ‘‰π‘ˆπΉ(π‘‘π‘£π‘ π‘ π‘“π‘œπ‘’, π‘£π‘œπ‘€π‘—π‘‘π‘—π‘’π‘“π‘’ ∩ 𝑑𝑏𝑔𝑓, 𝑑𝑏𝑔𝑓) if π‘žπ‘šπ‘π‘œ = {} and 𝐡𝑇𝐿 𝐿𝐢, 𝐼𝑏𝑀𝑓𝐡𝑠𝑠𝑝π‘₯ 𝑒 = 𝑒𝑠𝑣𝑓 then π‘žπ‘π‘‘π‘‘π‘—π‘π‘šπ‘“_π‘₯π‘£π‘›π‘žπ‘£π‘‘ ← 𝑦, 𝑧 : 𝐡𝑇𝐿 𝐿𝐢, ¬𝑋 𝑦,𝑧 = π‘”π‘π‘šπ‘‘π‘“ π‘žπ‘šπ‘π‘œ ← 𝑄𝑀𝐡𝑂_π‘‡πΌπ‘ƒπ‘ˆ(π‘‘π‘£π‘ π‘ π‘“π‘œπ‘’, π‘žπ‘π‘‘π‘‘π‘—π‘π‘šπ‘“_π‘₯π‘£π‘›π‘žπ‘£π‘‘, 𝑑𝑏𝑔𝑓) if π‘žπ‘šπ‘π‘œ = {} then 𝑒 π‘œπ‘π‘’_π‘£π‘œπ‘‘π‘π‘”π‘“ ← 𝑦, 𝑧 : 𝐡𝑇𝐿 𝐿𝐢, ¬𝑃𝐿 𝑦,𝑧 = π‘”π‘π‘šπ‘‘π‘“ π‘žπ‘šπ‘π‘œ ← 𝑄𝑀𝐡𝑂_π‘†π‘ƒπ‘‰π‘ˆπΉ(π‘‘π‘£π‘ π‘ π‘“π‘œπ‘’, π‘£π‘œπ‘€π‘—π‘‘π‘—π‘’π‘“π‘’ ∩ π‘œπ‘π‘’_π‘£π‘œπ‘‘π‘π‘”π‘“, 𝑑𝑏𝑔𝑓) if π‘žπ‘šπ‘π‘œ = {} then π‘žπ‘šπ‘π‘œ ← 𝑄𝑀𝐡𝑂_π‘†π‘ƒπ‘‰π‘ˆπΉ π‘‘π‘£π‘ π‘ π‘“π‘œπ‘’, 1,1 , 𝑑𝑏𝑔𝑓 + [π·π‘šπ‘—π‘›π‘] action ← 𝑄𝑃𝑄(π‘žπ‘šπ‘π‘œ) π‘ˆπΉπ‘€π‘€(𝐿𝐢, 𝑁𝐡𝐿𝐹_π΅π·π‘ˆπ½π‘ƒπ‘‚_π‘‡πΉπ‘‚π‘ˆπΉπ‘‚π·πΉ(π‘π‘‘π‘’π‘—π‘π‘œ, 𝑒)) 𝑒 ← 𝑒 + 1 return π‘π‘‘π‘’π‘—π‘π‘œ 96

  65. Hybrid agent (phases listed based on priority)  Simple-reflex (condition-action rule): if 𝐡𝑇𝐿(𝐿𝐢, π»π‘šπ‘—π‘’π‘’π‘“π‘  𝑒 ) = 𝑒𝑠𝑣𝑓 then π‘žπ‘šπ‘π‘œ ← [𝐻𝑠𝑏𝑐] + 𝑄𝑀𝐡𝑂_π‘†π‘ƒπ‘‰π‘ˆπΉ π‘‘π‘£π‘ π‘ π‘“π‘œπ‘’, 1,1 , 𝑑𝑏𝑔𝑓 + [π·π‘šπ‘—π‘›π‘]  Goal-based & reasoning: if π‘žπ‘šπ‘π‘œ = {} then = π‘”π‘π‘šπ‘‘π‘“ 𝑔𝑝𝑠 π‘π‘šπ‘š 𝑒 β€² ≀ 𝑒 𝑒 β€² π‘£π‘œπ‘€π‘—π‘‘π‘—π‘’π‘“π‘’ ← 𝑦, 𝑧 : 𝐡𝑇𝐿 𝐿𝐢, 𝑀 𝑦,𝑧 π‘žπ‘šπ‘π‘œ ← 𝑄𝑀𝐡𝑂_π‘†π‘ƒπ‘‰π‘ˆπΉ(π‘‘π‘£π‘ π‘ π‘“π‘œπ‘’, π‘£π‘œπ‘€π‘—π‘‘π‘—π‘’π‘“π‘’ ∩ 𝑑𝑏𝑔𝑓, 𝑑𝑏𝑔𝑓) if π‘žπ‘šπ‘π‘œ = {} and 𝐡𝑇𝐿 𝐿𝐢, 𝐼𝑏𝑀𝑓𝐡𝑠𝑠𝑝π‘₯ 𝑒 = 𝑒𝑠𝑣𝑓 then π‘žπ‘π‘‘π‘‘π‘—π‘π‘šπ‘“_π‘₯π‘£π‘›π‘žπ‘£π‘‘ ← 𝑦, 𝑧 : 𝐡𝑇𝐿 𝐿𝐢, ¬𝑋 𝑦,𝑧 = π‘”π‘π‘šπ‘‘π‘“ π‘žπ‘šπ‘π‘œ ← 𝑄𝑀𝐡𝑂_π‘‡πΌπ‘ƒπ‘ˆ(π‘‘π‘£π‘ π‘ π‘“π‘œπ‘’, π‘žπ‘π‘‘π‘‘π‘—π‘π‘šπ‘“_π‘₯π‘£π‘›π‘žπ‘£π‘‘, 𝑑𝑏𝑔𝑓) 97

  66. Hybrid agent (phases listed based on priority)  Exploration & reasoning if π‘žπ‘šπ‘π‘œ = {} then 𝑒 π‘œπ‘π‘’_π‘£π‘œπ‘‘π‘π‘”π‘“ ← 𝑦, 𝑧 : 𝐡𝑇𝐿 𝐿𝐢, ¬𝑃𝐿 𝑦,𝑧 = π‘”π‘π‘šπ‘‘π‘“ π‘žπ‘šπ‘π‘œ ← 𝑄𝑀𝐡𝑂_π‘†π‘ƒπ‘‰π‘ˆπΉ(π‘‘π‘£π‘ π‘ π‘“π‘œπ‘’, π‘£π‘œπ‘€π‘—π‘‘π‘—π‘’π‘“π‘’ ∩ π‘œπ‘π‘’_π‘£π‘œπ‘‘π‘π‘”π‘“, 𝑑𝑏𝑔𝑓)  Goal-based: if π‘žπ‘šπ‘π‘œ = {} then π‘žπ‘šπ‘π‘œ ← 𝑄𝑀𝐡𝑂_π‘†π‘ƒπ‘‰π‘ˆπΉ π‘‘π‘£π‘ π‘ π‘“π‘œπ‘’, 1,1 , 𝑑𝑏𝑔𝑓 + [π·π‘šπ‘—π‘›π‘] 98

  67. Hybrid agent: Using A* to make a plan function 𝑄𝑀𝐡𝑂_π‘†π‘ƒπ‘‰π‘ˆπΉ(π‘‘π‘£π‘ π‘ π‘“π‘œπ‘’, π‘•π‘π‘π‘š, π‘π‘šπ‘šπ‘π‘₯𝑓𝑒) returns an action sequence inputs : π‘‘π‘£π‘ π‘ π‘“π‘œπ‘’ , the agent ’ s current position π‘•π‘π‘π‘šπ‘‘ , a set of squares; try to plan a route to one of them π‘π‘šπ‘šπ‘π‘₯𝑓𝑒 , a set of squares that can form part of the route π‘žπ‘ π‘π‘π‘šπ‘“π‘› ← π‘†π‘ƒπ‘‰π‘ˆπΉ_𝑄𝑆𝑃𝐢𝑀𝐹𝑁(π‘‘π‘£π‘ π‘ π‘“π‘œπ‘’, π‘•π‘π‘π‘šπ‘‘, π‘π‘šπ‘šπ‘π‘₯𝑓𝑒) return 𝐡 βˆ— _𝐻𝑆𝐡𝑄𝐼_𝑇𝐹𝐡𝑆𝐷𝐼(π‘žπ‘ π‘π‘π‘šπ‘“π‘›) 99

  68. SATPlan  SATPlan is a method to solve the whole problem as a SAT problem  It considers both state fluents and actions (of each time) as proposition 100

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend