Presentation is loading. Please wait.

Presentation is loading. Please wait.

LOGICAL AGENTS CHAPTER 7 AIMA 3. OUTLINE  Knowledge-based agents  Wumpus world  Logic in general - models and entailment  Propositional (Boolean)

Similar presentations


Presentation on theme: "LOGICAL AGENTS CHAPTER 7 AIMA 3. OUTLINE  Knowledge-based agents  Wumpus world  Logic in general - models and entailment  Propositional (Boolean)"— Presentation transcript:

1 LOGICAL AGENTS CHAPTER 7 AIMA 3

2 OUTLINE  Knowledge-based agents  Wumpus world  Logic in general - models and entailment  Propositional (Boolean) logic  Agents based on Propositional logic 2

3 KNOWLEDGE BASES  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 3

4 A SIMPLE KNOWLEDGE-BASED AGENT This agent tells the KB what it sees, asks the KB what to do, tells the KB what it has done (or is about to do). This agent tells the KB what it sees, asks the KB what to do, tells the KB what it has done (or is about to do). The agent must be able to: The agent must be able to: Represent states, actions, etc. Represent states, actions, etc. Incorporate new percepts Incorporate new percepts Update internal representations of the world Update internal representations of the world Deduce hidden properties of the world Deduce hidden properties of the world Deduce appropriate actions Deduce appropriate actions 4

5 WUMPUS WORLD PEAS DESCRIPTION Performance measure Performance measure gold +1000, death -1000 gold +1000, death -1000 -1 per step, -10 for using the arrow -1 per step, -10 for using the arrow Environment Environment Squares adjacent to wumpus are smelly Squares adjacent to wumpus are smelly Squares adjacent to pit are breezy Squares adjacent to pit are breezy Glitter if gold is in the same square Glitter if gold is in the same square Shooting kills wumpus if you are facing it Shooting kills wumpus if you are facing it Shooting uses up the only arrow Shooting uses up the only arrow Grabbing picks up gold if in same square Grabbing picks up gold if in same square Releasing drops the gold in same square Releasing drops the gold in same square Sensors: Stench, Breeze, Glitter, Bump, Scream Sensors: Stench, Breeze, Glitter, Bump, Scream Actuators: Left turn, Right turn, Forward, Grab, Release, Shoot Actuators: Left turn, Right turn, Forward, Grab, Release, Shoot 5

6 WUMPUS WORLD CHARACTERIZATION Fully Observable No – only local perception Fully Observable No – only 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 Yes Discrete Yes Single-agent? Yes – The wumpus itself is essentially a natural feature, not another agent Single-agent? Yes – The wumpus itself is essentially a natural feature, not another agent 6

7 EXPLORING A WUMPUS WORLD 7 Directly observed: S: stench B: breeze G: glitter A: agent V: visited Inferred (mostly): OK: safe square P: pit W: wumpus 1,1 2,1 3,1 4,1 The first percept is :None, None, None, None, None], from which the agent can conclude that its neighboring squares, [1,2] and [2,1], are free of dangers—they are OK

8 EXPLORING A WUMPUS WORLD 8 In 1,1 we don’t get B or S, so we know 1,2 and 2,1 are safe. Move to 1,2. In 1,2 we feel a breeze.

9 EXPLORING A WUMPUS WORLD 9 In 1,2 we feel a breeze. So we know there is a pit in 1,3 or 2,2.

10 EXPLORING A WUMPUS WORLD 10 So go back to 1,1, then to 1,2, where we smell a stench.

11 EXPLORING A WUMPUS WORLD 11 We don't feel a breeze in 2,1, so 2,2 can't be a pit, so 1,3 must be a pit. We don't smell a stench in 1,2, so 2,2 can't be the wumpus, so 1,3 must be the wumpus. 2,2 has neither pit nor wumpus and is therefore okay.

12 EXPLORING A WUMPUS WORLD 12 We move to 2,2. We don’t get any sensory input.

13 EXPLORING A WUMPUS WORLD 13 So we know that 2,3 and 3,2 are ok.

14 EXPLORING A WUMPUS WORLD 14 Move to 3,2, where we observe stench, breeze and glitter! At this point we could infer the existence of another pit (where?), but since we have found the gold we don't bother. We have won.

15 LOGIC IN GENERAL Logics are formal languages for representing information such that conclusions can be drawn Logics are formal languages for representing information such that conclusions can be drawn Syntax defines the sentences in the language Syntax defines the sentences in the language Semantics define the "meaning" of sentences; Semantics define the "meaning" of sentences; i.e., define truth of a sentence in a world i.e., define truth of a sentence in a world E.g., the language of arithmetic E.g., the language of arithmetic x+2 ≥ y is a sentence; x2+y > {} is not a sentence 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 yx+2 ≥ y is true in a world where x = 7, y = 1 x+2 ≥ y is true iff the number x+2 is no less than the number yx+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 x+2 ≥ y is false in a world where x = 0, y = 6 15

16 ENTAILMENT Entailment means that one thing follows from another: Entailment means that one thing follows from another: Knowledge base KB entails sentence S if and only if S is true in all worlds where KB is true Knowledge base KB entails sentence S if and only if S 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., 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 E.g., x+y = 4 entails 4 = x+y Entailment is a relationship between sentences (i.e., syntax) that is based on semantics Entailment is a relationship between sentences (i.e., syntax) that is based on semantics 16

17 ENTAILMENT IN THE WUMPUS WORLD Situation after detecting nothing in [1,1], moving right, breeze in [2,1] Situation after detecting nothing in [1,1], moving right, breeze in [2,1] Consider possible models for KB assuming only pits: there are 3 Boolean choices  8 possible models (ignoring sensory data) Consider possible models for KB assuming only pits: there are 3 Boolean choices  8 possible models (ignoring sensory data) 17

18 WUMPUS MODELS FOR PITS 18

19 WUMPUS MODELS KB = wumpus-world rules + observations. Only the three models in red are consistent with KB. KB = wumpus-world rules + observations. Only the three models in red are consistent with KB. 19

20 WUMPUS MODELS 20 KB plus hypothesis S1 that pit is not in 1.2. KB is solid red boundary. S1 is dotted yellow boundary. KB is contained within S1, so KB entails S; in every model in which KB is true, so is S. We can conclude that the pit is not in1.2. KB plus hypothesis S2 that pit is not in 2.2. KB is solid red boundary. S2 is dotted brown boundary. KB is not within S1, so KB does not entail S2; nor does S2 entail KB. So we can't conclude anything about the truth of S2 given KB.

21 INFERENCE KB entails i S = sentence S can be derived from KB by procedure i KB entails i S = sentence S can be derived from KB by procedure i Soundness: i is sound if it derives only sentences S that are entailed by KB Soundness: i is sound if it derives only sentences S that are entailed by KB Completeness: i is complete if it derives all sentences S that are entailed by KB. Completeness: i is complete if it derives all sentences S that are entailed by KB. First-order logic: First-order logic: Has a sound and complete inference procedure Has a sound and complete inference procedure Which will answer any question whose answer follows from what is known by the KB. Which will answer any question whose answer follows from what is known by the KB. And is richly expressive And is richly expressive We must also be aware of the issue of grounding: We must also be aware of the issue of grounding: the connection between logical reasoning processes and the real environment in which the agent exists. the connection between logical reasoning processes and the real environment in which the agent exists. how do we know that KB is true in the real world? how do we know that KB is true in the real world? Sensing Sensing General rules General rules learning learning 21

22 PROPOSITIONAL LOGIC: SYNTAX Propositional logic is the simplest logic – illustrates basic ideas Propositional logic is the simplest logic – illustrates basic ideas The proposition symbols P 1, P 2 etc are sentences The proposition symbols P 1, P 2 etc are sentences If S is a sentence,  S is a sentence (negation) If S is a sentence,  S is a sentence (negation) If S 1 and S 2 are sentences, S 1  S 2 is a sentence (conjunction) If S 1 and S 2 are sentences, S 1  S 2 is a sentence (conjunction) If S 1 and S 2 are sentences, S 1  S 2 is a sentence (disjunction) If S 1 and S 2 are sentences, S 1  S 2 is a sentence (disjunction) If S 1 and S 2 are sentences, S 1  S 2 is a sentence (implication) If S 1 and S 2 are sentences, S 1  S 2 is a sentence (implication) If S 1 and S 2 are sentences, S 1  S 2 is a sentence (biconditional) If S 1 and S 2 are sentences, S 1  S 2 is a sentence (biconditional) 22

23 WUMPUS WORLD SENTENCES Let P i,j be true if there is a pit in [i, j]. Let B i,j be true if there is a breeze in [i, j].  P 1,1  B 1,1 B 2,1 "Pits cause breezes in adjacent squares" "Pits cause breezes in adjacent squares" B 1,1  (P 1,2  P 2,1 ) B 2,1  (P 1,1  P 2,2  P 3,1 ) 23

24 INFERENCE BY ENUMERATION Depth-first enumeration of all models is sound and complete Depth-first enumeration of all models is sound and complete For n symbols, time complexity is O(2 n ), space complexity is O(n) For n symbols, time complexity is O(2 n ), space complexity is O(n) 24

25 INFERENCE-BASED AGENTS IN THE WUMPUS WORLD A wumpus-world agent using propositional logic:  P 1,1  W 1,1 B x,y  (P x,y+1  P x,y-1  P x+1,y  P x-1,y ) S x,y  (W x,y+1  W x,y-1  W x+1,y  W x-1,y ) W 1,1  W 1,2  …  W 4,4  W 1,1   W 1,2  W 1,1   W 1,3 …  64 distinct proposition symbols, 155 sentences 25

26 26

27 EXPRESSIVENESS LIMITATION OF PROPOSITIONAL LOGIC Rapid proliferation of clauses. Rapid proliferation of clauses. For instance, Wumpus KB contains "physics" sentences for every single square For instance, Wumpus KB contains "physics" sentences for every single square Very bushy inference, especially if forward chaining. Very bushy inference, especially if forward chaining. Not trivial to express complex relationships; people don't naturally think in logical terms. Not trivial to express complex relationships; people don't naturally think in logical terms. Monotonic: if something is true it stays true Monotonic: if something is true it stays true Binary: something is either true or false, never maybe or unknown Binary: something is either true or false, never maybe or unknown 27

28 PROS AND CONS OF PROPOSITIONAL LOGIC Propositional logic is declarative Propositional logic is declarative Propositional logic allows partial/disjunctive/negated information (unlike most data structures and databases) Propositional logic allows partial/disjunctive/negated information (unlike most data structures and databases) Propositional logic is compositional: Propositional logic is compositional: meaning of B 1,1  P 1,2 is derived from meaning of B 1,1 and of P 1,2 meaning of B 1,1  P 1,2 is derived from meaning of B 1,1 and of P 1,2 Meaning in propositional logic is context-independent (unlike natural language, where meaning depends on context) Meaning in propositional logic is context-independent (unlike natural language, where meaning depends on context)  Propositional logic has very limited expressive power (unlike natural language) E.g., cannot say "pits cause breezes in adjacent squares“ E.g., cannot say "pits cause breezes in adjacent squares“ except by writing one sentence for each square except by writing one sentence for each square 28

29 INFERENCE When we have all this knowledge we want to DO SOMETHING with it When we have all this knowledge we want to DO SOMETHING with it Typically, we want to infer new knowledge Typically, we want to infer new knowledge An appropriate action to take An appropriate action to take Additional information for the Knowledge Base Additional information for the Knowledge Base Some typical forms of inference include Some typical forms of inference include Forward chaining Forward chaining Backward chaining Backward chaining Resolution Resolution 29

30 AGENTS BASED ON PROPOSITIONAL LOGIC 30

31 AGENTS BASED ON PROPOSITIONAL LOGIC The first step is to enable the agent to deduce, the state of the world given its percept history. This requires writing down a The first step is to enable the agent to deduce, the state of the world given its percept history. This requires writing down a complete logical model of the effects of actions complete logical model of the effects of actions The agent can use logical inference to construct plans that are guaranteed to achieve its goals. The agent can use logical inference to construct plans that are guaranteed to achieve its goals. Using SATPLAN : A propositional planning procedure Using SATPLAN : A propositional planning procedure 31

32 32 THE CURRENT STATE OF THE WORLD The agent knows that the starting square contains no pit (–p1,1) and no wumpus –W1,1 The agent knows that the starting square contains no pit (–p1,1) and no wumpus –W1,1 Thus, we include a large collection of sentences of the that form Thus, we include a large collection of sentences of the that form write down the transition model of the wumpus world as a set of logical sentences. Forward, west and other actions: Grab, Shoot, Climb, TurnLeft, and TurnRight. write down the transition model of the wumpus world as a set of logical sentences. Forward, west and other actions: Grab, Shoot, Climb, TurnLeft, and TurnRight.

33 A HYBRID AGENT 33 Condition-action & problem-solving algorithms. Condition-action & problem-solving algorithms. By Asking questions of the knowledge base, to work out which squares are safe and which have yet to visited. By Asking questions of the knowledge base, to work out which squares are safe and which have yet to visited.

34 SUMMARY Logical agents apply inference to a knowledge base to derive new information and make decisions Logical agents apply inference to a knowledge base to derive new information and make decisions Basic concepts of logic: Basic concepts of logic: syntax: formal structure of sentences syntax: formal structure of sentences semantics: truth of sentences wrt models semantics: truth of sentences wrt models entailment: necessary truth of one sentence given another entailment: necessary truth of one sentence given another inference: deriving sentences from other sentences inference: deriving sentences from other sentences soundness: derivations produce only entailed sentences soundness: derivations produce only entailed sentences completeness: derivations can produce all entailed sentences completeness: derivations can produce all entailed sentences Wumpus world requires the ability to represent partial and negated information, reason by cases, etc. Wumpus world requires the ability to represent partial and negated information, reason by cases, etc. Propositional logic lacks expressive power Propositional logic lacks expressive power 34


Download ppt "LOGICAL AGENTS CHAPTER 7 AIMA 3. OUTLINE  Knowledge-based agents  Wumpus world  Logic in general - models and entailment  Propositional (Boolean)"

Similar presentations


Ads by Google