1 Introduction

The Event Calculus (EC) [6] is a well-known approach to reasoning about the effects of a narrative of action occurrences (events) along a time line. This paper briefly summarises [3], which describes PEC, an adaptation of EC able to reason with probabilistic causal knowledge. There are numerous applications for this kind of probabilistic reasoning, e.g. in modelling medical, environmental, legal and commonsense domains, and in complex activity recognition and security monitoring. Full technical details of PEC are in [3]. Its main characteristics are: (i) it supports EC-style narrative reasoning, (ii) it uses a tailored action language syntax and semantics, (iii) it uses a possible worlds semantics to naturally allow for epistemic extensions, (iv) for a wide subset of domains it has a sound and complete ASP implementation, and (v) its generality allows in principle for the use of other models of uncertainty, e.g. truth-functional belief or Dempster-Schafer theory. Although other formalisms exist for probabilistic reasoning about actions (see e.g. [1, 2, 5, 11, 12]), PEC is, to our knowledge, the only framework to combine together these features. As shown in [3] it can be used to model scenarios such as:

Scenario 1

(Coin Toss). A coin initially (instant 0) shows Heads. A robot can attempt to toss the coin, but there is a small chance that it will fail to pick it up, leaving the coin unchanged. The robot attempts to toss the coin (instant 1).

Scenario 2

(Antibiotic). A patient has a rash often associated with a bacterial infection, and can take an antibiotic known to be reasonably effective. Treatment is not always successful, and if not may still clear the rash. Failed treatment leaves the bacteria resistant. The patient is treated twice (instants 1 and 3).

2 Overview of PEC’s Syntax and Semantics

A PEC domain language consists of a a finite non-empty set \(\mathcal {F}\) of fluents, a finite set \(\mathcal {A}\) of actions, a finite non-empty set \(\mathcal {V}\) of values such that \(\{ \top , \bot \} \subseteq \mathcal {V}\), a function \({\textit{vals}}\!:\!\mathcal {F}\cup \mathcal {A} \rightarrow 2^{\mathcal {V}} \setminus \emptyset \), and a non-empty set \(\mathcal {I}\) of instants with minimum element \(\bar{0}\) w.r.t. total ordering \(\le \). For \(A\in \mathcal {A}\) we impose \({\textit{vals}}(A)=\{ \top , \bot \}\). Our approach is to model a given domain with action-language-like propositions that specify (probabilistic) causal and narrative information. For example, Scenario 1 is modelled using the following domain description \( \mathcal {D}_C \):

figure a

More generally v-propositions, such as (C1), have the form     

$$\begin{aligned} F \mathbf{\,takes\text {-}values\, }\{ V_1, \dots , V_m \} \end{aligned}$$
(1)

for \(F\in \mathcal {F}\), \(m\ge 1\), \(V_i\in \mathcal {V}\) for all \(1\le i \le m\), and \(\{V_1, \dots , V_m\}=vals(F)\). c-propositions such as (C3) modeling causal relationships are of the form

$$\begin{aligned} \theta \mathbf{\,causes\text {-}one\text {-}of\, }\{ O_1, O_2, \dots , O_m \} \end{aligned}$$
(2)

where formula \(\theta \) captures preconditions, and \(O_1, \dots , O_m\) are alternative outcomes – partial assignments of fluent values paired with probabilities that sum to 1. Initial conditions are declared via i-propositions of the form

$$\begin{aligned} \mathbf{initially\text {-}one\text {-}of }\{ O_1, O_2, \dots , O_m \} \end{aligned}$$
(3)

and action occurrences are identified through p-propositions of the form

$$\begin{aligned} A \mathbf{\,performed\text {-}at\, }I \mathbf{\,with\text {-}prob\, }P^+ \end{aligned}$$
(4)

for \(A\in \mathcal {A}\), \(I\in \mathcal {I}\) and \(P^+ \in (0,1]\). When \(P^+ \! = \!1\) it is omitted as in (C4).

A domain description is a finite set \(\mathcal{D}\) of v-, c-, p- and i-propositions such that: (i) for any two distinct c-propositions in \(\mathcal {D}\) with bodies \(\theta \) and \(\theta '\), there is no state compatibleFootnote 1 with both \(\theta \) and \(\theta '\), (ii) \(\mathcal {D}\) contains exactly one i-proposition, and (iii) \( \mathcal {D} \) contains exactly one v-proposition for each \(F\in \mathcal {F}\).

PEC’s semantics describes how domain descriptions entail h-propositions of the form     

$$\begin{aligned} \varphi \mathbf{\,holds\text {-}with\text {-}prob\, }P \end{aligned}$$
(5)

where \(P \in [0,1]\), and \(\varphi \) is an i-formula (time-stamped formula). For example, \(\mathcal {D}_C\) entails ‘\([ { {\textit{Coin}} \! = \! {\textit{Heads}}} ]@2 \mathbf{\,holds\text {-}with\text {-}prob\, }0.51 \)’.

PEC has a possible-worlds semantics. A world is an evolution of the environment, i.e. a function \(W:\mathcal {I}\rightarrow \mathcal {S}\), where \(\mathcal {S}\) is the set of all states (complete assignments of values to fluents and actions). \(\mathcal {W}\) denotes the set of all worlds. Worlds can be pictured as timelines with information about the current state attached at each instant. E.g. two worlds for Scenario 1 can be visualised as:

figure b

Intuitively, \(W_1\) is consistent with domain description \(\mathcal {D}_{C}\) as it represents a coherent history of what could have happened in Scenario 1, whereas \(W_2\) does not (e.g., changes occur when no action is performed, an infinite number of actions are performed, etc...). For this reason, world \(W_1\) said to be well-behaved w.r.t. \(\mathcal {D}_C\), whereas \(W_2\) is not. The semantics captures this notion with the concept of a trace – a chain of effects matching both a unique world W and the domain description \(\mathcal {D}\), through consistency with propositions in \(\mathcal {D}\) and a persistence condition. In other words, a world W represents an evolution of state, whereas a trace of W represents a legal causal history w.r.t. W and a corresponding domain description. For example, two traces for \(W_1\) w.r.t. \(\mathcal {D}_C\) are:

figure c

where the special symbol is used to deal with the initial condition. The evaluation of a trace \({\textit{tr}}\), written \( \epsilon ({\textit{tr}}) \), is the product of all real values appearing in it. In our example, \(\epsilon (t_1) = 0.49\) and \(\epsilon (t_2) = 0.02\). \(W_2\) has no trace w.r.t. \(\mathcal {D}_C\) and so is not well-behaved w.r.t. \(\mathcal {D}_C\).

PEC’s semantics defines a probability distribution over worlds. To show this, we first define a [0,1]-interpretation as a function from \(\mathcal {W}\) to [0, 1], and, given a domain description \( \mathcal {D} \), single out a unique [0,1]-interpretation \(M_\mathcal {D}: \mathcal {W} \mapsto [0,1]\) called the model of \( \mathcal {D} \). For world W, well-behaved w.r.t. \( \mathcal {D} \), \(M_\mathcal {D}(W)\) is the sum of values \(\epsilon ({\textit{tr}})\) for all corresponding traces \({\textit{tr}}\) of W. If W is not well-behaved, then \(M_\mathcal {D} (W) = 0\). \(M_{\mathcal {D}}\) is extended to a function \(M_{\mathcal {D}}^{*}\) over i-formulas as follows:

(6)

where indicates that \(\varphi \) is satisfied in W (in the obvious sense, see [3]). We say that ‘\(\varphi \mathbf{\,holds\text {-}with\text {-}prob\, }P\)is entailed by \(\mathcal {D}\) iff \(M_\mathcal {D}^{*} ( \varphi ) = P\).

In [3], we prove that \(M^*\) is a probability function (see assumptions (P1) and (P2) from [9, Chap. 1]). Note that \(M^*\) could be alternatively defined to satisfy different axioms (see e.g. (DS1–3) from [9, Chap. 1] for Dempster-Schafer belief functions or [9, Chap.  5] for truth-functional belief functions).

3 ASP Implementation

We have implemented PEC for the class of domains in which the bodies \(\theta \) of c-propositions are conjunctive formulas. The implementation and example domain descriptions can be found at https://github.com/dasaro/pec. For this, a translator turns a PEC domain description \( \mathcal {D} \) into an ASP program using standard lexical analyser Flex and parser generator Bison. A grounder and solver, Clingo [4], then processes the translator’s output together with the domain-independent part of the semantics and a query (both in ASP). This returns a collection of answer sets, each representing a trace and the corresponding well-behaved world. A standard text processing tool, AWK, then evaluates \(\epsilon ({\textit{tr}})\) for each answer set trace \({\textit{tr}}\) and sums these to give a probability for the query using Eq. (6). The following diagram illustrates this procedure:

figure d

A general translation procedure from this class of PEC domain descriptions to ASP programs is given in [3]. To illustrate, \(\mathcal {D}_C\) is translated to:

figure e

Correctness of the translation and implementation are guaranteed by the following proposition, more details of which (including a proof) are given in [3].

Proposition 1

(Soundness and Completeness). Z is a stable model of the translated domain description \(\mathcal {D}\) together with the domain-independent part of PEC iff Z represents a well-behaved world W and one of its traces w.r.t. \(\mathcal {D}\).

Intuitively, this proposition states that if we interpret the elements of a stable model Z of the translated domain description and the domain-independent part of PEC as their natural semantic counterpart (e.g., \({\textit{holds}}( ((F,V),I) )\) is interpreted as \({ F \! = \! V} \in W(I)\)), then this interpretation is a trace together with its corresponding well-behaved world W w.r.t. \(\mathcal {D}\). The trace and world are then said to be represented by Z. Conversely, for every well-behaved world W w.r.t. \(\mathcal {D}\) and one of its traces \({\textit{tr}}\) there exists a stable model Z of the program such that Z represents W and \({\textit{tr}}\). It is in this sense that our implementation is sound and complete. Our proof in [3] relies on the Splitting Theorem [7].

4 Future Work

PEC semantics is defined in terms of (possible) worlds with a view to adding epistemic features in the future (see e.g. [10]). Our initial investigations in this respect focus on representing imperfect sensing actions and actions conditioned on knowledge acquired in previous instants (similar to the approach in the EFEC extension of FEC [8]). We envisage including s-propositions such as

$$ {\textit{See}}\mathbf{\,senses\, }{\textit{Coin}}\mathbf{\,with\text {-}accuracies\, }\begin{pmatrix} 0.9\; &{} 0.1\\ 0.3\; &{} 0.7 \end{pmatrix} $$

which represents that our coin-tossing robot can imperfectly sense the current face showing on the coin, and conditional p-propositions such as

$$ {\textit{Toss}}\mathbf{\,performed\text {-}at\, }2 \mathbf{\,if\text {-}believes\, }({ {\textit{Coin}} \! = \! {\textit{Tails}}}, (0.65,1]) $$

which represents that the robot will toss again if it believes with a greater than 65% probability that the first toss resulted in \({\textit{Tails}}\). Preliminary results indicate that our possible worlds semantics can be readily extended to cover these notions.

There are several other ways in which the present work can be continued. For instance, the problem of elaboration tolerance, which plays an important role in classical reasoning about actions, needs to be reviewed and solved in our setting. A related point is that of underspecification, i.e. what an agent can reasonably infer from a domain in which the initial conditions and the effects of actions are not entirely specified (even probabilistically). Finally, a crucial point is that of computational efficiency. Indeed, the intractability of several computational problems arising in this setting (such as temporal projection) suggests that techniques (e.g. Monte Carlo Markov Chain) are needed to efficiently approximate the correct answer to a given query with an appropriate degree of confidence.

Related Work: For a discussion of related work see [3].