Third edition of Artificial Intelligence: foundations of computational agents, Cambridge University Press, 2023 is now available (including the full text).

### 14.1.2 Event Calculus

The second representation, **event
calculus**, models how the truth value of relations
changes because of events occurring at certain times. Time can be modeled as either
continuous or discrete.

Events are modeled as occurring at particular times.
Event *E* occurring at time *T* is written as *event(E,T)*.

Events make some relations true and some no longer true:

*initiates(E,R,T)*is true if event*E*makes primitive relation*R*true at time*T*.*terminates(E,R,T)*is true if event*E*makes primitive relation*R*no longer true at time*T*.

Time *T* is a parameter to *initiates* and *terminates* because the effect
of an event can depend on what else is true at the time. For example, the effect
of attempting to unlock a door depends on the position of the robot
and whether it is carrying the appropriate key.

Relations are either true or false at any time. In event calculus, relations are reified, where *holds(R,T)*
means that relation *R* is true at time *T*. This is analogous to having *T*
as the last argument to *R* in situation calculus. The use of the meta-predicate *holds* allows general rules that are
true for all relations.

Derived relations are defined in terms of primitive relations and other derived relations for the same time.

Primitive relation *R* holds at time *T* if an
event occurred before *T* that made *R* true, and there was no
intervening event that made *R* no longer true. This can be
specified as follows:

*holds(R,T) ←*

*event(E,T*

_{0}) ∧*T*

_{0}<T∧*initiates(E,R,T*

_{0}) ∧*∼clipped(R,T*

_{0},T) .*clipped(R,T*

_{0},T) ←*event(E*

_{1},T_{1}) ∧*terminates(E*

_{1},R,T_{1}) ∧*T*

_{0}<T_{1}∧*T*

_{1}<T.The atom *clipped(R,T _{0},T)* means there is an event between times

*T*and

_{0}*T*that makes

*R*no longer true;

*T*is true if time

_{0}<T_{1}*T*is before time

_{0}*T*. Here

_{1}*∼*indicates negation as failure, and so these clauses mean their completion.

Actions are represented in terms of what properties they initiate
and terminate. As in situation calculus, the preconditions of
actions are specified using the *poss* relation.

**Example 14.11:**The

*pickup*action initiates a

*carrying*relation, and it terminates a

*sitting_at*relation as long as the preconditions for

*pickup*are true:

*initiates(pickup(Ag,Obj), carrying(Ag,Obj) ,T) ←*

*poss(pickup(Ag,Obj) ,T) .*

*terminates(pickup(Ag,Obj) ,sitting_at(Obj,Pos) ,T) ←*

*poss(pickup(Ag,Obj) ,T).*

*poss(pickup(Ag,Obj) ,T) ←*

*autonomous(Ag) ∧*

*Ag ≠Obj ∧*

*holds(at(Ag,Pos) ,T) ∧*

*holds(sitting_at(Obj,Pos) ,T) .*

This implies that if a *pickup* is attempted when the preconditions
do not hold, nothing happens. It is also possible to write clauses that
specify what happens under different circumstances, such as when a pickup is attempted for an object that is being held by something else.

Given particular action occurrences, and making the complete knowledge assumption that all intervening events are specified, the top-down proof procedure with negation as failure can be used to prove what is true. For planning, the agent can use abduction.