'
&
B.Y. Choueiry
Title:
Logial Agents
AIMA: Chapter 7 (Setions 7.1, 7.2, and 7.3)
1
Introdution to Artiial Intelligene
CSCE 476-876, Spring 2015
URL: www.se.unl.edu/~houeiry/S15-476-876
Instrutor's notes #11
Marh 16, 2015
Berthe Y. Choueiry (Shu-we-ri)
(402)472-5444
$
%
2
•
Knowledge bases
•
Wumpus world
•
Logi for Knowledge Representation & Reasoning
Instrutor's notes #11
Marh 16, 2015
'
&
B.Y. Choueiry
Outline
Syntax
Semantis
Inferene mehanisms: omplexity, ompleteness
Propositional logi/sentential logi
Prediate logi/rst-order logi
$
%
'
&
B.Y. Choueiry
Knowledge Base
A fat in the world:
A representation of a fat in the world
A sentene= a representation of a fat in the world in a
formal language
3
A Knowledge Based (KB):
A set sentenes
A set (of representations) of fats about the world
Instrutor's notes #11
Marh 16, 2015
Issues:
Aess to KB, Representation (language), Reasoning
(inferene)
$
%
'
&
B.Y. Choueiry
Level of Knowledge
Agents an be viewed at various levels:
1.
Epistemologial:
Abstrat desription of what the agent knows about the world
4
2.
Logial:
Enoding of knowledge into sentenes
Instrutor's notes #11
Marh 16, 2015
3.
Implementation:
Atual implementation (lists, arrays, hash tables, et.)
•
Very important for performane of agent
•
Irrelevant for higher levels of knowledge
$
%
'
&
B.Y. Choueiry
A simple KB-agent
function KB-AGENT( percept) returns an action
static: KB, a knowledge base
t, a counter, initially 0, indicating time
5
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, ations, et.
Instrutor's notes #11
Marh 16, 2015
inorporate new perepts
update internal representations of the world
dedue hidden properties of the world
dedue appropriate ations
$
%
function KB-AGENT( percept) returns an action
static: KB, a knowledge base
t, a counter, initially 0, indicating time
'
&
B.Y. Choueiry
Knowledge-Based Agent
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
6
Pereives:
Tells KB about new perepts (new sentenes)
Representation: Make-Perept-Sentene
Instrutor's notes #11
Marh 16, 2015
Aess to KB:
Asks KB about ations to take (inferene)
Two primitives: Ask and Tell hide reasoning details
Ats:
Tells KB about ations (new sentenes)
Representation: Make-Ation-Sentene,
Make-Ation-Query
$
%
'
&
B.Y. Choueiry
Motivating example:
The Wumpus world
Early omputer game
Agent explores a ave with:
7
4
Breeze
Stench
Breeze
3
Stench
PIT
Breeze
PIT
Gold
Instrutor's notes #11
Marh 16, 2015
•
bottomless pits
•
a beast that eats anyone who enters
the room, and
•
heap of gold to trap
2
Breeze
Stench
Breeze
1
Breeze
PIT
START
1
2
3
4
$
%
of the Wumpus world
Performane measure:
'
&
B.Y. Choueiry
PEAS desription
gold +1000, death -1000, -1 per step, -10
for using the arrow
Environment:
Squares adjaent to Wumpus are smelly
Squares adjaent to pit are breezy
8
Glitter i gold is in the same square
Shooting kills Wumpus if you are faing it
Shooting uses up the only arrow
Grabbing piks up gold if in same square
Instrutor's notes #11
Marh 16, 2015
Releasing drops the gold in same square
Sensors:
Breeze, Glitter, Smell
Atuators:
Left turn, Right turn, Forward, Grab, Release, Shoot
$
%
'
&
B.Y. Choueiry
Wumpus World:
Charaterization
Is the world:
9
Instrutor's notes #11
Marh 16, 2015
•
Observable?
•
Deterministi?
•
Episodi?
•
Stati?
•
Disrete?
•
Single-agent?
No, only loal pereption
Yes, outome exatly speied
No, sequential at the level of ations
Yes, Wumpus/Pits don't move
Yes
Yes, Wumpus onsidered a natural feature
$
%
single/multiple onguration
'
&
B.Y. Choueiry
Empirial evaluations:
An agent an do well in a single environment: learns the
environment, exeutes rules.
Agent must be tested in a omplete lass of environments and its
average performane must be determined
→
empirial experiments
10
•
Constraints: start from position [1,1℄, limited to 4×4 grid
•
Loation of Wumpus and Gold hosen randomly with a
uniform distribution (all squares are possible exept [1,1℄)
Instrutor's notes #11
Marh 16, 2015
•
Eah square, exept [1,1℄, an be a pit with probability 0.2
•
Terribly bad ases: gold in a pit or surrounded by pits
$
%
•
'
&
B.Y. Choueiry
Wumpus World:
Ating & Reasoning
After reeiving initial perepts, agent knows it is in [1,1℄ and it
is OK
11
•
No stenh or breeze in [1,1℄
⇒
•
Cautious agent moves only to square it knows it is OK
•
Agent moves only to square [2,1℄, detets breeze y
[1,2℄ and [2,1℄ are danger-free
⇒∃
a pit in
neighboring squares [1,1℄, [2,2℄ and [3,1℄. Agent knows no pit in
[1,1℄
Instrutor's notes #11
Marh 16, 2015
•
→
Pit indiated in [2,2℄ and [3,1℄ with
P?
Not visited OK squares? Only [1,2℄. Agent goes to [1,1℄,
proeeds to [1,2℄
$
%
Breeze
Stench
Breeze
3
Stench
'
&
B.Y. Choueiry
4
PIT
Breeze
PIT
Gold
2
Breeze
1
Wumpus World:
2,4
3,4
4,4
1,3
2,3
3,3
4,3
1,2
2,2
3,2
4,2
12
1,4
= Agent
= Breeze
= Glitter, Gold
= Safe square
= Pit
= Stench
= Visited
= Wumpus
Instrutor's notes #11
Marh 16, 2015
1,1
2
2,4
3,4
4,4
1,3
2,3
3,3
4,3
1,2
2,2
3,2
4,2
P?
3
4
OK
2,1
3,1
A
OK
1
1,4
OK
Breeze
PIT
START
Ating & Reasoning
A
B
G
OK
P
S
V
W
Breeze
Stench
4,1
1,1
2,1
V
OK
OK
(a)
A
B
OK
3,1
P?
4,1
(b)
$
%
•
'
&
B.Y. Choueiry
Wumpus World:
Ating & Reasoning
Agents detets stenh in [1,2℄
⇒
Wumpus nearby!
Possibilities: [1,1℄, [1,3℄ or [2,2℄.
Agent knows [1,1℄ is Wumpus-free (Agent was there!)
Agent an infer [2,2℄ is Wumpus-free (6
∃
stenh in [2,1℄)
Agent infers Wumpus is in [1,3℄ (W!)
13
•
Lak of breeze in [1,2℄
But,
∃
⇒
[2,2℄ is pit-free
a pit in either [2,2℄ or [3,1℄
⇒∃
pit in [3,1℄ (P!)
Inferene ombines knowledge gained at dierent times and
plaes, beyond the abilities of most animals, but Logial
Instrutor's notes #11
Marh 16, 2015
Inferene an handle this
•
Sine [2,2℄ is
•
et.
OK
and not visited, Agent moves there
$
%
4
Breeze
Stench
Breeze
3
Stench
'
&
B.Y. Choueiry
Wumpus World:
Ating & Reasoning
PIT
Breeze
PIT
Gold
Breeze
Stench
2
Breeze
1
Breeze
PIT
START
1
2
1,4
3
4
3,4
4,4
2,3
3,3
4,3
2,2
3,2
4,2
14
2,4
1,3
1,2
W!
A
Instrutor's notes #11
Marh 16, 2015
S
OK
1,1
= Agent
= Breeze
= Glitter, Gold
= Safe square
= Pit
= Stench
= Visited
= Wumpus
1,4
2,4
1,3 W!
1,2
OK
2,1
V
OK
A
B
G
OK
P
S
V
W
B
V
OK
3,1
P!
4,1
S
V
OK
1,1
4,4
2,3
3,3 P?
4,3
2,2
3,2
4,2
A
S G
B
V
OK
2,1
V
OK
(a)
3,4
P?
B
V
OK
3,1
P!
4,1
(b)
$
%
'
&
B.Y. Choueiry
The point of
the Wumpus world
15
In eah ase where the agent draws a onlusion from the available
information, that onlusions is guaranteed to be orret if the
available information is orret.
Instrutor's notes #11
Marh 16, 2015
−→
Fundamental property of logial reasoning.
$
%
'
&
B.Y. Choueiry
Logi in general
Logis
are formal languages for representing information suh that
onlusions an be drawn
Syntax
denes the sentenes in the language (grammar)
Semantis
dene the meaning of sentenes; i.e., dene truth of
a sentene in a world
16
Example: the language of arithmeti
Instrutor's notes #11
Marh 16, 2015
•
Syntax:
x+2≥y
•
Semantis:
x+2≥y
number y
x+2 ≥ y
x+2 ≥ y
is a sentene;
x2 + y >
is true i the number
x+2
is not a sentene
is no less than the
x = 7, y = 1
where x = 0, y = 6
is true in a world where
is false in a world
$
%
'
&
B.Y. Choueiry
Types of logi
Logis are haraterized by what they ommit to as primitives
Ontologial ommitment
:
what existsfats? objets? time? beliefs?
Epistemologial ommitment
:
17
what states of knowledge?
Instrutor's notes #11
Marh 16, 2015
Language
Ontological Commitment
(What exists in the world)
Epistemological Commitment
(What an agent believes about facts)
Propositional logic
First-order logic
Temporal logic
Probability theory
Fuzzy logic
facts
facts, objects, relations
facts, objects, relations, times
facts
degree of truth
true/false/unknown
true/false/unknown
true/false/unknown
degree of belief 0…1
degree of belief 0…1
$
%
Sentences
Facts
18
Fats:
Semantics
World
Sentence
Entails
Semantics
Representation
'
&
B.Y. Choueiry
Knowledge representation & reasoning
Follows
Fact
in the world
Representations:
Reasoning:
in the omputer
proess of onstruting new representations from old ones
Instrutor's notes #11
Marh 16, 2015
ensures new representations orrespond to fats
that atually follow from fats in the world
Proper Reasoning:
$
%
Entailment means that one thing follows from another:
|= α)
(KB
Knowledge base KB entails sentene
i
'
&
B.Y. Choueiry
Entailment
α
α
is true in all worlds where KB is true
19
{a ∧ b}, then
|= a; KB |= b; KB |= a ∨ b
Example: KB:
KB
Instrutor's notes #11
Marh 16, 2015
Entailment is a relationship between sentenes (i.e., syntax)
that is based on semantis
(α
|= β ):
the truth of
For example: (x+y=4)
|=
β
ontains the truth of
α
(4=x+y)
$
%
Logiians typially think in terms of
models, whih are formally
'
&
B.Y. Choueiry
Models
strutured worlds with respet to whih truth an be evaluated
We say
M (α)
20
Then
m is a model of
a sentene
is the set of all models of
KB |= α
if and only if
M(α )
α
if
α
is true in
m
α
M (KB) ⊆ M (α)
Instrutor's notes #11
Marh 16, 2015
11111111
00000000
00000000
11111111
00000000
11111111
00000000
11111111
00000000
11111111
M(KB)
00000000
11111111
00000000
11111111
00000000
11111111
00000000
11111111
$
%
in the Wumpus world
Situation: Agent deteted nothing in [1,1℄, breeze in [2,1℄
'
&
B.Y. Choueiry
Entailment
3
2 =8 possible models
Perepts + the PEAS desription = KB
Agent wonders whether pit is in [1,2℄, [2,2℄, and [3,1℄:
Only 3 models where the KB is true
21
α1
= no pit in [1,2℄:
α1
is true in 4 models.
PIT
2
2
Bree z e
1
1
Bree z e
PIT
2
3
1
KB
1
Instrutor's notes #11
Marh 16, 2015
α1
2
3
2
PIT
PIT
2
2
Bree z e
1
1
Bree z e
1
Bree z e
1
2
1
1
2
3
3
2
2
PIT
1
Bree z e
PIT
PIT
2
PIT
PIT
1
2
PIT
Bree z e
1
1
PIT
2
3
2
3
3
1
1
Bree z e
PIT
2
3
$
%
'
&
B.Y. Choueiry
Entailment
in the Wumpus world
PIT
2
2
Bree z e
1
1
Bree z e
PIT
2
3
1
KB
1
α1
2
3
2
PIT
PIT
2
2
Bree z e
1
1
Bree z e
1
Bree z e
1
2
1
2
3
2
2
PIT
1
Bree z e
PIT
22
PIT
2
PIT
PIT
1
2
1
= no pit in [1,2℄,
Model heking: KB
|= α1 ,
2
3
3
1
α1
PIT
Bree z e
1
Consider:
3
3
1
1
PIT
2
KB
α2
Bree z e
PIT
2
3
= no pit in [2,2℄
6|= α2
Instrutor's notes #11
Marh 16, 2015
Given KB, agent annot onlude whether
α2
holds or not
Entailment an be used to derive onlusions: Inferene
Inferene here is done by model heking
$
%
KB
⊢i α ≡ α
is derived from KB by proedure
Consequenes of KB are a haystak;
α
i
'
&
B.Y. Choueiry
Inferene
is a needle.
Entailment = needle in haystak; inferene = nding it
Soundness: i is sound if
23
whenever KB
⊢i α,
it is also true that KB
Completeness: i is omplete
whenever KB
|= α,
|= α
if
it is also true that KB
⊢i α
That is, the proedure will answer any question whose answer
Instrutor's notes #11
Marh 16, 2015
follows from what is known by the KB
The reord of operation of a sound inferene proedure is a
proof
Next, propositional logi: syntax, semantis, and inferene
$
%
© Copyright 2026 Paperzz