Logic Colloquium ’86 (eds Drake and1
Truss), c Elsevier, North-Holland
1988, 83–93
Cumulative Logic Programs and Modeling
ABSTRACT The formation process of pure logic programs over a first-order language is
iterated to give rise to cumulative logic programs. Such programs turn out to be objects
in a combinatory model and are therefore amenable to algebraic manipulation including
equation solving. It is pointed out how this fact can be employed in a discipline of modeling
for cooperative processes. Other results concern the representability of equational classes,
universal classes and algorithmic classes as solution sets of a set of combinatory equations.
1
Combinatory Models
Combinatory algebras, although going back only half a century, belong among the fundamental structures of mathematics just as much as groups and fields. Their study
has perhaps been hampered somewhat by the inherent self-referentialness of their
most successful constructs and by the fact that there can be no nontrivial computable
combinatory algebra. On the other hand, these structures are really ubiquitous since
they arise whenever a mathematical structure is furnished with a notion of internal
computability. While this fact usually remains hidden - e.g. in computable algebra
through a regime of arithmetization, i.e. coding via Göedel numbers - it is becoming
increasingly clear that the “true” computational nature of construction theory over a
given algebraic or relational structure resides in a set of additional objects, “rules of
construction” or “programs”, which by themselves form a really quite transparent algebraic structure: just our combinatory algebras. True, this was perhaps not foremost
in the minds of the promulgators of combinatory logic and algebra, Schönfinkel, Curry
and Church, and perhaps this point of view needed the advent of computer science
as well as the construction of mathematically transparent, i.e. set-theoretic, models
(Plotkin [10], Scott [11], Engeler [4]). The theme of objectification or reification of
construction rules is pushed a step further in the present chapter when we show that,
and how, even the mathematical structures on which we compute can become objects
in a combinatory algebra. And again, the conceptual link to computer science should
not be far from our minds: data types are, in most higher programming languages,
themselves objects of constructions, classical such as product types and current such
as function types and recursive types, [9].
Definition 1 An algebraic structure C =< C, · > with one binary operation (“application”) is combinatory complete, if for every term t(x1 ., , , .xn ), built up from
variables x1 , . . . , xn using the operation of application alone, there exists an element
T in C such that for all elements a1 , . . . , an in C we have the identity
2
t(a1 , . . . , an ) = (. . . (T · a1 ) · a2 ) · . . . · an
Combinatory complete algebraic structures with more than one element are called
combinatory algebras, [1].
Historical remark: Schönfinkel and Bernays reduced the above infinite set of existential
axioms for combinatory algebras to just two. It is tempting (and historically not
unfair) to compare the scheme of combinatory completeness to the full comprehension
axiom of set theory and the reduction to finitely many cases to the von NeumannBernays axiomatization, in particular K and S, to Gödel’s operations Fi that build
up the constructible universe. However, Gödel’s construction (over the ordinals) gives
only a relative consistency proof, while the term model of combinatory logic (built up
by primitive recursion over the natural numbers) is proved consistent, i.e. nontrivial,
via the Church-Rosser execution of Hilbert’s program for combinatory logic.
In addition to the laws
Sxyz = xy(xz)
Kxy = x
which thus characterize combinatory algebras, we may have another element L in the
algebra satisfying
Lxy = xy
∀z(xy = yz) ⊃ Lx = Ly
Combinatory algebras with such L are called combinatory models, [1]. As we shall
see, the set of cumulative logic programs forms an example of a combinatory model.
2
Logic Programs: Pure and Cumulative
Let A the set of atomic formulas of some first-order language. Ordinary pure logic
programs are (finite) sets of Horn formulas
a1 ∧ a2 ∧ . . . ∧ ak ⊃ b,
usually written
k≥0,
ai , b ∈ A
3
b : −a1 , . . . , an ; or b ← a1 , . . . , an
as in PROLOG. We shall here employ a variant notation, viz.
{a1 , . . . , ak } → b
and use the formal construction → iteratively. Thus,
G0 (A) = A
Gi+1 (A) = Gi (A) ∪ α → a : α finite, α⊆Gi (A), a ∈ Gi (A)
G(A) = ∪i Gi (A)
Note that within this cumulative hierarchy pure logic programs are simply subsets of
G1 (A). Cumulative logic programs then, are subsets of G(A).
Let DA be the set of subsets of G(A). We make DA into an algebraic structure
DA =< DA , · >
by defining the binary operation · of application on DA by
M · N = a : ∃α⊆N. α → a ∈ M
for arbitrary M, N ∈ DA . It can be easily shown [4] that DA is a combinatory algebra;
indeed, with
L = {β → u} → (α → u) : β⊆α⊆G(A), u ∈ G(A), α, β finite
it is a combinatory model.
The application operation can be used to explain the execution of pure logic programs
as a solution process for a corresponding fixpoint equation. To take an example, let
us consider the following logic program for the factorial function:
The first-order language is that of number theory, variables x, y, . . . ranging over
natural numbers, terms built up from variables by the operation successor S. The
language is augmented by a binary predicate fac(u, v) intended to mean that v is
the factorial of u, a ternary predicate mult(u, v, w) for “w = u · v”, and similarly for
addition. The program reads
4
fac(0, 1) : −
fac(S(x), y) : −f ac(x, z), mult(S(x), z, y)
mult(x, 0, 0) : −
mult(x, S(y), z) : −mult(x, y, u), add(x, u, z)
add(x, 0, x) : −
add(x, S(y), S(z)) : −add(x, y, z)
By our translation, this logic program becomes an element of DA , but not a finite
one: care has to be taken that
fac(x, z), mult(S(x), z, y) → fac(S((x), y)
is present not only for the variables x,y,z but for all terms of the language. Let P ∈ DA
be formed in this way, i.e.
P := ∅ → fac(0, 1)
S
S
{fac(t1 , t3 ), mult(S(t1 ), t3 , t2 )} → fac(S(t1 , t2 ) : t1 , t2 , t3 ∈ Terms
...
Then P ·∅, in the sense of the application operation of DA , yields those atomic formulas
which one step of unification/resolution can obtain. P (2) · ∅ = P · (P · ∅) yields answers
to those queries for which two steps suffice, etc. Indeed, the iteration
∪n P (n) · ∅
yields exactly all answers to possible queries. Now note the form of this expression:
it represents the least fixpoint of the equation
P ·X =X
in DA . Thus, solving this fixpoint equation amounts to obtaining the results of all
possible queries to the given logic program (this is the so-called fixed-point or denotational semantics of Prolog, see [2] for an independent formulation). What we have
5
shown, then, is that logic programming may be considered a discipline of equationsolving, very special equations to be sure, in the algebra DA . But we observe at once
that this discipline, which is a form of backward search familiar from problem-solving
à la Polya and from AI methodologies, is - with some modifications - applicable to a
wide class of fixed point equations
fi (X1 , . . . , Xn ) = Xi ,
i = 1, . . . , n
in the whole of DA . Details of this are given in the next section.
3
Continuity, Equation Solving and Process Modeling
In a separate paper [6] we put forward a method for the modeling of cooperative processes based on a representation of both processes and their interactions by elements
of an appropriate domain DA of cumulative logic programs. In outline, this representation proceeds as follows: Imagine two processes X and Y interacting in such a way
that either depends on the other in a well-determined way. If we describe the known
facts about X by a set of formulas, again denoted by X, and do the same with Y
then the interaction between the processes takes on the form
X = f (X, Y )
Y = g(X, Y )
where f and g are set-functions transforming (pairs of) sets of formulas into sets of
formulas. The most immediate case is to consider X and Y as subsets of A = G0 (A),
but more generally we should think of them as subsets of G(A). More importantly, it
is reasonable to expect that the functions f and g enjoy a certain continuity property:
f (X, Y ) =
S
g(X, Y ) =
S
f (α, β) : α⊆X, β⊆Y, α, β finite
g(α, β) : α⊆X, β⊆Y, α, β finite
This expectation is based on the constraints posed on modeling processes quite generally: we never have but finite amounts of information about the properties of the
processes which we model, accumulating this information is what leads to our “knowledge” of X. In any case, postulating f and g to be continuous in this sense (a notion
of continuity which can be linked to a well-known topology on G(A)), we have in DA
an important and useful fact:
6
f is continuous iff there is an F ∈ DA such that
F · u · v = f (u, v) identically
The proof, well known in combinatory algebra and in denotational semantics, is given
below for completeness in the present context: If f is continuous, define
F := α → (β → x) : x ∈ f (α; β), α, β⊆G(A), finite
2
and verify the identity. If, conversely, f : DA
→ DA is given by
f (X, Y ) = (F · X) · Y,
for some F ∈ DA
continuity follows by verifying
F ·X ·Y =
S
F · α · β : α⊆X, β⊆Y, α, β finite
which is immediate from the definition of the application operation.
Thus, the interaction equations from above are rendered
X = F · X · Y,
Y = G·X ·Y
for appropriate F, G ∈ DA . Indeed, as we have pointed out elsewhere, the sets F
and G are often quite easy to generate directly, and having obtained them, the least
S
S
solution of the pair of fixpoint equations is the pair X = i Xi , Y = i Yi, where
X0 = Y0 = ∅ and Xi+1 = F · Xi · Yi , Yi+1 = G · Xi · Yi .
Thus, whenever a set of cooperative processes lends itself to description of the form
Xi = fi (X1 , . . . , Xn ), i = 1, . . . , n, for continuous fi , we have here a full theoretical
solution, one that generalizes the fixpoint semantics of its special subcase, logic programs. A practical solution, consisting in a discipline of evaluating such systems of
fixpoint equations in analogy to interpreters of logic programs will be presented in a
forthcoming paper.
Obviously, not all interaction equations for all types of cooperating processes are in
the form of fixpoint equations. They arise quite often from some law such as physical
laws (e.g. conservation laws or minimalization principles) which do not always yield
autonomous differential equations. The typical case is rather of the form
7
fi (X1 , . . . , Xn ) = gi (X1 , . . . , Xn ), i = 1, . . . , n.
What does DA , as an algebraic structure, have to offer towards manipulating and
perhaps solving such equations? Here is one result:
Lemma 2 Let Γ be a finite set of equations in DA of the form
∀y1 · · · yn · fi (A1 , · · · , Ak , X1 , · · · , Xm , y1 , · · · , yn )
= gi (A1 , · · · , Ak , X1 , · · · , Xm , y1 , · · · , yn ),
fi , gi continuous i = 1, . . . , p
where Aj are constants of DA , X1 , · · · , Xm are the unknowns and y1 , · · · , yn are variables. Then we can effectively construct new constants A and B from the fi , gi, Ai
such that solving Γ for X1 , · · · , Xm is effectively equivalent to solving the equation
A · Z = B · Z for Z.
But we have to beware of the enormous generality of the problem formulated here as
that of solving one deceptively simple type of equation in an algebraic structure with
deceptively simple fundamental laws. Very little progress has been reported in the
general case ([5], [8], [9]).
4
Combinatory Representation of Model Classes
We now come to the claim that computations or “constructions” on algebraic or relational structures are most transparently thought of as additional elements of suitably
expanded structure in which they obey rather simple algebraic laws. To this claim is
added the further insight that various model classes, thus expanded, are describable
as solutions of combinatory equations similar to the ones encountered in the previous section. The research program expressed in the above has been carried out for
algebraic structures and equational classes in [7]; we report here on these results and
expand them to relational structures, universal classes, and algorithmic classes.
To fix ideas, let
H0 =< H0 , R, f, c >
be a relational structure with universe H0 , binary relation R, binary operation f and
distinguished element c. Consider a combinatory model
8
DA =< DA , · >
where for the present we disregard the particular structure of A and only ask that A
is an infinite superset of H0 . To realize H0 within DA we make use, as in [7], of a
suitable element h ∈ DA , which acts by left-multiplication as a retraction
h · (h · x) = h · x,
∀x ∈ DA .
and whose retract H = h · x : x ∈ DA = x ∈ DA : h · x = x consists of
H = G(A), ∅ ∪ {a} : a ∈ H0 ⊆A .
This set serves as the universe of the representation of H0 in DA . Actually, what is
represented is not H0 but its “completion”
H0 =< H 0 , R, f , c >
defined as follows:
H 0 = H0 , ∪{⊥, ⊤},
R(x, y) =
f(x, y) =
⊥, ⊤ 6 ∈H0 , ⊥6= ⊤,
c = c,
true
false
⊥
⊤
f (x, y)
⊥
⊤
⊥, ⊤ ∈ A.
if x, y ∈ H0 and R(x, y) = true
if x, y ∈ H0 and R(x, y) = false
if x =⊥ or y =⊥
otherwise
if x, y ∈ H0
if x =⊥ or y =⊥
otherwise
(∈ H0 ⊆H 0 ).
The binary operation f of H0 is realized by another element of DA , which we denote
again by f , and which satisfies
h · (f · (h · x) · (h · y)) = f · (h · x) · (h · y), ∀x, y ∈ DA .
9
Such f is easily constructed from the multiplication table of f :
f :=
∪
∪
{a} → ({b} → f (a, b)) : a, b ∈ H0
{a} → ({b} → a) : a, b ∈ A, a or b 6 ∈H0
α → (β → u) : u ∈ G(A), ∅ =
6 α 6= {a} ∀a ∈ A or ∅ =
6 β 6= {b} ∀b ∈ A
The realization of c ∈ H0 in DA is simply {c} which we denote, by abuse of notation
again, as c. So far we have simply restated the approach of [7]. What is added is the
treatment of relations. For this we shall use two particular elements of DA , namely
the combinators K and KI which will play the role of truth and falsity:
r · {a} · {b} =
(
K if R(a, b) is true and a, b ∈ H0
KI if R(a, b) is false and a, b ∈ H0
K satisfies the identity Kxy = x, and KI satisfies (KI)xy = y in DA ; thus the relation
R is actually realized as a test r. Explicitly, r is given by
r :=
∪
∪
{a} → ({b} → u) : a, b ∈ H0 , R(a, b) true , u ∈ K
{a} → ({b} → v) : a, b ∈ H0 , R(a, b) false v ∈ KI
α → (β → u) : u ∈ G(A), ∅ =
6 α 6= {a}, a ∈ A or ∅ =
6 β 6= {b}, b ∈ A
In this way, the relational structure H0 gives rise to four elements h, r, f, c of DA which
in turn determine a relational structure
DA [h; r, f, c]
where the Boolean values true, false, ⊥, ⊤ of R in H0 are realized by the values
K, KI, ∅ and G(A) in DA respectively. It is easy to show that
DA [h; r, f, c] ∼
= H0 .
We now recall from [3] the notion of an algorithmic class of structures. For any
similarity type of relational structure H0 =< H, R, f, c > consider a programming
language which embodies
10
assignments
tests
xi := xj ,
xi := c, xi := f (xj , xk )
if R(xi , xj ) then ...
else ...
corresponding to the operations and relations of the structures. If π(x1 , . . . xn ) is a
program in this language, we interpret
H0 |= π(x1 , . . . xn )
to mean that π halts for whatever initial values from H0 are given to π at the start
of its execution. The following program is a typical example:
z := x;
if x≤0 or y≤0 then halt else
while z < y do z : z + x od.
This program halts for all x, y from an ordered abelian group iff this group is archimedean;
the archimedean property is an “algorithmic property”.
We call a class A of similar relational structures an algorithmic class if there is a set
Π of programs such that
H0 ∈ A iff H0 |= π for all π ∈ Π
Even the most rudimentary control structures of a programming language suffice to
show that every universal class (in the sense of model theory) is an algorithmic class;
the above example shows that the converse is not true.
Now, if H0 , or more precisely, H0 , is embedded in DA we can make use of the combinators of DA such as the composition operator B and the fix-point operator Y to
compose operations f and tests r into elements of DA which correspond to (recursive)
programs on H0 : For each program π(x1 , . . . , xn ) there is an element P ∈ DA such
that for H0 ∼
= DA [h; r, f, c] we have:
H0 |= π(x1 , . . . , xn ) iff P · h · r · f · c · x1 · · · · · xn = K identically inH0
11
P is obtained by a quite straightforward construction in combinatory algebra [1].
These equations, then, are the proposed translations of the proper axioms for the
class A; they correspond to the translation of equations Eq in [7]. The remainder of
the translation can be lifted from that paper and we have:
Theorem For every set Π of programs and every similarity type of relational structures
H0 =< H0 , R, f, c > we can effectively find a set Γ of equations for elements h, r, f, c
in DA such that, disregarding cardinality restrictions:
(a) For every model H0 of the algorithmic properties Π the realization DA [h; r, f, c] ∼
=
H0 is such that h, r, f, c satisfy Γ.
(b) If h, r, f, c ∈ DA satisfy Γ and are nontrivial, then DA [h; r, f, c] ∼
= H0 for some
model H0 of the algorithmic properties Π.
The proof of this theorem is a simple extension of the proof of Theorem 2 [7].
12
Bibliography
[1] H. Barendregt. The Lambda Calculus North-Holland, Amsterdam, 2nd ed. (1984).
[2] M. H. Van Emden and R. A. Kowalski. The semantics of predicate logic as a
programming language, J. ACM 23 (1976), 733–742.
[3*] E. Engeler. Algorithmic properties of structures, Math. Systems Theory 1 (1967),
183–195.
[4*] E. Engeler. Algebras and combinators, Algebra Universalis 13 (1981), 389–392.
[5*] E. Engeler. Equations in Combinatory Algebras. In: Proceedings of Logics of
Programs ’83 (ed. D. Kozen) LN in Computer Science 164, Springer (1984), 193–
205.
[6] E. Engeler. Modeling of cooperative processes. In: Comput. Theory and Logic
(ed. E. Börger) LN Computer Science 270, Springer (1987), 143–153.
[7*] E. Engeler. Representation of varieties in combinatory algebras, Algebra Universalis 25 (1988), 85–95.
[8] T. Fehlmann. Theorie und Anwendung des Graphmodells der kombinatorischen
Logik. Berichte des Instituts fuer Informatik, ETH Zurich, No. 41 (1981).
[9] R. Maeder. Graph algebras, algebraic and denotational semantics, Dissertation
ETH No. 8065 Zurich (1986).
[10] G. Plotkin. A set-theoretic definition of application, Memorandum MIP-R-95,
School of AI, University of Edinburgh (1972).
[11] D. S. Scott. Models for the λ-calculus. Manuscript (1969).
13