The situation calculus is a logic formalism designed for representing and reasoning about dynamical domains. It was first introduced by John McCarthy in 1963.[1] The main version of the situational calculus that is presented in this article is based on that introduced by Ray Reiter in 1991. It is followed by sections about McCarthy's 1986 version and a logic programming formulation.
The situation calculus represents changing scenarios as a set of first-order logic formulae. The basic elements of the calculus are:
A domain is formalized by a number of formulae, namely:
A simple robot world will be modeled as a running example. In this world there is a single robot and several inanimate objects. The world is laid out according to a grid so that locations can be specified in terms of
(x,y)
The main elements of the situation calculus are the actions, fluents and the situations. A number of objects are also typically involved in the description of the world. The situation calculus is based on a sorted domain with three sorts: actions, situations, and objects, where the objects include everything that is not an action or a situation. Variables of each sort can be used. While actions, situations, and objects are elements of the domain, the fluents are modeled as either predicates or functions.
The actions form a sort of the domain. Variables of sort action can be used and also functions whose result is of sort action. Actions can be quantified. In the example robot world, possible action terms would be
move(x,y)
(x,y)
pickup(o)
In the situation calculus, a dynamic world is modeled as progressing through a series of situations as a result of various actions being performed within the world. A situation represents a history of action occurrences. In the Reiter version of the situation calculus described here, a situation does not represent a state, contrarily to the literal meaning of the term and contrarily to the original definition by McCarthy and Hayes. This point has been summarized by Reiter as follows:
A situation is a finite sequence of actions. Period. It's not a state, it's not a snapshot, it's a history.[2]
The situation before any actions have been performed is typically denoted and called the initial situation. The new situation resulting from the performance of an action is denoted using the function symbol (Some other references[3] also use). This function symbol has a situation and an action as arguments, and a situation as a result, the latter being the situation that results from performing the given action in the given situation.
The fact that situations are sequences of actions and not states is enforced by an axiom stating that
do(a,s)
do(a',s')
a=a'
s=s'
In the example robot world, if the robot's first action is to move to location
(2,3)
move(2,3)
do(move(2,3),S0)
do(pickup(Ball),do(move(2,3),S0))
do(move(2,3),S0)
do(pickup(Ball),do(move(2,3),S0))
See main article: Fluent (artificial intelligence). Statements whose truth value may change are modeled by relational fluents, predicates that take a situation as their final argument. Also possible are functional fluents, functions that take a situation as their final argument and return a situation-dependent value. Fluents may be thought of as "properties of the world"'. In the example, the fluent
it{isCarrying}(o,s)
it{isCarrying}(Ball,S0)
it{isCarrying}(Ball,do(pickup(Ball),S0))
location(s)
(x,y)
The description of a dynamic world is encoded in second-order logic using three kinds of formulae: formulae about actions (preconditions and effects), formulae about the state of the world, and foundational axioms.
Some actions may not be executable in a given situation. For example, it is impossible to put down an object unless one is in fact carrying it. The restrictions on the performance of actions are modeled by literals of the form
it{Poss}(a,s)
it{Poss}(drop(o),s)\leftrightarrowit{isCarrying}(o,s)
As a more complex example, the following models that the robot can carry only one object at a time, and that some objects are too heavy for the robot to lift (indicated by the predicate):
it{Poss}(pickup(o),s)\leftrightarrow(\forallz \negit{isCarrying}(z,s))\wedge\negheavy(o)
Given that an action is possible in a situation, one must specify the effects of that action on the fluents. This is done by the effect axioms. For example, the fact that picking up an object causes the robot to be carrying it can be modeled as:
Poss(pickup(o),s) → it{isCarrying}(o,do(pickup(o),s))
It is also possible to specify conditional effects, which are effects that depend on the current state. The following models that some objects are fragile (indicated by the predicate) and dropping them causes them to be broken (indicated by the fluent):
Poss(drop(o),s)\wedgefragile(o) → broken(o,do(drop(o),s))
While this formula correctly describes the effect of the actions, it is not sufficient to correctly describe the action in logic, because of the frame problem.
While the above formulae seem suitable for reasoning about the effects of actions, they have a critical weakness—they cannot be used to derive the non-effects of actions. For example, it is not possible to deduce that after picking up an object, the robot's location remains unchanged. This requires a so-called frame axiom, a formula like:
Poss(pickup(o),s)\wedgelocation(s)=(x,y) → location(do(pickup(o),s))=(x,y)
The need to specify frame axioms has long been recognised as a problem in axiomatizing dynamic worlds, and is known as the frame problem. As there are generally a very large number of such axioms, it is very easy for the designer to leave out a necessary frame axiom, or to forget to modify all appropriate axioms when a change to the world description is made.
The successor state axioms "solve" the frame problem in the situation calculus. According to this solution, the designer must enumerate as effect axioms all the ways in which the value of a particular fluent can be changed. The effect axioms affecting the value of fluent
F(\overrightarrow{x},s)
+ | |
Poss(a,s)\wedge\gamma | |
F |
(\overrightarrow{x},a,s) → F(\overrightarrow{x},do(a,s))
- | |
Poss(a,s)\wedge\gamma | |
F |
(\overrightarrow{x},a,s) → \negF(\overrightarrow{x},do(a,s))
The formula
+ | |
\gamma | |
F |
do(a,s)
- | |
\gamma | |
F |
If this pair of axioms describe all the ways in which fluent can change value, they can be rewritten as a single axiom:
+ | |
Poss(a,s) → \left[F(\overrightarrow{x},do(a,s))\leftrightarrow\gamma | |
F |
- | |
(\overrightarrow{x},a,s)\vee\left(F(\overrightarrow{x},s)\wedge\neg\gamma | |
F |
(\overrightarrow{x},a,s)\right)\right]
In words, this formula states: "given that it is possible to perform action in situation, the fluent would be true in the resulting situation
do(a,s)
By way of example, the value of the fluent introduced above is given by the following successor state axiom:
Poss(a,s) → \left[broken(o,do(a,s))\leftrightarrowa=drop(o)\wedgefragile(o) \veebroken(o,s)\wedgea ≠ repair(o)\right]
The properties of the initial or any other situation can be specified by simply stating them as formulae. For example, a fact about the initial state is formalized by making assertions about
S0
(0,0)
\forallz\negit{isCarrying}(z,S0)
location(S0)=(0,0)
\forallo\negbroken(o,S0)
The foundational axioms of the situation calculus formalize the idea that situations are histories by having
do(a,s)=do(a',s')\iffa=a'\lands=s'
Regression[4] is a mechanism for proving consequences in the situation calculus.[5] It is based on expressing a formula containing the situation
do(a,s)
do(a,s)
See main article: GOLOG. GOLOG is a logic programming language based on the situation calculus.[6] [7]
The main difference between the original situation calculus by McCarthy and Hayes and the one in use today is the interpretation of situations. In the modern version of the situational calculus, a situation is a sequence of actions. Originally, situations were defined as "the complete state of the universe at an instant of time". It was clear from the beginning that such situations could not be completely described; the idea was simply to give some statements about situations, and derive consequences from them. This is also different from the approach that is taken by the fluent calculus, where a state can be a collection of known facts, that is, a possibly incomplete description of the universe.
In the original version of the situation calculus, fluents are not reified. In other words, conditions that can change are represented by predicates and not by functions. Actually, McCarthy and Hayes defined a fluent as a function that depends on the situation, but they then proceeded always using predicates to represent fluents. For example, the fact that it is raining at place in the situation is represented by the literal
raining(x,s)
location(x,s)
location(x,s)=location(x,s')
s'
The execution of actions is represented by the function : the execution of the action in the situation is the situation
it{result}(a,s)
it{result}(a,s)
\neglocked(door,s) → open(door,it{result}(opens,s))
The predicates and represent the conditions of a door being locked and open, respectively. Since these conditions may vary, they are represented by predicates with a situation argument. The formula says that if the door is not locked in a situation, then the door is open after executing the action of opening, this action being represented by the constant .
These formulae are not sufficient to derive everything that is considered plausible. Indeed, fluents at different situations are only related if they are preconditions and effects of actions; if a fluent is not affected by an action, there is no way to deduce it did not change. For example, the formula above does not imply that
\neglocked(door,it{result}(opens,s))
\neglocked(door,s)
\neglocked(door,s) → \neglocked(door,it{result}(opens,s))
In the original formulation of the situation calculus, the initial situation, later denoted by, is not explicitly identified. The initial situation is not needed if situations are taken to be descriptions of the world. For example, to represent the scenario in which the door was closed but not locked and the action of opening it is performed is formalized by taking a constant to mean the initial situation and making statements about it (e.g.,
\neglocked(door,s)
open(door,it{result}(opens,s))
location(x,s)
It is also possible (e.g. Kowalski 1979, Apt and Bezem 1990, Shanahan 1997) to write the situation calculus as a logic program:
it{Holds}(f,do(a,s))\leftarrowit{Poss}(a,s)\wedgeit{Initiates}(a,f,s)
it{Holds}(f,do(a,s))\leftarrowit{Poss}(a,s)\wedgeit{Holds}(f,s)\wedge\negit{Terminates}(a,f,s)
Here is a meta-predicate and the variable ranges over fluents. The predicates, and correspond to the predicates,
+ | |
\gamma | |
F |
(\overrightarrow{x},a,s)
- | |
\gamma | |
F |
(\overrightarrow{x},a,s)