Computing with time and events
1. LOGIC PROGRAMMING WITH CONSTRAINTS 59 the empty clause To make this precise, we have to spell out the notion of
derivation step and derivation tree. Again, the reader not familiar with logic programming, in particular such notions as resolution and completion, is advised to consult the appendix before proceeding.
One difference between standard logic programming and constraint logic programming is its treatment of substitution. In the former, the unification algorithm applied to two atoms determines which terms have to be sub- stituted for the variables occurring in the atoms, in order for the atoms to become identical. In constraint logic programming the treatment is differ- ent: when the unification algorithm has determined that a term tshould be substituted for a given variablex, one adds aconstraint t = xbut no sub- stitution is effected. IfA, B are atoms, we let {A = B} denote the set of equations between terms which unifyAandBifAandBare unifiable; oth- erwise{A =B} is set to⊥. The constraints are then simply accumulated in the course of the derivation. There are some clear notational advantages to this approach, which avoids nested, possibly unreadable terms. The main advantage is conceptual, however, since it allows a more symmetric treat- ment of positive and negative information.
A consequence of this approach is that the constraint languageLhas to be extended, since constraints in the wider sense may now also involve ob- jects, (parametrized) events and (parametrized) fluents. Henceforth we as- sume that constants and function symbols denoting objects, (parametrized) events and (parametrized) fluents also belong to the constraint language, and that the theory describing them is Clark’s Equality TheoryCET, also known as the ‘uniqueness of names assumption’. This is the following set of statements for function symbolsf, gand termstof the language:
(1) f(y1, . . . , yn) = f(z1, . . . , zn) → y1 =z1∧. . .∧yn =zn
(2) f(y1, . . . , yn).=g(z1, . . . , zm), wheref, gare different
(3) ifyoccurs int,y.=t.
In the context of the event calculus (referring to the example of crossing the street), these statements say for example thatdistance(x)=distance(y)
→x=y, and thatstartis different fromreach.
To summarize: the constraint structureAconsists of the union of
{0,1,+,·, <}and the set of objects, events and fluents, and it is described by the union of the theories L and CET. All terms occurring in the pro- grammed predicates must be interpreted in the given constraint structure.
The main derivation rule is resolution, which can be formalized as fol- lows. Suppose?c, B1, . . . , Bi, . . . , Bmis a goal, andD1, . . . , Dk, c! → Aa
program clause. A new goal
?c!!, B1, . . . , D1, . . . , Dk, . . . , Bm
can be derived from these two clauses if the constraintc!!, defined asc!! = (c∧{Bi = A}∧c!) is satisfiable inA. That is, if A can be unified with Bi, one can replaceBibyD1, . . . , Dkif in addition the given constraintcis
60 5. COMPUTING WITH TIME AND EVENTS
c!. Given this inference rule, the concepts of derivation tree and branch in a
derivation tree have straightforward definitions8.
DEFINITION10. A branch in a derivation tree issuccessfulif it is finite and ends in a query of the form?c, wherecis a satisfiable constraint; note that the query is not allowed to contain an atom. A branch in a derivation tree isfinitely failed if it ends in a query?c, B1. . . Bm such that eithercis not satisfiable, or no program clause is applicable to theBi. Otherwise the branch is calledinfinite.
Intuitively, this definition applied to the situation of interest means the following. Suppose we start from a query ?HoldsAt(f, t) and find a suc- cessful branch ending in ?c. This should mean that for all t, if c(t) is true, then so is HoldsAt(f, t). Likewise, if a branch finitely fails and ends in ?c, B1. . . Bm, we should have, for all t satisfying c(t), ¬HoldsAt(f, t). These intuitions will be bolstered up by theorems to be presented later.
For our purposes, definite constraint logic programs are not yet expres- sive enough, due to the occurrence of¬in the bodies of the axioms of the event calculus. Once we allow negation in the body of a clause, we may as well allow (classical equivalents of) first order formulas of arbitrary com- plexity. That is, we can use all formulas containing only ∃, ¬ and ∧; of course, each formula is classically equivalent to such a formula, but the representation chosen facilitates a smooth inference procedure. More pre- cisely
DEFINITION11. Acomplex subgoalis defined recursively to be
(1) an atom inK, or
(2) ¬∃x(B1∧. . .∧Bm∧c), wherecis a constraint and eachBi is a complex subgoal.
DEFINITION12. Acomplex bodyis a conjunction of complex subgoals.
Anormal programis a formulaψ →AofCLP(T)such thatψis a complex body andAis an atom.
The form of negation most congenial to constraint logic programming is constructivenegation ([117]). In the customary negation as failure par- adigm, negative queries differ from positive queries: the latter yield com- puted answer substitutions, the former only the answers ‘true’ or ‘false’. Constructive negation tries to make the situation more symmetrical by also providing computed answer substitutions for negative queries. Applied to constraint logic programming, this means that both positive and nega- tive queries can start successful computations ending in constraints. The full operational definition of constructive negation is somewhat involved
8As in the case of standard logic programming, one also needs the concept of ase-
lection rule, which determines which atom should be chosen at a particular stage in a derivation. The interested reader may consult [117]; we need not dwell on this topic here.
1. LOGIC PROGRAMMING WITH CONSTRAINTS 61