Event calculus

The event calculus is a logical theory for representing and reasoning about events and about the way in which they change the state of some real or artificial world. It deals both with action events, which are performed by agents, and with external events, which are outside the control of any agent.

The event calculus represents the state of the world at any time by the set of all the facts (called fluents) that hold at the time. Events initiate and terminate fluents:

The event calculus differs from most other approaches for reasoning about change by reifying time, associating events with the time at which they happen, and associating fluents with the times at which they hold.

The original version of the event calculus, introduced by Robert Kowalski and Marek Sergot in 1986, was formulated as a logic program and developed for representing narratives and database updates. Kave Eshghi showed how to use the event calculus for planning, by using abduction to generate hypothetical actions to achieve a desired state of affairs.

It was extended by Murray Shanahan and Rob Miller in the 1990s and reformulated in first-order logic with circumscription. These and later extensions have been used to formalize non-deterministic actions, concurrent actions, actions with delayed effects, gradual changes, actions with duration, continuous change, and non-inertial fluents.

Van Lambalgen and Hamm showed how a formulation of the event calculus as a constraint logic program can be used to give an algorithmic semantics to tense and aspect in natural language.

Fluents and events
In the event calculus, fluents are reified. This means that fluents are represented by terms. For example, $$\mathit{holdsAt}(on(green\_block,table),1)$$ expresses that the $$\mathit{green\_block}$$ is on the $$\mathit{table}$$ at time $$1$$. Here $$\mathit{holdsAt}$$ is a predicate, while $$\mathit{on(green\_block, table)}$$ is a term. In general, the atomic formula
 * $$\mathit{holdsAt}(fluent,time)$$ expresses that the $$\mathit{fluent}$$ holds at the $$\mathit{time.}$$

Events are also reified and represented by terms. For example, $$\mathit{happensAt}(move(green\_block, red\_block), 3)$$ expresses that the $$\mathit{green\_block}$$ is moved onto the $$\mathit{red\_block)}$$ at time $$3$$. In general:
 * $$\mathit{happensAt}(event,time)$$ expresses that the $$\mathit{event}$$ happens at the $$\mathit{time.}$$

The relationships between events and the fluents that they initiate and terminate are also represented by atomic formulae:
 * $$\mathit{initiates}(event,fluent,time)$$ expresses that if the $$\mathit{event}$$ happens at the $$\mathit{time}$$ then the $$\mathit{fluent}$$ becomes true after the $$\mathit{time}$$.


 * $$\mathit{terminates}(event,fluent,time)$$ expresses that if the $$\mathit{event}$$ happens at the $$\mathit{time}$$ then the $$\mathit{fluent}$$ ceases to be true after the $$\mathit{time}$$.

Domain-independent axiom
The event calculus was developed in part as an alternative to the situation calculus, as a solution to the frame problem, of representing and reasoning about the way in which actions and other events change the state of some world.

There are many variants of the event calculus. But the core axiom of one of the simplest and most useful variants can be expressed as a single, domain-independent axiom:


 * $$\mathit{holdsAt}(F,T2) \leftarrow$$
 * $$[\mathit{happensAt}(E1,T1) \wedge \mathit{initiates}(E1, F, T1) \wedge (T1 < T2) \wedge $$
 * $$\neg \exists E2, T [\mathit{happensAt}(E2, T) \wedge \mathit{terminates}(E2, F, T) \wedge (T1 \leq T < T2)] $$

The axiom states that
 * a fluent $$F$$ holds at a time $$T2$$ if
 * an event $$E1$$ happens at a time $$T1$$ and
 * $$E1$$ initiates $$F$$ at $$T1$$ and
 * $$T1$$ is before $$T2$$ and
 * it is not the case that there exists an event $$E2$$ and a time $$T$$ such that
 * $$E2$$ happens at $$T$$ and
 * $$E2$$ terminates $$F$$ at $$T$$ and
 * $$T1$$ is before or at the same time as $$T$$ and
 * $$T$$ is before $$T2$$.

The event calculus solves the frame problem by interpreting this axiom in a non-monotonic logic, such as first-order logic with circumscription or, as a logic program, in Horn clause logic with negation as failure. In fact, circumscription is one of the several semantics that can be given to negation as failure, and it is closely related to the completion semantics for logic programs (which interprets if as if and only if).

The core event calculus axiom defines the $$holdsAt$$ predicate in terms of the $$happensAt$$, $$initiates$$, $$terminates$$, $$<$$ and $$\leq $$ predicates. To apply the event calculus to a particular problem, these other predicates also need to be defined.

The event calculus is compatible with different definitions of the temporal predicates $$<$$ and $$\leq $$. In most applications, times are represented discretely, by the natural numbers, or continuously, by non-negative real numbers. However, times can also be partially ordered.

Domain-dependent axioms
To apply the event calculus in a particular problem domain, it is necessary to define the $$initiates$$ and $$terminates$$ predicates for that domain. For example, in the blocks world domain, an event $$move(Object, Place)$$ of moving an object onto a place intitiates the fluent $$on(Object, Place)$$, which expresses that the object is on the place and terminates the fluent $$on(Object, Place1)$$, which expresses that the object is on a different place:


 * $$\mathit{initiates}(move(Object, Place), on(Object, Place), Time). $$
 * $$\mathit{terminates}(move(Object, Place), on(Object, Place1), Time) \leftarrow different(Place1, Place). $$

If we want to represent the fact that a $$Fluent$$ holds in an initial state, say at time 1, then with the simple core axiom above we need an event, say $$initialise(Fluent)$$, which initiates the $$Fluent$$ at any time:


 * $$\mathit{initiates}(initialise(Fluent), Fluent, Time). $$

Problem-dependent axioms
To apply the event calculus, given the definitions of the $$holdsAt$$, $$initiates$$, $$terminates$$, $$<$$ and $$\leq $$ predicates, it is necessary to define the $$happensAt$$ predicates that describe the specific context of the problem.

For example, in the blocks world domain, we might want to describe an initial state in which there are two blocks, a red block on a green block on a table, like a toy traffic light, followed by moving the red block to the table at time 1 and moving the green block onto the red block at time 3, turning the traffic light upside down:


 * $$\mathit{happensAt}(initialise(on(red\_block,green\_block), 0)$$
 * $$\mathit{happensAt}(initialise(on(green\_block,table), 0)$$


 * $$\mathit{happensAt}(move(red\_block, table), 1)$$
 * $$\mathit{happensAt}(move(green\_block, red\_block), 3)$$

A Prolog implementation
The event calculus has a natural implementation in pure Prolog (without any features that do not have a logical interpretation). For example, the blocks world scenario above can be implemented (with minor modifications) by the program:

The Prolog program differs from the earlier formalisation in the following ways:


 * The core axiom has been rewritten, using an auxiliary predicate  This rewriting enables the elimination of existential quantifiers, conforming to the Prolog convention that all variables are universally quantified.
 * The order of the conditions in the body of the core axiom(s) has been changed, to generate answers to queries in temporal order.
 * The equality in the condition $$T1 \leq T $$ has been removed from the corresponding condition  This builds in a simplifying assumption that events do not simultaneously initiate and terminate the same fluent. As a consequence, the definition of the  $$terminates$$ predicate has been simplified by eliminating the condition that $$different(Place1, Place)$$.

Given an appropriate definition of the predicate  the Prolog program generates all answers to the query what holds when? in temporal order:

The program can also answer negative queries, such as which fluents do not hold at which times? However, to work correctly, all variables in negative conditions must first be instantiated to terms containing no variables. For example:

Reasoning tools
In addition to Prolog and its variants, several other tools for reasoning using the event calculus are also available:
 * Abductive Event Calculus Planners
 * Discrete Event Calculus Reasoner
 * Event Calculus Answer Set Programming
 * Reactive Event Calculus
 * Run-Time Event Calculus (RTEC)

Extensions
Notable extensions of the event calculus include Markov logic networks–based variants probabilistic, epistemic and their combinations.