Then it cank itsef what tod-wers shoul follaw from the KB Knowledge base=set of senten ina formal language Kn owlad ge base resolution Logic in general-models and entailmen Wumpus world Knowledge bases Outline LOGICAL AGENT domain-independent .. .. Wumpus world characterization Sensrs Breeze,Glitter,Smell Wumpus World PEAS description sent states,actions,etc. The agent must be able to: Ask(KB.MAKE-ACHION-Q r-SENT A simple knowledge-based agent e
Logical agents Chapter 7 Chapter 7 1 Outline ♦ Knowledge-based agents ♦ Wumpus world ♦ Logic in general—models and entailment ♦ Propositional (Boolean) logic ♦ Equivalence, validity, satisfiability ♦ Inference rules and theorem proving – forward chaining – backward chaining – resolution Chapter 7 2 Knowledge bases Knowledge base Inference engine domain−specific content domain−independent algorithms Knowledge base = set of sentences in a formal language Declarative approach to building an agent (or other system): Tell it what it needs to know Then it can Ask itself what to do—answers should follow from the KB Agents can be viewed at the knowledge level i.e., what they know, regardless of how implemented Or at the implementation level i.e., data structures in KB and algorithms that manipulate them Chapter 7 3 A simple knowledge-based agent function KB-Agent( percept) returns an action static: KB, a knowledge base t, a counter, initially 0, indicating time Tell(KB,Make-Percept-Sentence( percept,t)) action ←Ask(KB,Make-Action-Query(t)) Tell KB ( ,Make-Action-Sentence(action,t)) t ← t + 1 return action The agent must be able to: Represent states, actions, etc. Incorporate new percepts Update internal representations of the world Deduce hidden properties of the world Deduce appropriate actions Chapter 7 4 Wumpus World PEAS description Performance measure gold +1000, death -1000 -1 per step, -10 for using the arrow Environment Squares adjacent to wumpus are smelly Squares adjacent to pit are breezy Glitter iff gold is in the same square Shooting kills wumpus if you are facing it Shooting uses up the only arrow Grabbing picks up gold if in same square Releasing drops the gold in same square Breeze Breeze Breeze Breeze Breeze Stench Stench Breeze PIT PIT PIT 1 2 3 4 1 2 3 4 START Gold Stench Actuators Left turn, Right turn, Forward, Grab, Release, Shoot Sensors Breeze, Glitter, Smell Chapter 7 5 Wumpus world characterization Observable?? Chapter 7 6
Wumpus world characterization No-only lcal perception Wumpus world characterization Wumpus world characterization Yes-Wumpus is essentially a natural featur Yes-Wumpus and Pits do nat move Yes-outcomes xctly specifie Wumpus world characterization No-ony lcal perception Wumpus world characterization StaticYes-Wumpus and Pits do not move Wumpus world characterization .!
Wumpus world characterization Observable?? No—only local perception Deterministic?? Chapter 7 7 Wumpus world characterization Observable?? No—only local perception Deterministic?? Yes—outcomes exactly specified Episodic?? Chapter 7 8 Wumpus world characterization Observable?? No—only local perception Deterministic?? Yes—outcomes exactly specified Episodic?? No—sequential at the level of actions Static?? Chapter 7 9 Wumpus world characterization Observable?? No—only local perception Deterministic?? Yes—outcomes exactly specified Episodic?? No—sequential at the level of actions Static?? Yes—Wumpus and Pits do not move Discrete?? Chapter 7 10 Wumpus world characterization Observable?? No—only local perception Deterministic?? Yes—outcomes exactly specified Episodic?? No—sequential at the level of actions Static?? Yes—Wumpus and Pits do not move Discrete?? Yes Single-agent?? Chapter 7 11 Wumpus world characterization Observable?? No—only local perception Deterministic?? Yes—outcomes exactly specified Episodic?? No—sequential at the level of actions Static?? Yes—Wumpus and Pits do not move Discrete?? Yes Single-agent?? Yes—Wumpus is essentially a natural feature Chapter 7 12
回 9 回 回 Exploring a wumpus world Exploring a wumpus world Exploring a wumpus world 回 Exploring a wumpus world Exploring a wumpus world Exploring a wumpus world
Exploring a wumpus world A OK OK OK Chapter 7 13 Exploring a wumpus world OK OK OK A A B Chapter 7 14 Exploring a wumpus world OK OK OK A A B P? P? Chapter 7 15 Exploring a wumpus world OK OK OK A A B P? P? A S Chapter 7 16 Exploring a wumpus world OK OK OK A A B P? P? A S OK P W Chapter 7 17 Exploring a wumpus world OK OK OK A A B P? P? A S OK P W A Chapter 7 18
0 9 n pus shoot straight ahead Can ue a strategy of coercion: cannot move Other tight spots Exploring a wumpus world Exploring a wumpus world ThenKBa if and only if M(KB)C M(a) Note:brains pocess(ofm sort) that is based on semantics E.g.+y=4 entails4=r+y Egthe language of arithmetic Models Entailment +2i true iff the number+is no lss than the number Syntax defnesthes intheangug Logic in general
Exploring a wumpus world OK OK OK A A B P? P? A S OK P W A OK OK Chapter 7 19 Exploring a wumpus world OK OK OK A A B P? P? A S OK P W A OK OK A BGS Chapter 7 20 Other tight spots A B OK OK OK A B A P? P? P? P? Breeze in (1,2) and (2,1) ⇒ no safe actions Assuming pits uniformly distributed, (2,2) has pit w/ prob 0.86, vs. 0.31 A S Smell in (1,1) ⇒ cannot move Can use a strategy of coercion: shoot straight ahead wumpus was there ⇒ dead ⇒ safe wumpus wasn’t there ⇒ safe Chapter 7 21 Logic in general Logics are formal languages for representing information such that conclusions can be drawn Syntax defines the sentences in the language Semantics define the “meaning” of sentences; i.e., define truth of a sentence in a world E.g., the language of arithmetic x + 2 ≥ y is a sentence; x2 + y > is not a sentence x + 2 ≥ y is true iff the number x + 2 is no less than the number y x + 2 ≥ y is true in a world where x = 7, y = 1 x + 2 ≥ y is false in a world where x = 0, y = 6 Chapter 7 22 Entailment Entailment means that one thing follows from another: KB |= α Knowledge base KB entails sentence α if and only if α is true in all worlds where KB is true E.g., the KB containing “the Giants won” and “the Reds won” entails “Either the Giants won or the Reds won” E.g., x + y = 4 entails 4 = x + y Entailment is a relationship between sentences (i.e., syntax) that is based on semantics Note: brains process syntax (of some sort) Chapter 7 23 Models Logicians typically think in terms of models, which are formally structured worlds with respect to which truth can be evaluated We say m is a model of a sentence α if α is true in m M(α) is the set of all models of α Then KB |= α if and only if M(KB) ⊆ M(α) E.g. KB = Giants won and Reds won α = Giants won M( ) M(KB) x x x x x x x x x x x x x x x x x x x x x x x x x xx x x x x x x x x x x x x x x x x x x x x Chapter 7 24
碎 Wumpus models 3 Bodlean choices 8 possible modeb Entailment in the wumpus world 西 ... o2=122]is safe".B o A=wumpus world ruks obse B=wumpus-world rules +observ Wumpus models Wumpus models +058
Entailment in the wumpus world Situation after detecting nothing in [1,1], moving right, breeze in [2,1] Consider possible models for ?s assuming only pits A A B ? ? ? 3 Boolean choices ⇒ 8 possible models Chapter 7 25 Wumpus models 1 2 3 1 2 Breeze PIT 1 2 3 1 2 Breeze PIT 1 2 3 1 2 Breeze PIT PIT PIT 1 2 3 1 2 Breeze PIT PIT 1 2 3 1 2 Breeze PIT 1 2 3 1 2 Breeze PIT PIT 1 2 3 1 2 Breeze PIT PIT 1 2 3 1 2 Breeze Chapter 7 26 Wumpus models 1 2 3 1 2 Breeze PIT 1 2 3 1 2 Breeze PIT 1 2 3 1 2 Breeze PIT PIT PIT 1 2 3 1 2 Breeze PIT PIT 1 2 3 1 2 Breeze PIT 1 2 3 1 2 Breeze PIT PIT 1 2 3 1 2 Breeze PIT PIT 1 2 3 1 2 Breeze KB KB = wumpus-world rules + observations Chapter 7 27 Wumpus models 1 2 3 1 2 Breeze PIT 1 2 3 1 2 Breeze PIT 1 2 3 1 2 Breeze PIT PIT PIT 1 2 3 1 2 Breeze PIT PIT 1 2 3 1 2 Breeze PIT 1 2 3 1 2 Breeze PIT PIT 1 2 3 1 2 Breeze PIT PIT 1 2 3 1 2 Breeze KB 1 KB = wumpus-world rules + observations α1 = “[1,2] is safe”, KB |= α1, proved by model checking Chapter 7 28 Wumpus models 1 2 3 1 2 Breeze PIT 1 2 3 1 2 Breeze PIT 1 2 3 1 2 Breeze PIT PIT PIT 1 2 3 1 2 Breeze PIT PIT 1 2 3 1 2 Breeze PIT 1 2 3 1 2 Breeze PIT PIT 1 2 3 1 2 Breeze PIT PIT 1 2 3 1 2 Breeze KB KB = wumpus-world rules + observations Chapter 7 29 Wumpus models 1 2 3 1 2 Breeze PIT 1 2 3 1 2 Breeze PIT 1 2 3 1 2 Breeze PIT PIT PIT 1 2 3 1 2 Breeze PIT PIT 1 2 3 1 2 Breeze PIT 1 2 3 1 2 Breeze PIT PIT 1 2 3 1 2 Breeze PIT PIT 1 2 3 1 2 Breeze KB 2 KB = wumpus-world rules + observations α2 = “[2,2] is safe”, KB 6|= α2 Chapter 7 30