Knowledge bases domain−independent algorithms Inference engine Knowledge base domain−specific content Logical agents 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 Chapter 7 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 1 Chapter 7 3 Outline A simple knowledge-based agent ♦ Knowledge-based agents function KB-Agent ( percept ) returns an action static : KB , a knowledge base ♦ Wumpus world t , a counter, initially 0, indicating time ♦ Logic in general—models and entailment Tell ( KB , Make-Percept-Sentence ( percept , t )) action ← Ask ( KB , Make-Action-Query ( t )) ♦ Propositional (Boolean) logic Tell ( KB , Make-Action-Sentence ( action , t )) t ← t + 1 ♦ Equivalence, validity, satisfiability return action ♦ Inference rules and theorem proving – forward chaining The agent must be able to: – backward chaining Represent states, actions, etc. – resolution Incorporate new percepts Update internal representations of the world Deduce hidden properties of the world Deduce appropriate actions Chapter 7 2 Chapter 7 4
Wumpus World PEAS description Wumpus world characterization Performance measure Observable?? Partially—only local perception gold +1000, death -1000 Deterministic?? -1 per step, -10 for using the arrow Breeze Environment Stench 4 PIT Squares adjacent to wumpus are smelly Breeze Breeze 3 Squares adjacent to pit are breezy PIT Stench Gold Glitter iff gold is in the same square Breeze Stench 2 Shooting kills wumpus if you are facing it Shooting uses up the only arrow Breeze Breeze 1 PIT Grabbing picks up gold if in same square START Releasing drops the gold in same square 1 2 3 4 Actuators Left turn, Right turn, Forward, Grab, Release, Shoot Sensors Breeze, Glitter, Smell Chapter 7 5 Chapter 7 7 Wumpus world characterization Wumpus world characterization Observable?? Observable?? Partially—only local perception Deterministic?? Yes—outcomes exactly specified Episodic?? Chapter 7 6 Chapter 7 8
Wumpus world characterization Wumpus world characterization Observable?? Partially— local perception Observable?? Partially— local perception Deterministic?? Yes—outcomes exactly specified Deterministic?? Yes—outcomes exactly specified Episodic?? No—sequential at the level of actions Episodic?? No—sequential at the level of actions Static?? Static?? Yes—Wumpus and Pits do not move Discrete?? Yes Single-agent?? Chapter 7 9 Chapter 7 11 Wumpus world characterization Wumpus world characterization Observable?? Partially— local perception Observable?? Partially— local perception Deterministic?? Yes—outcomes exactly specified Deterministic?? Yes—outcomes exactly specified Episodic?? No—sequential at the level of actions Episodic?? No—sequential at the level of actions Static?? Yes—Wumpus and Pits do not move Static?? Yes—Wumpus and Pits do not move Discrete?? Discrete?? Yes Single-agent?? Yes—Wumpus is essentially a natural feature Chapter 7 10 Chapter 7 12
Exploring a wumpus world Exploring a wumpus world P? OK B OK P? A OK OK OK OK A A Percept variables: B=breeze, S=stench, G=glitter Percept variables: B=breeze, S=stench, G=glitter State variables: P=pit, W=wumpus, OK State variables: P=pit, W=wumpus, OK Chapter 7 13 Chapter 7 15 Exploring a wumpus world Exploring a wumpus world P? B OK B OK P? A A S OK OK OK OK A A A Percept variables: B=breeze, S=stench, G=glitter Percept variables: B=breeze, S=stench, G=glitter State variables: P=pit, W=wumpus, OK State variables: P=pit, W=wumpus, OK Chapter 7 14 Chapter 7 16
Exploring a wumpus world Exploring a wumpus world P? P? OK P P B OK P? B OK P? OK OK OK A A A S S OK OK OK OK W W A A A A Percept variables: B=breeze, S=stench, G=glitter Percept variables: B=breeze, S=stench, G=glitter State variables: P=pit, W=wumpus, OK State variables: P=pit, W=wumpus, OK Chapter 7 17 Chapter 7 19 Exploring a wumpus world Exploring a wumpus world P? P? OK P P B OK P? B OK P? BGS OK OK OK A A A A A S S OK OK OK OK W W A A A A Percept variables: B=breeze, S=stench, G=glitter Percept variables: B=breeze, S=stench, G=glitter State variables: P=pit, W=wumpus, OK State variables: P=pit, W=wumpus, OK Chapter 7 18 Chapter 7 20
Other tight spots Entailment Entailment means that one thing follows from another: P? KB | = α Knowledge base KB entails sentence α B OK P? if and only if P? A Breeze in (1,2) and (2,1) α is true in all worlds where KB is true ⇒ no safe actions OK B OK E.g., the KB containing “the Giants won”, “the Reds won”, (...) P? A A entails “the Giants won or the Reds won” [logical or, not exclusive or] (also “the Gaints won and the Reds did not lose,” ...) Smell in (1,1) E.g., x + y = 4 entails 4 = x + y (also ...) ⇒ cannot move Can use a strategy of coercion: Entailment is a relationship between sentences (i.e., syntax ) shoot straight ahead that is based on semantics wumpus was there ⇒ dead ⇒ safe S wumpus wasn’t there ⇒ safe Note: brains process syntax (of some sort) A Chapter 7 21 Chapter 7 23 Logic in general Models Logicians typically think in terms of models, which are formally Logics are formal languages for representing information structured worlds with respect to which truth can be evaluated such that conclusions can be drawn We say m is a model of a sentence α if α is true in m Syntax defines the sentences in the language M ( α ) is the set of all models of α Semantics define the “meaning” of sentences; i.e., define truth of a sentence in a world Then KB | = α iff M ( KB ) ⊆ M ( α ) (ie ( M ( KB ) ∩ M ( α )) = M ( KB ) ) E.g., the language of arithmetic E.g. KB : Giants won and Reds won α : Giants won x + 2 ≥ y is a sentence; x 2 + y > is not a sentence x x x x [ α � = “Gaints and Yankees won”] x x x x x M( ) xx x + 2 ≥ y is true iff the number x + 2 is no less than the number y x x x x x x x x x x x x x + 2 ≥ y is true in a world where x = 7 , y = 1 x x x x x x xx x x x x + 2 ≥ y is false in a world where x = 0 , y = 6 x x x x x x M(KB) x x x x x x x Chapter 7 22 Chapter 7 24
Entailment in the wumpus world Wumpus models 2 PIT 2 Breeze 1 Breeze 1 PIT 1 2 3 KB 1 2 3 Situation after detecting nothing in [1,1], moving right, breeze in [2,1] ? ? 2 PIT 2 PIT 2 Breeze 1 PIT Breeze 1 Breeze 1 1 2 3 B 1 2 3 ? 1 2 3 Consider possible models for ?s A A 2 PIT PIT assuming only pits 2 PIT Breeze 1 Breeze 1 PIT 2 PIT PIT 3 Boolean choices ⇒ 8 possible models 1 2 3 1 2 3 Breeze 1 PIT 1 2 3 KB = wumpus-world rules + observations Chapter 7 25 Chapter 7 27 Wumpus models Wumpus models 2 PIT 2 PIT 2 2 Breeze Breeze 1 1 Breeze Breeze 1 1 PIT PIT 1 2 3 1 2 3 KB 1 2 3 1 2 3 1 2 2 PIT PIT 2 2 PIT PIT 2 2 Breeze Breeze 1 1 PIT PIT Breeze Breeze 1 1 Breeze Breeze 1 1 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 2 2 PIT PIT PIT PIT 2 2 PIT PIT Breeze Breeze 1 1 Breeze Breeze 1 PIT 1 PIT 2 2 PIT PIT PIT PIT 1 2 3 1 2 3 1 2 3 1 2 3 Breeze Breeze 1 1 PIT PIT 1 2 3 1 2 3 KB = wumpus-world rules + observations α 1 = “[1,2] is safe”, KB | = α 1 , proved by model checking Chapter 7 26 Chapter 7 28
Wumpus models Inference KB ⊢ i α = sentence α can be derived from KB by procedure i 2 PIT Consequences of KB are a haystack; α is a needle. 2 Breeze 1 Entailment = needle in haystack; inference = finding it Breeze 1 PIT 1 2 3 KB 1 2 3 Soundness: i is sound if whenever KB ⊢ i α , it is also true that KB | = α 2 PIT 2 PIT 2 Breeze 1 PIT Breeze Completeness: i is complete if 1 Breeze 1 1 2 3 1 2 3 whenever KB | = α , it is also true that KB ⊢ i α 1 2 3 2 PIT PIT 2 Preview: we will define a logic (first-order logic) which is expressive enough PIT Breeze 1 Breeze to say almost anything of interest, and for which there exists a sound and 1 PIT 2 PIT PIT 1 2 3 1 2 3 complete inference procedure. Breeze 1 PIT 1 2 3 That is, the procedure will answer any question whose answer follows from what is known by the KB . KB = wumpus-world rules + observations Chapter 7 29 Chapter 7 31 Wumpus models Propositional logic: Syntax Propositional logic is the simplest logic—illustrates basic ideas 2 PIT The proposition symbols P 1 , P 2 etc are sentences 2 Breeze 1 Breeze 2 1 PIT 1 2 3 If S is a sentence, ¬ S is a sentence (negation) KB 1 2 3 If S 1 and S 2 are sentences, S 1 ∧ S 2 is a sentence (conjunction) 2 PIT 2 PIT 2 Breeze 1 PIT If S 1 and S 2 are sentences, S 1 ∨ S 2 is a sentence (disjunction) Breeze 1 Breeze 1 1 2 3 1 2 3 1 2 3 If S 1 and S 2 are sentences, S 1 ⇒ S 2 is a sentence (implication) 2 PIT PIT 2 PIT If S 1 and S 2 are sentences, S 1 ⇔ S 2 is a sentence (biconditional) Breeze 1 Breeze 1 PIT 2 PIT PIT 1 2 3 1 2 3 Breeze 1 PIT 1 2 3 KB = wumpus-world rules + observations α 2 = “[2,2] is safe”, KB �| = α 2 Chapter 7 30 Chapter 7 32
Recommend
More recommend