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:

A fluent holds at a time

if the fluent is initiated by an event that happens at an earlier time

and the fluent is not terminated by any event that happens in the meantime.^{[citation needed]}

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,^{[1]} was formulated as a logic program and developed for representing narratives and database updates.^{[2]} Kave Eshghi showed how to use the event calculus for planning,^{[3]} 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^{[4]} 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.^{[5]}

This section does not cite any sources. Please help improve this section by adding citations to reliable sources. Unsourced material may be challenged and removed. (January 2024) (Learn how and when to remove this message)

In the event calculus, fluents are reified. This means that fluents are represented by terms. For example, expresses that the is on the at time . Here is a predicate, while is a term. In general, the atomic formula

- expresses that the holds at the

Events are also reified and represented by terms. For example, expresses that the is moved onto the at time . In general:

- expresses that the happens at the

The relationships between events and the fluents that they initiate and terminate are also represented by atomic formulae:

- expresses that if the happens at the then the becomes true after the .

- expresses that if the happens at the then the ceases to be true after the .

The event calculus was developed in part as an alternative to the situation calculus,^{[6]}^{[7]} 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:

The axiom states that

- a fluent holds at a time
**if** - an event happens at a time
**and** - initiates at
**and** - is before
**and** **it is not the case that**there exists an event and a time such that- happens at
**and** - terminates at
**and** - is before or at the same time as
**and** - is before .

- happens at

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

The core event calculus axiom defines the predicate in terms of the , , , and 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 . 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.

This section does not cite any sources. Please help improve this section by adding citations to reliable sources. Unsourced material may be challenged and removed. (January 2024) (Learn how and when to remove this message)

To apply the event calculus in a particular problem domain, it is necessary to define the and predicates for that domain. For example, in the blocks world domain, an event of moving an object onto a place intitiates the fluent , which expresses that the object is on the place and terminates the fluent , which expresses that the object is on a different place:

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

This section does not cite any sources. Please help improve this section by adding citations to reliable sources. Unsourced material may be challenged and removed. (January 2024) (Learn how and when to remove this message)

To apply the event calculus, given the definitions of the , , , and predicates, it is necessary to define the 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:

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:

```
holdsAt(Fluent, Time2) :-
before(Time1, Time2),
happensAt(Event, Time1),
initiates(Event, Fluent, Time1),
not(clipped(Fluent, Time1, Time2)).
clipped(Fluent, Time1, Time2) :-
terminates(Event, Fluent, Time),
happensAt(Event, Time),
before(Time1, Time),
before(Time, Time2).
initiates(initialise(Fluent), Fluent, Time).
initiates(move(Object, Place), on(Object, Place), Time).
terminates(move(Object, Place), on(Object, Place1), Time).
happensAt(initialise(on(green_block, table)), 0).
happensAt(initialise(on(red_block, green_block)), 0).
happensAt(move(red_block, table), 1).
happensAt(move(green_block, red_block), 3).
```

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

- The core axiom has been rewritten, using an auxiliary predicate
`clipped(Fact, Time1, Time2).`

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 has been removed from the corresponding condition
`before(Time1, Time).`

This builds in a simplifying assumption that events do not simultaneously initiate and terminate the same fluent. As a consequence, the definition of the predicate has been simplified by eliminating the condition that .

Given an appropriate definition^{[note 1]} of the predicate `before(Time1, Time2),`

the Prolog program generates all answers to the query *what holds when?* in temporal order:

```
?- holdsAt(Fluent, Time).
Fluent = on(green_block,table), Time = 1.
Fluent = on(red_block,green_block), Time = 1.
Fluent = on(green_block,table), Time = 2.
Fluent = on(red_block,table), Time = 2.
Fluent = on(green_block,table), Time = 3.
Fluent = on(red_block,table), Time = 3.
Fluent = on(red_block,table), Time = 4.
Fluent = on(green_block,red_block), Time = 4.
Fluent = on(red_block,table), Time = 5.
Fluent = on(green_block,red_block), Time = 5.
```

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:

```
timePoint(1).
timePoint(2).
timePoint(3).
timePoint(4).
timePoint(5).
fluent(on(red_block, green_block)).
fluent(on(green_block, red_block)).
fluent(on(red_block, table)).
fluent(on(green_block, table)).
?- timePoint(T), fluent(F), not(holdsAt(F, T)).
F = on(green_block,red_block), T = 1.
F = on(red_block,table), T = 1.
F = on(red_block,green_block), T = 2.
F = on(green_block,red_block), T = 2.
F = on(red_block,green_block), T = 3.
F = on(green_block,red_block), T = 3.
F = on(red_block,green_block), T = 4.
F = on(green_block,table), T = 4.
F = on(red_block,green_block), T = 5.
F = on(green_block,table), T = 5.
```

In addition to Prolog and its variants, several other tools for reasoning using the event calculus are also available:

Notable extensions of the event calculus include Markov logic networks–based variants^{[11]} probabilistic,^{[12]} epistemic^{[13]} and their combinations.^{[14]}