Home > Documents > Situation Calculus Vassilis Papataxiarhis Foundations of Databases June, 2006 June, 2006.

Situation Calculus Vassilis Papataxiarhis Foundations of Databases June, 2006 June, 2006.

Date post: 17-Dec-2015
Category:
View: 217 times
Popular Tags:
32
Situation Situation Calculus Calculus Vassilis Papataxiarhis Vassilis Papataxiarhis Foundations of Databases Foundations of Databases June, June, 2006 2006
Transcript

Situation Situation CalculusCalculusVassilis PapataxiarhisVassilis Papataxiarhis

Foundations of DatabasesFoundations of Databases June, June, 20062006

First-Order Logic (FOL)First-Order Logic (FOL)(1/4)(1/4)

First-Order Logic is a system of First-Order Logic is a system of

mathematical logic.mathematical logic.

FOL is extending Propositional LogicFOL is extending Propositional Logic Variables represent objects of a “universe of Variables represent objects of a “universe of

discourse”discourse”

Quantification over variablesQuantification over variables

First-Order Logic (FOL)First-Order Logic (FOL)(2/4)(2/4)

FOL VocabularyFOL Vocabulary

Set of constants which represents objects of a “universe Set of constants which represents objects of a “universe

of discourse”, e.g. of discourse”, e.g. Socrates, 20, 40Socrates, 20, 40 … …

Set of function symbols with arity 1, Set of function symbols with arity 1,

e.g. father_of (e.g. father_of (SocratesSocrates), average( average (), average( average (20, 4020, 40), ), 4040), ),

……

Set of predicates with arity 1, e.g. father (Set of predicates with arity 1, e.g. father (SocratesSocrates), ),

……

Infinite set of variables, e.g. x, y, z …Infinite set of variables, e.g. x, y, z …

First-Order Logic (FOL)First-Order Logic (FOL)(3/4)(3/4)

FOL VocabularyFOL Vocabulary (cont.) (cont.) Logical operators: Logical operators: ¬¬ (not), (not), (and), (and), (or), (or),

→→(conditional), (conditional), ↔↔(biconditional)(biconditional) Left and right parenthesis: “ ( “ , “ ) ”Left and right parenthesis: “ ( “ , “ ) ” Quantifiers: Quantifiers: (existential), (existential), (universal) (universal) Equality symbol “=“ is sometimes included, not Equality symbol “=“ is sometimes included, not

always.always.

Unlike predicates, fuction symbols are not true Unlike predicates, fuction symbols are not true or false, but represent objects of the or false, but represent objects of the “universe”.“universe”.

First-Order Logic (FOL)First-Order Logic (FOL)(4/4)(4/4)

Examples:Examples:

x P(x), “for at least one object x P(x), “for at least one object aa, P(, P(aa) is true”) is true”

x P(x), “for any object x P(x), “for any object aa, P(, P(aa) is true”) is true”

x (P(x) x (P(x) y (P(y) y (P(y) →→ x=y)), “P(x) holds for x=y)), “P(x) holds for

exactly one object”exactly one object”

Second-Order Logic Second-Order Logic (SOL) (1/3)(SOL) (1/3)

In FOL we quantify over individuals, but not over In FOL we quantify over individuals, but not over

properties.properties.

In FOL we can find the individuals of a property, but In FOL we can find the individuals of a property, but

how can we find the properties of an individual?how can we find the properties of an individual?

E.g. Suppose a simple knowledge base (KB): father(E.g. Suppose a simple knowledge base (KB): father(JohnJohn).).

:-? father (x).:-? father (x).

KB|=KB|= x=x=JohnJohn

:-? X (:-? X (JohnJohn).).

KB|=KB|= X=fatherX=father

Second-Order Logic Second-Order Logic (SOL) (2/3)(SOL) (2/3)

SOL is extending FOLSOL is extending FOL

Variables in predicate positions (rather than only in individual Variables in predicate positions (rather than only in individual

positions in FOL)positions in FOL)

Quantification over predicatesQuantification over predicates

As a result, SOL has more “expressive power” than FOL As a result, SOL has more “expressive power” than FOL

does.does.

E.g. In FOL there is no way to say explicitly that individuals E.g. In FOL there is no way to say explicitly that individuals aa

and and bb have at least a same property in common, but in SOL we have at least a same property in common, but in SOL we

can say: can say:

P ( P(P ( P(aa) ) P( P(bb) )) )

Second-Order Logic Second-Order Logic (SOL) (3/3)(SOL) (3/3)

Examples:Examples:

P P(P P(JohnJohn), “There is a property P that ), “There is a property P that JohnJohn is is

member of”member of”

F F(F F(JohnJohn) ) ¬¬F(F(JohnJohn) () (principle of bivalenceprinciple of bivalence))

“ “For every property, either For every property, either JohnJohn has it or he has it or he

doesn’t.”doesn’t.”

Equality in SOL can be defined by:Equality in SOL can be defined by:

x=y x=y P (P(x)P (P(x)↔↔P(y))P(y))

def

Situation Calculus : Situation Calculus : OverviewOverview

The Situation Calculus is a logic formalism designed for The Situation Calculus is a logic formalism designed for

McCarthy, Hayes 1969McCarthy, Hayes 1969

Reiter 1991Reiter 1991

In First-Order Logic, sentences are either true or false In First-Order Logic, sentences are either true or false

and stay that way. Nothing is corresponding to any sort and stay that way. Nothing is corresponding to any sort

of change.of change.

SitCalc represents changing scenarios as a set of SOL SitCalc represents changing scenarios as a set of SOL

formulae.formulae.

Situation Calculus : Situation Calculus : Basic ElementsBasic Elements

ActionsActions that can be performed in the world that can be performed in the world

Actions can be quantifiedActions can be quantified

FluentsFluents that describe the state of the world that describe the state of the world

SituationsSituations represent a history of action occurrences represent a history of action occurrences

AA dynamic world is modeled as progressing through a series dynamic world is modeled as progressing through a series

of situations as a result of various actions being performed of situations as a result of various actions being performed

within the worldwithin the world

A finite sequence of actionsA finite sequence of actions

A situation is not a state, but a historyA situation is not a state, but a history

Situation Calculus : Situation Calculus : FormulaeFormulae

A domain is encoded in SOL by three kind of A domain is encoded in SOL by three kind of

formulaeformulae

Action precondition axiomsAction precondition axioms and and action effects action effects

axiomsaxioms

Successor state axiomsSuccessor state axioms, one for each fluent, one for each fluent

The foundational axiomsThe foundational axioms of the situation of the situation

calculuscalculus

Situation Calculus : An Situation Calculus : An Example (1/10)Example (1/10)

WorldWorld: : robotrobot itemsitems locations (x,y)locations (x,y) moves around the worldmoves around the world picks up or drops itemspicks up or drops items some items are too heavy for the robot to pick upsome items are too heavy for the robot to pick up some items are fragile so that they break when some items are fragile so that they break when

they are droppedthey are dropped robot can repair any broken item that it is robot can repair any broken item that it is

holdingholding

Situation Calculus : An Situation Calculus : An Example (2/10)Example (2/10)

ActionsActions

move(x, y): move(x, y): robot is moving to a new locationrobot is moving to a new location

(x, y)(x, y)

pickup(o): pickup(o): robot picks up an objectrobot picks up an object o o

drop(o): drop(o): robot drops the object robot drops the object o o that holdsthat holds

Situation Calculus : An Situation Calculus : An Example (3/10)Example (3/10)

SituationsSituations Initial situation Initial situation SS00: no actions have yet occurred: no actions have yet occurred

A new situation, resulting from the performance of an A new situation, resulting from the performance of an

action a in current situation action a in current situation ss, is denoted using the , is denoted using the

function symbol function symbol do(a, s)do(a, s)..

do(move(do(move(22, , 33), S), S00):): denotes the new situation denotes the new situation

after the performance of action after the performance of action move(move(22, , 33)) in in

initial situation initial situation SS00..

do(pickup(do(pickup(BallBall ),), do(move(do(move(22,, 33),), S S00))))

do(a,s) do(a,s) is equal tois equal to do(a’,s’) s=s’ and a=a’ do(a’,s’) s=s’ and a=a’

Situation Calculus : An Situation Calculus : An Example (4/10)Example (4/10)

Fluents: Fluents: “properties of the world”“properties of the world”

Relational fluentsRelational fluents

Statements whose truth value may changeStatements whose truth value may change

They take a situation as a final argumentThey take a situation as a final argument

is_carrying(o, s)is_carrying(o, s):: robot is carrying object robot is carrying object oo in situation in situation ss

E.g. Suppose that the robot initially carries nothingE.g. Suppose that the robot initially carries nothing

is_carrying(is_carrying(BallBall, S, S00) : FALSE) : FALSE

is_carrying(is_carrying(BallBall,, do(pickup(do(pickup(BallBall ),), S S00))) : ) :

TRUETRUE

Situation Calculus : An Situation Calculus : An Example (5/10)Example (5/10)

Fluents Fluents (cont.)(cont.)

Functional fluentsFunctional fluents

Functions that return a situation-dependent Functions that return a situation-dependent

valuevalue

They take a situation as a final argumentThey take a situation as a final argument

location(s)location(s): returns the location (x, y) of : returns the location (x, y) of

the robot in situation the robot in situation ss

Situation Calculus : An Situation Calculus : An Example (6/10)Example (6/10)

Action Preconditions AxiomsAction Preconditions Axioms

Some actions may not be executable in a given Some actions may not be executable in a given

situationsituation

Poss(a,s): Poss(a,s): special binary predicatespecial binary predicate

denotes the executability of action denotes the executability of action aa in situation in situation ss

Examples:Examples:

Poss(drop(o),s) Poss(drop(o),s) ↔↔ is_carrying(o,s) is_carrying(o,s)

Poss(pickup(o),s) Poss(pickup(o),s) ↔↔ ( (z z ¬¬is_carrying(z,s) is_carrying(z,s)

¬¬heavy(o))heavy(o))

Situation Calculus : An Situation Calculus : An Example (7/10)Example (7/10)

Action Effects AxiomsAction Effects Axioms

Specify the effects of an action Specify the effects of an action on the fluentson the fluents

Examples:Examples:

Poss(pickup(o),s) Poss(pickup(o),s) →→

is_carrying(o,do(pickup(o),s))is_carrying(o,do(pickup(o),s))

Poss(drop(o),s) Poss(drop(o),s) fragile(o) fragile(o) →→

broken(o,do( drop(o),s))broken(o,do( drop(o),s))

Is that enough? No, because of theIs that enough? No, because of the frame problem frame problem

Situation Calculus : An Situation Calculus : An Example (8/10)Example (8/10)

The frame problemThe frame problem

How can we derive the How can we derive the non-effectsnon-effects of axioms? of axioms?

E.g. How can we derive that after picking up an E.g. How can we derive that after picking up an

object, the robot’s location remains unchanged?object, the robot’s location remains unchanged?

This requires a formulae likeThis requires a formulae like

Poss(pickup(o),s) Poss(pickup(o),s) location(s) = (x,y) location(s) = (x,y) →→

location(do(pickup(o),s)) = (x,y)location(do(pickup(o),s)) = (x,y)

Problem: too many of such axioms, difficult to specify Problem: too many of such axioms, difficult to specify

allall

Situation Calculus : An Situation Calculus : An Example (9/10)Example (9/10)

The solution: The solution: Successor state axiomsSuccessor state axioms Specify all the ways Specify all the ways the value of a particular fluent can be the value of a particular fluent can be

changedchanged

Poss(a,s) Poss(a,s) γγ++FF(x,a,s) (x,a,s) →→ F(x,do(a,s)) F(x,do(a,s))

Poss(a,s) Poss(a,s) γγ--FF(x,a,s) (x,a,s) →→ ¬¬F(x,do(a,s))F(x,do(a,s))

γγ++FF describes the conditions under which action describes the conditions under which action aa in situation in situation ss

makes the fluent makes the fluent FF become true in the successor situation become true in the successor situation do(a,s)do(a,s) ..

γγ--FF describes the conditions under which performing action describes the conditions under which performing action aa in in

situation situation ss makes fluent makes fluent FF false in the successor situation. false in the successor situation.

Situation Calculus : An Situation Calculus : An Example (10/10)Example (10/10)

Successor state axioms Successor state axioms (cont.)(cont.) Poss(a,s) Poss(a,s) →→ [F(x,do(a,s)) [F(x,do(a,s)) ↔↔ γγ++

FF(x,a,s) (x,a,s) (F(x,s) (F(x,s) ¬γ ¬γ--FF(x,a,s))](x,a,s))]

““Given that it is possible to perform Given that it is possible to perform aa in in ss, the fluent , the fluent FF would would

be true in the resulting situation be true in the resulting situation do(a,s)do(a,s) iff performing iff performing aa in in ss

would make it true, or it is true in would make it true, or it is true in ss and performing and performing aa in in ss

would not make it false. ”would not make it false. ”

Example:Example:

Poss(a,s) Poss(a,s) →→ [broken(o,do(a,s)) [broken(o,do(a,s)) ↔↔ (a=drop(o) (a=drop(o)

fragile(o))fragile(o))

(broken(o,s) (broken(o,s) a a repair(o,s))] repair(o,s))]

Situation Calculus : A Complete Situation Calculus : A Complete ExampleExample Precondition AxiomsPrecondition Axioms

Poss(pickup(o),s) ↔ z ¬is_carrying(z,s) ¬heavy(o) Poss(putonfloor(o),s) ↔ is_carrying(o,s) Poss(putontable(o),s) ↔ is_carrying(o,s)

Successor State AxiomsSuccessor State Axioms is_carrying(o,do(a,s)) ↔ a=pickup(o) (is_carrying(o,s) a

putontable(o) a putonfloor(o) ) OnTable(o,do(a,s)) ↔ (OnTable(o,s) a pickup(o)) a = putontable(o) OnFloor(o,do(a,s)) ↔ (OnFloor(o,s) a pickup(o)) a = putonfloor(o)

Initial stateInitial state ¬is_carrying(o,S0) OnTable(o, S0) ↔ o=A o=B

proc: RemoveBlock(o) : pickup(o) ; putonfloor(o) endProc; proc: ClearTable : while o OnTable(o) do RemoveBlock(o) endWhile

endProc;

KB |= s Do(ClearTable, S0, s).s=do(putonfloor(B),do(pickup(B),do(putonfloor(A),do(pickup(A), S0))))

We can formalize the evolution of a DB We can formalize the evolution of a DB

during a sequence of transactionsduring a sequence of transactions

Transactions are same as actionsTransactions are same as actions

During the evolution, a DB pass through During the evolution, a DB pass through

different statesdifferent states

Updatable DB-relationsUpdatable DB-relations

Once again: The frame problemOnce again: The frame problem

An Example (1/7)An Example (1/7) Suppose that DB involves 3 relations:Suppose that DB involves 3 relations:

1. 1. enrolled (st, course, s):enrolled (st, course, s): student student stst is enrolled in is enrolled in

course course coursecourse when DB is in state when DB is in state ss

student student stst in course in course coursecourse is is gradegrade when the DB is when the DB is

in state in state ss

3. 3. prerequ (pre, course):prerequ (pre, course): prepre is a prerequisite is a prerequisite

course for course course for course coursecourse

(Notice that last relation is state independent so is (Notice that last relation is state independent so is

not expected to change during the evolution of the not expected to change during the evolution of the

database.)database.)

An Example (2/7)An Example (2/7)

Three transactions:Three transactions:

11. . register (st, course): register (st, course): Register student Register student stst in in

course course coursecourse

2. change (st, course, grade): 2. change (st, course, grade): Change the Change the

current grade of student current grade of student st st in course in course coursecourse to to

3. drop (st, course): 3. drop (st, course): Student Student st st drops course drops course

coursecourse

An Example (3/7)An Example (3/7) Initial DB stateInitial DB state

First-order specification of what is true in First-order specification of what is true in

SS00

E.g. E.g.

enrolled (Mary, C100, SS00)

(pp) ¬¬prerequ (p, prerequ (p, C100C100))

An Example (4/7)An Example (4/7) Transaction PreconditionsTransaction Preconditions

Transactions have preconditions which must Transactions have preconditions which must be satisfied by the current DB statebe satisfied by the current DB state

E.g.E.g.

1. Poss(register (st,c),s) 1. Poss(register (st,c),s) ↔↔ [(pp) prerequ (p,c) prerequ (p,c) →→

2. Poss(change (st,c,g),s) Poss(change (st,c,g),s) ↔↔ ( (g’) g’)

3. Poss(drop(st,c),s) ↔↔ enrolled(st,c,s) enrolled(st,c,s)

An Example (5/7)An Example (5/7) Update SpecificationsUpdate Specifications

Specify the effects of all transactions on Specify the effects of all transactions on

all updatable DB relationsall updatable DB relations

E.g.E.g.

Poss(a,s) Poss(a,s) →→ [enrolled(st,c,do(a,s)) [enrolled(st,c,do(a,s)) ↔↔

a=register(st,c) a=register(st,c)

An Example (6/7)An Example (6/7) Update SpecificationsUpdate Specifications(cont.)(cont.)

It is the update specification axioms which It is the update specification axioms which

“solve” the frame problem“solve” the frame problem E.g.E.g.

Poss(a,s)Poss(a,s) a aregister(st,c) register(st,c) a adrop(st,c) drop(st,c) →→

(enrolled(st,c,do(a,s)) (enrolled(st,c,do(a,s)) ↔↔ enrolled(st,c,s)) enrolled(st,c,s))

register() register() andand drop() drop() are the only transactions are the only transactions

that can affect the truth value of that can affect the truth value of enrolled()enrolled()

An Example (7/7)An Example (7/7) Querying a DatabaseQuerying a Database

All updates are virtual, DB is never physically All updates are virtual, DB is never physically changedchanged

To query a DB, resulting from a sequence of To query a DB, resulting from a sequence of transactions, we must refer to this sequence transactions, we must refer to this sequence in the queryin the query

E.g. E.g. To determine if John is enrolled in any courses after the transaction sequence drop (John, C100), register (Mary, C100)drop (John, C100), register (Mary, C100)has been “executed”, we must determine whether

DB|= DB|= c enrolled(John, c, do(register (Mary, c enrolled(John, c, do(register (Mary, C100), do(drop (John, C100), C100), do(drop (John, C100), SS00))).))).

ReferencesReferences

J.McCarthy and P.J.Hayes, Some Philosophical Problems from the Standpoint of Artificial Intelligence, in Machine Intelligence 4, ed D.Michie and B.Meltzer, Edinburgh University Press (1969)

R. Reiter, On Specifying Database Updates, Journal of Logic Programming, 25(1):53–91, 1995.

ANY QUESTIONS?ANY QUESTIONS?

Recommended