ktdcw 13 intro - Graz University of Technology• if n=1 P(o) represents the property P of an object...

55
Gerald Steinbauer Institute for Software Technology 1 Situation Calculus - Introduction Situation Calculus Gerald Steinbauer Institute for Software Technology

Transcript of ktdcw 13 intro - Graz University of Technology• if n=1 P(o) represents the property P of an object...

Page 1: ktdcw 13 intro - Graz University of Technology• if n=1 P(o) represents the property P of an object o • if n>1 P(o 1,…,o n) represents relations between the objects o 1,…,o

Gerald Steinbauer

Institute for Software Technology

1

Situation Calculus - Introduction

Situation Calculus

Gerald SteinbauerInstitute for Software Technology

Page 2: ktdcw 13 intro - Graz University of Technology• if n=1 P(o) represents the property P of an object o • if n>1 P(o 1,…,o n) represents relations between the objects o 1,…,o

Gerald Steinbauer

Institute for Software Technology

2

Situation Calculus - Introduction

Organizational Issues

• Dates– 20.11.2013 11:45-14:00 (HS i11) lecture and

assignment– 27.11.2013 11:45-14:00 (HS i11) lecture– 27.11.2013 18:00-18:45 (HS i11) practice– 04.12.2013 18:00-18:45 (HS i11) practice and solution– 04.12.2013 12:00 submission

Page 3: ktdcw 13 intro - Graz University of Technology• if n=1 P(o) represents the property P of an object o • if n>1 P(o 1,…,o n) represents relations between the objects o 1,…,o

Gerald Steinbauer

Institute for Software Technology

3

Situation Calculus - Introduction

Agenda

• Organizational Issues• Motivation• Introduction

– Recap of First Order Logic (if necessary)

• Situation Calculus (today)– Introduction– Formal Definition– Usage

• Programming in Situation Calculus (next week)– Programming Language Golog– Domain Modeling

Page 4: ktdcw 13 intro - Graz University of Technology• if n=1 P(o) represents the property P of an object o • if n>1 P(o 1,…,o n) represents relations between the objects o 1,…,o

Gerald Steinbauer

Institute for Software Technology

4

Situation Calculus - Introduction

Literature“Knowledge in Action” by Raymond ReiterMIT Press

“Artificial Intelligence: A Modern Approach”

by Stuart Russel amd Peter Norvig

Prentice Hall

Page 5: ktdcw 13 intro - Graz University of Technology• if n=1 P(o) represents the property P of an object o • if n>1 P(o 1,…,o n) represents relations between the objects o 1,…,o

Gerald Steinbauer

Institute for Software Technology

5

Situation Calculus - Introduction

Motivation

What is Situation Calculus good for?

Page 6: ktdcw 13 intro - Graz University of Technology• if n=1 P(o) represents the property P of an object o • if n>1 P(o 1,…,o n) represents relations between the objects o 1,…,o

Gerald Steinbauer

Institute for Software Technology

6

Situation Calculus - Introduction

There is nothing permanent except change. Heraclitus of Ephesus, 535–c. 475 BC

Page 7: ktdcw 13 intro - Graz University of Technology• if n=1 P(o) represents the property P of an object o • if n>1 P(o 1,…,o n) represents relations between the objects o 1,…,o

Gerald Steinbauer

Institute for Software Technology

7

Situation Calculus - Introduction

Shakey, the Robot

• developed 1966-1972• at Stanford Research Institute (SRI)• move boxes in an office environment• Nils Nilsson• STRIPS• ~300k word program

http://www.youtube.com/watch?v=qXdn6ynwpiI

Page 8: ktdcw 13 intro - Graz University of Technology• if n=1 P(o) represents the property P of an object o • if n>1 P(o 1,…,o n) represents relations between the objects o 1,…,o

Gerald Steinbauer

Institute for Software Technology

8

Situation Calculus - Introduction

Dealing with Multiple Worlds

Page 9: ktdcw 13 intro - Graz University of Technology• if n=1 P(o) represents the property P of an object o • if n>1 P(o 1,…,o n) represents relations between the objects o 1,…,o

Gerald Steinbauer

Institute for Software Technology

9

Situation Calculus - Introduction

Belief Management

Page 10: ktdcw 13 intro - Graz University of Technology• if n=1 P(o) represents the property P of an object o • if n>1 P(o 1,…,o n) represents relations between the objects o 1,…,o

Gerald Steinbauer

Institute for Software Technology

10

Situation Calculus - Introduction

Belief Management

Page 11: ktdcw 13 intro - Graz University of Technology• if n=1 P(o) represents the property P of an object o • if n>1 P(o 1,…,o n) represents relations between the objects o 1,…,o

Gerald Steinbauer

Institute for Software Technology

11

Situation Calculus - Introduction

Recap First Order Logic

Page 12: ktdcw 13 intro - Graz University of Technology• if n=1 P(o) represents the property P of an object o • if n>1 P(o 1,…,o n) represents relations between the objects o 1,…,o

Gerald Steinbauer

Institute for Software Technology

12

Situation Calculus - Introduction

First Order Logic (FOL)

• extension to the propositional logic• handles objects and properties• additional concepts allow more expressivity• in general undecideable (Church Theorem)

• Satisfiability• Validity

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

Page 13: ktdcw 13 intro - Graz University of Technology• if n=1 P(o) represents the property P of an object o • if n>1 P(o 1,…,o n) represents relations between the objects o 1,…,o

Gerald Steinbauer

Institute for Software Technology

13

Situation Calculus - Introduction

Syntax of FOL (1)

• Constant Symbols• a name, refers to an object c

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

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

• Predicate Symbols• P has a arity n, it takes n objects and returns a truth value• if n=1 P(o) represents the property P of an object 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

Page 14: ktdcw 13 intro - Graz University of Technology• if n=1 P(o) represents the property P of an object o • if n>1 P(o 1,…,o n) represents relations between the objects o 1,…,o

Gerald Steinbauer

Institute for Software Technology

14

Situation Calculus - Introduction

Syntax of FOL (2)

• Terms• refers to an object• constant 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 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

Page 15: ktdcw 13 intro - Graz University of Technology• if n=1 P(o) represents the property P of an object o • if n>1 P(o 1,…,o n) represents relations between the objects o 1,…,o

Gerald Steinbauer

Institute for Software Technology

15

Situation Calculus - Introduction

Syntax of FOL (3)

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

quantifier• 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 variables

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

Page 16: ktdcw 13 intro - Graz University of Technology• if n=1 P(o) represents the property P of an object o • if n>1 P(o 1,…,o n) represents relations between the objects o 1,…,o

Gerald Steinbauer

Institute for Software Technology

16

Situation Calculus - Introduction

Semantics of FOL (1)

• 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))

Page 17: ktdcw 13 intro - Graz University of Technology• if n=1 P(o) represents the property P of an object o • if n>1 P(o 1,…,o n) represents relations between the objects o 1,…,o

Gerald Steinbauer

Institute for Software Technology

17

Situation Calculus - Introduction

Semantics of FOL (2)

• 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(φ1) and I(φ2)• universal quantifier φ=xφ1(x) I(φ)=t if I(φ1[x/o]))=t for

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

for at least one oD

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

Page 18: ktdcw 13 intro - Graz University of Technology• if n=1 P(o) represents the property P of an object o • if n>1 P(o 1,…,o n) represents relations between the objects o 1,…,o

Gerald Steinbauer

Institute for Software Technology

18

Situation Calculus - Introduction

The Situation Calculus

• is a methodology to reason about actions and change• it allows deductive reasoning on

• how to behave• what are the consequences

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

(e.g. Golog)

Page 19: ktdcw 13 intro - Graz University of Technology• if n=1 P(o) represents the property P of an object o • if n>1 P(o 1,…,o n) represents relations between the objects o 1,…,o

Gerald Steinbauer

Institute for Software Technology

19

Situation Calculus - Introduction

Properties of the Situation Calculus

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

problem)

• Drawbacks• based on second-order logic• domain modeling is complex and error prune • real implementation somehow fuzzy• computational expensive (if you do it wrong)

Page 20: ktdcw 13 intro - Graz University of Technology• if n=1 P(o) represents the property P of an object o • if n>1 P(o 1,…,o n) represents relations between the objects o 1,…,o

Gerald Steinbauer

Institute for Software Technology

20

Situation Calculus - Introduction

Building Blocks

Situations Actions

Domain DependentObjects

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

Fluents

Page 21: ktdcw 13 intro - Graz University of Technology• if n=1 P(o) represents the property P of an object o • if n>1 P(o 1,…,o n) represents relations between the objects o 1,…,o

Gerald Steinbauer

Institute for Software Technology

21

Situation Calculus - Introduction

States (1)

• Electrical Engineering• uses the concept of a state x• snapshot of the system at a time t

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

u uC2 uC1

iC1

R1

C2

R2

C1 TCC xxxuxux 212211 ,,

111 , yyiy C

duxcybuAxdtdx T ,

xyuxdtdx

RRRCR

RRCRCR

RRCRC

21111

2

22221

2

1111 11111

11

,0

)1(

Page 22: ktdcw 13 intro - Graz University of Technology• if n=1 P(o) represents the property P of an object o • if n>1 P(o 1,…,o n) represents relations between the objects o 1,…,o

Gerald Steinbauer

Institute for Software Technology

22

Situation Calculus - Introduction

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

• protocols• parser• model checking

q0

States (2)

FqQA ,,,, 0q0 q2q1 q3

signup

no submission

not pass

pass submission

Page 23: ktdcw 13 intro - Graz University of Technology• if n=1 P(o) represents the property P of an object o • if n>1 P(o 1,…,o n) represents relations between the objects o 1,…,o

Gerald Steinbauer

Institute for Software Technology

23

Situation Calculus - Introduction

Situations

• inductively defined as term• a constant symbol S0 denotes the initial situation

(nothing happened so far) • a binary function symbol

do: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 represented by s

• binary predicate symbol :situationsituationss’ denotes that s is a proper subsequence of s’

Page 24: ktdcw 13 intro - Graz University of Technology• if n=1 P(o) represents the property P of an object o • if n>1 P(o 1,…,o n) represents relations between the objects o 1,…,o

Gerald Steinbauer

Institute for Software Technology

24

Situation Calculus - Introduction

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 different

• the “state” of fluents may be the same

Page 25: ktdcw 13 intro - Graz University of Technology• if n=1 P(o) represents the property P of an object o • if n>1 P(o 1,…,o n) represents relations between the objects o 1,…,o

Gerald Steinbauer

Institute for Software Technology

25

Situation Calculus - Introduction

Situation Tree

S0

a1

a1

a1

a2

a2

a2

a3

a3

a3

an

an

an

do(a1,S0)

do(an,S0)

do(an,do(a1,S0))

Page 26: ktdcw 13 intro - Graz University of Technology• if n=1 P(o) represents the property P of an object o • if n>1 P(o 1,…,o n) represents relations between the objects o 1,…,o

Gerald Steinbauer

Institute for Software Technology

26

Situation Calculus - Introduction

Example – Dress Up

Page 27: ktdcw 13 intro - Graz University of Technology• if n=1 P(o) represents the property P of an object o • if n>1 P(o 1,…,o n) represents relations between the objects o 1,…,o

Gerald Steinbauer

Institute for Software Technology

27

Situation Calculus - Introduction

Actions

• actions are the only entities which change something (i.e., situations and values of fluents)

• actions have a unique name, if the names are different the actions perform different things

• 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 function s’=do(a,s) leading to a new situation s’

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

Page 28: ktdcw 13 intro - Graz University of Technology• if n=1 P(o) represents the property P of an object o • if n>1 P(o 1,…,o n) represents relations between the objects o 1,…,o

Gerald Steinbauer

Institute for Software Technology

28

Situation Calculus - Introduction

Qualification Problem

• a prominent problem of AI and philosophy• formulated by John McCarthy• it might be impossible to represent all preconditions

of an action• some preconditions might be unknown or the number

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

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

ones

Page 29: ktdcw 13 intro - Graz University of Technology• if n=1 P(o) represents the property P of an object o • if n>1 P(o 1,…,o n) represents relations between the objects o 1,…,o

Gerald Steinbauer

Institute for Software Technology

29

Situation Calculus - Introduction

Action Precondition Axioms

• take care if an action a is executable• we introduce a binary predicate symbol

Poss:actionsituation• is a sentence in the form

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)• axioms have to be defined for all actions A

Page 30: ktdcw 13 intro - Graz University of Technology• if n=1 P(o) represents the property P of an object o • if n>1 P(o 1,…,o n) represents relations between the objects o 1,…,o

Gerald Steinbauer

Institute for Software Technology

30

Situation Calculus - Introduction

Fluents

• used to catch the dynamic world• fluents are related to states• represent relations and functions that changes from

situation to situation• these changes are represented by fluents• two different fluents

• relational fluents• functional fluents

Page 31: ktdcw 13 intro - Graz University of Technology• if n=1 P(o) represents the property P of an object o • if n>1 P(o 1,…,o n) represents relations between the objects o 1,…,o

Gerald Steinbauer

Institute for Software Technology

31

Situation Calculus - Introduction

Relational Fluents

• represents a relation (or properties) of objects in a situation s

• it is represented by a predicate symbol with arity n+1in the form F(x1,…,xn,s)

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

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

Page 32: ktdcw 13 intro - Graz University of Technology• if n=1 P(o) represents the property P of an object o • if n>1 P(o 1,…,o n) represents relations between the objects o 1,…,o

Gerald Steinbauer

Institute for Software Technology

32

Situation Calculus - Introduction

Functional Fluents

• represents a function of objects in a situation s• it is represented by a function symbol with arity n+1 in

the form f(x1,…,xn,s)• it represents the result (object) of a function• f:(objectsactions)nsituation→(objectsactions)• example: position(x,s)

Page 33: ktdcw 13 intro - Graz University of Technology• if n=1 P(o) represents the property P of an object o • if n>1 P(o 1,…,o n) represents relations between the objects o 1,…,o

Gerald Steinbauer

Institute for Software Technology

33

Situation Calculus - Introduction

Frame Problem

• 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

action and what remains the same• sloppy: logic has no memory• 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))

Page 34: ktdcw 13 intro - Graz University of Technology• if n=1 P(o) represents the property P of an object o • if n>1 P(o 1,…,o n) represents relations between the objects o 1,…,o

Gerald Steinbauer

Institute for Software Technology

34

Situation Calculus - Introduction

Successor State Axioms (1)

• are a solution to the Frame Problem• naively we have to specify all effect axioms (because

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

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

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

Page 35: ktdcw 13 intro - Graz University of Technology• if n=1 P(o) represents the property P of an object o • if n>1 P(o 1,…,o n) represents relations between the objects o 1,…,o

Gerald Steinbauer

Institute for Software Technology

35

Situation Calculus - Introduction

Successor State Axioms (2)• F(x1,…,xn,s)˄¬F(x1,…,xn,do(A(y1,…,ym),s))→φ-(x1,…,xn,y1,…,ym,s)• F(x1,…,xn,s)˄¬φ-(x1,…,xn,y1,…,ym,s)→F(x1,…,xn,do(A(y1,…,ym),s))

[PFA]

• ¬F(x1,…,xn,s)˄F(x1,…,xn,do(A(y1,…,ym),s))→φ+(x1,…,xn,y1,…,ym,s)• ¬F(x1,…,xn,s)˄¬φ+(x1,…,xn,y1,…,ym,s)→¬F(x1,…,xn,do(A(y1,…,ym),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]

Page 36: ktdcw 13 intro - Graz University of Technology• if n=1 P(o) represents the property P of an object o • if n>1 P(o 1,…,o n) represents relations between the objects o 1,…,o

Gerald Steinbauer

Institute for Software Technology

36

Situation Calculus - Introduction

Successor State Axioms (3)

• 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

• α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(x1,…,xn,s)˄¬βF(x1,…,xn,a,s)→¬F(x1,…,xn,do(a,s))• the axioms are universal quantified over a• we need only 2 x #fluents axioms anymore• explanations have to be short

Page 37: ktdcw 13 intro - Graz University of Technology• if n=1 P(o) represents the property P of an object o • if n>1 P(o 1,…,o n) represents relations between the objects o 1,…,o

Gerald Steinbauer

Institute for Software Technology

37

Situation Calculus - Introduction

Successor State Axioms (4)

• the general solution• positive and negative normal form effect axioms

• +(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]• -(x1,…,xn,a,s)→ ¬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

• 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]

Page 38: ktdcw 13 intro - Graz University of Technology• if n=1 P(o) represents the property P of an object o • if n>1 P(o 1,…,o n) represents relations between the objects o 1,…,o

Gerald Steinbauer

Institute for Software Technology

38

Situation Calculus - Introduction

Successor State Axioms (5)

• 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,a,s)˅f(x,s)=y˄¬y‘.φf(x,y‘,a,s)

• now we need only #actions + #fluents axioms

Page 39: ktdcw 13 intro - Graz University of Technology• if n=1 P(o) represents the property P of an object o • if n>1 P(o 1,…,o n) represents relations between the objects o 1,…,o

Gerald Steinbauer

Institute for Software Technology

39

Situation Calculus - Introduction

Summary Successor State Axioms

• provides a solution to the Frame Problem• yields simple compact axioms• only for deterministic primitive actions• does not solve the qualification and ramification

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

fluent• assumption: only a few actions change a fluent

Page 40: ktdcw 13 intro - Graz University of Technology• if n=1 P(o) represents the property P of an object o • if n>1 P(o 1,…,o n) represents relations between the objects o 1,…,o

Gerald Steinbauer

Institute for Software Technology

40

Situation Calculus - Introduction

Deterministic Primitive Actions

• do not have one of the following structures:

• Conditional Action: if car_in_driveway then drive else walk

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

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

• Recursive Actions:proc d(n)

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

end

Page 41: ktdcw 13 intro - Graz University of Technology• if n=1 P(o) represents the property P of an object o • if n>1 P(o 1,…,o n) represents relations between the objects o 1,…,o

Gerald Steinbauer

Institute for Software Technology

41

Situation Calculus - Introduction

Ramification Problem

• yet another important problem of AI • concerns of indirect consequences of an action• how to represent what happens implicitly due to an

action• famous example: where is Lincoln leg buried ?• simple example:

painted(x,s)˄partof(y,x)→painted(y,s)• solution: implicit effects have to be modeled

Page 42: ktdcw 13 intro - Graz University of Technology• if n=1 P(o) represents the property P of an object o • if n>1 P(o 1,…,o n) represents relations between the objects o 1,…,o

Gerald Steinbauer

Institute for Software Technology

42

Situation Calculus - Introduction

Initial Situation

• S0 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

the world, i.e. fluents that hold in S0

• S0 is the only situation mentioned• DS0 must not mention Poss, do or • it may comprise non-situation terms • examples: location(robot,office1,S0 ),

mountain(MtEverest)

Page 43: ktdcw 13 intro - Graz University of Technology• if n=1 P(o) represents the property P of an object o • if n>1 P(o 1,…,o n) represents relations between the objects o 1,…,o

Gerald Steinbauer

Institute for Software Technology

43

Situation Calculus - Introduction

Foundational Axioms for Situations

• 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 [nothing happened prior S0]4. s do(a,s’)ss’ with ss’ ~ ss’˅s=s’

Page 44: ktdcw 13 intro - Graz University of Technology• if n=1 P(o) represents the property P of an object o • if n>1 P(o 1,…,o n) represents relations between the objects o 1,…,o

Gerald Steinbauer

Institute for Software Technology

44

Situation Calculus - Introduction

Basic Action Theory (BAT)

• Σ … set of foundational axioms for situations• Dssa … set of successor state axioms• Dap … set of action precondition axioms• Duna … set of unique name axioms for actions• DS0 … set of first order sentences uniform in S0

0Sunaapssa DDDDD

Page 45: ktdcw 13 intro - Graz University of Technology• if n=1 P(o) represents the property P of an object o • if n>1 P(o 1,…,o n) represents relations between the objects o 1,…,o

Gerald Steinbauer

Institute for Software Technology

45

Situation Calculus - Introduction

Putting all Together (An Example)

• Towers of Hanoi

1

32

a b c

1

32

Page 46: ktdcw 13 intro - Graz University of Technology• if n=1 P(o) represents the property P of an object o • if n>1 P(o 1,…,o n) represents relations between the objects o 1,…,o

Gerald Steinbauer

Institute for Software Technology

46

Situation Calculus - Introduction

Regression

• related to the projection problem• does a sentence hold for some future situation

• used for automated reasoning and planning in the SC• sketch: prove if sentence W is entailed by BAT

• W mentions a relational fluent F(x1,…,xn,do(a,σ))• successor state axiom F(x1,…,xn,do(a,s))F(x1,…,xn,a,s)• obtain W’ by substituting F by F

• eliminating complex situation do(a, σ) from W‘• W‘ is closer to S0 as W• repeat the substitution until W0 uniform in S0

• now we can prove W in the initial database

Page 47: ktdcw 13 intro - Graz University of Technology• if n=1 P(o) represents the property P of an object o • if n>1 P(o 1,…,o n) represents relations between the objects o 1,…,o

Gerald Steinbauer

Institute for Software Technology

47

Situation Calculus - Introduction

Regressable Formulas

a formula W in the situation calculus is regressable iff

1. situation terms mentioned in W are of the form do([α1,…,αn],S0)

2. for atoms of form Poss(α,s) mentioned in W α has the form A(t1,…,tn) and is an action function symbol

3. W does not quantify over situations4. W does not mention the predicate symbol nor any

equality atom σ=σ’ for situations

Page 48: ktdcw 13 intro - Graz University of Technology• if n=1 P(o) represents the property P of an object o • if n>1 P(o 1,…,o n) represents relations between the objects o 1,…,o

Gerald Steinbauer

Institute for Software Technology

48

Situation Calculus - Introduction

Examples for Regressable Formulas

1. Poss(walk(A,B)S0)˄Poss(enter(office(Sue)),do(walk(A,B),S0))˄Poss(giveCoffee(Sue),do([walk(A,B),enter(Office(Sue))],S0)

2. (a,a’).onTable(A,do(a,S0))˄(x).xA→¬onTable(x,do([a,a’],S0))

Regressable ? Poss(a,S0) holding(x,do(pickup(A),s))

Page 49: ktdcw 13 intro - Graz University of Technology• if n=1 P(o) represents the property P of an object o • if n>1 P(o 1,…,o n) represents relations between the objects o 1,…,o

Gerald Steinbauer

Institute for Software Technology

49

Situation Calculus - Introduction

Regression Operator

1. if W is situation-independent or a relational fluent F(x,S0)[W]=W

2. if W is a regressable Poss(A(t),α) atom and Poss(A(x),s)A (x,s)[W]=[A (x,s)]

3. if W is a relational fluent F(t,do(α,σ)) and F(x,do(a,s))F(x,a,s)[W]=[F(x,a,s)]

4. [¬W]=¬[W][W1˄W2]=[W1]˄[W2][(v)W]=(v)[W]

Page 50: ktdcw 13 intro - Graz University of Technology• if n=1 P(o) represents the property P of an object o • if n>1 P(o 1,…,o n) represents relations between the objects o 1,…,o

Gerald Steinbauer

Institute for Software Technology

50

Situation Calculus - Introduction

Some Results from Regression

• if D is a basic action theory and W is a regressablesentence then,D╞ W iff DS0Duna╞[W]

• executable(s)=a,s*.do(a,s*)s→Poss(a,s*)

• D ╞ executable(do([α1,…, αn],S0)) iffDS0Duna╞ [Poss(αi,do([α1,…,αi-1],S0))] ˄ … ˄[Poss(α1,do([],S0))]

Page 51: ktdcw 13 intro - Graz University of Technology• if n=1 P(o) represents the property P of an object o • if n>1 P(o 1,…,o n) represents relations between the objects o 1,…,o

Gerald Steinbauer

Institute for Software Technology

51

Situation Calculus - Introduction

Planning

• yet we cannot derive in which situation s a goal sentence G(s) holds

• s can be seen as a plan (a sequence of actions) started in situation S0 iff D╞ G(do([α1,…, α1],S0))

• we looking for an appropriate s

• a planning algorithm is needed

Page 52: ktdcw 13 intro - Graz University of Technology• if n=1 P(o) represents the property P of an object o • if n>1 P(o 1,…,o n) represents relations between the objects o 1,…,o

Gerald Steinbauer

Institute for Software Technology

52

Situation Calculus - Introduction

A very simple (naive) planner

1. test if goal G holds in initial situation S0, if so return empty sequence of actions

2. if not set n=13. generate all sequences of actions of length n where

the preconditions are satisfied4. test if goal G holds in any of the situation generated

by the sequences, if so return appropriate sequence of actions (using regresssion)

5. if not increment n and continue with 3

Page 53: ktdcw 13 intro - Graz University of Technology• if n=1 P(o) represents the property P of an object o • if n>1 P(o 1,…,o n) represents relations between the objects o 1,…,o

Gerald Steinbauer

Institute for Software Technology

53

Situation Calculus - Introduction

Summary

• Situation Calculus• allows for reasoning about change and actions• a dialect of the second-order logic• uses the concept of situations• allows for proving properties• solves the frame problem

• Basic Action Theory• implements the situation calculus• Action Precondition & Successor State Axioms & Unique Name

Assumption & Foundation Axioms & Initial Situation

• Regression and Planning• allows for automated reasoning and planning

Page 54: ktdcw 13 intro - Graz University of Technology• if n=1 P(o) represents the property P of an object o • if n>1 P(o 1,…,o n) represents relations between the objects o 1,…,o

Gerald Steinbauer

Institute for Software Technology

54

Situation Calculus - Introduction

Outlook - Golog

• Situation Calculus is yet only a theoretical construct• Golog (alGol for Logic) is based on the Situation

Calculus• it is a program language for dynamic systems• it allows a balance between reasoning/planning and

programming• it allows complex actions• there exist(s) (a) Prolog interpreter(s) for Golog

Page 55: ktdcw 13 intro - Graz University of Technology• if n=1 P(o) represents the property P of an object o • if n>1 P(o 1,…,o n) represents relations between the objects o 1,…,o

Gerald Steinbauer

Institute for Software Technology

55

Situation Calculus - Introduction

Questions ?