sit ti c l lsituation calculus · – usieli pl ding eclipse prolog and glgolog – groups of up to...

48
Institute for Software Technology Sit ti Cl l Situation Calculus Gerald Steinbauer Institute for Software Technology Gerald Steinbauer 1 Situation Calculus - Introduction

Upload: others

Post on 18-Feb-2020

3 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Sit ti C l lSituation Calculus · – usiEli Pl ding Eclipse Prolog and GlGolog – groups of up to five students Gerald Steinbauer 3 Situation Calculus - Introduction. Institute

Institute for Software Technology

Sit ti C l lSituation Calculus

Gerald SteinbauerInstitute for Software Technology

Gerald Steinbauer1

Situation Calculus - Introduction

Page 2: Sit ti C l lSituation Calculus · – usiEli Pl ding Eclipse Prolog and GlGolog – groups of up to five students Gerald Steinbauer 3 Situation Calculus - Introduction. Institute

Institute for Software Technology

Agenda

O i ti l I• Organizational Issues• Motivation• Introduction

– Recap of First Order Logic

• Situation Calculus• Situation Calculus– Introduction– Formal Definition– Usage

• Programming in Situation Calculus– Programming Language Golog– Domain Modeling

Gerald Steinbauer2

Situation Calculus - Introduction

Page 3: Sit ti C l lSituation Calculus · – usiEli Pl ding Eclipse Prolog and GlGolog – groups of up to five students Gerald Steinbauer 3 Situation Calculus - Introduction. Institute

Institute for Software Technology

Organizational Issues

D t• Dates– 04.11.2009 11:45-14:00 (HS i11) lecture– 11 11 2009 11:45-14:00 (HS i11) lecture11.11.2009 11:45 14:00 (HS i11) lecture– 11.11.2009 18:00-18:45 (HS i11) practice and assignment– 18.11.2009 18:00-18:45 (HS i11) question hour and interview

datesdates– 01.12.2009 23:59 submission– 03. & 04.12.2009 group interviews

• Homework– Modeling and Solving a Domain

i E li P l d G l– using Eclipse Prolog and Golog– groups of up to five students

Gerald Steinbauer3

Situation Calculus - Introduction

Page 4: Sit ti C l lSituation Calculus · – usiEli Pl ding Eclipse Prolog and GlGolog – groups of up to five students Gerald Steinbauer 3 Situation Calculus - Introduction. Institute

Institute for Software Technology

Literature“Knowledge in Action” “Artificial Intelligence: A gby Raymond ReiterMIT Press

Modern Approach” by Stuart Russel amd Peter

NorvigNorvigPrentice Hall

Gerald Steinbauer4

Situation Calculus - Introduction

Page 5: Sit ti C l lSituation Calculus · – usiEli Pl ding Eclipse Prolog and GlGolog – groups of up to five students Gerald Steinbauer 3 Situation Calculus - Introduction. Institute

Institute for Software Technology

Motivation

What is Situation Calculus good for?What is Situation Calculus good for?

Gerald Steinbauer5

Situation Calculus - Introduction

Page 6: Sit ti C l lSituation Calculus · – usiEli Pl ding Eclipse Prolog and GlGolog – groups of up to five students Gerald Steinbauer 3 Situation Calculus - Introduction. Institute

Institute for Software Technology

Gerald Steinbauer6

Situation Calculus - Introduction

Page 7: Sit ti C l lSituation Calculus · – usiEli Pl ding Eclipse Prolog and GlGolog – groups of up to five students Gerald Steinbauer 3 Situation Calculus - Introduction. Institute

Institute for Software Technology

Shakey, the Robot

•developed 1966-1972•at Stanford Research Institute (SRI)•move boxes in an office o e bo es a o ceenvironment•Nils NilssonNils Nilsson•STRIPS

300k d•~300k word program

Gerald Steinbauer7

Situation Calculus - Introduction

Page 8: Sit ti C l lSituation Calculus · – usiEli Pl ding Eclipse Prolog and GlGolog – groups of up to five students Gerald Steinbauer 3 Situation Calculus - Introduction. Institute

Institute for Software Technology

Situation Calculus @ RoboCup

RoboCup Middle-Size RoboCup@Home

Gerald Steinbauer8

Situation Calculus - Introduction

Page 9: Sit ti C l lSituation Calculus · – usiEli Pl ding Eclipse Prolog and GlGolog – groups of up to five students Gerald Steinbauer 3 Situation Calculus - Introduction. Institute

Institute for Software Technology

RoboCup@Home, AllemaniACs

Courtesy AllemaniACs RWTH Aachen

Gerald Steinbauer9

Situation Calculus - Introduction

Courtesy AllemaniACs, RWTH Aachen

Page 10: Sit ti C l lSituation Calculus · – usiEli Pl ding Eclipse Prolog and GlGolog – groups of up to five students Gerald Steinbauer 3 Situation Calculus - Introduction. Institute

Institute for Software Technology

Motivating Example• Wumpus Worldp

• Wumpus, Pits and Gold

• HunterMOVE FORWARD• MOVE FORWARD

• TURN LEFT 90°• TURN RIGHT 90°• SHOOT ONE ARROWSHOOT ONE ARROW• GRAB GOLD

• InformationSTENCH• STENCH

• BREEZE• GLITTER• BUMPBUMP• SCREAM

• MissionG t th G ld

Gerald Steinbauer10

Situation Calculus - Introduction

• Get the Gold

Page 11: Sit ti C l lSituation Calculus · – usiEli Pl ding Eclipse Prolog and GlGolog – groups of up to five students Gerald Steinbauer 3 Situation Calculus - Introduction. Institute

Institute for Software Technology

Motivating Example• Wumpus Worldp

• Wumpus, Pits and Gold

• HunterMOVE FORWARD• MOVE FORWARD

• TURN LEFT 90°• TURN RIGHT 90°• SHOOT ONE ARROWSHOOT ONE ARROW• GRAB GOLD

• InformationSTENCH• STENCH

• BREEZE• GLITTER• BUMPBUMP• SCREAM

• MissionG t th G ld

Gerald Steinbauer11

Situation Calculus - Introduction

• Get the Gold

Page 12: Sit ti C l lSituation Calculus · – usiEli Pl ding Eclipse Prolog and GlGolog – groups of up to five students Gerald Steinbauer 3 Situation Calculus - Introduction. Institute

Institute for Software Technology

Recap First Order Logic

Gerald Steinbauer12

Situation Calculus - Introduction

Page 13: Sit ti C l lSituation Calculus · – usiEli Pl ding Eclipse Prolog and GlGolog – groups of up to five students Gerald Steinbauer 3 Situation Calculus - Introduction. Institute

Institute for Software Technology

First Order Logic (FOL)

t i t th iti l l i• extension to the propositional logic• handles objects and properties• additional concepts allow more expressivity• in general undcideable (Church Theorem)

S ti fi bilit• Satisfiability• Validity

• parts are semi-decidableparts are semi decidable• a brave working horse for AI

Gerald Steinbauer13

Situation Calculus - Introduction

Page 14: Sit ti C l lSituation Calculus · – usiEli Pl ding Eclipse Prolog and GlGolog – groups of up to five students Gerald Steinbauer 3 Situation Calculus - Introduction. Institute

Institute for Software Technology

Syntax of FOL (1)

C t t S b l• Constant Symbols• a name, refers to an object c

• Function Symbols• Function Symbols• f has a arity n, it takes n objects and assign one object o=f(o1,…,on)

• Variable SymbolsVariable Symbols• represents an object which has to be determined at evaluation time

• Predicate Symbolsy• P has a arity n, it takes n objects and and returns a truth value• if n=1 P(o) represents the property P of an object o• if n>1 P(o o ) represents relations between the objects o o• if n>1 P(o1,…,on) represents relations between the objects o1,…,on

• if n=0 P is true independent to a universe of objects

Gerald Steinbauer14

Situation Calculus - Introduction

Page 15: Sit ti C l lSituation Calculus · – usiEli Pl ding Eclipse Prolog and GlGolog – groups of up to five students Gerald Steinbauer 3 Situation Calculus - Introduction. Institute

Institute for Software Technology

Syntax of FOL (2)

T• Terms• refers to an object• constant and variables are termsconstant and variables are terms• if t1,...,tn are terms then f(t1,…,tn) is also a tern

• Atomic Formulas (Atoms)• represents a truth value• if P is a predicate symbol an t1,…,tn are terms than is P(t1,…,tn) an

atomic formulaatomic formula

• Formulas• all a atomic formulas are formulas• if φ1 and φ2 are formulas then also: φ1 ˄ φ2 , φ1 ˅ φ2 , φ1 → φ2 ,

φ1↔ φ2 ,¬ φ1, x φ1,x φ1

Gerald Steinbauer15

Situation Calculus - Introduction

Page 16: Sit ti C l lSituation Calculus · – usiEli Pl ding Eclipse Prolog and GlGolog – groups of up to five students Gerald Steinbauer 3 Situation Calculus - Introduction. Institute

Institute for Software Technology

Syntax of FOL (3)

F V i bl• Free Variables• A variable x is free if it is not bounded by an universal or existential

quantifierq• x is free in φ if x occurs free at least once in φ, written as φ(x)

• Sentence• closed proposition• either true or false• comprises no free variablescomprises no free variables

• Equality Symbol• c1=c2 claims or test if two objects are the same entity

Gerald Steinbauer16

Situation Calculus - Introduction

Page 17: Sit ti C l lSituation Calculus · – usiEli Pl ding Eclipse Prolog and GlGolog – groups of up to five students Gerald Steinbauer 3 Situation Calculus - Introduction. Institute

Institute for Software Technology

Semantics of FOL (1)

h t i th i f t (t f l )• what is the meaning of sentences (true or false)

• universe of (infinite) objects, D (domain)• a vocabulary V• interpretation function I

• constant symbol cV, I(c) maps to one object in D• function symbol fV, I(f):Dn→D• predicate symbol PV, relation I(P) Dn

• I(f(t1,…,tn))=I(f)(I(t1),…,I(tn))

Gerald Steinbauer17

Situation Calculus - Introduction

Page 18: Sit ti C l lSituation Calculus · – usiEli Pl ding Eclipse Prolog and GlGolog – groups of up to five students Gerald Steinbauer 3 Situation Calculus - Introduction. Institute

Institute for Software Technology

Semantics of FOL (2)

t P(t1 t ) I( ) t if (I(t ) I(t )) I(P)• atom φ=P(t1,…,tn), I(φ)=t if (I(t1),…,I(tn)) I(P)• conjunction of formulas φ1 and φ2, I(φ) is the

propositional conjunction of I(φ ) and I(φ )propositional conjunction of I(φ1) and I(φ2)• universal quantifier φ=xφ1(x) I(φ)=t if I(φ1[x/o]))=t for

all oDall oD• existential quantifier φ=xφ1(x) I(φ)=t if I(φ1[x/o]))=t

for at least one oDfor at least one oD

• I is a model for φ if I(φ)=t (one possible world)• I is a model for φ if I(φ)=t (one possible world)• Satisfiability → at least one model• Validity → all interpretations are models

Gerald Steinbauer18

Situation Calculus - Introduction

• Validity → all interpretations are models

Page 19: Sit ti C l lSituation Calculus · – usiEli Pl ding Eclipse Prolog and GlGolog – groups of up to five students Gerald Steinbauer 3 Situation Calculus - Introduction. Institute

Institute for Software Technology

The Situation Calculus

i th d l t b t ti d h• is a methodology to reason about actions and change• it allows deductive reasoning on

h t b h• how to behave• what are the consequences

• proposed by John McCarthy (1963)proposed by John McCarthy (1963)• further developed by Raymond Reiter and others• originally used for database transactions (1995)originally used for database transactions (1995)• uses second-order logic (Reiter 2001)• modeling of dynamic systems (e g robots plants)• modeling of dynamic systems (e.g., robots, plants)• basis for several (action) programming languages

(e.g. Golog)

Gerald Steinbauer19

Situation Calculus - Introduction

(e.g. Golog)

Page 20: Sit ti C l lSituation Calculus · – usiEli Pl ding Eclipse Prolog and GlGolog – groups of up to five students Gerald Steinbauer 3 Situation Calculus - Introduction. Institute

Institute for Software Technology

Properties of the Situation Calculus

Ad t• Advantages• allows for reasoning about actions and change• uses the foundations of logicuses the foundations of logic• allows for testing and proving of properties• is solution to some fundamental problems of AI (e.g. frame

problem)problem)

• Drawbacks• based on second-order logicbased on second order logic• domain modeling is complex and error prune• computational expensive

Gerald Steinbauer20

Situation Calculus - Introduction

Page 21: Sit ti C l lSituation Calculus · – usiEli Pl ding Eclipse Prolog and GlGolog – groups of up to five students Gerald Steinbauer 3 Situation Calculus - Introduction. Institute

Institute for Software Technology

Building Blocks

Domain DependentDomain DependentObjects Fluents

Situations Actions

The green building blocks are different sorts in the second order logic.The blue building block is used to retrieve properties about the world

Gerald Steinbauer21

Situation Calculus - Introduction

The blue building block is used to retrieve properties about the world.

Page 22: Sit ti C l lSituation Calculus · – usiEli Pl ding Eclipse Prolog and GlGolog – groups of up to five students Gerald Steinbauer 3 Situation Calculus - Introduction. Institute

Institute for Software Technology

States (1)

El t i l E i i• Electrical Engineering• uses the concept of a state x• snapshot of the system at a time tsnapshot of the system at a time t

• Linear Time Invariant System (LTI)• Resistor/Capacitor-Network

i

R1 R2

duxcybuAxdtdx T ,

u uC2 uC1

iC1

C2 C1 TCC xxxuxux 212211 ,,

111 , yyiy C 111 yyy C

xyuxdtdx

RRRRRCRC

2122

1111 11111

11

,0

)1(

Gerald Steinbauer22

Situation Calculus - Introduction

dt RCRRCRCR

21111

2

22221

2 111 )1(

Page 23: Sit ti C l lSituation Calculus · – usiEli Pl ding Eclipse Prolog and GlGolog – groups of up to five students Gerald Steinbauer 3 Situation Calculus - Introduction. Institute

Institute for Software Technology

States (2)

• Computer Science• several applications of states• Deterministic Finite Automaton

• protocols• parser• model checking

q0

FqQA ,,,, 0q0 q2q1 q3

signuppass

interviewsubmit

no submit

not passinterview

Gerald Steinbauer23

Situation Calculus - Introduction

Page 24: Sit ti C l lSituation Calculus · – usiEli Pl ding Eclipse Prolog and GlGolog – groups of up to five students Gerald Steinbauer 3 Situation Calculus - Introduction. Institute

Institute for Software Technology

Situations

i d ti l d fi d• inductively defined• a constant symbol S0 denotes the initial situation

(nothing happened so far)(nothing happened so far) • a binary function symbol

do:actionssitationssituationsdo:actionssitationssituations• situations can be interpreted as sequences of actions• do(a,s) performs action a in situation s• do(a,s) adds action a to sequence s

binary predicate sysmbol :situation situation• binary predicate sysmbol :situationsituationss’ denotes thate s is a proper supsequence of s’

Gerald Steinbauer24

Situation Calculus - Introduction

Page 25: Sit ti C l lSituation Calculus · – usiEli Pl ding Eclipse Prolog and GlGolog – groups of up to five students Gerald Steinbauer 3 Situation Calculus - Introduction. Institute

Institute for Software Technology

Sates versus Situations

• situations are different to states • they contain a history of what happened so far

• snapshots of properties of the world are retrieved by fluents, i.e. what predicates hold in a situation

• two situations are different if their sequence is differentdifferent

• the “state” of fluents may be the same

Gerald Steinbauer25

Situation Calculus - Introduction

Page 26: Sit ti C l lSituation Calculus · – usiEli Pl ding Eclipse Prolog and GlGolog – groups of up to five students Gerald Steinbauer 3 Situation Calculus - Introduction. Institute

Institute for Software Technology

Situation Treeand ( S )

a2

a3

ando(an,S0)

S

a1an

S0

a

a3

a1

a2

a

do(an,do(a1,S0))

a1

a2

a3

an

do(a1,S0)

Gerald Steinbauer26

Situation Calculus - Introduction

a1

Page 27: Sit ti C l lSituation Calculus · – usiEli Pl ding Eclipse Prolog and GlGolog – groups of up to five students Gerald Steinbauer 3 Situation Calculus - Introduction. Institute

Institute for Software Technology

Actions

ti th l tit hi h h thi• actions are the only entity which change something (i.e., situations and fluents)actions have a unique name if the names are• actions have a unique name, if the names are different the actions perform different things

• actions can have parameters of arity n e g• actions can have parameters of arity n, e.g. moveto(object, room) or sleep

• an action a is executed in a situation s by the functionan action a is executed in a situation s by the function s’=do(a,s) leading to a new situation s’

• actions have a precondition – in what situation an actions have a precondition in what situation an action is possible to execute

Gerald Steinbauer27

Situation Calculus - Introduction

Page 28: Sit ti C l lSituation Calculus · – usiEli Pl ding Eclipse Prolog and GlGolog – groups of up to five students Gerald Steinbauer 3 Situation Calculus - Introduction. Institute

Institute for Software Technology

Qualification Problem

i t bl f AI d hil h• a prominent problem of AI and philosophy• formulated by John McCarthy• it might be impossible to represent all preconditions

of an actionditi i ht b k th b• some preconditions might be unknown or the number

is infinite• famous example: use a rowboat• famous example: use a rowboat • related to nonmonotonic reasoning and defaults –

flying exampleflying example• ignorance is a solution – specify only the important

ones

Gerald Steinbauer28

Situation Calculus - Introduction

ones

Page 29: Sit ti C l lSituation Calculus · – usiEli Pl ding Eclipse Prolog and GlGolog – groups of up to five students Gerald Steinbauer 3 Situation Calculus - Introduction. Institute

Institute for Software Technology

Action Precondition Axioms

t k if ti i t bl• take care if an action a is executable• we introduce a binary predicate symbol

Poss action sit ationPoss:actionsituation• is a sentence in the form

Poss(A(x x ) s) (x x s)Poss(A(x1,…,xn),s)A(x1,…,xn,s)• A is a formula with free variables x1,…,xn and s• e g Poss(enter room(x) s)door open(x s)• e.g. Poss(enter_room(x),s)door_open(x,s)• axioms have to be defined for all actions A

Gerald Steinbauer29

Situation Calculus - Introduction

Page 30: Sit ti C l lSituation Calculus · – usiEli Pl ding Eclipse Prolog and GlGolog – groups of up to five students Gerald Steinbauer 3 Situation Calculus - Introduction. Institute

Institute for Software Technology

Fluents

d t t h th d i ld• used to catch the dynamic world• fluents are related to states• relations and functions change from situation to

situationth h t d b fl t• these changes are represented by fluents

• two different fluents• relational fluents• relational fluents• functional fluents

Gerald Steinbauer30

Situation Calculus - Introduction

Page 31: Sit ti C l lSituation Calculus · – usiEli Pl ding Eclipse Prolog and GlGolog – groups of up to five students Gerald Steinbauer 3 Situation Calculus - Introduction. Institute

Institute for Software Technology

Relational Fluents

t l ti ( ti ) f bj t i• represents a relation (or properties) of objects in a situation sit is represented by a predicate symbol with arity n+1• it is represented by a predicate symbol with arity n+1in the form F(x1,…,xn,s)

• F:(objects actions)nsituation→{T F}• F:(objects actions)nsituation→{T,F}• it represents the truth value of a relation (property) in

a certain situationa certain situation• examples: at(x,y,s) or broken(x,s)

Gerald Steinbauer31

Situation Calculus - Introduction

Page 32: Sit ti C l lSituation Calculus · – usiEli Pl ding Eclipse Prolog and GlGolog – groups of up to five students Gerald Steinbauer 3 Situation Calculus - Introduction. Institute

Institute for Software Technology

Functional Fluents

t f ti f bj t i it ti• represents a function of objects in a situation s• it is represented by a function symbol with arity n+1 in

the form f(x x s)the form f(x1,…,xn,s)• it represents the result (object) of a function

f ( bj t ti )n it ti ( bj t ti )• f:(objects actions)nsituation→(objects actions)• example: position(x,s)

Gerald Steinbauer32

Situation Calculus - Introduction

Page 33: Sit ti C l lSituation Calculus · – usiEli Pl ding Eclipse Prolog and GlGolog – groups of up to five students Gerald Steinbauer 3 Situation Calculus - Introduction. Institute

Institute for Software Technology

Frame Problem

th i t t (f d t l) bl f AI• another important (fundamental) problem of AI • formulated by John McCarhty and Patrick Hayes• related to the abstract modeling of dynamic world• how to efficiently specify what is changed by an

ti d h t i thaction and what remains the same• sloppy: logic has no memory

iti d ti f i• positive and negative frame axioms• example: the color of an object does not change if it

is lifted color(x c s) color(x c do(lift(x) s))is lifted, color(x,c,s)→color(x,c,do(lift(x),s))

Gerald Steinbauer33

Situation Calculus - Introduction

Page 34: Sit ti C l lSituation Calculus · – usiEli Pl ding Eclipse Prolog and GlGolog – groups of up to five students Gerald Steinbauer 3 Situation Calculus - Introduction. Institute

Institute for Software Technology

Successor State Axioms (1)

l ti t th F P bl• are a solution to the Frame Problem• naively we have to specify all effect axioms (because

of the frame problem)of the frame problem)a. φ+(x1,…,xn,s)→F(x1,…,xn,do(a,s))b. φ-(x1,…,xn,s)→¬F(x1,…,xn,do(a,s))φ ( 1, , n, ) ( 1, , n, ( , ))c. φf(x1,…,xn,y,s)→f(x1,…,xn,do(a,s))=y

• example: fragile(x,s)→broken(x,do(drop(x),s))• use Causal Completeness Assumption

• a, b and c specify all casual laws relatet to a and F

Gerald Steinbauer34

Situation Calculus - Introduction

Page 35: Sit ti C l lSituation Calculus · – usiEli Pl ding Eclipse Prolog and GlGolog – groups of up to five students Gerald Steinbauer 3 Situation Calculus - Introduction. Institute

Institute for Software Technology

Successor State Axioms (2)

F( ) F( d ( )) ( )• F(x1,…,xn,s)˄¬F(x1,…,xn,do(a,s))→φ-(x1,…,xn,s)• F(x1,…,xn,s)˄¬φ-(x1,…,xn,s)→F(x1,…,xn,do(a,s)) [PFA]

• ¬F(x1,…,xn,s)˄F(x1,…,xn,do(a,s))→φ+(x1,…,xn,s)• ¬F(x1,…,xn,s)˄¬φ+(x1,…,xn,s)→¬F(x1,…,xn,do(a,s)) [NFA]

• lead to 2 x #actions x #fluents frame axioms

• fragile(x,s)→broken(x,do(drop(x),s)) [EA]• ¬broken(x,s)˄¬fragile(x,s)→¬broken(x,do(drop(x),s)) [NFA]

Gerald Steinbauer35

Situation Calculus - Introduction

Page 36: Sit ti C l lSituation Calculus · – usiEli Pl ding Eclipse Prolog and GlGolog – groups of up to five students Gerald Steinbauer 3 Situation Calculus - Introduction. Institute

Institute for Software Technology

Successor State Axioms (3)

l l ti• a more general solution• F(x1,…,xn,s)˄¬F(x1,…,xn,do(a,s))→αF(x1,…,xn,a,s)• ¬F(x1,…,xn,s)˄F(x1,…,xn,do(a,s))→βF(x1,…,xn,a,s)• use Explanation Closure Assumption

l t l ifi h F h f t t f l β ti• αF completely specifies when F changes from true to false, βF respective

• F(x1,…,xn,s)˄¬αF(x1,…,xn,a,s)→F(x1,…,xn,do(a,s))F( )˄ β ( ) F( d ( ))• ¬F(x1,…,xn,s)˄¬βF(x1,…,xn,a,s)→¬F(x1,…,xn,do(a,s))

• the axioms are universal quantified over ad l 2 #fl t i• we need only 2 x #fluents axioms anymore

• explanations have to be short

Gerald Steinbauer36

Situation Calculus - Introduction

Page 37: Sit ti C l lSituation Calculus · – usiEli Pl ding Eclipse Prolog and GlGolog – groups of up to five students Gerald Steinbauer 3 Situation Calculus - Introduction. Institute

Institute for Software Technology

Successor State Axioms (4)

th l l ti• the general solution• positive and negative normal form effect axioms

+( ) F(t t d ( ))• +(x,a,s)→ F(t1,…,tn,do(α,s))• (y1,…,ym)[a=α˄x=t ˄+(x,a,s)] → F(x1,…,xn,do(a,s))• +→ F(x1,…,xn,do(a,s))• (+(1)˅…˅+(k)) → F(x1,…,xn,do(a,s)) • +(x1,…,xn,a,s)→ F(x1,…,xn,do(a,s)) [PNF]• -(x x a ss)→ ¬F(x x do(a s)) [NNF]• (x1,…,xn,a,ss)→ ¬F(x1,…,xn,do(a,s)) [NNF]

• unique name axiom for actions• A(x)B(y) and A(x1,…,xn)=A(y1,…,yn) → x1=y1˄…˄ xn=yn( ) (y) ( 1, , n) (y1, ,yn) 1 y1 n yn

• if T entails ¬(x,a,s). +(x,a,s)˄ -(x,a,s)F(x,do(a,s)) +(x,a,s)˅F(x,s)˄¬ -(x,a,s) [SSA-RF]

Gerald Steinbauer37

Situation Calculus - Introduction

Page 38: Sit ti C l lSituation Calculus · – usiEli Pl ding Eclipse Prolog and GlGolog – groups of up to five students Gerald Steinbauer 3 Situation Calculus - Introduction. Institute

Institute for Software Technology

Successor State Axioms (5)

i il h f f ti l fl t• similar approach for functional fluents• successor state axiom for functional fluents• if T entails ¬(x,y,y’,a,s).φf(x,y,a,s)˄φf(x,y‘,a,s)˄yy’

f(x,do(a,s)=yφf(x,y,do(a,s))˅f(x,s)=y˄¬y‘.φf(x,y,a,s)

• now we need only #actions + #fluents axioms

Gerald Steinbauer38

Situation Calculus - Introduction

Page 39: Sit ti C l lSituation Calculus · – usiEli Pl ding Eclipse Prolog and GlGolog – groups of up to five students Gerald Steinbauer 3 Situation Calculus - Introduction. Institute

Institute for Software Technology

Summary Successor State Axioms

id l ti t th F P bl• provides a solution to the Frame Problem• yields simple compact axioms• only for deterministic primitive actions• does not solve the qualification and ramification

blproblem• length of successor state axioms ~ #actions change a

fluentfluent• assumption: only a few actions change a fluent

Gerald Steinbauer39

Situation Calculus - Introduction

Page 40: Sit ti C l lSituation Calculus · – usiEli Pl ding Eclipse Prolog and GlGolog – groups of up to five students Gerald Steinbauer 3 Situation Calculus - Introduction. Institute

Institute for Software Technology

Deterministic Primitive Actions

d t h f th f ll i t t• do not have on of the following structures:

• Conditional Action: if car_in_driveway then drive else walk

• Iterative Actions:• Iterative Actions:while [(block)ontable(block)] do remove(block)

• Nondeterministic Actions:Nondeterministic Actions:removeabock=( block)[pickup(block);putonfloor(block)]

• Recursive Actions:proc d(n)

if n=0 then no_opelse down;d(n-1)

Gerald Steinbauer40

Situation Calculus - Introduction

( )end

Page 41: Sit ti C l lSituation Calculus · – usiEli Pl ding Eclipse Prolog and GlGolog – groups of up to five students Gerald Steinbauer 3 Situation Calculus - Introduction. Institute

Institute for Software Technology

Ramification Problem

t th i t t bl f AI• yet another important problem of AI • concerns of indirect consequences of an action• how to represent what happens implicitly due to an

actionf l h i Li l l b i d ?• famous example: where is Lincoln leg buried ?

• simple example: painted(x s)˄partof(y x)→painted(y s)painted(x,s)˄partof(y,x)→painted(y,s)

• solution: implicit effects have to be modeled

Gerald Steinbauer41

Situation Calculus - Introduction

Page 42: Sit ti C l lSituation Calculus · – usiEli Pl ding Eclipse Prolog and GlGolog – groups of up to five students Gerald Steinbauer 3 Situation Calculus - Introduction. Institute

Institute for Software Technology

Initial Situation

S i i l t t f t it ti• So is a special constant of sort situation• it represents the initial situation• DS0 is the initial database• it comprises sentences describing the initial theory of

th ldthe world• S0 is the only situation mentioned

D t t ti P d• DS0 must not mention Poss, do or • it may comprise non-situation terms • examples: location(robot,office1,S0),

mountain(MtEverest)

Gerald Steinbauer42

Situation Calculus - Introduction

Page 43: Sit ti C l lSituation Calculus · – usiEli Pl ding Eclipse Prolog and GlGolog – groups of up to five students Gerald Steinbauer 3 Situation Calculus - Introduction. Institute

Institute for Software Technology

Foundational Axioms for Situations

ti f it ti• ensure some properties of situations• situations are understood as sequence of actions• abbreviation: do(an(…do(a1,S0)) = do([a1,an],S0)• s’ s denotes that s’ is a subsequence of s

1. do(a1,s1)=do(a2,s2)→a1=a2 ˄s1=s2 [UNA]2. P.P(S0)˄a,s.(P(s)→P(do(a,s)))→s.P(s) [SCA]3. ¬sS0 [ordering of situations]4. s do(a,s’)ss’ with ss’ ~ ss’˅s=s’

Gerald Steinbauer43

Situation Calculus - Introduction

Page 44: Sit ti C l lSituation Calculus · – usiEli Pl ding Eclipse Prolog and GlGolog – groups of up to five students Gerald Steinbauer 3 Situation Calculus - Introduction. Institute

Institute for Software Technology

Basic Action Theory (BAT)

0Sunaapssa DDDDD

• Σ … set of foundational axioms for situations• Dssa … set of successor state axiomsssa

• Dap … set of action precondition axioms• Duna … set of unique name axioms for actionsDuna … set of unique name axioms for actions• DS0 … set of first order sentences uniform in S0

Gerald Steinbauer44

Situation Calculus - Introduction

Page 45: Sit ti C l lSituation Calculus · – usiEli Pl ding Eclipse Prolog and GlGolog – groups of up to five students Gerald Steinbauer 3 Situation Calculus - Introduction. Institute

Institute for Software Technology

Putting all Together (An Example)

h d d li b t• one-hand delivery robot• hold one object• pickup one objectpickup one object• drop one object• walk A B

RL

C

Gerald Steinbauer45

Situation Calculus - Introduction

Page 46: Sit ti C l lSituation Calculus · – usiEli Pl ding Eclipse Prolog and GlGolog – groups of up to five students Gerald Steinbauer 3 Situation Calculus - Introduction. Institute

Institute for Software Technology

Putting all Together (1)

A ti P diti• Action Preconditions• Poss(pickup(r,x),s)robot(r)˄[z¬holding(r,z,s)]˄nextTo(r,x,s)• Poss(walk(r y) s)robot(r)Poss(walk(r,y),s)robot(r)• Poss(drop(r,x),s)robot(r)˄holding(r,x,s)

• Initial Situation• robot(R)• letter(L)• letter(L)• nextTo(R,A,S0)• nextTo(L,B,S0)• (z)¬holding(R,z,S0)

Gerald Steinbauer46

Situation Calculus - Introduction

Page 47: Sit ti C l lSituation Calculus · – usiEli Pl ding Eclipse Prolog and GlGolog – groups of up to five students Gerald Steinbauer 3 Situation Calculus - Introduction. Institute

Institute for Software Technology

Putting all Together (2)

Eff t A i• Effect Axioms• holding(r,x,do(pickup(r,x),s))• ¬holding(r x do(drop(r x) s))holding(r,x,do(drop(r,x),s))

• nextTo(r,y,do(walk(r,y),s))tT ( ) tT ( d (d ( ) ))• nextTo(r,y,s)→nextTo(x,y,do(drop(r,y),s))

• xy →¬nextTo(r,x,do(walk(r,y),s))

• onfloor(x,do(drop(r,x),s))• ¬onfloor(x,do(pickup(r,x),s))

Gerald Steinbauer47

Situation Calculus - Introduction

Page 48: Sit ti C l lSituation Calculus · – usiEli Pl ding Eclipse Prolog and GlGolog – groups of up to five students Gerald Steinbauer 3 Situation Calculus - Introduction. Institute

Institute for Software Technology

Putting all Together (3)

S St t A i• Successor State Axioms• holding(r,x,do(a,s))a=pickup(r,x)˅holding(r,x,s) ˄adrop(r,x)• nextTo(x y do(a s))a=walk(x y)˅(r)[nextTo(r y s) ˄a=drop(r x)] ˅nextTo(x,y,do(a,s))a walk(x,y)˅(r)[nextTo(r,y,s) ˄a drop(r,x)] ˅

nextTo(x,y,s)˄¬(z)[a=walk(r,z)˄zy] • onfloor(x,do(a,s)) (r)a=drop(r,x) ˅onfloor(x,s)˄ ¬(r)a=pickup(r,x)

• Unique Name Assumption for Actions• pickup(r,x) drop(r’,x)pickup(r,x) drop(r ,x)• pickup(r,x) walk(r’,x)• walk(r,y)=walk(r’,y’)→r=r’ ˄y=y’• …

Gerald Steinbauer48

Situation Calculus - Introduction