0% found this document useful (0 votes)
21 views23 pages

Lecture 4 - Logical Agents

This document discusses the concept of knowledge-based agents, focusing on the Wumpus World as a case study for logical reasoning and inference. It introduces a knowledge base (KB) that allows agents to infer new facts from existing ones, emphasizing the importance of logic in problem-solving. The document also outlines the structure of propositional logic and its application in representing knowledge about the environment.

Uploaded by

watif16207
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views23 pages

Lecture 4 - Logical Agents

This document discusses the concept of knowledge-based agents, focusing on the Wumpus World as a case study for logical reasoning and inference. It introduces a knowledge base (KB) that allows agents to infer new facts from existing ones, emphasizing the importance of logic in problem-solving. The document also outlines the structure of propositional logic and its application in representing knowledge about the environment.

Uploaded by

watif16207
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 23

TEB 2023: Artificial Intelligence

Chapter 4
Logical Agents
Recap: Informed Search
Example: Heuristic Function

h(x)
Comparison

Uniform Cost Greedy A*


Today: Course Objectives

 Knowledge-Based Agents
 The Wumpus World
 Logic
 Propositional Logic
 Agents Based on Propositional Logic
Why do we need logic?

 Problem-solving agents were very inflexible: hard code every possible


state.

 Search is almost always exponential in the number of states.

 Problem solving agents cannot infer unobserved information.

 We want an agent that can reason similarly to humans.


Knowledge and Reasoning

To address these issues we will introduce:

 A knowledge base (KB): a list of facts that are known to the agent.

 Rules to infer new facts from old facts using rules of inference.

 Logic provides the natural language for this.


Knowledge-Based Agents
 Central component of knowledge-based agent – Knowledge Base (KB).

 Knowledge base:
 set of sentences in a formal language.

 Declarative approach to building an agent:


 Tell it what it needs to know.
 Ask it what to do  answers should follow from the KB.
 There must be a way to add sentences to KB and query
 Tell and Ask operations involve inference (deriving new sentences
from old).
Simple Knowledge-Based Agent

 Each time the agent program is called, it does three things:


 First, it TELLs the knowledge base what it perceives.
 Second, it ASKs the knowledge base what action it should perform.
 Third, the agent program TELLs the knowledge base which action was chosen, and the agent
executes the action.
The Wumpus World
 The wumpus world is a cave consisting of rooms connected by
passageways.
 In the cave is the terrible wumpus, a beast that eats anyone who
enters its room.

 The wumpus can be shot by an agent, but the agent has only one
arrow.
 Some rooms contain bottomless pits that will trap anyone (except for
the wumpus).

 The only mitigating feature of this bleak environment is the


possibility of finding a heap of gold.
The 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

 Actuators: Left turn, Right turn, Forward, Grab, Release, Shoot

 Sensors: eyes, human player


Exploring the Wumpus World

[1,1] The KB initially contains the rules of the environment.

The first percept is [none, none,none,none,none],


move to safe cell e.g. 2,1
Exploring the Wumpus World

[2,1] = breeze

indicates that there is a pit in [2,2] or [3,1],

return to [1,1] to try next safe cell


Exploring the Wumpus World

[1,2] Stench in cell which means that wumpus is in [1,3] or [2,2]


YET … not in [1,1]
YET … not in [2,2] or stench would have been detected in [2,1]
(this is relatively sophisticated reasoning!)
Exploring the Wumpus World

[1,2] Stench in cell which means that wumpus is in [1,3] or [2,2]


YET … not in [1,1]
YET … not in [2,2] or stench would have been detected in [2,1]
(this is relatively sophisticated reasoning!)
THUS … wumpus is in [1,3]
THUS [2,2] is safe because of lack of breeze in [1,2]
THUS pit in [1,3] (again a clever inference)
move to next safe cell [2,2]
Exploring the Wumpus World

[2,2] move to [2,3]

[2,3] detect glitter , smell, breeze


THUS pick up gold
THUS pit in [3,3] or [2,4]
What our example has shown us

 Can represent general knowledge about an environment by a


set of rules and facts

 Can gather evidence and then infer new facts by combining


evidence with the rules

 The conclusions are guaranteed to be correct if


 The evidence is correct
 The rules are correct
 The inference procedure is correct
-> logical reasoning

 The inference may be quite complex


 E.g., evidence at different times, combined with different rules, etc
Logic
 We used logical reasoning to find the gold.
 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 syntax

 x+2 ≥ y is true in a world where x = 7, y = 1

semantics
 x+2 ≥ y is false in a world where x = 0, y = 6
Propositional Logic
 Propositional logic is the simplest logic – illustrates basic ideas

 The proposition symbols P1, P2 etc are sentences

 If S is a sentence, S is a sentence (negation)

 If S1 and S2 are sentences, S1  S2 is a sentence (conjunction)

 If S1 and S2 are sentences, S1  S2 is a sentence (disjunction)

 If S1 and S2 are sentences, S1  S2 is a sentence (implication)

 If S1 and S2 are sentences, S1  S2 is a sentence (biconditional)


Truth Table for Connectives
Wumpus World Sentenses
Let Pi,j be true if there is a pit in [i, j].
Let Bi,j be true if there is a breeze in [i, j].
start:  P1,1
 B1,1
B2,1
 "Pits cause breezes in adjacent squares"
B1,1  (P1,2  P2,1)
B2,1  (P1,1  P2,2  P3,1)

 KB can be expressed as the conjunction of all of these


sentences

 Note that these sentences are rather long-winded!


 E.g., breeze “rule” must be stated explicitly for each square
 First-order logic will allow us to define more general patterns.
Summary

 A knowledge base (KB): a list of facts that are known to the agent.

 Rules to infer new facts from old facts using rules of inference.

 Logic provides the natural language for KB design.

 Using PROLOG to design KB (Lecture 4 Part 2).

You might also like