Chronolog : Linear-Time Logic Programming: First Next
Chronolog : Linear-Time Logic Programming: First Next
ments in time can be combined through the use of ber for time t 0 and no other.
temporal operators, not by explicit references to time.
More recently, a number of logic programming lan- first f(1).
guages based on diverse temporal logics have been pro- first next f(1).
posed: Tempura [12] and Tokio [2] are based on inter- next next f(N) <- next f(X), f(Y), N is X+Y.
val logic; Templog [1] and Chronolog [13] are based on
linear-time temporal logics and Temporal Prolog [9] is Read all clauses as assertions true at all moments in
based on linear and branching time temporal logics. time. The rst two clauses dene the rst two Fi-
In Tempura, programs are systematically trans- bonacci numbers as 1; and the last clause denes the
formed into a sequence of state descriptions over an current Fibonacci number as the sum of the previ-
interval that satises the original program [12]. Tem- ous two. For example, the answer to the given goal
plog [1], Temporal Prolog [9] and Chronolog [13] are <- first next next f(X) is a (substitution) in-
extensions of logic programming in which temporal stance of the goal with X replaced by 2.
logic programs are executed to obtain answers by the In the following, we rst outline the temporal logic
use of resolution-type proof procedures. Tokio has a of Chronolog(Z ). We then discuss several applications
mixed execution mechanism [2]. of the language, including modeling non-terminating
There are also several attempts at developing se- computations and the simulationof sequential circuits.
mantics of temporal logic languages. Baudinet [3] We also propose a modular extension of Chronolog(Z )
showed that Templog's proof procedure is sound and for specifying objects with internal memory.
2 Temporal Logic of Chronolog(Z ) 2.2 Axioms of Temporal Logic
In the temporal logic of Chronolog(Z ), the collec- Let the notation ` A denote the fact that A is a
tion of moments in time is the set Z of integers. The theorem of TL. The notion of deducibility can be char-
temporal logic oers three temporal operators: first, acterized in terms of theoremhood: ? ` A means that
prev and next. Informally, the temporal operators the formula A is deducible from a set ? of formulas in
refer to the initial moment, the previous moment and TL. The following axioms state some of the important
the next moment in time respectively. We choose a properties of the temporal operators. Let 5 stand for
linear-time temporal logic with unbounded past and any of first, prev and next.
future as the underlying logic of Chronolog(Z ), be- (i) Temporal operator cancellation rules:
cause certain time-dependent properties are more nat- E1. 5(first A) $ first A.
ural and easier to express with past operators and the E2. next prev A $ A.
symmetry between past and future operators is best E3. prev next A $ A.
expressed in such a temporal logic. The rst axiom (E1) says that initial truths persist.
The syntax of the temporal logic of Chronolog(Z ) The axioms E2 and E3 capture the fact that prev and
extends that of rst-order logic with three new forma- next are complete inverses.
tion rules: if A is a formula, so are first A, prev A (ii) Temporal operator distribution rules:
and next A. We write next(n) and prev(n) for n D1. 5(A ^ B) $ (5 A) ^ (5 B).
successive applications of next and prev respectively. D2. 5(: A) $ :(5 A).
From here on, we refer to the underlying logic as TL. These axioms state that the temporal operators
commute with ^ and :.
2.1 Temporal Interpretations (iii) Rigidness of variables:
V. 5(8x)(A) $ (8x)(5 A).
The semantics of formulas of TL are provided by This axiom stipulates that the values of individual
temporal interpretations. A temporal interpretation variables range over extensions (data values).
of TL assigns meanings at all moments in time to all (iv) Rules of inference: we have the following tempo-
basic elements of the language such as function and ral operator introduction rules.
predicate symbols, and variables. Interpretations are R1. If ` A, then ` first A.
extended upward to all terms and formulas of TL by a R2. If ` A, then ` prev A.
satisfaction relation j=. The meaning of a formula of R3. If ` A, then ` next A.
TL varies in time. However, we restrict the discussion It is straightforward to show the correctness of the
to those temporal interpretations in which the values axioms and the rules of inference (that is, the sound-
of variables and function symbols are \rigid". The ness of the axiomatic system).
value of a rigid term is an invariant of time.
We assume a standard denition of the satisfaction Lemma 1 [14] All of the axioms and the rules of in-
relation j= in terms of temporal interpretations. In ference are valid with respect to the semantics scheme
the following, the fact that a formula A is true at a of TL.
moment t in time in a temporal interpretation I is
denoted as j= A. The formal semantics of temporal We assume that the rules of inference given above
I;t
operators of TL are given as follows: are extended to consider the notion of deducibility
from a set of formulas. The resolution-type proof pro-
j= first A i j= 0 A.
I;t I;
cedure of Chronolog(Z ) is based on these axioms and
rules of inference [14].
j= prev A i j= ?1 A.
I;t I;t
2.3 Temporal Logic Programs
j= next A i j= +1 A.
In programs of Chronolog(Z ) such as the Fibonacci
I;t I;t
where A is a formula, and t 2 Z . program given earlier, program clauses can contain
If a formula A is true in a temporal interpretation applications of temporal operators to atomic formu-
I at all moments in time, we say that A is true in I las. We call atomic formulas with a number (possibly
or I is a model of A and denote this fact as j= A.
I 0) of applications of temporal operators as temporal
We regard :, ^ and 8 as primitives and assume the atoms. All variables in program clauses are assumed
usual denitions of _, !, $ and 9 in terms of these to be universally quantied. For convenience, we use
primitives. upper-case letters for variables and lower-case letters
for function and predicate symbols. A temporal logic hamming(X) <- residue([X|L]).
program of Chronolog(Z ) is the conjunction of a set first residue([1]).
of program clauses regarded as assertions true at all residue(L1) <- prev residue([X|L]),
moments in time. Programs of Chronolog(Z ) are ex- multiply(2,X,X2),multiply(3,X,X3),
ecuted using a resolution-type proof procedure called multiply(5,X,X5),merge([X2,X3,X5],L,L1).
TiSLD-resolution [14]. merge(L1,L2,L3) <- ...
We need the notion of a canonical formula: Given multiply(X,Y,Z) <- ...
a formula A, by systematic applications of R1, R2 and We assume a standard denition for merge in which
R3, the following initial truths can be formed: given two ordered lists are merged to produce a third
first A (by R1),
first prev A (by R2, R1),
ordered list with duplicates removed. The residue
first next A (by R3, R1),
predicate holds all those Hamming numbers produced
but not yet consumed by the hamming predicate. In
first prev prev A (by R2, R2, R1),
the program, the hamming predicate is specied for the
first next next A (by R3, R3, R1) non-negative part of the linear-time.
and so on. Initial truths obtained from a formula A in According to the program, the residue predicate
the above fashion are called canonical instances of A. is true of the residue list [1] at time 0, which means
As the following lemma says, the value of a given that, by the rst clause, 1 is the rst Hamming num-
formula in a temporal interpretation can be expressed ber. At time 1, by the third clause, 1 is removed from
in terms of the values of its canonical instances. the residue list and then multiples of 1 are merged with
Lemma 2 [14] Let A be a formula and I a temporal the rest of the residue list (the empty list[]). Thus the
residue predicate represents the residue list [2,3,5]
interpretation of TL. j= A if and only if j= A for
I I t
at time 1, meaning that the second Hamming number
all canonical instances A of A.t
is 2. At time 2, by the third clause, 2 is removed from
TiSLD-resolution is applied to a set of canonical the residue list and multiples of 2 are merged with the
program and goal clauses. We assume that, in canon- rest of the residue list (the list [3,5]). The residue
ical instances of program clauses, all super
uous ap- predicate represents the residue list [3,4,5,6,10] at
plications of temporal operators are eliminated by ax- time 2, meaning that the third Hamming number is 3.
ioms E1-E3. For a given temporal logic program, The computation proceeds along these lines.
canonical instances of program clauses are obtained The open-ended goal clause <- hamming(N) trig-
by rules R1-R3 and axioms D1 and D2. When the gers a non-terminating computation of Hamming
canonicality restriction is lifted for goal clauses, they numbers. The goal is interpreted as an innite se-
can be open-ended. Open-ended goal clauses are used ries of canonical sub-goals into the future of the form
to initiate non-terminating computations (see below). <- first hamming(N), <- first next hamming(N),
Note that a thorough exposition to TiSLD-resolution <- first next(2) hamming(N) and so forth. The
can be found in [14]. answers to canonical sub-goals obtained by TiSLD-
resolution in fact constitute the answers to the orig-
inal goal [14]. The sequence of answer substitutions
3 Applications for N represents the sequence of Hamming numbers.
An implementation of Chronolog(Z ) produces an-
3.1 Non-terminating Computations swers to canonical sub-goals as long as time and re-
In temporal logic programming, non-terminating sources permit. The starting point and direction of
computations can be modeled by time-varying predi- the computation may be determined by users or de-
cates. Consider Hamming numbers which are multi- tected automatically by the implementation. The
hamming predicate depends on the residue predicate;
ples of 2, 3 and 5 of the form the residue predicate is dened by an initial clause
2 3 5 for some i; j and k.
i j k and a program clause with recursive past dependen-
cies. Therefore a non-terminating computation in the
We write a Chronolog(Z ) program to produce the se- negative direction cannot produce any results.
quence of Hamming numbers in increasing order with- 3.2 Circuit Simulation
out any repetitions. In the program, the hamming
predicate is true of the t + 1 Hamming number at
th
Clocksin [5] outlined a logic programming method
time t 0 and no other. for specifying and reasoning about sequential circuits.
first counter(0,0,0).
Q3 Q2 Q1 next counter(Q1,Q2,Q3) <-
clock(Ck), counter(I1,I2,I3),
J Q J Q J Q jk(1,1,Ck,I3,Q3), and(Ck,I3,C3),
Ck Ck Ck
q q
jk(1,1,C3,I2,Q2), and(Ck,I3,T),
K
K and(T,I2,C2), jk(1,1,C2,I1,Q1).