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
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
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
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
The DPLL algorithm Determining satisfiability of an input propositional logic sentence (in CNF) 37
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
Inference rules ο½ Some samples: ο½ Modus Ponens: Ξ±βΞ², Ξ± Ξ² ο½ And elimination: π½β§πΎ πΎ π½βπΎ ο½ Biconditional elimination: (π½βπΎ)β§(πΎβπ½) 39
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
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
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
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
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
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
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
CNF Grammar π·ππΊππππ’ππππ β π·πππ£π‘π 1 β§ β― β§ π·πππ£π‘π π π·πππ£π‘π β πππ’ππ ππ 1 β¨ β― β¨ πππ’ππ ππ π πππ’ππ ππ β ππ§ππππ | Β¬ππ§ππππ ππ§ππππ β π π π | β¦ 47
Example of resolution π 1,1 β¨ π 3,1 , Β¬π 1,1 β¨ Β¬π 2,2 π 3,1 β¨ Β¬π 2,2 48
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
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
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
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
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
Grammar ππ§ππππ β π π π | β¦ πΌππ ππ·πππ£π‘π β πΈππππππ’ππ·πππ£π‘π | π»ππππ·πππ£π‘π πΈππππππ’ππ·πππ£π‘π β ππ§ππππ 1 β§ β― β§ ππ§ππππ π β ππ§ππππ π»ππππ·πππ£π‘π β (ππ§ππππ 1 β§ β― β§ ππ§ππππ π ) β πΊπππ‘π 54
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
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
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
Forward chaining: example π β π π β§ π β π πΆ β§ π β π π΅ β§ π β π π΅ β§ πΆ β π π΅ πΆ 58
Forward chaining: example π β π π β§ π β π πΆ β§ π β π π΅ β§ π β π π΅ β§ πΆ β π π΅ πΆ 59
Forward chaining: example π β π π β§ π β π πΆ β§ π β π π΅ β§ π β π π΅ β§ πΆ β π π΅ πΆ 60
Forward chaining: example π β π π β§ π β π πΆ β§ π β π π΅ β§ π β π π΅ β§ πΆ β π π΅ πΆ 61
Forward chaining: example π β π π β§ π β π πΆ β§ π β π π΅ β§ π β π π΅ β§ πΆ β π π΅ πΆ 62
Forward chaining: example π β π π β§ π β π πΆ β§ π β π π΅ β§ π β π π΅ β§ πΆ β π π΅ πΆ 63
Forward chaining: example π β π π β§ π β π πΆ β§ π β π π΅ β§ π β π π΅ β§ πΆ β π π΅ πΆ 64
Forward chaining: example π β π π β§ π β π πΆ β§ π β π π΅ β§ π β π π΅ β§ πΆ β π π΅ πΆ 65
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
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
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
Backward chaining example π β π π β§ π β π πΆ β§ π β π π΅ β§ π β π π΅ β§ πΆ β π π΅ πΆ 69
Backward chaining example π β π π β§ π β π πΆ β§ π β π π΅ β§ π β π π΅ β§ πΆ β π π΅ πΆ 70
Backward chaining example π β π π β§ π β π πΆ β§ π β π π΅ β§ π β π π΅ β§ πΆ β π π΅ πΆ 71
Backward chaining example π β π π β§ π β π πΆ β§ π β π π΅ β§ π β π π΅ β§ πΆ β π π΅ πΆ 72
Backward chaining example π β π π β§ π β π πΆ β§ π β π π΅ β§ π β π π΅ β§ πΆ β π π΅ πΆ 73
Backward chaining example π β π π β§ π β π πΆ β§ π β π π΅ β§ π β π π΅ β§ πΆ β π π΅ πΆ 74
Backward chaining example π β π π β§ π β π πΆ β§ π β π π΅ β§ π β π π΅ β§ πΆ β π π΅ πΆ 75
Backward chaining example π β π π β§ π β π πΆ β§ π β π π΅ β§ π β π π΅ β§ πΆ β π π΅ πΆ 76
Backward chaining example π β π π β§ π β π πΆ β§ π β π π΅ β§ π β π π΅ β§ πΆ β π π΅ πΆ 77
Backward chaining example π β π π β§ π β π πΆ β§ π β π π΅ β§ π β π π΅ β§ πΆ β π π΅ πΆ 78
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
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
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
WalkSAT If max _πππππ‘ = β and π > 0 , WalkSAT will find a model (if any exists) If max _πππππ‘ = β , it never terminates for unsatisfiable sentences. 82
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
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
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
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
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
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
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
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
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
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
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
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
A hybrid agent for the wumpus world ο½ Basic concepts: ο½ Safeness of [π¦, π§] square: π’ π¦,π§ β§ ππ£πππ£π‘π΅πππ€π π’ ) ο½ ππΏ π¦,π§ β Β¬π π¦,π§ β§ Β¬(π ο½ Set of safe squares: π’ ο½ π‘πππ β π¦, π§ : π΅ππΏ πΏπΆ, ππΏ π¦,π§ = π’π π£π ο½ Set of unvisited squares: = ππππ‘π πππ πππ π’ β² β€ π’ π’ β² ο½ π£ππ€ππ‘ππ’ππ β π¦, π§ : π΅ππΏ πΏπΆ, π π¦,π§ 95
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
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
Hybrid agent (phases listed based on priority) ο½ Exploration & reasoning if ππππ = {} then π’ πππ’_π£ππ‘πππ β π¦, π§ : π΅ππΏ πΏπΆ, Β¬ππΏ π¦,π§ = ππππ‘π ππππ β πππ΅π_πππππΉ(ππ£π π πππ’, π£ππ€ππ‘ππ’ππ β© πππ’_π£ππ‘πππ, π‘πππ) ο½ Goal-based: if ππππ = {} then ππππ β πππ΅π_πππππΉ ππ£π π πππ’, 1,1 , π‘πππ + [π·ππππ] 98
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
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
Recommend
More recommend