Logical Agents Reasoning [Ch 6] Propositional Logic [Ch 6] - - PDF document

logical agents
SMART_READER_LITE
LIVE PREVIEW

Logical Agents Reasoning [Ch 6] Propositional Logic [Ch 6] - - PDF document

Logical Agents Reasoning [Ch 6] Propositional Logic [Ch 6] Predicate Calculus Representation [Ch 7] Predicate Calculus Inference [Ch 9] Implemented Systems [Ch 10] Applications [Ch 8] Planning [Ch 11]


slide-1
SLIDE 1

Logical Agents

  • Reasoning

[Ch 6]

  • Propositional Logic

[Ch 6]

  • Predicate Calculus – Representation

[Ch 7]

  • Predicate Calculus – Inference

[Ch 9]

  • Implemented Systems

[Ch 10]

  • Applications

[Ch 8]

  • Planning

[Ch 11]

− Using “Situation Calculus” − Simple − GraphPlan [Notes]

PC-Plan 1

slide-2
SLIDE 2

Typical Wumpus World

Breeze Breeze Breeze Breeze Breeze

Stench Stench

Breeze

PIT PIT PIT

1 2 3 4 1 2 3 4

START

Gold

Stench

PC-Plan 2

slide-3
SLIDE 3

Simple Reflex Agent

Rep’n: At time = t, specify

Percept([s,b,g,u,c], t)

where s ∈ {Stench, −}, b ∈ {Breeze, −}, . . . Eg: Tell(KB, Percept([Stench,-,Glitter,-,-], 3) )

  • Connect percepts directly to actions:

∀s, b, u, c, t Percept([s, b, Glitter, u, c], t) ⇒ Action( Grab, t )

  • Or, more indirectly:

∀s, b, u, c, t Percept([s, b, Glitter, u, c], t) ⇒ AtGold(t) ∀t AtGold(t) ⇒ Action(Grab, t)

Q1: Which is more flexible? Q2: Limitations of reflex approach?

PC-Plan 3

slide-4
SLIDE 4

Problem with Reflex Agents

Q: When to Climb? A: @ [ 1, 1 ], and have Gold . . . but . . . agent cannot sense

  • being @ [ 1, 1 ]

having Gold

  • Also. . . May be @ [ 2, 3 ] when hunting for gold

Then reach same [ 2, 3 ] when returning As SAME percepts both times & reflex agent can ONLY use percept to decide on action agent must take SAME actions both times. . . ⇒ ∞-loop! ⇒ Agent needs INTERNAL MODEL of state/world

PC-Plan 4

slide-5
SLIDE 5

Tracking a Changing World

  • Consider FINDING KEYS

. . . when “Keys are in pocket” . . . agent could keep percept history, & replay it Better: just store this info! FACT: Any decision based on past/present percepts can be based on current “world state”

(. . . which is updated each action)

So... perhaps KB should keep ONLY info about current situation

PC-Plan 5

slide-6
SLIDE 6

Single-Time Knowledge Base

Time 0: Initial configuration At(Agent, [ 1, 1 ]) Facing(Agent, North) Smell(No) ... Time 1: Then take a step Action = Forward NOW in new situation: Remove false statements remove At(Agent, [ 1, 1 ]), . . . Add in statement that are now true: add At(Agent, [ 1, 2 ]), . . . ⇒ use revised KB: At(Agent, [ 1, 2 ]) Facing(Agent, North) Smell(Yes) ... Time 2: Turn to the right Actions = TurnRight ⇒ use revised KB: At(Agent, [ 1, 2 ]) Facing(Agent, East) Smell(Yes) ...

PC-Plan 6

slide-7
SLIDE 7

Problems with Single-Time KBs

but . . . may need to reason about MANY times Eg: “Was there a stench in [ 1, 2 ] and [ 2, 3 ]?”

  • Need to

Maintain info from previous states . . . labeled with state

  • Kinda like “time stamp”

. . . but “time” is not relevant better to record SEQUENCE of ACTIONS!

Compare: Having GOLD at time 4

with Having GOLD after Going forward, then Turning right, then Going forward, then Grabbing ⇒ Sequence of actions ≈ “plan”!

PC-Plan 7

slide-8
SLIDE 8

Situation Calculus

  • Tag each “changable predicate” with “time”:

Eg: At( Agent, [ 1, 1 ], S0) At( Agent, [ 1, 2 ], Result( Forward, S0) ) At( Agent, [ 1, 3 ], Result(Forward, Result( Forward, S0))) . . . Notice: all stay around!

  • Only “label” predicates that can change.

As Pit doesn’t move, At(Pit, 3, 2) sufficient Similarly, just 2+2=4 , . . .

  • “Time” only wrt actions

Snapshot of SITUATION. . .

World represented as SERIES OF SITUATIONS connected by actions

PC-Plan 8

slide-9
SLIDE 9

Updating State, Based on Action

PIT PIT PIT

G

  • l

d

P I T P I T P I T

Gold

P I T P I T P I T

Gold

P I T P I T P I T

Gold

Forward S0 Forward TurnRight S1 S2 S3

S1 = Result( Forward, S0 ) S2 = Result( TurnRight, S1 ) =

Result( TurnRight, Result(Forward, S0) )

S3 = Result( Forward, S2 ) =

Result( Forward, Result( TurnRight, Result( Forward, S0 ) ) ) Result: Action × State → State

PC-Plan 9

slide-10
SLIDE 10

Computing Location

  • Can compute location:

∀i, j, s At(Ag, [ i, j ], s) ∧ Facing(Ag, North, s) ⇒ At(Ag, [ i, j + 1 ], Result(Forward, s)) ∀i, j, s At(Ag, [ i, j ], s) ∧ Facing(Ag, East, s) ⇒ At(Ag, [ i − 1, j ], Result(Forward, s)) . . .

  • Can compute orientation:

∀i, j, s Facing(Ag, North, s) ⇒ Facing(Ag, East, Result( TurnRight, s) ) . . .

PC-Plan 10

slide-11
SLIDE 11

Interpreting Percepts

  • Extract Individual Percepts

∀ b, g, u, c, t Percept([Stench, b, g, u, c], t) ⇒ Stench(t) ∀ b, u, c, s, t Percept([s, Breeze, g, u, c], t) ⇒ Breeze(t)

  • Combine with State to make Infer-

ences about Locations

∀ ℓ, s At(Agent, ℓ, s) ∧ Stench(s) ⇒ Smelly(ℓ) ∀ ℓ, s At(Agent, ℓ, s) ∧ Breeze(s) ⇒ Breezy(ℓ)

  • Combine with Causal Rules to Infer

Locations of Wumpus, Pits

∀ ℓ Breezy(ℓ) ⇔ [∃ x PitAt(x) ∧ Adj(ℓ, x)] ∀ ℓ Stench(ℓ) ⇔ [∃ x WumpusAt(x) ∧ Adj(ℓ, x)] ∀ ℓ OK(ℓ) ⇔ (¬WumpusAt(ℓ) ∧ ¬PitAt(ℓ))

PC-Plan 11

slide-12
SLIDE 12

Deducing Hidden Properties

  • Squares are breezy near a pit:

– Diagnostic rule — infer cause from effect

∀ ℓ Breezy(ℓ) ⇒ ∃ x Pit(x) ∧ Adj(ℓ, x)

– Causal rule — infer effect from cause

∀ ℓ, x Pit(x) ∧ Adj(ℓ, x) ⇒ Breezy(ℓ)

– Neither is complete. . .

Eg, the causal rule doesn’t say whether squares far away from pits can be breezy

⇒ Definition for Breezy predicate:

∀ ℓ Breezy(ℓ) ⇔ [∃ x PitAt(x) ∧ Adj(ℓ, x)]

  • Squares are stenchy near the wumpus:

∀ ℓ Stench(ℓ) ⇔ [∃ x WumpusAt(x) ∧ Adj(ℓ, x)]

PC-Plan 12

slide-13
SLIDE 13

Using Information

  • After concluding

¬Stench([ 1, 1 ]) ¬Stench([ 1, 2 ]) Stench([ 2, 1 ])

∀ℓ Adj([ 1, 1 ], ℓ) ⇔ (ℓ = [ 2, 1 ] ∨ ℓ = [ 1, 2 ]) ∀ℓ Adj([ 2, 1 ], ℓ) ⇔ (ℓ = [ 1, 1 ] ∨ ℓ = [ 2, 2 ] ∨ ℓ = [ 3, 1 ]) ∀ℓ Adj([ 1, 2 ], ℓ) ⇔ (ℓ = [ 1, 1 ] ∨ ℓ = [ 2, 2 ] ∨ ℓ = [ 1, 3 ])

  • Can derive

¬[∃ x WumpusAt(x) ∧ Adj([ 1, 1 ], x)] ∀ x Adj([ 1, 1 ], x) ⇒ ¬WumpusAt(x) ¬WumpusAt([ 1, 2 ]), ¬WumpusAt([ 2, 1 ]) ¬[∃ x WumpusAt(x) ∧ Adj([ 1, 2 ], x)] ¬WumpusAt([ 1, 1 ]), ¬WumpusAt([ 2, 2 ]), ¬WumpusAt([ 3, 1 ]) [∃ x WumpusAt(x) ∧ Adj([ 2, 1 ], x)] WumpusAt([ 1, 1 ]) ∨ WumpusAt([ 2, 2 ]) ∨ WumpusAt([ 1, 3 ]) . . . ⇒ WumpusAt([ 1, 3 ])

PC-Plan 13

slide-14
SLIDE 14

Connecting Inferences to Actions

  • Rate Each Action

∀ ℓ1, s WumpusAt(ℓ1) ∧ LocationAhead(Agent, s) = ℓ1 ⇒ Deadly( Forward, s) ∀ ℓ1, s OK(ℓ1,s) ∧ LocationAhead(Agent,s) = ℓ1 ∧ ¬Visited(ℓ1,s) ⇒ Good(Forward, s) ∀ ℓ1, s Gold(ℓ1,s) ⇒ Great(Grab, s)

  • Choose Best Action

∀ a, s Great(a, s) ⇒ Action(a, s) ∀ a, s Good(a, s) ∧ (¬∃ b Great(b, s)) ⇒ Action(a, s)

  • Now, for each situation S,

Ask( KB, ∃a Action( a, S) )

. . . find a s.t. KB | = Action( a, S )

PC-Plan 14

slide-15
SLIDE 15

Propagating Information

Effect Actions: If agent Grabs, when in room

with gold, he will be holding gold.

∀ℓ, s Glitters(ℓ) ∧ At(Agent, ℓ, s) ⇒ AtGold(s) ∀ℓ, s AtGold(s) ⇒ Holding(Gold, Result(Grab, s) )

So, if Glitters( [ 3, 2 ] ), At(Agent, [ 3,2 ], S6 ),

then Holding( Gold, S7 ) where S7 = Result( Grab, S6 ) What about NEXT situation? eg, S8 = Result( Turn Right, S7 )? Want to derive Holding( Gold, Result(Turn Right, S7 ) ), This requires . . .

PC-Plan 15

slide-16
SLIDE 16

Frame Axioms

  • ∀a, x, s Holding(x, s) ∧ (a = Release)

⇒ Holding(x, Result(a, s) ) ∀a, s ¬Holding(Gold, s) ∧ (a = Grab ∨ ¬AtGold(s) ⇒ ¬Holding( Gold, Result(a, s) ) Gen’l:

true afterwards ⇔ [an action made it true ∨ (true already & no action made it false)]

Here: ∀a, s Holding(Gold, Result(a, s)) ⇔ [ ( a = Grab ∧ AtGold(s) ) ∨ ( Holding(Gold, s) ∧ a = Release ) ] Similarly: ∀ a, d, p, s At( p, ℓ, Result(a, s) ) ⇔ [ (a = Forward ∧ ℓ = LocAhead(p, s) ∧ ¬Wall(ℓ)) ∨ (At(p, ℓ, s) ∧ a = Forward) ]

  • “Successor State Axiom”

Lists all ways predicate can become true/false

PC-Plan 16

slide-17
SLIDE 17

Frame, and Related, Problems

  • Representational Frame Problem

Encoding what doesn’t change, as ac- tions take place

(Solved via “success-state axioms”)

  • Inferential Frame Problem

. . . deal with long sequences of actions . . .

  • Qualification Problem

dealing with all qualifications

. . . gold brick is not slippery, not screwed to table, . . .

  • Ramification

When picking up the gold brick, also pick up the associated dust . . .

PC-Plan 17

slide-18
SLIDE 18

Goal-Based Agent

  • These rules sufficient to FIND gold

Then what?

  • Need to change strategies:

– Was “Find gold” – Now: “Get out!”

∀s Holding(Gold, s) ⇒ GoalLocation( [ 1, 1 ], s )

Need to incorporate. . . How?

PC-Plan 18

slide-19
SLIDE 19

How to Plan?

Planning agents seek plan ≡ sequence of actions that achieve agent’s goals. Inference: Let logical reasoning system per- form search:

Ask(KB, ∃ a1, a2, a3, a4, a5, t t = Result(a5, Result(a4, Result(a3, Result(a2, Result(a1, S0))))) ∧ Holding(Agent, Gold, t) ∧ At(Agent, Outside, t)) Problematic, as not easy to heuristically guide reasoning system. . . . . . what if > 5 actions required? . . .

Search: View actions as operations on KB, Goal = “KB includes Holding(Agent, Gold, t) At(Agent, Outside, t))” Planning: Special purpose reasoning systems. . .

PC-Plan 19

slide-20
SLIDE 20

Logical Agents

  • React to what it perceives
  • Extract abstract descriptions of current

state from percepts

  • Maintain internal model of relevant as-

pects of world even those not directly observable

  • Express and use info about desirability of

actions in circumstances

  • Use goals in conjunction with knowledge

about actions to construct plans As all domain-specific knowledge is encoded as logical formulae, agent is completely generic!

PC-Plan 20

slide-21
SLIDE 21

Logic, Uncertainty, and Utility

Advantages of Logic-Based Agents

  • High-level language for tracking environ-

ments.

  • Permits modular decomposition of state

representation. Limitations of Simple Logic-Based Agents

  • Cannot track stochastic environments.
  • Cannot represent and reason with utilities—

can’t make tradeoffs.

PC-Plan 21

slide-22
SLIDE 22

Limitations of Situation Calculus

  • Situation Calculus works well for

Wumpus World

  • But. . .
  • “Discrete Actions”

Can’t handle continuous actions:

− Flow of Electrons − Control of factory − . . .

  • Action at an “instant”

What if actions have duration?

  • One action at a time

What if multiple agents? What if world changes spontaneously?

PC-Plan 22

slide-23
SLIDE 23

Time and First-Order Logic

  • Representing & reasoning with

dynamic / changing world is not “strong point” of first-order logic

  • Work on different logics:

eg dynamic logic / nonmonotonic logic

  • Nonmon: long “struggle”.

Yale shooting problem: Actions: load gun / point gun / wait 5 seconds / fire gun Question: Is target dead? (was gun loaded when fired) > 100 research papers since 1986; still not fully resolved

  • First-order Logic better at “static” infor-

mation.

PC-Plan 23