This content was uploaded by our users and we assume good faith they have the permission to share this book. If you own the copyright to this book and it is wrongfully on our website, we offer a simple DMCA procedure to remove your content from our site. Start by pressing the button below!
A an assignment. The value for a and A is a truth value from {true, false} and is defined by: £' a signature morphism and $ C L(£) o set ofS-formulas. Then p(* E ) C (/*(*))jy. • The following definition reflects the fact that the purpose of a calculus is to grasp the notion of logical consequence. Definition 8.3 (Soundness, completeness). Let L be a logic, S a signature and AC a calculus for L and E. Furthermore, let U be a domain for E. (i) AC is called sound with respect to U if, for any set $ C L(£) and any formula . E>N : F = {x € R | (3y € Er)(Bz
The following definition concludes the definition of the logic PL.
Algebraic specification of abstract data types
243
Definition 6.12 (The satisfaction relation of PL). Let S be a signature. The satisfaction relation of first-order predicate logic is defined by: A (=s V O- (A(a)(
7
Models and logical consequences
This section is devoted to the study of the properties of logic.
7.1
Models
Definition 7.1 (Model). Let L be a logic, E a signature and $ C L(E) a set of formulas. (i) A E-algebra A is called a model of $ if A \=% $, i.e. A (=s if for each
(f e $. (ii) A domain (or universe) for E is a class of E-algebras that is closed under isomorphism, i.e. an abstract data type. The class of all algebras of a domain U for S that are models of $ is denoted Modu, ?,($}, or Modu($) for short. From a pragmatic point of view a domain consists of those algebras one is interested in. Practical examples of domains are Alg(E), the class Gen(E) of all generated S-algebras and the class of E-algebras generated in some sorts. One writes Modv($) instead of Mod A/J(E)($) an
(i) Modz(9) = Alg(L). (ii) Mod(PL(S)) = 0. (iii) Let E = ({s}, {0 : -4 s, _ + _: s x s -»• «}) and let x, y, £ be variables. Let $ C PL(E) be the set $ = { x + (y + z) = (x + j/) + z, z + 0 = z, 0 + z = x, Vx: s.3j/: s.(x + j/ =
244
J. Loeckx, H.-D. Ehrich and M. Wolf The reader may easily check that = {A e Alg(E) \ A(s) with A(+) forms a group with neutral element A(0) }, A(s) =
The following theorem illustrates the relation between logic and abstract data types. Theorem 7.3. Let L be a logic, E a signature, $ C £(S) a set of formulas and If a domain for E. Then Modu($) is an abstract data type. A relation between formula sets and their model classes is given in the following theorem: Theorem 7.4. Let L be a logic, E a signature, $,$ C L(S) sets of formulas and U a domain for E. Then (i) Modu(^ U *) = Modu())• The unique homomorphism from T(E, $) to an arbitrary algebra A of Mods(^) is called the initial homomorphism of A. Again, T(E, $) is an abstract data type. The following theorem is a direct consequence of Corollary 4.20. It forms the basis of the initial specification method (see section 11.1) and thus justifies the above appellation "initial homomorphism" . Theorem 7.6. Let L, E, 4> be as in Definition 7.5. If the quotient term algebra T(S,$) is a model o/$, then it is initial in Mod-z($).
7.2
Logical consequence
Definition 7.7 (Logical consequence). Let L be a logic, E a signature, f € £(E) a formula and $ C £(£) a set of formulas. Furthermore, let U be a domain for E. (i) The formula ip is called a logical consequence of $ in U if A |=s if for each A € U with A |=£ $; one then writes $ |=z/,£
(ii) The formula tp is said to be valid in U if it is a logical consequence
Algebraic specification of abstract data types
245
of the empty set of formulas in U\ one then writes |=w,s (p instead of 0 |=M,E ¥>• If W = -4^(S) the formula ? is said to be logically valid and is called a tautology; one then writes [=s
7.3
Theories
Definition 7.9 (Theory). Let L be a logic and S a signature. (i) The theory of a E-algebra A with respect to L is the set (ii) The theory of a class C of E-algebras with respect to L is ThLf(C) = { > € L(E) | A ^E V for each A e C }. Informally, the theory of C consists of all formulas that express common properties of the algebras of C. Clearly, the theory is "larger" when the logic is more "powerful" — as illustrated in Example 7.11. Fact 7.10. (i) A theory is closed under logical consequence. (ii) A theory contains all tautologies.
246
J. Loeckx, H.-D. Ehrich and M. Wolf
The first of these facts expresses the fact that, for instance, Thi(C) \= (p implies if £ ThL(C). Example 7.11. Let E = ({nat}, {0 : -> nat, Succ : not -4 nat}) and A be the "classical" E-algebra. (i) ThEi(A) contains tautologies only. (ii) Apart from tautologies, ThpL(A) contains formulas such as -i(0 = Swcc(O)) and Vx: nat.By: nat.y = Succ(x). The first part of the following theorem states that theories cannot distinguish between isomorphic algebras. Theorem 7.12. Let L be a logic, E a signature and A, B 'S-algebras. (i) A~B implies ThL(A) = ThL(B). (ii) If L is a logic with equality and if A and B are generated, then ThL(A) = ThL(B) implies A~B. The following theorem is a dual of Theorem 7.4. Theorem 7.13. Let L be a logic, E a signature and C\, C% two classes of 'E-algebras. Then: (i) ThL(d\JC2) = ThL(d) n 17»i(C2); (ii) Ci C C2 implies ThL(C2) C ThL(Ci). To be manageable a theory should be recursively enumerable. Only in that case it is possible to describe it axiomatically. Definition 7.14 (Axiomatizable algebra). (i) A E-algebra A is said to be axiomatizable in a logic L if ThL,z(A) is recursively enumerable. (ii) An axiomatizable class of algebras is defined similarly. Example 7.15. Let E be the signature of Example 2.2. The classical algebra A for this signature (with A(nat) = NO) is called the Pea.no arithmetic. It is well known that this algebra is not axiomatizable.
7.4
Closures
Informally, the closure of a set of formulas is the smallest theory containing this set as a subset. Definition 7.16 (Closure of a set of formulas). Let L be a logic, E a signature, $ C L(E) a set of formulas and 14 a domain for E. The closure of $ with respect to the domain U is the set of formulas If U = Alg(£) one speaks of the closure of $ and writes $£ or 3>* instead of $*Aig<^y If U = Gen(S) one speaks of the inductive closure and writes or $ * instead o f $ -
Algebraic specification of abstract data types
247
The following theorem allows an alternative definition of a closure. Theorem 7.17. With L, E, $ and U as in Definition 7.16 and * C L(S) *£ = ThL(Modu(*)). Closures possess numerous properties as illustrated in the following theorems. Theorem 7.18. With L, S, $ and U as in Definition 7.16 and * C L(S): ft) * C
^ $ C * implies $£, C *^. Theorem 7.19. Let L be a logic, E a signature, U a domain for E and . Tfcen: £ C $£, if and onfy if Modu($) C w C #£, »/ and on/j/ t/ * \=u $. As a corollary of this theorem two sets $ and $ of formulas have the same models if and only if $ is a logical consequence of $ and vice versa. Hence, to prove that Mod^($) — Modu(^f) it is sufficient to prove $ \=u * and * \=u *• A dual notion of the closure of a set of formulas is that of the closure of a class of algebras. Definition 7.20 (Closure of a class of algebras). Let L be a logic, S a signature, U a domain for S and C C U a class of E-algebras. The closure of C with respect to L and U is the subclass C.*LUTi (or C£ w for short) of U: Clearly, C*L
• C C C' implies Q)M C CJ*>M. Moreover, the dual of Theorem 7.19 also holds: Theorem 7.21. Let L be a logic, E a signature, U a domain for E and C,C' C U classes of'E-algebras. Then: ft) Clu Q C'f-u if and only if ThL(C') C fii; C£^ C C'lju if and only ifCL,u C C
248
J. Loeckx, H.-D. Ehrich and M. Wolf
It is possible to show that Modu and Thi constitute a Galois connection; the interested reader may consult, for instance, Exercise 5.7-4 in [Loeckx et al, 1996].
7.5
Reducts
The present section investigates the logical properties of reducts. To simplify the presentation, the domain is assumed to be Alg(H); a generalization for an arbitrary domain U poses no fundamental problems. The following theorem is a straightforward consequence of the satisfaction condition. Theorem 7.22. Let L be a logic and fj. : S —» E' a signature morphism. (i) Let $ C L(E). Then Modv(n($)) = { A' € Alg(E') \ (A1 (ii) LefD' C Alg(E'). Then (V | ft) = {
7.6
Extensions
The present section investigates the logical properties of extensions of model classes. Theorem 7.24. Let L be a logic, p, : £ —> E' a signature morphism and $ C L(E), $' C L(E') sets of formulas. (i) Mods' ($') is a ^-extension of Mod^Q) if and only if $' )=£' /*($)• (ii) If Mods' ($') is a. persistent ^-extension of Modj;($), then Definition 7.25 (Extension of a set of formulas). Let L be a logic, H : E —> E' a signature morphism and $ C L(E), $' C L(E') two sets of formulas. The set $' is called a ^-extension of $ if /<(*E) C $^, . The It-extension is called persistent if /u($s) = ^E ^ ^(M^))Informally, a /i-extension $' of $ contains $ as a subset "modulo /i" . If the /^-extension is persistent, $' is identical with $ "modulo //" except for formulas from L(S') - L(^(E)). By the way, L(E') = £(//(£)) whenever |i is surjective. A reader having difficulties in grasping these notions is recommended to first consider the particular case in which jj, is an inclusion. The following theorem links extensions of formula sets to extensions of model classes.
Algebraic specification of abstract data types
249
Theorem 7.26. Let L be a logic, fj, : E —» E' o signature morphism and $ C L(E), $' C L(E') sets of formulas. Then: (i) $' is a /4-extension of $ if and only t/ Mods/ ($') is a ^-extension of Modify; (ii) if Mod-£> ($') is a persistent ^-extension of Modz($), then $' is a persistent ^-extension This theorem allows Theorem 7.24 to be rephrased.
8
Calculi
Informally, a calculus constitutes an inductive definition of a set of strings. In a calculus for a logic these strings are formulas. The goal of such a calculus is to syntactically grasp the notion of logical consequence. Hence, with such a calculus it is in principle possible to mechanically prove statements such as $(=?. Calculi for particular logics have been studied extensively in the frame of mathematical logic and artificial intelligence (e.g. [Ebbinghaus et al., 1984; Bibel, 1993]). The present section restricts itself to some general definitions, an example and a few comments.
8.1
Definitions
Definition 8.1 (Calculus). Let L be a logic and E a signature. A calculus for L and S is a pair K. = (Ax, Inf) where: • Ax is a finite set of decidable subsets of L(E); an element of Ax is called an axiom scheme and an element of an axiom scheme is called an axiom; • Inf is a finite set of inference rules each of which consists of a decidable subset of (£(S))n x L(E), for some n, n > 0. Note that an inference rule { ((ipi ,... ,ipn),tp) \ . . . } is generally written
as V 1 , • • • ,
The "meaning" of a calculus results from the following definition. Definition 8.2 (Derivable formula). Let L be a logic, E a signature and 1C a calculus for L and E. Let $ C L(E) be a set of formulas and ip € £(E) a formula. The formula (p is said to be derivable from $ in 1C if there exists a finite non-empty sequence
250
J. Loeckx, H.-D. Ehrich and M. Wolf • tpj is an axiom of AC; • there exist indices ii,...,in < j such that (((^ , . . . ,
is an
One then writes $ l-jc
8.2 An example The following calculus is a calculus for the equational logic EL of Section 6.2. It constitutes a generalization of the calculus presented in [Tucker and Meinke, 1992] in that it allows empty carrier sets. Definition 8.4 (Equational calculus). Let E be a signature and X, Y sets of variables for E. The following axiom scheme (I) and four inference rules (II) to (V) constitute a calculus for the equational logic EL and the signature E:
(i) vx.t = t (ll)
teT^xy,
^7
t = n,VX.u = v —
. fc — l/
t,u€T^x}; t, u, v 6 T E(JC );
a : X —> TY.(Y\ a substitution;
Algebraic specification of abstract data types
251
=U
VX.va = vr m > 1, ti,Ui € T-E(X) f°r all z with 1 < i < m, v e T S (y), CT,T : Y —> ?£(X) two substitutions satisfying the condition for each y £ Y: either cr(y) = r(y) or (ff(y) = tj and r(y) = Uj for some j, 1 < 3 < m). Note that the calculus takes cares of empty carrier sets. More precisely, assume that Y C X; the calculus allows VX.t = u to be deduced from VY.t = u; on the other hand it allows VY.t = u to be deduced from VX.t = u only if for each sort s with Ys = 0 and Xs ^ 0 the set T^^Y),s is not empty (cf. Example 6.5(ii) with X = {x} and Y = 0). Theorem 8.5. The equational calculus of Definition 8.4 is sound and complete with respect to Alg(E). While the proof of the soundness is straightforward, the proof of the completeness is not trivial (see, for example, [Tucker and Meinke, 1992] or [Loeckx et al., 1996]).
8.3
Comments
The calculus above is of course also sound with respect to any domain for the signature S, for instance with respect to Gen(E). It is not complete with respect to Gen(S) because the inductive consequence "j=/n. If the calculus is sound without being complete, it is not guaranteed that $ I- tp holds.
252
J. Loeckx, H.-D. Ehrich and M. Wolf
The axioms and inference rules of a calculus are generally very "elementary" and — especially in the case of first-order predicate logic—"nonintuitive" . Proving properties of the form $ h ip in a calculus is therefore very tedious. To this end calculi have been implemented in the form of "proof systems" allowing proofs to be carried out automatically or semiautomatically with a computer. Some of these systems allow induction to be "simulated" and thus inductive consequences to be proved. From what has been said above it follows that such systems cannot be complete. Instead, the most sophisticated among them use heuristics; if these fail the user is asked for some "clever" lemma enabling the proof to be carried out.
9
Specification
The goal of this section is to introduce a few general notions on specification and thus constitute an introduction to sections 10 to 14 of this chapter. The fundamental idea of abstract data type specification is to define abstract data types by formulas. As in the case of programs, specifications must have a modular structure lest they get incomprehensible. This leads to the following techniques for the design of "small" and "large" specifications, respectively. Specification in the small consists in drawing up specifications "from scratch". Essentially such a specification consists of a signature and a set of formulas. The abstract data type defined by the specification is in general a subclass of the model class of the set of formulas. In sections 10 to 12 three different specification techniques will be discussed yielding loose specifications, initial specifications and constructive specifications, respectively. They differ from each other by the logic used, by the set of formulas allowed and/or by the subclass defined. Henceforth, a specification obtained by specification-in-the-small is called an atomic specification. Specification in the large consists in drawing up specifications by putting (already designed) specifications together. This is performed with the help of a formalism called specification language. The principles of such languages will be examined in sections 13 and 14. The following—very general—definition reflects the fact that a specification does not necessarily "exactly" capture the intended abstract data type. Definition 9.1 (Adequate specification). Let C be an abstract data type. Furthermore, let sp be a specification and M(sp) its meaning, i.e. the abstract data type sp defines. Then: (i) sp constitutes an adequate specification of C if C C M(sp); (ii) sp constitutes a strictly adequate specification of C if C = Ai(sp). By an abuse of language one also speaks of an adequate or strictly adequate
Algebraic specification of abstract data types
253
specification of an algebra, meaning an adequate or strictly adequate specification of the monomorphic abstract data type containing this algebra. Note that if M(sp) is a monomorphic abstract data type the notions of adequacy and strict adequacy coincide. A specifier or user of a specification may want to prove certain properties of a specification. He may, for instance, want to prove that a given specification sp constitutes an adequate or strictly adequate specification of an abstract data type C. Of course, such a proof presupposes that the abstract data type C has been precisely defined elsewhere. Another interesting question is whether the class M(sp) defined by the specification sp constitutes a monomorphic abstract data type. A further question is whether M(sp) is empty (and hence "useless"). Proofs of such properties may take the form of informal "mathematical" proofs similar to those that may be found in any textbook on theoretical computer science. A particular case is constituted by those properties that may be reduced to logical consequences. Such a property may be written as $ \=u tp, where y is, for instance, a property of the abstract data type and where $ is the set of formulas of an atomic specification. According to section 8.3 such properties may be proved automatically or semi-automatically whenever there exists a sound (and complete) calculus with respect to U. As indicated above, proving the adequacy of a specification presupposes that the abstract data type to be specified is exactly known. Except for "trivial" abstract data types this is generally not the case in practice: the specification itself often constitutes the only precise definition of the abstract data type. Instead, the adequacy may be checked by a testing method called rapid prototyping. Essentially, this testing method consists in mechanically determining the value of some "critical" terms and comparing this value with one's "expectations". This mechanical evaluation of terms presupposes that the specification is in some sense "executable" or "constructive" and hence monomorphic—as will be discussed below. Clearly, being based on testing rapid prototyping may disprove adequacy but cannot prove it; in other words, rapid prototyping may at best improve one's confidence in the adequacy. A specification defining a polymorphic abstract data type is sometimes called a requirement specification. In contrast, a design specification is a monomorphic specification that allows rapid prototyping.
10
Loose specifications
Loose specifications are atomic specifications in the sense of section 9.
10.1 Genuinely loose specifications Definition 10.1 (Loose specification). Let L be a logic.
254
J. Loeckx, H.-D. Ehrich and M. Wolf
(i) (Abstract syntax.) A loose specification in L is a pair sp = (£,$) where S is a signature and $ C L(E) a decidable set of formulas. (ii) (Semantics.) The meaning M(sp) of a loose specification sp = (£, ft) is defined to be the abstract data type M(sp) = Informally, a loose specification stands for the class of all models of its set of formulas. To improve their readability and allow for a mechanical treatment specifications may be written in a concrete syntax. In this syntax a loose specification is a string of, for instance, the following form: loose spec sorts list-of-sorts opns list-of-operations vars list- of -variables axioms list-of- formulas endspec Informally, the sorts and operations fix the signature; an element of the list- of -variables is of the form x: s where x is a variable and s its sort. It is required that only variables of the list-of-variables occur in the formulas. In the examples a list of variables such as x: s, y: s, z: s will be written x,y,z: s. In this chapter examples will be given in concrete syntax while theorems and definitions will refer to the abstract syntax. Example 10.2. The logic used in this specification is the first-order predicate logic PL of section 6.4. Note the similarity with Example 4.9. loose spec sorts boot, el, list opns True : -> bool False : -¥ bool [ } : ->• list Add: el x list -> list . . _ : list x list ->• list Isprefix : list x list —> list vars l,m,n: list, e: el axioms []./ = { Add(e, l).m = Add(e, l.m) (Isprefix (I, m) — True) = (3n.(m = l.n)) endspec The specification is an adequate specification of the "classical" algebra because this algebra constitutes a model of the "axioms" — as one may easily check. It is not a strictly adequate specification due to the existence of models that are not generated in the sorts bool and list. Example 10.3 (Peano axioms). Again the logic considered is PL. loose spec sorts bool, nat opns True : -»• bool
Algebraic specification of abstract data types
255
False: -+ bool 0: -» nat Succ: nat —t nat _ + _: nat x not —>• nat _ * _ : nat x nat —» nat . < _: nat x nat -> feooJ vars m, n: nat axioms -i(7Vue = False) -.(0 = Succ(n)) Succ(n) = Succ(m) D n = m (0 < n) = Thie (Succ(n) < 0) = Fake (Succ(n) < Swcc(m)) = (n < m) n+0=n n + Swcc(rn) = Succ(n + m) n*0 = 0 n * Swcc(m) = n + (n * m) endspec Clearly, the specification is an adequate specification of Peano arithmetic (see Example 7.15). As Peano arithmetic is not axiomatizable, it cannot be a strictly adequate one. The following theorem indicates some limits of the expressive power of loose specifications. Theorem 10.4. Let sp = (E, $) be a loose specification in a logic L. Then: (i) M(sp) = (M(sp)YL; (ii) if L is a logic for which there exists a sound and complete calculus, then M(sp) is axiomatizable in L; (in) if L is one of the logics of sections 6.2 to 6.4 and if M.(sp) contains an algebra with an infinite carrier set, then M.(sp) also contains nongenerated algebras, A variant of Theorem 10.4(iii) is also known as the Lowenheim-Skolem theorem (see, for instance [Ebbinghaus et al, 1984]). Properties of loose specifications may be proved along the lines discussed in section 9. In general, rapid prototyping is not possible for loose specifications.
10.2 Loose specifications with constructors Definition 10.5 (Loose specification with constructors). Let L be a logic. (i) (Abstract syntax.) A loose specification with constructors is a 4-tuple
256
J. Loeckx, H.-D. Ehrich and M. Wolf sp = (S, $, 5 c ,fl c ) where £ = (5, fi) is a signature, $ C L(S) a set of formulas, Sc C. S a set of sorts and flc C fi a set of operations with target sorts in Sc called constructors.
(ii) (Semantics.) The meaning M(sp) of sp is defined to be the abstract data type M(sp) = Modu($) where U
=
{A € AlgCE) \ A is generated in the sorts of Sc by the set flc}.
The concrete syntax for such specifications may be chosen to be identical with that of section 10.1 except that in the list- of- operations each sort of Sc and each operation of fZc is preceded by the keywords generated and constr respectively. Example 10.6. Consider the specification sp of Example 10.2 with generated preceding boot and list and with constr preceding each of the first four operations. By its very definition M(sp) no longer contains algebras that are not generated in the sorts bool and list. Nevertheless, it still fails to be a strictly adequate specification because it contains models for which the carrier set of sort list is a singleton. Example 10.7. Consider the specification of Example 10.3 with generated preceding bool and nat and with constr preceding each of the first four operations. It may be shown that the abstract data type defined by the specification is monomorphic. Hence, it constitutes a strictly adequate specification of Peano arithmetic. By the way, this specification illustrates that the first-order predicate calculus together with the induction principle is in some sense complete with respect to Gen(S) (cf. section 8.3). The properties of loose specifications — including Theorem 10.4 — carry over to loose specifications with constructors. Of course, the effect of the Lowenheim-Skolem theorem (Theorem 10.4(iii)) is void.
10.3
Loose specifications with free constructors
The definition of these specifications is as in Definition 10.5 with "freely generated" instead of "generated" . Similarly, one uses the keyword freely generated instead of generated. Example 10.8. Consider the specification of Example 10.6 with freely generated instead of generated. The specification is now a strictly adequate specification of the "classical" algebra. Note that the abstract data defined is still polymorphic due to the non-generated sort el. Example 10.9. Consider Example 10.7 but with freely generated instead of generated. The first three formulas are now superfluous and may be removed. Example 10.10. Consider the following specification:
Algebraic specification of abstract data types
257
loose spec sorts opns
freely generated not constr 0 : —» not constr Succ : nat —> not Pred : nat -> nat vars n: no£ axioms Pred(Succ(n)) = n
endspec in which Pred is "intended" to be the predecessor function. This polymorphic specification is a strictly adequate specification of the "classical" algebra in which the value Prerf(O) is left pending. More precisely, the abstract data type defined contains non-isomorphic algebras differing from each other only by the value of Pred(0).
11
Initial specifications
Initial specifications are atomic specifications in the sense of section 9. They differ from loose specifications in that they always define monomorphic abstract data types. Furthermore, initial specifications make use of equational logic or conditional equational logic. While sections 11.1 to 11.7 treat the case of equational logic, section 11.8 briefly considers the case of conditional equational logic.
11.1
Initial specifications in equational logic
Definition 11.1 (Initial specifications). Let EL be the equational logic of section 6.2 and let T(£, $) denote the quotient term algebra of Definition 7.5. (i) (Abstract syntax.) An initial specification in equational logic is a pair sp = (£, $) where S is a signature and $ C EL(E) a set of equations. (ii) (Semantics.) The meaning M(sp) of an equational specification sp = (£, 4>) is the monomorphic abstract data type M(sp) = {Ae Alg(E) | A ~ T(E, *) }. The interest of this definition stems from the following fundamental theorem of equational logic: Theorem 11.2. Let S be a signature and $ C ££(£) a set of equations. ThenT(£,
258
J. Loeckx, H.-D. Ehrich and M. Wolf
Prom the properties of algebras and, in particular, of quotient term algebras one easily deduces the following fact: Fact 11.4. Let sp = (£,$) be an initial specification. (i) Each algebra of M (sp) is generated. (ii) For each algebra A 6 Morfs($) there exists a unique homomorphism h : T(S, $) —> A defined by h([t]) = A(i), t € Ts, viz. the initial homomorphism (see Definition 7.5). (iii) For each algebra B € M(sp) there exists a unique and surjective homomorphism h : T(S) —> B defined by h(i) = A concrete syntax for initial specifications is chosen to be identical with that of section 10.1 but with the keywords initial and eqns instead of loose and axioms.
11.2
Examples
Example 11.5. (i) A trivial initial specification is: initial spec sorts not opns 0 : -» not Succ : nat —>• nat _ + _ : nat x nat —> nat vars m,n:nat eqns n + 0 = n n + Succ(m) = Succ(n + m) endspec One may prove that the specification is an adequate specification of the "classical" algebra. Note, in particular, that T(£,$)(nat) consists of the equivalence classes [0], [5«cc(0)],[5«cc(5«cc(0))], etc. Note also that, for instance, [0] = [0 + 0] = [0 + 0 + 0] = . . . [SMcc(O)] = [SMCc(O) + 0] = [0 + S«cc(0)] = [Succ(O) + 0 + 0] = . . . . (ii) The following example is the classical example of an initial specification. Its glamour stems from the fact that there is no equivalent loose specification with free constructors that is equally "abstract" . initial spec sorts nat,, set opns 0 : ->• nat Succ : nat —> nat 0 : -> set Insert : set x nat —> set vars m, n: nat,s: set eqns Insert(Insert(s,n),n) = Insert (s, n)
Algebraic specification of abstract data types
259
Insert(Insert(s,n),m) = Insert(Insert(s,m),n) endspec Informally, the first equation identifies terms in which the same "element" occurs several times; the second equation identifies terms in which the same "elements" occur in different order. The following example illustrates the problems resulting from the fact that initial specifications cannot define polymorphic abstract data types. Example 11.6. Consider the initial specification deduced from the loose specification of Example 10.10 by deleting the keywords freely generated and constr and by replacing loose and axioms by initial and eqns. This specification is not an adequate specification of the "classical" algebra because T(S,
= Error, = Error, = Error.
.
(11.1) (11.2) (11-3)
This solution leads to an additional carrier, viz. [Error]. A more elegant "solution" consists in adding the equation Succ(Pred(n)) = n. Actually, it still fails to eliminate superfluous carriers, viz. [Pred(O)], [Pred(Pred(G))},.... A combination of the last two solutions that consists in adding the corresponding four equations has a dramatic result: the carrier set is reduced to a singleton because [Error] = [0] = [SWc(O)] = ... — as one can easily check. For more examples of initial specifications the reader is referred to the abundant literature on the subject (e.g. [Ehrig and Mahr, 1985]).
260
11.3
J. Loeckx, H.-D. Ehrich and M. Wolf
Properties
The following property of equational logic directly follows from Theorem 3.8. Theorem 11.8. Let E be a signature, A, B Ti-algebras and h : A —> B a homomorphism. Furthermore, lett = u be a ground equation and VX.v = w an equation of EL(E) . (i) If A\=t- u, then B\=t = u. (ii) If h is surjective and A \= VX.v — w, then B \= VX.v = w. (iii) If h is injective and B |= VX.v = w, then A \= VX.v = w. This leads to the following important property of initial specifications. Note that T(£, $) may be viewed as a representative of the abstract data type defined by the initial specification (S,«J>). Theorem 11.9. Let (£,$) be an initial specification. Let t = u be a ground equation and VX.v = w an arbitrary equation of ££(£). Then: (i) T(£, $)\=t = u if and only if $ I- t = u; (ii) T(E, $) |= t = u if and only if A |= t = u for each T,-algebra A from (iii) T(S, $) f= VX.v -w if and only if $ (=/nd VX.v = w; (iv) r(S, $) |= VX.v — w if and only if A^= VX.v = w for each E-algebra A from Indz($) (i-e. for each generated 'S-algebra from Informally, the theorem states that T(S, $) possesses exactly those properties that are common to all generated models (and that are expressible in equational logic).
11.4
Expressive power of initial specifications
By their very definition initial specifications can only define monomorphic abstract data types consisting of generated algebras. Conversely, any such abstract data type can be defined by an initial specification, the equation set of which consists of a possibly infinite number of ground equations. Remember that the notions of adequacy and strict adequacy coincide for specifications defining a monomorphic abstract data type. Theorem 11.10. Let A be a generated 'S-algebra. The initial specification (E, { t = u € #L(E) | t, u € TS, A(t) = A(u) }) is an adequate specification of A. In practice one is especially interested in specifications with a finite set of equations. Theorem 11.11. There are generated algebras for which there exists an adequate initial specification with a finite set of equations but no adequate initial specification with a finite set of ground equations.
Algebraic specification of abstract data types
261
An example of such an algebra is the S-algebra A with £ = ({not}, {0: -> nat, Succ: nat -4 nat, Double : nat ->• not}) and A(nat) = NO , A(Q) and A(Succ) "classical", A(Double)(n) = 2 * n. Clearly, the initial specification with: 4> = (Double(G) = 0, Double(Succ(n)) = Succ(Succ(Double(n)))} is an adequate specification of A. The basic idea of the proof that a finite number of ground equations does not suffice, is that one needs recursion to express "doubling" with the help of the successor function. Theorem 11.12. There are generated algebras for which there exists no adequate initial specification with a finite set of equations. An example is the E-algebra A with: S = ({nat}, {0: —> nat, Succ: nat —> nat, Square : nat —» nat}) with A(nat), A(0), A(Succ) as usual and A(Square)(n) = n*n. The basic idea of the proof is to show that one needs nested recursion to express squaring with the help of the successor function (in the absence of an "auxiliary" function such as addition). The following theorem shows that the use of such "auxiliary" functions suffices to finitely specify any generated "computable" algebra. The notation ... | E is that of Definition 5.6. Theorem 11.13. Let A be a generated ^-algebra, the functions of which are computable. Let C be the monomorphic abstract data type containing A. Then there exists an initial specification sp = (£',') with S C £', *' C ££(£') and $' finite such that C = (M(ap) \ E). The idea of the proof is to simulate a Turing machine by an initial specification (cf. [Bergstra and Tucker, 1983]).
11.5
Proofs
Properties of initial specifications may be proved along the lines discussed in section 9. In addition, one may make use of the specific properties of these specifications and apply one of the following four principles of proof. The first principle is based on the fact that the algebra T(£, $) is initial in Modz($). Hence, to prove for a given S-algebra A that A ~ T(£, $), it is sufficient to prove that A is a model of $ and that the initial homomorphism of A (viz. h : T(£, $) —> A defined by h([t]) = A(t), t 6 TE) is bijective. Similarly, to prove that the initial specifications (£, 4>) and (E, *) are equivalent, it suffices to prove that $ |= * and that the initial homomorphism h : T(£, $) —>• T(£, *) is injective. A second principle is based on the fact that T(E, $) is generated and on the following property of equational logic. Theorem 11.14. Let E be a signature, VX.t = u £ EL(E) an equation and A a generated 'E-algebra. Then A \= VX.t = u if and only if
262
J. Loeckx, H.-D. Ehrich and M. Wolf
A\=to- = ua for all ground substitutions a : X —» TE . Informally, the theorem states that a variable may be replaced by an arbitrary ground term. Hence, to prove T(£, $) (= VX.t = u one proves T(£, $) |= ta = ua for all ground substitutions a : X —> TE or, according to Theorem 11.9(i), $ (= ta — ua for all ground substitutions a : X —>• T£. This may be proved by induction on the structure of the ground terms that are substituted for the variables, i.e. on the structure of the value cr(x), x 6 X . Example 11.15. Consider the specification of Example 11.5(i). To prove that T(S, $) |= V{n}.0 + n = n, it is sufficient to prove: (i) $ |= 0 + 0 = 0; (ii) if $ (= 0 + t = t for some t € IE, then $ (= 0 + Swcc(£) = Succ(t); (iii) i f $ | = 0 + u = w and $ h 0 + u = w for some u,v £ Ts, then $ (= 0 + (u + l>) = M + V.
Actually, step (iii) of the proof may be shown to be superfluous. In fact, one may show that for each ground term t e TH there exists n > 0 such that $ (= t = Succ^n\0). Informally, this means that 0 and Succ are constructors of the sort nat. A third principle of proof consists in replacing the algebra T(£, 4>) by an isomorphic but "simpler" algebra. It is based on the following theorem which is a direct consequence of Theorem 4.6. Theorem 11.16. Let (S,$) be an initial specification with S = (5,0). Let C be a generated H-algebra with C(s) C TsiS for each s 6 S. If (i) C \= $, and if, moreover, (ii) $ f= C(t) = t for all ground terms t € T%, thenC ~T(£,$). An algebra C satisfying the conditions of the above theorem is called a characteristic term algebra for the initial specification (E,$). The proof technique now consists in finding a characteristic term algebra C for the given specification and replacing the study of T(S, $) by that of C. Example 11.17. Consider again the specification of Example 11.5 (i). Define the S-algebra C by: C(0) = 0, C(Succ)(Succ(n\Q)) = C-(+)(5«cc ( " ) (0),5'wcc (m) (0)) = Succ(n+m)(0). The reader may check that C satisfies conditions (i) and (ii) of Theorem 11.16. Hence, to prove T(S, $) |= V{n}.0 + n = m it is sufficient to prove C \= V{n}.0 + n = n, i.e.
Algebraic specification of abstract data types
263
C(+)(C(Q),at(ri)) = a(n) for all assignments a : {n} —> C or, equivalently, C'(+)(0,5ttcc(n)(0)) = S«cc(n)(0) for all n > 0. Note that C indirectly proves that 0 and Succ are constructors of the sort not (see the remark in Example 11.15). The fourth principle of proof consists in the use of term rewriting systems, to which we now turn.
11.6
Term rewriting systems and proofs
Term rewriting systems are particular reduction systems. Both types of systems are extensively discussed in [Klop, 1992; Avenhaus, 1995]. In order to fix the notation the main definitions are briefly recalled. First the notions related to reduction systems are defined. Definition 11.18 (Reduction system). (i) A reduction system is a pair (R, ->) where jR is a set and "—>•" a relation on R. (ii) A reduction sequence of a reduction system (R, —») is a possibly infinite sequence r\,..., r / t , . . . of elements of R such that FJ -» r,+1 for each i > 1; one then writes r\ ->•* r^ for any k>l. (iii) An equivalence sequence is defined similarly but with r, —» r»+i or n+i ->• Ti for each i > I; one writes r\ ~ r^ for any k > 1. Definition 11.19 (Noetherian, confluent, locally confluent). (i) A reduction system is Noetherian if it possesses no infinite reduction sequence, (ii) A reduction system (jR, —>) is locally confluent if for all r, s, t € R the following holds: if r -> s and r -* t then there exists u € R with s —>•* w and t —>* u. (iii) The notion of a confluent reduction system is defined as in (ii) but with r —t* s and r —>•* t instead of r —» s and r —> t, respectively. Definition 11.20 (Normal form). Let (R, ->) be a reduction system and r & R. A normal form of r is an element s £ R such that r —»* s and there exists no i € .R with s -t t. Theorem 11.21 (Newman's lemma). A Noetherian and locally confluent reduction system is confluent. Theorem 11.22. Let (R, ->) be a Noetherian and confluent reduction system. (i) Each element of R has exactly one normal form. (ii) Let r,s € R. Then r ~ s if and only if r and s have the same normal form. The following definition associates a reduction system with each initial specification.
264
J. Loeckx, H.-D. Ehrich and M. Wolf
Definition 11.23 (Term rewriting system). The term rewriting system of an initial specification (E, $) is the reduction system (T^, —>) with " ->" inductively defined by: (i) ta —> ucr for each equation VX.t = u £ $ and each ground substitution a : X —> Ts; (ii) if i -> u, then v[t/y] -» w[u/y] for all terms w e ?E({»}) containing at least one occurrence of the variable y. Note that an initial specification in which an equation VX.t = u is replaced by VX.u = t leads to a different relation "-»*" but to the same relation "~". The following definition and theorem constitute the basis of a criterion guaranteeing that a term rewriting system is Noetherian: Definition 11.24 (Rewrite ordering, reduction ordering). Let £ be
a signature with Tg)g ^ 0 for each sort s from £. Furthermore, let X be a set of variables for £. An irreflexive partial order ">" on T£(X) is called a rewrite ordering on TE(X) if f°r a^ terms t,u € TE(X) : (i) i > u implies fcr > ucr for all substitutions a : X —> ^£(-f ) > (ii) t > u implies v[t/y] > v[u/y] for all terms v 6 ?s(xu{y}) where j/ is a variable for S, y £ X, which occurs at least once in v. A rewrite ordering is called a reduction ordering if there exists no infinite sequence • • • < h < *2 < ti,
ti € TZ(X) for all i > 1.
Theorem 11.25. Le£ (E, $) 6e an initial specification and X a set of variables for S containing the variables occurring in $. // there exists a reduction ordering < on T%(x), such that u < t for any equation VY.t = u e $, £/«en #je term rewriting system of (£,$) is Noetherian. The main theorem of term rewriting states that the equivalence relation "~" coincides with the validity of ground equations in the initial algebra: Theorem 11.26. Let (£,$) be an initial specification and (Ts,->) its term rewriting system. For all ground terms t, u € TS it is the case that t ~ u if and only if T(E, $) |= t = u. Note that the theorem does not require that the term rewriting system is Noetherian and/or confluent. The previous theorem is the basis of the fourth principle of proof mentioned in section 11.5. Suppose one has to prove T(E, $) |= VX.t = u. It is sufficient to show that for all ground substitutions a : X •—> T^ it is the case that T(£,<J>) |= ta = ua (according to Theorem 11.14) or, equivalently, that ta ~ ua (according to Theorem 11.26),
Algebraic specification of abstract data types
265
Example 11.27. Consider the specification of Example 11.5(i). (i) To prove that T(E, $) \= Vn.n + Succ(Succ(0)) = Succ(Succ(Q)) + n one proves that t+Succ(Succ(0)) ~ Succ(Succ(t)) + Q for an arbitrary *€TE: t + Succ(Succ(G)) -> Succ(t + Succ(0)) -»• Succ(Succ(t) + 0) ->• Succ(Succ(t)) <- Succ(Succ(t)) + 0. (ii) To prove that T(E, $) (= V{n}.0 + n = n one proves that 0 +1 ~ t for an arbitrary i 6 IE- This may be done by induction on t (cf. Example 11.15). Clearly, a term rewriting system has similarities with a calculus for equational logic. As an advantage over the calculus it leads to an efficient proof procedure in the following particular but "frequent" case. When the term rewriting system of an initial specification (S, $) is Noetherian and confluent, the proof of T(E, $) |= VX.t = u may be replaced by a proof of the following property: for all substitutions a : X —» Tg the ground terms to and ua have the same normal form (see Theorem 11.22). The calculation of the normal form of a ground term is a straightforward procedure that allows an efficient implementation. Hence, the (main parts of the) proof of T(£, $) |= VX.t = u may be carried out automatically. Example 11.28. Consider again Example 11.27(1). One easily proves: t + Succ(Succ(<0)) ->* Succ(Succ(t)), Succ(Succ(t)) + 0 ->* Succ(Succ(t)). Hence t + Succ(Succ(0)) and Succ(Succ(t)) + Q have the same normal form, viz. the normal form of Succ(Succ(t)). Reducing proofs to the calculation of normal forms is possible only if the term rewriting system of the specification is Noetherian and confluent. Several criteria have been developed that guarantee each of these properties; they are based on Theorem 11.25 and Theorem 11.21, respectively. The Knuth-Bendix algorithm constitutes a particular implementation of these criteria: it tries to transform an initial specification sp = (S, $), the term rewriting system of which is Noetherian, into an initial specification sp1 = (E,
11.7
Rapid prototyping
Rapid prototyping consists in the evaluation of ground terms. When the term rewriting system of an initial specification is Noetherian and confluent,
266
J. Loeckx, H.-D. Ehrich and M. Wolf
rapid prototyping may be reduced to the calculation of normal forms — as will now be shown. Definition 11.29. Let (E, <J>) be an initial specification, the term rewriting system of which is Noetherian and confluent. One associates with this specification a E-algebra C defined by: C(s) = { t £ TE>S | Ha a normal form }, for each sort s of E; C(ui) = the normal form of the term n, for each operation u> = (n : —> s) of E; C (w) (ti,... , t k ) — the normal form of the term n(ti, .. .,**), for each operation (jj = (n: si x . . . x Sfc -» s) of E. Theorem 11.30. Let (S,*) and C be as in Definition 11.29. Then C is a characteristic term algebra of the initial specification (E, $). Hence Informally, the theorem states that the algebra C of Definition 11.29 may be viewed as a representative of the abstract data type defined by the initial specification (S, 4>). This justifies why the evaluation of ground terms in the algebra C may be defined as rapid prototyping. As this evaluation consists in the calculation of the normal form of these ground terms, it may be performed automatically by the term rewriting tools mentioned in section 11.6. Example 11.31. Consider the specification of Example 11.5(i). Rapid prototyping of the ground term Succ(Succ(0)) + Succ(Q) yields the ground term Succ(Succ(Succ(0))).
11.8
Initial specifications in conditional equational logic
The main definitions and theorems of sections 11.1 to 11.7 may be generalized in a straightforward way for conditional equational logic. In particular, Theorem 11.2 holds for conditional equational logic as well. The use of conditional equational logic often simplifies the design of initial specifications because it allows the expression of implications between equalities instead of equalities only. On the other hand it may be more difficult to grasp the structure of the initial algebra T(E, $) and, in particular, of its carriers; moreover, term rewriting systems and their tools are more complex (see, for example, [Klop, 1992; Padawitz, 1988]).
11.9
Comments
It is tempting to try to generalize initial specifications for logics other than equational and conditional equational logic. The following example illustrates the limits of such a generalization.
Algebraic specification of abstract data types
267
Example 11.32. Let £ be a signature with a single sort and four constants, viz. a, 5, c, d. Let $ be a set consisting of the single formula (of predicate logic): (-.a = 6 A c = d) V (a = b A -ic = d). Then Mod-s($) has no initial algebra. In fact, by Theorem 3.8 an initial algebra A has to satisfy both A(a) / A(b) and A(c) ^ A(d). Hence, it cannot be a model of $.
12
Constructive specifications
While loose specifications and initial specifications have a model-theoretic semantics, constructive specifications have an operational semantics. Hence, constructive specifications allow rapid prototyping by their very definition. The literature proposes several notions of constructive specifications, some of which lack a precise definition. The following general notion encompasses most of them. For more clarity its definition is given in three steps. Definition 12.1 (Constructive specification: abstract syntax). A
constructive specification is a triple sp = (£,4>, fic) where S = (S,fl) is a signature, $ C EL(%) a set of equations and J7C C fi a set of operations called constructors. It is required that the following three constraints are satisfied. In these constraints X is a set of variables for E, Ec = (S, fl c ) and Var(t) denotes the set of variables occurring in a term t. (i) Each equation of $ is of the form n(vt , . . . , V k ) — t with (n: Si x ... x at -> s) £ n — H c , k > 0, *>i € TSc(x),«,. for all i, 1 < i < k, and t € T^X),sMoreover, it must be the case that Var(t) C Var(n(vi,... , r^)). Finally, no variable may occur more than once in n(«i,... ,ut). (ii) For each ground term n(w\,..., Wk) of IE with (n: si x ... x Sk -» s) € ft - ftc, k > 0, u>i € Tzc,si for each i, 1 < i < k, there exists exactly one equation n(v\,... ,Vk) = t 6 $ and exactly one ground substitution a : Var(n(vi,... ,Vk)) —> T^c such that Wi = Via for all i, 1 < i < k. (iii) There exists a reduction ordering "<" such that t < n(v\,..., Vk) for each equation H ( V I , . . . , Vk) = t € $.
Informally, constraints (i) and (ii) make $ look like a (generalized version of a) recursive function definition in the theory of computability. Constraint
268
J. Loeckx, H.-D. Ehrich and M. Wolf
(iii) makes sure that the calculation of the value of a ground term terminates (see Definition 12.3). The concrete syntax for constructive specifications is chosen to be similar to that of an initial specification but with constructive instead of initial and with constr preceding B each constructor in the list- of -operations. Example 12.2. constructive spec sorts nat opns constr 0 : —» nat constr Succ : nat —)• nat - + . : nat x nat —¥ nat vars m, n: nat eqns m + 0 = 0
m + Succ(n) = Succ(m + n) endspec The reader having difficulties checking that constraints (ii) and (iii) of Definition 12.1 are satisfied may wait for the remarks preceding Example 12.6. Definition 12.3 (Constructive specification: semantics). Let sp = (£,$,n c ) be a constructive specification with S = (5, fl). Put Sc = (5, flc). The meaning M.(sp) of sp is the monomorphic abstract data type M(sp) = { A 6 Alg(E) \ A ~ C } where C is the E-algebra defined by: (i) C(s) = T EcjS for each sort s € 5; (ii) C(uj) = n for each constant u> = (n: —> s) € fic; (iii) C(u)(wi,...,Wk) = n(wi,...,Wk) for each u = (n:si x . . . x Sk -> s) € (7C, k > 1, and all tUj € Tsc<Si, (iv)
C(w)(wi,...,wk) for each w = (n:si x . . . xs^ -» s) € fi — n c , k > 0, and all Wi € 7s c>Si , 1 < i < k, where t and a are defined as follows: t is the right-hand side of the uni vocally defined equation n(vi,...,Vk) = t € $ and a : Var(n(vi, . . . ,Vk)) —> TSC is the univocally defined substitution for which vna — Wi, 1 < i < k, guaranteed by constraint (ii) of Definition 12.1.
The semantics M (sp) is constructive in that the specification sp constitutes an explicit definition of the algebra C and, more importantly, because the value C(t) of an arbitrary ground term t € IE may be effectively computed in finite time— as expressed by the following theorem: Theorem 12.4. Let sp = (S,$,fi c ) and C be as in Definition 12.3. For any ground term t 6 TS the computation of the value C(t) is finite and yields a unique result.
Algebraic specification of abstract data types
269
A precise definition of the notion of a computation of the value C(t) and a proof of the theorem may be found in [Loeckx et al., 1996]. Clearly, the proof of finiteness is founded on constraint (iii) of Definition 12.1. A computation resembles term rewriting with the algebra C behaving as a characteristic term algebra. While the semantics of loose specifications is based on model theory and that of initial specification on term algebras and quotients, the semantics of constructive specifications is operational. The following theorem shows a relation between these three semantics. As constructive specifications may be viewed as programs, the theorem also shows that the difference between specifications and programs is not sharp. Theorem 12.5. Let sp = (E,$,n c ) be a constructive specification with E = (5, fi). Call spL the loose specification with free constructors (S, $, S, fic) and spj the initial specification (£,$). Then M(sp) = M(spL) = M(sPl). Of course, due to the constraints of Definition 12.1 constructive specifications are in some sense less abstract than initial specifications. Similarly, loose specification with free constructors allow, for instance, no "abstract" specification of sets (see Examples ll.S.(ii) and Example 13.11). They are less expressive than loose specifications because—similarly to initial specifications—they can only define monomorphic abstract data types. Nevertheless, in concrete "practical" examples the difference between initial and constructive specifications is often purely notational as is illustrated by Examples 11.5(i) and 12.2. A similar remark holds for loose specifications with free constructors where the abstract data type defined is monomorphic (cf. Example 10.9). The design of a constructive specification faces the problem of checking constraints (i) to (iii) of Definition 12.1. Actually, checking constraint (i) is trivial. Constraint (ii) is verified when the left-hand sides of the equations for any operation of fl — Oc constitute a "complete set of constructor patterns". A precise definition of this notion, which is based on the "unfolding" of variables, may, for instance, be found in [Loeckx et al., 1996]. Complete sets of constructor patterns of the operation "+" of Example 12.2 are, for instance:
{n + m}, {n + 0, n + Succ(m)}, {0 + m, Succ(n) + m}, {0 + 0, Succ(n) + 0,0 + Swcc(m), Succ(ri) + Swcc(m)}, {n + Q,n + Succ(0),n + Succ(Succ(m))}. Finally, a sufficient condition for constraint (iii) is the following: the operations of fZ — fic may be written as w i , . . . , wj, I > 0, such that for each equation n(v\,..., Vk) — t of $, u>i — (n : s\ x ... x Sk —> s):
270
J. Loeckx, H.-D. Ehrich and M. Wolf
• for each subterm n(ti,...,tk) of t, each ti is a subterm of Uj, 1 < i < A;; moreover, there exists j, 1 < j• < fc, such that tj is a proper subterm of Wj . The specification of Example 12.2 satisfies these conditions. A more elaborate example is the following: Example 12.6. The example consists of the constructive specification of Example 12.2 with the additional sort bool, the additional constructors True : —> bool, False : -> bool, the additional operations _ < _: nat x nat —> nat, Even : nat —> bool and the additional equations 0 < n = True, Succ(m) < 0 = False, Succ(m) < Succ(n) = m < n, Even(Q) = True, Even(Succ(0)) = False, Even(Succ(Succ(m))) = Even(m). More details on constructive specifications and on the checking of their constraints as well as a generalization for conditional equational logic may be found in [Loeckx et al., 1996; Loeckx, 1997].
13
Specification languages
As already mentioned in section 9, a specification language allows "large" specifications to be constructed out of "small" ones. The basic building blocks in this construction are the specifications obtained by specificationin-the-small, i.e. the atomic specifications designed along the principles presented in sections 10 to 12. The present section is concerned with the principles of specification languages without modularization and parameterization; these concepts will be investigated in section 14. Several more or less tentative specification languages have been proposed in the literature: CLEAR [Burstall and Goguen, 1980], ASL [Wirsing, 1986], ACT ONE [Classen et al, 1993; Classen, 1989], PLUSS [Bidoit, 1989; Bidoit, 1991], Larch [Guttag et al, 1985; Guttag and Horning, 1993], OBJ 3 [Goguen and Winkler, 1988], OBSCURE [Lehmann and Loeckx, 1993], and Spectrum [Broy et al., 1993]. A more detailed overview may be found in [Wirsing, 1995; Sannella and Wirsing, 1999]. A very general language, called CASL, is presently being developed by an international Working Group (see, for instance, [protectSannella, 1999; Mosses, 1999]); the release of the final version of this language scheduled for the end of
Algebraic specification of abstract data types
271
the year 2000. In this section and in section 14 a very simple specification language is described that encompasses the main features of these different languages.
13.1
A simple specification language
The specification language introduced below is a very elementary one and is called SL. Two additional constructs will be added in section 13.2. The specification language is general in that it fixes neither the nature of the atomic specifications nor the logic. According to its abstract syntax, the language is defined as a set of "specifications". With each specification, say sp, is associated a signature S(sp). Definition 13.1 (Abstract syntax of the specification language SL). The set of specifications sp of the specification language SL and their signatures S(sp) are defined inductively: (i) any atomic specification of sections 10 to 12, say at, is a specification; S(at) is defined to be the signature of this atomic specification; (ii) (union) if spi and sp2 are specifications, then
(iii)
(iv)
(v)
(vi)
is a specification with S(spl + sp2) = S(spl) (renaming) if sp is a specification and // : <S(sp) —>• £' a renaming, then (rename sp by n) is a specification with <S((rename sp by //)) = fj,(S(sp)); (forgetting) if sp is a specification, S a set of sorts and fl a set of operations such that (5, 0) C S(sp) and S(sp) — (S, f2) is a signature, then (sp forget (5, fl)) is a specification with S(sp forget (5,17)) = S(sp) — (5, fi); (extension) if sp is a specification, S a set of sorts and ft a set of operations such that S(sp) U (5, H) is a signature, then (extend sp by (5, ft)) is a specification with <S(extend sp by (S, ft)) = S(sp) U (5, H)); (modelling) if sp is a specification and 4> C L(S(sp)) for some logic L, then
(sp model $) is a specification with S(sp model $) = S(sp); (vii) (restriction) if sp is a specification with S(sp) = (5,0), if 5C C 5 and if Qc C fj is a set of operations with target sorts in Sc, then (sp generated in Sc by Qc)
272
J. Loeckx, H.-D. Ehrich and M. Wolf and
(sp freely generated in Sc by flc) are specifications with <S(sp generated in Sc by H c )
= S(sp freely generated in Sc by ttc) = S(sp). It is easy to show that S(sp) is a signature for any specification sp. Additional syntactical conditions may even guarantee that S(sp) is strongly typed (cf. Definition 3.2). It is understood that parentheses may be deleted if no ambiguity arises. Again, in the examples the abstract syntax is replaced by a concrete one. In this concrete syntax a pair (S, ft) consisting of a set of sorts and a set of operations is again written as sorts opns
list-of-sorts list-of-operations
and a set $ of formulas as vars list-of-variables axioms list-of-formulas Finally, a renaming ^ : S —> E' is written sorts si,...,8k opns u > \ , . . . , u j i as sorts s(,..., s'k opns LJ{ ,..., u\ with S i , . . . , s/c and s(,..., s'k sorts of S and E' respectively, k > 0, and with ui,...,u>i and u > [ , . . . ,u[ operations of E and £' respectively, I > 0. The renaming p, = (us, A*fi) defined by this concrete syntax is , ,. _ J s'i if s = Si for some i, 1 < i'. < k, \ s otherwise, j'j
if u = (jjj for some j, I < j < I, if u = (n: Si x ... x sk —>• s) ^ ujj for all j, 1 < j < /.
Note that the concrete syntax has to satisfy several "context conditions" lest /z fails to be a renaming. For instance, the sorts s{,..., s'k have to be pair wise different. The constructs of the specification language are interpreted as operations on classes of algebras. Alternative semantics descriptions will be briefly described in section 13.8. Definition 13.2 (Semantics of the specification language SL). The meaning M. (sp) of a specification sp of the language SL is defined inductively and follows the structure and notation of Definition 13.1:
Algebraic specification of abstract data types
273
(i) the meaning M(at) of an atomic specification at is the abstract data type defined by this atomic specification according to sections 10 to 12; (ii) M(sp! + sp2) = {Ae Alg(S(sPl + sp2)) | (A \ S(sPl}) 6 M(sPl), (A\S(sp2))eM(sp2)}; (ui) X(rename sp by /z) = {A £. Alg(p,(S(sp))) \ (A \ n) 6 M ( s p ) } ; (iv) M(sp forget (5,0)) = (M(sp)) \ (S(sp) - (5,0)); (v) Ai(extend sp by (5,0)) = { A e Alg(S(sp) U (5,0)) | (A \ S(sp)} € M(sp) }; (vi) M(sp model $) = M(sp) n Mods(sp)($)\ (vii) M(sp generated in 5C by Oc) = { A 6 .M(sp) | ^4 is generated in Sc by Oc } .M(sp freely generated in 5C by O c ) = { A € M(sp) I A is freely generated in 5C by Oc }. Informally, the construct "+" builds a persistent extension of M(spl) and M(sp2) (see Definition 5.10(ii)); note that, if S(spl) and S(sp2) are not disjoint, only those algebras of .M(spi) and M(sp2), the common parts of which "coincide", contribute to the result. The construct rename merely performs a renaming of sorts and operations because /j. is bijective. The construct forget drops sorts and operations. The construct extend adds "loose" sorts and operations. The construct model filters out the algebras that are not models of $; a similar remark holds for generated and freely generated. It is easy to show that M(sp) is an abstract data type of signature S(sp) for any specification sp. Prom a user's point of view the construct "+" allows specifications to be put together. The construct rename allows more appropriate names to be introduced or name collisions to be avoided during a subsequent application of the construct "+". The construct forget allows deletion of sorts and operations that are no longer needed. The construct extend together with the constructs model, generated and freely generated allows sorts and operations to be added and the model class to be restricted, respectively. A non-trivial example of a specification is far too lengthy to be presented here. Moreover, the specification language SL is too elementary to allow elegant descriptions. Hence, the goal of the following example is merely to illustrate the concepts introduced. Example 13.3. The atomic specifications used within the following specification are loose ones with free constructors: ((extend (loose spec sorts freely generated bool opns constr True : -4 bool constr False: -> bool
274
J. Loeckx, H.-D. Ehrich and M. Wolf
endspec + loose spec sorts freely generated nat opns constr 0: —> nat constr Succ: nat —> nat endspec) by opns _ < - : nat x nat -» bool) model vars m,n:nat axioms 0 < n = True Succ(m) < 0 = False Succ(m) < Succ(n) = m < n)
13.2
Two further language constructs
The semantics of the constructs extend and model of the specification language introduced above has a loose flavour that is illustrated by the following fact. An atomic loose specification (S, $) has the same semantics as the specification: (extend e by S) model $ where e stands for a specification defining the abstract data type for the empty signature. The present section introduces two additional similar constructs that have an initial rather than loose flavour. It is necessary first to introduce two notions that may be viewed as a generalization of the notion of an initial algebra and of a quotient term algebra, respectively. Their definition is somewhat technical and may be difficult to understand at first reading. A more detailed treatment of the subject may be found in textbooks such as [Loeckx et al., 1996]. Definition 13.4 (Free extension). Let E, E' be signatures with E C S ' . Let A be a E-algebra and C' a class of S'-algebras. (i) A homomorphic extension of A for (E',C') is a pair (B',g) where B' € C' and where g : A —>• B' \ E is a E-homomorphism. (ii) A free extension of A for (E',C') is a homomorphic extension (E',q) of A for (S',C') such that for each homomorphic extension (B',g) of A for (S',C') there exists exactly one E'-homomorphism h' : E' —> B' with g = (h11 E) o q. (iii) If C' = Mods- ($') where $' C L(E') is a set of formulas for some logic L, one speaks of a homomorphic extension and a free extension of A for (£',*')• If the homomorphism q of a free extension (E',q) is known, it is common practice to identify the algebra E' with (E',q) and to speak of the free extension E'.
Algebraic specification of abstract data types
275
E'
ft1 IE
h' B'
Fig. 2. Illustration of Definition 13.4 Informally, a homomorphic extension is an algebra of C' that is related to A by a homomorphism. Prom a free extension both components B1 and g of an extension (B',g) may be "reached" by a unique homomorphism h'. The definition is illustrated by Figure 2. The use of this graphical representation may be helpful in understanding proofs. Clearly, the notion of a free extension for (E',C') coincides with the notion of an initial algebra of C', when the signature E is empty. Definition 13.5 (Quotient term extension). Let £ = (S, fi), E' = (5', fi') be signatures with £ C E'. Let A be a E-algebra and $' C ££(£') a set of equations. Write • 0.4 = { ca : —>• s \ a <E A(s), s 6 5 } where each ca : —>• s is a "new" constant;
• EC = (s, n u oo, E; = (5', n' u oo; • Ac for the Ec-algebra identical with A but with, additionally, Ac(ca '• -* s) = a for each new constant ca : -» s of fi^; • & = $' U Th^Ac) with ThGEL(Ac) = {(t = u)£ ThEi(Ac) \ t,u € TSc } (i.e. Th^^Ac) consists of the ground equations of ThsL^c))The quotient term extension of the E-algebra A for (E', <£') is the S'-algebra A(E', *') defined as
Informally, the quotient term extension ^4(E', $') is similar to the quotient term algebra T(E', $') but possesses in addition all "equational properties" of ^4. This results from the addition of the ground equations of the equational theory of A to $'. This, in its turn, required the introduction of the constants ca allowing "access" to each carrier of A. The following corollary constitutes a generalization of Theorem 11.2. Corollary 13.6. Let E, E' be signatures with E C E'. Let A be a £algebra and let $' C EL(H'). The quotient term extension A(E',$') is a
276
J. Loeckx, H.-D. Ehrich and M. Wolf
model of $'. Example 13.7. Let £ and A be as in Example 4.9. Let 6,61,62: el and /: list be variables and $ = {Add(e,Add(e,l)) = Add(e,l), Add(e1,Add(e-2,l)) = Add(e2,Add(ei,l))}. Consider the quotient term extension A(£, $) of A for (£, $). Then A(£,$) ~ £ with £(e/) = ^(ei), B(/ist) is the set of all finite sets of elements from B(el), B([]) is the empty set and B(Add)(e, s) = sU{e} for all e 6 B(el) and s € B(list). The following theorem shows that all free extensions coincide with the quotient term extension up to isomorphism. It constitutes a generalization of Corollary 11.3. Theorem 13.8. Let £, S' be signatures with £ C £', let A be a ^-algebra and let $' C EL(S'). Let A(Z',&) be the quotient term algebra of A for (£',$') and q : A —» A(E',$') | £ its associated homomorphism. (i) E' ~ A(£', $') for any free extension (E', r) of A for (£', $'). («J IfE' ~ A(£',$') according to the isomorphism i' : A(£',$') —> E', then (E1, (V \ £) o q) is a free extension of A for (£', $'). By the way, the preceding theorem allows a free extension (E',r) to be identified with the algebra E': according to part (ii) of the theorem the homomorphism r is uniquely determined by E1 (cf. the remark at the end of Definition 13.4). Moreover, part (i) of the theorem allows the free extension E' of A for (£', $') to be identified with the algebra -A(£', $')• In building a free extension of an algebra A the carrier sets may be modified by a factorization—as illustrated in Example 13.7. The following property expresses the fact that the carrier sets remain unchanged—up to isomorphism. Definition 13.9 (Persistent free extension). Let £, £' be signatures with £ C £', let A be a £-algebra and let $' C ££(£'). Also let E1 be a free extension of A for (£', $') and i' : A(E', $') —> E' the corresponding isomorphism. Call q : A —> A(£',$') £ the homomorphism associated with the quotient term algebra j4(£',$'). The free extension E' is called persistent when the homomorphism (i1 | £) o q : A —->• E' \ £ is an isomorphism. Finally, it is possible to introduce the "initial counterparts" of the language constructs extend and model. Definition 13.10 (Two further constructs of the specification language SL). The abstract syntax of the specification language of Definition 13.1 is augmented by two cases:
Algebraic specification of abstract data types
277
(viii) if sp is a specification, S a set of sorts and ft a set of operations such that S(sp) U (5, ft) is a signature, then (freely extend sp by (S, ft)) is a specification with S(freely extend sp by (5, ft)) = S(sp) U (5, ft); (ix) if sp is a specification and $ C EL(S(sp)) a set of equations then (sp quotient $) is a specification with S(sp quotient $) = S(sp). The semantics of Definition 13.2 is accordingly augmented by the cases: (viii) M(freely extend sp by (5, ft)) = { £' 6 Alg(Z') | E' is a free extension of A for (S', 0), AeM(sp) } where S' = S(sp) U (5, ft); (ix) M.(sp quotient $) = { E € 4fy(£) | E is a free extension of A for (S, $), where S = Informally, in contrast with the construct extend, the construct freely extend replaces each algebra of M(sp) by its free extensions rather than by all possible extensions. Similarly, while model removes the algebras that fail to be a model, quotient presses all algebras into a mould by factorization. Hence, when no algebras of sp happen to be a model of 4>, (sp model $) is the empty class of algebras while (sp quotient $) consists of algebras with carrier sets consisting of a singleton. More generally, in contrast with the constructs of the specification language, freely extend and quotient may modify the algebras to which they are applied: whenever the free extension is not persistent, freely extend adds carriers and quotient identifies carriers by factorization. Note that an initial (atomic) specification (E, ) has the same semantics as the specification: (freely extend e by (S,ft)) quotient $ where e stands for the specification defining the abstract data type for the empty signature. The following examples illustrate that the construct quotient may also be used to overcome a deficiency of loose specifications with free constructors and of constructive specifications. As already indicated, these specifications fail to lead to an "elegant" or "abstract" description of abstract data types, the carrier sets of which cannot be represented in a "natural
278
J. Loeckx, H.-D. Ehrich and M. Wolf
way" by a term language. The classical example of such a data type is "set" (cf. Example 11.5(ii)). Example 13.11. Informally, the construct quotient makes sets out of lists; the construct rename introduces more appropriate names: rename ((loose spec sorts el, freely generated list opns constr [ ] : — ) • list constr Add: el x list -»• list endspec) quotient (vars 6,61,62: el, I: list
eqnsAdd(e,Add(e,l)) = Add(e,l) Add(ei,Add(e2,l)) = Add(e2,Add(el,l)}))
by sorts list opns [ ]: —» list
Add: el x list -> list as sorts set opns 0 : —» set Add: el x set -» set
13.3
Adding an environment
While a specification language such as the one described above allows specifications to be "structured", a non-trivial specification is a long piece of text. The idea is to cut this text into "small" specifications and to give them names according to a technique that is classical in programming. To this end it is necessary to add an "environment" mapping names into "environment-dependent specifications"—henceforth called "especifications". A specification then consists of an e-specification together with an environment. While this idea is simple, the corresponding definition is somewhat subtle. In fact, as the notions of an "environment" and of an "e-specification" are interrelated, their inductive definition has to be simultaneous. The definition implicitly makes use of a set of names not further defined. Definition 13.12 (Environment, abstract syntax of e-speciflcations). The notions of an environment, of an e-specification, of the signature of an e-specification in an environment and of the relation "is an e-specification for the environment" are defined by simultaneous induction. Note that an environment is defined to be a partial function: (i) an atomic specification, say at, is an e-specification for the everywhere undefined environment; the signature S(at)(env) of this especification in the environment env is the signature of the atomic specification at;
Algebraic specification of abstract data types
279
(ii) if esp1 and esp2 are e-specifications for the environment env, then (espl + esp2) is an e-specification for the environment env; the signature of this e-specification in the environment env is S(espl + esp2)(env) = S(espl)(env)
(JS(esp2)(env);
(iii) to (ix): as (iii) to (ix) of Definition 13.1 and (the first part of) Definition 13.10 but with: • "e-specification for the environment env" instead of "specification" ; • "S(.. .)(env)" instead of "£(...)" where "..." stands for an (e-)specification; (x) if env is an environment and n a name such that env(n) is defined, then n is an e-specification for the environment env; the signature of the e-specification n in the environment env is S(n)(env) = S(env (n)) (env}; (xi) the everywhere undefined function is an environment; (xii) if env is an environment, n a name such that env(ri) is undefined and esp an e-specification for the environment env, then env[esp/n] is an environment (where env[esp/n] is identical with env except for (env[esp/n])(n) •=• esp); (xiii) an e-specification for an environment env is also an e-specification for an environment env1, whenever env C env'. Informally, an e-specification according to this definition is a specification according to Definition 13.1, it being understood that a name is also an e-specification. If esp is an e-specification for the environment env, then env(n) is defined for each name n occurring in esp. Finally, an environment env contains no "recursive calls" in the sense that there exists no sequence HI ,..., rik of names, fc > 1, such that: • env(ni) contains an occurrence of rij + i, 1 < i < k — 1; • env(rik) contains an occurrence of n\. The following definition fixes the meaning of an e-specification in an environment. Definition 13.13 (Semantics of e-specifications). Let esp be an e-
-specification for the environment env. The meaning M.(esp)(env) of esp in env is defined inductively according to cases (i) to (x) of Definition 13.12: (i) M(at)(env) is the abstract data type defined by the atomic specification at; (ii) M(esp1 + espz)(env) = {A 6 Alg(S(esp1 + esp%)(env)) \
280
J. Loeckx, H.-D. Ehrich and M. Wolf
(A | S(esp1)(env)) e M(espl)(env), (A j S(esp2)(env)) € M(esp2)(env) }; (iii) to (ix): similar to (ii) and in accordance with Definition 13.2 and (the second part of) Definition 13.10; (x) Ai(n)(env) = M (env (n)) (env). It is now possible to define a specification language with an environment. This specification language is called e-SL; syntactically it consists of a set of pairs called "specifications" . Definition 13.14 (The specification language e-SL). (i) (Abstract syntax.) A specification of the specification language e-SL is a pair (env, esp) where esp is an e-specification for the environment env. Its signature is S((env, esp)) — S(esp)(env). (ii) (Semantics.) The meaning of a specification (env, esp) of the language e-SL is the abstract data type M((env, esp)) = M(esp)(env). Again, it is possible to introduce a concrete syntax. One then writes decl; esp instead of (env, esp). In this notation decl stands for a string called a "declaration". The set of all declarations decl and the environments £(decl) they describe are defined inductively: (i) the empty string e is a declaration; it describes the environment £(e) = the everywhere undefined function; (ii) if decl is a declaration, if esp is an e-specification for the environment £(decl) and if n is a name for which £(decl)(ri) is undefined, then decl; n is esp is a declaration; it describes the environment £(decl;n is esp) = (£(decl))[esp/n\. Example 13.15. The specification of Example 13.3 may now be written in a more readable way: BOOL is loose spec sorts freely generated bool opns constr True : -> bool constr False : —> bool endspec; NAT is loose spec sorts freely generated nat opns constr 0 : —» nat constr Succ : nat —» nat endspec; extend (BOOL + NAT)
Algebraic specification of abstract data types
281
by opns _ < _ : nat x nat —)• nat model vars m, n: nat axioms 0 < n = True Succ(m) < 0 = False Succ(m) < Succ(n) = m
13.4
Flattening
Flattening consists in "translating" a specification into an atomic specification with the same meaning. The reason for our interest in flattening will become clear in sections 13.5 and 13.6. In the process of flattening, constructs such as rename and forget lead to some minor problems of a syntactical nature. The other constructs of the specification language SL lead to semantical problems, some of which are undecidable. The following comments illustrate some of these problems. For more simplicity they refer to the specification language SL of sections 13.1 and 13.2. Fact 13.16. (i) Let spt = (Si,$!), sp-2 = (£2,^2) be loose specifications (in the sense of Definition 10.1). Then Ai(spl + sp2) = M(sp), where sp is the loose specification ( S i U £ 2 , $ i U $ 2 ) (ii) Let sp = (£,$) be a loose specification in a logic L. Let S be a set of sorts and (7 a set of operations such that £ U (5, fi) is a signature; let \P C £,(£ U (S, Q)) be a set of formulas. Then ^(extend sp by (S, fi) model $) = M(sp') where sp' is the loose specification (£ U (S, ft), * U #). This fact does not hold for initial specifications, loose specifications with (free) constructors or constructive specifications. Fact 13.17. Let sp = (£,$) be an initial specification. Let S and fi be such that £ U (S, H) is a signature and let * C EL(£, U (5, fi)). Then .M(freely extend sp by (5,0) quotient <£) = M(sp') where sp1 is the initial specification (E U (5, fi), $ U *). Again, the fact does not hold for loose specifications or constructive specifications. As flattening has been studied in some detail for initial specifications, additional properties for this particular case can be found in the literature (see, for example, [Ehrig and Mahr, 1985]). A similar approach to deriving so-called "normal forms" of structured specifications can be found in [Wirsing, 1993].
282
J. Loeckx, H.-D. Ehrich and M. Wolf
13.5
Properties and proofs
A first family of properties refers to the constructs of the specification language. Typical properties one may want to prove are: • M(spl + sp2) is a persistent extension of M(spi), i = 1,2 (in the sense of Definition 5.10); • .M(extend sp by (5, fi) model $) is a persistent extension of M(sp); • each algebra of M(freely extend sp by (S, fi) quotient $) is a persistent free extension of an algebra of M(sp) (in the sense of Definition 13.9). While these properties are undecidable in the general case, the latter one has been studied to some extent in the literature on initial specifications (see, for example, [Ehrig and Mahr, 1985]). A further family of properties refers to the abstract data type defined by a specification (cf. section 9). By flattening the specification the proof of such a property is reduced to a proof for an atomic specification. Alternatively, it is possible to develop a calculus for the specification language that reduces the property of a specification to properties of the atomic specifications contained by it. In this way the proof is again reduced to proofs for atomic specifications. An example of such a calculus is given in [Wirsing, 1993; Bidoit et a/., 1999].
13.6
Rapid prototyping
There are two methods that allow the rapid prototyping of a specification. The first method is based on "compilation" and consists in first flattening the specification into an atomic specification that allows rapid prototyping. The second method is based on "interpretation" and makes use of a program that "interprets" the different constructs. This method is particularly simple when the atomic specifications contained by the specification are constructive (see e.g. [Loeckx and Zeyer, 1995]).
13.7
Further language constructs
The specification languages SL or e-SL may be extended in two ways. First, it is possible to introduce additional constructs by defining them as "macros". While these constructs do not increase the expressive power of the language, they may be very useful by simplifying the notation. Second, it is possible to introduce additional language constructs. An example is the construct of "amalgamated union" which constitutes a generalization of the construct "union" (i.e. "+") and which will now be briefly described. Informally, the amalgamated union avoids name clashes through automatic renaming and thus reduces the number of algebras disregarded by "+".
Algebraic specification of abstract data types
283
Definition 13.18 (Amalgamated union: abstract syntax). (i) (Abstract syntax.) If spl and sp2 are specifications and if 5 is a set of sorts and J) a set of operations with (5, 17) C S(spi) C\S(sp2), then (sPi +(s,fi) sPz) is a specification with S(spl +(s,n) sp2) — A*i(«S(sPi)) U M2(<S(«P 2 )); in this definition Hi and /*2 are the surjective signature morphisms univocally defined as follows:
.
/, f*\ - / s if s € S or s PiW - j s> otherwise for all sorts s 6 S(sp1),
s» otherwise for all sorts s e S(sp2), n:m(s1) x ... x if w 6 (7 or u & S(sp2), n':/ii(si) x ... x fj,i(sk) —t/j,i(s) otherwise for all operations w = (n: si x . . . x sfc -> s) e 5(5;?!), fc > 0, • ^(w) defined similarly, where s', s", . .., n', ... are "new", pairwise different sorts and operation names. (ii) (Semantics.) M(sp1 +(s,n) SP2) — and
(
By the way, as "+s,n" may be defined as a macro with the help of "rename" and "+" , it does not increase the expressiveness of the language.
13.8
Alternative semantics description
The semantics of the specification language was defined above as a function M mapping specifications into abstract data types. This method for describing the semantics is called model- oriented. There exist other description methods, two of which will be briefly discussed. Each of these methods naturally leads to a slightly different semantics of some of the language constructs. According to the specification- oriented (also called presentation-oriented) description method the semantics of a specification language is a function AT mapping specifications into atomic specifications defining the same abstract data type. Assume that Af maps specifications into atomic loose specifications or, alternatively, into atomic initial specifications. Two examples of the semantics of the language constructs are: Af(at)
— at for any atomic specification at;
284
J. Loeckx, H.-D. Ehrich and M. Wolf
with E!, £ 2 , *i, $2 defined by ./V(spi) = (£i,*i) and.W(sp 2 ) = (£ 2 ,$ 2 ). An advantage of this description method is that flattening is explicit. A drawback is that the nature of the atomic specifications has to be fixed and, more importantly, the semantics of some constructs may be less transparent. According to the theory-oriented description method the semantics is a function T mapping specifications into theories. Two examples are: T(at) = $* for the atomic specification at = (£, $); T(*PI + sp2) = (T(sPl) U T(sp2))*. A more detailed description of these alternative semantics classically makes use of some additional notions. The following definition is intended to help the reader in consulting the relevant literature. Definition 13.19 (Theory morphism, specification morphism, hierarchical specification). Let L be a logic, // : £ —>• £' a signature morphism and $ C L(E), $' C £(£')• (i) The signature morphism fj, is called a theory morphism and one writes p, : $* —» <J>'* if 4>' is a /^-extension of $ (cf. Definition 7.25). (ii) The signature morphism /z is called a specification morphism and one writes fj, : (£, $) —>• (£', $') if // : $* —» $'* is a theory morphism. (iii) The pair ((£,), (E',$')) is called a hierarchical specification if the signature morphism n is an inclusion and fj, : (E, $) —>• (E', $') is a specification morphism.
14
Modularization and parameterization
The specification languages discussed above have two shortcomings. First, they are concerned with algebras and thus implicitly suggest a bottom-up design of specifications. A more general design would require the possibility of handling incomplete specifications, say "specification pieces". Next, the languages do not support reusability. This would require the possibility of providing "specification pieces" with parameters. Sections 14.1 to 14.3 introduce a notion of "specification piece", henceforth called "module specification" . A facility for parameterization is proposed in section 14.4.
14.1
Modularized abstract data types
Informally, modularized abstract data types are the objects to be specified by the module specifications to be introduced in sections 14.2 and 14.3. Definition 14.1 (Module signature). A module signature is a pair (Si, Se) of signatures; £j and Se are called the import signature and export signature, respectively. A sort or operation from the signature Ej n Se is called inherited.
Algebraic specification of abstract data types
285
A graphical representation of the module signature (E,, E e ) with ,r},{ui,u2}), Ee = ({s},{wi,w3}) is:
The dotted lines characterize the inherited sorts and operations. Definition 14.2 (Modularized abstract data type). (i) A modularized abstract data type for the module signature (Ej,E e ), or (S,, E e )-modwJe for short, is a (total) function F : such that the class F(A) is an abstract data type for each A € Alg(£i)i in this definition Clas9(£e) denotes the "collection" of all classes of Ee-algebras. (ii) A (Sj,£e)-module F is called persistent if for each A e Alg(Si): for each B € It is called consistent if F(^4) ^ 0 for each A € (iii) A (Sj, Ee)-module F is called monomorphic if F(A) is monomorphic for each A € Alg(Ei). Informally, persistency expresses the fact that inherited sorts and operations have the "same" meaning in A and F(A); consistency expresses the fact that the mapping F is "effective" . Clearly, an abstract data type (in the sense of Definition 2.15) may be viewed as a module with an empty import signature.
14.2
Atomic module specifications
The different atomic specifications of sections 10 to 12 are now generalized for module specifications. By way of restriction, only module signatures (Ej, E e ) with Sj C Ee are considered. This restriction is irrelevant because
286
J. Loeckx, H.-D. Ehrich and M. Wolf
the constructs forget and export rename of the specification language of section 14.3 will allow modules with S, £ Se to be obtained. First, the case of loose specifications is treated (cf. Definition 10.1). Definition 14.3 (Loose module specification). Let L be a logic. (i) (Abstract syntax.) A loose module specification in L is a pair msp = ((S,,E e ),$) where (£j,£ e ) is a module signature with Sj C Ee and where $ C L(E e ) is a set of formulas. (ii) (Semantics.) The meaning of the loose module specification msp — ((£;, £ e ), $) is the module M(msp) defined by M(msp)(A) = {B& Alg^e) B \= $ and (B \ £,) ~ A} for each A 6 Alg(Tn). Clearly, the meaning of a loose module specification is persistent but not necessarily consistent. A possible concrete syntax is like that for loose specifications of section 10.1 but with the keyword import preceding each sort and operation of the import signature and with mspec instead of spec. Example 14.4. The following example is similar to Example 10.2: loose mspec sorts list, import bool, import el opns import True: -> bool import False : —>• bool
[ ]: -4 list Add: el x list —>• list - . - : list x list —> list Isprefix: list x list -> list vars l,m,n: list,e: el axioms [ ]./ = / Add(e, l).m — Add(e,l.m) (Isprefix(l,m) — True) = (3n.(m = l.n)) endmspec Hence, S; = ({bool, el}, {True, False}) and Se = ^t\j({list}, {[ ], Add,...}). Informally, the module specification specifies lists. The abstract data types bool and el are to be defined "elsewhere". Clearly, the abstract data type el is intended to be a parameter. Loose module specifications with constructors and/or free constructors may be defined similarly. Next, the case of initial specifications is treated (cf. section 11.1). Definition 14.5 (Initial module specification).
(i) (Abstract syntax.) An initial module specification in equational logic is a pair msp = ((Sj, £«=),$) where (Sj,S e ) is a module signature with EJ C Ee and where $ C EL(T,e) is a set of equations.
Algebraic specification of abstract data types
287
(ii) (Semantics.) The meaning of the initial module specification msp = ((£j,£ e ),$) is the module M(msp) defined by M(msp)(A) — {B^Alg(T,e)\ B is a free extension of A for(E e ,*)} for each A € Alg(Ei) (cf. Definition 13.4). Clearly, the meaning of an initial module specification is consistent; it is persistent only if for each A € Alg(Y,i) the free extension of A for (S e ,$) is persistent (cf. Definition 13.4). Constructive module specifications may be defined similarly. Their meaning is persistent and consistent. By the way, loose module specifications may be simulated by normal specifications in the following sense. If msp = ((Ej,E e ),$), £{ C £ e , is a loose module specification, consider the loose specification sp = (E e , <£). Then M(sp) = {M(map)(A) \ At Alg^}}. In other words, a loose module specification differs from a loose specification only by the fact that the sorts and operations to be specified "elsewhere", i.e. those of £$, are explicitly marked by the keyword import. Note that this remark does not hold for initial or constructive module specifications.
14.3
A modularized specification language
An elementary modularized specification language, called MSL, is presented. Like the specification language SL presented in sections 13.1 and 13.2, it is not designed for practical use but merely tries to capture the main features of the modularized specification languages presented in the literature. Again, the following definition associates with each module specification msp a module signature S(msp). The goal of the different "context conditions" contained in the definition is essentially to avoid name clashes between the export and import signatures and thus preserve the property of persistency. Definition 14.6 (Abstract syntax of the modularized specification language MSL). The set of module specifications msp of the language MSL and their module signatures S(msp) are defined inductively: (i) any atomic module specification atm is a module specification; S(atm) is the module signature of this atomic module specification; (ii) if mspl and msp2 are module specifications with <S(mspj) — (Sit, £i e ), S(msp2) = (£ 2 i,£2e) and if • each sort and each operation of H\e fl S2i is inherited in • each sort and each operation of E 2e n SH is inherited in
J. Loeckx, H.-D. Ehrich and M. Wolf
288
\[^
e U S2e
ji
Se
1l
m^ »P2
/i
Ei.
msj»,
77k!Oo
1
yl
'£1,
i1 E mt'Pi
S2i
I ^i
^'
j
EH US? . (a) Illustration of Wispj + msp^
VI.
(b) Illustration of msp2
Fig. 3. Illustration of the syntax of the constructs "+" and "o" of the modularized specification language MSL. S(msp2), then
(msp1 is a module specification with S(mspl + msp2) = (E^ U £2*, Sie U S2e) (cf- Figure 3(a)); (iii)
if mspi and msp2 are module signatures with t^mspj) = (£j,E), S(msp2) = (E,E e ), then
is a module specification with S(msp2°msp1 ) = (£j, E e ) (cf. Figure
(iv)
if msp is a module specification with // : Se —^ E' is a renaming such that or operation so with ^i(so) ^ so, then
= (Ei,S e ), if Si for each sort
(rename msp by /j.) is a module specification with <S (rename msp by /x) = (Ej, /i(E e )); (v)-(x) the constructs forget, extend, model, generated, freely generated, freely extend and quotient are defined similarly to (iv) (cf. Definition 13.1(iv) to (vii) and Definition IS.lO(viii) to (ix)).
Algebraic specification of abstract data types
289
Definition 14.7 (Semantics of MSL). The semantics M(msp) of a module specification msp is a module (in the sense of Definition 14.2) and is defined inductively according to Definition 14.6: (i)
(ii)
the semantics M(atm) of an atomic module specification aim is the module defined by this atomic module specification (see section 14.2); if 5(mspj) = (£ij, Si e ) and <S(msp2) = (£ 2i , £ 2e ), then M(mspl + msp2)(A) =
(iii)
{ B € Alg(Zle U S2e) | (B \ £ le ) € M(msPl)(A \ E«), (B|£2e)eM(msp2)(.4|£2i)}
for all A £ Alg(Zu U £ 2i ); if 5(msp!) = (£«,£) and 5(msp2) = (£,£ e ) then ./M(msp2 o msp1)(A) =
(iv)
(^J
.M(msp2)(.B)
for all A e Alg(Zi); if S(msp) = (Ej,S e ), then (rename msp by
for all A e (v)-(x) similar to (iv) (cf. Definition 13.2(iv) to (vii) and Definition 13.10(viii) to (ix)). The reader may easily check that these different definitions are consistent. The different language constructs, except for freely extend and quotient, may be shown to preserve persistency (cf. the remark following Definition 13.10). The constructs also preserve consistency except possibly +, model, generated and freely generated; the construct + preserves consistency, when applied to persistent specifications. As announced above, the constructs rename and forget may lead to module specifications, the import signature of which is not a subsignature of the export signature. An environment may be added in a way similar to that of section 13.3. Example 14.8. Let msp denote the atomic module specification of Example 14.4. An example of a module specification with environment is: LIST is msp; BOOL is loose mspec sorts freely generated bool opns constr True : —> bool constr False : —^ bool endmspec; LIST o BOOL
290
J. Loeckx, H.-D. Ehrich and M. Wolf
The import signature of this module specification is empty. Hence, it may be viewed as a specification with signature ({bool, el, list}, {True, False, [ ], Add,...}) defining lists of "elements". Further comments on the modularized specification language may be found in section 14.5.
14.4
A parameterized specification language
The parameter mechanism introduced in this section is a very elementary one. It allows the simulation of most of the parameter mechanisms that are described in the literature (see section 14.6). According to this parameter mechanism, a parameter is a distinguished sort or operation of the import signature of a module specification. In the module specification of Example 14.4 the imported sort el is predestined as a parameter in contrast with the imported sort bool. The reason is that the sort el is concerned with reusability while bool is concerned with modular design. More precisely, the intended meaning of bool is fixed while the meaning of el is intentionally left pending. In fact, it makes sense to use the module specification with different meanings for el, for instance natural numbers, strings or lists of lists of natural numbers, but it is not sensible to use the module with a meaning for bool other than the intended one. By the way, the difference between imported sorts or operations that are parameters and those that are not is similar to that between parameters and global variables in the procedure body of an imperative language. As a result, imported sorts and operations that are parameters and those that are not do not differ in their semantics but merely differ in their intended use. Providing a module specification language with a parameter mechanism may therefore be reduced to the introduction of two additional language constructs called import rename and import model, respectively. The first of these constructs allows parameter passing by renaming the (imported sorts and operations that constitute the) formal parameters into their actual values. In the case of Example 14.4 it allows one to rename the sort el into, for instance, nat or string. The second construct allows one to put semantic constraints on the parameters. For instance, a module specification of "ordered lists" that is parameterized in the sort of its elements requires that the carriers of this sort satisfy the axioms of a partial order—as will be illustrated in Example 14.13. The following two definitions introduce a parameterized specification language called PSL. This language is identical with the module specification language MSL except for the two additional language constructs mentioned above. The definition of the construct import rename is slightly more complex than the above comments may suggest. While the construct introduces
Algebraic specification of abstract data types
291
"new" names for the sorts and operations of the import signature, it generally modifies the export signature too. In fact, the inherited sorts and operations in the export signature have to be renamed accordingly. The same holds for the inherited sorts occurring in the arities of the exported operations. For this reason the signature morphism is defined as a signature morphism fj,: Ej U Se —» E' rather than // : EJ —> E'. Definition 14.9 (Abstract syntax of the parameterized specification language PSL). The set of parameterized specifications psp of the language PSL and their module signatures S(psp) are defined inductively: (i)-(x) as Definition 14.6(i) to (x) but with "parameterized specification" instead of "module specification"; (xi) if psp is a parameterized specification with S(psp) = (Ej,S e ) and if n : Ej U Ee —t E' is a surjective signature morphism satisfying the following four conditions: (a) for each sort s from E e \Ej, n(s) = s, (b) for each operation u> from E e \£j, /x(w) and w have the same operation name, (c) for any two different sorts or operations so\e and so-ze from S e , n(soie) — n(so?,e) implies that both so\e and so^e are inherited, (d) for any sort or operation so, from Ej and soe from S e , l_t(soi) = n(soe) implies that soe is inherited, then (import rename psp by /x) is a parameterized specification with ^(import rename psp by p.) = (/i(Sj),/x(S e )); (xii) if psp is a parameterized specification with S(psp) = (Sj,£ e ) and if $ C L(Ej) is a set of formulas for some logic L, then (psp import model *) is a parameterized specification with S(psp import model $) = S(psp). Informally, conditions (xi)(a) and (xi)(b) express the fact that /j, constitutes a renaming of the import signature. More precisely, condition (xi) (a) expresses the fact that n renames sorts from Se only if they are inherited. Condition (xi)(b) expresses the same property for operations or, at least, for their names; the condition does not extend to their arities: if a noninherited operation u from Se contains imported sorts in its arity, w and n(w) may differ from each other in their arities. Conditions (xi)(c) and (xi)(d) avoid "name clashes". More precisely, condition (xi)(c) expresses
292
J. Loeckx, H.-D. Ehrich and M. Wolf
the fact that p. is injective on the non-inherited sorts and operations from Se. Condition (xi)(d) expresses the fact that p, may identify a sort or operation from £, and a sort or operation from Se only if the latter is inherited. Note that the signature morphism n is not necessarily bijective and hence may fail to constitute a renaming in the sense of Definition 5.1(ii). This is sensible because it must be possible that two different formal parameters get the same actual value (see Example 14.11). In the concrete syntax one uses pspec and endpspec instead of mspec and endrnspec. Definition 14.10 (Semantics of PSL). The meaning M(psp) of a parameterized specification psp is a module (in the sense of Definition 14.2) and is inductively defined according to Definition 14.9: (i) to (x) as in Definition 14.7 but with "parameterized specification" instead of "module specification"; (xi) ifS(psp) = (Si.Se), then M (import rename psp by n}(A) = { B 6 Alg(»(Ee)) | (B | (/z|EJ) € M(psp)(A \ (/i| Ej )) } for each A 6 Alg(fj,(Si)); (xii) if S(psp) = (Ef,E e ), then ... . . , / M(psp)(A) W/n M(psp import model1 A$)(/!) = < „ v (0 for each A E. Alg(£i).
ifA\=$, ,, • otherwise
The meaning of the construct import rename is as expected. The effect of the construct import model is to "eliminate" the imported algebras that fail to satisfy $. The construct import rename preserves persistency and, when applied to persistent specifications, consistency. The construct import model preserves persistency but not necessarily consistency. Again, the addition of an environment presents no problem. Example 14.11. A "declaration" of a parameterized specification is PAIR is loose pspec sorts freely generated pair, import eli, import el? opns constr [_ , _ ]: el\ x el2 -* pair First :pair —>• el\ Second : pair ->• el2 vars e\: eli, e2: el-2 axioms Fz'rsi([e1;e2]) = ei Second([ei,e2]) = e2 endpspec An instantiation of this parameterized specification is
Algebraic specification of abstract data types
293
import rename PAIR by sorts e l i , eli as sorts nat, not The instantiation specifies pairs of natural numbers or, more precisely, of carriers of sort not. Its module signature (£,, S e ) is as expected: £i = ({nat},®), T,e = ({nat,pair}, {[_]: nat x nat ->• pair, First -.pair ->• na£, Second :pair —> nat}). The example illustrates that import renaming must not be injective. The notation for an instantiation is clumsy and requires repetition of the formal parameters. By storing the formal parameters in the environment one may adopt a "sugared" notation similar to that of programming languages: the formal and actual parameters are written between brackets after the name of the parameterized specification. This notation has the additional advantage that it explicitly distinguishes between parameters and imported sorts and operations that are not parameters. Example 14.12. The parameterized specification of Example 14.11 may now be written: PAIR (sorts eli, el2) is loose pspec sorts freely generated pair, import eli, import e/2 opns [_ , _ ] : . . . endpspec Similarly, the instantiation is written: PAIR (sorts nat, nat) The following example illustrates the use of import model for expressing parameter constraints. Example 14.13. The following parameterized specification defines ordered lists. In it the construct import model makes sure that the relation "C" is a partial order. ORDERED-LISTS (sorts el, opns _ C _ : el x el ->• boot) is ((loose pspec sorts freely generated list, import bool, import el opns import True: —> bool import False : -4 bool import _ C _: el x el —t bool constr [ ]: -> list constr Add : el x list -¥ list Is-ordered : list —»• bool vars e,e\,e^: el, I: list axioms Is-ordered([ ]) = True
294
J. Loeckx, H.-D. Ehrich and M. Wolf Is-ordered(Add(e, [ ])) = True (d C 62) = True D Is- ordered ( Add (ei, Add (e^, I))) = Is-ordered(Add(e<2,l)) (e\ C 62) = Fafae D endpspec) import model vars 6,61,62,63: d axioms (e C e) = TVwe (ei C e 2 ) = Trwe A (e2 C e3) = True D (ei C 63) = True (ei C e 2 ) = True A (e2 C ei) = True D ei = e 2 )
Now let NAT is (loose pspec sorts
freely generated boot, freely generated nat opns constr True : —> bool constr False : —> 6ooZ constr 0 : —> nat constr SWcc : nat —> na£ _ < _ : nat x nai —>• bool vars m, n: nai axioms (0 < n) = TVue (5wcc(m) < 0) = Fafee (Succ(m) < Succ(ri)) = (m < n) endpspec)
Then ORDERED-LISTS (sorts not, opns <:natx nat -> 600?) o is a specification of ordered lists of natural numbers. Of course, this specification makes sense only if the module it defines is consistent (in the sense of Definition 14.2). Hence, it is necessary to prove that "<" satisfies the axioms of "C". By the way, if the reader is still irritated by the clumsy notation he should remember that the specification languages presented are not intended for "practical" use.
14.5
Comments
The remarks on flattening, properties and proofs, rapid prototyping and further constructs of sections 13.4 to 13.5 carry over to the specification languages MSL and PSL. By way of a restriction rapid prototyping is not possible as long as the meaning of the imported sorts and operations is not fixed.
Algebraic specification of abstract data types
14.6
295
Alternative parameter mechanisms
The literature contains a large number of proposals for modularized and parameterized specification languages and, in particular, for parameter mechanisms (see, for example, [Ehrig and Mahr, 1985; Ehrig and Mahr, 1990; Ehrich et al., 1989; Burstall and Goguen, 1980; Wirsing, 1986; Broy et al., 1993; Lehmann and Loeckx, 1993]). Most of them differ from the languages presented here by being less "elementary". The interface, for instance, generally consists of signatures or even specifications rather than single sorts and operations. Two parameter mechanisms are now roughly sketched. In the X-calculus approach a parameter consists of a complete specification. More precisely, a parameterized specification is of the form XX:par.sp
(14.1)
where par and sp are specifications of a specification language with environment—such as the specification language PSL (with an environment)—and where X is a name. It is understood that X may occur in the specification sp. Informally, the notation "A": par" indicates that actual parameters have to be of "type" par, i.e. have to belong to the abstract data type defined by par. Somewhat more precisely, (14.1) is equivalent to the following parameterized specification of PSL: • the environment is extended by the declaration
X is ... where ... stands for the loose atomic module specification ((S(par), S(par)), Th(M(par))); informally, this module specification leaves the signature <S(por) unchanged but adds the formulas of the theory of the abstract data type defined by par; • sp is turned into a parameterized specification of PSL by defining the sorts and operations of S(par) as imported sorts and operations or, more precisely, as parameters. Alternatively, one may define ... to stand for the loose atomic module specification ((S(par),S(par)),®) and add Th(M(par)) to the parameterized specification obtained from sp with the help of the construct import model. The following approach is called the pushout approach because the parameter passing mechanism is defined as a pushout in an appropriate category. The approach was first described in [Ehrich and Lohberger, 1979]. It makes use of the notion of a specification morphism (introduced in Definition 13.19(ii)). To simplify the description of the approach it is assumed that all specifications are atomic ones or, alternatively, have been turned into atomic ones by the meaning function J\f of section 13.8. A parameterized specification is now a specification morphism
296
J. Loeckx, H.-D. Ehrich and M. Wolf
par
'«r
7T
''
sp(par)
\ -^ /
Fig. 4. The specification sp(act) is the pushout object of the specification morphisms •K and /z. TT : par '-^ sp(par) that is an inclusion. The specification par = (E p0 rj3> P ar) constitutes the formal parameter; the specification sp(par) = (£ sp ( pa r)>$s P ( P ar)) constitutes the parameterized specification proper. The notation sp(par) is intended to suggest that par is "part of" sp(par) according to the inclusion ir. Note that £ par C £ sp ( par ) and $*paT C $* , ar j because TT is a specification morphism. Parameter passing is defined as a specification morphism : par
act
where act = (Soct^act) is the specification constituting the actual parameter. Note again that (/i($par))* C $*c< because p. is a specification morphism; this forces the actual parameter act to "respect" the requirements 4>par imposed on par. Finally, the effect of parameter passing is a specification sp(act) that is characterized as the pushout object of TT and fi in the category of specifications and specification morphisms (see Figure 4). This pushout object is unique up to isomorphism and its existence is granted in the usual category of specifications and specification morphisms. Roughly speaking, the pushout of TT and fi constitutes the "minimal completion" to a commutative square. It yields the specification morphism p! : sp(par) —>• sp(act) describing the relationship between the specifications before and after replacing par by act, and the specification morphism TT' : act <—> sp(act) describing the embedding of the actual parameter into the resulting specification. The semantic counterpart of the pushout construction is given by the amalgamation lemma ([Ehrig and Mahr, 1985], p. 217). The class M(sp(act)) consists of the £sp(act)-algebras C for which (C | TT') = A and (C | //) = B with A e M(act), B e M(sp(par)) and (A | fj.) = (B | TT). Informally, (A\ fji) = (B \ ?r) requires that the parameter components of A and B coincide; C is the algebra B with the par component of B replaced by A. A similar property holds for the £sp(acj)-homomorphisms. It is not difficult to simulate the pushout approach in the specification
Algebraic specification of abstract data types
297
language PSL when the parameter passing /j, is surjective. The renaming effect of parameter passing may then be simulated by the import rename construct together with the (surjective) signature morphism A*
:
Essentially, this signature morphism performs the renaming of the import signature Epar into E OC ( and of the inherited sorts and operations in the export signature £ sp ( por ). The condition that the different morphisms are specification morphisms may be taken care of by the construct import model — as in the case of the (simulation of the) A-approach. When the parameter passing \i is not surjective the sorts and operations of SaC( — M(Epar) nave to t>e added to the result of the import rename construct as inherited sorts and operations. This may require a preliminary renaming to avoid "name clashes" . Clearly, one of the advantages of the pushout approach with respect to its simulation in PSL is that all renamings are performed implicitly.
15
Further topics
The present section discusses topics the treatment of which has not (yet) reached the level of maturity of the topics treated above. The reader interested in more details is referred to the bibliographic notes of section 15.7.
15.1
Behavioural abstraction
It is a fundamental principle of specification not to distinguish between "similar" algebras. Clearly, isomorphic algebras are "similar" as they possess, for instance, the same theory. For this reason abstract data types were defined as algebra classes closed under isomorphism. The interest in monomorphic abstract data types exhibited throughout this chapter may suggest that, conversely, "similar" algebras are necessarily isomorphic. The following example shows that in some situations it may be sensible to use a notion of "similarity" that is more general than that of isomorphism. Example 15.1. Let £ = (S, fi) be a signature with S = {bool,nat,set} and H = {0 : —» nat,Succ:nat —>• nat, 0 : —» set, Add: nat x set —>• set, . € . : nat x set -> bool}. Let A and B denote the "classical" algebras of respectively sets and lists of natural numbers. More precisely: • A(bool) = B(bool), A(nat) = B(nat), A(0) = 5(0), A(Succ) = B(Succ) are classical; • A(Q) is the empty set, 5(0) is the empty list; • A(Add) adds a number to a set, B(Add) adds a number to the front of a list; checks whether a number is in a set — and similarly for -B(e).
298
J. Loeckx, H.-D. Ehrich and M. Wolf
Clearly, A and B are not isomorphic and even fail to have the same theory. For instance, putting t = Add(0, 0), u = Add(0, Add(0: 0)), one has A(t) = A(u), but B(t) ^ B(u). On the other hand the algebras A and B behave "similarly" with respect to the operation "e". More precisely, it is easy to show that A(t) = B(t) for all ground terms t € Ts^ooi of sort bool. Informally, this property ensues from the fact that membership depends neither on the order of insertion nor on the number of times an element has been inserted. Hence the algebras A and B are "similar" whenever one restricts attention to the membership problem or, put another way, to the effect of set on the "outside world" of bool.
This notion is now defined formally. Definition 15.2 (Behavioural equivalence). Let £ = (S, J7) be a signature and So C S a set of sorts called observable sorts. Two S-algebras A and B are said to be behaviourally equivalent on SQ, if for each sort s € 5o, for all ground terms t, u € TE<S, One then writes A «s0 B. Example 15.3. Let A and B be the algebras of Example 15.1. Let C similarly be the "classical" algebra of multisets (i.e. "sets" in which elements may occur more than once). Then A f^{booi} B ~{&0oJ} C. The following corollary states that behavioural equivalence generalizes isomorphism. Corollary 15.4. Let E = (5, ft) be a signature, SQ C S be a set of sorts and A and B be 'Z-algebras. (i) IfA~B, then A wSo B. (ii) If A «5 B and both A and B are generated algebras, then A ~ B. Definition 15.5 (Behavioural abstraction). Let S = (5, fi) be a signature, So C S & set of sorts and C C Alg(^) an abstract data type. The behavioural abstraction of C with respect to SQ is the class of E-algebras Behav(C, S0) = { A E Alg(S) \ A wSo B for some B e C }. By Corollary 15.4 a behavioural abstraction is again an abstract data type. The following theorem states that a behavioural abstraction of a monomorphic abstract data type contains final algebras (Definition
Algebraic specification of abstract data types
299
Theorem 15.6. Let S = (5,0) be a signature, So C 5 a set of sorts and C C Alg(S) a monomorphic abstract data type. Then Behav(C,Sg) contains final algebras. Example 15.7. Let A, B, C be as in Example 15.3. Put C = { D € Alg(S) \D~A}. Then A, B and C all belong to Behav(C, {bool}). It is possible to prove that A is final in C. Theorem 15.6 allows one to introduce one more specification method. One should remember that final algebras are unique up to isomorphism (Theorem 2.14(ii)). Definition 15.8 (Final specification). (i) (Abstract syntax.) A final (or behavioural) specification is a triple sp = (£, 4>, SQ) where (£, $) is an initial specification with £ = (5, fi) and where 5o C 5. (ii) (Semantics.) The meaning .M(sp) of a final specification sp = (£, $, 5o) consists of the class of final algebras of Behav(C, So) where C is the (monomorphic abstract data type that constitutes the) meaning of the initial specification (£,$). Example 15.9. Let A be the algebra of sets and B the algebra of lists of Example 15.1. If (£, 3>) is an initial specification for B, the final specification (£, $, {boot}) is a specification for A. Informally, this means that the effect of behavioural abstraction is the same as that of the equations in an initial specification
Add(n,Add(n,s)) = Add(n,s) Add(n, Add(m, s)) = Add(m,Add(n,s)) distinguishing sets from lists.
15.2 Implementation Informally, an implementation consists in the design of an efficient program for a given specification. This design includes, in particular, the transformation of a possibly loose non-constructive specification into a constructive one. It generally also includes a change of data types. The implementation of data types by other more "concrete" ones is briefly discussed in the present section. To abstract from specification details, the notions are defined on data types rather than on specifications. Example 15.10. A classical example of an implementation is that of stacks by arrays and integers. Informally, the contents of a stack of depth n are stored in the elements A[l],..., A[n] of an array A; the integer has the value n and thus "points" to the topmost stack element. The operation Push is implemented by writing the new element into A[n + 1] and by adding one to the integer. The operation Pop is implemented simply by subtracting one from the integer.
300
J. Loeckx, H.-D. Ehrich and M. Wolf
Clearly, an implementation of stacks by arrays and integers is "sensible" : the abstract data types array and integer are more "concrete" than the abstract data type stack because they are available in any imperative programming language and thus are "nearer" to a program. The example above illustrates three features of an implementation: (i) a data type is in general implemented by several data types rather than by a single one; in the example stack is implemented by array and integer; (ii) there does not necessarily exist a one-to-one relation between a data type and its implementation; in the example arrays differing only by the elements beyond the element pointed to by the integer represent the same stack; (iii) the implementing data types may get values that do not represent values of the implemented data type; in the example an integer may, for instance, have a negative value. At first glance one may think that the notion of behavioural equivalence introduced in section 15.1 may capture the notion of implementation. Actually, this does not work because of feature (iii) above. The following definition is intended to capture features (ii) and (iii). Definition 15.11 (Realization). Let A and B be S-algebras for some signature E. The algebra B is said to realize A if A is isomorphic to a quotient of a subalgebra of B. Informally, the definition accounts for feature (iii) by means of the subalgebra and for feature (ii) by means of the quotient. The next definition is intended to capture feature (i). The specifications used in it are from a specification language such as SL. Definition 15.12 (Construction term). Let Bi,...,Bm be algebras for signatures E 1 ; . . . , E m , m > 1. Let spl,..., spm be strictly adequate specifications of Bi,...,Bm (cf. Definition 9.1). A construction term of BI, ..., Bm is a monomorphic specification sp that: • contains (occurrences of) the specifications spl,...,spm instead of (occurrences of) atomic specifications; • uses only the constructs "+", rename and forget. Informally, sp is obtained by "putting together" sp1,..., spm. Finally, it is possible to introduce the notion of an implementation of an algebra by other algebras. Definition 15.13 (Implementation). Let A,Bi,...,Bm, m > 1, be algebras and let sp be a construction term of BI, ..., Bm. The specification sp is said to constitute an implementation of A by the basis BI ,..., Bm if each algebra of the abstract data type M(sp) defined by sp realizes A.
Algebraic specification of abstract data types
301
The condition "sp realizes A" in this definition constitutes the correctness criterion of the implementation. The investigation of this criterion is one of the topics in the study of implementations. The notion of implementation introduced above is for algebras. A generalization of this notion for abstract data types and modularized abstract data types is straightforward. This generalization naturally leads to a notion of implementation for specifications and parameterized specifications. An interesting question is whether the realization "is implemented by" is transitive. Another question is whether the relation is compatible with the constructs of a specification language.
15.3
Ordered sorts
It is common in mathematics that some data types are "subtypes" of others. For example, non-zero natural numbers constitute a subtype of natural numbers which in turn constitute a subtype of integers. These subtypes "inherit" functions from their supertypes. More precisely, if / : A —> B is a function, if C C A and if B C D, then the function g : C —»• D defined by 9(c) = f ( c ) f°r all c e C is said to be obtained by inheritance. These notions are now defined formally. Definition 15.14 (Order-sorted signature). An order-sorted signature is a triple E = (S, ft, <) such that the following conditions hold true: (i) (S, ft) is a signature in the sense of Definition 2.1; (ii) < is a (reflexive) partial order on S; (iii) whenever H:SI x ... x Sk -* s 6 fl, k > 0, s[,..., s'k, s' € S, s 'i < s i j • • • > s fc < Sfc, s < s', then n: s[ x ... x s'k —> s' € n too. Note that an order-sorted signature in general fails to be strongly typed (see Definition 3.2). Example 15.15. An example of an order-sorted signature is the triple S = (S, fl, <) with 5 n
= =
{nat, int, bool}, {0:->nai, Succ: nat —>• nat, Succ : int —> int, Pred: int -> int, Root: nat -4 nat, True : -4 bool, False : -y bool, Eq: int x int -y bool } U f l c , < = {(nat, int)} Li {(nat, nat), (int, int), (bool, bool)} where, according to Definition 15.14(iii),
302
J. Loeckx, H.-D. Ehrich and M. Wolf nc
=
{ 0: -> int, Succ: nat —> int, Pred: nat -4 int, Root: nat —>• int, Eq: nat x int —> bool, Eq: int x nat —>• bool, Eq: nat x nat —> bool }.
Definition 15.16 (Order-sorted algebra). Let E = (S, Q, <) be an order-sorted signature. An order-sorted algebra for S, or ^-algebra, is an (5, fi)-algebra (in the sense of Definition 2.3) with the following conditions holding true: (i) (Subtype condition.) A(SI) C Afa) for any si,S2 £ S with si < s 2 . (ii) (Inheritance condition.) whenever <jj = (n: «i x ... x Sk —> s) € ft and w' = (n: s[ x . . . x s'k -> s') € ft with sj < si,..., s'k < Sk, s < s', k>0, then A(u')(ai ,...,ak) = A(ui)(ai,. ..,ak) for all ai 6 A(s'1), ...,ake A(s'k). Example 15.17. Referring to Example 15.15, a E-algebra is the "classical" algebra given by the natural numbers and the integers—both equipped with the number zero as well as the successor, predecessor, square root and equality functions—and the truth values—equipped with the values true and false. Homomorphisms and terms may be defined in the usual way. As the signature is in general not strongly typed, a term may have different sorts. It should also be noted that some terms are no longer correctly typed that one would consider intuitively so. The term Root (Pred (Succ(Q))), for example, is not correctly typed, because the subterm Pred(Succ(0)) only has the sort int. This is unintuitive because in the "classical" algebra the evaluation of this "term" is—intuitively speaking—unproblematic. Logic may be defined in the usual way. By way of an important result, the initiality results of section 11 remain valid. Moreover, the notion of term rewriting in the same section may be easily generalized for ordered sorts while keeping the main properties. An example of application of ordered sorts is given in section 15.4.
15.4
Exceptions
Informally, an exception is a situation in which a computation cannot be pursued. Classical examples of exceptions are division by zero, popping an empty stack, computing the predecessor of zero in N 0 , etc. Imperative programming languages handle exceptions as "emergency exits" by means of a jump statement. The treatment of exceptions in functional programming
Algebraic specification of abstract data types
303
languages is less trivial. Hence it is not surprising that there is no simple solution to the exception problem in algebraic specification. There exist essentially four different solutions to the exception problem in algebraic specifications: a logical solution, a partial algebra solution, an error solution and an order-sorted solution. In the logical solution the treatment of an exception is left pending by the use of loose specifications. Such a specification, for instance, axiomatically fixes the value of the predecessor function only for non-zero arguments (Example 10.10). In the partial algebra solution a function with exceptions is modelled as a partial function. Popping the empty stack, for instance, leads to the undefined value. In the error solution the partial algebra solution is simulated by total algebras. To this end an extra carrier is added to each carrier set: it is called Error and represents the undefined value. This approach leads to specifications with additional formulas fixing the function values in case one or more arguments are Error — as illustrated by equations (11.2) and (11.3) in Example 11.7. If one adopts the strictness convention, a function value is Error whenever one of the arguments is Error and the corresponding formulas need not appear in the description of the specification. Of course, these formulas may not be ignored in proofs or in rapid prototyping. Unfortunately, there exist operations that are not compatible with the strictness convention. An example of such an operation is if-then-els e-fi: if True then ... else Error fi should yield ... as a value, not Error. By way of a conclusion, the error solution leads to essentially larger sets of formulas that harm the transparency of specifications and make proofs more elaborate. The order-sorted solution uses order-sorted algebras. The following example illustrates the idea. Example 15.18. Let £ = (S, ft,<) be the order-sorted signature with S = {el, stack, nestack} (where nestack stands for "non-empty stack"), with fi = {Emptystack : —>• stack, Push : stack x el -> nestack, Pop : nestack —¥ stack} U fJc and with "<" defined by nestack < stack. As in Example 15.15, fic accounts for Definition 15.14(iii); in the present case fic = {Push: nestack x el -> nestack}. An order-sorted E-algebra A is defined by: A(stack) = the set of all stacks with elements from A(el), A(nestack) = A(stack) — {the empty stack}, A(Emptystack) = the empty stack,
304
J. Loeckx, H.-D. Ehrich and M. Wolf A(Push), A(Pop): as expected.
The main difference with the "classical" (partial) algebra of stacks is that A(Pop) is now a total function, its domain being A(nestack) rather than A(stack). A precise treatment of the order-sorted solution is outside the scope of this overview. Let it suffice to note that a sort SQK is added for each "concerned" sort s. This sort is "safe" in that it does not lead to errors. In the above example nestack stands for stack OK •
15.5
Dynamic data types
Data types are "static" structures consisting of sets and functions. Pieces of software, however, nearly always contain "dynamic" parts consisting of processes operating on data. As long as these processes are algorithms, they can conveniently be described in a functional style that is compatible with algebraic data type specification, i.e. the algorithms are specified as functions within data types. However, algebraic specification as described in this chapter reaches its limits when the processes are reactive, i.e. when they have—possibly elaborate—interaction structures with the environment, and when they are concurrent, i.e. when several processes act independently and autonomously. Dynamic data types constitute an extension of "static" data types that is intended to overcome these limits. Several approaches have been proposed in the literature. The ones most widely discussed so far are based on the idea that concurrent processes are simply data. Basically, these approaches introduce an imperative flavour into the functional style of abstract data type specification by introducing sorts for process data—such as states and actions—and process operations—such as state transitions. On the semantic level some of these approaches use infinitary extensions of algebras—such as continuous algebras or projection spaces—and a form of behavioural semantics. In order to get the flavour of the dynamic data type approach, the basic concepts of one of the earliest and most elaborate approaches in this area, viz. SMoLCS [Astesiano and Reggio, 1987], are briefly outlined. Definition 15.19 (Dynamic signature). A dynamic signature is a triple (E,S 0 ,n) where: • S = (5, (7) is a signature in the sense of Definition 2.1, • S0 C 5 is a set of sorts called dynamic sorts, • II is a set of transition predicates of the form n:si x ... x Sfc
where n is a transition name and $1,..., Sk 6 S, k > 1. It is required that for each dynamic sort d € S0:
Algebraic specification of abstract data types
305
(i) there is a sort l-d 6 S — S0 called the label sort of d; (ii) there is a predicate _ -4 _ : dx l-dx d S II. Example tended to language: S So fi
n
15.20. The following dynamic signature ((5, n),5 0 ,II) is inmodel state variables of sort s of an imperative programming = { s,Var[s}}, 1- Var[s] , = { Var[S}} , = {[±]:-+ Vbr[s], [ _ ] : s -4 Var[s], :=_: s -> 1 - Vor[s] }, = { . -^ . : Var[s]xl - Var[s]x Var[s] }.
Informally, the sort s stands for the values to be assigned, the sort Var[s] stands for the variables containing values of sort s and the sort 1 — Vor[s] stands for labels identifying transitions, i.e. "actions" on variables. For instance, [_L] stands for a variable with undefined contents and [a] stands for a variable with contents a. Similarly,
:= a stands for the action of assigning the value a to a variable. Finally, II is used to denote the possible transitions representing the assignments of values to variables. The signature is used in Examples 15.21 and 15.22. A precise definition of the notion of a dynamic algebra is beyond the scope of this overview. Informally, a dynamic algebra for the dynamic signature (S,5 0 ,II) consists of: • a S-algebra (in the sense of Definition 2.3), say A; • for each element of II, say n : s i X . . .xsk, a subset of A ( S I ) X . . .xA(sk). In such an algebra the triples of the subset defined by "_ -^ _" constitute the possible transitions. Example 15.21. A possible dynamic algebra for the dynamic signature of Example 15.20 is defined as follows: • the E-algebra A is as indicated in the comments on Example 15.20; • the meaning of II is defined to be: {[JL] ^ [a] | a e A ( s ) } u { [ a ] ^4 [b] \a,b&A(s)}. The triples of (the meaning of) II represent the possible transitions; each transition consists in the action of assigning a value to a variable. Note that in the example the actions of the transition predicate are deterministic. This need not be so in general. Abstract dynamic data types and dynamic specifications are defined as usual.
306
J. Loeckx, H.-D. Ehrich and M. Wolf
Dynamic algebras may model transition systems of various dynamic sorts. The question remains how dynamic algebras reflecting the isolated and cooperative behaviour of these systems may be specified. In the case of isolated behaviour, specification up to behavioural equivalence is practical and feasible. In the case of cooperative, i.e. concurrent, behaviour, configurations consisting of multisets of local states are introduced, together with global information on the configuration. Global transitions are specified by splitting the specification into several steps; at each step some partial moves are defined using the partial moves at the previous step; at the first step, the partial moves are defined by using the transitions of the components. Contrasting with the approaches to dynamic data types discussed above there exist approaches in which processes are represented as algebras rather than as data. These approaches offer the possibility of providing states with an algebraic structure that can be specified along the lines described in this book. A transition structure on top of the algebras allows one to move from one state algebra to another. More precisely, a transition allows one to remove or add carriers, or to redefine (the functions that constitute) the meaning of the operations.
15.6
Objects
Since the advent of SMALLTALK [Kay and Goldberg, 1976; Kay, 1993], the underlying paradigm of object-orientation has become quite successful, as illustrated by the numerous object-oriented programming languages, database systems, and software development methods. In this paradigm, software systems are considered to be dynamic collections of autonomous objects that interact with each other. Autonomy means that each object encapsulates all features needed to act as an independent computing agent: individual attributes (data), methods (operations), behaviour (process) and communication facilities. Moreover, each object has a unique identity that is immutable throughout its lifetime. Coincidentally, object-orientation comes with an elaborate system of types and classes, facilitating structuring and reuse of software. Object specification combines ideas from algebraic data type specification, conceptual data modelling, behaviour modelling, specification of reactive systems, and concurrency theory. The basic concepts are now illustrated by means of an example, using an ad-hoc notation in algebraic specification style. Example 15.22. The following specification introduces an object class Var[s] of state variables of sort s (cf. Examples 15.20 and 15.21): object class Var[s]; uses s, nat; attributes value:s; actions create; :=s; delete;
Algebraic specification of abstract data types
307
axioms var v,w: s; ©create = > • ( - > > create A >:=v A > delete) U©delete ©delete =>• > create A ->t>:=v A -i> delete Q:=V => value=D U (0:=w V ©delete) end. A variable x of class Var[s] has an attribute x.value denoting its current value. It has actions x. create for creation, x: =s for assigning values of sort s (i.e. an action x:=v for every value v of sort s), and a;.delete for deletion. In the class axioms, the predicate ©a is used for expressing the fact that action a has just occurred, and >a for expressing the fact that action a is enabled, i.e. that it may occur at the current state. The temporal operator (pUip means that, from the current moment on, (p will be true all the time until \j) becomes true for the next time. The latter must happen some time, and (p need not be true any more when this happens. The axioms express the fact that: • after creation, all actions except creation are enabled until deletion; • after deletion, all actions except creation are disabled; • after assignment, the value assigned is kept until the next assignment is made, or until the variable is deleted. Enabling creation after deletion gives the possibility of reusing variables. More generally, an object type is a set of object instances. It is characterized by a data type of object identities along with an object class describing the prototypical behaviour shared by all instances of the object type. A specification may be defined along the lines described in the previous chapters of this book in the following way. As usual, a signature is a pair S = (S, 0) where S is a set of sorts and n is a set of operations. Data and objects are distinguished by assuming that the set S of sorts consists of two disjoint subsets SD of data sorts and So of object sorts. Interpretation of a signature £ is given in a E-algebra A. The intended interpretation of a data sort d e SD in the algebra A is a set A(d) of data elements that constitutes the carrier set of sort d. The intended interpretation of an object sort s 6 So in A is a pair A(s) = A(s)ld .A(s)bv where A(s)'d is a set of identities and A(s)bv is the behaviour of objects of sort s. In other words, A(s) represents a set of object instances i.A(s)bv, each one given by an object identity i e A(s)td, and each one having the same behaviour A(s)bv. The operations are interpreted as usual. In analogy to data types, one may define an object type as the set A(s) of object instances of sort s £ So within a S-algebra A, together with the operations of fi defined on A(s). Hence, an object type is like a data type but with object instances taking the place of data elements.
308
J. Loeckx, H.-D. Ehrich and M. Wolf
The essential difference is that an object instance has a dynamic behaviour whereas a data element has a static behaviour. Formally, all instances of an object type have the same behaviour. It is possible, however, that different parts of this behaviour are relevant for different objects of the type, thus introducing some heterogeneity. Object-orientation comes with a rich structure of object relationships and constructions: inheritance, generalization, aggregation and interaction. A theoretical basis for their study is given by object type morphisms preserving structure and behaviour of object types: there is a map that relates the identity sets, and a behaviour morphism between related behaviours. A crucial point in object specification is how to specify behaviours and their morphisms, i.e. behaviour preserving maps. In order to describe sequential and concurrent behaviour, many logics and models of concurrency can be adopted and integrated. One choice is to use temporal logic and its extensions for specification, and event structures for interpretation. But other choices are possible, based, for instance, on predicate logic and labelled transition systems (cf. section 15.5). Another crucial point is how to specify interaction between objects. Basically, this can be done by constraining the cooperative behaviour of components within an aggregated object, using the specification logic at hand.
15.7
Bibliographic notes
Sections 15.1 to 15.4 are short accounts of corresponding chapters in [Ehrich et al., 1989] where more details can be found. A survey and annotated bibliography of the state of the art is in [?]. Behavioural abstraction is also treated in [Reichel, 1987; Bidoit and Hennicker, 1996; Bidoit and Hennicker, 1998]. A first concept of implementation was published in [Ehrich, 1978]. A survey of implementation and behavioural equivalence may be found in [Orejas et al., 1993]. In [Goguen and Meseguer, 1992; Goguen and Diaconescu, 1993] an alternative approach to order-sorting and exception handling is provided. A further approach to using order-sorting in algebraic specification is given in [Mosses, 1993]; this paper also contains an overview and comparison with related approaches. An approach to exception handling with explicit error values is pursued in [Gogolla et al, 1984]. Exception handling using partial algebras is treated in [Reichel, 1987]. Dynamic data type approaches have been described in, for instance, [Astesiano and Reggio, 1987; Kaplan, 1989; Ehrig et al., 1990]. A standardized specification language and method developed on these grounds is given in [ISO-LOTOS, 1989]. A survey of algebraic specification of concurrency with an emphasis on dynamic data types is given in [Astesiano and Reggio, 1993]; this paper also contains a rich collection of references to the literature. The states-as-algebras approach to dynamic data types
Algebraic specification of abstract data types
309
is pursued in [Dauchy and Gaudel, 1994; Zucca, 1999; Ehrig et al, 1995]. A recent overview of the topic may be found in [Astesiano et al., 1999a]. Object specification as outlined here is based on work by the second author of this chapter and others [Sernadas et al., 1987; Ehrich and Sernadas, 1995; Ehrich, 1999; Ehrich and Hartel, 1996] and on the TROLL language project [Hartmann et al., 1995; Jungclaus et al., 1996; Hartel et al., 1997]. Other noteworthy object specification approaches related to algebraic specification are FOOPS [Goguen and Meseguer, 1987; Goguen and Socorro, 1995] and MAUDE [Meseguer, 1993]: FOOPS is based on the specification language OBJ3 [Goguen and Winkler, 1988]; MAUDE is based on rewriting logic that is a uniform model of concurrency [Meseguer, 1992].
16 16.1
The categorical approach Categories
Many authors use categories to introduce and discuss the topics treated in this chapter (e.g. [Ehrig and Mahr, 1985; Ehrig and Mahr, 1990; Sannella and Tarlecki, 2001]). By its very abstractness category theory can lead to more general results and avoid repeating similar proofs. On the other hand the approach may be difficult to understand for a reader who is not familiar with category theory. The first clue in this approach is the fact that any class of algebras together with their homomorphisms constitutes a category. A monomorphic module (in the sense of Definition 14.2(iii)) may then be viewed as a functor on such categories. Several notions introduced and properties proved in the present chapter may be viewed as notions and properties from category theory. For instance, the notions of an initial algebra and of a reduct correspond to the categorical notions of an initial object and—at least in the case of an inclusion—of a forgetful functor. As another example, the notion of a free extension is related to the categorical notion of a free functor. Another interesting category is constituted by the atomic specifications together with their specification morphisms (see Definition 13.19(ii)). It allows one to define the amalgamated union (Definition 13.18) and the parameter passing mechanism as pushouts (see section 14.6). The reader interested in category theory and its application to the specification of abstract data types may consult [Sannella and Tarlecki, 2001].
16.2
Institutions
An institution constitutes a generalization of the notion of (algebra) logic introduced in Definition 6.1. For instance, signatures together with their signature morphisms are merely supposed to form a category instead of being the concrete objects in Definitions 2.1 and 5.1. While most of the properties of section 7 still hold, institutions allow a large variety of signatures (including, for instance, order-sorted signatures and higher-order
310
J. Loeckx, H.-D. Ehrich and M. Wolf
signatures), of models (including, for instance, error-algebras and partial algebras) and of logics (including temporal logics). Definition 16.1 (Institution). Let SET be the category of sets and CAT the category of all categories. An institution is a 4-tuple (SIG, Sen, Mod, (=) where: (i) SIG is a category; the objects of SIG are called signatures, and its morphisms signature morphisms; (ii) Sen : SIG —> SET is a functor; for any signature S of SIG, the elements of the set Sen(S) are called (Z)- formulas (or: (E)-sentences); (iii) Mod : SIG —>• CATOJ> is a functor where CATop is the opposite category of CAT; for any signature £ of SIG, the objects of the category Mod(S) are called E-models; (iv) |= = (|=E)E6SiG is a family of relations denned for each signature £ of SIG where (=E C |Mod(£)| x Sen(S) and where |Mod(E)| denotes the class of objects of the category Mod(E). It is required that the following condition is satisfied: For any signature morphism /j, : E —» £' of SIG, any formula ip of Sen(E) and any model M' of Mod(S'), Mod(fj.)(M') ^vV&M' The reader interested in more details may consult [Goguen and Burstall, 1992; Sannella and Tarlecki, 2001].
References [Abrial, 1996] J. R. Abrial. The B-book: Assigning Programs to Meaning. Cambridge University Press, 1996. [Andrews and Ince, 1991] D. Andrews and D. Ince. Practical Formal Methods with VDM. McGraw-Hill, 1991. [Astesiano et al, 1999a] E. Astesiano, M. Broy and G. Reggio. Altebraic specification of concurrent systesm. In E. Astesiano, H.-J. Kreowski and B. Krieg-Briickner, editors, Algebraic Foundations of Systems Specification, pages 467-520. Springer- Verlag, 1999. [Astesiano et al, 1999b] E. Astesiano, H.-J. Kreowski and B. KriegBriickner, editors, Algebraic Foundations of Systems Specification, Springer- Verlag, 1999. [Astesiano and Reggio, 1987] E. Astesiano and G. Reggio. An outline of the SMoLCS methodology. In M. V. Zilli, editor, Proc. Advanced School on Mathematical Models for the Semantics of Parallelism, Lecture Notes in Computer Science 280, pages 81-113. Springer- Verlag, 1987. [Astesiano and Reggio, 1993] E. Astesiano and G. Reggio. Algebraic specification of concurrency. In M. Bidoit and C. Choppy, editors, Recent
Algebraic specification of abstract data types
311
Trends in Data Type Specification, Lecture Notes in Computer Science 655, pages 1-39. Springer-Verlag, 1993. [Avenhaus, 1995] J. Avenhaus. Reduktionssysteme. Springer-Verlag, 1995. [Barstow, 1983] D. Barstow, editor. The Programming Language Ada. Reference Manual. Lecture Notes in Computer Science 155, Springer-Verlag, 1983. [Bergstra and Tucker, 1983] J.A. Bergstra and J.V. Tucker. Initial and final algebra semantics: two characterization theorems. SIAM Journal of Computation, 12(2):366-387, 1983. [Bibel, 1993] Wolfgang Bibel. Deduction: Automated Logic. Academic Press, 1993. [Bidoit, 1989] M. Bidoit. PLUSS, un langage pour le developpement de specifications algebriques modulaires. These d'etat, Universite ParisSud, Orsay, 1989. [Bidoit, 1991] M. Bidoit. Development of modular specifications by stepwise refinement using the PLUSS specification language. Rapport de Recherche LIENS-91-9, Ecole Normale Superieure, 1991. [Bidoit and Hennicker, 1995a] M. Bidoit and R. Hennicker. Behavioural theories. In E. Astesiano, G. Reggio, and A. Tarlecki, editors, Recent Trends in Data Type Specification, Lecture notes in Computer Science 906, pages 153-169. Springer-Verlag, 1995. [Bidoit and Hennicker, 1996] M. Bidoit and R. Hennicker. Behavioural' theories and the proof of behavioural properties. Theoretical Computer Science, 165(1): 3-55, 1996. [Bidoit and Hennicker, 1998] M. Bidoit and R. Hennicker. Modular correctness proofs of behavioural implementations. Acta Inforamtica, 35(11):951-1005, 1998. [Bidoit et al., 1999] M. Bidoit, M. Cengarle, R. Hennicker. Proof systems for structured specifications and their refinements. In E. Astesiano, H.J. Kreowski and B. Krieg-Briickner, editors, Algebraic Foundations of Systems Specification. Springer-Verlag, 1999. [Broy et al, 1993] M. Broy, C. Facchi, R. Grosu, R. Hettler, H. Hettler, H. Hussmann, D. Nazareth, F. Regensburger, O. Slotosch, and K. St01en. The requirement and design specification language SPECTRUM: an informal introduction (Version 1.0). Technical report, Technische Universitat Miinchen, 1993. [Burstall and Goguen, 1980] R. M. Burstall and J.A. Goguen. The semantics of CLEAR, a specification language. In E. Bjorner, editor, Proc. Advanced Course on Abstract Software Specifications, Lecture Notes in Computer Science 86, pages 292-332. Springer-Verlag, 1980. [Cerioli et al., 1997] M. Cerioli, M. Gogolla, H. Kirchner, B. Krieg-Briickner, Z. Qian,
312
J. Loeckx, H.-D. Ehrich and M. Wolf
and M. Wolf, editors. Algebraic System Specification and Development: Survey and Annotated Bibliography (Second Edition), Shaker-Verlag, Aachen, 1997. [Classen, 1989] I. Classen. I. Classen. Revised ACT ONE: Categorical cnstructions for an algebraic specification language. In H. Ehrig, H. Herrlich, H.-J. Kreowski and G. Preuss, editors, Categorical Mthods in Computer Science, Lecture Notes in Computer Science 393, pages 435-465. Springer-Verlag, 1989. [Classen et al., 1993] I. Classen, H. Ehrig, and D. Wolz. Algebraic Specification Techniques and Tools for Software Development: The ACT Approach. World Scientific Publishing Co., 1993. [Dauchy and Gaudel, 1994] P. Dauchy and M.-C. Gaudel. Algebraic specifications with implicit state. Technical report, Universite Paris-Sud, 1994. [Ebbinghaus et al., 1984] H.-D. Ebbinghaus, J. Flum, and W. Thomas. Mathematical Logic. Springer-Verlag, 1984. [Ehrich, 1978] H.-D. Ehrich. Extensions and implementations of abstract data type specifications. In J. Winkowski, editor, Mathematical Foundations of Computer Science, Lecture Notes in Computer Science 64, pages 155-164. Springer-Verlag, 1978. [Ehrich, 1999] H.-D. Ehrich. Object specification. In E. Astesiano, H.J. Kreowski and B. Krieg-Briickner, editors, Algebraic Foundations of System Specification, pages 435-465. Springer-Verlag, 1999. To appear. [Ehrich and Hartel, 1996] H.-D. Ehrich and P. Hartel. Temporal specification of information systems. In A. Pnueli and H. Lin, editors, Logic and Software Engineering. Proceedings of the International Workshop in Honor of C. S. Tang, Beijing, pages 43-71. World Scientific, 1996. [Ehrich and Lohberger, 1979] H.-D. Ehrich and V.G. Lohberger. Constructing specifications of abstract data types by replacements. In V. Glaus, H. Ehrig, and G. Rozenberg, editors, Proc. Colloq. on Graph Grammars, Lecture Notes in Computer Science 73, pages 180-191. Springer-Verlag, 1979. [Ehrich and Sernadas, 1995] H.-D. Ehrich and A. Sernadas. Local specification of distributed families of sequential objects. In E. Astesiano, G. Reggio, and A. Tarlecki, editors, Recent Trends in Data Type Specification, Lecture Notes in Computer Science 906, pages 219-235. SpringerVerlag, 1995. [Ehrich et al., 1989] H.-D. Ehrich, M. Gogolla, and U. Lipeck. Algebraische Spezifikation abstrakter Datentypen. Teubner-Verlag, 1989. [Ehrig and Mahr, 1985] H. Ehrig and B. Mahr. Fundamentals of Algebraic Specification 1. Equations and Initial Semantics. Springer-Verlag, 1985. [Ehrig and Mahr, 1990] H. Ehrig and B. Mahr. Fundamentals of Algebraic
Algebraic specification of abstract data types
313
Specification 2. Module Specifications and Constraints. Springer-Verlag, 1990. [Ehrig et al., 1990] H. Ehrig, F. Parisi-Presicce, P. Boehm, C. Rieckhoff, C. Dimitrovici, and M. Grosse-Rhode. Combining data type and recursive process specifications using projection algebras. Theoretical Computer Science, 71:347-380, 1990. [Ehrig et al, 1995] H. Ehrig, M. Lowe, and F. Orejas. Dynamic abstract data types based on algebraic graph transformations. In E. Astesiano, G. Reggio, and A. Tarlecki, editors, Recent Trends in Data Type Specification, Lecture Notes in Computer Science 906, pages 236-254. SpringerVerlag, 1995. [Gogolla et al., 1984] M. Gogolla, K. Drosten, U.W. Lipeck, and H.-D. Ehrich. Algebraic and operational semantics of specifications allowing exceptions and errors. Theoretical Computer Science, 34:289-313, 1984. [Goguen and Burstall, 1992] J.A. Goguen and R.M. Burstall. Institutions: Abstract model theory for specification and programming. Journal of the Association for Computing Machinery, 39(1):95-146, 1992. [Goguen and Diaconescu, 1993] J.A. Goguen and R. Diaconescu. A short Oxford survey of order sorted algebra. In G. Rozenberg and A. Salomaa, editors, Current Trends in Theoretical Computer Science. Essays and Tutorials, pages 209-222. World Scientific Series in Computer Science 40, World Scientific,1993. [Goguen and Meseguer, 1987] J.A. Goguen and J. Meseguer. Unifying functional, object oriented and relational programming with logical semantics. In B. Shriver and P. Wegner, editors, Research Directions in Object-Oriented Programming, pages 417-477. MIT Press, 1987. [Goguen and Meseguer, 1992] J.A. Goguen and J. Meseguer. Ordersorted algebra I: equational deduction for multiple inheritance, overloading, exceptions and partial operations. Theoretical Computer Science, 105(2):217-273, 1992. [Goguen and Socorro, 1995] J.A. Goguen and A. Socorro. Module composition and system design for the object paradigm. Journal of Object Oriented Programming, 7(14), 1995. [Goguen and Winkler, 1988] J.A. Goguen and T. Winkler. Introducing OBJ3. Research report SRI-CSL-88-9, SRI International, 1988. [Guttag and Horning, 1993] J.V. Guttag and J.J. Horning. Larch: Languages and Tools for Formal Specification. Springer-Verlag, 1993. [Guttag et al., 1985] J. Guttag, J. Horning, and J. Wing. Larch in five easy pieces. Internal report SRC TR# 5, Digital Equipment Corporation, 1985. [Hartel et al., 1997] P. Hartel, G. Denker, M. Kowsari, M. Krone and H.-D. Ehrich. Information systems modelling with TROLL—Formal methods at work. Information Systems, 22(2-3):79-99, 1997.
314
J. Loeckx, H.-D. Ehrich and M. Wolf
[Hartmann et al., 1995] T. Hartmann, G. Saake, R. Jungclaus, P. Hartel, and J. Kusch. Revised Version of the Modelling Language TROLL (Version 2.0). Informatik-Bericht 94-03, Technische Universitat Braunschweig, 1995. [ISO-LOTOS, 1989] ISO-LOTOS. A formal description technique based on the temporal ordering of observational behaviour. Technical report IS 8807. International Standards Organization, 1989. [Jungclaus et al, 1996] R. Jungclaus, G. Saake, T. Hartmann, and C. Sernadas. TROLL—a language for object-oriented specification of information systems. ACM Transactions on Information Systems, 14(2): 175211, 1996. [Kaplan, 1989] S. Kaplan. Algebraic specification of concurrent systems. Theoretical Computer Science, 69(1):69-115, 1989. [Kay, 1993] A. Kay. The early history of Smalltalk. ACM SIGPLAN Notices, pages 69-96, March 1993. [Kay and Goldberg, 1976] A. Kay and A. Goldberg. Smalltalk-72 Instruction manual. Technical report, Xerox PARC, March 1976. [Klop, 1992] J.W. Klop. Term rewriting systems. In S. Abramsky, D.M. Gabbay, and T.S.E. Maibaum, editors, Handbook of Logic in Computer Science. Volume 2. Background: Computational Structures, pages 2-117. Clarendon Press, 1992. [Lehmann and Loeckx, 1993] T. Lehmann and J. Loeckx. OBSCURE, a specification language for abstract data types. Acta Informatica, 30(4):303-350, 1993. [Loeckx, 1997] J. Loeckx. Hierarchical constructive specifications and their termination. Internal note, Computer Science Department, University of Saarbrucken, 1997. [Loeckx and Sieber, 1987] J. Loeckx and K. Sieber. The Foundations of Program Verification. Wiley/Teubner, 1987. [Loeckx and Zeyer, 1995] J. Loeckx and J. Zeyer. Experiences with a specification environment. In M. Broy and S. Jahnichen, editors, KORSO: Methods, Languages and Tools for the Construction of Correct Software, Lecture Notes in Computer Science 655,, pages 255-268. Springer LNCS 1009, 1995. [Loeckx et al., 1996] J. Loeckx, H.-D. Ehrich, and M. Wolf. Specification of Abstract Data Types. Wiley/Teubner, 1996. [Meseguer, 1992] J. Meseguer. Conditional rewriting as a unified model of concurrency. Theoretical Computer Science, 96(1):73-156, 1992. [Meseguer, 1993] J. Meseguer. A logical theory of concurrent objects and its realization in the Maude language. In G. Agha, P. Wegener, and A. Yonezawa, editors, Research Directions in Object-Oriented Programming, pages 314-390. MIT Press, 1993.
Algebraic specification of abstract data types
315
[Mosses, 1993] P.D. Mosses. The use of sorts in algebraic specifications. In M. Bidoit and C. Choppy, editors, Recent Trends in Data Type Specification, Lecture Notes in Computer Science 655, pages 66-92. Springer LNCS 655, 1993. [Mosses, 1999] P. Mosses. CASL. A guided tour of its design. In J. Fiadeiro, editor, Recent Trends in Algebraic Development Techniques, Lecture Notes in Computer Science 1589. Springer-Verlag, 1999. [Orejas et al, 1993] F. Orejas, M. Navarro, and A. Sanchez. Implementation and behavioural equivalence: a survey. In M. Bidoit and C. Choppy, editors, Recent Trends in Data Type Specification, Lecture Notes in Computer Science 655, pages 93-125. Springer-Verlag, 1993. [Padawitz, 1988] P. Padawitz. Computing in Horn Clause Theories. Springer-Verlag, 1988. [Paulson, 1991] L.C. Paulson. ML for the Working Programmer. Cambridge University Press, 1991. [Raise Development Group, 1995] The Raise Development Group. The Raise Development Method. BCS Practitioners Series. Prentice Hall International, 1995. [Reichel, 1987] H. Reichel. Initial Computability, Algebraic Specifications and Partial Algebras. Oxford University Press, 1987. [Ryan and Sadler, 1992] M. Ryan and M. Sadler. Valuation systems and consequence relations. In S. Abramsky, D.M. Gabbay, and T.S.E. Maibaum, editors, Handbook of Logic in Computer Science. Volume 1. Background: Computational Structures, pages 1-78. Clarendon Press, 1992. [protectSannella, 1999] D. Sannella. CoFI WG 29432. - Interim Report 1 October 1998 - 30 September 1999. Internal paper, Computer Science Department, University of Edinburgh, 1999. [Sannella and Tarlecki, 2001] D. Sannella and A. Tarlecki. Foundations of Algebraic Specifications and Formal Program Development. Cambridge University Press, 2001. Scheduled to appear in 2001. [Sannella and Wirsing, 1999] D. Sannella and M. Wirsing. Specification languages. In E. Astesiano, H.-J. Kreowski, and B. Krieg-Briickner, editors, Algebraic Foundations of Systems Specifications, pages 243-272. Springer-Verlag, 1999. [Sernadas et al., 1987] A. Sernadas, C. Sernadas, and H.-D. Ehrich. Object-oriented specification of databases: an algebraic approach. In P.M. Stoecker and W. Kent, editors, Proc. 13th Int. Conf. on Very Large Data Bases, pages 107-116. VLDB Endowment Press, 1987. [Spivey, 1989] J.M. Spivey. The Z Notation. Prentice Hall, 1989. [Tucker and Meinke, 1992] J.V. Tucker and K. Meinke. Universal algebra. In S. Abramsky, D.M. Gabbay, and T.S.E. Maibaum, editors, Hand-
316
J. Loeckx, H.-D. Ehrich and M. Wolf
book of Logic in Computer Science. Volume 1, pages 189-411. Clarendon Press, 1992. [Wirsing, 1986] M. Wirsing. Structured algebraic specifications: a kernel language. Theoretical Computer Science, 42(2): 123-250, 1986. [Wirsing, 1993] M. Wirsing. Structured specifications: syntax, semantics and proof calculus. In F.L. Bauer, W. Brauer, and H. Schwichtenberg, editors, Logic and Algebra of Specification, pages 411-442. SpringerVerlag, 1993. [Wirsing, 1995] M. Wirsing. Algebraic specification languages: an overview. In E. Astesiano, G. Reggio, and A. Tarlecki, editors, Recent Trends in Data Type Specification, Lecture Notes in Computer Science 906, pages 81-115. Springer-Verlag, 1995. [Woodman and Heal, 1993] M. Woodman and B. Heal. Introduction to VDM. McGraw-Hill, 1993. [Zucca, 1999] E. Zucca. From static to dynamic data types: an institution transformation. Theoretical Computer Science, 216:109-157, 1999.
Computable functions and semicomputable sets on many-sorted algebras J. V. Tucker and J. I. Zucker
Contents 1
2
3
Introduction 1.1 Computing in algebras 1.2 Examples of computable and non-computable functions . 1.3 Relations with effective algebra 1.4 Historical notes on computable functions on algebras . . 1.5 Objectives and structure of the chapter 1.6 Prerequisites Signatures and algebras 2.1 Signatures 2.2 Terms and subalgebras 2.3 Homomorphisms, isomorphisms and abstract data types 2.4 Adding Booleans: Standard signatures and algebras . . . 2.5 Adding counters: TV-standard signatures and algebras . . 2.6 Adding the unspecified value ui; algebras A" of signature Eu 2.7 Adding arrays: Algebras A*_of signature IT* 2.8 Adding streams: Algebras A of signature £ While computability on standard algebras 3.1 Syntax of While(E) 3.2 States 3.3 Semantics of terms 3.4 Algebraic operational semantics 3.5 Semantics of statements for While(Yi) 3.6 Semantics of procedures 3.7 Homomorphism invariance theorems 3.8 Locality of computation 3.9 The language WhileProc("S) 3.10 Relative While computability 3.11 .For(£) computability 3.12 WhileN and ForN computability
319 322 325 329 335 340 343 344 344 349 350 351 353 355 356 359 360 361 363 363 364 366 368 371 372 374 375 376 377
318
4
5
6
J. V. Tucker and J. I. Zucker 3.13 While* and For* computability 3.14 Remainder set of a statement; snapshots 3.15 £*/£ conservativity for terms Representations of semantic functions; universality 4.1 Godel numbering of syntax 4.2 Representation of states 4.3 Representation of term evaluation 4.4 Representation of the computation step function 4.5 Representation of statement evaluation 4.6 Representation of procedure evaluation 4.7 Computability of semantic representing functions; term evaluation property 4.8 Universal WhileN procedure for While 4.9 Universal WhileN procedure for While* 4.10 Snapshot representing function and sequence 4.11 Order of a tuple of elements 4.12 Locally finite algebras 4.13 Representing functions for specific terms or programs . . Notions of semicomputability 5.1 While semicomputability 5.2 Merging two procedures: Closure theorems 5.3 Projective While semicomputability: semicomputability with search 5.4 WhileN semicomputability 5.5 Projective WhileN semicomputability 5.6 Solvability of the halting problem 5.7 While* semicomputability 5.8 Projective While* semicomputability 5.9 Homomorphism invariance for semicomputable sets . . . 5.10 The computation tree of a While statement 5.11 Engeler's lemma 5.12 Engeler's lemma for While* semicomputability 5.13 S* definability: Input/output and halting formulae . . . 5.14 The projective equivalence theorem 5.15 Halting sets of While procedures with random assignments Examples of semicomputable sets of real and complex numbers 6.1 Computability on E and C 6.2 The algebra of reals; a set which is projectively While semicomputable but not While* semicomputable . . . . 6.3 The ordered algebra of reals; sets of reals which are While semicomputable but not While* computable 6.4 A set which is projectively While* semicomputable but not projectively WhileN semicomputable
378 380 383 387 388 389 389 390 392 393 394 397 401 402 404 405 406 407 408 409 413 414 416 416 420 421 422 423 425 429 431 434 435 438 439 441 443 445
Computable functions on algebras 6.5
7
8
1
Dynamical systems and chaotic systems on E; sets which are WhileN semicomputable but not While* computable 6.6 Dynamical systems and Julia sets on C; sets which are WhileN semicomputable but not While* computable Computation on topological partial algebras 7.1 The problem 7.2 Partial algebras and While computation 7.3 Topological partial algebras 7.4 Discussion: Two models of computation on the reals . . . 7.5 Continuity of computable functions 7.6 Topological characterisation of computable sets in compact algebras 7.7 Metric partial algebra 7.8 Connected domains: computability and explicit definability 7.9 Approximable computability 7.10 Abstract versus concrete models for computing on the real numbers A survey of models of computability 8.1 Computability by function schemes 8.2 Machine models 8.3 High-level programming constructs; program schemes 8.4 Axiomatic methods 8.5 Equational definability 8.6 Inductive definitions and fixed-point methods 8.7 Set recursion 8.8 A generalised Church-Turing thesis for computability . . 8.9 A Church-Turing thesis for specification 8.10 Some other applications
319
447 449 451 452 453 455 458 460 464 465 465 470 475 479 479 484 488 490 490 492 493 493 496 500
Introduction
The theory of the computable functions is a mathematical theory of total and partial functions of the form / : N™ ->• N,
and sets of the form
SCW1
that can be defined by means of algorithms on the set
320
J. V. Tucker and J. I. Zucker
of natural numbers. The theory establishes what can and cannot be computed in an explicit way using finitely many simple operations on numbers. The set of naturals and a selection of these simple operations together form an algebra. A mathematical objective of the theory is to develop, analyse and compare a variety of models of computation and formal systems for defining functions over a range of algebras of natural numbers. Computability theory on N is of importance in science because it establishes the scope and limits of digital computation. The numbers are realised as concrete symbolic objects and the operations on the numbers can be carried out explicitly, in finitely many concrete symbolic steps. More generally, the numbers can be used to represent or code any form of discrete data. However, the question arises: Can we develop theories of functions that can be defined by means of algorithms on other sets of data? The obvious examples of numerical data are the integer, rational, real and complex numbers; and associated with these numbers there are data such as matrices, polynomials, power series and various types of functions. In addition, there are geometric objects that are represented using the real and complex numbers, including algebraic curves and manifolds. Examples of syntactic data are finite and infinite strings, terms, formulae, trees and graphs. For each set of data there are many choices for a collection of operations from which to build algorithms. How specific to the set of data and chosen operations are these computability theories? What properties do the computability theories over different sets of data have in common? The theory of the computable functions on N is stable, rich and useful; will the theory of computable functions on the sets of real and complex numbers, and the other data sets also be so? The theory of computable functions on arbitrary many-sorted algebras will answer these questions. It generalises the theory of functions computable on algebras of natural numbers to a theory of functions computable on any algebra made from any family of sets and operations. The notion of 'computable' here presupposes an algorithm that computes the function in finitely many steps, where a step is an application of a basic operation of the algebra. Since the data are arbitrary, the algorithm's computations are at the same level of abstraction as the data and basic operations of the algebra. For example, this means that computations over the field E of real numbers are exact rather than approximate. Thus, the algorithms and computations on algebras are intimately connected to their algebraic properties; in particular, the computability theory is invariant under isomorphisms. Already we can see that, in the general case, there is likely to be a ramification of computability notions. For example, in the case of computable functions on the set E of real numbers it is also natural to consider
Computable functions on algebras
321
computability in terms of computing approximations to the values of a function. The use of approximations recognises the fact that data like the real numbers are infinite objects and can, or must, be algorithmically approximated. This is the approach of computable analysis. We wll present two approaches to computation on the reals: 'algebraic' and 'topological'. In our algebraic approach we are looking for what can be computed exactly, knowing only what the operations reveal about the reals. The operations may have been chosen to reveal properties that are specific to the reals, of course. In the topological approach we are looking for what can be computed with essentially infinite data on the basis of a finite amount of information. Actually, this is again, at bottom, an algebraic approach, for the performance of approximate computations. In this chapter our objective is to show the following: 1. There is a general theory of computable functions on an arbitrary algebra that possesses generalisations of many of the important results in computability theory on natural numbers. 2. The theory provides technical concepts and results that improve our understanding of the foundations of classical computability and definability theory on N. 3. The theory has a wide range of applications in mathematics and computer science. 4. The theory can be developed using many models of computation that are equivalent in that they define the same class of computable functions. 5. The theory possesses a generalisation of the Church-Turing thesis for functions and sets computed by algorithms on any abstract algebraic structure. 6. The theory generalises other less general but still abstract and algebraic, theories of finite computation, including effective algebra and computable analysis. Computability theories on particular and general classes of algebras address central concerns in mathematics and computer science. Some, such as effective algebra, have a long history and several subfields with deep results, such as the theory of computable rings and fields and the word problem for groups. However, abstract computability theories of the kind we will develop have a short and less eventful history: starting in the late 1950s, with theoretical work on flowcharts, many approaches have been presented that vary in their generality and objectives; indeed, there has been a remarkable amount of reinventing of ideas and results, sometimes with new motivations, such as obtaining results on: the structure of flowcharts; the power of programming constructs; the design of program correctness logics; the development of axiomatic foundations for generalised recursion theories based on ordinals and higher types; and the study of algorithmic aspects of ring and field theory, and of dynamical system theory.
322
J. V. Tucker and J. I. Zucker
In this section we will introduce in a very informal way the model of computation we will use (in section 1.1) and pose some questions about examples of computable functions (in section 1.2). Then, in section 1.3, we will outline the relationship between our model and other models of computation, especially effective algebra and computable analysis. In section 1.4 the history of the theory of computable functions on abstract algebras is sketched. In sections 1.5 and 1.6 the structure of the chapter and its prerequisites are discussed in more detail. The chapter is closely linked scientifically with the chapters in this Handbook on universal algebra (Volume I), computability (Volume I), and effective algebra (Volume IV); it also connects with other subjects (e.g., topology (Volume I) and those on semantics (Volumes III and IV)). Further information on prerequisites is given in section 1.6.
1.1
Computing in algebras
Let us begin with a basic question: Let S be a non-empty set of data and let f : Sn —> S be a total or partial function. How do we compute f ? The methods we have in mind start with postulating an algebra A containing the set 5. The algebra may consist of a finite family of non-empty sets Ai , . . . , Ak called the carriers of the algebra, one of which is the set S and another is the set B of Booleans. The algebra is also equipped with a finite family Cl , . . . , Cp
of elements of the sets, called constants, and a finite family
of functions on the sets called operations; these functions are of the form F : ASl x ...x ASn -» As
and can be total or partial. Among the operations are some standard functions on the Booleans. Such an algebra is called a standard manysorted algebra; we say it is standard because it contains the Booleans and their special operations. An algebra is often written (Ai,... ,Ak, ci,... ,cp,Fi,... ,Fq). A set £ of names for the data set, constants and operations (and their arities) of the algebra A is called a signature.
Computable functions on algebras
323
For most of the time we will use many-sorted algebras with finitely many constants and total operations, but we will need the case of partial operations to discuss the relationship between our computable functions and continuous functions on topological algebras such as algebras of real numbers, and algebras with infinite data streams. The problem is to develop and classify models of computation that describe ways of constructing new functions on the set 5 from the basic operations of the algebra A. In particular, each model of computation M is a method or technique which we use to define the notion that the function / on the carriers of A is computable from the operations on A by means of method M ; and we collect all such functions into the set M-Comp(A) of functions X-computable over the algebra A. There are many useful choices for a model of computation M with which to develop a computability theory— we list several in a survey in section 8. In this chapter we focus on a theory for computing with a simple imperative model, namely the While programming language. In this programming language, basic computations on an algebra A are performed by concurrent assignment statements of the form
where xi, . : . , xra are program variables and t\ , . . . ,tn are terms or expressions built from variables and the operation symbols from the signature of the algebra A; and x^ and ti correspond in their types (1 < i < n). The control and sequencing of the basic computations are performed by three constucts that form new programs from given programs Si, S^ and S, and Boolean test b: (i) the sequential composition construct
(ii) the conditional branching construct if b then Si else 52 fi (Hi) the iteration construct while b do S od. The set of all programs so constructed over the signature E is denoted While(£). The operational semantics of a While program is a function that, given an initial state, enumerates every state of a resulting computation. The input/output (i/o) semantics of a while program is a function that
324
J. V. Tucker and J. I. Zucker
transforms initial states to final states, if they exist. To compute a function on A by means of a While program we formulate a simple class of function procedures based on While programs; a function procedure P has the form P = proc in a out b aux c begin 5 end where a, b, c are lists of input, output and auxiliary variables, respectively, and 5 is a While program, satisfying some simple conditions. The semantics of a procedure P is a function [P]"4 on A whose input and output types are determined by the types of the lists of input and output variables a and b. A function / is While computable on algebra A if there is a While function procedure that computes it, i.e., {P]A = /. All While computable functions on A are collected in the set While(A). A set is defined to be While computable, or decidable, if its characteristic function is While computable. It is While semicomputable, or semidecidable, if it is the domain of a partial While computable function; in other words, if it is the halting set of a While program. A crucial property of an abstract model of computation is that it is designed to apply to any algebra or class of algebras. Two important consequences are the following. Firstly, it is easy to explore uniform computation where programs generate computations over a class of implementations or representations of data types in a uniform way. For example, think of a While program that is intended to implement Euclid's algorithm to calculate greatest common divisors in a way that is uniform over a class of algebras. By such a 'class' we could mean, for example, any of the following: (i) the class of all Euclidean domains, (ii) the isomorphism class of all (ideal, infinite) implementations of the ring of integers, (Hi) the class of (actual, finite) machine implementations of the integers. Secondly, it is easy to employ certain forms of type constructions. Since we can compute on any algebra (possessing the Booleans) using the programming model, we can augment an algebra A to form a new algebra A', by adding new types and operations, and apply the programming model to A'. Adding new data sets and operations is a key activity in theory and practice. In particular, three modest expansions of an algebra A that have significant practical effects and (as we shall show) interesting mathematical theories are: (a) adding the set N of natural numbers and its standard operations to A to make a new algebra AN; (b) adding finite sequences, and appropriate operations, to A to make an algebra A*. (c) adding infinite streams, and appropriate operations, to A to make an algebra A.
Computable functions on algebras
325
We apply the model of computation to form new classes of computable functions, namely: While(AN),
While(A*)
and
WhUe(A).
By this means it is trivial to add constructs like counters, finite arrays and infinite data streams to the theory of computation, though it is not trivial to chart the consequences. In summary, what mechanisms are available for computing in an algebra? The methods of computation are merely: (i) basic operations of the algebra; and (n) sequencing, branching and iterating the operations. Is equality computable? Do we have available unlimited data storage? Can we search the algebra for data? We will see that for any many-sorted algebra A with the Booleans, by adding the naturals, we can add (Hi) any algorithmic construction on a numerical data representation; and, by adding A*, we can add (iv) local search through all elements of the subalgebra generated by given input data; (v) unlimited storage for data in computations. To obtain equality we have to postulate it as a basic operation of the algebra. We will study these models of computation. The most important turns out to be the programming language While*, which consists of While programs with the naturals and finite arrays, and is defined simply by While" (A) = While(A'). This is the fundamental model of imperative programming that yields a full generalisation, to an arbitrary many-sorted algebra A, of the theory of computable functions on the set N of natural numbers, and for which the generalised Church-Turing thesis for computation on A will be formulated and justified.
1.2
Examples of computable and non-computable functions
First, let us look at the raw material of our theory, namely problems concerning computing functions and sets on specific algebraic structures. We will give a list of questions about computing with While programs on different algebras and invite the reader to speculate on their answers; it is not essential that the reader understand or recognise all the concepts in the examples. The idea is to prepare the reader for the role of algebraic structures in the theory of computable functions and sets, and arouse his or her curiosity.
326
J. V. Tucker and J. I. Zucker
Let B be the set of Booleans and let N, Z, Q, R and C be the sets of natural, integer, rational, real and complex numbers, respectively. 1. Are the sets of functions While computable over the following algebras the same as those computable over (N; 0, n + 1)? (N; 0, n + 1, n + m, n • m, n = m) (N; 0, n + 1, n + m, n • m, nm, n — m) (N; 0, 1, n + m, n • m, n = m) (N; 0, n + m, n • m, n = m) (N; 0, n + m, n = m) (N; 0, n • m, n — m) 2. Consider each of the following functions: f(n) /(n) f(n)
3. 4. 5.
6.
7.
= 4 =n =n+1
f(n,m) —n + m f(n,m) = n —m In each case is / € W7iz/e(N; 0, n — 1)? Let B be the set of Booleans and / : B* -»• B. Is / eW7«Je(B;tt,f, and, not)? Let A be a finite set and / : A -> A. Is / 6 While(A; c\,... , cp, FI, ... ,Fq) for any choice of constants c, and operations Fj on Af Consider the algebra (B,N,[N ->B]; tt,ff, and, not,0, n + l,eval) of Booleans expanded by adding the set N of naturals with zero and successor, and the set [N -> B] of infinite sequences, or streams, of Booleans, with the evaluation map eval:[N —> B] x N —» B defined by eval(6, n) = b(n). Are the following functions While computable over this algebra: shift: [N -» B] x N ->• B defined by shift(a,n) = o(n + 1); Shift: [N -> B] -> [N ->• B] defined by Shift(a)(n) = o(n + 1)? Which of the following sets of Boolean streams are (i) While computable, and (n) While semicomputable, over the stream algebra in question 5? { a | for some n, a(n) =tt} { a I for all n, a(n) =tt) { a | for infinitely many n, a(n) = tt} { a | a(0) = tt, ... , a(n) =tt} for some fixed n Consider each of the following functions: f(x) = 4 f ( x ) = floor(^) f ( x ) = x/2 f ( x ) = 1* f(x) = TT f(x) = sin(x) f(x) = x f(x) = cos(a;) f(x) = x5 f(x) = tan(x) /(x) = v/x /(x) = ex
Computable functions on algebras
327
In each case, is / While computable over (E;0, l,x + y,—x, x-y,x'1) 8. Are cos(a;) and tan(x) While computable over (E;0, l,a; + |/, — x, x-y,x~l,sin(x})'? 9. Let / : E2 ->• E be the step function f(^r)
10.
11. 12. 13.
/Oifa;<7= { , ., ^ I 1 if x > r.
Is / While computable over (E; 0, 1, x + y, -x, x • y, x""1)? Which of the following subsets of E are (a) While computable, and (6) While semicomputable, over the field of real numbers? (z) The rational subfield Q of the field of reals (ii) The subfield Q(>/2) of the field of reals generated by Q and \/2 (Hi) The subfield Q(y^ | p prime) of the field of reals generated by Q and the set {^/p \ p prime} (iv) The subfield Q(r) of the field of reals generated by Q and a non-computable real number r (v) The subfield AR of the field of reals containing precisely the real algebraic numbers Is the subalgebra A of (E; 0, 1, x + y, —x, x • y, a;"1, ex) generated by Q While semidecidable? Is there a While program over (E; 0, 1, x + y, -x, x • y, a;"1, \/x) that computes all the real roots of all quadratic equations with real coefficients? Consider the polynomial p(X) = a0 + aiX + a 2 X 2 + ... + anXn
(a 0 ,... , an € E).
(a) Is the set {x 6 M | p(x) = 0} of roots of p While decidable over (E; 0, 1, x + y, -x, x-y, x~l, o 0 ,... ,a n )? (ft) For each n find operations to add to the algebra (E; 0, 1, x + y, —x, x • y, x"1) to calculate the n roots of the polynomial as functions of the coefficients. 14. Consider the algebra (E, B; 0, 1, x + y, —x, x • y, x~l, x = y) which adds equality =: E2 -» B to the field of reals. What new functions / : E* ->• E can be computed? 15. Consider the algebra (E, B; 0, 1, x + y, —x, x-y, x~*, x = y, x < y) which adds ordering <: E2 -*• B to the field of reals. What new functions / : E* —> E can be computed? 16. Is every cyclic subgroup (t) of the circle group S1 While decidable?
328
J. V. Tucker and J. I. Zucker
17. If / : E -> E is While computable on (E; 0, 1, x+y, -x, x-y, x~l), is / continuous? 18. Can any continuous function / : E —» E be approximated (in some suitable metric) by a function While computable over (E; 0, 1, a; + 2/, -x, a;-?/, a;"1)? 19. What is the relationship, for functions on E, between computability in the sense of computable analysis, and While computability on (E; 0, I , x + y, -x, x - y , or1)? 20. Is there an algebra A(E) containing E, for which
Jtec(R) =
While(A(R)),
where JZec(fi) is the set of functions computable on E in the sense of recursive or computable analysis? 21. Consider the many-sorted algebra (E, N, [N -» E]; OR, 1R, x + y, -x, 0 N , n + 1, eval) that is an expansion of the additive Abelian group of reals, made by adding the naturals with zero and successor, infinite sequences or streams of real numbers, and the evaluation map eval : [N —> E] x N —> E defined by eval(o,n) = a(n). Are the following functions While computable on this algebra: add: [N -> M]2 x N ->• E defined by add(a,b,n) = a(n) + b(n); Add: [N -» M]2 ->• [N -> E] defined by Add(a, b)(n) = a(n) + b(n)l 22. Are complex conjugation — z and modulus \z\ of a complex number z While computable over the following algebras? (i) (C; 0, 1, x + y, -x, x • y, x~l) (ii) (C; 0, l,i,x + y, -x, x • y, 2T1) 23. Is the set {i} While decidable over either of the fields listed in question 22? 24. Consider the function f ( x ) = 4x(l — x) on the reals. Is the orbit of /, defined by orb(f,x)
= (fn(x)
| n e N, 0 < x < 1}
While computable over the field of real numbers? 25. Are the fractal subsets of C, such as the Mandelbrot and Julia sets, While decidable over the field of complex numbers? 26. Are the following subsets of C either While decidable, or While semidecidable, over the algebra (C, B; 0, 1, i, z\, x+y, —x, x-y, a;"1, = )? (i) The set {i} (ii) The set of all roots of unity (Hi) The set of all algebraic complex numbers
Computable functions on algebras
329
27. Consider the rings TL\X\,... ,Xn] of all polynomials in n indeterminates over the integers. Is the ideal membership relation q€ (pi,... ,p m ) (in q,pi,... ,pm) While decidable over this ring? 28. Consider the rings F[Xi,... ,Xn] of all polynomials in n indeterminates over a field F. Is the ideal membership relation While decidable over this ring? 29. Consider the algebra T(S, X) of all terms over signature £ in the finite set X of indeterminates. Let Ax be the set of assignments to X in an algebra A. Define the term evaluation function T: TE(E, X) x Ax -» A
by TE(t,a) = t(a). Is TE While computable over the algebra formed by simply combining the algebras T(£,X) and A! 30. (a) Are all first-order definable subsets of natural numbers While computable with respect to the following algebras? (i) (N; 0, n + 1, n + m, n • m) (M) (N; 0,n + l,n + m) (in) (N; 0, n + 1) (6) Are the While semicomputable sets precisely the Ei-definable sets with respect to these algebras? 31. Is any set of complex numbers that is first-order definable over the field of complex numbers While decidable over this field? Is any set of real numbers that is first-order definable over the ordered field of real numbers While decidable over this field?
1.3 Relations with effective algebra In computer science, many-sorted algebras are used to provide a general theory of data and, indeed, of whole computing systems. They have been employed to specify and analyse many new forms of data types; classify data representations; characterise which data types are implementable; model systems; analyse the modularisation of computing systems; formalise the correctness of systems; and reason about systems. A many-sorted algebra models a concrete representation of a data type or system; such representations are compared by homomorphisms, axiomatised by equations and conditional equations, and prototyped by term rewriting methods. There is a considerable theoretical and practical literature
330
J. V. Tucker and J. I. Zucker
available which may be accessed through survey works such as Meseguer and Goguen [1985], Wirsing [1991], Wechler [1992] and Meinke and Tucker [1992]. The theory of computable functions and sets on many-sorted algebras is intended to provide an abstract theory of computing to complement this abstract algebraic theory of data. With this in mind we ask the question: How is the theory of While computable functions and sets on many-sorted algebras related to other theories of computability on such algebras? We have mentioned earlier that there are many models of computation that can be applied to an arbitrary algebra and that turn out to define the same class of functions and sets as the While language; these equivalent models belong to the computability theory and are the subject of section 8. Here we will discuss an important approach to analysing computability on algebras called effective algebra. Effective algebra is concerned with what algebras are computable, or effective, and what functions and sets on these algebras are computable, or effective. The subject is explained in Stoltenberg-Hansen and Tucker [1995; 1999a]. A starting point for the discussion is the theory of the computable functions on the set N = {0,1,2,...} of natural numbers. According to the Church-Turing thesis, the class Comp(N) of computable function on N, defined by any one of a number of models of computation, is precisely the class of functions definable by means of algorithms on the natural numbers. As we have noted, the algorithms are often over some algebraic structure on N. In fact, seen from the algebraic theory of data, the algebras used form a class of concrete representations of the natural numbers that is parameterised by both the choice of operations and the precise nature of the number representations (e.g., binary, decimal and roman). The extent to which the theory of computable functions on N varies over the class of these algebras of numbers is an important question, but one that is not often asked. We expect there to be very little variation in practice (but compare questions 1 and 2 of section 1.2). In general terms, a computability theory consists of (a) a class of algebraic or relational structures to define data and operations; and (b) a class of methods, which we call a model of computation, to define algorithms and computations on the data using the operations. A generalised computability theory is one which can be applied to a structure containing the set N of natural numbers to define the set C7omp(N) of computable functions on Comp(H). An abstract computability theory is a computability theory in which the theory is invariant up to isomorphism (in some appropriate sense). To develop an abstract generalised computability theory for any algebra A, and classify the computable functions and sets on A, one can proceed
Computable functions on algebras
331
in either of the following two directions. One can apply computability theory on N to algebras using maps from sets of natural numbers to algebras called numberings. The long-established theories of decision problems in semigroups, groups, rings and fields, etc. are examples of this approach. Furthermore, the theory of computable functions Comp(R) on the set E of real numbers in computable analysis uses computability theory on Comp(N) to formalise how real number data and functions are approximated effectively. Theories based on these approaches are parts of what we here call effective algebra. Alternatively, one can generalise the computability theory on N to accommodate abstract structures; the theory of computable functions on many-sorted algebras developed in this chapter is an example, of course, and more will be said about equivalent models of computation in section 8. However, there are examples of generalised computation theories that are strictly stronger, such as ordinal recursion theory, set recursion theory, higher type recursion theory and domain theory. Typically these four generalised computability theories allow infinite computations to return outputs. To appreciate the diversity of some of these theories it is necessary to examine closely their original motivations; seen from our simple finitistic algebraic point of view, generalised recursion theories have a surprisingly untidy historical development. Let us focus on the first direction. Effective algebra is a theory that provides answers for questions such as: When is an algebra A computable? What functions on A are computable? What sets on A are decidable or, at least, semidecidable? It attempts to establish the scope and limits of computation by means of algorithms for any set of data, by applying the theory of computation on N to universal algebras containing the set of data using numberings. Thus, it classifies what data can be represented algorithmically, and what sets and functions can be defined by algorithms, in the same terms as those of the Church-Turing thesis for algorithms on N. Assuming such a thesis, we may then use the theory of the recursive functions on N to give precise answers to the above questions about algebras, and to the question: What sets of data and functions on those data can be implemented on a computer in principle? The numberings capture the scope and limits of digital data representation and, thus, effective algebra is a general theory of the digital view of computation. More specifically, in effective algebra we can investigate the consequences of the fact that 1. an algebra is computable; 2. an algebra is effective in some weaker senses; and
332
J. V. Tucker and J. I. Zucker
3. a topological algebra can be approximated by a computable or effective algebra. Among the weaker senses are the concepts of semicomputable, cosemicomputable and, most generally, effective algebras. For an algebra to be effective it must be countable, so that its elements may be enumerated. For an algebra to be effectively approximable it must have a topological structure, so that its elements may be approximated; the bulk of interesting topological algebras are uncountable. A full account of these concepts is given in Stoltenberg-Hansen and Tucker [1995]. At the heart of the theory of effective algebra is the notion of a computable algebra: a computable algebra is an algebra that can be faithfully represented using the natural numbers in a recursive way. Here is the definition for a single-sorted algebra: Definition 1.1. An algebra A = (A; c\ , . . . , cp, F\ , . . . , Fq) is computable if: (?) the data of A can be computably enumerated— there exists a recursive subset J7a C N and a surjection
a: na -» N called a numbering, that lists or enumerates, possibly with repetitions, all the elements of A; (ii) the operations of A are computable in the enumeration—for each operation Fj : An^ —>• A of A there exists a recursive function that tracks the f, in the set $la of numbers, in the sense that for all Xi, . . . , X n j
& ' 'a
(Hi) the equivalence of numerical representations of data in A is decidable — the equivalence relation =a defined by = a(x-2) s recursve. An equivalent formulation, in the algebraic theory of data, is that A is computable if it is the image of a recursive algebra Ha of numbers under a homomorphism a : J7Q —)• A whose kernel =a is decidable. (This simple algebraic characterisation leads to new methods of generalising computability theories: see Stoltenberg-Hansen and Tucker [1995]). What mechanisms are available for computing in a computable algebra? Via the enumeration, the methods include: (i) basic operations of the algebra; (ii) sequencing, branching and iterating the operations;
Computable functions on algebras (Hi) (iv) (v) (vi)
333
any algorithmic construction on the numerical data representation; global search through all elements of the algebra; unlimited storage for data in computations; the equality relation on the algebra via the congruence.
Conditions (i) and (ii) are shared with our While programming model and, indeed, are necessary for an algebraic theory: recall section 1.1. There are also a number of features that extend the methods of our While model, including conditions (Hi) and, more dramatically, (iv). Using the properties of the numbers that represent the data we can perform global searches through the data sets (by means of an ordering on the code set), and store data dynamically without limitations on data storage (by means of a pairing on the code set). Note that condition (vi) is a denning feature of computable algebras and can be relaxed (as in the case of semicomputable or effective algebras, for instance). Note that an algebra A is computable if there exists some computable numbering a for A. The computability of functions and sets over A may depend on the numbering a; thus, to be more precise, we should say that A, its functions and subsets etc. are a-computable. Let us define the computable subsets and functions for such an algebra. Definition 1.2 (Sets and maps). Let A be an algebra of signature S, computable under the numbering a : Oa —» A. (1) A set 5 = Ak is a-decidable, a-semidecidable or a-cosemidecidable if the corresponding set a~l(S) =
{(x1,...,xk)eflc,k\(a(xi),...,a(xk)€S}
of numbers is recursive, recursively enumerable (r.e.) or co-recursively enumerable (co-r.e.) respectively. (2) A function > : A -4 A is an a-computable map if there exists a recursive function / : $la —> HQ such that for all x € f l a , f ( a ( x ) ) = a(f(x)); or, equivalently, / commutes the following diagram:
a]
o
1-
\ o_
Let Compa(A) be the set of all a-computable maps on A. For any computable algebra, there are many computable numberings, some of which may have desirable properties; for example, it is the case that every computable algebra has a bijective numbering with code set N.
334
J. V. Tucker and J. I. Zucker
Let C(A) be the set of all computable numberings of the algebra A. The choice of a numbering a € C(A) suggests that the effectiveness of a subset or function on A may depend on a. To illustrate, let S C A and consider the following questions: Is S decidable for all computable numberings of A; or decidable for some, and undecidable in others; or undecidable for all computable numberings of A? Another question concerns the invariance of computable maps. // A is computable under two numberings a and /? then what is the relation between the sets Compa(A) and Compg(A)? What is Compa(A)t Consider our abstract model based on While programs. We have noted that While(N; 0, n + 1) = Comp(N). The question then arises for our algebras: What is the relationship between While(A) and Compa(A) for an arbitrary computable representation a ? We can prove that if A is computable then While(A) C
P|
Compa(A).
(1.1)
a€C(A)
(In fact this inclusion holds for much weaker hypotheses on A.) The converse inclusion does not hold in general. To see why, consider the algebra (N; 0, n - 1),
and the use of a While program to compute a function / : N™ —>• N. It turns out that for any x\ , . . . , xn € N, f(xi,...,xn)
< max(z1 , . . . , xn)
because assignments can only reduce the value of the inputs. It follows that While(N; 0, n - 1) C
p|
Compa(N; 0, n - 1)
(1.2)
aec(A) because in any numbering the successor function S(o:) = x + 1 can be computed.
Computable functions on algebras
335
More difficult to answer is the question: When is While(A) =
p|
Compa(A)l
Ot€C(A)
Some results in this direction are known. Inequality (1-2) is not a weakness of the abstract theory. Rather it is an indication of the fact that the abstract models provide a more sensitive analysis of finite computations. For example, the abstract theory reveals the special properties of the algebras of numbers that give computability theory on N its special characteristics: the theory of Compa(A) is the same as the theory of While* (A) when A is an algebra finitely generated by constants.
1.4
Historical notes on computable functions on algebras
The generalisation of the theory of computable functions to abstract algebras has a complicated history. On the one hand the connections between computation and algebra are intimate and ancient: algebra grew from problems in computation. However, the fact that it is now necessary to explain how computation theory can be connected or applied to algebra is an aberration, and is the result of interesting intellectual and social mutations in the past. It is a significant task to understand the history of generalisations of computability theory, with questions for research by historians of mathematics, logic and computing, as well as sociologists of science. The story that underlies this work involves the development of algebra; the development of computability theory; interactions between computability theory and algebra; and applications to computing. Some of the connections between computation theory and algebra have been provided in other Handbook chapters: for notes on the histories of effective algebra, see Stoltenberg-Hansen and Tucker [1995]; computable rings and fields, see Stoltenberg-Hansen and Tucker [l999a]; algebraic methods in computer science, see Meinke and Tucker [1992]. In the following notes we discuss the nature of generalisations and point out the earliest work on abstract computability theory. Section 8 is devoted to a fairly detailed survey of the literature. We first list some common-sense reasons for generalising computability theory. A common view is to say that the purpose of a generalisation of computability theory is one or more of the following: (i) to say something new and useful about the original theory; (it) to provide new methods of use in computer science and mathematics; (Hi) to illuminate and increase our understanding of the nature of computation.
336
J. V. Tucker and J. I. Zucker
As will be seen, the theory of computable functions on many-sorted algebras is certainly able to meet the goals (i)-(iii). For a discussion of these and other reasons for generalising computability theory, see Kreisel [1971]. Broadly speaking, it is often the case that a new mathematical generalisation of an old theory focuses on a few basic technical ideas, results or problems in the old theory and makes them primary objects of study in the new theory. If the generalised theory is technically satisfying then a substantial subject can be built on foundations consisting of little more than some modest technical motivations. Recent history records many attempts at generalisations of computability theory that have different, narrower, technical aims than those of the original theory. Indeed, in some cases, if the generalisation can be applied to analyse computation on algebras then its aims need not be particularly useful or meaningful. Generalised computability theories bear witness to the fact that computability theory has several concepts, results and problems that can bear the weighty load of a satisfying generalisation. For instance, on generalising finiteness, and allowing infinite computations, theoretical differences can be found that allow models of computation to cleverly meet goal (i), but not (if) or (in). Computability theory can also support a good axiomatic framework in which deep results can be proved, and generalised computability theories are models. For example, the axiomatic notion of computation theory developed by by Moschovakis and Fenstad elegantly captures basic results and advanced degree theory: see Stoltenberg-Hansen [1979] and Fenstad [1980]. There is usually a good market for general frameworks in theoretical subjects because there is more space in which to seek ideas and show results. Generality is attractive: there are many new technical concepts and the original theory can underwrite their value. Generalisations are developed, gain an audience and reputation, and, like so many other technical discoveries, await an application. Applications can arise in more exotic or commonplace areas than their creators expected. In the case of generalising computability theory, some theories have useful applications (e.g. in set theory), and some languish in the museum of possible models of axiomatic theories of computation. Abstract computability theory developed rather slowly, and owes much to the development of programming languages. A starting point is the notion of the flowchart. The idea was first seen in examples of programs for the ENIAC from 1946, published in Goldstine and von Neumann [1947]. Flowcharts were adapted and used extensively in practical work. For example, standards were provided by the American Standards Association (see American Standards Association [1963] and Chaplin [1970]). To define mathematically the informal idea of a flowchart required a number of papers on flow diagrams, graph schemata and other mod-
Computable functions on algebras
337
els; some commonly remembered papers are: lanov [i960], Peter [1958], Voorhes [1958], Asser [1961], Corn [*196l] and Kaluzhnin [1961]. By the time of the celebrated Bohm and Jacopini [1966] paper on the construction of normal forms for flowcharts, the subject of flowcharts was well established. In some of these papers the underlying data need not be the natural numbers, strings or bits. In particular, in Kaluzhnin [1961] flowcharts are modelled using finite connected directed graphs. These have vertices either with one edge to which are assigned an operation, for computation, or two exit edges to which are assigned a discriminator, for tests. The graph has one vertex with no incoming edge, for input, and one vertex with no outgoing edge, for output. To interpret a so-called graph scheme, a set of functions is used for the operations, and a set of properties is used for the discriminators. Kaluzhnin's work was used in various studies, such as Bigot's early work, and in Thiele [1966], a major study of programming, in which flow diagrams are presented that are not necessarily connected graphs. The semantics of flow diagrams is denned here formally, in terms of the functions El&£(n) = object or data after the nth step in flow diagram A starting at state £, Kl&^(n) = edge in flow diagram A traversed after the n-th step starting at state £. using simultaneous recursions. Thiele's work influenced the formal development of operational semantics as found in the Vienna Definition Language: see Lauer [1967; 1968] and Lucas et al. [1968]. The important point is that predicate calculus with function symbols and equality is extended by adding expressions that correspond with flow diagrams to make an algorithmic language involving graphs. Thus, in the period 1946-66, some of the basic topics of a theory of computation over any set of data had been recognised, including: equivalence of flowcharts; substitution of flowcharts into other flowcharts; transformations and normal forms for flow charts; and logics for reasoning about flowcharts. Flowcharts were not the only abstract model of computation to be developed. Against the background of early work on the principles of programming by A. A. Lyapunov and theoretical work by lanov and others in the former Soviet Union, Ershov [1958] considered computation with any set of operations on any set of data. In Ershov [i960; 1962] the concept of operator algorithms is developed. These are imperative commands made from expressions over a set of operations; the algorithms allow self-modification. The model was used in early work on compilation in the former Soviet Union. See Ershov and Shura-Bura [1980] for information on early programming. Of particular interest is McCarthy [1963], which reviewed the requirements and content of a general mathematical theory of computation. It
338
J. V. Tucker and J. I. Zucker
emphasises the idea that classes of functions can be defined on' arbitrary sets of data. Starting with a (finite) collection F of base functions on some collection of sets, we can define a class C{F} of functions computable in terms of F. The mechanism used is that of recursion equations with an informal operational meaning based on term substitution. An abstract computability theory is an aim—not 'merely' a model of programming structure etc.—and McCarthy writes (p. 63): Our characterisation of C{F} as the set of functions computable in terms of the base functions in F cannot be independently verified in general since there is no other concept with which it can be compared. However it is not hard to show that all partial recursive functions in the sense of Church and Kleene are in C{zero, succ}. This, of course, falls short of a generalised Church-Turing thesis. The paper also mentions functionals and the construction of new sets of data from old, including a product, union and function space construction for two sets, and recursive definition of strings. McCarthy's paper is eloquent, perceptive and an early milestone in the mathematical development of the subject. E. Engeler's innovative work on the subject of abstract computability begins in Engeler [1967]. This contains a mathematically clear account of program schemes whose operations and tests are taken from a first-order language over a single-sorted signature. The programs are lists of labelled conditional and operational instructions of the form k : k:
if 4> then goto p else goto q do ip then goto p
where k, p and q are natural numbers acting as labels for instructions,
x:=y
or
x:=f (y x ,... ,yk)
where x, y , . . . are variables, and c and f are any constant and operation of the signature. Interpretations are given by means of a notion of state, mapping program variables to data in a model. A basic result proved here is this: To each program TT one can associate a formula
<=> A |= <j>.
Results involving the definability of the halting sets of programs in terms of computable fragments of infinitary languages will be proved in section 5 and applied in section 6, where we refer to them as versions of Engeler's lemma.
Computable functions on algebras
339
In Engeler [I968a] two new models of computation are given: one is based on a new form of Kleene ^-recursion, the other on a deductive system. The functions computable by the programs and these two models are shown to be equivalent. Engeler's development of the subject in the period 1966-76 addresses original and yet basic questions including the computability of geometrical constructs, exact and approximate computation, and a Galois theory for specifications and programs: see Engeler [1993]. The study of program schemes and their interpretation on abstract structures grew in the early 1970s, along with the theoretical computer science community. Problems concerning program equivalence, decidability and the expressive power of constructs were studied and formed a subject called program schematology (see, for example, Greibach [1975]). The problem of finding decidable properties, and especially finding decidable equivalence results, is work directly influenced by lanov [i960]. The subject of program schemes, and the promise of decidability results on abstract structures, was addressed in the unpublished Luckham and Park [1964], and early undecidability results appeared in Luckham et al. [1970]. Program schematology was part of the response to the need to develop a comprehensive theory of programming languages, joining early work on programming language semantics, program verification and data abstraction also characteristic of the period. We will look at the subject again in section 8. The next milestone is that of Friedman [l971a]. Friedman's paper has received a fine exegesis in Shepherdson [1985] which we recommend. Against a backcloth of growing interest in the generalisations of computability theory by mathematical logicians, and inspired by the work of Moschovakis on computation, Friedman considered the mathematical question (in Shepherdson's words): What becomes of the concepts and results of elementary recursion theory if, instead of considering only computations on natural numbers, we consider computations on data objects from any relational structure? In this he gave four models of computation for an algebra A. The first two were based on register machines, the programs for which were called finite algorithmic procedures (or faps). The third was a generalisation of Turing machines. The fourth was a model based a set of r.e. lists of conditional formulae of the form Riik...tcRtkt -*• ti for i = 1,2,..., where the fly are tests and the ti is a term, called effective definitional schemes. In section 8 we will discuss these models again. All four models compute the partial recursive functions on the natural numbers. Freidman organised some 22 basic theorems of computability theory on the natural numbers N into six groups which were defined by
340
J. V. Tucker and J. I. Zucker
the properties of a structure A that are sufficient to prove the theorems on A. Also noteworthy are results which showed some of these models are not equivalent in the abstract setting. Friedman's paper is technically intense, with several good ideas and results. Looking back at the literature, one wonders why such an indispensable paper had not appeared before. The theory of computation on natural numbers and strings began in mathematical logic, motivated by questions in the foundations of mathematics. However, the theory of computation on arbitrary algebraic and relational structures began and was sustained in computer science, motivated by the need to model programming language constructs. Mathematical logic plays two roles: firstly, it provides knowledge of abstract structures, formal languages and their semantics; and secondly, it provides a deep theory of computation on natural numbers. Both the complicated history of algebra and computability theory mentioned earlier (and sketched in the historical notes of other Handbook chapters), and the development of abstract computability since the 1950s, have much to offer those interested in the historical development of mathematical theories. In the matter of the development of abstract computability these brief notes, coupled with our survey in section 8, suggest some questions a historical analysis might answer. Why have there been many independent attempts at making models of computation but relatively few attempts to show equivalencies, or undertake sustained programmes of theoretical development and applications? Why have there been so many demonstrations of an ability to ignore earlier work and to reinvent ideas and results? Why was the development of the theory so slow and messy? Why was computability theory on the natural numbers not generalised to rings and fields, or even relational structures, before the Second World War? Why did the subject not find a home in mathematical logic? It is clear that computer science played an essential role in creating the theory of computable functions on abstract algebras. One is reminded of McCarthy's [1963] commonly quoted words: It is reasonable to hope that the relationship between computation and mathematical logic will be as fruitful in the next century as that between analysis and physics in the last. The development of this relationship demands a concern for both applications and for mathematical elegance. It also demands patience.
1.5
Objectives and structure of the chapter
Computability theory over algebras can be developed in many directions and can be used in many applications. In this short introduction we have chosen to emphasise computation on general many-sorted algebras. We see algebra as providing a general theory of data that is theoretically satisfying and practically useful. Therefore, theories of what is computable
Computable functions on algebras
341
over algebras are fundamental for a general theory of data. In section 2 we define the basic algebraic notions we will need: algebras with Booleans and naturals, relative homomorphisms, terms and their evaluation, abstract data types, etc. In particular, we look at expanding an algebra A, by adding new types such as finite sequences to make a new algebra A* that models arrays, and adding infinite sequences to make a new algebra A that models infinite streams of data. In section 3 we begin the study of computing on algebras with While programs. For a satisfactory theory, the algebras are required to include the Booleans and standard Boolean operations. Such algebras are called standard algebras. The semantics of While programs on A is given by a new technique called algebraic operational semantics (AOS). This involves axioinatising a function CompA that defines the state CompA (S, o~, t) at time t in the computation by program 5 starting in intial state a. From this we obtain a state transformer semantics in which a program 5, applied to a state o~, may give rise to a final state [S']"4^). Simple but important properties of computations are examined. First, the invariance of computations under homomorphisms and isomorphisms: if algebras A and B are isomorphic, then the semantical interpretations of any While program S on A and B are isomorphic. This result has many consequences; for example, it comfirms that executing a While program on equivalent implementations of a data type results in equivalent computations. The second property is that each computation by a While program S takes place in the subalgebra of A generated by the input. This is a key to understanding the nature of abstract computation: in any algebra computations are local to the input in this sense and, for instance, searches are at best local. Next, in section 4, we consider the universality of computation by While programs. Let A be an algebra with Booleans and naturals. We can code the While programs •So , S\ , 82, • • •
by the natural numbers in A and ask if there exists a universal While program to compute the function Univ"4 on A such that
We prove that the universal function is While computable on A if, and only if, the term evaluation function is While computable on A. The evaluation of terms is not always computable. However, it is While computable in several commonly used algebras such as: semigroups, groups, rings, fields, lattices, Boolean algebras; this because such algebras have computationally efficient normal forms for their terms. For any algebra A, the algebra A" of finite sequences from A has the property
342
J. V. Tucker and J. I. Zucker
that term evaluation is always While computable on it; hence, the model of While* programs is universal. In section 5 we turn our attention to sets. We begin with a study of computable and semicomputable sets. We prove Post's theorem in the present setting. We also study the ideas of projections of computable and semicomputable sets. It turns out that the classes of computable and semicomputable sets are not closed under projection. The notion of projection is very important since it distinguishes clearly between forms of specification and computation. Furthermore, it focuses our attention to the difference between local search and global search in computation. Projections also lead us to consider the relationship between While programming and certain non-deterministic constructs on data. These include: search procedures; initialisation mechanisms; and random assignments. Next, with each While program is associated a computation tree. With this technique, we prove that every semicomputable set is definable by an effective infinite disjunction of Boolean terms over the signature. In section 6 we illustrate the core of the theory with a study of its application to computing sets of real and complex numbers over various many sorted algebras. We include some pleasing examples from dynamical systems. In section 7 we return to the special properties and problems of computation of the reals. More generally, we study computation on topological algebras. A key consideration is the property that if a function is computable then it is continuous. To guarantee a good selection of applications we use partial functions, which raises interesting topological issues. This study of programming over topological algebras contains new material. We also contrast exact versus approximate computation on the reals. The following fact was observed in Shepherdson [1976]. Let / be a function on the reals. Then / is computable in the sense of computable analysis if, and only if, there is a function g which is While computable over the algebra (E, B, N; 0, 1, x + y, x.y, —x,...) such that \f(x)-g(n,x)\<2-n for all n € N and x 6 K. We extend and adapt this result to topological algebras. In section 8 we survey other models of computation and see their relation with While programs. We consider briefly: /^-recursive functions; register machines; flowcharts; axiomatic methods; set recursion; and equational definability. A generalised Church-Turing thesis is discussed. There are many subjects that we have omitted from the discussion, for example: the delicate classification of the power of constucts, including types; computations with streams; program verification; connections with proof theory; connections with model theory; degree theory; and generalised complexity theory. There will be good work by many authors that
Computable functions on algebras
343
we have neglected to mention, from ignorance or forgetfulness. We will be pleased to receive reminders, information and suggestions. Abstract computability theory is a subject that offers its students considerable theoretical scope, many areas of application, and scientific longevity. We hope this chapter provides a first introduction that is satisfying, stimulating and pleasurable. We thank Jan Bergstra (Amsterdam), Martin Davis (NYU and Berkeley), Jens Erik Fenstad (Oslo), Dag Norman (Oslo), Viggo StoltenbergHansen (Uppsala) and Karen Stephenson (Swansea) for useful discussions on aspects of this work. We thank Peter Lauer (McMaster) and Ithel Jones (Swansea) for discussions and information on the history of programming language semantics. We also thank our colleagues and students in Swansea and McMaster for their helpful responses to the material in courses and seminars, especially Jeff Koster, Matthew Poole, Dafydd Rees, Kristian Stewart, Anton Wilder and Ian Woodhouse. Special thanks are due to Sol Feferman, who presented some of the material of this chapter at a graduate course in computation theory at Stanford University in spring 1999, and provided us with valuable feedback. We are particularly grateful to Jane Spurr for her excellent and essential work in producing the final version of the chapter. The second author is grateful for funding by a grant from the Natural Science and Engineering Research Council of Canada.
1.6
Prerequisites
First, we assume the reader is familiar with the theory of the recursive functions on the natural numbers. It is treated in many books such as Rogers [1967], Mal'cev [1973], Cutland [1980] and Machtey and Young [1978]. An introduction to the subject is contained in this Handbook (see Phillips [1992]) and other handbooks (e.g. Enderton [1977]). Secondly, we assume the reader is familiar with the basics of universal algebra. Some mathematical text-books are: Burris and Sankappanavar [1981] and McKenzie et al. [1987]. An introduction to the subject with the needs of computer science in mind is contained in this Handbook (see Meinke and Tucker [1992]) and in Wechler [1992]. The application of universal algebra to the specification of data types is treated in Ehrig and Mahr [1985], Meseguer and Goguen [1985] and Wirsing [1991]. The theory of computable and other effective algebras is covered by Stoltenberg-Hansen and Tucker [1995]. Thirdly, we will need some topology. This is covered in many books, such as Dugundji [1966] and Kelley [1955] and in a chapter in this Handbook (see Smyth [1992]). Finally, we note that the subject connects with other subjects, including term rewriting (see, for example, Klop [1992]) and domain theory (see, for example, Stoltenberg-Hansen et al. [1994]).
344
2
J. V. Tucker and J. I. Zucker
Signatures and algebras
In this section we define some basic algebraic concepts, establish notations and introduce three constructions of many-sorted algebras. We will use many-sorted algebras equipped with Booleans, which we call standard algebras. Sometimes we use algebras with the natural numbers as well, which we call N-standard algebras. All our algebras have total operations, except in section 7, where we compute on topological partial algebras. We are particularly interested in the effects on computations of adding and removing operations in algebras. To keep track of these changes, we use expansions and reducts of algebras, and relative homomorphisms. The constructions of new algebras from old involve adding (i) unspecified elements, (ii) finite arrays, and (Hi) infinite streams.
2.1
Signatures
Definition 2.1 (Many-sorted signatures). A signature E (for a manysorted algebra) is a pair consisting of (1) a finite set Sort(S) of sorts, and (2) a finite set F«nc(E) of (primitive or basic) function symbols, each symbol F having a type si x ... x sm -t s, where m > 0 is the arity of F, and 81,... ,sm € Sort(E) are the domain sorts and s € Sort(S) is the range sort; in such a case we write
F : Si x ... x sm -» s. The case ra = 0 corresponds to constant symbols; we then write F : —> s or just F : s. Our signatures do not explicitly include relation symbols; relations will be interpreted as Boolean-valued functions. Definition 2.2 (Product types over E). A product type over E, or Yi-product type, is a symbol of the form s\ x . . . x sm (m > 0), where si,... ,sm are sorts of E, called its component sorts. We define ProdType(E) to be the set of S-product types, with elements u,v,w, If u = Si x ... x sm, we put lgth(u) = m, the length of u. When lgth(u) = 1, we identify u with its component sort. When lgth(u) = 0, u is the empty product type. For a E-product type u and E-sort s, let Func(Y,)u^.s denote the set of all S-function symbols of type u —> s. Definition 2.3 (E-algebras). A ^-algebra A has, for each sort s of E, a non-empty set As, called the carrier of sort s, and for each E-function symbol F : si x ... x sm -» s, a function FA : ASl x • • • x ASm -> As. For a E-product type u — s\ x ... x sm, we write Au =df ASl x ... x A8m.
Thus x € Au if, and only if, x — (x\,... ,xm), where Xi 6 ASi for i = 1,... ,m. So each E-function symbol F : u —>• s has an interpretation
Computable functions on algebras
345
FA : Au -»• As. If u is empty, i.e., F is a constant symbol, then FA is an element of As. We will sometimes use the same notation for a function symbol F and its interpretation FA. The meaning will be clear from the context. For most of this chapter, we make the following assumption. Assumption 2.4 (Totality). The algebras A are total, i.e., FA is total for each S-function symbol F. Later (in section 7) we will drop this assumption, in our study of partial algebras. We will sometimes write H(A) to denote the signature of an algebra A. We will also consider classes K of S-algebras. In particular, Alg(E) denotes the class of all E-algebras. We will use the following perspicuous notation for signatures E: signature sorts
E
s,
(s £ Sort(E))
F : si x ... x sm -+ s,
(F eFwnc(E))
functions
end
and for E-structures A: algebra carriers
A
As,
(s € Sort(E))
functions FA : ASl x . . . x ASm -»• As,
end
Examples 2.5. (a) The algebra of naturals A/o = (N; 0, succ) has a signature containing the sort nat and the function symbols 0: -»nat and succ:nat-»nat. We can display this signature thus:
346
J. V. Tucker and J. I. Zucker signature sorts functions
nat 0: —»nat, S:nat-»nat
end
In practice, we can display the algebra thus: algebra carriers functions
A/o N 0: S:
end
from which the signature can be inferred. Below, we will often display the algebra instead of the signature. (b) The ring of reals T^o = (K; 0,1, +,-, x) has a carrier ffi of sort real, and can be displayed as follows: algebra carriers functions
72« R 0,1: _1_ s, . -r, X . - :R
end
(c) The algebra Co of complex numbers has two sorts, complex and real, and hence two carriers, C and HL It includes the algebra 72.Q, and therefore has all the operations on ]R listed in (b), as well as operations on C, as follows: algebra import carriers functions
C0 Ti0 C 0, l,i : -» C, +, x : C2 -»• C, - : C ->• C, re,im: C -> R, TT : R2 ->• C
end
where TT is the inverse of re and im. (d) A group has the form
Computable functions on algebras algebra carriers functions
347
G 1 : -» G, * : G2 -> G, inv: G -» G
end
where the carrier G has sort grp. The concepts of reduct and expansion will be important in our work. Definition 2.6 (Reducts and expansions). Let £ and £' be signatures. (a) We write £ C £' to mean Sor<(£)C Sort(£')and Ftmc(£)C Func(S')(6) Suppose £ C £'. Let A and A' be algebras with signatures £ and £' respectively. (i) The 'E-reduct A'\-£ of A' is the algebra of signature £, consisting of the carriers of A' named by the sorts of £ and equipped with the functions of A' named by the function symbols of £. (ii) A' is a £''-expansion of A if, and only if, A is the £-reduct of A'. Example 2.7. The algebra Co (see Example 2.5(c)) is an expansion to E(Cb). Definition 2.8 (Function types). We collect some definitions and notation. Let A be a £-algebra. (a) A function type over £, or £-function type, is a symbol of the form u -> v, with domain type u and range type v, where u and v are £-product types. (&) For any £-function type u -> v, a function of type u -+ v over A is a function
f :AU -> Av.
(2.1)
If v = si x . . . x sn then the component functions of / are /i , . . . , /n, where
/> : ^ -> ^
(2-2)
for j = 1, . . . , n, and for all a; € Au, f ( x ) ~ (/!(*),..-,/„(*)).
(2.3)
(We will explain the '~' in (c) below.) Conversely, given n functions fj as in (2.2), all with the same domain type u, and with range types (or sorts) si, . . . , sn respectively, we can form their vectorisation as a function / satisfying (2.1) and (2.3).
348
J. V. Tucker and J. I. Zucker
We will investigate computable vector-valued functions (2.1) over A. (c) Although all the primitive functions of S are total, the computable functions on the S-algebra may very well be partial, as we will see. We use the following notation: if / : Au -> As and x € Au, then f(x)^ ('/(#) diverges') means that x ^ dom(f); f ( x ) ] , (lf(x) converges') means that x & dom(f); and f ( x ) ± y ('f(x) converges to y') means that x £ dom(f) and f ( x ) = y. We also make the following convention for convergence of vectorvalued functions: in the notation of (2.1) and (2.2), for any x 6 Au, we say that f ( x ) ± if, and only if, fj(x)± for every component function fj o f / , in which case f ( x ) = ( f i ( x ) , . . . , f n ( x ) ) . Otherwise (i.e., if fj(x) t for any j with 1 < j < n), we say that f ( x ) j. (That is the meaning of the symbol '~' in (2.3) above.) Definition 2.9 (Relations; projections of relations). We collect some more definitions and notation. (a) A relation on A of type u is a subset of Au. We write R : u if R is a relation of type u. Let R be a relation on A of type u = si x . . . x sm. (b) The characteristic function of R is the function \n '• Au ~+ ® which takes the values tt on R and ff off R. (c) The complement of R in A is the relation
Rc = AU\R = {a € Au a£ R}, also of type u. (
—» More generally (with R : u where u = si x . . . x s m ) let i be any list of numbers ii,... ,ir such that 1 < i\ < ... < ir < m, and ~t ~~* ~? let j = ji,... ,jm-r >list {!,... ,m} \ i. Then u i denotes the —» restriction of u to i, that is, the product type s,j x ... x Sirr; and -^ -+ .-* -+ pro.7'[M| i ](-R) is the projection of R on i (or on ^4U| * ) , or the Au*3 projection of R, that is, the relation 5 : u i defined by existentially quantifying over Au\J':
-+
,... ,xm).
Computable functions on algebras
2.2
349
Terms and subalgebras
Definition 2.10 (Closed terms over E). We define the class T(E) of closed terms over E, denoted t, t', ti,..., and for each E-sort s, the class T(S)gof closed terms of sort s. These are generated inductively by the rule: if F € Func(E) u _ >g and ti 6 T(E)Si for i = 1,... ,m, where u = si x ... x s m , then F(ti,... , *m) € T(E) g . Note that the implicit base case of this inductive definition is that of m = 0, which yields: for all constants c : —> s , c ( ) € T(E)S. In this case we write c instead of c(). Hence if £ contains no constants, T(£) is empty. Definition 2.11 (Valuation of closed terms). For A €Alg(£) and t € T(S)S, we define the valuation tA £ As o f t in A by structural induction on t: F(ti,...,tm)A = FA((tl)A,...
,(tm)A).
In particular, for m — 0, i.e., for a constant c : -4 s, CA = CA.
We want a situation where T(E) is non-empty, and, in fact, T(£)s is non-empty for each s € Sort(E). We therefore proceed as follows. Definition 2.12. The signature E is said to be: (a) non-void at sort s if T(E) S ^ 0; (6) non-void if it is non-void at all S-sorts. Assumption 2.13 (Instantiation). E is non-void. Throughout this paper we will make this assumption, except where explicitly stated: see, for example, Remark 2.31(e). It simplifies the theory of many-sorted algebras (see Meinke and Tucker [1992]). Definition 2.14 (Default terms; default values). (a) For each sort s, we pick a closed term of sort s. (There is at least one, by the instantiation assumption.) We call this the default term of sort s, written 6s. Further, for each product type u = si x ... x sm of S, the default (term) tuple of type u, written Su, is the tuple of default terms (SSl,... ,6s™). (b) Given a S-algebra A, for any sort s, the default value) of sort s in A is the valuation <5^e Aa of the default term, d s ; and for any product type u = s\ x ... x sm, the default (value) tuple of type u in A is the tuple of default values 6U A = (6%,... , 8'j") (E Au. Definition 2.15 (Generated subalgebras). Let X C U«esoft(£) ^»Then (X)'4 is the (£,-)subalgebra of A generated by X, i.e., the smallest subalgebra of A which contains X, and (X)^ is the carrier of (X)'4 of sort
350
J. V. Tucker and J. I. Zucker
s. (See Meinke and Tucker [1992, §§3-2.6 ff] for definitions.) Also for a product type u = si x ... x sm,
(X)AU = < J f £ x . . . x <*)£.. Similarly, for a tuple a € Au, (a)A is the (T,-) subalgebra of A generated by a, etc. Remark 2.16. (a) Using the terminology of sections 3.1-3.3, we can characterise (for all E-sorts s and S-product types u) the sets (X)A and (X)^ by (X)A={[t]A(r \ t e Terms (S) and for all x £var(t),a(x) € X} (X)A={[t]A(T I t € TermTupu(S) and for all x £var(t),a(x) £ X.} (6) The smallest subalgebra of A is its closed term subalgebra, given by
(9)A = {tA \t e T(E)}. (c) The instantiation assumption implies that for any X and every sort s, (X)A ± 0. Definition 2.17 (Minimal carriers; minimal algebra). Let A be a S-algebra, and s a S-sort. (a) ^4 is minimal at s (or the carrier As is mimimal in A) if As ={0)^, i.e., As is generated by the closed S-terms of sort s. (b) A is minimal if it is minimal at every E-sort. Example 2.18. To take examples from later: (a) Every N-standard algebra (section 2.5) is minimal at sorts bool and nat. (b) The ring of reals 7£o (Example 2.5) (or its standardisation (section 2.4) or ./V-standardisation (section 2.5)) is not minimal at sort real.
2.3
Homomorphisms, isomorphisms and abstract data types
Given a signature E, the notions of 'S-homomorphism as well as E-epzmorphism (surjective), T,-monomorphism (injective), 'E-isomorphism (bijective) and E-automorphism are defined as usual (see [Meinke and Tucker, 1992, §3.4]). We need a more sophisticated notion, that of relative homomorphism. Definition 2.19 (Relative homomorphism and isomorphism). Let E and E' be signatures with £ C E'. Let A and B be two standard E'algebras such that
Computable functions on algebras
351
(a) A Y,'-homomorphism relative to S from A to B, or a E'/E-/iomom0rp/iism >: A -> B, is a Sort(E')-indexed family of mappings <£ = {<£„ : As -» Bs | s € Sort(E')) which is a S'-homomorphism from A to B, such that for all s € Sort(S),
2.4
Adding Booleans: Standard signatures and algebras
An very important signature for our purposes is the signature of Booleans: signature sorts functions
bool true, false: -»bool, and, or: bool2 ->bool not: bool->bool
end
The algebra B of Booleans, with signature E(/B), has the carrier B = {tt, ff} of sort bool, and, as constants and functions, the standard interpretations of the function and constant symbols of E(B). Thus, for example, true 6 = tt and false6 = ff. Of particular interest to us are those signatures and algebras which contain S(B) and B. Definition 2.21 (Standard signatures and algebras). (a) A signature E is a standard signature if (i) S(B) C E, and (zz) the function symbols of E include a discriminator if s : bool x s2 —>• s for all sorts s of S other than bool, and an equality operator
352
J. V. Tucker and J. I. Zucker eqs : s2 —> bool
for certain sorts s. (b) Given a standard signature S, a E-algebra A is a standard algebra if (z) it is an expansion of B, and (M) the discriminators and equality operators have their standard interpretation in A; i.e., for 6 e B and x,y € As,
ifs(b,x,y)
=
if b = f,
and eqs is interpreted as the identity on each equality sort s. Let EqSort(T,)CSort(£) denote the set of equality sorts of S, and let StdAlg(Y>) denote the class of standard E-algebras. Remark 2.22. (a) Strictly speaking, the definition of standardness of a signature E or algebra depends on the choice of the set EqSort(%) of equality sorts of E. However, our terminology and notation will not make this dependence explicit. (b) The exact choice of the set of propositional connectives in B is not crucial; any complete set would do. (c) Excluding the sort bool from the sorts of the discriminator is not significant; we can easily define ifbooi from the other Boolean operators. Also, eqb0oi can easily be defined. (Exercise.) (d) Any many-sorted signature E can be standardised to a signature EB by adjoining the sort bool together with the standard Boolean operations; and, correspondingly, any algebra A can be standardised to an algebra AB by adjoining the algebra B and the discriminator and equality operators. Note that both A and B are reducts of this standardisation AB. (See the examples below.) (e) If A and B are two standard E-algebras, then any S-homorphism from A to B is actually a E/E(#)-homomorphism, i.e., it fixes the reduct B. Examples 2.23. (a) The simplest standard algebra is the algebra B of the Booleans. (b) The standard algebra of naturals JV is formed by standardising the algebra .A/o of Example 2.5(a), with nat as an equality sort, and, further, adjoining the order relation1 lessnat on N: x The reason for adjoining lessnat will be clear later: in the proof of Theorem 3.63 (£*/£ conservativity for terms), we need it for the translation of E*-terms to S^-terms.
Computable functions on algebras algebra import functions
353
•A/b.B
if Mt : B x N2 -)• N,
on
locc
-T^P
L TO,
end
(c) The standard algebra 71 of reals is formed similarly by standardising the ring HQ of Example 2.5(6), with real as an equality sort: algebra U import "R-0,13 functions if real :B x eqreai: end
(d) We will also be interested (in section 5) in the expansion 7?,< of "R, formed by adjoining the order relation on the reals lessreai: M2 —¥ B, thus: algebra import functions
K< H lessreai:IR2
end
(e) The standard algebra C of complex numbers C is formed similarly by standardising the algebra Co of Example 2.5(c), with equality on both E and C. (/) Again, we will consider the expansion C < of C formed by adjoining (g) The standard group Q is formed similarly by standardising the group Go, with equality on G. Throughout this chapter, we will assume the following, unless otherwise stated. Assumption 2.24 (Standardness). The signature £ and the S-algebra A are standard.
2.5
Adding counters: N-standard signatures and algebras
Definition 2.25. (a) A standard signature E is called N-standard if it includes (as well as bool) the numerical sort nat, as well as function symbols for the standard operations of zero, successor and order on the naturals: 0: S:
lessn
-> nat nat -* nat bool nar
354
J. V. Tucker and J. I. Zucker
as well as the discriminator if nat and the equality operator eqnat on nat. (6) The corresponding E-algebra A is N-standard if the carrier A nat is the set of natural numbers N = {0,1,2,...}, and the standard operations (listed above) have their standard interpretations on N. Definition 2.26. (a) The N-standardisation S^ of a standard signature S is formed by adjoining the sort nat and the operations 0,5, eq na t, lessnat and if nat . (b) The N-standardisation AN of a standard S-algebra A is the T,Nalgebra formed by adjoining the carrier N together with certain standard operations to A, thus: algebra import carriers functions
AN A N 0 : -> N S:N-»N if nat :B x N2 • eqnat,lessnat:f
end (c) The N-standardisation ~KN of a class K of E-algebras is (the closure with respect to E^/E-isomorphism of) the class {AN | A € K}. Examples 2.27. (a) The simplest ./V-standard algebra is the algebra M of Example 2.23(6). (6) We can ./V-standardise the real and complex rings Ti and C, and the group Q of Examples 2.23, to form the algebras HN, CN and QN, respectively. Remark 2.28. (a) For any standard A, both A and N are H-reducts of the ^-standardisation AN (cf. Remark 2.22(d)). (b) If A and B are two TV-standard E-algebras, then any E-homorphism from A to B is actually a E/S(^V)-homomorphism, i.e., it fixes the reduct N (cf. Remark 2.22(e)). (c) A E-homomorphism (or E-isomorphism) between two standard Ealgebras A and B can be extended to a S-homomorphism (or Eisomorphism) between AN and BN. (Exercise.) (d) If A is already JV-standard, then AN will contain a second copy of N, with (only) the standard operations on it. Further, AN can be effectively coded within A, using a standard coding of I^2 in N. (Check.) (e) In particular, (^4^)^ can be effectively coded within AN. We will occasionally make use of a notion stricter than ./V-standardness.
Computable functions on algebras
355
Definition 2.29 (Strict W-standardness). (a) An N-standard signature S is said to be strictly N-standard if its only function symbols with range sort nat are '0', 'S' and 'if nat '. (b) An AT-standard algebra is strictly N-standard if its signature is. Note that the TV-standardisation of any algebra is strictly ,/V-standard.
2.6
Adding the unspecified value ui; algebras A" of signature Eu
In this subsection, we need not assume that £ and A are standard. For each sort s of £ let ui be a new object, representing an 'unspecified value', and let A* = As U {uis}. For each function symbol F of S of type si x . . . x sm -> s, extend its interpretation FA on A to a function FA>" : A"Sl x ... x A»Sm —> Aus by strictness — i.e. the value is denned as ui whenever any argument is ui. Then the algebra A u , with signature Su, contains: (i) the original carriers A3 of sort s, and functions FA on them; (ii) the new carriers A" of sort su, and functions F A>U on them; (Hi) a constant unspecss : su to denote uis as a distinguished element of A"; and (TO) an embedding function \s : s -» su to denote the embedding of As into A", and the inverse function js : su -» s, mapping ui s to the default term 5s for each sort s. Further, if A is a standard algebra, we assume Au also includes: (v) a Boolean-valued function Unspecss : su -» bool, the characteristic function of ui«; (vi) the discriminator on A* for each sort s; and (vii) the equality operator on A" for each equality sort s. Thus, if A is standard, A™ is constructed from A as follows: algebra import carriers functions
A" A A" ui, : -> A1 r ' : ^*-ai X ... X AS i . A \. A** >s • •"-, ^ •flg
}s : Al -> As Unspec s : A" -»• B if su : B x (.A")2 ->• A* eqsu : (A")2 -»• B
end
(s £ S)
(s e s), -> -A™
(F : si x . . . x sm -> s in E),
(s 6 S),
(s e S), (s e 5), (s e S), (s e Se)
356
J. V. Tucker and J. I. Zucker
where S=Sort(E)and Se = J£g,Sor<(E)(and the superscript A has been dropped from the new function symbols). Also, K" is (the closure with respect to Su/E-isomorphism of) the class {A* | A e K}. Remark 2.30. (a) The algebra Au is a ^-expansion of A. If S has r sorts, then Eu has 2r sorts. (b) If A is standard, then so is Au. (c) Suppose A (and hence A") is standard. Then A" can be effectively coded within A. Each element y of Aus is represented by the pair (b, js(y)) € B x As, where b = tt if y ^ ui s and 6 = ff otherwise. This induces, in an obvious way, a coding of the operations on A" by operations on A. (The coding is described in [Tucker and Zucker, 1988] for a slightly different definition of Au—however, it is clear how to modify that for the present context.) (d) (Two- and three-valued Boolean operations.) Suppose again that A is standard. Then Au contains the carrier Bu = {tt, f, ui} as well as B, with associated extensions of the original standard Boolean operations, leading to a weak three-valued logic (see [Kleene, 1952; Tucker and Zucker, 1988]). Further, there are two equality operations on A" for each equality sort s: (i) the extension by strictness of eqf to a three-valued function eq^'u : Aus x Aus -> Bu which has the value uibooi if either argument is uis; (ii) the standard (two-valued) equality on A", eqf : A" x A". ^ B,
which we will usually denote by '=' in infix. (e) Some of the functions in Au are not strict, namely the (interpretations of) the discriminator if«, the function Unspecs and the two-valued equality operator equ (see (d)(ii) above). (/) A E-homomorphism (or S-isomorphism) between two standard Ealgebras A and B can be extended to a E-homomorphism (or £isomorphism) between A" and Bu. (Exercise.)
2.7
Adding arrays: Algebras A* of signature S*
Given a standard signature S, and standard E-algebra A, we extend E and expand A in three stages: (1°) Construct Eu and Au, as in section 2.6. (2°) N-standardise these to form £ UTJV and A"'N, as in section 2.5. (3°) Define, for each sort s of S, the carrier A*s to be the set of pairs
Computable functions on algebras
357
a* = («,/)
where a : N -» AJ, / € N and, for all n > I, a(ri) = ui s .
So / is a witness to the "finiteness" of a, or an 'effective upper bound' for a*. The elements of A*s have "starred sort" s*, and can be considered as finite sequences or arrays. The resulting algebras A* have signature £*, which extends S u>Ar by including, for each sort s of S, the new starred sorts s* (in addition to s u ), and also the following new function symbols: (i) the null array Null s of type s*, where Null? = (An -in., 0)€A*t; (if) the application operator Ap g of type s* x nat —> s" , where Ap?((a,0,n)=a(n); (Hi) the Updates operator of type s* x nat x su ->•«*, where for (a,/) € A*,n e N and x € Aus, Update^((a,l),n,x) is the array (0,1) € A* such that for all k e N,
{
a(fe) x uis
if k
(w) the Lgths operator, of type s* -> nat, where
(w) the Newlengths operator of type s* x nat ->• s*, where Newlength^1 ((a, Z),m) is the array (/3,m) such that for all fc,
Ufc) I ui s
if k<m if K > m;
(uz) the discriminator on A* for each sort s; and (UM) the equality operator on A* for each equality sort s. The justification for (vii) is that if a sort s has 'computable' equality, then clearly so has the sort s*, since it amounts to testing equality of finitely many pairs of objects of sort s, up to a computable length. For a* € A; and n e N, we write a*[n] for j^(Ap^(a*,n)). Thus a*[n] is the element of As 'corresponding to' Ap(a*,n) 6 A".
J. V. Tucker and J. I. Zucker
358
To depict this construction of A* from a standard A: suppose we have constructed Au as in section 2.6, and then ^-standardised it to AU'N as in section 2.5. We now proceed as follows: algebra import carriers functions
A' AU,N A: Nulls : -> A*s Aps : A; x N -> A". Updates : A*s x N x A", -> A*s Lgths : A; ->• N Newlengths : yl* x N -> A* if,. : B x (A*) 2 -»• .4* eqs, : (A;)2 -+ 1
(a€S) (a€S) (a £ 5 ) (a€S) (aeS) (a €5) (aeS) (* € Se)
end
where again S = Sort(S)and Se = EqSort(£)(and the superscript has been dropped from the new function symbols). Also, K* is (the closure with respect to S*/E-isomorphism of) the class {A* | A e K}. Remark 2.31. (a) The algebra A* is a E*- expansion of A", and (hence) of A. If S has r sorts, then S* has 3r + 1 sorts, namely s, su and s* for each sort s of S, and also nat. (6) S* and A* are W-standard. (c) (Internal versions of A* and E*.) Suppose A is ./V-standard. Then AN has a second copy of N, and, according to our definition above, A* is constructed on AN using this second copy of N. Let A*' (of sort £*') be an alternative version of A" constructed on A, using the 'original' copy of N. Then A* and A*' can be effectively coded in each other. (Check; cf. Remark 2.28(d).) We call A*' and £*' internal versions of ^4* and S*, respectively. (d) We may also need to speak of finite sequences of starred sorts. However, we do not have to introduce an algebra (A*)* of 'doubly starred' carrier sets containing 'two-dimensional arrays'; such an algebra can be effectively coded in A*, since we can effectively code a finite sequence of starred objects of a given sort as a single starred object of the same sort, thanks to the explicit Lgth operation. More precisely, a sequence X Q , . . . , x*k_l of elements of A* (for some sort s) can be coded as a pair (y*,n*) £ A*s x N*, where Lgth(n*) = k, and, for 0<j
Computable functions on algebras
359
and 2.30(/).) (/) The reason for introducing starred sorts is the lack of effective coding of finite sequences within abstract algebras in general. (g) Starred sorts have significance in programming languages, since starred variables can be used to model arrays, and (hence) finite but unbounded memory.
2.8
Adding streams: Algebras A of signature E
Let, again, £ be a standard signature, and A a standard E-algebra. We define an extension of £ and a corresponding expansion of A, alternative to £* and A*. First we ./V-standardise £ and A, to form £ w and AN . Then we choose a set S C Sort(S) of pre-stream sorts. We then extend N T, to a stream signature £ relative to S: in the following way. (a) With each s € S , we associate a new stream sort s, also written nat —> s. Then SoH(£S)=,Sort(£)US, where S =df {s \ s £ S}. (b) Func (E )consists of Fwnc(E), together with the evaluation function evals : (nat ->• s) x nat -> s, for each s e S. Now we can expand AN to a S -stream algebra As by adding for each pre-stream sort s: (i) the carrier for nat —> s, which is the set
of all streams on A, i.e. functions £ : N -> A; (ii) the interpretation of evals on A as the function eval^ : [N -> As] x N As which evaluates a stream at an index, i.e., eval? (£,») = £(«); (Hi) the discriminator on As, for all s € S. The algebra As is the f/u//,) stream algebra over A with respect to S. This construction of As from a standard A is depicted by: algebra import carriers functions
As AN [N evalf : [N -»Ag] x N ->• As iff : B x ([N ->A g ]) 2 -4 [N
end where now S is the set of stream sorts.
360
J. V. Tucker and J. I. Zucker
_ c Also, Ks is (the closure with respect to S /E-isomorphism of) the class {A | A € K}. Remark 2.32. _
g
—'S
(a) The algebra As is a E -expansion of A. If S has r sorts, then S has r + k + 1 sorts, where k is the cardinality of S.
(b) E and As are TV-standard. (c) Because we have taken As to be the set of all streams on As, we call As the full stream algebra (with respect to S). Note that if yls_has cardinality greater than 1 for some s € S, then As, and hence A, is uncountable. (d) A E-homomorphism (or S-isomorphism) between two standard Ealgebras A and B can be extended to a E-homomorphism (or Sisomorphism) between A and B. (Exercise; cf. Remarks 2.28(c), 2.30(/) and 2.31(e).) (e) Note that the instantiation assumption does not hold (in general) on stream algebras.
3
While computability on standard algebras
In this section, we begin to study the computation of functions and relations on algebras by means of imperative programming models. We start by defining a simple programming language While = While(E), whose programs are constructed from concurrent assignments, sequential composition, the conditional and the 'while' construct, and may be interpreted on any many-sorted S-algebra; this takes up sections 3.1-3.6. We will define in detail the abstract syntax and semantics of this language, and methods by which its programs can compute functions and relations. In sections 3.7 and 3.8 we prove some algebraic properties of computation on algebras, with regard to homomomorphisms and locality. In sections 3.9-3.13, we will add to the basic language a number of new constructs, namely 'for', procedure calls and arrays, and extend our model of computation accordingly. In section 3.14 we study the concept of a sequence of 'snapshots' of a computation, which will be useful later in investigating the solvability of the halting problem in certain (locally finite) algebras. We conclude (section 3.15) with a useful syntactic conservativity theorem for S*-terms over S-terms. We illustrate the theory with several examples of computations on the algebras of real and complex numbers. Throughout section 3, we assume (following Convention 1.4.3) that E is a standard signature,and A is a standard 'S-algebra.
Computable functions on algebras
3.1
361
Syntax of W7ule(E)
We begin with the syntax of the language Whiie(S). First, for each S-sort s, there are (program) variables a s ,b s ,... , x s , y * . . . of sort s. We define four syntactic classes: variables, terms, statements and procedures. (a) Var = Var(S) is the class of S-variables, and Vars is the class of variables of sort s. For u = Si x ... x sm, we write x : u to mean that x is a u-tuple of distinct variables, i.e., a tuple of distinct variables of sorts « i , . . . , sm, respectively. Further, we write VarTup= VarTup(S)for the class of all tuples of distinct S-variables, and VarTupu for the class of all u-tuples of distinct S-variables. (b) Term = Term(S) is the class of S-terms t,..., and for each S-sort s, Terms is the class of terms of sort s. These are generated by the following rules. (i) A variable x of sort s is in Term$. (M) If F £ Ftmc(S)u_>.s and ti € TermSi for i = 1,... ,m where u = si x ... x sm, then F(ti,... ,tm) € Terms. Note again that S-constants are construed as 0-ary functions, and so enter the definition of Term(S) via clause (ii), with m = 0. The class Term(S) can also be written (in more customary notation) as T(S,Var), i.e., the set of terms over S using the set Var of variables (clause (i) in the definition). Analogously, the set T(S) of closed terms over S (2.10) can be written as T(S,0). We write type(t) = s or t: s to indicate that t 6 Terms. Further, we write TerTn.T«p=TermTup(S)for the class of all tuples of S-terms, and, for u = sj x ... x sm, TermTupu for the class of u-tuples of terms, i.e., TermTupu =# TermSl x ... x Term Sm. We write type(t) = u or t: u to indicate that t is a u-tuple of terms, i.e.,, a tuple of terms of sorts s i , . . . , sm. For the sort bool, we have the class of Boolean terms or Booleans £?ooJ(S) =df Termed) denoted either tboo[... (as above) or b, This class is given (according to the above definition of Terms) by: b
::=
xbool|F(*)|eqs(£f,^)| true | false | not(6)| and (61;62)| or(6!,62)| if(Mi,&2)
where F is a S-function symbol of type u -4 bool (other than one of the standard Boolean operations, which are listed explicitly) and s is an equality sort. (c) Stmt = Simt(S) is the class of statements 5, The atomic statements are 'skip' and the concurrent assignment x := t where for some product type u, x : u and t : u.
362
J. V. Tucker and J. I. Zucker Statements are then generated by the rules S ::= skip|x := t\ Si;S2|if b then Si else S2 fi|while b do S od
(d) Proc = Proc(S) is the class of procedures P, Q, the form
These have
P = proc D begin S end
where D is the variable declaration and S is the body. Here D has the form D = in a out b aux c
where a, b and c are lists of input variables, output variables and auxiliary (or local) variables, respectively. Further, we stipulate: * a, b and c each consist of distinct variables, and they are pairwise disjoint; * every variable occurring in the body S must be declared in D (among a, b or c); * the input variables a must not occur on the Ihs of assignments inS; * (initialisation condition:) S has the form Sinit;S', where Smit is a concurrent assignment which initialises all the output and auxiliary variables, i.e., assigns to each of them the default term (section 2.12) of the same sort. Each variable occurring in the declaration of a procedure binds all free occurrences of that variable in the body. If a : u and b : v, then P is said to have type u —> v, written P : u —» v. Its input type is u. We write Procu-+v= Proc(S)u_>t; for the class of S-procedures of type u —* v. Notation 3.1.
(a) We will often drop the sort superscript or subscript s. (b) We will use E,E',Ei,... to denote syntactic expressions of any of the three classes Term, Stmt and Proc. (c) For any such expression E, we define var(E) to be the set of variables occurring in E. (d) We use '=' to denote syntactic identity between two expressions. Remark 3.2 (Structural induction; induction on complexity). We
will often prove assertions about, or define constructs on, expressions E of a particular syntactic class (such as Term, Stmt or Proc) by structural induction (or recursion) on E, following the inductive definition of that class. Alternatively, we may give such proofs or definitions by course-of-values induction (or recursion) on compl(E), the structural complexity of E'. One
Computable functions on algebras
363
suitable definition of this is the length of the maximum branch of the parse tree of E. Thus, for example, for a program term t = F(ti ,..., tm), compl(t) = max.i(compl(ti) + 1). Another possible definition of compl(E), which would in fact be satisfactory for our purposes, is simply the length of £ as a string of symbols. Sections 3.2-3.6 will be devoted to the semantics of While.
3.2
States
For each standard E-algebra A, a state on A is a family (as\ s & Sort(Z)) of functions as : Vars -> At.
(3.1)
Let State (A) be the set of states on A, with elements CT, ---- Note that State(A.) is the product of the state spaces States(A) for all s e Sort(S), where each StateS(A) is the set of all functions as in (3.1). We use the following notation. For x 6 Vars, we often writeCT(X)for
We can now give the semantics of each of the three syntactic classes: Term, Stmt and Proc, relative to any A £StdAlg(T,). For an expression E in each of these classes, we will define a semantic function |£]A. These three semantic functions are defined in sections 3.3, 3.4-3.5 and 3.6, respectively.
3.3
Semantics of terms
For t € Terms, we define the function where [^(tf) is the value of t in A at state a. The definition is by structural induction on t: \x\Aa
— cr(x)
Note that this definition of \t\Aa extends that of t^ for t € T(E) (Definition 2.11). Also the second clause incorporates the cases that (a) F is a constant; (b) F is a standard Boolean operation, e.g. the discriminator:
364
J. V. Tucker and J. I. Zucker
if [6^(7 = tt
For a tuple of terms t = (t±, . . . , tm), we use the notation
\t\Ao =dj ([*i]V...,[*m] y MDefinition 3.3. For any M C Vars, and states <TI and 0^2, fi ~ 0^2 (rel M) means u\ \ M = a^\ M, i.e., Va; € M(cri(x) = (72(2;)). Lemma 3.4 (Functionality lemma for terms). For any term t and states a \ and a 2, if &i K &2 (rel var(t)), then [tlAcri = |<J a^. Proof. By structural induction on t.
3.4
I
Algebraic operational semantics
In this subsection we will describe a general method for defining the meaning of a statement 5, in a wide class of imperative programming languages, as a partial state transformation, i.e., a partial function [SIA : State(A)^- State(A). We define this via a computation step function CompA: StmtxState(A)xN->
State(A)L){*}
where '*' is a new symbol or object. The idea is that CompA(S,o~,n) is the nth step, or the state at the nth time cycle, in the computation of S on A, starting in state a . The symbol '*' indicates that the computation is over. Thus if for any n, CompA(S,a,n) = *, then for all m > n CompA(S,a,m) = *. If we put an = CompA(S, a, n), then the sequence of states <7 =
O~Q, < 7 i , (72,
- • . , CTn,
. . .
is called the computation sequence generated by S at
Computable functions on algebras
365
Assume, firstly, that (for the language under consideration) there is a class AtStC Stmt of atomic statements for which we have a meaning function fl S \>A : State(A) -> State(A), for S € AtSt, and secondly, that we have two functions First RestA
: Stmt -)• AtSt : Stmt x State(A)-^ Stmt,
where, for a statement S and state
by
CompA(S,a)
= QFirst(S) \,Aa.
The definition of CompA(S,a,n) now follows by a simple recursion ('tail recursion') on n:
(
* if n > 0 and S is atomic CompA(RestA(S, a), CompA(S,
Note that for n = 1, this yields CompA(S,o-,l)
= CompA(S,a).
We call this approach algebraic operational semantics, first used in Tucker and Zucker [1988], and developed and applied in Stephenson [1996]. From this semantics we can easily derive the i/o semantics as follows. First we define the length of a computation of a statement S, starting in state a, as the function CompLengthA : Stmt x State(A) ->• N U {00} where
366
J. V. Tucker and J. I. Zucker least ns.t.
CompLengthA(S,cr)
= { oo
Then, putting / = CompLengthA(S,a) we define \S\A(
CompA(S, a, n + 1) = * if such an n exists otherwise. and noting that 0 < / < oo,
^
If
i ?o o otherwise.
Remark 3.5 (Tail recursion). Consider the recursive definition (3.2) of CompA. In the 'recursive call' (the second expression on the right-hand side of the second equation), notice that (1°) CompA is on the 'outside', and (2°) the parameter changes (from a to CompA(S,a,n)). Such a definitional scheme is said to be tail recursive. Because of (2°), these equations (as they stand) do not form a definition by primitive recursion. However, at least in the classical case, where all the arguments and values range over N, it can be shown that such a scheme can be reduced to a primitive recursive definition. (See, for example, Goodstein [1964, §6.1], where this is called 'recursion with parameter substitution', or Peter [1967, §7], where a more general scheme, not satisfying (1°) only, is considered.) An alternative, primitive recursive, definition of CompA is given below in section 3.14.
3.5
Semantics of statements for While(J^)
We now apply the above theory to the language W/iiJe(S). Here there are two atomic statements: skip and concurrent assignment. We define ^ S tyA for these: d skipper { x:= t $A(r
= CT =
Next we define First and RestA. The definitions of First(S) and RestA(S, a) proceed by structural induction on S. Case 1. S is atomic. First (S) RestA(S,a]
= S = skip.
Case 2. S= Si; 82 (the interesting case!). First(S) = First(Si) ^2 A Rest (Si,cr);S2 Case 3. S = if b then Si else 52 fi.
if Sl is atomic
otherwise.
Computable functions on algebras
First (S)
367
= skip
Case 4- S = while 6 do So od. First (S) A
Rest .ficSl
(S*) 10,17]
= skip —
S i^ S i 1 skip
if tt ./• ^ r t i 4A = «-
if \b\ a = f.
This completes the definition of First and RestA . Note (in cases 3 and 4) that the Boolean test in an 'if or 'while' statement 5 is assumed to take up one time cycle; this is modelled by taking First(S) = skip. The following shows that the i/o semantics, derived from our algebraic operational semantics, satisfies the usual desirable properties. Theorem 3.6. (a) For S atomic, [S]A = QSfyA, i.e., ^ skip \Aa
r 2
= a
[S2]A([Si]Aa).
if [b]A
a
if [blAa = tt
Proof. Exercise. Hint: For part (6), prove the following lemma. Formulate and prove analogous lemmas for parts (a), (c) and (d). I Lemma 3.7. CompA(Si; 52, a, n) —
CompA(Si,
if Vfc < nCompA(Si,a, k + 1) ^ * if 3fc < nCompA(Si,a, k + 1) = * where n0 is the least such fc, and a1 = CompA(Si,a,no).
368
J. V. Tucker and J. I. Zucker
Remark 3.8. (a) The four suitably formulated lemmas needed to prove parts (a)-(d) of Theorem 3.6 (of which Lemma 3.7 is an example for part (&)) provide an alternative definition of CompA(S,(r,n), which does not make use of First or RestA. This definition is by structural induction on 5, with a secondary induction on n. (b) The meaning function [S J (i.e., our i/o semantics) was derived from our operational semantics, i.e., the CompA function. We could also give a denotational i/o semantics for While statements. Theorem 3.6 would then provide (one direction of) a proof of the equivalence of the two semantics (as in de Bakker [1980]). (c) The semantics given here is simpler than that given in Tucker and Zucker [1988] where the states have an 'error value' almost everywhere (for uninitialised variables), and there is an 'error state' corresponding to an aborted computation. While such an 'error semantics' is superior (we feel) to the one given here, the semantics given here is simpler, and adequate for our purposes. For the semantics of procedures, we need the following. Let M C Vars, and a, a' € State(A). Lemma 3.9. Suppose var(S) C M. If a\ « a-i (rel M), then for all n > 0, CampA(S,ai,n) w CompA(S,a2,n) (rel M). Proof. By induction on n. Use the functionality lemma (3.4) for terms. • Lemma 3.10 (Functionality lemma for statements). Suppose var(S) C M. // a\ w <72 (rel M), then either ft) [S}Ao'i 4- ff'\ and [S]Aff2 4- ""2 (say)> where a[ m cr2 (rel M), or (ii) \S\Aoi | and [S\Aff2 tProof. From Lemma 3.9.
3.6
I
Semantics of procedures
Now if
P = proc in a out b aux c begin 5 end is a procedure of type u —> v, then its meaning is a function
defined as follows. For a £ Au, let a be any state on A such that
Computable functions on algebras
369
For [P}A to be well defined, we need the fact that the procedure P is functional, as follows. Lemma 3.11 (Functionality lemma for procedures). Suppose P = proc in a out b aux c begin S end. If a\ ?a <72 (rel a), then either (i) [5]Acri 4- a\ and [S]A
or
Proof. Suppose <TI w 172 (rel a). We can put S=Sinu;S', where 5jnit consists of an initialisation of b and c to closed terms (see section 3.1). Then, putting [$n«]A<7i = /
and
{Sinit\A^ = cr2',
it is easy to see that a'/WCTg (rela,b,c). The result then follows from the functionality lemma 3.10 for statements (with 5', a" and er2 in place of S,
370
J. V. Tucker and J. I. Zucker from the equivalence of partial recursiveness and While computability on the naturals (see, for example, McNaughton [1982]), or from the results in section 8. Hence every partial recursive function over N is While computable on every N -standard algebra.
(b) In the ./V-standardised group QN (Example 2.27(6)), the partial function ord: G -¥ N, defined by ,. . I least n s.t. yqn = 1, ord(g) ~ < 11
if such an n exists otherwise,
which gives the order of group elements, is While computable, since the 'constructive least number operator' is (see section 8). Alternatively, we can give directly a While procedure in the signature proc in g:grp out n:nat aux prod:grp begin prod:=g;
{temporary product}
n:=l;
while not(prod=l) do prod:=prod* g; n:=succ(n) od end
We emphasise that this order function is defined uniformly over all Nstandardised groups (of the given signature E(^ Ar )). The following proposition will be useful. Proposition 3.15 (Closure of While computability under composition). The class of While computable functions on A is closed under composition. In other words, given (partial) functions f : Au -t A" and g : A" —t Aw (for any ^-product types u,v,w), if f and g are While computable on A, then so is the composed function g o / : Au ->• Aw . Proof. Exercise. (Construct the appropriate While procedure for the composed function.) I Remark 3.16. Similarly, we have closure under composition for the related notions of computability still to be considered in this section, namely WhileN, While*, For, ForN and For* computability, and the relativised versions of these. The results for For computability (etc.) can be derived from its equivalence with PR computability (etc.) (cf. section 8).
Computable functions on algebras
3.7
371
Homomorphism invariance theorems
We will investigate how our semantics of While programs interacts with homomorphisms between standard S-algebras. Let A and B be two standard E-algebras. Let (j> = {<£„ \s £ Sort(S,)} be a S-homomorphism from A to B. For a 6 A,, we will write (j>(a) for 0«(a); and for a tuple a = (ai, . . . ,am) 6 Au, we will write 4>(a) for (<^(oi), . . . ,<£(a m )). Lemma 3.17. (a) >t>ooi is the identity on B. (6,) 0g is injective on all equality sorts s. Proof. Exercise.
I
Definition 3.18. The mapping » induces a mapping 4> : State(A) U {*} -> State(B) U {*}
i.e., if a = (as \s € Sort(E)>, then ^(tr) =
I
Theorem 3.20 (Homomorphism invariance for atomic statements).
For 5 6 AtSt, 4U S \Ao) = 4 S \iB4>(a). Proof. The case where 5 = skip is trivial. The case where S is an assignment follows from Theorem 3.19. I Corollary 3.21 (Homomorphism invariance for the Compi predicate). S,
372
J. V. Tucker and J. I. Zucker
Proof. By induction on n. For the base case n = 1, use Corollary 3.21. I Theorem 3.23 (Homomorphism invariance for statements). Either (i) \SlAo- J, a' and IS1]5^) 4. a" (say), where 4>(a') = a", or (ii) {S\Aa t and lS}Bj>(
I
Theorem 3.24 (Homomorphism invariance for procedures). For a procedure P : u —>• v and a € Au , PB(4>(a)).
(a)) ~
Proof. Prom Theorem 3.23.
3.8
I
Locality of computation
We will investigate how the semantics of While programs relates to the subalgebra generated by the input. (Recall Definition 2.15.) We want to prove the locality theorem: for any While computable function / on A of type u ->• u, and any a £ Au, if /(a) J, then /(a) C (a)A. This will follow immediately from Theorem 3.30 below. Lemma 3.25. For a term t : s with var(t) C x, lt\Aa e
(a(x})A.
(Recall the definition of cr[x] in section 3.2.) Proof. By structural induction on t.
I
Lemma 3.26. For an atomic statement S with var(S) C x : u,
Proof. There are two cases to consider. If S is an assignment, the result follows from Lemma 3.25. If 5 = skip, then it is trivial. I Lemma 3.27. I f v a r ( S ) C x : u, then CompA(S,a)[x]
C (
Proof. From Lemma 3.26.
I A
Lemma 3.28. I f v a r ( S ) C x and Comp (S,cr,n) ^ *, then
Computable functions on algebras
373
Comp^S, a, n)[x] C (O-[X})A. Proof. By induction on n (with 5 and a varying). For the base cases (n = 1), use Lemma 3.27. For the induction step, use the facts that var(RestA(S,o-)) C var(S) and that
X C (Y)A => (X)A C (Y)A. The details are left as an exercise. I Theorem 3.29 (Locality for statements). // var(S) C x : u and lS]A(o-) J, then [S]V)M e Mx]tf.
Proof. From Lemma 3.28. I Theorem 3.30 (Locality for procedures). For a procedure P : u -* v and a € Au such that PA(a) \,, PA(a) e (a)A.
Proof. Suppose P = proc in a out b aux c begin Sinu', S1 end
where Sinu consists of an initialisation of b and c to closed terms (see section 3.1). Put x = a,b,c, and suppose a[a]=a,
[Sintt]Aa = a" and
[S']Aa"±ol.
Then (a)A = (<,[*])*
= (a"(x})A,
(3.3)
since Sinu consists (only) of the initialisation of b and c to the closed terms, the values of which lie in every E-subalgebra of A. Also, by the syntax of procedures (section 3.1(c)), var(Sinu', S1) C x. Hence by Theorem 3.29, applied to S' and a", PA(a) =df
(3.4)
The result follows from (3.3) and (3.4). • Certain useful additions to, or modifications of, the While language defined in section 3.1, with corresponding notions of computability, will be defined in sections 3.9-3.13.
374
3.9
J. V. Tucker and J. I. Zucker
The language WhileProc(T?)
In the language While(Yi), we use procedures not in the construction of statements, but only as a convenient device for defining functions (section 3.6). We can, however, define a language WhileProcCS) which extends While(S) by the adjunction of a new kind of atomic statement, the procedure call (3.5)
x := P(t),
where P is a procedure of type u -> v (say), t is a tuple of terms of type u (the actual parameters) and x : v. The semantics of While is then extended by adding the following clause to the semantics of atomic statements (section 3.4): v
._
_
) | a (say)
Note that the function d • ^ : AiS* ->• (5• State (4)) is now partial (compare section 3.4). However, it is easy to 'eliminate' all such procedure calls from a program statement, i.e., to effectively transform WhileProc statements to While statements with the same semantics, as follows. For any procedure call (3.5), suppose P = proc in a out b aux c begin 5 end.
(3-6)
Then replace (3.5) by the statement S(a,b,c/*,x,z),
(3.7)
where z is a tuple of distinct 'fresh' variables of the same type as c, and (...) denotes the simultaneous substitution of t,x,z for a,b,c. Note that the result of this substitution (3.7) is a syntactically correct statement, by the stipulation (section 3.1) that the input variables a not occur on the left-hand side of assignments in 5. Remark 3.31.
(a) According to our syntax, in the procedure call (3.5) above, 'P' is not just a name for a procedure but the procedure itself, i.e., the complete text (3.6)! In practice, it is of course much more convenient — and customary — to 'declare' the procedure before its call, introducing an identifier for it, and then calling the procedure by means of this identifier.
Computable functions on algebras
375
In any case, our syntax prevents recursive procedure calls. The situation with recursive procedures would be quite different from that described above — they cannot be eliminated so simply (de Bakker [1980]). (6) Another way of incorporating procedure calls into statements is by expanding the definition of terms, as was done in Tucker and Zucker [1994]. The problem with that approach here is that it would complicate the semantics by leading to partially defined terms. In Tucker and Zucker [1994] this problem does not occur, since the procedures, being in the For language rather than While, produce total functions.
3.10
Relative While computability
Let g = (gA \ A £ K) be a family of (partial) functions
We define the programming language While(g) which extends the language While by including a special function symbol g of type u —» v. We can think of g as an 'oracle' for gAThe atomic statements of While(g) include the oracle call z:=g(«) where t : u and x : v. The semantics of this is given by
x :=
|
if <M(WM t •
Similarly, for a tuple of (families of) functions g\,... ,gn, we can define the programming language While(gi,... ,gn) with oracles gi,... ,g n for <7i > • • • j 9n, or (by abuse of notation) the programming language While(g\, ••-,&»)• In this way we can define the notion of While(g\,--., gn) computability, or While computability relative to g\,... ,gn, or While computability in gi,... , gn, of a function on A. Similarly, we can define the notion of relative While semicomputability of a relation on A. We can also define the notion of uniform relative While computability (or semicomputability) over a class K. Lemma 3.32 (Transitivity of relative computability). /// is While computable in g\,... , gm, hi,... ,hn, and g\,... , gm are While computable in hi,... , hn, then f is While computable in hi,... , hn. Proof. Suppose that gi is computable by a While(hi,... ,h n ) procedure Pj for t = 1,... ,m. Now, given a While(gi,... ,g m ,hi,... ,h n )
376
J. V. Tucker and 3. I. Zucker
procedure P for /, replace each oracle call x := g t ( t ) in the body of P by the procedure call x := Pj(t). This results in a WhUe(h\,... ,h n ) procedure — actually, a WhileProcfoi,... ,h n ) procedure (section 3.9) — which also computes /. I Note that this result holds over a given algebra A, or uniformly over a class K of E-algebras.
3.11
.For(E) computability
We consider briefly another programming language, For = For(E), which also plays a role in this paper. Assume now that E is an N-standard signature, and A an N-standard algebra. The syntax for For is like that for While, except that Simt(E) is denned by replacing the loop statement while b do 5 od by for t do S od,
(3.8)
where t : nat, with the informal semantics: execute S k times, where t evaluates to k. More formally: first we define the notation Sk (k > 0) to mean the fc-fold iterate of S, i.e., cfc _ I S;... ; 5 (k times) if k > 0 [skip if jfc = 0. We now define the semantics of For by modifying the definitions (section 3.5) of the functions First and RestA, replacing case 4 with: Case 4'. S ~ f o r t do 50 od. First(S) RestA(S,a)
= skip = (S0)k
where k = \t\Aa. Note that t is evaluated (to k) once, upon initial entry into the loop, which is then executed exactly k times (even if the value of t changes in the course of the execution). Thus \S\A is always total, and functions computable by For procedures are always total. We define For(A) to be the class of functions For computable on A. As in section 3.10, we can define the notion of relative For(E) computability, and prove a transitivity lemma for this, analogous to Lemma 3.32. Example 3.33. The functions For computable on M of type nat* -»nat are precisely the primitive recursive functions over N. This follows from the equivalence of primitive recursiveness and For computability on the naturals (proved in Meyer and Ritchie [1967]; see, Davis and Weyuker [1983], for example) or from section 8. Hence
Computable functions on algebras
377
every primitive recursive function over N is For computable on every N-standard algebra. (Compare Example 3.14(a).) Proposition 3.34. (a) .For(E) computability implies While(S) computability. More precisely, there is an effective translation S —> S' of For(E) statements to While(E) statements, and (correspondingly) a translation P -> P' of For(S) procedures to While(S) procedures which is semantics preserving, i.e., for all For(E) procedures P and Nstandard ^-algebras A, [P}A = [P'1A. (b) More generally, relative For(£) computability implies relative Whtic(S) computability. Proof. Simple exercise.
3.12
I
While" and For^ computability
Consider now the While and For programming languages over T,N. Definition 3.35. (a) A WhileN(H) procedure is a While(E) procedure in which the input and output variables have sorts in E. (However the auxiliary variables may have sort nat.) (6) ProcN(£) is the class of While1* (E) procedures. Definition 3.36 (WhileN computable functions). (a) A function / on A is computable on A by a WhileN procedure P if / = PA. It is WhileN computable on A if it is computable on A by some WhileN procedure. (b) A family / = (/A \ A € K) of functions is WhileN computable uniformly over K if there is a WhileN procedure P such that for all A € K, fA = PA(c) WhileN(A) is the class of functions WhileN computable on A. The class of ForJV(E) procedures, and ForN(S) computability, are defined analogously. Remark 3.37. (a) If A is ^-standard (so that For computability is defined on A), then AN has two copies of N, which we can call N and N', of sort nat and nat', respectively (each with 0, S and < operations). To avoid technical problems, we assume then that in the for command ((3.8) in section 3.11), the term t can have sort nat or nat'. This assumption helps us prove certain desirable results, for example: (i) There are For(AN) computable bijections, in both directions, between the two copies of N.
378
J. V. Tucker and J. I. Zucker
(ii) For computability implies ForN computability (the seemingly trivial direction '<£=' of Proposition 3.38). (b) ForN computability implies WhileN computability (cf. Proposition 3.34). (c) Relativised versions of WhileN and ForN computability can be denned as with While computability (section 3.10), and corresponding transitivity lemmas (cf. Lemma 3.32) proved. Also, relative ForN computability implies relative WhileN computability. Proposition 3.38. // A is N-standard, then WhileN (or ForN) computability coincides with While (or For) computability on A. Proof. For the direction lWhileN (or ForN) computability =£> While (or For) computability', we can use the coding of AN in A (see Remark 2.28(d)), or, more simply, represent the computation over AN by computation over A, by 'identifying' the two carriers N* and N with each other, or (equivalently) 'identifying' the two sorts nat' and nat, renaming variables of these sorts suitably to avoid conflicts. (See also Remark 3.37(a).) •
3.13
While* and For* computability
Recall the algebra A* of arrays over A, with signature E* (section 2.7). Consider now the While and For programming languages over £*. Definition 3.39. (a) A sort of E* is called simple, augmented or starred according as it has the form s, su or s* (respectively), for some s £ Sort(E). (b) A variable is called simple, augmented or starred according as its sort is simple, augmented or starred. Note that every sort of S* is simple, augmented, starred or nat. Definition 3.40. (a) A While*(E) procedure is a While(Y*) procedure in which the input and output variables are simple. (However the auxiliary variables may be augmented or starred or nat.) (b) Proc*= Proc*(S) is the class of While*(S) procedures. (c) Proc*u^v = Proc*(£)„_»„ is the class of While*(E) procedures of type u —> v, for any S-product types u and v. Remark 3.41. We can assume that the auxiliary variables of a While* procedure are either simple or starred or nat, since a procedure with augmented variables as auxiliary variables can be replaced by one with simple variables, by the device of coding A" in A (see Remark 2.30(c)). Definition 3.42 (While* computable functions). (a) A function / on A is computable on A by a While* procedure P if / = PA. It is While* computable on A if it is computable on A by some While* procedure.
Computable functions on algebras
379
(6) A family / =(/A \ A € K) of functions is While* computable uniformly over K if there is a While* procedure P such that for all 4 6 K , fA=PA(c) While* (A) is the class of functions While* computable on A. The class of For*(E) procedures, and For*(S) computability, are defined analogously. Remark 3.43. (a) While* computability will be the basis for a generalised ChurchTuring thesis, as we will see in section 8.8. (b) For*(Ti) computability implies While* (£) computability (cf. Proposition 3.34). (c) Relativised versions of While* and For* computability can be defined as with While computability (section 3.10) and corresponding transitivity lemmas (cf. Lemma 3.32) proved. Also, relative For* computability implies relative While* computability. (d) In M, WhileN and While* computability are equivalent to While computability, which in turn is equivalent to partial recursiveness over N (Example 3.14(o)). Similarly, in JV, For, ForN and For* computability are all equivalent to primitive recursiveness (Example 3.33). Theorem 3.44 (Locality of computation for While* procedures). For a While* procedure P : u —>• v and a G Au such that PA(a) 4-,
PA(«) 6 (a)A. Proof. This follows from the corresponding Theorem 3.30 for While computability, applied to A*, together with E*/E conservativity of subalgebra generation (to be proved below, in Corollary 3.65). I The following observation will be needed later. Proposition 3.45. On A*, While* (or For*) computability coincides with While (or For) computability. This follows from the effective coding of (A*)* in A* (Remark 2.31(d)). Remark 3.46 (Internal versions of While* and For* computability). If A is ./V-standard, we can consider 'internal versions' of While* and For* computability, based on the 'internal version' of A*, which uses the copy of N already in A instead of a 'new' copy (see Remark 2.31(c)). We can show that these versions provide the same models of computation as our standard ('external') versions. Proposition 3.47. Suppose A is N-standard. Let While*' and For*' computability on A be the 'internal versions' of While* and For* (respectively) computability on A (see previous remark). Then While*' and
380
J. V. Tucker and J. I. Zucker
For*' computability coincide with While* and For* (respectively) computability on A. Proof. Exercise. (Cf. Proposition 3.38.)
3.14
I
Remainder set of a statement; snapshots
We now return to the operational semantics of section 3.4. The concepts developed here will be useful in investigating the solvability of the halting problem for certain algebras (Section 5.6). First we define the remainder set RemSet(S) of a statement S, which is (roughly) the set of all possible iterations of the RestA operation on S at any state. Definition 3.48. The remainder set RemSet(S) of S is defined by structural induction on S: Case 1. S is atomic. RemSet(S) - {S}. Case 2. S = Si;S2. RemSet(S) = {S[;S2 \ S[ £ Re-ruSet^)}
(jRemSet(S2).
Case 3. S = if b then Si else S2 fi. RemSet(S) = {S} \JRemSet(Si) U RemSet(S2). Case 4- S = while b do SQ od.
RemSet(S) = {S} U {S'0; S | SQ € RemSet(S0)}. Example 3.49. Consider a statement of the form S s oj; while 6 do 02; 03; 04 od;05 where the o, are atomic statements (using ad hoc notation) and 6 is a Boolean test. Then RemSet(S) consists of the following:
S, while 6 do 02503504 od;o5, 02503504; while b do 02503504 od;o5, 03504; while b do 02503504 od;as, 04; while b do 02;03; 04 od; 05, a5. The next proposition says that RemSet(S) contains S, and is closed under the 'Rest' operation (for any state).
Computable functions on algebras
381
Proposition 3.50. (a) S&RemSet(S). (b) S' 6 RemSet(S) ==» RestA(S',a) € RemSet(S) for any state a. Proof. By structural induction on S. I Proposition 3.51. RemSet(S) is finite. Proof. Structural induction on S. I Definition 3.52. The statement remainder function RemA : Stmtx5ta*e(A)xN ->Stmt is the function such that RemA(S, cr,n) is the statement (the 'remainder of 5') about to be executed at step n of the computation of 5 on A, starting in state cr (or skip when the computation is over). This is defined by recursion on n (tail recursion again): RemA(S,tr,Q) = S RemA(S,(T,n+l) = {
skip if n > 0 and S is atomic RemA(RestA(S,a),CompA(S,o-),n) otherwise.
Note the similarity with the tail recursive definition of CompA (section 3.4). Note also that for n = 1, this yields RemA (S, a,l) = RestA(S,a). The two functions Comp and Hem also satisfy the following pair of relationships, which (together with suitable base cases n = 0) could be taken as a (re-) definition of them by simultaneous primitive recursion: Proposition 3.53. (a) CompA(S,a,n + l) = Compf (RemA(S,o-,n),CompA(S,o-,n)) (b) RemA(S,a,n + 1) = ReatA(RemA(S,a,n),CompA(S,a,n)) provided CompA(S,a,n) ^ *. Proof. Exercise. I A Proposition 3.54. For all n, Rem (S,a,n) € RemSet(S)\j{sk\p}. Proof. Induction on n. Use Proposition 3.50. I A If we put Sn =Rem (S,a,n), then the sequence of statements 5 = So, S\, 5-2, • • • is called the remainder sequence generated by S at
382
J. V. Tucker and J. I. Zucker
Corollary 3.55. For fixed S and a, the range of RemSeqA(S,a) is finite. Proof. Prom Propositions 3.51 and 3.54.
•
Now we introduce the notion of a 'snapshot'. Definition 3.56. (a) A snapshot is an element (a,S) of (State(A)D{*})x (b) The snapshot function
Stmt.
SnapA : Stmt x State(A) x N -)• (State(A)U{*}) x Stmt is denned by
SnapA(S,a,n) = ( CompA (S,a,n), RemA (5,
= (a0,S0),(ffi,Si),
CompA(S,ff,n)
(<7 2 ,S 2 ), ...
is called the snapshot sequence generated by S at a, written SnapSeqA(S,
= SnapA (S,a,n) ^ (*,skip)
i.e., ffm = an ^ * and Sm = Sn, then for all k > 0 SnapA(S, a,rn + k) = SnapA(S,a,n + k) ^ (*,skip). Proof. Exercise.
I
Corollary 3.58. If the snapshot sequence generated by S at cr repeats a value, then it is infinite. Remark 3.59.
(a) The snapshot function will be used later, in considering the solvability of the halting problem for locally finite algebras (section 5.5). (6) The snapshot function is adapted from Davis and Weyuker [1983] (or Davis et al. [1994]). There a 'snapshot' or 'instantaneous description'
Computable functions on algebras
383
of a program P is defined as a pair (i, a) consisting of an instruction number (or line number) i of P, and the state a. The reliance on instruction numbers is possible here because programs consist of sequences of elementary instructions, including the conditional jump. However, in the context of our While programming language, the specification of an instantaneous description by a simple 'instruction number' is impossible; we need the more complex notion of a particular 'remainder' of the given program (or statement) .
3.15
£*/£ conservativity for terms
We conclude this section with a very useful syntactic conservativity theorem (Theorem 3.63) which says that every £*-term with sort in £ is effectively semantically equivalent to a S-term. This theorem will be used in sections 4 (universality for While* computations: Corollary 4.15) and 5 (strengthening Engeler's lemma: Theorem 5.58). First we review and extend our notation for certain syntactic classes of terms. Notation 3.60.
(a) Terma = Terma(£) is the class of E-terms t with var(t) C a, and Term^s = Term aiS (£) is the class of such terms of sort s. (b) Further, we define: Term£ = Terma(£*) Termf = Term a (£ N ) and similarly, Terma s = Terma)S(S*) for any sort s, etc. (c) For any £' D E, we write Terma(S'/E) for the class of E'-terms of sort in S (but possibly with subterms of sort in S' \ S), and Terma,8 (£'/£) for the class of such terms of sort s (in S). We will show that for all s € S'ort(S), every term in Term£)S (i.e., £*-term of sort s) is effectively equivalent to a term in Terma>s (i.e., a E-term of sort s). We will do this in three stages: (1°) Define an effective transformation of £*-terms (of sort in EU]7V) to E^-terms. (2°) Define an effective transformation of Su'N-terms (of sort in S N ) to Ew-terms. (3°) Define an effective transformation of E^-terms (of sort in S) to Sterms. Here, in all cases, the program variables of the terms are among a. In preparation for this, we must define the notion of the maximum value of a term in Term£ nat. This is the maximum possible numerical value that such a term could have, under any assignment to the variables a.
384
J. V. Tucker and J. I. Zucker
Definition 3.61. For t e Term* nat , its maximum value maxval(t) 6 N is defined by induction on the complexity of t (which we can take as the length of t as a string of symbols: cf. Remark 3.2). There are four cases: (a) (b) (c) (d)
t=0 : maxval(t) = 0. t=St0 : maxval(t) = maxval(t0) + 1. t=\f(b,ti,t2) : maxval(t) = max(maxval(ti), maxval(t^)). <=Lgths(r), where r is of starred sort. There are four subcases, according to the form of r: (i) (ii)
r = Null : maxval(t) = 0. r = Update(r 0 ,ii,i2) : maxval(t) =maxval(Lgth(ro)).
(Hi)
r = Newlength(ro,ii) : maxval(t) =maxval(ti).
(iv)
r = if(6,ri,r 2 ) : maxval(t) — max.(maxval(Lgth(ri)),
Remark 3.62. (a) This definition, which is used in stage 1 of the syntactic transformation described in Theorem 3.63 below, uses the assumption that the variables of t all have sorts in E. If, for example, t (or a subterm of t) was a variable of sort nat, or was of the form Lgth(z*) for a variable z* of starred sort, we could not define maxval(t). (b) Suppose (i) E is strictly TV-standard (and so includes the sort nat), and (ii) the sorts of a do not include nat. Then, with Terra* s = Terma)s(S*) with the 'internal' version of S* (using this sort nat instead of a 'new' sort, cf. Remark 2.31(c)), we can still give an appropriate definition of maxval(t) for t € Terra* nat . (Check.) Theorem 3.63 (E*/S conservativity for terms). Let a be an (arbitary but fixed) tuple of'S-variables. For all s 6 Sort(E), every term in Terra*;S is effectively semantically equivalent to a term in Terma,s. Proof. This construction (or transformation) of terms proceeds in three stages: Stage 1: from E*-terms (of sort in E""^) to Eu'Ar-terms; Stage 2: from Eu"/v-terms (of sort in E^) to E^-terms; Stage 3: from E^-terms (of sort in E) to S-terms. In all cases, the program variables of the terms are among a. Stage 1: From Terraa(E*/Su'JV) to Terraa(Eu'Ar). This amounts to removing subterms of starred sort from a term of unstarred sort.
Computable functions on algebras
385
First notice that if a term of unstarred sort contains a subterm of starred sort, then it must contain a (maximal) subterm r of starred sort in one of the three contexts: r = r',
Ap(r,«),
Lgth(r).
We will show how to eliminate each of these three contexts in turn. Step a. Transform all contexts of the form r\ = TI fa of starred sort) to M
Lgth(n) = Lgth(r2) A where M =maxwai(Lgth(ri)), and k is the numeral for fc (that is, '0' preceded by 'S' fc times). Now all (maximal) occurrences of a subterm r of starred sort are in a context of the form either Ap(r, t) or Lgth(r). Step b. Transform all contexts of the form Ap(r, t), by structural induction on r. There are four cases, according to the form of r: (i) (ii) (Hi) (iv)
r = Null: Ap(r, t) i—>• r = Update(r 0 ,to,£i): Ap(r,*) i—> r = Newlength(r 0 , to): Ap(r, t) i—> r = if(6,ri,r 2 ): Ap(r.t) •— >
unspec. M(t = tQ < Lgth(ro), ti, Ap(r 0 ,t)). if(t < Jo, Ap(r 0 ,<), unspec). if(6, Ap(n,«), Ap(r 2 ,*)).
Note the use of the 'if operator in cases (ii) and (in). Hence the inclusion of 'if in the definition of standard algebra (section 2.4). Note also the use of '<' in cases (ii) and (Hi). Hence the inclusion of '<' in the definition of the standard algebra Af (Example 2.23(6)) and TV-standardisations (section 2.5). Step c. Transform all contexts of the form Lgth(r), by structural induction on r. Again there are four cases, according to the form of r: (i) (ii) (in) (iv)
r = Null: Lgth(r) -^ 0. r = Update(r 0 ,*o,*i) : Lgth(r) i—> Lgth(ro). r = Newlength(ro,to): Lgth(r) ^ t0. r = \f(b,ri,r2): Lgth(r) >—> if(ft,Lgth(n), Lgth(r 2 )).
386
J. V. Tucker and J. I. Zucker
By these three steps, we transform a starred term (i.e., a term of Terma(S*)), into an unstarred term (i.e., a term of Term a (S u>Ar )), as desired, completing stage 1. Stage 2: From Terma(Su'Ar/EAr) to Term*(SN). Let i be a term of E u>Ar , with sort in T,N. We note the two following assertions: (1°) A maximal subterm ru of t of augmented sort su must occur in one of the following contexts: («) MO, (6) Unspec8(ru), (c) r u = r'u or r'u = r u (for s an equality sort). (2°) Any term r" € Term a (E u ' Ar ) of sort su is semantically equivalent to a term having one of the following forms: (i) i,(r), where r & Term(£N), (M) unspec s . Assertion (1°) is proved by a simple inspection of the possibilities, and (2°) is proved by structural induction on r". (Details are left to the reader.) Stage 2 is completed by considering all combinations of cases (a), (b) and (c) in (1°) with cases (i) and (ii) in (2°), and (writing '~' for semantic equivalence over S u>;v ) noting that (a) JaOsM) - r, j s (unspec s ) ~ 6s (cf. section 2.6), (b) Unspecs(is(r)) ~ false, Unspecs(unspecs)) ^ true, (c) (i.(r) = i.(r')) * (r = r'), (is(r) = unspecs) ~ false, (unspecs = is(r)) ~ false, (unspecs =unspecs) ~ true. Stage 3: From Terma(SAr/E) to Terma(S). Let t be a term of ZN, with sort in S. We note the two following assertions: (1°) A maximal subterm r of t of sort nat must occur in one of the contexts
r < r',
r' < r,
r = r',
r' = r
for some subterm r' of sort nat. (2°) Any term r 6 Terma(SjV) of sort nat is semantically equivalent to a numeral n. Again, assertion (1°) is proved by a simple inspection of the possibilities, and (2°) is proved by structural induction on r. (Details are left to the reader.)
Computable functions on algebras
387
Stage 3, and hence the proof of the lemma, is completed by noting that all four cases listed in (1°) are then equivalent to m < n or fh = n, and hence (depending on m and n) to either true or false. I Remark 3.64. (a) The transformation of terms given by the conservativity theorem is primitive recursive in Godel numbers. (6) Suppose (i) £ is strictly AT-standard (and so includes a sort nat), and (ii) the sorts of a do not include nat. Then, with Term* s = Term a>s (£*) with the 'internal' version of S* (as in Remark 3.62(6)), the conservativity theorem still holds. (Check.) Recall Definition 2.15 on generated subalgebras. . Corollary 3.65 (£*/£ conservativity of subalgebra generation). Let X C Usesort(s) -^*- Then for any S-sort s, (X)f*
= (Xtf.
We can apply this to strengthen Theorem 3.30: Theorem 3.66 (Locality for While, WhileN or While* computable functions). Let f be a (partial) function on A of type u -> v, let a € Au, and suppose f ( a ) \~ If f is While, WhileN or While* computable, then /» e ( « ) -
4
Representations of semantic functions; universality
In this section we examine whether or not the While programming language is a so-called universal model of computation. This means answering questions of the form: Let A be a £ -algebra. Does there exist a universal While program Uprog € While(H) that can simulate and perform the computations of all programs in Whife(S) on all inputs from A? Is there a universal While procedure Uproc G Proc(£) that can compute all the While computable functions on A? These questions have a number of precise and delicate formulations which involve representing faithfully the syntax and semantics of While computations using functions on A. To this end we need the techniques of Godel numbering, symbolic computations on terms, and state localisation. Specifically, for Godel numbering to be possible, we need the sort nat, and so we will investigate the possibility of representing the syntax of a standard S-algebra A (not in
388
J. V. Tucker and J. I. Zucker
A itself, but) in its ./V-standardisation AN, or (failing that) in the array algebra A*. Among a number of results, we will show that for any given Yi-algebra A, there is a universal While procedure over A if, and only if, there is a While program for term evaluation over A. In consequence, because term evaluation is always While computable on A*, we have that for any 'S-algebra A, there is a universal While program and universal While procedure over A* . Thus, for any algebra A our While* model of computation is universal. In particular, we can enumerate the While* computable functions (f>o, <j>i,
which is While* computable, uniformly in the types u, v. If the E-algebra A has a While program to compute term evaluation, then While* (A) = WhileN(A). We consider also the uniformity of universal programs and procedures over a class K. of algebras. Many familiar classes of algebras, such as groups, rings and fields, have While programs to compute term evaluation uniformly over these classes.
4.1
Godel numbering of syntax
We assume given a family of numerical codings, or Godel numberings, of the classes of syntactic expressions of £ and £*, i.e., a family gn of effective mappings from expressions E to natural numbers rE~( = gn(E), which satisfy certain basic properties: • rE~* increases strictly with compl(E), and in particular, the code of an expression is larger than those of its subexpressions. • sets of codes of the various syntactic classes, and of their respective subclasses, such as {ri~1 | t e Term}, {rr | t € Terms}, {rSn | 5 6 Stmt}, {r5"1 | S is an assignment}, etc. are primitive recursive; • We can go primitive recursively from codes of expressions to codes of their immediate subexpressions, and vice versa; thus, for example, r 5i"1 and rS^~< are primitive recursive in rSi;S^'>, and conversely, r Si; S?'1 is primitive recursive in rSin and r52n. In short, we can primitive recursively simulate all operations involved in processing the syntax of the programming language. This means that the
Computable functions on algebras
389
syntactic classes form a computable (in fact, primitive recursive) algebra, in the sense of Definition 1.1. We will use the notation r
Termn =% { T 1 1 6 Term},
etc., for sets of Godel numbers of syntactic expressions. We will be interested in the representation of various semantic functions on syntactic classes such as Term(S), Stmt(£) and Proc(E) by functions on A or A* , and in the computability of the latter. These semantic functions have states as arguments, so we must first define a representation of states.
4.2
Representation of states
Let x be a w-tuple of program variables. A state cr on A is represented (relative to x) by a tuple of elements a € Au if
)
=
(tt, a[x])
where 6^ is the default tuple of type u in A (section 2.14).
4.3
Representation of term evaluation
Let x be a u-tuple of variables. Let Term* = Term z (E) be the class of all S-terms with variables among x only, and for all sorts s of E, let TermItS = TermItS(S) be the class of such terms of sort s. Similarly, we write TermTup-f for the class of all term tuples with variables among x only, and TermTup*^ for the class of all u-tuples of such terms. The term evaluation function on A relative to x : Term^x State (A) defined by is represented by the function ~1 xAu
390
J. V. Tucker and J. I. Zucker
defined by r, a) =
where a is any state on A such that
r
Term^s~l x A" te
Strictly speaking, if gn is not surjective on N, then teAs is not uniquely specified by the above definition, or by the diagram. However, we may assume that for n not a Godel number (of the required sort), teAs(n, a) takes the default value of sort s (2.12). Similar remarks apply to the other representing functions given below. Further, for a product type v, we will define a evaluating function for tuples of terms teAv:
Av
similarly, by , a) -
[t]A
We will be interested in the computability of these term evaluation representing functions.
4.4
Representation of the computation step function
Let AtSt* be the class of atomic statements with variables among x only. The atomic statement evaluation function on A relative to x, AEA: AtSt^x State(A) -> State(A), defined by is represented by the function Au aeA: r defined by aeA( r5^, a) where a is any state on A such that
Computable functions on algebras
AtSt x xState(A)
(gn,RepA)
AEA
391
1 State(A)
T
t
Rep*
aeA Next, let Stmtf be the class of statements with variables among x only, and define RestA=df RestA\ (StmtxxState(A)). Then First and Rest* are represented by the functions r
Stmtn ->.
which are defined so as to make the following diagrams commute:
Stmt
jPirst
gn\
>•
AtSt
\gn first
Resti
gn r
StmtI"1
Note that first is a function from N to N, and (unlike restf and most of the other representing functions here) does not depend on ^4 or x. Next, the computation step function (relative to x) Comp2= CompA\(StmtIxState(A.)xN}: Stmt x xState(A)xN ->• State (A) U {*} is represented by the function
392
J. V. Tucker and J. I. Zucker camp?:
r
Stmt^xAu x N ->• 1 x Au
which is denned so as to make the following diagram commute: CompA
>
State(A)\j{*}
(gn,RepAidw)
RepA
r
StmtI~lxAu x N
A
>•
B x Au
comp We put
compA(rS^,a,n)
= (notoverA(rS~*,a,n),
state^^S'*,a,n))
with the two 'component functions' notoverA: sfate^1:
r r
Stmt^xAu x N -> 1 StmtI'1xylu x N -> A"
where notoverA(rS~],a, n) tests whether the computation of rSn at a is over by step n, and state^^S"*, a, n) gives the value of the state (representative) at step n.
4.5
Representation of statement evaluation
Let Stmt^ be the class of While statements with variables among x only. The statement evaluation function on A relative to x, SEA: Strut** State(A) -> State(A), defined by SEA(S,a)
= fS]V
is represented by the (partial) function seA: rStmt^xAu -» Au, defined by
where a is any state on A such that cr[x] = a. (This is also well defined, by the functionality lemma for statements, 3.10.) In other words, the following diagram commutes.
Computable functions on algebras
StmtIxState(A)
SEf
393
> Stote(A) Rep?
SxA"
>•
Au
We will also be interested in the computability of se^ •
4.6
Representation of procedure evaluation
We will want a representation of the class Procu_>w of all While procedures of type u —> i>, in order to construct a universal procedure for that type. This turns out to be a rather subtle matter, since it requires a coding for arbitrary tuples of auxiliary variables. We therefore postpone such a representation to section 4.8, and meanwhile consider a local version, for the subclass of Procu^v of procedures with auxiliary variables of a given fixed type, which is good enough for our present purpose (Lemma 4.2 and Theorem 4.3). So let a,b,c be pairwise disjoint lists of variables, with types a : u, b : v and c : w. Let Froca,b,c be the class of While procedures of type u -> v, with declaration in a out b aux c. The procedure evaluation function on A relative to a,b,c
defined by PE^c(P,a) = PA(a) is represented by the function P
394
J. V. Tucker and J. I. Zucker a ,b,c
X Au
x Au
We will also be interested in the computability of pe£b c.
4.7
Computability of semantic representing functions; term evaluation property
By examining the definitions of the various semantic functions in Section 3, we can infer the relative computability of the corresponding representing functions, as follows. Lemma 4.1. The function first: N —> N is primitive recursive, and hence While computable on AN , for any standard 'E-algebra A. Lemma 4.2. Let x be a tuple of program variables and A a standard Ealgebra. (a) ae£ and rest£ are While computable in ( te^s\ s € Sort(S)) on AN. (b) compA, and its two component functions notover^ and state^, are While computable in ae^ and rest^ on AN . (c) se^ is While computable in comp^ on AN . (d) pe£b c is While computable in se£ on AN , where x=a,b,c. (e) te£s is While computable in pe^ « on AN , where y is a variable of sort s, not in x. The above relative While computability results all hold uniformly for A £ Proof. Note first that if a semantic function is defined from others by structural recursion on a syntactic class of expressions, then a representing function for the former is definable from representing functions for the latter by course of values recursion on the set of Godel numbers of expressions of this class, which forms a primitive recursive subset of N. We can then prove parts (a)-(d) by examining the definitions of the semantic functions, and applying Lemma 4.1 and (relativised versions of) the following facts: (1°) If a function / on ^4^ is defined by primitive recursion or tail recursion on nat from functions g, h, . . . on AN , then / is For(g, h,...) computable on AN. (Used in (a) and (b).)
Computable functions on algebras
395
(2°) Course of values recursion on nat with range sort nat is reducible to primitive recursion on nat. (Used in (a).) (3°) The constructive least number operator, used in part (c) (cf. the definition of CompLength in section 3.4), is While computable onAN. References for facts (1°) and (3°) are given later (Theorem 8.5). Fact (2°) can be proved by an analogue of a classical technique for computability on M which can be found in Peter [1967] or Kleene [1952]. We complete the cycle of relative computability by proving (e) as follows: given a term t e Terrors, consider the procedure P = proc in x out y begin y:=t end. r
Then since P~" is primitive recursive in rt~[ and te^a(rt~>,a) = Pex,y,(>(r^>~1'°) (an(i since For computability implies While computability), the result follows from (1°). • Theorem 4.3. The following StdAlg(-£).
are equivalent, uniformly
for A
6
(i) For all x and s, the term evaluation representing function te^s is While computable on AN. (ii) For all x, the atomic statement evaluation representing function ae£, and the representing function rest^, are While computable on AN. (Hi) For all x, the computation step representing function comp£, and its two component functions notover^ and state^, are While computable on AN. (iv) For allx., the statement evaluation representing function se^ is While computable on AN. (v) For all a,b,c, the procedure evaluation representing function pe^b c is While computable on AN. Proof. From the transitivity lemma for relative computability (3.32) and Lemma 4.2. • Definition 4.4 (Term evaluation). (a) The algebra A has the term evaluation property (TEP) if for all x and s, the term evaluation representing function te^s (or, equivalently, any of the other sets of semantic representing functions listed in Theorem 4.3) is While computable on AN. (b) The class K has the uniform TEP if the term evaluation representing function is uniformly While computable on KN. Examples 4.5. (a) Many well-known varieties (i.e., equationally axiomatisable classes of algebras) have (uniform versions of) the TEP. Examples are: semigroups, groups, and associative rings with or without unity. This
396
J. V. Tucker and J. I. Zucker
follows from the effective normalisability of the terms of these varieties. In the case of rings, this means an effective transformation of arbitrary terms to polynomials. Consequently, the unordered and ordered algebras of real and complex numbers (R.,'R<,C and C < , defined in Example 2.23), which we will study in section 6, have the TEP. (See Tucker [1980, §5].) (b) An (artificial) example of an algebra without the TEP is given in Moldestad et al. [I980b]. Proposition 4.6. The term evaluation representing function on A* is For (and hence While) computable on A* , uniformly for A £.StdAlg(Y,). Hence the class StdAlg(£*) has the uniform TEP. Proof. (Outline.) The function te ^* is definable by course of values recursion (cf. Remark 8.6) on Godel numbers of E*-terms, uniformly for A £StdAlg(E). It is therefore uniformly For computable on A*, by Theorem 8. 7(a). I Corollary 4.7. (a) The term evaluation representing function on A is For* (and hence While*) computable on AN , uniformly for A £StdAlg(E). (b) The other semantic representing functions listed in Theorems 4.3 are While* computable on AN , uniformly for A (EStdAlg(£). Remark 4.8. Suppose £ and A are ,/V-standard. Then the semantic representing functions listed above (such as te^s) can all be defined over A instead of AN . In that case, Lemma 4.2, Theorem 4.3, Definitions 4.4 and Corollary 4.7 can all be restated, replacing 'AN\ 'S^' and 'KN' by 'A', '£' and 'K', respectively. Similar remarks apply to the definitions and results in Sections 4.8-4.12. Recall the definitions of generated subalgebras, and minimal carriers and algebras (Definitions 2.15 and 2.17 and Remark 2.16). Corollary 4.9 (Effective local enumerability) . (a) Given any ^-product type u and H-sort s, there is a For* computable uniform enumeration of the carrier set of sort s of the subalgebra (a)A generated by a & Au , i.e., a total mapping enum£s: Au x N -> As which is For* computable on AN , such that for each a £ A" , the mapping
(where x : u) is surjective. (b) If A has the TEP, then enum£s is also While computable on AN .
Computable functions on algebras
397
Proof. Define enum^ s simply from the appropriate term evaluation representing function: p (a, n) = te^s(n,a). Corollary 4.10 (Effective global enumerability). (a) If A is minimal at s, then there is a For* computable enumeration of the carrier As, i.e., a surjective total mapping enumf:
N -»• As, N
which is For* computable on A . (b) If in addition A has the TEP, then enumf table on AN .
is also While compu-
Proof.. From Corollary 4.9, using the empty list of generators.
4.8
•
Universal WhileN procedure for While
It is important to note that the procedure representing function pe^b c of section 4.6 is not universal for Proc(£,)u^.v (where a : u and b : v) . It is only 'universal' for While procedures of type u -» v with auxiliary variables of type type(c). In this subsection we will construct a universal procedure UniVy J)(rP~1, a) for all P € Procu-+vand a £ Au. This incorporates not the auxiliary variables of P themselves, but representations of their values as (Godel numbers of) terms in the input variables a. These can then all be coded by a single number variable. We will, assuming the TEP for A, construct a universal procedure for ProCu-+v on A. For this we need another representation of the computation step function which differs in two ways from comp^ in section 4.4: (1°) it is denned relative to a tuple a of program variables ('input variables'), which does not necessarily include all the variables in S; (2°) it has as output not a tuple of values in A, but a tuple of terms in the input variables — or rather, the Godel number of such a tuple of terms. More precisely, given a product type u = s\ x . . . x sm and a u-tuple of variables a : u, we define compu*. rVarTup~l x rStmt~* x Au x N ->• B x rTermTup~l as follows: for any product type w extending u, i.e., w = si x . . . x sp for some p > m, and for any x : w extending a (i.e., x=a, x Sm+1 , . . . , x Sp ), and for any 5 € Stmtx , o, 6 Au and n € N, where
398
J. V. Tucker and J. I. Zucker
(i) bn =notover2(rS~>, (a, 6 A ) , n), and («) tne TermTupl!W and te*w(Vt(a,8A)) n), where 5^ is the default tuple of type sm+i x . . . x sp. This use of default values follows from the initialisation condition for output and auxiliary variables in procedures (section 3.1(d)). (This is also what lies behind the functionality lemma 3.11 for procedures.) (If p is not a Godel number of a tuple of variables x which extends a, or if q is not a Godel number of a statement 5 with var(S)C x, then we define compu£(p,q,a,n) — 0 (say). This case is decidable primitive recursively in p and q. Similarly for the other functions defined below.) The function compu^ has the two 'component functions' notoverUx stateu*
: :
VarTupxr Strut1 xAu x N -» B VarTupxrStmt~(xAu x N ->• rTermTup~l
where, for x extending a and s € Sttnt*, (rxn,r5"l,a,n) (rx~(,rS^,a,n)
= =
bn tn~l.
r
Compare these functions with comp^ and its components notover^ and (section 4.4). Note that for any x extending a and S notover^(rS'1, (a, 6 A), n) state? (rS^, (a, 8A), n)
= =
notoveru£(ryi~',rS~*, a,n) = bn
Think of compu^ and its component functions as uniform (in x) versions of cornp^ and its component functions. Only the 'input variables' a are specified. We need a syntactic operation on terms and variables. Definition 4.11. For any term or term tuple t and variable tuple a, subex(t, a) is the result of substituting the default terms 8s for all variables xs in t except for the variables in a. Remark 4.12.
(a) For all t 6 TermTup, subex(t,a) e TermTup*. (b) subex is primitive recursive in Godel numbers. (c) Suppose t : w and var(t) C x = a, z where a : u. Then for a € Au, where S A is the default tuple of type type(z). This follows from the 'substitution Lemma' in logic; see, for example, Sperschneider and Antoniou [1991]. Lemma 4.13. The function compu^, and its component functions notoveru^ and stateu*, are While computable in (te^s \ s € Sort(Z)} on AN , uniformly for A &StdAlg(E).
Computable functions on algebras
399
Proof. (Outline.) We essentially redo parts (a) and (b) of Lemma 4.2, using uniform (in x) versions of aeA and restA, i.e., we define (1°) the function aeuA:
r
VarTup~>xrAtSt~l
-»
r
TermTup~(
where for any x : w and S € AtSt*, we have aeu /t ( r x~ 1 , r S~ 1 ) € !~TermTupI,w~l, such that for any x£ Aw, (r^rS^), x) = aeA(rS and (2°) the function restuA:
r
VarTup~(xrStmt~>xAu
->•
where for any x : w extending a : u, 5 € AtSto and a € Au, restuA(r^,rS^,a)
= rest? (''S'1, (a, 6 A)).
We can then show that (i) aeuA is primitive recursive; (ii) compuA is While computable in restuA on A; and (Hi) restuA is While computable in (teAs \ s 6 5or<(S)). Combining these three facts gives the result. Note, in (Hi), that the term evaluation functions teAs are used to evaluate Boolean tests in the course of defining restuA. The one tricky point is this: how do we evaluate, using teAt3, a (Godel number of) a term t € TermIiS, which contains variables in x other than a? (This is the issue of 'uniformity in x'.) The answer is that by Remark 4.12(c) the evaluation of t is given by £e£s(rsu6ea;(t,a)~1, a). • Theorem 4.14 (Universality characterisation theorem for While(E) computations). The following are equivalent, uniformly for
(i) A has the TEP. (ii) For all ^-product types u,v, there is a While(£N) procedure Univ U ) U : rProcu_yt,~1 x u -> v
which is universal for Procu->v on A, in the sense that for all P € Procu.^v and a € Au , UnivjyP^a) ~ PA(a). Proof. (i) =>• (ii): Assume A has the TEP. We give an informal description of the algorithm represented by the procedure Univ U)t; . With input (rP"1, a), where P eProcu->vand a € Au, suppose
400
J. V. Tucker and J. I. Zucker P = proc in a out b aux c begin S end where a : u and b : v. Putting x=a,b,c, evaluate notoveru* (rx~l,r5~l, a, n) for n = 0, 1, 2, . . . , until you find the (least) n for which the computation of S at a terminates (if at all), i.e.,, the least n = HQ such that notoverUx(rx^,rS~],a, n0 + 1) = ff. Note that notoveru^ is While computable by Lemma 4.13 and assumption. Now let us put stateu^(rx~l,rS~l,a, n0) = rt, t', t"'1, where the term tuples t, t' and t" represent the current values of a, b and c, respectively. This is also While computable by Lemma 4.13 and assumption. Finally, the output is
(cf. Remark 4.12(c)). By assumption and Remark 4.12(6), this is While computable in rt'~l and a, and hence in rP~l and a. («) =>• (j): Note that for any a,b,c, where a : u and b : v. Hence pe^b,c ig While(£N) computable if is. The result follows from Theorem 4.3. I Corollary 4.15 (Universality for ^4*). For all ^-product types u,v, there is a While* (EN ) procedure Univ* )1( : natxu which is universal for Proc*u_+v, in the sense that for all P € A e StdAlg(S) and a £ Au, rPV) ^ PA(a). Proof. StdAlg(£,*) has the uniform TEP, by Proposition 4.6.
I
Remark 4.16. (a) For all u, v, the construction of Univ u , v (direction (i) => (ii) in the proof of Theorem 4.14) is uniform over S in the following sense. There is a relative While(£N) procedure Uu
Computable functions on algebras
401
coTnjm^(rxn,rSn, a, 0), compu^(rx~l,rS~1, a, 1), ... ; (4.1)
and (2°) in the evaluation of the output variables t' (see proof of Theorem 4.14). We can separate, and postpone, both these applications of term evaluation by modifying the construction of the universal procedure as follows. Step 1: Construct from S, not a computation sequence as in (4.1) but rather a computation tree (section 5.10), specifically comptree(rx~l, r S~l,n) (where x = a, b, c), which is the Godel number of the first n levels of the computation tree from S € Stmtx labelled by wtuples of terms in TermTupz<w. Note that comptree:^ -»• N is primitive recursive. Step 2: Select a path in this tree by evaluating Boolean tests (using te^bool together with the subex operation) until you come (if at all) to a leaf. Evaluate the terms representing the output variables at this leaf (again using te£B with the subex operation).
4.9
Universal WhileN procedure for While*
We can strengthen the universal characterisation theorem for While computations (4.14) using the £*/£ conservativity thorem (3.63). Theorem 4.17. (Universality characterisation theorem for While* computations) The following are equivalent, uniformly for A
(i) A has the TEP. (ii) For all ^-product types u,v, there is a While(£iN) procedure Univ U)t ,: natxu —> v
which is universal for Proc*u^v on A, in the sense that for all P € Proc*u^v and a 6 Au, '.a) ~ PA(a). Proof. (i) => (H): Modify the proof of Theorem 4.14, following the algorithm of Remark 4.16(6). Construct a computation tree as in 'step 1. Then, in step 2 (term evaluation), replace all Boolean terms (in selecting a path) and the output terms (at the leaf) by the corresponding Sterms given by Theorem 3.63, and apply te£s (for s € S'ort(E)) to these. Since this transformation of terms is primitive recursive in
402
J. V. Tucker and J. I. Zucker
Godel numbers (Remark 3.64(o)), the whole algorithm can be formalised as a While(SN) procedure. (M) => (j): This follows trivially from Theorem 4.14. I Corollary 4.18. The following are equivalent, uniformly for A £StdAlg(E).
(i) A has the TEP. (ii) While* (A) = WhileN(A).
4.10
Snapshot representing function and sequence
Next we consider the statement remainder and snapshot functions (section 3.14) which will be useful in our investigation of the halting problem (section 5.6). Let x : u. The statement remainder function (relative to x) RemA= RemA\(StmtxxState(A)xN) Stmt%xState(A)x^ ->
:
(cf. Definition 3.52) is represented by the function remA: rStmt^xAu x N ->• r which is denned so as to make the following diagram commute: RemA
StmtzxState(A)xN
>•
Stmt*
r
Stmt^xAu x N
(Again, this is well defined, by Lemma 3.10.) The snapshot function (relative to x) Snap*=
SnapAl(StmtIxState(A)xN): StmtIxState(A)xN ->• (Stote(A)U{*})xStmtx
(cf. Definition 3.56) is represented by the function snapA:
r
Stmt^xAu x N -> (B x Au)xrStmtI~l
which can be defined simply as snapA(rS~l,a,n)
= =
(compA(rS~l,a,n), remA(rS~l,a,n)) ((notoverA(rS~i,a, n), stateA (rS'1 ,a, n)),
Computable functions on algebras
403
or (equivalently) so as to make the following diagram commute: SnapA
> (State(A) U
(gn,RepA ,idN)
(RepAt,gn)
Fix x : u, s 6 Stmtf and a € A". Put &„ = notoverA(rS~t,a, n), an ( r 5~ l ,a,n) and rSn~1 = rem^l(r5"1, a,n). Then the sequences (tt,a)
=
(&o,ao)> (&i,ai), (62,02), •••
are called, respectively, the computation representing sequence, the remainder representing sequence and the snapshot representing sequence generated by S (or rSn) at a (with respect to x), denoted respectively by compseq£(rS~(,a), reraseg^(rS~1,a) and snapseq^(rS^,a). (Compare the sequences CompSeqA(S,a), RemSeqA(S,a) and SnapSeqA(S,o~) introduced in section 3.) The sequences compseqf (r S~* ,a) and snapseqA(rS~*,a) are said to be non-terminating, if, for all n, notoverA(rS^,a,n) = tt, i.e., for no n is These representing sequences satisfy analogues of the results listed in section 3.14; for example: Proposition 4.19. // snapseqA f~ ^5n ,a) repeats a value at some point, then it is periodic from that point on, and hence non-terminating. In other words, if for some m,n with m^n
then, for all k > 0, snapA(rS-l,a, m + k) = snapA(rS^,an + k) ? ((ff,^),skip) (Cf. Proposition 3.57 and Corollary 3.58.) With the function anapA , we can extend the list of relative computability results (Lemma 4.2), and add a clause to Theorem 4.3: Lemma 4.20. (Cf. Lemma 4-%-) The function snapA, and its two component functions compA and remf, are While computable in (teAs \ s € SoH(£)) on AN, uniformly for A
404
J. V. Tucker and J. I. Zucker
Proof. Simple exercise.
I
Theorem 4.21. (Cf. Theorem 4-3.) formly for A €StdAlg(Z):
The following are equivalent, uni-
(i) For all x and s, the term evaluation representing function te£g is While computable on AN . (ii) For all x, the snapshot representing function snap^ , and its two component functions camp* andrem^, are While computable on AN. Proof. As for Theorem 4.3.
I
A uniform (in x) version of snap* will be used in section 5.6 in our investigation of the 'solvability of the halting problem'.
4.11
Order of a tuple of elements
Let u be a E-product type, s a E-sort and A a S-algebra. The order function of type u,s on A is the function ord£s: Au -> N where, for all x 6 A", i.e., the cardinality of the carrier of sort s of the subalgebra of A generated by x. (It is undefined when the cardinality is infinite.) Note that this is a generalisation of the order operation for single elements of groups (Example 3.14(6)). Note that for a tuple x € Au, the subalgebra (x)f can be generated in stages as finite sets: <*>i!o C (xfa C (x)^ C... where (x)*n is defined by induction on n, simultaneously for all S-sorts s (cf. Meinke and Tucker [1992, 3.12.15ff.] for the single-sorted case), and
Also (x)f is finite if, and only if, there exists n such that
<*>£> = ««+i
(4-2)
in which case Ws,n
=
(x/s,n+l
— \x)s,n+2
= • ••
= (X)
s
.
Lemma 4.22. For any tuple of variables x : u, there is a primitive recursive function
Computable functions on algebras SubAlgStage^u,s:
405
N -> N
such that SubAlgStagex,u,s(n) is the Godel number of a list (rti~*... r £fc n ~ 1 ) of Godel numbers of the set of terms generated by stage n, i.e.,
Example 4.23. Suppose s is an equality sort. (a) The order function ord^ s is While computable in te^s (where x : u) on AN, uniformly for A £StdAlg(£). (b) Hence if A has the TEP, then ord£s is While computable on AN . Proof. The algorithm to compute ord^ s is (briefly) as follows. Suppose given an input x e Au. With the help of the functions SubAlgStageI
4.12
Locally finite algebras
Definition 4.24. An algebra A is locally finite if every finitely generated subalgebra of A is finite, i.e., if for every finite X C Usesortffi) ^» an<^ every sort s, (X)^1 is finite. Note that A is locally finite if, and only if, ord£s (section 4.11) is total for all u and s. Example 4.25. Consider the algebra AC = (N-; 0,pred) where N~ is just (a copy of) N, and 'pred' is the predecessor operation on this: pred(n + 1) = n and pred(O) = 0. We write 'N~ ' to distinguish this carrier from the 'standard' naturals N, which we can adjoin to form the ./V-standardised algebra. We also write the sort of N~~ as nat~ . Let M- = (N-,B; 0,pred,eqnat-, ... ) be the standardised version of jV^~ (with nat~ an equality sort). Then both .A/^ and jV~ are locally finite; in fact for any k\ , . . . , km e N~ ,
where fc = max(fci,... ,fc m ). (Check.) Hence
Theorem 4.26. Suppose A is locally s € Strut* and a € Au:
finite.
Then for any x : u,
406
J. V. Tucker and J. I. Zucker
(a) snapseq^(rS~l,a) has finite range. (b) snapseq^ (rS~l,a) (or, equivalently, compseq£(rS~l,a)) is non-terminating •<=> snapseqf(rS'l,a) repeats a value (other than ((f, 6^) Proof.
(a) Consider a typical element of the snapshot representing sequence generated by 5 at a: (an,rSn^)
(4.3)
where an = comp^(rS~t,a,n) and rS«n = rem£(rS~l,a, n) for some n. By Lemma 3.28, an must be in (a)^, which is finite by assumption. Also, by Proposition 3.54, 5n must be in RemSet(S)\J {skip}, which is finite, by Proposition 3.51. Hence the pair (4.3) must be in the product set (a)^ x rRemSet(S)~*, which is also finite. (b) The direction '=>' follows from (a). The direction '•£=' follows from Corollary 3.58 or (equivalently) Proposition 4.19. I Local finiteness will be used later, in considering 'solvability of the halting problem' (Section 5.6).
4.13 Representing functions for specific terms or programs The representing functions that we considered in sections 4.3-4.6 and 4.10 have as arguments (typically) (i) Godel numbers of terms, statements or procedures, and (ii) representations of states. Computability of all these functions is equivalent to the TEP (Theorems 4.3 and 4.21). Another form of representation which will be useful is to use (i) the term, statement, etc. as a parameter, not an argument, and just have (ii) the state representation as an argument. More precisely, we define (for x : u, t £Term XjS , s G Stmtx, a : u, b : v and P €Proc^tC) the functions Au -+ Au
^
u
->
A
u
A xN Au x N -> B x Au
(4.4)
Computable functions on algebras
remAs snapAs
: :
407
Au x N Au x N -» (I x .4") x
seAs
such that
t<.» = tc^rr.o), A r 1
compAs(a,n)
=
comp ( S~ ,a, n),
and similarly for the other functions listed in (4.4). We then have: Theorem 4.27. (a) The functions teAsj and aeAs are While computable on A. The functions reatAs, notoverAs, 8tateAs, compAs, remAs and snapAs are While computable on AN . The functions seAs and peAb c P are WhileN computable on A. (b) Suppose A is N-standard. Then all the functions listed in (4-4) are While computable on A. Proof. For (a): computability of teAs
5
Notions of semicomputability
We want to generalise the notion of recursive enumerability to many-sorted algebras. There turn out to be many non-equivalent ways to do this. The primary idea is that a set is While semicomputable if, and only if, it is the domain or halting set of a While procedure; and similarly for WhileN and While" semicomputability. There are many useful applications of these concepts, and they satisfy closure properties and Post's theorem: A set is computable if, and only if, it and its complement are semicomputable.
408
J. V. Tucker and J. I. Zucker
The second idea of importance is that of a projection of a semicomputable set. In computability theory on the set N of natural numbers, the class of semicomputable sets is closed under taking projections, but this is not true in the general case of algebras, even with While* computability. (A reason is the restricted form of computable local search available in our models of computation.) Protective semicomputability is strictly more powerful (and less algorithmic) than semicomputability. In this section we will study the two notions of semicomputability and projective semicomputability in some detail. We will consider the invariance of the properties under homomorphisms. We will prove equivalences, such as projective While* semicomputability = projective For* computability. In the course of the section, we also consider extensions of the While language by non-deterministic constructs, including allowing: (i) arbitrary initialisations of some auxiliary variables in programs; (if) random assignments in programs. We prove that in these non-deterministic languages, semicomputability is equivalent to the corresponding notion of projective semicomputability. We also show an equivalence between projective semicomputability and (Hi) definability in a weak second-order language. We characterise the semicomputable sets as the sets definable by some effective countable disjunction
\/bk k=0
of Boolean-valued terms. This result was first observed by E. Engeler. There are a number of attractive applications, e.g. in classifying the semicomputable sets over rings and fields, where Boolean terms can be replaced by polynomial identities; we consider this topic in section 6. These concepts and results are developed for computations with the three languages based on the While, WhileN and While* constructs; and their uniformity over classes of algebras is discussed. We assume throughout this section that E is a standard signature, and A a standard E-algebra.
5.1
While semicomputability
Definition 5.1. The halting set of a procedure P : u -+ v on A is the relation HaltA(P) =df {a e Au \ PA(a) 4.}. Now let J? be a relation on A.
Computable functions on algebras
409
Definition 5.2. (a) R is While computable on A if its characteristic function is. (b) R is While semicomputable on A if it is the halting set on A of some While procedure. (c) A family R =(RA \ A € K) of relations is W^hi/e semicomputable uniformly over K if there is a W^/iiJe procedure P such that for all A € K, .RA is the halting set of P on A. It follows from the definition that R is While semicomputable on A if, and only if, R is the domain of a While computable (partial) function on A. Remark 5.3. As far as defining relations by procedures is concerned, we can ignore output variables. More precisely, if R =HaltA(P), then we may assume that P has no output variables, since otherwise we can remove all output variables from P simply by reclassifying them as auxiliary variables. We will call any procedure without output variables a relational procedure. Definition 5.4 (Relative While semicomputability). Given a tuple
=
proc in x: real begin while not x= 0 do x := x-1 od end
(c) Similarly, the set of integers is While semicomputable on 7£. (Exercise.) (d) However, the sets of naturals and integers are While computable on Tl< (section 2.23(d)). (Exercise.) (e) The set of rationals is While semicomputable on K. (Exercise. Hint: Prove this first for KN.)
5.2
Merging two procedures: Closure theorems
In order to prove certain important results for While semicomputable sets, namely (a) closure under finite unions, and (b) Post's theorem, we need to develop an operation of merging two procedures, i.e., interleaving their
410
J. V. Tucker and J. I. Zucker
steps to form a new procedure. In the context of TV-standard structures, and assuming the TEP, this is a simple construction (as in the classical case over N). In general, however, the merge construction is quite non-trivial, as we shall now see. Lemma 5.6. Given two relational While(T,) procedures PI and PI, of input type u, we can construct a While(E) procedure Q = mg(Pi,P2) : u -> bool, the merge of PI and P2 , with Boolean output values (written '1 ' and '2 ' for clarity) such that for all A £StdAlg(E) and a € A":
or
QA(a) \r 1
=»
PA(a) |,
Proof. We may assume without loss of generality that PI P2
= =
proc in x aux z\ begin Si end proc in x aux z2 begin 8-2 end
where x : u and ziDz2 = 0. We can construct a procedure Q = proc in x aux zi,z2, . . . out which begin S end where S=mg(Si,Sz), the 'merge' of Si and 52, and 'which' is a Boolean variable with values written as '!' and '2'. The operation m(Si,S 2 ) is actually defined for all pairs Si,S2 such that var(Si)nuar(S 2 )C x, and none of the x occur on the Ihs of any assignment in Si or S2. It has the semantic property that for all A, a:
or and if [ra<7(Si,S2)lAcr ^ a' then a' (which) = 1 =» {Si\a\. and [mg(Si, S2)]Aa « [Si]Aff (rel worSi), (/(which) = 2 =*• [5 2 JaJ.and [mg(Si,S^)]Aa w [S2]A(r (rel varS2). The definition of mg(Si,Sz) is by course of values recursion on the sum of compl(Si) and compl(S2)- Details are left as a (challenging) exercise. (Hint: The tricky case is when both Si and S2 have the form Sj=while hi do S? od; S< (i = 1, 2), where ';S-' may be empty). I Remark 5.7. The construction of mg(Pi , P2) for A is much simpler if we can assume that (i) A is N-standard, and (ii) A has the TEP. In that case, by Theorem 4.3, the computation step representing function compA is While computable on A. Using this, we can construct a While procedure which interleaves the computation steps of Si and S2, tests at each step
Computable functions on algebras
411
whether either computation has halted, and (accordingly) gives an output of 1 or 2. Theorem 5.8 (Closure of While semicomputability under union and intersection). The union and intersection of two While semicomputable relations of the same type are again While semicomputable. Moreover, this result is uniformly effective over StdAlg(E), in the sense that given two While procedures PI and P2 of the same input type u, there are two other procedures Piu2 and Pm2 of input type u, effectively constructible from P\ and PI, such that on any standard ^-algebra A, (a) HaltA(Piu2) = HaltA(Pi)U HaltA(P2); (b) HaltA(Pln2) = HaltA(Pl)r\ HaltA(P2). Proof. Suppose again without loss of generality that PI P2
= =
proc in x aux z\ begin Si end proc in x aux z2 begin S2 end
where z\ n z2 = 0. (a) Piu2 can be defined as Tn.g(Pi,P2), as in Lemma 5.6. (We ignore its output here.) (b) Pm2 can be defined, more simply, as in the classical case: Pm2 = proc in x aux zi, z2 begin Si; 82 end. If R is a relation on A of type u, we write the complement of A as Rc
=df
I
AU\R.
Theorem 5.9 (Post's theorem for While semicomputability). For any relation R on A R is While computable
<£=»
R and Rc are While semicomputable.
Moreover, this equivalence is uniformly effective over StdAlg(£), i.e., (considering the reverse direction) given any procedures PI and P2 of the same input type u, there is a procedure P$ : u —> bool, effectively constructible from PI and P2, such that on any standard Y,-algebra A, if the halting sets of PI and P2 are RA and RCA respectively, then P3 computes the characteristic function of RA . Proof.
(=0
This follows, as in the classical case, by modifying a procedure which computes the characteristic function of R into two procedures which have R and Rc respectively as halting sets. («=) Again, we can just take P3 = mg(Pi,P 2 ), as in Lemma 5-6. • Another useful closure result, applicable to ./V-standard structures, is: Theorem 5.10 (Closure of While semicomputability under N-projections). Suppose A is N-standard. If R C A uxnat is While semicomputable on A, then so is its ^-projection {x € Au \ 3n € N/t(x,n)}.
412
J. V. Tucker and J. I. Zucker
Proof. From a procedure P which halts on R, we can effectively construct another procedure which halts on the required projection. Briefly, for input x, we search by dovetailing for a number n such that P halts on (x,ri). In other words, the algorithm proceeds in stages (1,2, . . . ), given by the iterations of a 'while' loop. At stage n, test whether P halts in at most n steps, with input (x, k), for some k < n. This can be done by computing notover^s(x,k) for all k < n (see section 4.13). The algorithm halts if and when we get an output f. I Note that if A has the TEP, we could just as well use the computation step representing function comp£ in the above proof instead of comp£s. (Cf. Remark 5.7.) We can generalise Theorem 5.10 to the case of an As-projection for any minimal carrier Aa (recall Definition 2.17), provided A has the TEP: Corollary 5.11 (Closure of While semicomputability under projections off minimal carriers). Suppose A is N-standard and has the TEP. Let As be a minimal carrier of A. If R C Au*s is While semicomputable on A, then so is its projection {x e Au \ 3y € As R(x,y)}. Proof. Recall that by Corollary 4.10, there is a total While computable enumeration of As, enurn^: N -> As. u
So for all x € A ,
3y e AsR(x,y)
«=>• 3nR(x,enum£(n))
•$=> 3nR'(x,n)
where (as is easily seen) the relation R'(x,n) =df
R(x,enumf(n))
is While semicomputable. The result follows from Theorem 5.10.
I
Note that there are relativised versions (cf. Definition 5.4) of all the results of this subsection so far. Discussion 5.12 (Minimality and search). Corollary 5.11 is a manysorted version of (part of) Theorem 2.4 of [Friedman, 1971a], cited in [Shepherdson, 1985]. The minimality condition (a version of Friedman's Condition III) means that search in As is computable (or, more strictly, semicomputable) provided A has the TEP. Thus in minimal algebras, many of the results of classical recursion theory carry over, e.g., • the domains of semicomputable sets are closed under projection (as above); • a semicomputable relation has a computable selection function; • a function with semicomputable graph is computable. (Cf.Theorem 2.4 of Friedman [I971a].) If, in addition, there is computable equality at the appropriate sorts, other results of classical recursion theory carry over, e.g.,
Computable functions on algebras
413
• the range of a computable function is semicomputable. (Cf. Theorem 2.6 of Friedman [I971a].)
5.3
Projective While semicomputability: semicomputability with search
We introduce and compare two new notions of semicomputability: (1°) projective While semicomputability and (2°) While semicomputability with search. First, for (1°): Definition 5.13. (a) R is protectively While computable on A if, and only if, R is a projection of a While computable relation on A (see Definition 2.9(d)). (b) R is projective While semicomputable on A if, and only if, R is a projection of a While semicomputable relation on A. The notions of uniform projective While computability and semicomputability over K of a family of relations, are denned analogously (cf. Definition 5.2(c)). Note that projective While semicomputability is, in general, weaker than While semicomputability. Example 6.15 will show this, using Engeler's lemma. We do, however, have closure of semicomputability in the case of Nprojections, i.e., existential quantification over N, as we saw in Theorem 5.10. Further, we have from Corollary 5.11: Proposition 5.14. Suppose A is N-standard and minimal and has the TEP. Then on A projective While semicomputability =
While semicomputability.
Now, for (2°), we introduce a new feature: definability with the possibility of arbitrary initialisation of search variables. For this, we define a new type of procedure. Definition 5.15. A search procedure has the form Psrch = proc in a out b aux c srch d begin S end,
(5.1)
with search variables d as well as input, output and auxiliary variables, and with the stipulations (compare section 3.1(d)): • a, b, c and d each consist of distinct variables, and they are pairwise disjoint; • every variable in S is included among a, b, c or d; • the input and search variables a,d can occur only on the right-hand side of an assignment in 5; • (initialisation condition): S has the form Smit'iS', where Sina consists of an initialisation of the output and auxiliary variables, but not of the search variables d.
414
J. V. Tucker and J. I. Zucker
Again, we may assume in (5.1) that PSrch has no output variables, i.e., that b is empty. (See Remark 5.3.) Definition 5.16. The halting set of a search procedure as in (5.1) on A (assuming a : u and d : w) is the set HaltA(Psrch)
=df {a e Au\ for some a with a [a] = a, [5]
In other words, it is the set of tuples a € Au such that when a is initialised to a, then for some (non-deterministic) initialisation of d, S halts. Note that this reduces to Definition 5.1 when Psrch has no search variables. Now let J? be a relation on A. Definition 5.17. R is While semicomputable with search on A if R is the halting set on A of some While search procedure. Again, the notion of uniform While semicomputability with search over K of a family of relations, is defined analogously. Now we compare the two notions introduced above. Theorem 5.18.
(a) R is While semicomputable with search on A •*=> R is protectively While semicomputable on A. (b) This equivalence is uniform over StdAlg(E), in the sense that there are effective transformations Psrch >-* P and P i-> Psrch between search procedures Psrch and ordinary procedures P, such that for all A £StdAlg(T,), HaltA(Psrch) is a projection of HaltAP. Proof. The equivalence follows easily from the definitions. Suppose R is the halting set on A by a search procedure Psrch with input variables a : u and search variables d : w. Let P be the procedure formed from Psrch simply by relabelling d as additional input variables. (So the input type of P is ux w.) Then R is the projection onto Au of the halting set of P. The opposite direction is just as easy. I
5.4
WhileN semicomputability
Let R be a relation on A. Definition 5.19. (a) R is WhileN computable on A if its characteristic function is (section 3.12). (b) R is WhileN semicomputable on A if it is the halting set of some WhileN procedure P on AN. Again, we may assume that P has no output variables. (See Remark 5.3.) From Proposition 3.38 we have:
Computable functions on algebras
415
Proposition 5.20. If A is N -standard, then WhileN semicomputability on A coincides with While semicomputability on A. Theorem 5.21 (Closure of WhileN semicomputability under union and intersection). The union and intersection of two WhileN semicomputable relations of the same input type are again WhileN semicomputable, uniformly over StdAlg(S). Proof. Prom Theorem 5.8, applied to AN .
• N
Theorem 5.22 (Post's theorem for While For any relation R on A
semicomputability).
R is WhileN computable •£=*> R and Rc are WhileN semicomputable, uniformly for A
€StdAlg(E).
Proof. From Theorem 5.9, applied to AN .
I
Note that if A has the TEP, then the construction of a 'merged' WhileN procedure mg(P\,P2) from two WhileN procedures PI and P%, used in the above two theorems, is much simpler than the construction given in Lemma 5.6 (cf. Remark 5.7). Also Theorem 5.10 and Corollary 5.11 can respectively be restated for WhileN semicomputability: Theorem 5.23 (Closure of WhileN semicomputability under Mprojections) . Suppose R C yl uxnat ; where u £ProdType(E), and R is While semicomputable on AN , Then its ^-projection {x | 3n € N/?(a;,n)} is WhileN semicomputable on A. Corollary 5.24 (Closure of WhileN semicomputability under projections off minimal carriers). Suppose A has the TEP. Let As be a minimal carrier of A. If R C Au*s is WhileN semicomputable on A, then so is its projection {x € Au \ 3j/ € ^4S R(x,y)}. Example 5.25. (a) (WhileN semicomputability of the subalgebra relation.) For a standard signature E, equality sort s, product type u and standard Salgebra A, the subalgebra relation (where (x)f is the carrier of sort s of the subalgebra of A generated by x 6 Au) is While semicomputable (on AN) in the term evaluation representing function te£s, where x : u (section 4.3). To show this, we note that (cf. Remark 2.16) and apply (a relativised version of) Theorem 5.23. Hence if A has the TEP, this relation is WhileN semicomputable on A.
416
J. V. Tucker and J. I. Zucker
(b) On the standard group Q (Examaple 2.23(#)) the set {g 6 G \ 3n(gn = 1)} of elements of finite order is WhileN semicomputable, being the domain of the order function on QN, which is While computable on QN (Example 3.14(6)). In fact, this set is even While semicomputable on Q. (Exercise.) (c) More generally, for any S-product type u and E-equality sort s, the set (x e Au \(x)f
is finite}
N
is While semicomputable in te£s. This follows from the fact that it is the domain of the function ord^ s, which is While computable in te?s on AN (Example 4.23). Hence if A has the TEP, then this set is WhileN semicomputable on A.
5.5
Projective WhileN semicomputability
Let R be a relation on A. Definition 5.26. (a) R is protectively WhileN computable on A if, and only if, R is a projection of a While(EN) computable relation on AN. (b) R is protectively WhileN semicomputable on A if R is a projection of a While(£N) semicomputable relation on AN. Proposition 5.14 can be restated for WhileN semicomputability: Proposition 5.27. Suppose A is a minimal and has the TEP. Then on A projective WhileN semicomputability =
WhileN semicomputability.
Definition 5.28. R is WhileN semicomputable with search on A if J? is the halting set of a While(2,N) search procedure on AN. Note that the While(£N) search procedure in this definition has simple input variables. However, the auxiliary, search and output variables may be simple or nat. Again, the following equivalence follows easily from the definitions. (Cf. Theorem 5.18.) Theorem 5.29.
(a) R is WhileN semicomputable with search on A 4=> R is projectively WhileN semicomputable on A. (b) This equivalence is uniform over StdAlg(Y,).
5.6
Solvability of the halting problem
The classical question of the solvability of the halting problem ([Davis, 1958]; implicit in [Turing, 1936]) applies to the algebra of naturals A/o (Example 2.5(a)) or its standardised version M (Example 2.23(6)). We
Computable functions on algebras
417
want to generalise this question to any standard signature E and standard E-algebra A. We will find that the problem can only be formulated in ./V-standard algebras. Definition 5.30. Suppose E C S ' , where S is standard and E' is Nstandard, and suppose A is a standard S-algebra and A' is a E'-expansion of A. Then we say the halting problem (HP) for While(E) computation on A is While(Y,')-solvable on A', or the HP for While(A) is solvable in While(A'), if for every S-product type u there is a WhtJe(E') procedure HaltTestn: natxw -4 bool, such that HaltTest^ is total, and for every While(E) procedure P of input type u, and all a £ Au,
, a) = ' [f
otherwise.
The procedure HaltTestu in the above definition is called a universal halting test for type u on While(A).
Proposition 5.31. // the HP for While(A) is solvable in While(A'), then every While(E) semicomputable set in A is While(£') computable in A'. Proof. Simple exercise.
I
The two typical situations are: (») S' = XN and A' = AN; (ii) S is ./V-standard, £'= S and A' = A. Example 5.32. For the algebra N (Example 2.23(6)), the HP is not solvable in While(N). This is a version of the classical result of [Kleene, 1952]. Theorem 5.34 makes use of the concept of local finiteness (section 4.12). In preparation for it, we define uniform (in x) representations of the statement remainder function and the snapshot function (cf. section 4.10). Namely, given a product type u = sj x . . . x sm and a w-tuple of variables a : u (which we think of as input variables) , we define
remu^: snapu*:
r
VarTup^xrStmt~(xAu x N -^rStmt~l l r u VarTup~ x Stmt~nl xA x N ->• r r (Bx TermT«pa ) x Stmt~l
r
as follows: for any product type w extending u, i.e., w = Si x . . . x sp for some p > m, for any x : w extending a (i.e., x = a, x Sm+1 , . . . , x 8)p ), and for any S 6 Stmtj, a € Au and n € N, where 5,4 is the default value of type s m +i x . . . x sp, and
418
J. V. Tucker and J. I. Zucker snapu£(rx.~l,rS~l, a, n)
= (compu£(rx~l, r5~", a, n), rermt^(rx~1,rS~', a, ")) =
((bn,V),rSn^
(5.2)
where bn
=
notoveru^(rx.~l, I~S~1, a, n)
r
Sn'] = Lemma 5.33. The function snapu^, and its components compu^ and remu£, are While computable in (te^s \ s 6 5ort(S)) onAN, uniformly forAeStdAig(£). Proof. Similar to Lemma 4.20.
I
Theorem 5.34. Suppose (1°) £ has equality at all sorts, (2°) A has the TEP, and (3°) A is locally finite. Then the HP for While(A) is solvable in While(AN). Proof. Given a E-product type u = si x . . . x sm, we will give an informal description of an algorithm over ^4^ for a universal halting test for type u on While(A). (Compare the construction of the universal procedure in section 4.8.) With input ( r P n , a), where P has input type u, and a 6 Au, suppose P =. proc in a out b aux c begin S end where a : u. Put x = a, b, c. Then for n = 0, 1, 2, ... snapu?(V,rS^,a, n) = ((bn,rtn^,rSn^) as in (5.2) above. Now put %n =te£w(rtn~l,a) = state^ (r 3^,0, 6A), n). By Lemma 5.33 and assumption (2°), snapu^ is While computable on AN . In other words, its three components bn, r t n n and rSn~l (as functions of n) are While computable on AN . Hence by assumption (2°) again, the components of the w-tuple xn are While computable on AN (as functions of n). Now for n — 0, 1, 2, . . . , evaluate the w-tuple xn, and compare it (componentwise) to xm for all TO < n (which is possible by assumption (1°)), until either (a) bn = f, which means that the computation of 5 (and hence of P at a) terminates; or
Computable functions on algebras
419
(b) for some distinct m and n, bm = bn = tt, xm = xn and rSrn~l = r Sn~>, which means that the computation of 5 never terminates, by Proposition 3.34. Exactly one of these two cases must happen, by Theorem 4.26 and assumption (3°). In case (a) halt with output tt, and in case (b) halt with output f I Note that Assumption (1°) can be weakened to: (1°') Equality on As is WhileN computable, for all E-sorts s. Also, for all M, the above construction of HaltTestu is uniform over E in the following sense: t'here is a relative While(£,N) procedure Hu : nat x u -4 bool containing oracle procedure calls (gs \ s € Sort(E)) and (ha | s € Sort(S)) with gs : s1 ->• bool and hs : nat x u -> s, such that for any A €StdAlg(E), if A is locally finite, then, interpreting gs and /is as eq^1 and te^s respectively on A (where x : u), Hu is a universal halting test for type u on A. (Cf. Remark 4.16(a).) Corollary 5.35. Suppose (1°) E has equality at all sorts, (T) A has the TEP, (3°) A is locally finite, and (4°) A is N-standard. Then the HP for While(A) is solvable in While(A). Example 5.36 (A set which is WhileN but not While semicomputable). The above theory allows us to produce an example to distinguish between While and WhileN semicomputability. Let A be the algebra JV~ (Example 4.25). We present an outline of the argument. Check each of the following points in turn. (i) In AN there is a computable bijection (n H-> n) from N~ to N. (U) Hence the WhileN computable subsets of N~ are precisely the recursive sets of natural numbers (cf. Remark 3.43(d)). (Hi) Similarly the WhileN semicomputable subsets of N~~ are precisely the recursively enumerable sets of natural numbers (cf. Example 5.5). (iv) Since M~ is locally finite (4.25) and has the TEP, the HP for While(A) is solvable in While(AN). Therefore, by Proposition 5.31, every While semicomputable subset of N~ is WhileN computable, and hence recursive. The result follows from (Hi) and (iv). The same algebra, A/""", can be used to distinguish between While and WhileN computable functions. (Exercise. Hint: There is a universal WhileN(Af~) procedure for all total While(N~) functions of type nat~-»nat~.)
420
5.7
J. V. Tucker and J. I. Zucker
While* semicomputability
Let R be a relation on A. Definition 5.37. (a) R is While* computable on A if, and only if, its characteristic function is. (b) R is While* semicomputable if, and only if, it is the halting set of some While procedure P on A*. Again, we may assume that P has no output variables. (See Remark 5.3.) From Proposition 3.45 we have: Proposition 5.38. On A*, While* semicomputability coincides with While semicomputability. Theorem 5.39 (Closure of While* semicomputability under union and intersection). The union and intersection of two While* semicomputable relations of the same type are again While* semicomputable, uniformly over StdAlg(S). Proof. From Theorem 5.8, applied to A*
I
Theorem 5.40 (Post's theorem for While* semicomputability). For any relation R on A R is While* computable both R and Rc are While* semicomputable, uniformly for A &StdAlg(E). Proof. From Theorem 5.9, applied to A*.
I
Note that if A has the TEP, then the construction of a 'merged' WhileN procedure mg(Pi,P-2) from two WhileN procedures PI and P2, used in the above two theorems, is much simpler than the construction given in Lemma 5.6 (cf. Remark 5.7). Note that since A* has the TEP for all A €StdAlg(Z), there is a uniform construction of a 'merged' While* procedure mg(Pi,P2) from two While* procedures PX and P2, used in the above two theorems, which is much simpler than the construction given in Lemma 5.6 (cf. Remark 5.7). Also Theorem 5.10 (and 5.23) and Corollary 5.11 (and 5.24) can be restated for While* semicomputability: Theorem 5.41. Suppose R C Au*nat, where u e ProdType(£), and R is While* semicomputable on AN. Then its ^-projection {x \ 3n € N.R(o:,n)} is While* semicomputable on A. Corollary 5.42 (Closure of While* semicomputability under projections off minimal carriers). Let As be a minimal carrier of A, and let u€ProdType(£).
Computable functions on algebras
421
(a) If R C j4 uxs is While* semicomputable on A, then so is its projection {x € Au | 3y € As R(x, y)}. (b) If R C Auxs is While semicomputable on A*, then its projection {x € Au | By* 6 A* R(x,y*)} is While* semicomputable on A. Proof. In (b) we use the fact that if As is minimal in A, then ^4* is minimal in A*. (Exercise.) I Remark 5.43. Unlike the case with Corollaries 5.11 and 5.24, we do not have to assume the TEP here, since the term evaluation representing function is always While* computable. Example 5.44. The subalgebra relation is While* semicomputable on A. This follows from its WhileN semicomputability in term evaluation (Example 5.25(a)), and While* computability of the latter (Corollary 4.7.) The semicomputability equivalence theorem, which we prove later (Theorem 5.61), states that for algebras with the TEP, While* semicomputability coincides with WhileN semicomputability.
5.8 Projective While* semicomputability Let R be a relation on A. Definition 5.45. (a) R is projectively While* computable on A if R is a projection of a WhileCS,*) computable relation on A*. (b) R is projectively While* semicomputable on A if R is a projection of a While("S*) semicomputable relation on A*. Proposition 5.14 (or 5.27) can be restated for While* semicomputability: Proposition 5.46. Suppose A is a minimal. Then on A projective While* semicomputability = While* semicomputability. Note again that the TEP does not have to be assumed here (cf. Remark 5.43). Also we are using the fact that if A is minimal then so is A*. Definition 5.47. R is While* semicomputable with search on A if R is the halting set of a While(E*) search procedure on A*. Note that the W/iiZe(S*) search procedure in this definition has simple input variables. However the auxiliary, search and output variables may be simple, nat or starred. Again, we have (cf. Theorems 5.18 and 5.29): Theorem 5.48.
(a) R is While* semicomputable with search on A <=>• R is projectively While* semicomputable on A. (b) This equivalence is uniform over StdAlg(E).
422
J. V. Tucker and J. I. Zucker
Example 5.49. In J\f, the various concepts we have listed—While, WhileN and While* semicomputability, as well as projective While, WhileN and While* semicomputability—all reduce to recursive enumerability over N (cf. 5.5(o)). In general, however, projective While* semicomputability is strictly stronger than projective While or WhileN semicomputability. In other words, projecting along starred sorts is stronger than projecting along simple sorts or nat. (Intuitively, this corresponds to existentially quantifying over a finite, but unbounded, sequence of elements.) An example to show this will be given in section 6.4. We do, however, have the following equivalence: projective While* semicomputability = projective For* computability. This is the projective equivalence theorem, which will be proved in section 5.14. Projective While* semicomputability is the model of specifiability which will be the basis for a second generalised Church-Turing thesis (section 8.9).
5.9
Homomorphism invariance for semicomputable sets
For a S-homomorphism cj>: A —> B and a relation R : u on A, we write =df
{
which is a relation of type u on B. Theorem 5.50 (Epimorphism invariance for halting sets). For any 'S-epimorphism 0 : A —> B, <j)[HaltA(P)\ = HaltB(P). Proof. From Theorem 3.24.
I
Notice that the above result holds for a given procedure P, and any epimorphism
(a) If R is protectively While semicomputable on A, then for any Eautomorphism 4> of A, (f>[R] = R. (b) Similarly for protectively While* semicomputable sets.
Computable functions on algebras
423
Example 5.53. In the algebra C~ of complex numbers (Example 2.23(e) without the constant i, the singleton set {i} is not While semicomputable, or even projectively While* semicomputable. This is because there is an automorphism of C~ with itself which maps i to —i. However the set {—i,i} is While semicomputable, and in fact computable, in C~, by the procedure proc in x:complex out b:bool begin b:= xxx= -1 end.
5.10
The computation tree of a While statement
We will define, for any While statement S over S, and any tuple of distinct program variables x = x i , . . . , xn of type u = s\ x ... x sn such that var(S) C x, the computation tree T[S, x], which is like an 'unfolded flow chart' of 5. The root of the tree T[S,x] is labelled 's' (for 'start'), and the leaves are labelled 'e' (for 'end'). The internal nodes are labelled with assignment statements and Boolean tests. Furthermore, each edge of T[S, x] is labeled with a syntactic state, i.e., a tuple of terms t : u, where t = ti,... , £„, with ti 6 TermKiSi. Intuitively, t gives the current state, assuming execution of 5 starts in the initial state (represented by) x. In the course of the following definition we will make use of the restricted tree T~[S, x], which is just T[S, x] without the 's' node. We also use the notation T[S, t} for the tree formed from T[S, x] by replacing all edge labels t' by t'(x./t}. The definition is by structural induction on S. (i) S= skip. Then T[5,x] is as in Fig. 1.
0
©
Fig. 1. (ii) S = y := r, where y = y x , . . . , ym and r = n , . . . , rm, with each y; in x. Then T[S,x] is as in Fig. 2, where t = ti,... ,tn is defined by: ( ., _ I TJ if ~x.i=jj rtor some j I x,otherwise.
424
J. V. Tucker and J. I. Zucker
Fig. 2. (m) T = Si;S2- Then T[S,x] is formed from T[Si,x] by replacing each leaf (Fig. 3) by the tree in Fig. 4.
' t
©
Fig. 3.
Fig. 4. (iv) S = if b then Si else S2 fi. Then T[S, x] is as in Fig. 5. (u) S = while b do Si od. For the sake of this case, we temporarily adjoin another kind of leaf to our tree formalism, labelled '!' (for 'incomplete computation'), in addition to the e-leaf (representing an end to the computation). Then T[S, x] is defined as the 'limit' of the sequence of trees Tn, where TO is as in Fig. 6, and Tn+i is formed from Tn by replacing each i-leaf (Fig. 7) by the tree in Fig. 8, where T-,~[Si,t] is formed from 7~~[Si,i] by replacing all e-leaves in the latter by i-leaves. Note that the Boolean test b shown in Fig. 8 is evaluated at the 'current syntactic state't (which amounts to evaluating b(x/t) at 'the initial state' x). Note also that the 'limiting tree' T[S, x] does not contain any i-leaves. (Exercise.)
Computable functions on algebras
425
Fig. 5.
0 © Fig. 6.
Remark 5.54. (a) In case (i>) the sequence 7^(5, x] is defined by primitive recursion on n. An equivalent definition by tail recursion is possible (Exercise; compare the two definitions of CompA(S,(r,n) in sections 3.4 and 3.14; see also Remark 3.5). (6) The construction of T[S, x] is effective in S and x. More precisely: T[S, x] can be coded as a recursive set of numbers, with index primExample 5.55. Let S = while x > 0 d o x := x — 1 od, where x is a natural number variable. Then (in the notation of case (u)) TO, 71 and ?2 are, respectively, as shown in Figs. 9, 10 and 11, and T[S, x] is the infinite tree shown in Fig. 12. Notice that each tree in the sequence of approximations is obtained from the previous tree by replacing each i-leaf by one more iteration of the 'while' loop.
5.11
Engeler's lemma
Using the computation tree for a While statement constructed in the previous subsection, we will prove an important structure theorem for While semicomputabilty due to Engeler [l968a]. One of the consequences of this result will be the semicomputability equivalence thorem (5.61).
426
J. V. Tucker and J. I. Zucker
& Fig. 7.
Fig. 8. For each leaf A of the computation tree T[S, x], there is a Boolean bs,x, with variables among x, which expresses the conjunction of results of all the successive tests, that (the current values of) the variables x must satisfy in order for the computation to 'follow' the finite path from the root s to A. Consider, for example, a test node in T[5, x]: If the path goes to the right here (say), then it contributes to bg,\ the conjunct ... A --6(x/t) A ... Next, let (AQ, AI, A a , . . . ) be some effective enumeration of leaves of T[S, x] (e.g., in increasing depth, and, at a given depth, from left to right). Then, writing bs,k= bs,\k, we can express the halting formula for S as the countable disjunction
halts =df \/ bs,k
(5.3)
which expresses the conditions under which execution of S eventually halts, if started in the initial state (represented by) x.
Computable functions on algebras
427
Fig. 9.
Fig. 10.
Note that although the Booleans b$,k, and (hence) the formula halts, are constructed from a computation tree T[S, x] for some tuple x containing var(S), their construction is independent of the choice of x. Remark 5.56. (a) The Booleans b$,k are effective in 5 and k. More precisely, rbs,k~* is partial recursive in rSn and k. (b) Further, by a standard technique of classical recursion theory, for a fixed S, if T[S, x] has at least one leaf, then the enumeration
bs,o,bs,i,bs,z, •• • can be constructed (with repetitions) so that b$,k is a total function of k, and, in fact, primitive recursive in k. Now consider a relational procedure P = proc in a aux c begin 5 end
428
J. V. Tucker and J. I. Zucker
Fig. 11. with input variables a : u and auxiliary variables c : w. Then S = Sinit',S', where Smu is an initialisation of the auxiliary variables c to the default tuple Sw. The computation tree for P is defined to be
T(P)
=df
with a corresponding halting formula
halts, = V (cf. (5.3)). Now, for k = 0, 1, . . . , let bk be the Boolean which results from substituting Sw for c in bs',k- Note that var(bk) C a. Let ft*[a] € 1 be the evaluation of bk when a € Au is assigned to a. Then by (5.4), the halting set of P (5.1) is characterised as an effective countable disjunction
a € HaltA(P) <=^ \f bk[a]
(5.5)
k=Q
for all a € Au. Now suppose R is a While semicomputable relation on A. That means, by definition, that R =HaltA(P)for a suitable While procedure P. Hence, by (5.5), we immediately derive the following theorem
Computable functions on algebras
429
Fig. 12. due to Engeler [I968a]: Theorem 5.57 (Engeler's lemma). Let R be a While semicomputable relation on a standard H-structure A. Then R can be expressed as an effective countable disjunction of Booleans over £. Actually, we need a stronger version of Engeler's lemma, applied to While* programs, which we will derive next.
5.12
Engeler's lemma for While* semicomputability
We will use the results of the previous subsection, applied to While* computation, together with the £*/£ conservativity theorem for terms (Theorem 3.63), to prove a strengthened version of Engeler's lemma.
430
J. V. Tucker and J. I. Zucker
Fig. 13.
Theorem 5.58 (Engeler's lemma for While* semicomputability). Let R be a While* semicomputable relation on a standard ^-structure A. Then R can be expressed as an effective countable disjunction of Booleans over E. Proof. Suppose R has type u (over S). By assumption, R is the halting set HaltA(P] for a While* procedure P. By (5.5) of the previous subsection,
R(a) <=> V bk[a]
(5.6)
for all a e Au, where (now) bk £ Term* bool, i.e., the Booleans bk, though not of starred sort, may contain subterms of starred sort — for example, they may be equations or inequalities between terms of starred sort. As before, bk[a] is the evaluation of 6fc when a € Au is assigned to a. Now for any Boolean 6 €Term* bool , let b' be the Boolean in Terma,booi associated with b by the conservativity theorem (3.63). Then from (5.6), for all a 6 Au,
R(a) <=» \/ bfk(a}. k=o
(5.7)
Because the disjunction in (5.6) and the transformation b >-> b' are both effective, the disjunction in (5.7) is also effective. I For the converse direction: Lemma 5.59. Let R be a relation on a standard ^-algebra A. If R can be expressed as an effective countable disjunction of Booleans over E, then R is While* semicomputable. Proof. Suppose R is expressed by an effective disjunction oo \/bk[a} k=0
Computable functions on algebras
431
for all a 6 Au, where bk € Term^ot>\. Then for all a e Au, R(a) <=> 3k (te^ooi (V, a) =
tt)
(5.8)
where rb^ is (total) recursive in k. Hence, by Corollary 4.7, Remark 3.16 and Theorem 5.41, R is While* semicomputable. I Combining Engeler's lemma for While* semicomputability with this lemma gives the following 'structural' characterisation of While* semicomputable relations. Corollary 5.60. Let R be a relation on a standard Y,-algebra. Then R can be expressed as an effective countable disjunction of Booleans over £ if, and only if, R is While* semicomputable. If, moreover, A has the TEP, then we can say more: Theorem 5.61 (Semicomputability equivalence theorem). Suppose that A is a standard Y,-algebra with the TEP, and that R is a relation on A. Then the following assertions are equivalent: (i) R is WhileN semicomputable on A; (ii) R is While* semicomputable on A; (Hi) R can be expressed as an effective countable disjunction of Booleans over T,. Proof. The step (i) =$• (ii) is trivial, and (ii) =£• (Hi) is just Engeler's lemma for While*. The new step here ((in) =*• (i)) follows from (5.8) and Theorem 5.23. I Corollary 5.62. Suppose that A is a standard ^-algebra with the TEP, and that R is a relation on A. Then R is WhileN computable on A
<=$> R is While* computable on A.
Proof. From Theorem 5.61, or from Corollary 4.18.
5.13
I
SJ definability: Input/output and halting formulae
For any standard signature £, let Lang*= Lang(£*)be the first-order language with equality over E*. The atomic formulae of Lang*aie equalities between pairs of terms of the same sort, for any sort of £*, i.e., sort s, su and a*, for all sorts s of E (whether equality sorts or not), and for the sort nat. Formulae of Lang* are formed from the atomic formulae by means of the prepositional connectives and universal and existential quantification over variables of any sort of S*. We are more interested in special classes of formulae of Lang*.
432
J. V. Tucker and J. I. Zucker
Definition 5.63 (Classes of formulae of Lang*). (a) A bounded quantifier has the form 'Vfc < V or '3k < f , where t : nat. (b) An elementary formula is one with only bounded quantifiers. (c) A EJ formula is formed by prefixing an elementary formula with existential quantifiers only. (d) An extended EJ formula is formed by prefixing an elementary formula with a string of existential quantifiers and bounded universal quantifiers (in any order). Proposition 5.64. For any extended E* formula P, there is a E* formula Q which is equivalent to P over S, in the sense that Proof. The construction of Q from the P is given in Tucker and Zucker [1993]. (In that paper, the equivalence is actually shown relative to a formal system over K with EJ induction. However, we are not concerned with issues of provability in this chapter.) I Because of this result, we will use the term 'SJ' to denote (possibly) extended EJ formulae. Proposition 5.65. If P is an elementary formula all of whose variables are of equality sort, then the predicate defined by P is For* computable. Proof. By structural induction on P. Equations between variables of equality sort, and Boolean operations, are trivially computable. Bounded quantification uses the 'for' loop. I In general, formulae over the structure A* (or rather, over the signature £*) may have simple, augmented, starred or nat variables (Definition 3.39). We are interested in formulae with the property that all free variables are simple, since such formulae define relations on A. For such formulae, all bound augmented variables may be replaced by bound simple variables, by the effective coding of ^4" in A (see Remark 2.30(c)). Theorem 5.66 (The ££ i/o formula for a procedure). Given a While* procedure P : u ->• v P = proc in a out b aux c* begin 5 end
(5-9)
where a : u, b : v and c* : w* , we can effectively construct a E* formula IOp = 7Op(a, b), with free variables among a,b, called the input/output (or i/o) formula for P, which satisfies: for all A €StdAlg(£i), a € Au and be Av, A \= IOp [a, b] <=^ PA(a) \. b. Note: The left-hand side means that A satisfies IOp at any state which assigns a to a and b to b.
Computable functions on algebras
433
Proof. First we construct an elementary formula CompMs(x,y,z*) (where var(S)C x), as in Tucker and Zucker [1988, §2.6.11], by structural induction on S, with the meaning: 'z* represents a computation sequence generated by statement S, starting in a state in which all the variables of S have values (represented by) x, and ending in a state in which these variables have value y'. From this it is easy to construct a E* formula Compup(&, b, z*) with the meaning: 'z* represents a computation sequence generated by procedure P, starting in a state in which the input variables have values (represented by) a, and ending in a state in which the output variables have values b'. Finally we obtain the SJ i/o formula IOp(a,b) =df 3z* Corap«p(a, b, z*) as required. I Remark 5.67 (Quantification over N sufficient). We can construct a EJ i/o formula in which there is only existential quantification over N. Briefly, a formula similar to Compus (in the above proof) is constructed in which the variable z* representing the computation sequence is replaced by a Godel number. (Cf. point (2°) in section 4.8, concerning the replacement of the function comp^ by compu^.) Remark 5.68 (Alternative construction of/Op). Let a be the p,PR* scheme (section 8.1) which corresponds to P according to the construction given by the proof of Theorem 8.5(d). By structural induction on a, we construct the formula IOa(= IOp), as in Tucker et al. [1990] or Tucker and Zucker [1993, §5] (where it is called P0). Corollary 5.69 (The S* halting formula for a procedure). Given a While* procedure P : u -» v as in (5.9), we can construct a E| definition for the halting formula haltp = haltp(ei) for P. Proof. We define haltP(a) = 3bIO P (a,b) Alternatively, recalling (Remark 5.3) that in the context of semicomputability we may assume that P has no output variables, we can put, more simply, haltp (a) = IOp (a). Since IOp is EJ, so is haltp (in either case). I Remark 5.70 (Quantification over N sufficient). Again, by the use of Godel numbers, we can construct a EJ halting formula in which there is only existential quantification over N. (Cf. Remark 5.67.) Note finally that by Corollary 5.69, since for all A eStdAlg(E) and all a<=Au,
434
J. V. Tucker and J. I. Zucker a&HaltA(P) <^=> A \= haltP(a),
it follows that the halting set for While* procedures is SJ definable, uniformly over StdAlg(X).
5.14
The projective equivalence theorem
Theorem 5.71. Let R be a relation on a standard S-algebra A. Then R is protectively While* semicomputable <=>• R is projectively For* computable. We present two proofs of this theorem. The first uses S* definability of the halting set (and the assumption that S has equality at all sorts) while the second uses Engeler's lemma (without any assumption about equality sorts). First proof. First we restate the theorem suitably. Suppose E has an equality operator at all sorts. Let R be a relation on A. Then the following are equivalent: (i) R is projectively While* semicomputable; (U) R is EJ definable; (Hi) R is projectively For* computable. (i)=>(ii'):
Suppose R : u, and for all a; € Au, R(x)^=*3y* € AvtR!(x,y')
(5.10)
where v* is a product type of £*, and RI : u x v* is While semicomputable on A*. Then RI is the halting set of a While(£*) procedure P on A*. By Corollary 5.69, RI is £J definable on A", say fl!(a:,y*)<=>.3«« 6 A""B<>(x,y',z"),
(5.11)
where w** is a product type of £**, and RQ(. ..) is given by an elementary formula over S**. Combining (5.10) and (5.11): R(x)^3y* £ Av'3z** 6 Aw"Ro(x,y*,z*f).
(5.12)
Finally, by the coding of (A*)* in A* (Remark 2.31(d)), we can rewrite the existential quantification over (A*)* in ('5.12) ('Bz** € /I™**') as existential quantification over A*, yielding a SJ definition of R on A. (ii):=>(m): Suppose J? is defined by the formula 3z*P(x,z*), where z* is a tuple of starred and unstarred variables, and P is elementary. Then R is a projection of P, which, by Proposition 5.65, is For* computable. (Here we use the assumption about equality sorts.)
Computable functions on algebras
435
); Trivial (using Proposition 3.34). • Second proof. (Here we make no assumption about equality sorts.) Suppose R : u is projectively While* semicomputable on A. Then (as before) for some product type v* of £*, R(x) <=» 3y* € Av" ' Rfay*) where RI : u x v* is While semicomputable on A* . By Engeler's lemma (Theorem 5.57) applied to A", there is an effective sequence 6fc*(x,y*) (k = 0, 1,2, . . .) of Booleans over E* such that Ri(x,y*) is equivalent over A to the disjunction of bk*[x,y*]. Further, by Remark 5.56(6), this sequence can be denned so that r 6fc* n is primitive recursive in k. (Assume here that R is non-empty, otherwise the theorem is trivial.) Then Ri(x,V*) «=» for some fc, te^*,ibool(rb*;*"1,x,2/*) = tt. Further, te^ . bool is For computable on A* (by Proposition 4.6). Hence the function g defined on A* by g ( k , x , y * ) =4
te£. ibool W,
*,»*)
is For computable on A* (by Equation 3.8 and Remark 3.16). Hence the relation Ro(k,x,y*)
5.15
•
Halting sets of While procedures with random assignments
We now consider the While programming language over S, extended by the random assignment x:=? for variables x of every sort of E. This is an example of non-deterministic computation. The semantics of the While-random programming language can be obtained by a modification of the semantics of the While language given in section 3, by taking the meaning of a statement 5 to be a function [S] from states to sets of states. In the case that 5 is a random assignment x := ?, [S]Acr is the set of all states which agree with a on all variables except x.
436
J. V. Tucker and J. I. Zucker
However we are only interested here in the While-random language for defining relations, not functions, as the following definition clarifies. Definition 5.72. Let P be a While-random procedure, with input variables a : u (and, we may assume, no output variables). The halting set of P on A is the set of tuples a £ A" such that when a is initialised to a, then for some values of the random assignments, execution of P halts. Definition 5.73. Let R be a relation on A. (a) R is While-random semicomputable on A if R is the halting set of a W/iife-random procedure on A. (6) R is While"-random semicomputable on A if R is the halting set of a W/iiie(S*)-random procedure on A*. Note that in (6), there could be random assignments to starred (auxiliary) variables. Remark 5.74. Clearly, semicomputability with random assignments can be viewed as a generalisation of the notion of semicomputability with search, i.e., initialisation of search variables (section 5.3), since initialisation amounts to random assignments at the beginning of the program. We may ask how these two notions of semicomputability compare. We will show that, at least over A*, they coincide: both are equivalent to projective While* semicomputability. Theorem 5.75. Let R be a relation on A. Then R is While*-random semicomputable <=>• R is protectively While* semicomputable. Proof. The direction (4=) follows from Remark 5.74 and Theorem 5.18. We turn to the direction (=>). For ease of exposition, we will assume first that R is While-random semicomputable. We will define a computation tree 7~[S, x] for W/ii/e-random statements S with varS C x = xi,... ,x ra , extending the definition for While statements given in Section 5.10. There is one new case: (uz) S = Xi := ?. Then T[S,x] is as in Fig. 14. So Xj is replaced by a new variable xj of the same sort. Notice that for a '?'-assignment S, and for terms t = ti,... ,tn, the tree T[S, t] is asn in Fig. 15. where xj does not occur in x or t. The intuition here is that there is nothing we can say about the 'new' value of Xj, so we can only represent it by a brand new variable x'4. If this assignment is followed by another assignment Xj := ?, we introduce another new variable x", and so on. In this way the variables proliferate, and the tree contains (possibly) infinitely many variables. Hence we cannot simply construct a halting formula as an (infinite) disjunction of Booleans in a fixed finite number of variables over E, as we did in section 5.11.
Computable functions on algebras
437
•— —?
©
Fig. 14.
' t
Fig. 15. The solution is to represent all the variables x j, xj, x",. • • which arise in this way for each i ( l < j < n ) b y a single starred variable x* (with x*[0],x*[l],x*[2],... representing X j , x ^ , x " , . . . ) . Then to each leaf A of T[S, x] there corresponds (as in section 5.11) a Boolean b$,\, but now in the starred variables x*=xj,... , xj^. Again, as in section 5.11, we can define the halting formula for 5 as a countable disjunction of Booleans:
halts =df \J k=0
where the 6s,fc are effective, in fact primitive recursive, in S and k. Note however that the program variables in halts are now among x*, not x. Now suppose that the relation R : u is the halting set of a While-
438
J. V. Tucker and J. I. Zucker
random procedure on A, P = proc in a aux c begin Sjn«;S' end where a : u = «i x ... x sm and c : w. As in section 5.11, let 6* be the Boolean which results from substituting the default tuple Sw for c in bs',k- Note that war(6/t)C a, c* : u xw*. Then for all a € Au:
a 6 R <^> 3c* € Aw 3k
£.ibooir&*-', 0) c*) = tt
(cf. (5.8) in section 5.12) which (by Proposition 4.6) is projectively For" computable on A, and hence projectively While* semicomputable on A. This proves the theorem for the case that R is W/iiie-random semicomputable on A. Assume, finally, that R is W/izZe*-random semicomputable, i.e., the procedure for R may contain starred auxiliary variables, and there may be random assignments to these. Now we can represent a sequence of random assignments to a starred variable by a single doubly starred variable, or two-dimensional array, which can then be effectively coded in A* (Remark 2.31(d)), and proceed as before. •
6
Examples of semicomputable sets of real and complex numbers
In this section we look at the various notions of semicomputability in the case of algebras based on the set E of real numbers and the set C of complex numbers. By doing so, we will find examples proving the inequivalence of the following notions: (i) (ii) (Hi) (iv)
While computability; While semicomputability; projective While semicomputability; projective While* semicomputability.
We will also find interesting examples of sets of real and complex numbers which are semicomputable but not computable. Some of these sets belong to dynamical system theory: orbits and periodic sets of chaotic systems turn out to be semicomputable but not computable. Finally we will also reconsider an example of a semicomputable, noncomputable set of complex numbers described in Blum et al. [1989]. The effective content of their work can be obtained from the general theory. Our main tool will be Engeler's lemma. We will concentrate on the following algebras introduced in Example 2.23: the standard algebras
Computable functions on algebras
439
U = (B; M; 0, 1, +, -, x,if rea i,eq re ai) of reals, and C = (71;C; 0, 1,»,+, -, x, re, im, TT) of complex numbers, and their expansions K< = (K; lessreai)
and
C< = (C;lessreal)
formed by adjoining the order relation on the reals lessreai: M2 ->• B (which we will write as infix '<')- We will show that: (a) the order relation on E is projectively While semicomputable, but not While semicomputable, on 7£; and (6) a certain real closed subfield of M is projectively While* semicomputable, but not projectively While semicomputable, on 'R<.
6.1
Computability on R and C
Based on the general theory of computability developed so far, we can see that each of these four algebras has a computability theory with several standard properties (e.g., universality, section 4.9). First, we will list some preliminary results for computability on the real and complex numbers that will entail simplicity and elegance of computation on these structures, but will also show that the analogy with the classical case of computation on N often breaks down. To begin with, we have: Proposition 6.1. For A = H,^,C or C<, WhileN(A) = While(A).
(6.1)
This is proved essentially by simulating the algebra^, i.e., the carrier N, with zero, successor, etc., in the carrier M, using the non-negative integers together with 0, the operation +1, etc. As an exercise, the reader should formulate a theorem expressing a sufficient condition on an algebra A for (6.1) to hold, from which the above proposition will follow as a simple corollary. This situation should be contrasted with that in Example 5.36. Recall Definition 4.4 and Examples 4.5: Lemma 6.2 (TEP). The algebras 7^,7^ < ,C andC< all have the TEP. The TEP has a profound impact on the computability theory for an algebra. For example, from Corollary 4.18 we know that on Ti,Ti<,C and C<: While" computability = WhileN computability and hence (or from the semicomputability equivalence theorem (5.61)) While* semicomputability = WhileN semicomputability
440
J. V. Tucker and J. I. Zucker
for these four algebras. We will give more detailed formulations of these facts for each of these algebras shortly. Example 6.3 (Non-computable functions). Recall Theorem 3.66 which says that the output of a While, WhileN or While* computable function is contained in the subalgebra generated by its inputs. From this we can derive some negative computability results for these algebras: (a) The square root function is not While* computable on TL or 7^<. This follows from the fact that the subset of R generated from the empty set by the constants and operations of ~R or 'R.< is the set Z of integers. But \/2 is not in this set. (For computability in ordered Euclidean fields incorporating the square root operation, see Engeler [I975a]). (b) The mod function (z <-> |z|) is not While* computable on C or C<. This follows from the fact that the subset of R generated from the empty set by the constants and operations of C or C< is again Z. But again, |1 + i\ = V2 is not in this set. (c) The mod function would be computable in C if we adjoined the square root function to the algebra "R, (as a reduct of C). In the rest of this subsection, we will apply Engeler's lemma for While* semicomputability (section 5.12) to the algebras K,K<,C and C<. From the semicomputability equivalence theorem (5.61) (which follows from Engeler's lemma) and from the TEP lemma (6.2), we get: Theorem 6.4 (Semicomputability equivalences for Tl,'R,<,C,C<), Suppose A is Tl or U<, and R C R"; or A is C or C<, and R C C". Then the following are equivalent: (i) R is WhileN semicomputable on A; (ii) R is While* semicomputable on A; (Hi) R can be expressed as an effective countable disjunction of Booleans over A. For applications of this theorem, we need the following normal form lemmas for Booleans over K and 7?.<. Lemma 6.5 (Normal form for Booleans over 7?.). A Boolean over 71, with variables x = xi,... ,xn of sort real only, is effectively equivalent over H. to a finite disjunction of finite conjunctions of equations and negations of equations of the form p(x) = 0
and
q(x) ^ 0,
where p and q are polynomials in x with coefficients in Z. Lemma 6.6 (Normal form for Booleans over Tl<). A Boolean over Ti<, with variables x — x\,... ,xn of sort real only, is effectively equivalent over Tl< to a finite disjunction of finite conjunctions of equations and
Computable functions on algebras
441
inequalities of the form
p(x) = 0
and
q(x) > 0,
where p and q are polynomials in x with coefficients The proofs of these are left as exercises.
6.2
in Z .
The algebra of reals; a set which is projectively While semicomputable but not While* semicomputable
In this subsection we obtain results distinguishing various notions of semicomputability, using the algebra 71 of reals. In the next subsection we will obtain other results in a similar vein, using the ordered algebra ?£< of reals. We begin with a restatement of the semicomputability equivalence thorem (6.4) for the particular case of 71. Theorem 6.7 (Semicomputability for 71). Suppose R C E n . Then the following are equivalent: (i) R is WhileN semicomputable on 71; (ii) R is While* semicomputable on 71; (Hi) R can be expressed as an effective countable disjunction
i(x)
(6.2)
where each bi(x) is a finite conjunction of equations and negations of equations of the form
p(x) = 0
and
q(x) ± 0,
(6.3)
where p and q are polynomials in x = (x\ ,..., xn) € Kn , with coefficients in 1. Proof. From Theorem 6.4 and Lemma 6.5.
I
Thus we see that there is an intimate connection between computability, polynomials and algebraic field extensions on BL Definition 6.8 (Algebraic and transcendental points). Let us define a point a = (ai ,..., an) 6 En to be (i) algebraic if it is the root of a polynomial in n variables with coefficients in Z; and (ii) transcendental if it is not algebraic, or, equivalently, if for each i = 1, . . . , n, aj is transcendental (in the usual sense) over Q(ai, . . . ,a«-i). The following corollary was stated for n = 1 in Herman and Isard [1970].
442
J. V. Tucker and J. I. Zucker
Corollary 6.9. IfRCW1 is While* semicomputable on "R, and contains a transcendental point a, then R contains some open neighbourhood of a. Proof. In the notation of (6.2): a satisfies bt(x) for some i. Then (for this i) bi(x) cannot contain any equations (as in (6.3)) since a is transcendental, and so it must contain negations of equations only. The result follows from the continuity of polynomial functions. I An immediate consequence of this is: Corollary 6.10 (Density/codensity condition). Any subset ofW1 which is both dense and co-dense in W1 (or in any non-empty open subset ofW1) cannot be While* computable on 7J. Example 6.11. The following subsets of Mn are easily seen to be WhileN semicomputable on 72. — in fact While semicomputable (by Proposition 6.1). However, they are not While (= WhileN= While*) computable, by the density/codensity condition: (a) the set of points with rational coordinates; (b) the set of points with algebraic coordinates; (c) the set of algebraic points. Of course, a standard example of a While semicomputable but not While* computable set can be found in .A/*, namely any recursively enumerable, non-recursive set of naturals (Example 5.49). Next, specialising to n = 1: Corollary 6.12 (Countability/cofiniteness condition). If R C R is While* semicomputable on ~R, then R is either countable or cofinite (i.e., the complement of a fine set) in M. Proof. By the fundamental theorem of algebra, each polynomial equation with coefficients in Z has at most finitely many roots in R. Hence, regarding the disjunction in (6.2), there are two cases: Case 1. For some i, bi(x) contains only negations of equations. Then (for this i) bi(x) holds for all but finitely many x € M. Hence R is co-finite in R. Case 2. For all i, bi(x) contains at least one equation. Then (for all i) bi(x) holds for at most finitely many a; € E. Hence R is countable. I Hence we have: Corollary 6.13. A subset ofR which is (While or WhileNor While*) computable on Ti it is either finite or cofinite. Example 6.14. From Corollary 6.13 we have another example of a subset of R which is While semicomputable but not While* computable, namely the integers (Example 5.5(c)). Example 6.15 (Projectively While semicomputable, not While* semicomputable set). The order relation on K is a primitive operation
Computable functions on algebras
443
in 1i<, but, as we shall see, is not even semicomputable in K. Consider first the relation Ro(x,y) on K. RO is clearly While computable on K, and so its projection on the first argument, R =ds {x | 3y(x = y2)} i.e., the set {x \ x > 0} of all non-negative reals, is projectively While semicomputable. Prom the countability/cofiniteness condition (6.12) however, it is not (even While*) semicomputable on Ti. From this it is easy to see that the order relation x < y •<=>• (y — x) € R and x ^ y is also projectively While semicomputable, but not While" semicomputable, on 71.
6.3
The ordered algebra of reals; sets of reals which are While semicomputable but not While* computable
In the previous subsection we saw that the order relation on R is not (even) While* semicomputable on the algebra 7£. Let us add it now to K, to form the algebra K< , and see how this affects the computability theory. We begin again with a restatement of the semicomputability equivalence theorem (6.4), this time for the algebra Tl<. Theorem 6.16 (Semicomputability for 1l<). Suppose RCW1. Then the following are equivalent: (i) R is WhileN semicomputable on K< , (ii) R is While* semicomputable on 'R,< , (Hi) R can be expressed as an effective countable disjunction \fbi(x) where each bi (x) is a finite conjunction of equations and inequalities of the form p(x) = 0 and q(x) > 0, where p and q are polynomials in x = (x\,... , xn) €. E n , with coefficients in Z. Proof. From Theorem 6.4 and Lemma 6.5.
•
To proceed further, we need some definitions and lemmas about points and sets defined by polynomials. (Background information on algebraic geometry can be found, for example, in Shafarevich [1977] or Brocker and
444
J. V. Tucker and J. I. Zucker
Lander [1975, Chapter 12]. For the application below (section 6.4), we relativise our concepts to an arbitrary subset D of E. Definition 6.17.
(a) An interval in E (open, half-open or closed) is algebraic in D if, and only if, its end-points are. (b) A patch in E is a finite union of points and intervals. (c) A D-algebraic patch in E is a finite union of points and intervals algebraic in D. Definition 6.18. A set in En is D-semialgebraic if, and only if, it can be defined as a finite disjunction of finite conjunctions of equations and inequalities of the form
p(x) = 0
and
q(x) > 0,
where p and q are polynomials in x with coefficients in 1\D\. We will drop the '£>' when it denotes the empty set. Note that clause (Hi) of Theorem 6.16 can, by Definition 6.18, be written equivalently in the form: (in1) R can be expressed as an effective countable union of semialgebraic sets. Lemma 6.19. A semialgebraic set in E" has a finite number of connected components. (See Becker [1986]. This will be used in section 6.6.) It follows that a semialgebraic subset of E is a patch. However, for n = 1 we need a stronger result: Lemma 6.20. A subset of K is D-semialgebraic if, and only if, it is a D-algebraic patch. Lemma 6.21. A projection of a D-semialgebraic set in E™ on Em (m < n) is again D-semialgebraic. This follows from Tarski's quantifier-elimination theorem for real closed fields (see, for example, Kreisel and Krivine [1971, Chapter 4]). From this and Lemma 6.20: Corollary 6.22. A projection of a D-semialgebraic set in E" on E is a D-algebraic patch. Remark 6.23. Corollaries 6.9 and 6.10 (the density/codensity condition) hold for fa*- as well as fa, leading to the same examples (6.11) of subsets of E" which are WhileN semicomputable, but not WhileN (= While') computable, on fa*-. Another example is given below (6.26). The following corollary, however, points out a contrast with fa. Corollary 6.24. In fa<, the following three notions coincide for subsets ofR":
Computable functions on algebras
445
(i) WhileN semicomputability; (ii) While* semicomputability; (in) protective WhileN semicomputability. This follows from Theorem 6.16 and Lemma 6.21. (This corollary fails in the structure Tl, since in that structure, Lemma 6.21, depending on Tarski's quantifier-elimination theorem, does not hold.) However, the above three notions of semicomputability differ in 7^< from a fourth: (iv) protective While* semicomputability, as we will see in section 6.4. But first we need: Corollary 6.25 (Countable connectivity condition). (a) If R C K is While* semicomputable on 'R.<, then R consists of countably many connected components. (b) If R CM. is While* semicomputable on 'R.<, then either R is countable or R contains an interval. (This is a refinement of the countability/cofiniteness condition (6.12).) This follows from Theorem 6.16 and Lemma 6.19, since the connected subsets of K are precisely the singletons and the intervals. Example 6.26.
(a) The Cantor set in [0,1] is not While* semicomputable on 1i<, by the countable connectivity condition. (b) The complement of the Cantor set in [0,1] is While semicomputable on 7^< (Exercise), but (by (a)) it is not (even While*) computable on H<. Other interesting examples of semicomputable, non-computable sets are given in sections 6.5 and 6.6.
6.4
A set which is projectively While* semicomputable but not projectively WhileN semicomputable
First we must enrich the structure 72.<. Let E = {eo,61,62,...} be a sequence of reals such that for all i, ei is transcendental over Q(eo,... ,6j-i).
(6.4)
We define 7t
n<'E n< E j :E
446
J. V. Tucker and J. I. Zucker
We write E C M for the real algebraic closure of It is easy to see that E is projectively While* semicomputable in Ti<'E . (In fact, E is the projection on K of a While semicomputable relation on K x E*.) We will now show that, on the other hand, E is not projectively WhileN semicomputable in K<>E. Theorem 6.27. Let F C E be projectively WhileN semicomputable in -fc<,E Then F / E. Specifically, suppose for some While computable function
(6.5) (with existential quantification over all four sorts in "R,< where Fi = {x\ (By & Er)(3z e ITW.y,*)} and bi is a finite conjunction of equations and inequalities of the form p(x,y,z,)=Q
and
q(x,y,z)>Q
where p and q are polynomials in x,y,z with coefficients in Z. Proof. Apply Engeler's lemma. Also replace existential quantification over nat and bool by countable disjunctions. I Lemma 6.29. (In the notation of Lemma 6.28,) for any r-tuple e = (e^ , • •• >Zir) of elements of E, put Fi[e] =df {x | (3«
Then for all e € Er , Fi[e] is a (finite) set of points, all algebraic in e. Proof. Note that Fi[e] is a projection on R of an e-semialgebraic set in Ks+1 . Hence, by Corollary 6.22, it is an e-algebraic patch. Since by assumption Fi[e] CFCE, Fi[e] is countable, and hence cannot contain any (non-degenerate) interval. The result follows from the definition of e-algebraic patch. • Since F is the union of F<[e] over all i, and all r-tuples e from E, the theorem follows from Lemma 6.29 and the following:
Computable functions on algebras
447
Lemma 6.30. For all n, there exists a real which is algebraic over E but not over any subset of E of cardinality n. Proof. Take x = e0 + e\ + ... + en (more strictly, j(e0) + ... + j(en)). The result follows from the construction (6.4) of E. I We have shown that E (although a projection on R of a While semicomputable relation on Rx E*) is not a projection of a WhileN semicomputable relation in 7?.<>B'. In fact, we can see (still using Engeler's lemma) that E is not even a projection of a While" semicomputable relation on E" x Em (for any n,m > 0). Thus to define E, we must project off the starred sort E*, or (in other words) existentially quantify over a finite, but unbounded sequence of elements of E.
6.5
Dynamical systems and chaotic systems on R; sets which are WhileN semicomputable but not While* computable
We will examine algorithmic aspects of certain dynamical systems. Many physical, biological and computing systems are deterministic and share a common mathematical form. Consider a deterministic system (S, F) modelled by means of a set 5 of states, whose dynamical behaviour in discrete time is given by a system function F:TxS->S where T = N = {0,1,2,...} and for t € T and s € S, F(t, s) is the state of the system at time t given initial state s. The orbit of F at state s is the set
Orb(F,s) = {F(t,s) | t G T } . The set of periodic points of F is Per(F) = {s e S | 3* € T(F(M) = s)}. In modelling a dynamical system (S,F), the computability of the F and of sets such as the orbits and periodic points is of immediate interest and importance. Now suppose, more specifically, that the evolution of the system in time is determined by a next state function
f :S-> 5 through the equations F(0,s) F(t + l,s) which have the solution
= s = f(F(t,s))
448
J. V. Tucker and J. I. Zucker
F(t,s)=ft(s) for t € T and s £ S. We call such systems iterated maps. In this case, we write orb(f,s)
=
Orb(F,s)
=
{ f ( s ) \t £ T}
per(f)
=
Per(F)
=
{s € 5 | 3t > 0(F(t, a) = «)}.
Theorem 6.31. Let A be an N-standard algebra (with N = T), and containing the state space S. If the next state function f is While computable on A then so is the system function F. Furthermore, the orbits orb(f, s) and the set of periodic points per(f) are While semicomputable on A. Proof. By computability of primitive recursion (Theorem 8.5) and closure of semicomputability under existential quantification over N (Theorem 5.23). I Now we will consider the computability of some simple dynamical systems with one-dimensional state spaces. More specifically, suppose the state space is an interval
S = I = [a,b] C R and so the next state function and system function have the form /:/->/ F: T x 7 -»• 7. F is called an iterated map on the interval I. Dynamical systems based on such maps have a wide range of uses and a beautiful theory. For example, such systems will under certain circumstances exhibit 'chaos'. The following discussion is taken from Devaney [1989]. Let (I,F) be a dynamical system based on the iterated map F. Definition 6.32. (o) (/, F) is sensitive to initial conditions if there exists 6 > 0 such that for all x 6 I and any neighbourhood U of x, there exist y € U and t€T such that }F(t,x)-F(t,y)\>6. (b) (I, F) is topologically transitive if for any open sets U\ and C/a there exist x £ Ui and t € T such that F(t,x) € C/2Note that if J is compact then (/, F) is topologically transitive if, and only if, Orb(F,x) is dense in / for some x € I. (The direction '«=' is clear. The proof of '=>' depends on the Baire category theorem.)
Computable functions on algebras
449
Definition 6.33. The system (/, F) is chaotic if: (a) it is sensitive to initial conditions; (b) it is topologically transitive; (c) the set Per(F) of periodic points of F is dense in /. Consider the quadratic family of dynamical systems ( I , F ^ ) for // real, where / = [0,1] and the next state function is / M (z) = nx(l-x). For n = 4 we have: Theorem 6.34. The system (I, F4) is chaotic. Thus, for the algebras'R and 7l< ; (a) for some x £ [0,1], tfte set Orb(F±,x) is WhileN semicomputable but not WhileN (= While*) computable; (b) the set Per(F) is WhileN semicomputable, but not WhileN (— While*) computable. Proof. That (/, F^) is chaotic is proved in Devaney [1989]. The semicomputability of /4 is clear. Semicomputability of Orb(F±,x) and Per(F) follows from Theorem 6.31. Further, it can be shown that Orb(F^,x) and Per(F) are both dense and codense in /. (Exercise.) Non-computability then follows from the density/codensity condition (see Remark 6.23). I
6.6
Dynamical systems and Julia sets on C; sets which are WhileN semicomputable but not While* computable
We reconsider an example from Blum et al. [1989], and show how it follows from our general theory of Semicomputability. We work from now on in C<. First, we must relate computability in the complex and real algebras. We consider the algebras C and C<. Notation 6.35. If 5 C C", we write S =df
{{m(zi),\m(zi),...,n(zn),\m(zn))\(z1,...,zn)€C1}
C M 2n .
Lemma 6.36 (Reduction lemma). Let S C Cn .
(a) S is While (or WhileN or While*) semicomputable in C if, and only if, S is While (or WhileN or While*) semicomputable in 7£. (b) S is While (or WhileN or While*) semicomputable in C< if, and only if, S is While (or WhileN or While*) semicomputable in-R<. This lemma will enable us to reduce problems of Semicomputability in the algebras C or C< to those in the corresponding real algebras. For example, from this lemma and Corollary 6.24 we have:
450
J. V. Tucker and J. I. Zucker
Corollary 6.37. InC**, the notions ofWhileN, While* and protective WhileN semicornputability all coincide for subsets of C". Note that the reduction lemma would not be true if we included the mod function (z i-> |z|) in C or C*-, by Example 6.3(6). We work from now on in C<. Let g : C -> C be a function. For z 6 C, the orbit of g at z (as in section 6.5) is the set orb(g,z) = {<7 n (z)|n = 0,l,2,...}. Let
U(g) = {z € C | orb(g, z) is unbounded} and
=iz e C | orb(g,z) is bounded}
The set F(g) is the filled Julia set of g; the boundary J(g) of F(g) is the Julia set of g. For any r € R define Vr(d) — {-2 € C | 3n(|<7n(,z)| > r)}. Clearly, U(g) C Fr(g) for all r. Theorem 6.38. For g(z) — z2 - c, with \c\ > 4, we have U(g) is While semicomputable but not (even While*) computable. Thus, F(g) is not While* semicomputable. Proof. Assume for now that |c| > 1, and choose r = 2|c|. Then for \z\ > r, \g(z)\ = \z*-c\ > \zf-\c\
> \\z\.
Hence for all n, /3 N n and so
gn(z) -> oo as n ->• oo.
Hence for such r, Vr(g) C U(g), and so V(g) = Vr(g) = {z€C\ 3n(\gn(z)\ > r)}. To show that U(g) is semicomputable is routine; for example, as the halting set of the procedure
Computable functions on algebras
451
proc in a: complex aux b: complex begin b:=a;
while | b | 2 < 4|c|2 do b := b2 - c od end.
(Note that although the function z (->• \z\ is not computable, the function z )->• \z\2 = re(z)2 + im(z) 2 is.) To conclude the proof we must show that F(g) is not While* semicomputable. Suppose it was, then (by the countable connectivity condition and the reduction lemma) it would consist of countably many connected components. But if we choose |c| > 4 it can be shown that F(g) is compact, totally disconnected and perfect, i.e., homeomorphic to the Cantor set (see, for example, Hocking and Young [1961]), and so we have a contradiction (cf. Example 6.26(a)). I
7
Computation on topological partial algebras
We have considered While computations on algebras of reals in section 6. Connections were made between notions of semicomputability and familiar rational polynomial definability; we also made some observations on connections between projective semicomputability and field extensions of
Q-
There is thus a close relationship between computability properties, and algebraic properties of sets of reals. (Of course many of these properties can be reformulated for arbitrary rings and fields.) In this section we explore the relationship between computability properties and topological properties of sets of reals. We will analyse While computations on general topological algebras, and using these general concepts and results, we will be able to give a quick guide to the primary case of computation on BL The outline of this section is as follows. In section 7.1 we indicate the basic problem: although computability implies continuity (to be proved later), total Boolean-valued functions on R such as equality and order are discontinuous. The solution is to work with partial functions. We therefore define partial algebras in section 7.2, and topological partial algebras in section 7.3. In section 7.4 we compare the two approaches to computation on the reals: the algebraic model of section 6, and the stream model which lies behind the models studied in this section. In section 7.5 we prove that computable functions are continuous, from which it follows that semicomputable or projectively semicomutable sets are open, and hence computable sets are clopen (= closed and open). In section 7.6 we infer a converse of this last statement in the case of compact algebras with open subbases of semicomputable sets. In section 7.7 we specialise to metric partial algebras, and in section 7.8 show the equivalence between com-
452
J. V. Tucker and J. I. Zucker
putability and explicit definability in the case of a connected domain. This result is used in the study of approximate computability in section 7.9, in which effective Weierstrass computability (generalising the classical notion of Weierstrass approximability) is shown to be equivalent on connected domains (under certain broad assumptions) to effective uniform While (or While*) approximability. Finally, in section 7.10, we discuss the relationship between abstract and concrete models of computability, with particular reference to computation on the reals. The material of this section is based on Tucker and Zucker [1999]. Background information on topology can be found in any standard text, such as Kelley [1955], Hocking and Young [1961], Simmons [1963] or Dugundji [1966].
7.1
The problem
Consider again the standard algebras n = (E, 1; 0, 1, +, -, x, if real , eqre.1,...) and Ti<, which extends 7£ with less,eai (or '<'). Not all the functions in While(K) and While^R^) are continuous. This is obvious, because both algebras contain certain basic operations, namely eqreai and lessreai ('=' and '<'), that are not continuous (with respect to the usual topology on E). If A is an algebra built on E such that all its basic operations are continuous, then is every function in While(A) continuous? Let us immediately consider this question more generally. Definition 7.1. (1) A topological (total) ^,-algebra is a pair (A, T), where A is a S-algebra and T is a family (Ta \ s e Sort(S)), where for each s € Sort(E), Ts is a topology on As, such that for each basic function symbol F : u -t s of E, the function FA : A" -> As is continuous. (2) A standard total topological algebra (A, T) is a total topological algebra in which A is standard, and the carrier Ab00i = B has the discrete topology. We will often speak of a 'topological algebra A\ without stating the topology explicitly. Remark 7.2. In a topological algebra, the carriers of all equality sorts must be discrete, in order for the equality operation on them to be continuous. In particular, if A is N-standard, then the carrier Anat = N must be discrete. To provide motivation, we state the following theorem here. (It will be formulated and proved later in a more general context.)
Computable functions on algebras
453
Theorem 7.3. Let A be a standard topological algebra. (a) If f € While(A) then f is continuous on A. (b) If f € WhileN(A) then f is continuous on A. (c) If f £ While*(A) then f is continuous on A. At first sight this gives a satisfactory answer to the above question about continuity of While computable functions. However, a standard total topological algebra based on E has the following problem. There can be no non-constant basic operations of the form F : W -» B such as '<' or even '='. This is because if / : M9 -> B is continuous, then /^[tt] and /-1[f] are disjoint open sets whose union is E g . So one must be ffi?, and the other 0, by the connectness of M. (We investigate connectedness in topological algebras in section 7.8.) Hence the problem with the above theorem is the paucity of useful applications. In fact, the only continuous equality test is on a discrete space. However, equality and order on E do have some properties close to continuity. For example, given two points x and y with x < j/, there are disjoint neighbourhoods Ux and Uy of x and y respectively such that for all u £ Ux and v 6 Uy, u < v. (Similarly for inequality '/'.) We will develop notions that allow us to express these 'continuity' properties as follows. Define partial functions lessp : E2 -»I eqp : E2 -» B so that
{
tt if x < y fifx>y t if x = y,
and tlf = ( \fif
These partial functions are continuous, in the sense that the inverse images of {tt} and {f} are always open subsets of E2. We will exploit these observations about '<' and '=' to the full by studying topological partial algebras. We will also prove a more general version of Theorem 7.3 for such partial algebras (Theorem 7.12).
7.2
Partial algebras and While computation
A partial H-algebra is defined in the same way as a S-algebra (section 2.3), except that for each F : u -> s in Func(E), the function FA : Au -» As may be partial.
454
J. V. Tucker and J. I. Zucker
Standard and N-standard partial S-algebras are defined analogously, as are the standardisation and N-standardisation of partial E-algebras (cf. sections 2.4, 2.5). Suppose S is a standard signature, and A is a standard partial Ealgebra. The error partial algebra A", of signature E u , is constructed as before (cf. section 2.6). In particular, for each F eF«nc(E), its interpretation FA on A is extended by strictness to a partial function FA'U on A". The array partial algebra A*, of signature E*, is constructed as before (cf. section 2.7). _ _ The stream partial algebra A, of signature S, is constructed as before (cf. section 2.8). The semantics of While programs on A is similar to that for total algebras (cf. sections 3.3-3.8), except that many of the semantic functions are now partial, namely: the term evaluation function \t]A (section 3.3), the functions §StyA, CompA, CompA, CompLengthA (section 3.4), and (as before) the statement evaluation function [5]A (section 3.5) and procedure evaluation function PA (section 3.6). For example, the definition of [^becomes (cf. section 3.3): \JL}Aa =
[F(ti,...,tm)\Aar
~ t
otherwise.
except for the case that F(. . . ) is the discriminator if (b, t\ , < 2 ), in which case we have a 'non-strict' computation of either [tiller or [/2]"V, depending on the value of [fe]"4^:
if [6]^ A 4- tt
]* if[b]
if[&]A^t-
The results in sections 3.3-3.10 (functionality lemmas, homomorphism invariance and locality theorems) still hold, with certain obvious modifications related to divergence. For example, the functionality lemma for terms (3.4) becomes: Lemma 7.4 (Functionality lemma for terms). For any term t and states a\ and 0-2, if a\ « <72 (rel vart), then either (i) {t\Aal I and [t]A<72 4. and [t]A(n = [t]A
or
Computable functions on algebras (ii) [t]Atn t
7.3
455
[t]A
Topological partial algebras
Note that in, this section, by 'function' we generally mean partial function. Definition 7.5. Given two topological spaces X and Y, a function / : X —> Y is continuous if for every open V C Y, f~l[V] —df {x € X \ x € dom(f) and f(x) £ Y} is open in X. Definition 7.6. (1) A topological partial ^-algebra is a partial E-algebra with topologies on the carriers such that each of the basic functions is continuous. (2) A standard topological partial algebra is a topological partial algebra which is also a standard partial algebra, such that the carrier B has the discrete topology. (Cf. Definition 7.1.) Examples 7.7. (a) (Real algebra.) An important standard topological partial algebra for our purpose is the algebra KP = (R, B; 0, 1, +, -, x,if r e a l , eqp, less, which is formed from by the replacement of eqreai and lessreai by the partial operations eqp and lessp (defined in section 7.1). It becomes a topological partial algebra by giving K its usual topology, and B the discrete topology. An open base for the standard topology on M is given by the collection of open intervals with rational endpoints. These intervals are all While semicomputable on Kp. (Exercise.) (b) (Interval algebras.) Another useful class of topological partial algebras are of the form algebra import carriers functions
IP T^P / '/ : 7->R, mi Fi : 7 -> /, Fk
:
jmk _^ j
end
where I is the closed interval [0,1] (with its usual topology), i/ is the embedding of J into K, and -Fj : Imi —> I are continuous partial functions. These are called (partial) interval algebras on I. Example 7.8 (While computable functions on Up). We give two examples of functions computable by While programs, using the above Boolean-valued functions (eqp and lessp) as tests. (In both cases, the inputs are taken to be positive reals to simplify the programs, although the
456
J. V. Tucker and J. I. Zucker
programs could easily be modified to apply to all reals, positive and nonpositive) . (a) The characteristic function of Z on E, isJnt : R+ -> B, where . . , , f t if a; is an integer 8 is-mt(z) = < ' I f otherwise. This is defined by the procedure proc in x : pos-real out b: bool begin b: =false;
while x>0 {if x = 0, test diverges!} do x:=x-l od end
(b) The truncation function trunc : R+ —» Z, where , . I LXJ if x is not an integer 6 trunc(:r) = \ Ij otherwise. The procedure for this is similar: proc in x : pos-real out c: int begin c:=0;
while x > 1 {if x = 1, test diverges} do x:=x—1; c:=c+l od end
Until further notice (section 7.8) let A be a standard topological partial E-algebra. Definition 7.9 (Expansions of topological partial algebra).
(a) The topological partial algebra A", of signature S u , is constructed from A by giving each new carrier A" the disjoint union topology of As and {ui}. (This makes ui an isolated point of A"s.) (b) The topological partial algebra AN, of signature S", is constructed from A by giving the new carrier N the discrete topology.
Computable functions on algebras
457
(c) The topological partial algebra A*, of signature £*, is constructed from AN as follows. Viewing the elements of each new carrier A* as (essentially) infinite sequences of elements of A", which take the value ui for all indices greater than Lgth(a*), we give A*s the subspace topology of the set (A")N of all infinite sequences from A", with the product topology over A"s. Equivalently, viewing the elements of A*s as (essentially) arrays of elements of A" of finite length, we can give A*s the disjoint union topology of the sets (Aus)n of arrays of length n, for all n > 0, where each set (Aus)n is given the product topology of its components ^4". It is easy to check that A* is indeed a topological algebra, i.e., all the new functions of A" are continuous. (d) The topological partial algebra A, of signature S, is constructed by giving each new carrier As the product topology over As. Note that, if As is compact for any sort s, then so is As, by Tychonoff's theorem (see Remark 7.28). Definition 7.10. A is Hausdorffif each carrier of A is Hausdorff (i.e., any distinct pair of points can be separated by disjoint neighbourhoods.) Proposition 7.11. If A is Hausdorff, then so are the expansions AU,AN, A" and A. Theorem 7.12. Let A be a standard topological partial algebra. (a) If f € While(A) then f is continuous on A. (b) If f £ WhileN(A) then f is continuous on A. (c) If f & While*(A) then f is continuous on A. The proof will be given in section 7.5. For now we observe that this theorem implies the following. Theorem 7.13. If R is (a) While* semicomputable on A, or (b) protectively While* semicomputable on A, then R is open in A. Proof. (a) Suppose R is the halting set of a While* computable function / : Au ->• As. By Theorem 7.12, / is continuous. Hence R = f ~ l [ A s ] is open. (6) From (a) and since a projection of an open set is open. (Check.) I Note that in the above proof, we used the fact that a projection of an open set is open. (Check.) Corollary 7.14. A While* computable relation on A is clopen in A. Proof. By Post's theorems (5.40) and Theorem 7.13.
I
458
7.4
J. V. Tucker and J. I. Zucker
Discussion: Two models of computation on the reals
The purpose of this subsection is to explain the conceptual background for our models of computation on the reals. There are two types of models of reals, and computations on them: (1) The algebraic model. Here we work with a many-sorted algebra like U = (R.N.B; 0,1,+, x , . . . ) , This was the approach in section 6. (2) The stream model. A real number input or output is given as a stream of (i) digits (representing a decimal expansion), or (M) rationals (representing a Cauchy sequence), or (Hi) integers (representing a continued fraction). This idea lies behind the partial algebras of reals Ttp and Ip studied in this section. For convenience, we concentrate on (i). (The decimal representation may be to any base.) Then a procedure for a computable real-valued function / : Mn -> E has as input n streams of digits, and as output a stream of digits. Similarly a procedure for a computable relation on the reals, or Boolean-valued function, R : M" —^ B has as input n streams of digits, and as output a Boolean value (or bit). In the algebraic approach, the input and output reals are just 'points' (elements of E) given in one step. Continuity of the computable functions, or even of the primitive functions (with respect to the usual topology on R), is not forced on us — and our models in section 6 violated it. In the stream model, however, the reals form infinite data; at any finite time, only a finite part has been processed (written or read). Continuity of the computable functions (which we will prove formally in the next subsection) is then forced on us conceptually by computability requirements, (a) For / : En -» TSL to be computable, we must be able to get the output real (= stream of digits) to any desired degree of accuracy (= length) by inputting sufficiently long input streams. (Briefly: the longer the inputs, the longer the output.) (b) For R : En -» B to be computable, we must be able to get an output bit after finite (suficiently long) input streams. We often work with the algebraic model, because of its simplicity. It is a good source of examples to distinguish various notions of abstract computability and semicomputability (as we saw in section 6). However, the stream model is more satisfying conceptually, conforming to our intuition
Computable functions on algebras
459
of reals as they occur to us, e.g., in physical measurements and calculations. So we can use the stream model as a source of insights for our requirements or assumptions regarding the algebraic model, notably the continuity requirement for computable functions. Recall the problem discussed in Section 7.1 concerning the continuity requirement for computable relations, i.e., Boolean-valued functions R : K" ->• B: the only continuous total functions from En to any discrete space such as B are the constant funtions. The solution, we saw, was to work with partial algebras, i.e., to interpret the function symbols in the signature by partial functions. We use the stream model for insight. Consider, for example, the equality and order relations on the reals. Suppose we have two input reals (between 0 and 1) defined by streams of decimal digits, which we read, one digit at a time: a /3
= = 0.606162---
Consider the various possibilities: (a) a < /3. Then for some n, this will be determined by the initial segments ao . . . an and bo . . .bn. (6) a > /3. Similarly, this will be determined by some pair of initial segments. (c) a ^ (3. This is the disjunction of cases (a) and (c), so again it will be determined by some pair of initial segments. (d) a = 0. This case, however, cannot be determined by initial segments of any length! (Note that this analysis is not affected by the double decimal representation of rationals.) This analysis suggests the following definitions for partial functions in the signature of E:
(compare (i));
(iv)
lseq p (z,y) = < f
if x = y
(same as (m)!).
Note that examples (i) and (iii) were incorporated as basic operations in the topological partial algebras 7£p and Xp in section 7.3.
460
J. V. Tucker and J. I. Zucker
Further, we can add real-valued functions such as division: ,(v)x xdn .- y = R
Note that in the above definitions, 't' (undefinedness or divergence) must not be confused with V (error), which occurs in integer division:
,- vi-N In the integer case, we can effectively test whether the input y is 0, and so (if y = 0) give an output, namely an error message (or default value, if we prefer). In the real case, if y — 0, this cannot be effectively decided, and so no output (error or other) is possible. (Suppose the first n digits of the input y are 00 ... 0. The (n + l)th digit may or may not also be 0.) We remark that the concept of reals as streams is reminiscent of Brouwer's notion of reals defined by lawless sequences or choice sequences. In fact, for Brouwer, a function was a constructively defined function, and he 'proved' that every function on M is continuous! (See, for example, the discussion in Troelstra and van Dalen [1988, Chapter 12]). We conclude this discussion by pointing out a related, intensional, approach by Feferman to computation on the reals, based on Bishop's constructive approach to higher analysis (Bishop [1967], Bishop and Bridges [1985]). This is outlined in Feferman [l992a; 1992b].
7.5
Continuity of computable functions
In this section we will prove that computational processes associated with While* programs over topological partial algebras are continuous. More precisely, we will prove Theorem 7.12:
(a) If f € While(A) then f is continuous on A. (b) If f € WhileN(A) then f is continuous on A. (c) If f & While* (A) then f is continuous on A. Clearly, part (a) follows trivially from parts (b) and (c). Note that, conversely, parts (b) and (c) follow easily from (a). For example, if / 6 While* (A) then f £While(A*), therefore / is continuous on A*, and hence on A. We will prove part (a) by demonstrating the continuity of the operational semantics developed in section 3 (as modified for partial algebras). We will see the advantage of the algebraic approach to operational semantics used there, since these functions are built up from simpler functions using composition, thus preserving continuity. We proceed with a series of lemmas. Let X,Y, . . . be topological spaces. Remember, functions are (in general) partial. Lemma 7.15 (Basic lemmas on continuity). (a) A composition of continuous functions is continuous.
Computable functions on algebras
461
(b) Let f : X -»• Ft x . . . x Yn have component functions fa : X -> Yi fori = l,...,n, i.e., f ( x ) ~ (/i (*),... ,/„(«)) /or otf z e X. JTien / is continuous if, and only if, all the fa are continuous for i = l,... ,n. (c) If D is a discrete space, then a function f : X x D —» Y is continuous if, and only if, /( • ,d) : X -> Y is continuous for all d 6 D. Proof. Exercise.
I 2
Corollary 7.16. TTie discriminator f : BxX -> X, defined by /(tt, x, y) = f ( f , x , y ) = j/, is continuous. Proof. Exercise. Corollary 7.17. let / : X ->• F fee defined by if fc(a:) 4- *
t
otherwise,
w/iere gi , 32 : X ->• F and /i : X -»• B are continuous. Then f is continuous. Proof. From Corollary 7.16 and Lemma 7.15(a).
I
Lemma 7.18 (Least number operator). Let g : X x N —> Y be continuous, and let yo £ Y be such that {yo} is clopen in Y. Let f : X —> N be defined by /(x) ~ nk[g(x,k) 4,y 0 ], i.e.,
f ( x ) 4- k <£=> Vz < k(g(x,i) ^ j/ 0 )A (g(x, k) 4- j/ 0 ) Then f is continuous. Proof. Since N has the discrete topology, it is sufficient to show that for any k G N, /-1({fc}) is open. We have k-l
=
f}{x\g(xii)^y0}r({x\g(x,k)iry0} i=0 k-l
t=0
which is a finite intersection of open sets, since by assumption both {yo} and Y\{y0} are open. I The rest of the proof consists of showing the continuity of the various semantic operations defined in section 3.
462
J. V. Tucker and J. I. Zucker
First we must specify topologies on the various spaces involved in the operational semantics. For a product type u = si x ... x sm, the space Au =<*/ AS1 x ... x ASm has (of course) the product topology of the ASi 's. The state space State(A) is the (finite) product of the state spaces States(A) for all s € Sort(E) (section 3.2), where each States(A) is an (infinite) product of the carriers As (indexed by Vars). Thus State(A) is an infinite product of all the carriers As, and takes the product topology of the Ag's. The space State(A.)L){*} is formed as the union of State(A) and the singleton space {*}. Note that this makes the point * clopen in State(A.)\j{*}. The syntactic sets Stmt and AtSt have the discrete topology, as do the sets B and N of Booleans and naturals. Lemma 7.19. For t € Terms, the function {tlA: State (A) -> As (section 3.3) is continuous. Proof. By structural induction on t. Use the facts that the basic functions of E are continuous, and that continuity is preserved by composition (Lemma 7.15(a)). I Recall that \t\A and the other semantic functions considered below are actually the partial algebra analogues of the functions defined in section 3 (as discussed in section 7.2). Lemma 7.20. The state variant function \o-,a- a{x./a} : State(A) x A" -> State(A) (for some product type u and fixed tuple of variables x : u) is continuous. Proof. Exercise.
I A
Lemma 7.21. For S € AtSt, the function §S$ : State(A) -> State(A) (section 3.5) is continuous. Proof. For 5=skip, this is trivial. For 5=x := t, use Lemmas 7.19, 7.20 and 7.15(6). I Lemma 7.22. The functions First and RestA (section 3.6) are continuous. Proof. For First, this is trivial (a mapping with discrete domain space). For RestA, it is sufficient, by Lemma 7.15(c), to show that for any fixed S € Stmt, the function RestA(S, - ) : State(A)-> Stmt is continuous. This is proved by structural induction on S, making use (in the case that S is a conditional or 'while' statement) of Corollary 7.17. I Lemma 7.23. The one-step computation function
Computable functions on algebras
463
CompA : Stmt x State(A) ->• State(A) (section 3.4) is continuous. Proof. Again, by Lemma 7.15(c), it is sufficient to show that for any fixed S £ Stmt, the function CompA(S, •) is continuous. But by definition, this is §First(S)$A, which is continuous by Lemma 7.22. I A Lemma 7.24. The computation step function Comp (section 3.4) is continuous. Proof. Again, it is sufficient to show that for any fixed S £ Stmt and n £ N, the function CompA(S, -,n): State(A)->S*ate(A)U{*} is continuous. This is proved by induction on n, using (in the base case) Lemma 7.23 and (in the induction step) Lemmas 7.22 and 7.23. I Lemma 7.25. The computation length function CompLengthA (section 3.4) is continuous. Proof. This function is defined by CompLengthA(S, a) ~ im[CompA(S, a, n + 1) 4- *]• Its continuity follows from Lemma 7.18, since {*} is clopen in State(A)U{*}, and by Lemma 7.24. I Lemma 7.26. For S <S Stmt, the function [S[A: State (A)-* State(A) (section 3.5) is continuous. Proof. Since [S]A(cr) ~ CompA(S, a,CompLengthA(S,a)), the result follows from Lemmas 7.24 and 7.25.
I
A
Lemma 7.27. For any While procedure P, the function P (section 3.6) is continuous. Proof. Suppose P = proc in a out b aux cbegin 5 end, where a : u and b : v, so that PA : Au -> Av. Fix any stateCTOeState(A). The imbedding and projection functions ta : Au ->• State (A)
and
?rb : State (A) -> Av
defined by t a (z) = a0{a./x} and 7rb(cr) = a[b] are continuous. (Exercise.) Hence the composition 7Tbo [S]Aota : A»->A«. is continuous. But this is just PA, independent of the choice of (TO, by the functionality lemma (3.11) for procedures. • Theorem 7.12(o) follows from this.
464
7.6
J. V. Tucker and J. I. Zucker
Topological characterisation of computable sets in compact algebras
For background on compactness, see any of the books listed at the beginning of section 7. Remark 7.28 (Compactness).
(a) By Tychonoff 's theorem, the product of compact spaces is compact. (6) The unit interval / is compact. Hence so is the product space I9 for any q. Now we have seen (Theorem 7.13 and Corollary 7.14) that for sets: semicomputable computable
=> =£•
open clopen.
We can reverse the direction of the implication in the second of these assertions, under the assumption of compactness. Theorem 7.29. Let Abe a topological partial algebra, and let u = si x . . . x sm £ ProdType(T^, where, for i = 1, ... ,n, (a) ASi is compact, and (b) As. has an open subbase of While semicomputable sets. Then for any relation R C Au, the following are equivalent: (i) R is While computable; (ii) R is While* computable; (in) R is clopen in Au. Proof. (Z):=>(M) is trivial. (n)=>(m) follows from Corollary 7.14. (m)=^-(i): Note first that from assumptions (a) and (6), the product space Au (with the product topology) is compact, and has an open subbase of While semicomputable sets. Suppose now that R is clopen in Au. Since R is open, we can write R=\jBt where the Bt are basic open sets. Each Bi is a finite intersection of subbasic open sets, and hence semicomputable, by Theorem 5.8. Since -R is closed, R is compact, and hence R is the union of finitely many of the BJ'S, and so R is semicomputable, by Theorem 5.8. Repeating the above argument for Rc, we infer by Post's theorem (5.9) that R is computable. I
Computable functions on algebras
7.7
465
Metric partial algebra
A particular type of topological partial algebra is a metric partial algebra. This is a pair (A, d) where d is a family of metrics (d8 \ s £ Sort(E)), and for each s € Sort(E), ds is a metric on As, such that for each basic function symbol F : u —> s of S, the function FA : Au —»• As is continuous (where continuity of a partial function is as per Definition 7.5). This induces or defines a topological partial algebra in the standard way. Note that if A is standard, then the carrier B, as well as the carriers of all equality sorts, will have the discrete metric, defined by O ifx = y
which induces the discrete topology (see Remark 7.2). Again, we will often speak of a 'metric algebra A\ without stating the metric explicitly. Example 7.30. The real algebra Tlp and interval algebras Ip (Examples 7.7) can be viewed (or recast) as metric algebras in an obvious way. Remark 7.31. If A is a metric partial algebra, then for each product sort u = si x ... x sm, we can define a metric du on Au, which induces the product topology on A", by i,... ,xm),(yi,... ,ym)) = n or more generally, by the tp metric m
*<,W)) P ) 1/P
(l
Metric algebras will be used in our study of approximable computability (section 7.9).
7.8
Connected domains: computability and explicit definability
In this subsection we investigate the relationship between computability and explicit definability for a function on a connected domain. First we review the concept of connectedness. Remark 7.32 (Connectedness).
(a) A topological space X is said to be connected if the only clopen subsets of X are X and 0. (b) It is easy to see that X is connected if, and only if, the only continuous
466
J. V. Tucker and J. I. Zucker
total functions from X to B (or to any discrete space) are the constant functions. (Exercise.) (e) A finite product of connected spaces is connected. (See any of the references listed at the beginning of section 7.) Hence in a topological S-algebra A, if u = si x ... x sm € ProdType(S), and ASi is connected for i = 1,... , m, then so is A". (d) The space R of the reals, with its usual topology, is connected. Therefore, so is the product space E9 for any q. Hence, by Corollary 7.14, for any topological partial algebra over K, such as the algebra Tip (Example 7.7(a)), the only While or While* computable subsets of !« are W itself and 0. (e) Similarly, by the connectedness of the unit interval / (and hence of /*), the only While or While* computable subsets of Iq in any interval algebra over / (Example 7.7(6)) are I9 itself and 0, ... , regardless of the choice of (continuous) functions F±,... ,Fk as basic operations! We will only develop the theory in this section for total functions on total algebras. The essential idea is that if / is a computable total function on A, then / is continuous, and so, by Remark 7.32(6), its definition cannot depend non-trivially on any Boolean tests involving variables of sort s if As is connected. (We will make this precise below, in the proof of Lemma 7.40.) Note that many of these results can be extended to the case of total functions / on connected domains in partial algebras. We intend to investigate this more fully in future work. However, for now we assume in this subsection: Assumption 7.33. A is a total topological algebra. Examples 7.34 (Topological total algebras on the reals). Two important total topological algebras based on the reals which will be important for our purposes are: (a) The algebra ftf (T for 'total topological'), defined by algebra import functions
1$ TZo.JV, B ifreal : 1 x E2 -> M, divnat : M x N -> M,
end
Here K0 is the ring of reals (E; 0, 1, +, -, x) (Example 2.5(6)), JV is the standard algebra of naturals (Example 2.23(6)), div nat is division of reals by naturals (where division by zero is defined as zero), and E has its usual topology. Note that 7?.f does not contain the (total) Boolean-valued functions eqreai or lessreai, since they are not continuous (cf. the partial functions
Computable functions on algebras
467
eqp and lessp of 72.p). It is therefore not an expansion of the standard algebra 7J of reals (Example 2.23(c)) which contains eqreai- (Compare the ^-standardisation KN of K (Example 2.27(6)) which does contain eqreal-) (b) (The interval algebra of reals.) Here the unit interval / = [0,1] is included as a separate carrier of sort 'intvl', again with the usual topology. This is useful for studying real continuous functions with compact domain. (We could also choose I = [—1,1], etc.) The total topological algebra If* is defined by algebra import carriers functions end
T^ f$ I i/ : /
Here i/ is the embedding of / into HL Remark 7.35. Note that both algebras K^ and l£ are strictly N-standard. The reason why N, and the function div nat , are included in these total algebras (unlike the partial algebras Tlp and Ip of 7.7) is because of their applicability in the theory of approximable computability in section 7.9. Definition 7.36. Let / be a function on A. (a) f is S- explicitly definable on A if / is definable on A by a S-term. (6) / is £*-explicitly definable on A if f is definable on A by a S*-term. By the £*/£ conservativity theorem (3.63)', the two concepts defined above are equivalent: Proposition 7.37. A function on A is H-explicitly definable if, and only if, it is %*-explicitly definable. Remarks 7.38. (a) Suppose (i) A is strictly N-standard (e.g., K^ and 1^), and («) the domain and range types of / do not include nat (e.g., / : ffi* —>• R or / : / ' — » R in these algebra, respectively). Then this proposition also holds with the 'internal' version of S* (Remark 2.31(c)), by Remark 3.64(6). (6) Because of Proposition 7.37, we shall usually use 'explicit definability' over an algebra to mean either S- or E*-explicit definability. In the following lemma, A is any total algebra, not necessarily topological. Lemma 7.39. Explicit definability on A =*• While computability on A. Proof. Simple exercise. In preparation for the converse direction, we need the following:
I
468
J. V. Tucker and J. I. Zucker
Lemma 7.40. Suppose Au is connected. Let P : u —^ v be a (While or While*) procedure which defines a total function on A, i.e., HaltA(P) = Au. Then the computation tree T(P) for P is essentially finite, or (more accurately) semantically equivalent to a finite, unbranching tree. (The computation tree for a procedure was defined in section 5.11.) Proof. Put P = proc in a out b aux c begin S end where a : u, b : v and c : w, and S = Sinit',S', where Smit is an initialisation of the variables b,c to their default values. Let T = T(P). First, we show that all branches in T can be eliminated. Consider a branch at a test node in T (Fig. 16).
Fig. 16.
This Boolean test defines a function fb,t : Au ->
where (putting x = a, b, c) A» = b
i.e., /6,t(a) is the evaluation of 6(x/t) when a is assigned to a and the default tuples SV,6W are assigned to b,c respectively. The function fb,t is clearly (While or While*) computable, by Lemma 7.39, and hence continuous, by Theorem 7.12. It is also total, since A is total by assumption (7.33). By Remark 7.32(6) it must therefore be constant on Au. If it is constantly tt, we can replace this test node by its left branch (i.e., delete the node and the right branch), and if it is constantly ff, we can similarly replace the node by its right branch only. By repeating this process, we can replace T by a semantically equivalent tree T' without any Boolean tests, and (hence) without any branching. The tree T' consists of a single path, which must be finite, since PA is total by assumption. I
Computable functions on algebras
469
Remarks 7.41. (o) Examples of the application of this lemma are the total topological algebras 71^ and if*, and procedures of type real9 —> real and intvl 9 -» real, respectively. Note that the result also holds with the 'internal' version of While* computability, by Proposition 3.47. (b) Without the assumption that Au be connected, Lemma 7.40 is false, i.e., it is possible for PA to be total, but T(P) to be infinite. (Exercise.) (c) Note that any computation tree T is finitely branching; therefore, by Konig's lemma, T is finite if, and only if, all its paths are finite. Hence any counterexample to demonstrate (b) would be an example of a computation tree for a procedure which defines a total function, but nevertheless has infinite paths! (d) The lemma also holds without the assumption that A be total, as long as PA is total (and Au is connected). (Exercise.) (e) In general, this transformation of T(P) to a finite unbranching tree given by the proof of Lemma 7.40 is not effective in P, since it depends on the evaluation of (constant) Boolean tests. If we want it to be effective in P (as we will in the next subsection, dealing with approximable computability), we will need a further condition on A, such as the Boolean computability property (Definition 7.56). Lemma 7.42. // a computation tree T(P) for a (While or While*) procedure P is finite and unbranching, then PA is (£-) explicitly definable on A. Proof. Exercise.
I
Remark 7.43. More generally, Lemma 7.42 holds if T(-P) is finite but (possibly) branching. (Use the discriminator in constructing the defining term.) Combining Lemmas 7.39, 7.40 and 7.42, we have conditions for an equivalence between explicit definability and While computability: Theorem 7.44. Let A be a total topological algebra, and suppose Au is connected. Let f : Au -* Av be a total function. Then the following are equivalent: (i) f is While computable on A; (ii) f is While* computable on A; (Hi) f is explicitly definable on A. Example 7.45. This theorem holds for the total topological algebras Ti^ and If, and total functions / : R* -> R and /:!*-»/, respectively. Note that by Remarks 7.38(o) and 7.41 (a), the theorem also holds in these algebras with 'internal' versions of While* computability and £*explicit definability.
470
7.9
J. V. Tucker and J. I. Zucker
Approximable computability
It is often the case that functions are computed approximately, by a sequence of 'polynomial approximations'. In this way we extend the class of computable functions to that of approximably computable functions. This theory will build on the work of section 7.8. First we review some basic notions on convergence of sequences of functions. Definition 7.46 (Effective uniform convergence). Given a set X, a metric space Y, a total function / : X ->• Y and a sequence of total functions gn : X -*• Y (n = 0,1,2,...), we say that gn converges effectively uniformly to f on X (or approximates f effectively uniformly on X) if, and only if, there is a total recursive function e : N —> N such that for all n, k and all x € X, k>e(n) =>• dy($*(*),/(*))< 2-". Remark 7.47. Let M : N -)• N be any total recursive function which is increasing and unbounded. Then (in the notation of Definition 7.46) the sequence gn converges effectively uniformly to f on X if, and only if, there is a total recursive function e : N -4 N such that for all n, k and all a; 6 X, k > e(n) =» d Y ( 9 k ( x ) , f ( x ) ) < l/M(n). (Exercise.) The theory here will be developed for total functions on metric total algebras (denned in section 7.5). We therefore assume in this subsection: Assumption 7.48. A is a metric total algebra. Example 7.49 (Metric total algebras on the reals). The two total topological algebras based on the reals given in Example 7.34 can be viewed as metric algebras in an obvious way. The second of these, the interval algebra if*, will be particularly useful here. We will present, and compare, two notions of approximable computability on metric total algebras: effective uniform While (or While*) approximability (Definition 7.50) and effective Weierstrass approximability (Definition 7.54). So suppose A is a metric total E-algebra. Let u, v € ProdType(E) and s € Sort(E). Definition 7.50. A total function / : Au -> A" is effectively uniformly While (or While*) approximable on A if there is a While (or While ) procedure P : nat x u -» v on AN such that PA is total on AN and, putting gn(x) =
(n,x),
Computable functions on algebras
471
Remark 7.51. If A is ./V-standard, we can replace 'AN' by 'A' in the above definition (by Proposition 3.38). Lemma 7.52. If Au is compact, and f : Au —> As is effectively uniformly While* approximate on A, then f is continuous. Proof. By Theorem 7.12, the approximating functions for / are continuous. The theorem follows by a standard result for uniform convergence on compact spaces. • Remark 7.53. Note that a function from E* to M is explicitly definable over n.^ if, and only if, it is definable by a polynomial in q variables over E with rational coefficients. Similarly, a function from /* to E is explicitly definable over If* if, and only if, it is definable by a polynomial in q variables over / with rational coefficients. This explains the following terminology, since Weierstrass-type theorems deal typically with approximations of real functions by polynomial functions (uniformly on compact domains). Definition 7.54 (Effective Weierstrass approximability).
(a) A total function / : Au -t As is effectively S- Weierstrass approximable over A if, for some x : u, there is a total computable function h : N ->• rTermx,s(xr such that, putting gn(x) —q te^s(h(n),x), the sequence gn converges to / effectively uniformly on A". (b) Effective E*-Weierstrass approximability is defined similarly, by replacing 'E' by '£*' and lte^ by 'te£'. (The term evaluation representing function te^s was defined in section 4.3.) Proposition 7.55. A function on A is effectively Y,-Weierstrass approximable if, and only if, it is effectively ^-Weierstrass approximate. Proof. From a computable function h* : N -> rTermI,s(E*)'1 we can construct a computable function h : N ->
r
TermI,f(S)~l
where, for each n, h(n) and h*(n) are Godel numbers for semantically equivalent terms, using the fact that the transformation of E*-terms to S-terms in the conservativity theorem 2.15.4 is effective. • We shall therefore usually speak of 'effective Weierstrass approximability' over an algebra to mean effective Weierstrass approximability in either sense.
472
J. V. Tucker and J. I. Zucker
We now investigate the connection between effective uniform While approximability and effective Weierstrass approximability. We are looking for a uniform version of Theorem 7.44 (i.e., uniform over N-sequences of functions). To attain this uniformity, we need an extra condition in each direction: for 'effective Weierstrass =$• effective uniform While' (i.e., a uniform version of Lemma 7.39) we need the TEP (section 4.7), and for 'effective uniform While =>• effective Weierstrass' (i.e., a uniform version of Lemma 7.40) we need a new condition, the Boolean computability property (cf. Remark 7.41(e)), which we now define. Definition 7.56. A E-algebra A has the Boolean computability property (BCP) if for any closed S-Boolean term 6, its valuation 6 A (= tt or ff, cf. Definition 2.11) can be effectively computed, i.e., (equivalently) there is a recursive function
with /(rZP) = bA. Remark 7.57. To avoid confusion: the BCP is not a special case of the TEP, for closed terms of sort bool. It requires the function / in Definition 7.56 to be recursive, i.e., computable over N (and B) in the sense of classical recursion theory. The TEP entails only that / be computable over A — a weaker assumption (in general). Example 7.58. Both ftf and If have the TEP and the BCP. (Exercise.) We will see how these two conditions (TEP and BCP) are applied in opposite directions to obtain a uniform version of Theorem 7.44. In the following lemma, A is any total algebra, not necessarily metric or even topological (cf. Lemma 7.39). Lemma 7.59. Suppose A has the TEP. Given variables x : u, let
h : N -+ rTermI,s(S)n be a total computable function. Then there is a While(EN) procedure P : nat x u —> s such that for all x £ Au and n € N, PAN(n,x) = teAtl(h(n),x). Proof. Simple exercise.
I
For the converse direction: Lemma 7.60. Suppose Au is connected and A has the BCP. Let P : nat x u -t v be a (While or While*) procedure over AN which defines
Computable functions on algebras
473
a total function on AN . Then there is a computable function h : N ->• TermIiS(sr su^h that for all x € Au and n € N,
r
teAs(h(n),x)
= PAN(n,xy
Proof. Suppose P = proc in n, a out b aux c begin 5 end where n : nat. Consider the WhileN(E) procedures Pn : u —¥ v (n = 0,1,2,...) denned by Pn = proc in a out b aux n, c begin n := n; S end where n is the numeral for n. It is clear that for all n 6 N and x € Au,
PA(x) = PAN(n,x). By Lemmas 7.40 and 7.42, PA is definable by a S-term tn. Moreover, the sequence (tn) is computable in n, by use of the BCP to effectivise the transformation of the tree T to T' in the construction given by the proof of Lemma 7.40. (Note that the evaluation of a constant Boolean test can be effected by the computation of any closed instance of the Boolean term, which exists by the instantiation assumption.) Hence the function h denned by r
h(n) = ^
is computable.
I
We now have a uniform version of Theorem 7.44: Theorem 7.61. Suppose Au is connected and A has the TEP and BCP. Let f : Au -> A8 be a total function. Then the following are equivalent: (i) f is effectively (ii) f is effectively (Hi) f is effectively
uniformly While approximate on A; uniformly While* approximable on A; Weierstass approximable on A.
Proof. From Lemmas 7.59 and 7.60.
I
The requirement in the above theorem that / be total derives from the application of Lemma 7.60, which in turn used Lemma 7.40, where totality was required. Remark 7.62. The equivalence of (i) and (in) was noted for the special case A = If, Au = /« and As = R in Shepherdson [1976], in the course of proving the equivalence of these with another notion of computability on the reals (Theorem 7.64).
474
J. V. Tucker and J. I. Zucker
We are especially interested in computability on the reals, and, in particular, a notion of computability of functions from Iq to E, developed in Grzegorczyk [1955; 1957] and Lacombe [1955]. We repeat the version given in Pour-El and Richards [1989], giving also, for completeness, the definitions of computable sequences of rationals and computable reals. Finally (Theorem 7.64),we state the equivalence of this notion with the others listed in Theorem 7.61. Definition 7.63. (a) A sequence (r^) of rationals is computable if there exist recursive functions a, 6, s : N -* N such that, for all k, b(k) ^ 0 and rt Tk
- ( p.(fc)°(*) ~ ( lj &(*)'
A double sequence of rationals is computable if it is mapped onto a computable sequence of rationals by one of the standard recursive pairing functions from N2 onto N. (b) A sequence (x^ of reals is computable if there is a computable double sequence of rationals (rnk) such that \i"nk — xn\ < 2~k
for all k and n.
(c) A total function / : / ' - * M is GL (or Grzegorczyk-Lacombe) computable if: (i) f is sequentially computable, i.e., / maps every computable sequence of points in /' into a computable sequence of points in TO. JK,
(ii) f is effectively uniformly continuous, i.e., there is a recursive function 6 : N -> N such that, for all x, y € I9 and all n € N, \x-V\<2-iW=>\f(x)-f(v)\<2-n. Theorem 7.64. Let f : Iq ->• K be a total function. Then the following are equivalent: (i) f is effectively uniformly While approximate on if1; (ii) f is effectively uniformly While* approximate on 1™; (Hi f is effectively Weierstrass approximate on 1^; (iv) f is GL computable. Proof. As we have noted, /« is connected and I? has the TEP and BCP. Hence the equivalence of the first three assertions is a special case of Theorem 7.61. The equivalence of (Hi) and (iv) is proved in detail in Pour-El and Richards [1989]. I Remark 7.65 (Historical). The equivalence (iii)&(iv) was proved in Pour-El and Caldwell [1975]. An exposition of this proof is given in Pour-El
Computable functions on algebras
475
and Richards [1989]. Shepherdson [1976] gave a proof of (i)-e>(iv) by (essentially) noting the equivalence (i)-o(m') and reproving (m)'O(iv). The new features in the present treatment are: (a) the equivalence (i)t$(iii) in a more general context (Theorem 7.61), and (6) the equivalence of (ii) with the rest (Theorems 7.61 and 7.64).
7.10
Abstract versus concrete models for computing on the real numbers
Our models of computation can be applied to any algebraic structure. Furthermore, our models of computation are abstract: the computable sets and functions on an algebra are isomorphism invariant. Thus to compute on the real numbers we have only to choose an algebra A in which (any one of the representations of) the set E of reals is a carrier set. There are infinitely many such algebras of representations or implementations of the reals, all with decent theories resembling the theory of the computable functions on the naturals. However, unlike the case of the natural numbers, it is easy to list different algebras of reals with different classes of While computable functions (see below). In sections 6 and 7, we have let the abstract theory dictate our development of computation on the reals. The goal of making an attractive and useful connection with continuity led us to use partial algebras in section 7. Because of the fundamental role of continuity, this partial algebra approach is important since it enables us to relate abstract computation on the reals with concrete computation on representations of the reals (via the natural numbers). This we saw in section 7.4 and, especially, in section 7.9. Here we will reflect further on the distinction between concrete and abstract, following Tucker and Zucker [1999]. The real numbers can be built from the rational numbers, and hence the natural numbers, in a variety of equivalent ways, such as Dedekind cuts, Cauchy sequences, decimal expansions, etc. Thus it is natural to investigate the computability of functions on the real numbers, starting from the theory of computable functions on the naturals. Such an approach we term a concrete computability theory. The key idea is that of a computable real number. A computable real number is a number that has a computable approximation by rational numbers; the set of computable real numbers forms a real closed subfield of the reals. Computable functions on the reals are functions that can be computably approximated on computable real numbers. The study of the computability of the reals began in Turing [1936], but only later was taken up in a systematic way, in Rice [1954], Lacombe [1955] and Grzegorczyk [1955; 1957], for example. The different representations of the reals are specified axiomatically, uniquely up to isomorphism, as a complete Archimedean ordered field. But computationally they are far from being equivalent. For instance, representing real numbers by infinite decimals leads to the problem that the trivial function 3x cannot be computable. If Cauchy sequences are used,
476
J. V. Tucker and J. I. Zucker
however, elementary functions on the reals are computable. The problems of representation are worse when investigating computational complexity (see Ko [1991]). It is a general problem to understand concrete representations of infinite data and, to this end, to establish a comprehensive theory of computing in topological algebras. There have been a number of approaches to computability based on concrete representations for the reals and other topological structures. Only recently have these approaches been shown to be equivalent. The ideas about computable functions on the reals were generalised to metric spaces in Moschovakis [1964] who proved some of the special theorems of Ceitin [1959] obtained earlier with a constructive point of view. An axiomatic approach to computability on Banach spaces is given in Pour-El and Richards [1989]. This gives general theorems about the independence of computation from representations, and provides a series of remarkable results characterising computable operators. Computability theory on N includes a theory of computation for functionals on the set B =df [N -> N]
which, with the product topology, is called Baire space. The theory of computation on B is called type 2 computability theory. Klaus Weihrauch and his collaborators, in a long series of papers, have created a fine generalisation of the theory of numberings of countable sets (recall section 1.3) to a theory of type 2 numberings of uncountable sets. In type 2 enumeration theory, numberings have the following form. Let X be a topological space. A type 2 enumeration of X is surjective partial map
a : B -> X (cf. Definition 1.1). Computability on X is analysed using type 2 computability on B. See, for example, Kreitz and Weihrauch [1985] and, especially, Weihrauch [1987]. A more abstract method for the systematic study of effective approximations of uncountable topological algebras has been developed by V. Stoltenberg-Hansen and J. V. Tucker. It is based on representing topological algebras with algebras built from domains and applying the theory of effective domains. This method of applying domain theory to mathematical approximation problems was first developed for topological algebras and used on completions of local rings in Stoltenberg-Hansen and Tucker [1985; 1988]. It was further developed on universal algebras in StoltenbergHansen and Tucker [1991; 1993; 1995]; see also Stoltenberg-Hansen et al. [1994, Chapter 8]. We will sketch the basic method; an introduction can be found in Stoltenberg-Hansen and Tucker [1995]. Suppose A is a topological algebra. The idea is to build an algebra R that represents A by means
Computable functions on algebras
477
of the continuous representation map a : R -> A and to computably approximate R. We imagine building R from a set P of approximating data that is a computable structure (in the sense of section 1.3). Each datum in R is approximated by some sequence of data from P. More specifically, R is a topological space obtained from P by some form of completion process in which P is dense in R. The key feature of this approach is that, since P is computable, some of the approximating sequences are computable. The subset of R consisting of the computably approximable elements forms a basis for the computable approximation of R and hence of A. We usually use a special type of approximating structure P called a conditional upper semilattice, and a completion process called ideal completion. This process yields an algebraic domain. The method effectively approximates a large class of examples: ultrametric algebras, locally compact Hausdorff algebras (Stoltenberg-Hansen and Tucker [1995]), and complete metric algebras (Blanck [1997]). Similar ideas have been used in Edalat [I995a; 1995b], applying continuous domains to analytical questions, such as integration and measure. The domain method is related to Weihrauch's generalised computability theory: a type 2 enumeration is easily shown to give a domain representation, and it is possible to construct a type 2 enumeration for a large class of domain representations (see also Weihrauch and Schreiber [1981]). Indeed, in Stoltenberg-Hansen and Tucker [l999b] there is a series of theorems that show that for a wide class of spaces the concrete models based on effective metric algebras, axiomatic computation theory, type 2 enumerability, algebraic domain representability, and continuous domain representability are all equivalent. Thus there is a stable theory of computable functions based on concrete models. It is important to understand fully the relationship between the concrete and abstract computability theories developed here and elsewhere: in the one direction, we construct concrete representations of abstract models, and in the other, we abstract from concrete models. Let us examine this more closely. The various concrete computability theories discussed above have a common form, which is similar to that of the theory of computable algebras (see section 1.3), one difference being that, at present, the theory of effective computation on topological algebras is not completely settled. Let A be a topological algebra. To compute in A, a concrete representation
a : R -»• A
(7.1)
of A must be made where: (i) R is a topological algebra, made from computable data types, on which we can compute; and
478
J. V. Tucker and J. I. Zucker
(ii) a is a surjective continuous homomorphism that allows us to compute on A by computing on R. In particular, there is a set Compa(A) of functions on A computable in terms of the representation (7.1). In general terms, when comparing abstract and concrete models of computation, we may expect the following situation. Let AbsComp(A) be a set of functions on A that is computable in an abstract model of computation (e.g. the While language). Let ConcRep(A) be a class of concrete representations of the form a : R —> A (e.g., a type 2 enumeration, or domain representation). For a € ConcRep(A), let Compa(A) be the set of functions on A computable with the representation a. Computing with a concrete representation R of an algebra A enables more functions to be computable than with an abstract model of computation based solely on the operations. In fact, for a class of concrete models of computation, we expect the following abstraction condition to hold: AbsComp(A) C
^\a€ConcRep(A)ComP^(A}-
In the case of classes of concrete models of computation that are designed to characterise the set of functions on A that can be computed, we can further postulate (using the generalised Church-Turing thesis, cf. section 8.9):
While*(A) C
naeConcRep(A)CoTnP<*(A)
(compare (1.1) of Section 1.3). In the known concrete models, the computable functions are continuous, therefore the continuity of the abstract computable functions is essential. There is much to explore in the border between abstract and concrete computability. In Stewart [1999] it is shown that if A is an effective metric algebra with enumeration a, then the While* approximable functions on A are a-effective. The converse is not true. To bridge this gap, nondeterministic choice must be added to the 'While' language, and manyvalued functions considered (see Tucker and Zucker [2000a]). A theory of relations (or multi-valued functions) denned by generalised Kleene schemes has been developed in Brattka [1996; 1997]. Among several important results is an equivalence between the abstract computability model based on Kleene schemes and Weihrauch's type 2 enumerability. The distinction between abstract and concrete models made in Tucker and Zucker [1999] has practical use in classifying the many approaches to computability in concrete structures. However, this distinction needs further theoretical refinement. One is reminded of the distinction between 'internal' and 'external', applied to higher type functionals, in Normann [1982].
Computable functions on algebras
8
479
A survey of models of computability
In this section we will survey other abstract approaches to computability on abstract algebras, and discuss two generalised Church-Turing theses: one for computability of functions, and one for specification of relations, that draw support from theorems estabilishing the equivalence of different models. Earlier we have surveyed the origins of these abstract generalisations (section 1.4) and also the 'independent' development of abstract models for computation on real and complex numbers (sections 6 and 7.10). The alternative methods for defining While computable functions are to be found in various mathematical contexts and have various objectives. Technically, they share the abstract setting of a single-sorted abstract structure (i.e., an algebraic or a relational structure). Here we consider their common purpose to be the characterisation of those functions effectively computable in an abstract setting: their generalisation to a class of manysorted abstract algebras is not difficult. The first alternative approach we look at in some detail, namely: the class of functions defined from the operations of an algebra by the application of composition, simultaneous primitive recursion and least number search, which we call the fiPR computable functions. This model of computation was created in Tucker and Zucker [1988] with the needs of equational and logical definability in mind. A simpler generalisation using induction schemes was made early on, in Engeler [l968a]. We have found the various recursion schemes on N to be a primary source of technical ideas about functions computable on an abstract algebra A, and a useful tool for applications. The While computable functions can also be characterised by approaches based upon (i) machine models; (ii) high-level programming constructs; (iii) axiomatic methods; (iv) equational calculi; (v) fixed-point methods for inductive definitions; (vi) set-theoretic methods; (vii) logical languages. We will say something about each in turn.
8.1
Computability by function schemes
We will consider computability on TV-standard algebras formalised by schemes, which apply uniformly to all algebras of some fixed Af-standard signature £. These generalise the schemes in Kleene [1952], for constructing functions over N by starting with some basic functions and applying to these composition, simultaneous primitive recursion and the constructive least number operator. We write a,/3,.,. for schemes. Each scheme a will have a fixed type u —> v, with domain type u and
480
J. V. Tucker and J. I. Zucker
range type v, both product types over E; we will also write a : u —> v. The semantics of such a scheme, for each A E.NStdAlg(E)(ihe class of TV-standard S-algebras), will then be a function IO!A : Au -> Av.
We will usually write aA for |a] . We will consider four notions of computability by schemes: PR, PR*, p,PR and (j,PR*, and see how they correspond with our basic notions of computability involving While and For programs. Definition 8.1 (PR computability). Given a standard signature S, we will define the family Pfl(E) =
(i) Initial functions and constants. For each E-product type u, E-sort s and function symbol F € Func(S)u^s, there is a scheme F € P/Z(E) U _ >S . On each A €.NStdAlg(£), it defines the function
FA : Au -» A.. (if) Projection. For all m > 0, u = si x . . . x sm and i with 1 < i < m, there is a scheme U tt> , 6 PJ?(S)u_j.Si . It defines the projection function u «,i : AU -> A*i on each A £NStdAlg(V), where
for all (xi,... ,xm) € Au. (in) Definition by cases. For every E-sort s there is a scheme dc € P.R(E)BXSXS-»S- It defines the function dc : B x A% —* As on each A £NStdAlg(£), where
if 6 = tt
for all 6 € B and x,y € Ag.
Computable functions on algebras
481
Induction: Building new function schemes from old (iv) Vectorisation. For all S-product types u,v, where v = Si x . . . x s n , and for all schemes /31; . . . ,/3n, where /3, € PH(E) u ^ Si for i = 1, . . . ,n, there is a scheme a = vectu?j,(/3i,. . . ,/?„) € PH(S) tl _ >w . It defines the function aA : Au ->• v4w on each A eJVStd.A/0(S), where
for all x € A". (u) Composition. For all E-product types u,v,w, and for all schemes /3 € PR(£) U -> u and 7 6 PH(S)tI^u, there is a scheme a = compu „ „, (/?,7) € PR(£)«_y w . It defines the function aA : Au -4 ^l"1 on each A £ NStdAlgCS), where
for all x&Au. (vi) Simultaneous primitive recursion. For all S-product types u,v,w, and for all schemes f3 6 PJl(E) u _ > ^ and 7 € Pfl(S) natX uxt;-n) there is a scheme a = prim U)t ,(/?,7) 6 -P-R(S) natxu ^ v . It defines the function aA : N X Au ->• Av on each A eTVStdAi^CS), where
aA(0,x) a (z + l,x) A
= -
/3A(x) 7A (z, x, aA(z,x))
for all z e N and x € ,4". Now, for any A €.NStdAlg(T,), we define
PR(A) = (PR(A)U^V where
u,ve
PJl(A)u^v = {a^4 | a €
It turns out that a broader class of functions provides a better generalisation of the notion of primitive recursiveness, namely P.R*(S) computability.
Definition 8.2 (PR* computability). We define P.R*(S) to be the class of PJZ(£*) schemes for which the domain and range types are in E, i.e., P#*(E) =# (PR(Z*)u^v\u,v€ProdType(Z)
C
pfl(S').
Then any such scheme a e PR* (£)„_>„ defines a function aA : Au -> A41 on each A €AT,Sttd.A/0(E). Also PR* (A) is the set of PR* (E)-computable functions on A. Next we add the constructive least number operator to the PR schemes.
482
J. V. Tucker and J. I. Zucker
Definition 8.3 (p,PR computability). The class of fj,PR schemes over
2, /xP.R(E) - (nPR(E)u->v
u,v£ ProdType(E)),
is formed by adding to the PR schemes of Definition 8.1 the following: (vii) Least number or n operator. For all E-product types u and for all schemes 0 6 M-P-Ruxnat->booi there is a scheme a=min u (/3) £ p,PR(S)u^nM. It defines the function aA : Au -» N on each A £NStdAlg(E), where for all x e Au, hat is, aA (x) \. z if, and only if, {3A (x, y) \. f for each y < z and f3A (x,z] \. ft. Also fiPR(A) is the set of /xP.R(E)computable functions on A. Note that this scheme (as well as the scheme for simultaneous primitive recursion) uses the ./V-standardness of the algebra. Also, [iPR computable functions are, in general, partial. Again, however, a broader class turns out to be a better generalisation, namely: Definition 8.4 (pPR* computability). The class (iPR*(£) consists of those (j,PR(E*) schemes for which the domain and range types are in E, i.e., /xPH*(S) =df (fj.PR(^)u^v
\u,v€ ProdType(S))
g
M pfl(E*).
Also, for any A €NStdAlgC£), nPR*(A) is the set of pPR* (S)-computable functions on A. We now compare the above notions of scheme computability with our notions of computability involving imperative programming languages. They correspond as follows. Theorem 8.5. For any N-standard T,-algebra A,
(a) PR(A) = For (A), (b) PR* (A) = For* (A), (c) tiPR(A) - While(A), (d) nPR*(A) = While" (A). These equivalences hold uniformly over E. 'Uniformity over E' in the above theorem means (taking, for example, case (a), and writing PorProc(S) for the class of .For(E) procedures) that there are effective mappings 0:
PJZ(E) -»• .ForProc(E)
tf>:
.ForProc(E) ->• P-R(E)
and
Computable functions on algebras
483
(primitive recursive in the enumerated syntax) such that for all PR(H) schemes a, For(E) procedures P and TV-standard S-algebras A, [
and
W(P)]A
= [P]A-
and similarly for parts (6), (c) and (d). Similar uniformity results hold for the equivalences stated in the following subsections. The above theorem can be proved by the techniques of Tucker and Zucker [1988] or Thompson [1987]. Part (a), in the classical case over N or Z, was originally proved in Meyer and Ritchie [1967]. For an exposition of parts (a) and (c) in the classical case, see, for example, Brainerd and Landweber [1974], Kfoury et al. [1982], Davis and Weyuker [1983, Chapter 13] or Zucker and Pretorius [1993, Section 13]. Remark 8.6 (Course of values recursion). In our development above, we considered the class PR(£,) of primitive recursive schemes equivalent to For(E) computability. From this we could obtain the class PB*(£) of schemes equivalent to For*(S) computability by operating with the same schemes PR, but over the extended array signature S*. An alternative approach for strengthening P.R(£) is to maintain the signature S, but strengthen the recursion scheme. More precisely, we define the class CR(E) of course of values recursive schemes by replacing the scheme (vi) for simultaneous primitive recursion by the scheme (vi') Simultaneous course of values recursion. For all E-product types u, v and positive integers d, and for all schemes f3 eCfl(E) u _ K ,, 7 € CR(E)natxuxvj_+v!aid6i,... ,6d where Si €CB(S) nat xu-»nat (i = 1, • • • , d ) , there is a scheme a = cvalu,,.^, 7, «i,... ,«„) € It defines the function aA : N x Au -> A" on each A where
€NStdAlg(Z),
aA(0,x) = f)A(x) and for z > 0 aA(z,x) =
i(z,x,aA(61(z,x),x),...,aA(Sd(z,x),x)),
where 6i are the 'reducing functions' derived from Si, defined by Si(z,x) ~ min(S(z,x), z — 1)
for z > 0.
We also define the class /*Cfl(S) of course of values recursive schemes with the least number operator by adjoining the scheme (vii) for the ^
484
J. V. Tucker and J. I. Zucker
operator to CR(S). 8.5):
We then obtain the two equivalences (cf. Theorem
Theorem 8.7. For any N-standard H-algebra A, (a) CR(A) = PR" (A) ( = For" (A)) (b) nCR(A) = nPR*(A) (= While*(A)). Part (6) is proved in Tucker and Zucker [1988] by showing that p,CR(A) — While* (A). (Part (a) can be proved similarly.) This proof is more delicate than the proofs for Theorem 8.5. The direction '<=' is based on local representability and term evaluation arguments. Remark 8.8 (Some applications of the scheme models).
(1) These can be used easily in the mathematical modelling of many deterministic systems, from computers (e.g. Harman and Tucker [1993] to spatially extended non-linear dynamical systems (Holden et al. [1992]). (2) The uPR schemes have been adapted and extended to characterise the computable relations on certain metric algebras, including the algebra of reals (Brattka [1996; 1997]).
8.2
Machine models
Perhaps the most concrete approach to generalising computability theory from N to an algebra A is that based upon models of machines that handle data from A. To be specific, we consider some models called A-register machines that generalise, to a single-sorted relational structure A, the register machine models on N in Shepherdson and Sturgis [1963] (see also Cutland [1980] for a development of recursive function theory using register machines); the first A-register machines appeared in Friedman [l971a]. Some of these register machine models are used in work on real number computation (Herman and Isard [1970], Shepherdson [1976] and Blum et al. [1989]) and have been developed further independently of the earlier literature (see our survey in section 1.4). We will consider four types of A-register machine for an arbitrary singlesorted algebra. A (basic) A-register machine has a fixed number of registers, each of which can hold a single element of A. The machine can perform the basic operations of A and decide the basic relations of A; in addition, it can relocate data and test when two registers carry the same element. Thus, the programming language that defines the A-register machine has register names or variables r0, r\ , r 2 ,... and labels 0,1,2,..., and allows instructions of the form r\ •= F(r^,... ,r M m ) r\ := c r\ := r^ if R(r^,... , r^ m ) then i else j
Computable functions on algebras
485
and, if equality is required, if r\ = r^ then i else j wherein A, p., /zi, pm € N; i, j € N are considered as labels; and F,c,R are symbols for a basic operation, constant and relation, respectively. A program for an A-register machine is called, in Friedman [l971a], a finite algorithmic procedure or fap, and it has the form of a finite numbered or labelled list of A-register machine instructions I\,... , /„. Given a formal definition of a machine state, containing the contents of registers and the label of a current instruction, is it easy to formalise an operational semantics for the finite algorithmic procedures — one in which the instructions are given their conventional meaning. On setting conventions for input and output registers we obtain the class FAP(A) of all partial functions on A computable by all finite algorithmic procedures on A-register machines. Secondly, an A-register machine with counting is an A-register machine enhanced with a fixed, finite number of counting registers. Each counting register can hold a single element of N and the machine is able to put 0 into a counting register, add or subtract 1 from a counting register, and test whether two counting registers contain the same number. Thus, an A-register machine with counting is an A-register machine augmented by a conventional register machine on N. (Implicitly, this is concerned with the process of ^-standardisation of the algebra A by the addition of the natural numbers N.) The programming language that defines the A-register machine with counting has new variables co,ci,C2,... for counting registers, and new instructions CA := 0 c\ := CM + 1 CA := CM - 1 if CA = CM then i else j for A,/z € N and i,j € N considered as labels. A program for an A-register machine with counting is called a finite algorithmic procedure with counting or fapC, and is a finite numbered list of machine instructions. Once again it is easy to give a formal semantics for the language and to rigorously define the class FAPC(A) of all partial functions on A computable by A-register machines with counting. The point of this model is that it enhances computation on the abstract algebra A with computation on N. The A-register machine and A-register machine with counting, and their classes of partial functions FAP (A) and FAPC(A), were introduced and studied in Friedman [l971a]. Next, an A-register machine with stacking is an A-register machine augmented with a stacking device into which the entire contents of the algebraic
486
J. V. Tucker and J. I. Zucker
registers of the A-register machine can be copied at various points in the course of a computation. The programming language that defines the A-register machine with stacking has a new variable s for the store or stack and the new instructions: stack (i,r0,... ,rm) restore (r 0 ,... , r,-_i, rj+i,... ,rm) if s = empty then k else marker. Here i,j, k € N are considered as labels, and the machine has m registers and one stack. Intuitively, what they mean for the machine is as follows. The 'stack' instruction commands the device to copy the contents of all the registers and store at the top of a (single) stack, along with the instruction label i. The 'restore' instruction returns to the registers T O , . . . , TJ—\ , TJ+I ,... ,rm the values stored at the top of the stack; the value of TJ is lost (in order not to destroy the result of the subcomputation preceding the 'restore' instruction), as is the instruction label. The test instruction passes control to instruction k if the stack is empty and to the instruction indexed by the label contained in the topmost element of the stack otherwise. A program for an A-register machine with stacking is called a finite algorithmic procedure with stacking or fapS, and is a finite numbered list of machine instructions. On formalising the semantics for the language, it is easy to define the class FAPS(A) of all partial functions on A computable by A-register machines with stacking. Of course there are alternative designs for a stacking device of equivalent computational power. The point of this model is that first, it enhances the bounded finite algebraic memory available in computation by an A-register machine with unbounded finite algebraic storage, and secondly, it does not enable us to simulate counting with natural numbers. Finally, an A-register machine with counting and stacking is an Aregister machine augmented by both a counting and stacking device. A program for such a machine is called a finite algorithmic procedure with counting and stacking or fapCS, and the class of all partial functions on A computable by such machines is denoted FAPCS(A). This stack device and its associated classes of functions FAPS(A) and FAPCS(A) were introduced in Moldestad et al. [1980a; 1980b]. Of course, in the case of computability of the natural numbers A = N we have FAP(N)
= FAPC(N)
= FAPS(N)
=
FAPCS(N)
but in the abstract setting we have: Theorem 8.9. For any single-sorted algebra A, the inclusion relationship between the sets of functions is shown in Fig 17. Moreover, there exists an algebra on which the above inclusions are strict.
Computable functions on algebras
487
FAPC(A)
FAP(A)
FAPCS(A)
FAPS(A)
Fig. 17. This theorem is taken from Moldestad et al. [l980b]. It and other results about these models make clear the fact that, when computing in the abstract setting of an algebra A, adding • computation on N • unbounded algebraic memory over A both separately, and together, increases the computational power of the formalism. The connection with the imperative models is easily described. Assuming the straightforward generalisation of the machine models to accommodate many-sorted algebra, we have:
Theorem 8.10. For any standard ^-algebra A, While(A) WhileN(A) While* (A)
= FAP(A), = FAPC(A), = FAPCS(A).
Three other machine model formalisms of interest are the finite algorithmic procedures with index registers (fapIR) and countable algorithmic procedures (cap) in Shepherdson [1973] and the generalised Turing algorithms (gTa) in Friedman [l971a], all equivalent to While* computability. In the obvious notation, we have:
Theorem 8.11. For any standard 'S-algebra A, FAPCS(A) = GTA(A) = FAPIR(A) = CAP(A) = While" (A). In addition, it is convenient at this point to mention Friedman's effective definitional schemes (eds) which are a simple and transparent technical device for defining and analysing computability on A. The effective definitional schemes have found a useful role in the logic of programs (see Tiuryn [l981b], for example). Theorem 8.12. For any standard Ti-algebra A, FAPCS(A) = EDS(A)
= While* (A).
488
8.3
J. V. Tucker and J. I. Zucker
High-level programming constructs; program schemes
Practical programming languages, especially imperative languages, are a rich source of theoretical ideas about computation. However, their development, from the 1940s to the present, has not had a dominant role in shaping computability theories. The development of high-level constructs, abstract data types and non-deterministic constructs for algorithmic specification is clearly relevant. The study of computability via machine models is akin to low-level programming, where there is a simple correspondence between instructions and machine operations. In high-level programming, abstractions away from the machine are achieved wherein a program statement or command can set off a sequence of machine operations. This break with programming a specific architecture increases the practical need for mathematical semantics. All our algebraic models are high-level since they are based on abstract data types that abstract from the data representations and their algorithms. We have, of course, already studied some high-level constructs in the languages for While and While* programs. However, in contemplating high-level constructs with regard to generalising computability theory, close attention must be paid to the ideas about algorithms that motivate their introduction. Clearly, recursion and iteration are distinct tools for defining algorithms in connection with procedures. Non-deterministic constructs, by contrast, are proposed as tools for algorithm specification, in order to abstract away from algorithmic implementation. Non-deterministic control and data commands, such as those in the guarded command language if 6 1 - > 5 i | ) . . . , | & f c - > S f c f i do bi -»• Si |,... , j bk -» Sk od (Dijkstra [1976]), or the non-deterministic assignment x := y.$(x,y),
where $ is some condition relating y to x (Back [1983]), or the random assignment x :=? (Apt and Plotkin [1986]), are needed to express appropriately the design of an algorithm. We have examined some of these non-deterministic constructs in section 5, where we showed, for example, that the random assignment defines projectively semicomputable sets. In building a generalisation, it is prudent to concentrate on making a comprehensive deterministic theory, having clear relations with 'classical' computability theory on N, and its applications to other data types such as K. Technically, to appreciate non-deterministic constructs, a deterministic theory is a necessary prerequisite. Unfortunately, there are unanswered
Computable functions on algebras
489
questions as to the nature of the relationships between non-determinism, specification and non-computability, and (correspondingly) between determinism, implementation and computability. The programming of computations involving non-deterministic aspects of control, concurrency and communication is also an important topic that we leave unexplored. (We have dealt with synchronous concurrency in concurrent assignments and in the scheme of simultaneous primitive recursion in section 8.1.) We will return to the broad theme of programming languages and computability theory in section 8.9. Here we will briefly draw attention to a body of early work on the computational power of elementary control and data structures. The systematic classification of programming features such as iterations, recursions, 'goto's, arrays, stacks, queues and lists seems to have begun in earnest with Luckham et al. [1970] and Paterson and Hewitt [1970]. The central notions are that of a program scheme and its interpretation in a model, and that of the equivalence of program schemes in all models. These ideas may be considered as technical precursors of the corresponding syntactic and semantic concepts we use here, namely: program, state transformer semantics, abstract data type, equivalence on K. The importance of a general syntactic notion of a program scheme that can be applied to abstract structures was discussed in Luckham and Park [1964] and Engeler [1967]. We note that in the latter paper computation over arbitrary classes of structures is treated in the course of analysing program termination by means of logical formulae from a simple fragment of CWltlt>; Engeler [1967] is the origin of algorithmic and dynamic logic. The study of the power of programming features came to be known as program schematology. Like program verification, the subject was contemporary with, but independent of, research on programming language semantics. The necessity of introducing abstract structures in such a classification project is easy to understand. From the point of view of programming theory the equivalence of most algorithmic formalisms for computing on N with the partial recursive functions on N is a mixed blessing. This stability of the computational models illuminates our perception of the scope and limits of computer languages and architectures, and has many technical applications in the mathematical theory of computation. However, the restriction to N fails to support an analysis of the intuitive differences between programming with and without arrays, 'goto's, Boolean variables, and so forth. The research on schematology has produced several program constructs and languages that are weaker than or equivalent to those of the four basic machine models discussed in section 8.2. We refer the reader to Greibach [1975] for a general introduction to schematology and, in particular, to Shepherdson [1985] for a detailed discussion of many important results and their relation to machine models. Other significant references are Constable and Cries [1972], Chandra [1973] and Chandra and Manna [1972].
490
J. V. Tucker and J. I. Zucker
High-level imperative programming models were slow to enter mainstream computability theory, despite attention being drawn to the value of this approach in Scott [1967]. Some early textbooks to feature such programming models were Brainerd and Landweber [1974], Manna [1974], Bird [1976] and Clark and Cowell [1976].
8.4
Axiomatic methods
In an axiomatic method one defines the concept of a computation theory as a set Q(A) of partial functions on an algebra A having some of the essential properties of the set of partial recursive functions on N. To take an example, Q(A) can be required to contain the basic algebraic operators of A; be closed under operations such as composition; and, in particular, possess an enumeration for which appropriate universality and s-m-n properties (see, for example, Rogers [1967]) are true. Thus in section 4 we saw that While* (A) is a computation theory in this sense. It is important to note that computation theory definitions, of which there are a number of equivalent examples, require N to be part of the underlying structures A for the indexing of functions: axiomatic methods specifically address N-standard structures and classes of N-standard structures. With reference to the definition sketched above, the following theorem is of importance here: Theorem 8.13. The set While* (A) of While* computable functions on an N-standard algebra A is the smallest set of partial functions on A to satisfy the axioms of a computation theory; in consequence, While* (A) is a subset of every computational theory Q(A) on A. The definition of a computation theory used here is from Fenstad [1975; 1980] which take up the ideas in Moschovakis [1971]. We note that the While computable functions coincide with the prime computable functions of Moschovakis. Theorem 8.13 can be deduced using work in Moldestad et ai [I980b]; see also Fenstad [1980, Chapter 0]. The development of axiomatisations of computable functions includes Strong [1968] and Wagner [1969]. The axiomatisation of subrecursive functions is tackled in Heaton and Wainer [1996].
8.5
Equational definability
One of the earliest formalisations of effective computability was by means of functions effectively reckonable in an equational calculus, a method known as equational or Herbrand-Godel-Kleene definability. This was the method employed to define the recursive functions in important works such as Church [1936] and Kleene [1952].
Computable functions on algebras
491
Equational definability may be generalised from N to an arbitrary algebra A with the natural result that, if A is an TV-standard structure, equational definability is equivalent with While* computability. The first attempt at such a generalisation is Lambert [1968]. We sketch a simpler treatment from Moldestad and Tucker [1981], adapted to many-sorted algebras. First we choose a language Eqn= Eqn(£) for defining equations over a signature S and transforming them in simple deductions. Let Eqn have constants a, 6, c,... and variables x, y, z,... for data; and variables p,q,r,... for functions. Using the basic operations of the signature, we inductively define E-terms t,... in the usual way. An equation in Eqn is an expression e = (ti = t^), where t\ and t% are terms of the same sort. A deduction of an equation e from a set of equations E is a list e\,... ,ek of equations such that for each i = 1,... , k one of the following holds: (*) et € E; (ii) ei is obtained from BJ for some j < i by replacing every occurrence of a variable x in BJ by a constant c; (Hi) et is obtained from ej for some j < i by replacing at least one occurrence of a subterm t of Cj by a constant c, where t has no free variables, and for some j' < i, ej> = (t = c). An equation e is defined to be formally derivable or deducible from E, written E h e, if there is a deduction of e from E. Thus, it remains to formulate equational deductions with respect to a given algebra A of signature E in order to formulate what it means for a function / on A to be equationally definable on A. This is essentially giving our system a semantics. The first semantical problem is to allow the basic operations of A to play a role in deductions from a set of equations E, and this is accomplished by permitting
E\-p(c1,...,cn) = c if FA(cA,...,cA) = CA. This is the reason why we add the constants to Eqn. The second semantical problem is to prove a single-valuedness property of the form: E\-p(a,... ,c n ) = 01 and E\-p(ci,... ,cn) = a2
=>
01 = a 2 .
This done, we can define / : Au -> A to be equationally definable over A if for some finite set of equations E and some function symbol p, E\-p(Cl,... ,cn) = c =»• f(cA,... ,CA) = CA for all constants of Eqn. Let Eqn(A) denote the set of all equationally definable functions on A.
492
J. V. Tucker and J. I. Zucker
Theorem 8.14.
(a) For any standard 'E-algebra A, Eqn(A) = FAPS(A). (b) For any N-standard E-algebra A, Eqn(A) = FAPCS(A) = While* (A).
8.6
Inductive definitions and fixed-point methods
The familiar definition of the recursive functions on N based on the primitive recursion scheme of Dedekind and Godel, and the least number operator of Kleene, appeared in Kleene [1936]. Kleene provided a thorough revision of the process of recursion on N sufficiently general to include recursion in objects of higher function type: see Kleene [1959; 1963]. In Platek [1966] there is an abstract account of higher-type recursion. Studies of higher type inductive definitions have been taken up by D. Scott and Y. Ershov, whose work forms part of domain theory (see, for example, Stoltenberg-Hansen et al. [1994]). The central technical notion is that of fixed points of higher type operators. In Moldestad et al. [I980a] Platek's methods were analysed and classified in terms of the machine models of section 8.2. Like equational definability, definability by fixed-point operators applies to an arbitrary algebra A and is there equivalent to fapS computability. Thus, this notion coincides with While* definability in an JV-standard structure. We will sketch the method (adapted to many-sorted algebras). First we construct the language FPD= FPD(S) for defining fixedpoint operators. Let FPD have the data and function variables of Eqn, the equation language of section 8.5. Using the basic operations of the signature £ and the A-abstraction notation, we create a set of fixed-point terms of both data and function types: t
::=
x\p\F\T(ti,...,tn)\fy[>(p-yi,...,yn-t].
Here p is a function variable, F is a basic operation of S, T is a term of type function, t\,... ,tn and t are terms of type data, and y\,... , y n are data variables. Each term defines a function on each algebra A of signature E. The definition of the semantics of terms is by induction on their construction, the terms of the form f p [ A p - j / i , . . . ,yn-t] being assigned the unique least fixed point of the continuous monotonic operator defined by the notation Xp • y\,... , yn • t. A function / : Au —¥ A is definable by fixed-point terms over A if there is a term t such that for all x € Au, f ( x ) ~ t(x). Let FPD(A) denote the set of all functions definable by fixed-point terms over A.
Computable functions on algebras
493
Theorem 8.15. (a) For any standard 2,-algebra A, FPD(A) = FAPS(A). (b) For any N-standard 'S-algebra A, FPD(A) = FAPCS(A) = While* (A). For more details see Moldestad et al. [I980a]. An approach to computation on abstract data types, alternative to that presented in this chapter, is the development in Feferman [I992a; 1992b] of a theory of abstract computation procedures, defined by least fixed-point schemes, influenced by Moschovakis [1984; 1989]. The 'abstract data types' here are classes of structures similar to our standard partial many-sorted algebras, abstract in the sense that they are closed under isomorphism, and the computation procedures are abstract in the sense that they are isomorphism invariant on the data types; cf. Theorem 3.24. Types (or sorts) and operations can have an intensional or extensional interpretation. Another treatment of inductive definitions (also influenced by Moschovakis) and a survey of their connections with machine models is given in Hinman [1999].
8.7
Set recursion
Given a structure on A one can construct a set-theoretic hierarchy H(A.) over A, taking A as so-called urelements, and, depending upon the construction, develop a recursion theory on H(A). This is the methodology in Normann [1978] where combinatorial operations on sets are employed to make a generalisation of computability. In Moldestad and Tucker [1981], Normann's set recursion schemes are applied to the domain HF(A), the set of hereditarily finite subsets, so as to invest the general construction with computational content. HF(A) is inductively defined as follows: (t) A C HF(A); (ii) if a i , . . . ,a n e HF(A)then {ai,... ,a n } € HF(A), n > 0. Thus, 0 EHF(A), a copy of N is imbedded in HF(A), and copies of An (n = 2,3,...) are embedded in HF(A). From computability on HF(A) a notion of computability on A, set recursiveness, is easily obtained. Then, writing SR(A) for the class of set-recursive functions on A, we have: Theorem 8.16. For any standard H-algebra A, SR(A) = While" (A).
8.8
A generalised Church—Turing thesis for computability
The While* computable functions are a mathematically interesting and useful generalisation of the partial recursive functions on N to abstract
494
J. V. Tucker and J. I. Zucker
many-sorted algebras A and classes K of such algebras. Do they also give rise to an interesting and useful generalisation to A and K. of the ChurchTuring thesis, concerning effective computability on N? They do; though this answer is difficult to explain fully and briefly. In this section we will only sketch some reasons. The issues are discussed in more detail in Tucker and Zucker [1988]. Consider the following naive attempt at a generalisation of the ChurchTuring thesis. Thesis 8.17 (A naive generalised Church-Turing thesis for computability). (a) The functions 'effectively computable' on a many-sorted algebra A are precisely the functions While* computable on A. (b) The families of functions 'effectively computable' uniformly over a class K of such algebras are precisely the families of functions uniformly While* computable over K. Consider now: what can be meant by 'effective computability' on an abstract algebra or class of algebras? In the standard situation of calculation with N, the idea of effective computability is complicated, as it is made up from many philosophical and mathematical ideas about the nature of finite computation with finite or concrete elements. For example, its analysis raises questions about the mechanical representation and manipulation of finite symbols; about the equivalence of data representations; and about the formalisation of constituent concepts such as algorithm; deterministic procedure; mechanical procedure; computer program; programming language; formal system; machine; and the functions definable by these entities. The idea of effective computability is particularly deep and valuable because of the close relationships that can be shown to exist between its distinct constituent concepts. However, only some of these constituent concepts can be reinterpreted or generalised to work in an abstract setting; and hence the general concept, and term, of 'effective computability' does not belong in a generalisation of the Church-Turing thesis. In addition, since finite computation on finite data is truly a fundamental phenomenon, it is approriate to preserve the term with its established special meaning. In seeking a generalisation of the Church-Turing thesis we are trying to make explicit certain primary informal concepts that are formalised by the technical definitions, and hence to clarify the nature and use of the computable functions. We will start by trying to clarify the nature and use of abstract structures. There are three points of view from which to consider the step from concrete structures to abstract structures, and hence three points of view from which to consider the While* computable functions. First, there is abstract algebra, which is a theory of calculation based upon the 'behaviour' of elements in calculations without reference to their
Computable functions on algebras
495
'nature'. This abstraction is achieved through the concept of isomorphism between concrete structures; an abstract algebra A is 'a concrete algebra considered unique only up to isomorphism'. Secondly, there is formal logic, which is a theory about the scope and limits of axiomatisations and formal reasonings. Here structures and classes of structures are used to discuss formal systems and axiomatic theories in terms of consistency, soundness, completeness, and so on. Thirdly, in programming language theory, there is data type theory, which is about data types that users may care to define and that arise independently of programming languages. Here structures are employed to discuss the semantics of data types, and isomorphisms are employed to make the semantics independent of implementations. In addition, axiomatic theories are employed to discuss their specifications and implementation. Data type theory is built upon and developed from the first two subjects: it is our main point of view. Computation in each of the three cases is thought of slightly differently. In algebra, it is natural to think informally of algorithms built from the basic operations that compute functions and sets in algebras, or over classes of algebras uniformly. In formal logic, it is natural to think of formulae that define functions and sets, and their manipulation by algorithms. In data type theory, we use programming languages to define a computation. Each of these theories, because of its special concerns and technical emphasis, leads to its own theory of computability on abstract structures. Suppose, for example, the While* computable functions are considered with the needs of doing algebra in mind. Then the context of studying algorithms and decision problems for algebraic structures (groups, rings and fields, etc.) leads to a formalisation of a generalised Church-Turing thesis tailored to the language and use of an algebraist: Thesis 8.18 (Generalised Church-Turing thesis for algebraic computability). (a) The functions computable by finite deterministic algebraic algorithms on a many-sorted algebra A are precisely the functions While* computable on A. (b) The families of functions uniformly so computable over a class K of such algebras are precisely the families of functions uniformly While* computable over K. An account of computability on abstract structures from the point of view of algebra is given in Tucker [1980]. Now suppose that the While* computable functions are considered with the needs of computer science in mind. The context of studies of data types, programming and specification constructs, etc., leads to a formulation tailored to the language and use of a computer scientist: Thesis 8.19 (Generalised Church—Turing thesis for programming
496
J. V. Tucker and J. I. Zucker
languages). Consider a deterministic programming language over an abstract data type dt. (a) The functions that can be programmed in the language on an algebra A which represents an implementation of dt, are the same as the functions While* programmable on A. (b) The families of functions that can be programmed in the language uniformy over a class K of implementations of dt, are the same as the families of functions While* programmable over K The thesis has been discussed in Tucker and Zucker [1988]. The logical view of computable functions and sets, with its focus on axiomatic theories and reasoning, is a more abstract view of computation than the view from algebra and data type theory, with their focus on algorithms and programs. The logical view is directed at the specification of computations.
8.9
A Church-Turing thesis for specification
In the course of our study, we have met logical and non-deterministic languages that define in a natural way the projectively computable sets (and, equivalently, the projectively semicomputable sets). These languages are motivated by the wish to specify problems and computations, and to leave open all or some of the details of the programs that will solve the problems and perform the computations. To better understand the role of the projective computable sets, we introduce the idea of an algorithmic specification language which includes some ideas about non-deterministic programming languages. The properties that characterise an algorithmic specification language are forms of algorithmically validating a specification. An algorithmic specification language is an informal concept that is intended to complement that of a deterministic programming language. The problem we consider is that of formalising the informal notion of an algorithmic specification language by means of a generalised Church-Turing thesis for specification, based on projectively computable sets. There are four basic components to a computation: (0) a data type; (1) a specification of a task to be performed or problem to be solved; (2) specifications for algorithms whose input/output behaviour accomplishes the task or solves the problem; and (3) algorithms with appropriate i/o behaviour. We model mathematically these components of a computation, by assuming that: (0°) a data type is a many-sorted algebra, or class of algebras; (1°) a specification of the task or problem is defined by a relation on the algebra;
Computable functions on algebras
497
(2°) specifications of algorithms for the task or problem are defined by functions on the algebra; and (3°) algorithms are defined by programs that compute functions on the algebra. Usually, the relations, functions and programs are defined uniformly over a class of algebras. Given a specification S C Au x Av on an algebra A, the task is: for all x € Au, to calculate all or some y € Av such that R(x, y) holds, if any such y exist. The set D =df
{x€A»\3yR(x,y)}
may be called the domain of the task. Thus the task of computing the relation can be expressed in the following functional form: R: Au -» P(AV) (where P(A") is the power set of Av), defined for x € Au by
R(x) =4 {y e A* \ R(x,y)}. Quite commonly, the task is 'simplified' to computing one or more so-called selection functions for the relation. Definition 8.20 (Selection functions). Let R C Au x Av be a relation. A function / : Au -» Av is a selection function for R if (i) Vx[3yR(x,y) =» f(x) | and R(x,f(x))]; and (it) Vx[/(ar)4, =**(*,/(*))]. Notice that the domain and range of a selection function / are projections: dom(f) ran(f)
= {xeAu\3yR(x,y)}, = {y € Av \ 3xR(x,y)}.
Note also that any partial function f is definable as the unique selection function for its graph G(f) = {(x,y) \ f ( x ) | y}. Other sets of use in specification theory can be derived from these sets (e.g. weakest preconditions and strongest postconditions — see Tucker and Zucker [1988]).
498
J. V. Tucker and J. I. Zucker
To define and reason about computations on a data type, we must define a class of relations, functions and programs on an algebra A. The key ideas are those of formal languages that define functions, called programming languages, and those that define relations, called specification languages. The relation between a programming language P and a specification language S is that of satisfaction \= C
PxS
defined for p e P and s 6 S by p (= s •<=>•
the function defined by p is a selection function for the relation defined by s.
What properties of relations are needed for a specification language? We propose two properties. The first is that it should be possible to 'validate' ('test', 'check', ...) data against each specification. A basic question is, therefore: For any given data x and y, can we validate whether or not the given y is a valid output for the given input x ? We define the following informal concept: Definition 8.21 (Algorithmic specification language). An algorithmic specification language is a language in which any data for any task can be validated. The process of validation depends on the relations defined by the specification. Our theory of computability on algebras presents three cases: Definition 8.22 (Algorithmic validation of specifications). Let 5 be a specification language. (a) S has decidable validation if each relation it defines is computable. (b) S has semidecidable validation if each relation it defines is semicomputable. (c) 5 has projectively decidable validation if each relation it defines is projectively computable. The second property is 'adequacy'. A specification language may be quite expressive, containing specifications for tasks for which there does not exist an algorithmic solution. It should, however, be capable of expressing at least all those tasks which are algorithmic. We therefore define the following informal concept: Definition 8.23 (Adequate specification language). A specification language is adequate if all computations can be specified in it.
Computable functions on algebras
499
To specify a function is to define a relation for which it is a selection function. Recall that any function is definable as the unique selection function for its graph. Consider the adequacy of an algorithmic specification language with each of the three types of algorithmic validation above. (a) If a specification language has decidable validation then not every partial computable function can be specified uniquely, since the graph of a partial computable function need not be computable (by a standard result of classical computation theory). (6) If a specification language has semidecidable validation then every partial computable function can be specified uniquely, since the graph of a partial computable function is semicomputable. (c) Thus a specification language with projectively decidable validation is also adequate for the definition of all possible computations. Furthermore, there are many occasions when the adequacy of a specification formalism demands greater expressiveness. The problem is to allow a class of specifications that extends that of the semicomputable relations, and yet retains some chance of an effective test or check. For example, let E C A be a computable subset of an algebra A and consider the membership relation for the subalgebra (E) of A generated by E; using established notations, this is defined by: a<=(E) <£> 3k>Q3ei,... ,ek € E3t € Term(S)[T£7(t,e 1) ... ,ek) = a}. This relation is not semicomputable, nor even projectively computable over A, but projectively computable over A* . In examples of the above kind, the computation and specification of y from x involves a finite sequence of auxiliary data z* that is 'hidden' from R, but can be recovered from the specification and algorithm. This type of specification R has the form
where RQ is computable. That is, R is projectively computable (or semicomputable) over A* . This is a weak form of the concept of a specification that can be validated algorithmically. We have seen a number of methods, involving logical and non-deterministic languages, all of which define the projections of computable sets (or, equivalently, of semicomputable sets); we recall them briefly: (i) Projections in first-order languages. Consider the first-order languages
Lang(£)
and
Lang(£*)
over the signatures E and S* with their usual semantics. The relations that are EX definable in these languages are the projectively While and While* computable sets.
500
J. V. Tucker and J. I. Zucker
(ii) Horn clause languages. In Tucker and Zucker [1989; 1992a] we studied a generalisation of logic programming languages based on Horn clauses, and a semantics based on resolution. The relations definable in this specification-cum-programming language were the projectively While* computable sets. The logic programming model was shown to be equivalent to certain classes of logically definable functions (Fitting [1981]). (Hi) Other definabilities. In Fitting [1981] the relations are shown to be equivalent to those definable in Montague [1968]. Hence, by work in Gordon [1970], these all coincide with the search computable functions of Moschovakis [l969a]. A summary of these results is contained in Tucker and Zucker [1988, section 7]. (iv) Non-deterministic programming languages. Finally, recall from section 5 that we have seen that constructs allowing non-deterministic choices of data, state, or control in programming languages also lead to the projectively computable sets. In particular, the models While* computability with initialisation and While* computability with random assignments were analysed. The equivalence results suggest that the concepts of projective computablity and semicomputability are stable in the analysis of models of specification. The concept of an algorithmic specification language in its weak form, together with all the above equivalence results, leads us to formulate the following generalised Church-Turing thesis for specification, to complement that for computation: Thesis 8.24 (Generalised Church—Turing thesis for specification on abstract data types). Consider an adequate algorithmic specification language S over an abstract data type dt. (a) The relations on a many-sorted algebra A implementing dt that can be specified in S are precisely the projectively While* computable relations on A. (b) The families of relations over a class K of such algebras implementing dt, that can be specified in S, uniformly over K, are precisely the families of uniformly projectively While* computable relations over
This thesis has been discussed in Tucker and Zucker [1988].
8.10
Some other applications
Computations on many-sorted algebras lead to many investigations and applications. We conclude by mentioning two.
Computable functions on algebras
501
(i) Provably computable selection functions. In this chapter we have not dealt with proof systems, or the connections between provability and computability. In Tucker and Zucker [1988] we developed one such connection, namely the use of proof systems for verifying program correctness. Another connection is based on classical proof theory, and its application to computability on the naturals. In Tucker et al. [1990] and Tucker and Zucker [1993] we investigated the generalisation of a particular problem in classical proof theory to the context of ^-standard many-sorted signatures and algebras. Specifically, we developed classical and intuitionistic formal systems for theories over AT-standard signatures S. We showed, in the case of universal theories (i.e., theories with axioms containing only universal quantifiers) that, in either of these systems: if an existential assertion is provable, then it has a PR* (£) selection function. (Recall the discussion of selection functions in section 8.9.) It follows that if a (j,PR* (£) function scheme is provably total, then it is extensionally equivalent over S to a P.R*(S) scheme. The methods are proof-theoretical, involving cut elimination. These results generalise to an abstract setting previous results of Parsons [1971; 1972] and Mints [1973] over the natural numbers. (if) Computation on stream algebras. A stream over a set A is a sequence of data from A ... , o(t), ... indexed by time t 6 T. Discrete time T is modelled by the naturals N, and the space of all streams over A is the set [N -> A] of functions from N to A. Streams are ubiquitous in computing. In hardware, where clocking and timing are important, most systems process streams (see McEvoy and Tucker [1990] and Moller and Tucker [1998]). Models of stream computation are needed for any wide spectrum specification method such as FOCUS (see Broy et al. [1993]). A general theory of stream processing is given in Stephens [1997]. There is a strong need to incorporate stream computation in a general theory of computation on many-sorted algebras. Some first steps in this direction, partly motivated by technical questions arising in an algebraic study of stream processing by synchronous concurrent algorithms (see Thompson and Tucker [1991]), were taken in Tucker and Zucker [1994; 1998]. Another approach to this problem has been developed in Feferman [1996], within (an extensional version of) the framework of computation theory on abstract data types presented in Feferman [l992a; 1992b], as summarised in section 8.6. The relationship between these two theories of stream computations remains to be investigated.
502
J. V. Tucker and J. I. Zucker
We conclude with a brief survey of the former approach (Tucker and Zucker [1994]). Here we consider the following problem: Given a algebra A (which we suppose for notational simplicity is single-sorted), consider stream transformations of the form / : [N-^]"1-^-^] as well as their cartesian or uncurried forms cart(f) : [N -*A]m x N ->• A defined by We ask the following questions. For any algebra A, what are the computable stream transformations over A ? What is their relation to the computable functions on A? To answer these, we extend A to the stream algebra A (section 2.8), and consider various models of computation MC(A) over A, as well as the corresponding models of computation MC(A) over A. These models of computation MC include the schemes PR,
PR*,
fj,PR,
uPR*.
We also consider the operation of stream abstraction or currying inverse to cart: for any function g: D x N-> A, where D is any cartesian product of carriers of A, construct the function \abs(g) : £>->[N-»yi] defined by
(\aba(g))(d)(n)
= g(d,n).
The addition of this construct to models of computation MC leads to models of computation XM.C(A): XPR,
\PR*,
XpPR,
\nPR*.
We investigate the relationships between these various models; for example, we prove some computational conservativity results: for any function / on A,
fePR(X)
^=* fePR(A)
and similarly for \PR*: XfiPR and \/j,PR*. We also show that computability is not invariant under Cartesian forms, i.e., there are functions / such that
Computable functions on algebras / i PR(A)
but
503
cart(f) e PR(A)
and similarly for XPR*, XfiPR and X^iPR*. Further, 'A-elimination' does not hold, i.e., there are functions / such that / € XPR(A)
but
/ i PR(A);
for example, the function const"4: A -t [N -> A], which maps data a € A to the stream const"4(a) € [N -*A] with constant value a, is in XPR(A) but not in PR(A), or even in fiPR*(A). However, we do have X-elimination + cartesian form, in the sense that f€XPR(A)
^ cart(f) € PR(A),
and similarly for XPR*, Xp,PR and XpPR*. There are advantages to working with stream transformers via their cartesian forms. It is then true, but difficult to show, that the class of computable functions so denned is closed under composition (Stephens and Thompson [1996]). Suppose now we ask for a model of computability to satisfy a generalised Church-Turing thesis for stream computations. The model nPR*(A) obtained from our previous generalised Church-Turing thesis on arbitrary standard algebras (section 8.8, substituting A for A) would be too weak, since (as we have seen) even the constant stream function const"4 is not computable in it. However, we can show, as a corollary of the computational conservativity results, that the following models of computation are equivalent: XfiPR(A), Xfj,PR(A), XnPR*(A), XnPR(A*). This shows that the model \HPR(A) is robust, and suggests it as a good candidate for a generalised ChurchTuring thesis for stream computations. (Hi) Equational specification of computable functions. Many functions are defined as solutions of systems of equations from, for example, datatype theory or real analysis. Sometimes considerable effort is expended in devising algorithms to implement or compute these functions; this is the raison d'etre of numerical methods for differential and integral equations. It is possible to develop a theory of equational specifications for functions on algebras, including topological algebras. In Tucker and Zucker [2000b] it is shown that any While* approximable function on a total metric algebra is the unique solution of a finite system of conditional equations, which can be chosen uniformly over all algebras of the signature, and over all While* computations. The converse however is not true; specifiability by conditional equations is a more powerful device than While* approximation - how much more powerful, remains to be investigated.
504
J. V. Tucker and J. I. Zucker
References The great majority of the publications listed here are referenced in the text. Some papers, however, marked with a star next to the date, are not so referenced. They are included here as a guide to further reading, either because they shed some light on the historical development of the subject, or because they provide useful further information in certain areas, such as program verification and computation on the reals. [American Standards Association, 1963] American Standards Association. Proposed American standard flowchart symbols for information processing, Communications of the Association for Computing Machinery 6:601-604, 1963. [Apt, *198l] K. R. Apt. Ten years of Hoare's logic: A survey — Part 1, ACM Transactions on Programming Languages and Systems 3:431-483, 1981. [Apt and Plotkin, 1986] K. R. Apt and G. D. Plotkin. Countable nondeterminism and random assignment, Journal of the Association for Computing Machinery, 33:724-767, 1986. [Arbib and Give'on, *1968] M. A. Arbib and Y. Give'on. Algebra automata I: Parallel programming as a prolegomena to the categorical approach, Information and Control 12:331-345, 1968. [Ashcroft and Manna, *197l] E. Ashcroft and Z. Manna. The translation of 'go to' programs to 'while' programs, Information Processing, 71:147152, 1971. [Ashcroft and Manna, *1974] E. Ashcroft and Z. Manna. Translation program schemas to while-schemas, SIAM Journal of Computing 4:125-146, 1974. [Asser, *1960] G. Asser. Rekursive Wortfunktionen, Zeitschrift fur mathematische Logik und Grundlagen der Mathematik 6:258-278, 1960. [Asser, 1961] G. Asser. Funktionen-Algorithmen und Graphschemata, Zeitschrift fur mathematische Logik und Grundlagen der Mathematik 7:20-27, 1961. [Back, 1983] R. J. R. Back. A continuous semantics for unbounded nondeterminism, Theoretical Computer Science 23:187-210, 1983. [de Bakker, 1980] J. W. de Bakker. Mathematical Theory of Program Correctness, Prentice Hall, 1980. [Banachowski et al., *1977] L. Banachowski, A. Kreczmar, G. Mirkowska, H. Rasiowa and A. Salwicki. An introduction to algorithmic logic, mathematical investigations in the theory of programs. In Mathematical Foundations of Computer Science, A. Mazurkiewicz and Z. Pawlak eds, pp. 7-99, Banach Center Publications, 1977. [Barwise, *1975] J. Barwise. Admissible Sets and Structures, SpringerVerlag, 1975.
Computable functions on algebras
505
[Becker, 1986] E. Becker. On the real spectrum of a ring and its application to semialgebraic geometry, Bulletin of the American Mathematical Society (N.S.) 15:19-60, 1986. [Bergstra and Tucker, *1980a] J. A. Bergstra and J. V. Tucker. A natural data type with a finite equational final semantics specification but no effective equational initial semantics specification. Bulletin of the European Association for Theoretical Computer Science 11:23-33, 1980. [Bergstra and Tucker, *1980b] J. A. Bergstra and J. V. Tucker. A characterisation of computable data types by means of a finite equational specification method. In 7th International Colloquium on Automata, Languages and Programming, Noordwijkerhout, The Netherlands, July 1980. J. W. de Bakker and J. van Leeuwen eds, Lecture Notes in Computer Science 85, pp. 76-90, Springer-Verlag, 1980. [Bergstra and Tucker, *1982a] J. A. Bergstra and J. V. Tucker. The completeness of the algebraic specification methods for data types, Information & Control 54:186-200, 1982. [Bergstra and Tucker, *1982b] J. A. Bergstra and J. V. Tucker. Some natural structures which fail to possess a sound and decidable Hoare-like logic for their while-programs, Theoretical Computer Science 17:303-315, 1982. [Bergstra and Tucker, *1982c] J. A. Bergstra and J. V. Tucker. Expressiveness and the completeness of Hoare's logic, Journal of Computer & Systems Science 25:267-284, 1982. [Bergstra and Tucker, *1982d] J. A. Bergstra and J. V. Tucker. Two theorems about the completeness of Hoare's logic, Information Processing Letters, 15:143-149, 1982. [Bergstra and Tucker, *1983a] J. A. Bergstra and J. V. Tucker. Hoare's logic and Peano's arithmetic, Theoretical Computer Science 22:265-284, 1983. [Bergstra and Tucker, *1983b] J. A. Bergstra and J. V. Tucker. Initial and final algebra semantics for data type specifications: two characterization theorems, SIAM Journal of Computing 12:366-387, 1983. [Bergstra and Tucker, *1984a] J. A. Bergstra and J. V. Tucker. Hoare's logic for programming languages with two data types, Theoretical Computer Science 28:215-221, 1984. [Bergstra and Tucker, *1984b] J. A. Bergstra and J. V. Tucker. The axiomatic semantics of programs based on Hoare's logic, Acta Informatica 21:293-320, 1984. [Bergstra and Tucker, *1987] J. A. Bergstra and J. V. Tucker. Algebraic specifications of computable and semicomputable data types, Theoretical Computer Science 50:137-181, 1987. [Bergstra et al, *1982] J. A. Bergstra, J. Tiuryn and J. V. Tucker. Floyd's principle, correctness theories and program equivalence, Theoretical Computer Science 17:113-149, 1982.
506
J. V. Tucker and J. I. Zucker
[Bird, 1976] R. Bird. Programs and Machines: An Introduction to the Theory of Computation, John Wiley and Sons, 1976. [Bishop, 1967] E. Bishop. Foundations of Constructive Analysis, McGrawHill, 1967. [Bishop and Bridges, 1985] E. Bishop and D. Bridges. Constructive Analysis, Springer-Verlag, 1985. [Blanck, 1997] J. Blanck. Domain representability of metric spaces, Annals of Pure and Applied Logic 83:225-247, 1997. [Blum and Smale, 1993] L. Blum and S. Smale. The Godel incompleteness theorem and decidability over a ring. In From Topology to Computation: Proceedings of the Smalefest, M. W. Hirsch, J. E. Marsden and M. Schub eds, pp. 321-339, Springer-Verlag, 1993. [Blum et al., 1989] L. Blum, M. Shub and S. Smale. On a theory of computation and complexity over the real numbers: NP-completeness, recursive functions and universal machines, Bulletin of the American Mathematical Society 21:1-46, 1989. [Blum et al., 1996] L. Blum, F. Cucker, M. Shub and S. Smale. Complexity and real computation: A manifesto, International Journal of Bifurcation and Chaos 6(l):3-26, 1996. [Bohm and Jacopini, 1966] C. Bohm and G. Jacopini. Flow diagrams, Turing machines and languages with only two formation rules, Communications of the Association for Computing Machinery, 9:366-371, 1966. [Brainerd and Landweber, 1974] W. S. Brainerd and L. H. Landweber. Theory of Computation, John Wiley & Sons, 1974. [Brattka, 1996] V. Brattka. Recursive characterisation of computable realvalued functions and relations, Theoretical Computer Science 162:45-77, 1996. [Brattka, 1997] V. Brattka. Order-free recursion on the real numbers, Mathematical Logic Quarterly 43:216-234, 1997. [Brocker and Lander, 1975] T. Brocker and L/C. Lander. Differentiate Germs and Catastrophes, London Mathematical Society, Lecture Notes Series 17, Cambridge University Press, 1975. [Brown et al., *1972] S. Brown, D. Gries and T. Szymanski. Program schemes with pushdown stores, SIAM Journal of Computing 1:242-268, 1972. [Broy et al, 1993] M. Broy, F. Dederichs, C. Dendorfer, M. Fuchs, T. F. Gritzner and R. Weber. The design of distributed sytems: An introduction to FOCUS, Technical Report TUM-19202-2, Institut fur Informatik, Technical University of Munich, January 1993. [Burris and Sankappavanar, 1981] S. Burris and H. P. Sankappavanar. A Course in Universal Algebra, Springer-Verlag, 1981. [Byerly, *1993] R. E. Byerly. Ordered subrings of the reals in which output sets are recusively enumerable, Proceedings of the American Mathematical Society 118:597-601, 1993.
Computable functions on algebras
507
[Ceitin, 1959] G. S. Ceitin. Algebraic operators in constructive complete separable metric spaces, Doklady Akademii Nauk SSSR 128:49-52,1959. [Chandra, 1973] A. K. Chandra. On the properties and applications of program schemas, PhD. thesis, Department of Computer Science, Stanford University, 1973. [Chandra, 1974] A. K. Chandra. The power of parallelism and nondeterminism in programming. In Information Processing '74, North-Holland, pp. 461-465, 1974. [Chandra and Manna, 1972] A. K. Chandra and Z. Manna. Program schemes with equality. In Proceedings of the 4th Annual ACM Symposium on the Theory of Computing, Denver, Col. pp. 52-64, Association for Computing Machinery, 1972. [Chandra and Manna, 1975] A. K. Chandra and Z. Manna. On the power of programming features, Journal of Computer Languages 1:219-232, 1975. [Chaplin, 1970] N. Chaplin. Flowcharting with the ANSI Standard, Computer Surveys 2:119-30, 1970. [Church, 1936] A. Church. An unsolvable problem of elementary number theory, American Journal of Mathematics 58: pp. 345-363, 1936. [Clark and Cowell, 1976] K. L. Clark and D. F. Cowell. Programs, Machines and Computation: An Introduction to the Theory of Computing, McGraw-Hill, 1976. [Clarke, *1979] E. M. Clarke, Jr. Programming language constructs for which it is impossible to obtain good Hoare-like axioms, Journal of the ACM 26:126-147, 1979. [Clarke, *1984] E. M. Clarke, Jr. The characterization problem for Hoare logic, Philisophical Transactions of the Royal Society of London J4:312;423-440, 1984. [Clarke et al, *1983] E. M. Clarke, Jr., S. German and J. Y. Halpern. Effective axiomatization of Hoare logics, Journal of the Association for Computing Machinery, 30:612-636, 1983. [Constable and Gries, 1972] R. L. Constable and D. Gries. On classes of program schemata, SIAM Journal of Computing 1:66-118, 1972. [Cook, *1978] S. A. Cook. Soundness and completeness of an axiom system for program verification, SIAM Journal of Computing 7:70-90, 1978; corrigendum [1981], ibid. 10, 612. [Cucker et al., *1994] F. Cucker, M. Shub and S. Smale. Separation of complexity classes in Koiran's weak model, Theoretical Computer Science 13:3-14, 1994. [Cutland, 1980] N. J. Cutland. Computability: An Introduction to Recursive Function Theory, Cambridge University Press, 1980. [Dariko, *1983] W. Dariko. Algebraic properties of finitely generated structures. In Proceedings in Logics of Programs and their Applications,
508
J. V. Tucker and J. I. Zucker
Poznan 1980, A. Salwicki ed., Lecture Notes in Computer Science 148, pp. 118-131, Springer-Verlag, 1983. [Davis, 1958] M. Davis Computability and Unsolvability. McGraw-Hill, 1958. (Reprinted [1983], Dover.) [Davis and Weyuker, 1983] M. D. Davis and E. P. Weyuker. Computability, Complexity, and Languages, Academic Press, 1983. [Davis et al., 1994] M. D. Davis, R. Sigal and E. P. Weyuker. Computability, Complexity, and Languages (2nd edition), Academic Press, 1994. [Devaney, 1989] R. Devaney. An Introduction to Chaotic Dynamical Systems, Addison Wesley, 1989. [Dijkstra, 1976] E. W. Dijkstra. A Discipline of Programming, Prentice Hall, 1976. [Dugundji, 1966] J. Dugundji. Topology, Allyn and Bacon, 1966. [Edalat, 1995a] A. Edalat. Domain theory and integration, Theoretical Computer Science 151:163-193, 1995. [Edalat, 1995b] A. Edalat. Dynamical systems, measures, and fractals via domain theory, Information & Computation 120:32-48, 1995. [Ehrig and Mahr, 1985] H. Ehrig and B. Mahr. Fundamentals of Algebraic Specification 1, EATCS Monographs 6, Springer-Verlag, 1985. [Eilenberg and Elgot, *1968] S. Eilenberg and C. C. Elgot. Iteration and recursion, IBM Research Report RC-2148, 1968. [Eilenberg and Elgot, *1970] S. Eilenberg and C. C. Elgot. Recursiveness, Academic Press, 1970. [Eilenberg and Wright, *1967] S. Eilenberg and J. B. Wright. Automata in general algebras, Information & Control 11:452-470, 1976. [Elgot, *1966a] C. C. Elgot. Abstract algorithms and diagram closure. In Programming Languages, Genuys ed., pp. 1-42, Academic Press, 1966, also: Preprint, IBM Laboratory Vienna (1966) (presented at NATO Summer School on Programming Languages, Villard-de-Lans (Isere), Prance, September 1966). [Elgot, *1966b] C. C. Elgot. A notion of interpretability of algorithms in algorithms, Preprint, IBM Laboratory Vienna (presented at NATO Summer School on Programming Languages, Villard-de-Lans (Isere), Prance, September 1966). [Elgot, *1966c] C. C. Elgot. Machine species and their computation languages. In Formal Language Description Languages for Computer Programming, Proceedings of the IFIP Working Conference on Formal Language Description Languages, Amsterdam, T. B. Steel, Jr., ed., NorthHolland, pp. 160-178, 1966. [Elgot, *1970] C. C. Elgot. The common algebraic structure of exitautomata and machines, IBM Research Report RC-2744, 1970. [Elgot, *197l] C. C. Elgot. Algebraic theories and program schemes. In Symposium on Algorithmic Semantic Languages, E. Engeler ed., Lecture Notes in Mathematics 188, Springer-Verlag, 1971.
Computable functions on algebras
509
[Elgot and Robinson, *1964] C. C. Elgot and A. Robinson. Randomaccess, stored-program machines. An approach to programming Languages, Journal of the Association for Computing Machinery, 11:365399, 1964. [Elgot et ai, *1966] C. C. Elgot, A. Robinson and J. D. Rutledge. Multiple control computer models, IBM Research Report RC-1622, 1966. [Enderton, 1977] H. B. Enderton. Elements of recursion theory. In Handbook of Mathematical Logic, J. Barwise, ed., pp. 527-566, North-Holland, 1977. [Engeler, 1967] E. Engeler. Algebraic properties of structures, Mathematical Systems Theory 1:183-195, 1967. [Engeler, 1968a] E. Engeler. Formal Languages: Automata and Structures, Markham Publishing Co., 1968. [Engeler, 1968b] E. Engeler. Remarks on the theory of geometrical constructions. In The Syntax and Semantics of Infinitary Languages, Lecture Notes in Mathematics 72, pp. 64-76, Springer-Verlag, 1968. [Engeler, 1971] E. Engeler. Structure and meaning of elementary programs. In Symposium on Semantics of Algorithmic Languages, Lecture Notes in Mathematics 188, pp. 89-101, Springer-Verlag, 1971. [Engeler, 1975a] E. Engeler. On the solvability of algorithmic problems, in Logic Colloquium '73, H. E. Rose and J. C. Shepherdson eds, pp. 231-251, North-Holland, 1975. [Engeler, 1975b] E. Engeler. Algebraic logic. In Foundations of Computer Science, Mathematical Centre Tracts No. 63, J. W. de Bakker, ed., Amsterdam, pp. 57-85, 1975. [Engeler, 1993] E. Engeler. Algebraic Properties of Structures, World Scientific, 1993. [Ershov, 1958] A. P. Ershov. On operator algorithms, Doklady Akademii Nauk SSSR 122:967-970, 1958 (in Russian), translated in Automation Express 1:20-23, 1959. [Ershov, I960] A. P. Ershov. Operator algorithms I, Problemi Kibernetiki 3, 1960. (in Russian), translated in Problems of Cybernetics 3, 1962. [Ershov, 1962] A. P. Ershov. Operator algorithms II, Problemi Kibernetiki 8:211-233 (in Russian), 1962. [Ershov, *198l] A. P. Ershov. Abstract computability on algebraic structures. In Algorithms in Modern Mathematics and Computer Science, A. P. Ershov and D. E. Knuth, eds, Lecture Notes in Computer Science 122, Springer-Verlag, 1981. [Ershov and Shura-Bura, 1980] A. P. Ershov and M. R. Shura-Bura. The early development of programming in the USSR. In A History of Computing in the Twentieth Century, E. N. Metropolis, J. Hewlett and G.-C. Rota eds, pp. 137-196, Academic Press, 1980. [Feferman, 1992a] S. Feferman. A new approach to abstract data types, I:
510
J. V. Tucker and J. I. Zucker
Informal development, Mathematical Structures in Computer Science 2: pp. 193-229, 1992. [Feferman, 1992b] S. Feferman. A new approach to abstract data types, II: Computability on ADTs as ordinary computation. In Computer Science Logic, E. Borger, G. Jager, H. Kleine Biining and M. M. Richter eds, Lecture Notes in Computer Science 626, pp. 79-95, Springer-Verlag, 1992. [Feferman, 1996] S. Feferman. Computation on abstract data types: The extensional approach, with an application to streams, Annals of Pure and Applied Logic 81:75-113, 1996. [Fenstad, 1975] J. E. Fenstad. Computation theories: an axiomatic approach to recursion on general structures. In ISILC Logic Conference, Kiel 1974, G. Miiller, A. Oberschelp and K. Potthoff eds, Lecture Notes in Mathematics 499, pp. 143-168, Springer-Verlag, 1975. [Fenstad, 1980] J. E. Fenstad. Recursion Theory: An Axiomatic Approach, Springer-Verlag, 1980. [Fitting, 1981] M. Fitting. Fundamentals of Generalized Recursion Theory, North-Holland, 1981. [Floyd, *1967] R. W. Floyd. Assigning meaning to programs. In Mathematical Aspects of Computer Science, J. T. Schartz ed, pp. 19-32, American Mathematical Society, 1967. [Friedman, 1971a] H. Friedman. Algebraic procedures, generalized Turing algorithms, and elementary recursion theory. In Logic Colloquium '69, R. 0. Gandy and C. M. E. Yates eds, pp. 361-389, North-Holland, 1971. [Friedman, *1971b] H. Friedman. Axiomatic recursive function theory. In Logic Colloquium '69, R. 0. Gandy and C. M. E. Yates eds, pp. 113-137, North-Holland, 1971. [Friedman and Mansfield, *1992] H. Friedman and R. Mansfield. Algebraic procedures, Transactions of the American Mathematical Society 332:297312, 1992. [Gabrovsky, *1976] P. Gabrovsky. Models for an axiomatic theory of computability, PhD thesis, Syracuse University, 1976. [Gandy, *1980] R. 0. Gandy. Church's thesis and principles for mechanisms. In The Kleene Symposium, J. Barwise, H. J. Keisler and K. Kunen eds, pp. 123-148, North-Holland, 1980. [Garland and Luckham, *1973] S. J. Garland and D. C. Luckham. Program schemes, recursion schemes, and formal languages, Journal of Computer and Systems Science 7:119-160, 1973. [Goguen et al, *1978] J. A. Goguen, J. W. Thatcher and E. G. Wagner. An initial approach to the specification, correctness and implementation of abstract data types. In Current Trends in Programming Methodology, 4: Data Structuring, R.T. Yeh ed, pp. 80-149, Prentice Hall, 1978. [Goldstine and von Neumann, 1947] H. H. Goldstine and J. von Neumann. Planning and Coding Problems for an Electronic Computing Instrument,
Computable functions on algebras
511
Institute for Advanced Study, Princeton, 1947. Reprinted in A. H. Traub ed, John von Neumann's Collected Works, 5, pp. 80-235, Pergamon, 1963. [Goodstein, 1964] R. L. Goodstein. Recursive Number Theory, NorthHolland, 1964. [Gordon, 1970] C. E. Gordon. Comparisons between some generalizations of recursion theory, Compositio Mathematica 22:333-346, 1970. [Gordon, *197l] C. E. Gordon. Finitistically computable functions and relations on an abstract structure (abstract), Journal of Symbolic Logic 36:704, 1971. [Gorn, *196l] S. Gorn. Specification languages for mechanical languages and their processors, Communications of the Association for Computing Machinery 4:532-542, 1961. [Grabowski, *198l] M. Grabowski. Full weak second-order logic versus algorithmic logic, In Proceedings in Mathematical Logic in Computer Science, Colloquia Mathematica Societatis Janos Bolyai 26, pp. 471-483, North-Holland, 1981. [Grabowski and Kreczmar, *1978] M. Grabowski and A. Kreczmar. Dynamic theories of real and complex numbers. In Mathematical Foundations of Computer Science '78, J. Winkowski ed., Lecture Notes in Computer Science 64, pp. 239-249, Springer-Verlag, 1978. [Greibach, 1975] S. A. Greibach. Theory of Program Structures: Schemes, Semantics, Verification, Lecture Notes in Computer Science 36, Springer-Verlag, 1975. [Grzegorczyk, 1955] A. Grzegorczyk. Computable functions, Fundamenta Mathematicae 42:168-202, 1955. [Grzegorczyk, 1957] A. Grzegorczyk. On the defintions of computable real continuous functions, Fundamenta Mathematicae 44:61-71, 1957. [Guttag, *1977] J. V. Guttag. Abstract data types and the development of data structures, Communications of the Association for Computing Machinery 20:396-404, 1977. [Harel, *1980] D. Harel. On folk theorems, Communications of the Association for Computing Machinery 23, 1980. [Harel, *1984] D. Harel. Dynamic logic. In Handbook of Philisophical Logic, II, D. Gabbay and F. Guenthner eds, pp. 497-604, Reidel, 1984. [Harel et al., *1977] D. Harel, A. R. Meyer and V. R. Pratt. Computability and completeness in logics of programs. In Proceedings of the 9th Annual ACM Symposium on the Theory of Computing, Boulder, Colorado, 1977. [Harman and Tucker, 1993] N. A. Harman and J. V. Tucker. Algebraic methods and the correctness of microprocessors. In Correct Hardware Design and Verification Methods, G. J. Milne and L. Pierre eds, Lecture Notes in Computer Science 683, pp. 92-108, Springer-Verlag, 1993. [Harnik, *1975] V. Harnik. Effective proper procedures and universal
512
J. V. Tucker and J. I. Zucker
classes of program schemata, Journal of Computer & Systems Science 10:44-61, 1975. [Heaton and Wainer, 1996] A. Heaton and S. Wainer. Subrecursion theories. In Computability, Enumerability, Unsolvability, S. B. Cooper, S. S. Wainer and T. A. Slaman eds, London Mathematical Society Lecture Note Series, Cambridge University Press, 1996. [Hemmerling, *1994] A. Hemmerling. On genuine complexity and kinds of nondeterminism, Journal of Information Processing and Cybernetics 30:77-96, 1994. [Hemmerling, *1995] A. Hemmerling. Computability and complexity over structures of finite type, Preprint Nr. 2-1995, Preprint-Reihe Mathematik, Ernst-Moritz-Arndt-Universitat, Greifswald, 1995. [Hemmerling, *1998] A. Hemmerling. Computability of string functions over algebraic structures, Mathematical Logic Quarterly 44:1-44, 1998. [Herman and Isard, 1970] G. T. Herman and S. D. Isard. Computability over arbitrary fields, Journal of the London Mathematical Society 2:7379, 1970. [Hinman, 1999] P. G. Hinman. Recursion on abstract structures. In Handbook of Computability Theory, E. Griffor ed., pp. 315-359. Elsevier, 1999. [Hoare, *1969] C. A. R. Hoare. An axiomatic basis for computer programming, Communications of the Association for Computing Machinery 12:576-583, 1969. [Hobley et al., *1988] K. M. Hobley, B. C. Thompson and J. V. Tucker. Specification and verification of synchronous concurrent algorithms: a case study of a convoluted algorithm. In The Fusion of Hardware Design and Verification (Proceedings of IFIP Working Group 10.2 Working Conference), G. Milne ed, pp. 347-374, North-Holland, 1988. [Hocking and Young, 1961] J. G. Hocking and G. S. Young. Topology, Addison Wesley, 1961. [Holden et al, 1992] A. V. Holden, M. Poole, J. V. Tucker and H. Zhang. Coupled map lattices as computational systems. American Institute of Physics - Chaos, 2: 367-376, 1992. [lanov, 1960] I. lanov. The logical schemes of algorithms, Problemi Kibernetiki 1:75-127,1958 (in Russian). Translated in Problems of Cybernetics 1:82-140, 1960. [igerashi, *1968] S. Igerashi. An axiomatic approach to the equivalence problems of algorithms with applications, Report from the Computing Centre of the University of Tokyo 1, 1968. [Ivanov, *1986] L. L. Ivanov. Algebraic Recursion Theory, Ellis Horwood, 1986. [Jacopini, *1966] G. Jacopini. Macchina Universale di von Neumann ad unico comando incondizionato, Calcolo 3:23-29, 1966. [Jervis, 1988] C. A. Jervis. On the specification, implementation and verification of data types, PhD thesis, Department of Computer Studies,
Computable functions on algebras
513
University of Leeds, 1988. [Kaluzhnin, 1961] A. Kaluzhnin. Algorithmization of mathematical problems, Problemi Kibernetiki 2, 1959 (in Russian). Translated in Problems of Cybernetics 2, 1961. [Kaphengst, *1959] M. Kaphengst. Eine abstrakte programmgesteuerte Rechenmaschine, Zeitschrift fur mathematische Logik und Grundlagen der Mathematik 5: 366-379, 1959. [Kaplan, *1969] D. M. Kaplan. Regular expressions and the equivalence of programs, Journal of Computer & System Sciences, 3:361-386, 1969. [Karp and Miller, *1969] R. M. Karp and R. E. Miller. Parallel program schemata, Journal of Computer & Systems Science 3:147-195, 1969. [Kelley, 1955] J. L. Kelley. General Topology, Van Nostrand, 1955. Reprinted Springer-Verlag, 1975. [Kfoury, *1972] A. J. Kfoury. Comparing algebraic structures up to algorithmic equivalence. In International Colloquium on Automata, Languages and Programming, Paris, 1972, M. Nivat, ed., pp. 235-264, North-Holland, 1972. [Kfoury, *1983] A. J. Kfoury. Definability by programs in first-order structures, Theoretical Computer Science 25:1-66, 1983. [Kfoury, *1985] A. J. Kfoury. Definability by deterministic and nondeterministic programs (with applications to first-order dynamic logic), Information & Control 65:98-121, 1985. [Kfoury and Park, *1975] A. J. Kfoury and D. M. Park. On the termination of program schemas, Information & Control 29:243-251, 1975. [Kfoury and Urzyczyn, *1985] A. J. Kfoury and P. Urzyczyn. Necessary and sufficient conditions for the universality of programming formalisms, Acta Informatica 22:347-377, 1985. [Kfoury et al, 1982] A. J. Kfoury, R. N. Moll and M. A. Arbib. A Programming Approach to Computability, Springer-Verlag, 1982. [Kleene, 1936] S. C. Kleene. General recursive functions of natural numbers, Mathematische Annalen 112:727-742, 1936. [Kleene, 1952] S. C. Kleene. Introduction to Metamathematics, NorthHolland, 1952. [Kleene, 1959] S. C. Kleene. Recursive functionals and quantifiers of finite types I, Transactions of the American Mathematical Society 91:1-52, 1959. [Kleene, 1963] S. C. Kleene. Recursive functionals and quantifiers of finite types II, Transactions of the American Mathematical Society 108:106142, 1963. [Klop, 1992] J. W. Klop. Term rewriting systems. In Handbook of Logic in Computer Science, Vol. 1, S. Abramsky, D. Gabbay and T. Maibaum eds, pp. 2-116, Clarendon Press, 1992. [Knuth, *1974] D. E. Knuth. Structured programming with 'go to' statements, Computing Surveys 6:261-301, 1974.
514
J. V. Tucker and J. I. Zucker
[Knuth and Prado, *1980] D. Knuth and L. T. Prado. The early development of programming languages. In A History of Computing in the Twentieth Century, N. Metropolis, J. Hewlett and G.-C. Rota eds, pp. 197-273, Academic Press, 1980. [Ko, 1991] K.-I. Ko. Complexity Theory of Real Functions, Birkhauser, 1991. [Kolmogorov, *1953] A. N. Kolmogorov. O ponyatii algoritma, Uspekhi Matematicheskikh Nauk 814:175-176, 1953. [Kreczmar, *1977] A. Kreczmar. Programmability in fields, Fundamenta Informaticae 1:195-230, 1977. [Kreisel, 1971] G. Kreisel. Some reasons for generalizing recursion theory. In Logic Colloquium '69, R. O. Gandy and C. M. E. Yates eds, pp. 139198, North-Holland, 1971. [Kreisel and Krivine, 1971] G. Kreisel and J. L. Krivine. Elements of Mathematical Logic, North-Holland, 1971. [Kreitz and Weihrauch, 1985] C. Kreitz and K. Weihrauch. Theory of representations, Theoretical Computer Science 38:35-53, 1985. [Lacombe, 1955] D. Lacombe. Extension de la notion de fonction recursive aux fonctions d'une ou plusieurs variables reelles, I, II, III, Comptes Rendus de I'Academie des Sciences Paris 240:2470-2480,241:13-14,151153, 1955. [Lacombe, *197l] D. Lacombe. Recursion theoretic structure for relational systems. In Logic Colloquium '69, R. O. Gandy and C. M. E. Yates eds, pp. 3-18, North-Holland, 1971. [Lambert, 1968] W. M. Lambert, Jr. A notion of effectiveness in arbitrary structures, Journal of Symbolic Logic, 33:577-602, 1968. [Lauer, 1967] P. E. Lauer. The formal explicates of the notion of algorithm, Technical Report TR 25.072, IBM Laboratory, Vienna, 1971. [Lauer, 1968] P. E. Lauer. An introduction to H. Thiele's notions of algorithm, algorithmic process and graph-schemata calculus, Technical Report TR 25.079, IBM Laboratory, Vienna, 1968. [Levien, *1962] R. E. Levien. Set-theoretic formalizations of computational algorithms, computable functions and general purpose computers. In Proceedings of the Symposium on the Mathematical Theory of Automation, New York, American Mathematical Society, pp. 101-123, 1962. [Lucas et al, 1968] P. Lucas, P. E. Lauer and H. Stigleitner. Method and notation for the formal definition of programming languages, Technical Report TR 25.087, IBM Laboratory, Vienna, 1968. [Luckham and Park, 1964] D. Luckham and D. M. Park. The undecidability of the equivalence problem for program schemata, Report 1141, Bolt, Beranek and Newman Inc., 1964. [Luckham et al., 1970] D. Luckham, D. M. Park and M. S. Paterson. On formalized computer programs, Journal of Computer & Systems Science 4:220-249, 1970.
Computable functions on algebras
515
[Machtey and Young, 1978] M. Machtey and P. Young. An Introduction to the General Theory of Algorithms, North-Holland, 1978. [Mahr and Makowsky, *1984] B. Mahr and J. A. Makowsky. Characterizing specification languages which admit initial semantics, Theoretical Computer Science 31:49-59, 1984. [Makowsky and Sain, *1989] J. A. Makowsky and I. Sain. Weak second order characterization of various program verification systems, Theoretical Computer Science 66:239-321, 1989. [Mal'cev, 1973] A. I. Mal'cev. Algebraic Systems, Grundlehren der mathematischen Wissenschaften 192, Springer-Verlag, 1973. [Manna, 1974] Z. Manna. Mathematical Theory of Computation, McGrawHill, 1974. [Martin and Tucker, *1988] A. R. Martin and J. V. Tucker. The concurrent assignment representation of synchronous systems, Parallel Computing 9:227-256, 1988. [McCarthy, *1960] J. McCarthy. Recursive functions of symbolic expressions and their computation by machine, Part I, Communications of the Association for Computing Machinery 3:184-195, 1960. [McCarthy, *1962] J. McCarthy. Towards a mathematical science of computation, in Proceedings of the International Congress of Information Processing pp. 21-34, 1962. [McCarthy, 1963] J. McCarthy. A basis for a mathematical theory of computation. In Computer Programming and Formal Systems, P. Braffort and D. Hershberg, eds., North Holland, Amsterdam, pp. 33-70, 1963. [McEvoy and Tucker, 1990] K. McEvoy and J. V. Tucker, eds. Theoretical Foundations of VLSI Design, Cambridge University Press, 1990. [McKenzie et al, 1987] R. N. McKenzie, G. F. McNulty and W. F. Taylor. Algebras, Lattices, Varieties 1, Wadsworth and Brookes Cole, 1987. [McNaughton, 1982] R. McNaughton. Elementary Computability, Formal Languages and Automata, Prentice Hall, 1982. [Meer, *1993] K. Meer. Komplexitatsbetrachtungen fur reelle Maschinenmodelle, Shaker Verlag, 1993. [Meer and Michaux, *1996] K. Meer and C. Michaux. A survey on real structural complexity theory, Bulletin of the Belgian Mathematical Socitety 3:113-148, 1996. [Megiddo, *1993] N. Megiddo. A general NP-completeness theorem. In From Topology to Computation: Proceedings of the Smalefest, M. W. Hirsch, J. E. Marsden and M. Schub eds, pp. 432-442, Springer-Verlag, 1993. [Meinke and Tucker, 1992] K. Meinke and J.V. Tucker. Universal algebra. In Handbook of Logic in Computer Science, Vol. 1, S. Abramsky, D. Gabbay and T. Maibaum eds, pp. 189-411, Clarendon Press, 1992. [Melzak, *196l] Z. A. Melzak. An informal arithmetical approach to com-
516
J. V. Tucker and J. I. Zucker
putability and computation, Canadian Mathematical Bulletin, 4:279293, 1961. [Meseguer and Goguen, 1985] J. Meseguer and J. A. Goguen. Initiality, induction and computability. In Algebraic Methods in Semantics, M. Nivat and J. Reynolds eds, pp. 459-541, Cambridge University Press, 1985. [Meyer and Ritchie, 1967] A. R. Meyer and D. M. Ritchie. The complexity of loop programs. In Proceedings of the 22nd National Conference, Association for Computing Machinery, pp. 465-469, Thompson Book Company, 1967. [Meyer and Tiuryn, *1982] A. R. Meyer and J. Tiuryn. A note on equivalences among logics of programs. In Proceedings in Logics of Programs, Yorktown Heights 1981, D. Kozen ed, Lecture Notes in Computer Science 92, Springer-Verlag, 1982. [Michaux, *1989] C. Michaux. Une remarque a propos des machines sur R. In Comptes Rendus de I'Academic des Sciences Paris, Serie 7309: pp. 435-437, 1989. [Michaux, *1990] C. Michaux. Machines sur les reels et problemes NP-complets. In Seminaire de structures algebriques ordonnees, Prepublication de 1'equipe de logique mathematique de Paris 7, 1990. [Michaux, *199l] C. Michaux. Ordered rings over which output sets are recursively enumerable, Proceedings of the American Mathematical Society, 112:569-575, 1991. [Milner, *1969] Equivalences on program schemes. Journal of Computer & System Sciences 4: 205-219, 1969. [Mints, 1973] G. Mints. Quantifier-free and one-quantifier systems, Jounal of Soviet Mathematics 1:71-84, 1973. [Moldestad and Tucker, 1981] J. Moldestad, and J. V. Tucker. On the classification of computable functions in an abstract setting. Unpublished manuscript, 1981. [Moldestad et al, 1980a] J. Moldestad, V. Stoltenberg-Hansen and J. V. Tucker. Finite algorithmic procedures and inductive definability, Mathematica Scandinavica 46:62-76, 1980. [Moldestad et al, 1980b] J. Moldestad, V. Stoltenberg-Hansen and J. V. Tucker. Finite algorithmic procedures and inductive definability, Mathematica Scandinavica 46:77-94, 1980. [Montague, 1968] R. Montague. Recursion theory as a branch of model theory, Logic, Methodology & Philosophy of Science III, B. van Rootselaar and J. F. Staal eds, North-Holland, pp. 63-86, 1968. [Moschovakis, 1964] Y. N. Moschovakis. Recursive metric spaces, Fundamenta Mathematicae 55:215-238, 1964. [Moschovakis, 1969a] Y. N. Moschovakis. Abstract first-order computability I, Transactions of the American Mathematical Society 138:427-464, 1969.
Computable functions on algebras
517
[Moschovakis, *1969b] Y. N. Moschovakis. Abstract first-order computability II, Transactions of the American Mathematical Society 138:465-504,1969. [Moschovakis, *1969c] Y. N. Moschovakis. Abstract computability and invariant definability, Journal of Symbolic Logic, 34:605-633, 1969. [Moschovakis, 1971] Y. N. Moschovakis. Axioms for computation theories — first draft. In Logic Colloquium '69, R. O. Gandy and C. E. M. Yates eds, pp. 199-255, North-Holland, 1971. [Moschovakis, *1974] Y. N. Moschovakis. Elementary Induction on Abstract Structures, North-Holland, 1974. [Moschovakis, 1984] Y. N. Moschovakis. Abstract recursion as a foundation for the theory of recursive algorithms. In Computation and Proof Theory, M. M. Richter, E. Borger, W. Obserschelp, B. Schinzel and W. Thomas, eds, Lecture Notes in Mathematics 1104, pp. 289-364, Springer-Verlag, 1984. [Moschovakis, 1989] Y. N. Moschovakis. The formal language of recursion, Journal of Symbolic Logic 54:1216-1252,1989. [Miiller and Tucker, 1998] B. Miiller and J. V. Tucker, eds. Prospects for Hardware Foundations. Lecture Notes in Computer Science 1546, Springer-Verlag, 1998. [Normann, 1978] D. Normann. Set-recursion. In Generalized Recursion Theory II: Proceedings of the 1977 Oslo Symposium, J. E. Fenstad, R. 0. Gandy and G. E. Sacks eds, pp. 303-320, North-Holland, 1978. [Normann, 1982] D. Normann. External and internal algorithms on the continuous functionals. In Patas Logic Symposium, G. Metakides, ed, Studies in Logic, vol. 109, pp. 137-144. North-Holland, 1982. [Parsons, 1971] C. Parsons. On a number theoretic choice scheme II (Abstract), Journal of Symbolic Logic 36:587, 1971. [Parsons, 1972] C. Parsons. On n-quantifier induction, Journal of Symbolic Logic 37:466-482, 1972. [Paterson, *1967] M. S. Paterson. Equivalence problems in a model of computation, PhD thesis, Cambridge University, 1967. [Paterson, *1968] M. S. Paterson. Program schemata, Machine Intelligence 3:19-31, 1968. [Paterson and Hewitt, 1970] M. S. Paterson and C. E. Hewitt. Comparative schematology. In Record of Project MAC Conference on Concurrent Systems and Parallel Computation pp. 119-128, ACM; also MIT, AI Technical Memo 201, 1979. [Peter, 1958] R. Peter. Graphschemata und rekursive Funktionen, Dialectica 2:373-393, 1958. [Peter, 1967] R. Peter. Recursive Functions, Academic Press, 1967. [Phillips, 1992] I. C. C. Phillips. Recursion theory. In Handbook of Logic in Computer Science, Vol. 1, S. Abramsky, D. Gabbay and T. Maibaum eds, pp. 79-187, Clarendon Press, 1992.
518
J. V. Tucker and J. I. Zucker
[Plaisted, *1972] D. Plaisted. Program schemas with counters. In Proceedings of the 4th Annual ACM Simposium on the Theory of Computing, Denver, Col. pp. 44-51, Association for Computing Machinery, 1972. [Platek, 1966] R. A. Platek. Foundations of recursion theory, PhD thesis, Department of Mathematics, Stanford University, 1966. [Pour-El and Caldwell, 1975] M. B. Pour-El and J. C. Caldwell. On a simple definition of computable function of a real variable with applications to functions of a complex variable, Zeitschrift fur mathematische Logik und Grundlagen der Mathematik 21:1-19, 1975. [Pour-El and Richards, 1989] M. B. Pour-El and J. I. Richards. Computability in Analysis and Physics, Springer-Verlag, 1989. [Rice, 1954] H. G. Rice. Recursive real numbers, Proceedings of the American Mathematical Society 5:784-791, 1954. [Rogers, 1967] H. Rogers, Jr. Theory of Recursive Functions and Effective Computability, McGraw-Hill, 1967. [Rutledge, *1964] J. D. Rutledge. On lanov's program schemata, Journal of the Association for Computing Machinery 11:1-9, 1964. [Rutledge, *1970] J. D. Rutledge. Parallel processes—schemata and transformations, IBM Research Report RC-2912 1970. Also in Architecture and Design of Digital Computers, Boulayeed., pp. 91-129, Dunod, 1971. [Rutledge, *1973] J. D. Rutledge. Program Schemes as Automata 1, Journal of Computer & System Sciences 7:543-578, 1973. [Saint John, *1994] R. Saint John. Output sets, halting sets and an arithmetical hierarchy for ordered substrings of the real numbers under Blum/Shub/Smale computation, Technical Report TR-94-035, ICSI, Berkeley, CA, 1994. [Saint John, *1995] R. Saint John. Theory of computation for the real numbers and subrings of the real numbers following Blum/Shub/Smale, Dissertation, University of California at Berkeley, 1995. [Sanchis, *1988] L. E. Sanchis. Reflexive Structures, Springer-Verlag, 1988. [Schreiber, *1975] P. Schreiber. Theorie der geometrischen Konstruktionen, Deutscher Verlag der Wissenschaften, Berlin, 1975. [Scott, 1967] D. Scott. Some definitional suggestions for automata theory, Journal of Computer & System Sciences 1:187-212, 1967. [Scott, *1970a] D. S. Scott. The lattice of flow diagrams, Programming Research Group, Oxford, 1970. [Scott, *1970b] D. S. Scott. Outline of a mathematical theory of computation. In Proceedings of the 4th Annual Princeton Conference on Information Sciences & Systems, Princeton University, pp. 169-176, 1970. Also Technical Monograph PRG-2, Porgramming Research Group, Oxford University, 1970. [Scott and Strachey, *197l] D. S. Scott and C. Strachey. Towards a mathematical semantics for computer languages. In Proceedings of the Symposium on Computers & Automata, 3. Fox ed., Polytechnic Institute
Computable functions on algebras
519
of Brooklyn. Also in Technical Monograph 6, Programming Research Group, Oxford, 1971. [Shafarevich, 1977] I. R. Shafarevich. Basic Algebraic Geometry, SpringerVerlag, 1977. [Shepherdson, 1973] J. C. Shepherdson. Computations over abstract structures: serial and parallel procedures and Friedman's effective definitional schemes, in Logic Colloquium '73, H. E. Rose and J. C. Shepherdson eds, pp. 445-513, North-Holland, 1973. [Shepherdson, 1976] J. C. Shepherdson. On the definition of computable function of a real variable, Zeitschrift fur mathematische Logik und Grundlagen der Mathematik 22:391-402, 1976. [Shepherdson, 1985] J. C. Shepherdson. Algebraic procedures, generalized Turing algorithms, and elementary recursion theory. In Harvey Friedman's Research on the Foundations of Mathematics, L. A. Harrington, M. D. Morley, A. Scedrov and S. G. Simpson eds, pp. 285-308, NorthHolland, 1985. [Shepherdson, *1994] J. C. Shepherdson. Mechanisms for computing over arbitrary structures. In The Universal Turing Machine, A Half-Century Survey, R. Herken ed, pp. 581-601, Oxford University Press, 1994. [Shepherdson and Sturgis, 1963] J. C. Shepherdson and H. E. Sturgis. Computability of recursive functions, Journal of the Association for Computing Machinery 10:217-255, 1963. [Simmons, 1963] G. F. Simmons. Introduction to Topology and Modern Analysis, McGraw-Hill, 1963. [Smyth, 1992] M. B. Smyth. Topology. In Handbook of Logic in Computer Science, Vol. 1, S. Abramsky, D. Gabbay and T. Maibaum eds, pp. 641761, Clarendon Press, 1992. [Soskov, *1987] I. N. Soskov. Prime computability on partial structures. In Mathematical Logic and its Applications, D. G. Skordev ed, pp. 341-350, Plenum Press, 1987. [Soskov, *1989a] I. N. Soskov. Definability via enumerations, Journal of Symbolic Logic, 54:428-440, 1989. [Soskov, *1989b] I. N. Soskov. An external characterization of the prime computability, Annuaire de I'Universite de Sofia 83:89-110, 1089. [Soskov, *1990] I. N. Soskov. Computability by means of effectively definable schemes and definability via enumerations, Archive for Mathematical Logic 29:187-200, 1990. [Soskova, *1994] A. A. Soskova An external approach to abstract data types I, Annuaire de I'Universite Sofia 87, 1994. [Soskova and Soskov, *1990] A. A. Soskova and I. N. Soskov. Effective enumerations of abstract structures. In Heyting '88, P. Petkov ed, pp. 361372, Plenum Press, 1990. [Sperschneider and Antoniou, 1991] V. Sperschneider and G. Antoniou. Logic: A Foundation for Computer Science, Addison Wesley, 1991.
520
J. V. Tucker and J. I. Zucker
[Stephens, 1997] R. Stephens. A survey of stream processing, Acta Information 34:491-541, 1997. [Stephens and Thompson, 1996] R. Stephens and B. C. Thompson. Cartesian stream transformer composition, Fundamenta Informaticae 25:123174, 1996. [Stephenson, 1996] K. Stephenson. An algebraic approach to syntax, semantics and computation, PhD thesis, Department of Computer Science, University of Wales, Swansea, 1996. [Stewart, 1999] K. Stewart. Abstract and concrete models of computation over metric algebras. PhD thesis, Computer Science Department, University of Wales, Swansea, 1999. [Stoltenberg-Hansen, 1979] V. Stoltenberg-Hansen. Finite injury arguments in infinite computation theories, Annals of Mathematical Logic 16:57-80, 1979. [Stoltenberg-Hansen and Tucker, 1985] V. Stoltenberg-Hansen and J. V. Tucker. Complete local rings as domains, Technical Report 1.85, Centre for Theoretical Computer Science, University of Leeds, 1985. [Stoltenberg-Hansen and Tucker, 1988] V. Stoltenberg-Hansen and J. V. Tucker. Complete local rings as domains, Journal of Symbolic Logic 53:603-624, 1988. [Stoltenberg-Hansen and Tucker, 1991] V. Stoltenberg-Hansen and J. V. Tucker. Algebraic and fixed point equations over inverse limits of algebras, Theoretical Computer Science 87:1-24, 1991. [Stoltenberg-Hansen and Tucker, 1993] V. Stoltenberg-Hansen and J. V. Tucker. Infinite systems of equations over inverse limits and infinite synchronous concurrent algorithms. In Semantics: Foundations and Applications J. W. de Bakker, W.-P. de Roever and G. Rozenberg, eds. Lecture Notes in Computer Science 666, pp. 531-562, Springer-Verlag, 1993. [Stoltenberg-Hansen and Tucker, 1995] V. Stoltenberg-Hansen and J. V. Tucker. Effective algebras. In Handbook of Logic in Computer Science, Vol. 4, S. Abramsky, D. Gabbay and T. Maibaum eds, pp. 357-526, Oxford University Press, 1995. [Stoltenberg-Hansen and Tucker, 1999a] V. Stoltenberg-Hansen and J. V. Tucker. Computable rings and fields. In Handbook of Computability Theory, E. Griffor ed, North-Holland, 1999. [Stoltenberg-Hansen and Tucker, 1999b] V. Stoltenberg-Hansen and J. V. Tucker. Concrete models of computation for topological algebras. Theoretical Computer Science, 219:347-378, 1999. [Stoltenberg-Hansen et al., 1994] V. Stoltenberg-Hansen, I. Lindstrom and E. Griffor. Mathematical Theory of Domains, Cambridge University Press, 1994. [Strong, 1968] H. R. Strong, Jr. Algebraically generalised recursive function theory, IBM Journal of Research and Development, 12:465-475, 1968.
Computable functions on algebras
521
[Strong, *197l] H. R. Strong, Jr. Translating recursion equations into flowcharts, Journal of Computer & Systems Science 5:254-285, 1971. [Thiele, 1966] H. Thiele. Wissenschaftstheoretische Untersuchungen in algorithmischen Sprachen, VEB Deutcher Verlag der Wissenschaften, 1966. [Thompson, 1987] B. C. Thompson. A mathematical theory of synchronous concurrent algorithms, PhD thesis, School of Computer Studies, University of Leeds, 1987. [Thompson and Tucker, 1991] B. C. Thompson and J. V. Tucker. Algebraic specification of synchronous concurrent algorithms and architectures, Research Report CSR 9-91, University College of Swansea, 1991. [Tiuryn, *1981a] J. Tiuryn. Unbounded program memory adds to expressive power of first-order dynamic logic. In Proceedings of the 22nd Annual Symposium on the Foundations of Computer Science, Nashville, pp. 335-339, IEEE, 1981. [Tiuryn, 1981b] J. Tiuryn. Logic of effective definitions, Fundamenta Informaticae 4:629-660, 1981. [Tiuryn, *1981c] J. Tiuryn. A survey of the logic of effective definitions. In Logics of Programs: Workshop, ETH Zurich, May-July 1979, E. Engeler ed., Lecture Notes in Computer Science 125, pp. 198-245, SpringerVerlag, 1981. [Troelstra and van Dalen, 1988] A. S. Troelstra and D. van Dalen. Constructivism in Mathematics: An Introduction, Vols. I and II, NorthHolland, 1988. [Tucker, 1980] J. V. Tucker. Computing in algebraic systems, Recursion Theory, Its Generalisations and Applications, F. R. Drake and S. S. Wainer eds., London Mathematical Society Lecture Note Series 45, pp. 215-235, Cambridge University Press, 1980. [Tucker, *199l] J. V. Tucker. Theory of computation and specification over abstract data types and its applications. In NATO Advanced Study Institute, International Summer School at Marktoberdorf, 1989, on Logic, Algebra and Computation, F. L. Bauer ed, pp. 1-39, Springer-Verlag, 1991. [Tucker and Zucker, 1988] J. V. Tucker and J. I. Zucker. Program Correctness over Abstract Data Types, with Error-State Semantics, CWI Monographs 6:, North-Holland, 1988. [Tucker and Zucker, 1989] J. V. Tucker and J. I. Zucker. Horn programs and semicomputable relations on abstract structures, in 16th International Colloquium on Automata, Languages and Programming, Stresa, Italy, July 1989, G. Ausiello, M. Dezani-Ciancaglini and S. Ronchi della Rocca eds., Lecture Notes in Computer Science 372:, Springer-Verlag, pp. 745-760, 1989. [Tucker and Zucker, *199l] J. V. Tucker and J. I. Zucker. Projections of semicomputable relations on abstract data types, International Journal
522
J. V. Tucker and J. I. Zucker
of Foundations of Computer Science 2:267-296, 1991. [Tucker and Zucker, 1992a] J. V. Tucker and J. I. Zucker. Deterministic and nondeterministic computation, and Horn programs, on abstract data types, Journal of Logic Programming 13:23-55, 1992. [Tucker and Zucker, *1992b] J. V. Tucker and J. I. Zucker. Examples of semicomputable sets of real and complex numbers. In Constructivity in Computer Science: Summer Symposium, San Antonio, Texas, June 1991, J. P. Myers, Jr. and M. J. O'Donnell eds, Lecture Notes in Computer Science 613, pp. 179-198, Springer-Verlag, 1992. [Tucker and Zucker, *1992c] J. V. Tucker and J. I. Zucker. Theory of computation over stream algebras, and its applications. In Mathematical Foundations of Computer Science 1992: 17th International Symposium, Prague, I.M. Havel and V. Koubek eds, Lecture Notes in Computer Science 629, pp. 62-80, Springer-Verlag, 1992. [Tucker and Zucker, 1993] J. V. Tucker and J. I. Zucker. Provable computable selection functions on abstract structures. In Proof Theory, P. Aczel, H. Simmons and S. S. Wainer eds, Cambridge University Press, pp. 277-306, 1993. [Tucker and Zucker, 1994] J. V. Tucker and J. I. Zucker. Computable functions on stream algebras. In NATO Advanced Study Institute, International Summer School at Marktoberdorf, 1993, on Proof and Computation, H. Schwichtenberg ed, pp. 341-382, Springer-Verlag, 1994. [Tucker and Zucker, 1998] J. V. Tucker and J. I. Zucker. Infinitary algebraic specifications for stream algebras. Report CAS 98-02, Department of Computing and Software, McMaster University, 1998. [Tucker and Zucker, 1999] J. V. Tucker and J. I. Zucker. Computation by 'While' programs on topological partial algebras. Theoretical Computer Science, 219:379-420, 1999. [Tucker and Zucker, 2000a] J. V. Tucker and J. I. Zucker. Abstract versus concrete comptability over partial metric algebras (in preparation). [Tucker and Zucker, 2000b] J. V. Tucker and J. I. Zucker. Abstract computability, algebraic specificationa nd initiality. Technical Report No. CAS 2000-01-J2, Department of Computing & Software, McMaster University, Hamilton, Canada. [Tucker et al, 1990] J. V. Tucker, S. S. Wainer and J. I. Zucker. Provable computable functions on abstract data types. In 17th International Colloquium on Automata, Languages and Programming, Warwick University, England, July 1990, M. S. Paterson ed, Lecture Notes in Computer Science 443, pp. 660-673, Springer-Verlag, 1990. [Turing, 1936] A. M. Turing. On computable numbers, with an application to the Entscheidungsproblem, Proceedings of the London Mathematical Society 42: pp. 230-265; correction [1937], ibid. 43, pp. 544-546. Reprinted [1965], The Undecidable, M. Davis, ed., Raven Press, 1936.
Computable functions on algebras
523
[Urzyczyn, *1981a] P. Urzyczyn. Algorithmic triviality of abstract structures, Fundamenta Informaticae 4:819-849, 1981. [Urzyczyn, *1981b] P. Urzyczyn. The unwind property in certain algebras, Information & Control 50:91-109, 1981. [Urzyczyn, *1982] P. Urzyczyn. On the unwinding of flow-charts with stacks, Fundamenta Informaticae 4:119-126, 1982. [Urzyczyn, *1983] P. Urzyczyn. Nontrivial definability by flow-chart programs, Information & Control, 58:101-112, 1983. [Voorhes, 1958] E. A. Voorhes. Algebric formulation of the notion of flowdiagrams, Communications of the Association for Computing Machinery 1:4-8, 1958. [Wagner, *1965] E. A. Wagner. Uniformly reflexive structures: An axiomatic approach to computability. In Logic, Computability & Automation: Joint PADG-AIAC Symposium, Trinkaus Manor, Oriskany, New York, 1965. [Wagner, 1969] E. A. Wagner. Uniformly reflexive structures: On the nature of Godelizations and relative computability, Transactions of the American Mathematical Society 144:1-41, 1969. [Walker and Strong, *1973] S. Q. Walker and H. R. Strong. Characterizations of flowchartable recursions, Journal of Computer & Systems Science 7:404-447, 1973. [Warner, *1993] S. Warner. Topological Rings, Mathematics Studies 178, North-Holland, 1989. [Wechler, 1992] W. Wechler. Universal Algebra for Computer Scientists, EATCS Monographs 25, Springer-Verlag, 1992. [Weihrauch, 1987] K. Weihrauch. Computability, EATCS Monographs 9, Springer-Verlag, 1987. [Weihrauch and Schreiber, 1981] K. Weihrauch. Embedding metric spaces into complete partial orders. Theoretical Computer Science 16:5-24, 1981. [van Wijngaarden, *1966] A. van Wijngaarden. Numerical analysis as an independent science, BIT 6:68-81, 1966. [Wirsing, 1991] M. Wirsing. Algebraic specification. In Handbook of Theoretical Computer Science Vol.B: Formal Methods and Semantics, J. van Leeuwen ed, pp. 675-788, North-Holland, 1991. [Zucker and Pretorius, 1993] J. I. Zucker and L. Pretorius. Introduction to computability theory, South African Computer Journal 9:3-30, 1993.
This page intentionally left blank
ON
-"
,)(.< ^
So
= i
ft
TTITIT •q^ qii 4ii J J <S -U-
ONOsOs O\ ON
oooo o\
VO
oo VO
I < > S5,| SS::|*'S 53"';^3' '— : ^ 2,| > N
K° ft0 ft° ?» || || || LU
a fD
526 A, 120 A,, 60 <,79 x.lll A, 82 -»,51 --,85 (j> prop [T], 77 KA:XKA^ 7i>, 109 7Ti,45
^,80 Sr, 135 Soo, 135 a + a', 53 CT = a' [T], 103 crto, 62
INDEX
abstraction condition, 478 actual variables, 138 adequate specification, 252 algebra, 221 compact, 464-465,471 complete metric, 477,484 complex numbers, 328-329,346, 353,423,438-451 passim, 451-^-78 passim, computable, 332-335 connected, 465—469 effective, 321, 329, 335 expansion, 324-325,347,456457 final, 224 freely generated, 233 generated, 231 Hausdorff, 457 homomorphic image of, 223 initial, 224 interval, 445 locally compact, 477 locally finite, 405,418-419 many sorted, 320,322,325,329330,344-360 passim metric, 465 minimal, 350,412 AT-standard, 350, 353-354 natural numbers, 320,326,329, 334,345-346,352-354,269270,405,409 order-sorted, 302 partial, 345,451-478 passim partial topological, 451-478 passim polynomials, 327,329,438^151 passim, 471 quotient algebra, 226 quotient term algebra, 235 quotient term algebra of a set of formulas, 244
INDEX real numbers, 320-321,327-329, 346, 353, 354, 396, 409, 438-451 passim, 451-478 passim reduct of an, 237 standard, 322, 351-352,360 streams, 326,328,359-360,451, 454,501 subalgebra, 225 term algebra, 234 terms, 329 topological, 332, 451^78 passim total, 345 ultrametric, 477 with arrays, 356-359 with unspecified value, 355-356 algebraic theory, 45 dependently typed, 102 algebraic and transcendental points, 441 algebraic domain, 477 algebraic operational semantics, 364366 amalgamated union, 283 ap,61,120 approximate computation 320-321, 342,451-478 passim arity,51,220 assignment, 228 atomic formula, 143 atomic specification, 252 Ax, J., 207 axiom, 249 scheme, 249 term-equality, 102 type-equality, 102 axiomatizable, 246 Baire space, 476 Barwise, J., 200 Baur, W., 209 behavioural abstraction, 298 behavioural equivalence, 298
527
Ben-Or, M., 209 B6nabou,J., 113 Beck-Chevalley condition, 96,97 Berman, L., 193,194,209 bi-rule, 86 Bloom, S. L., 75 Blum, L., 438,484,506 B6rger,E., 136,154 Brattka, V., 478,484, 506 Brown, S. S., 208 Buchi, J., 154 C-property, 79 Cat, 114 Ct(Th),1Q, 107 Cpo, 80 cur, 120 curi, 60 calculus, 249 equational, 250 Cantor set, 445,451 carrier, 221 carrier set, 221 Cartmell,J.,41, 101,110 case, 53 categorical combinators, 123 category bicartesian closed, 77 cartesian closed, 62 classifying, 70 prop-, 79 slice, 111 type-, 110 well-pointed, 49 well-powered, 81 category with attributes, 101 Cegielski, P., 136 Chagrov.A., 136 Chandra, A., 140 chaotic systems, 447—451 Cherlin, G., 208 Church-Turing thesis, see generalised Church-Turing thesis
528
classifying category, 70 prop-category, 99 type-category, 108-109 closure, 246 of a class of algebras, 247 condition, 225 theorems for semicomputable sets, 409-413, 415-416, 420421 coherence, 101,123 complete, 142,250 completeness, 77,97-100 Compton, K., 134,206 computational lambda calculus, 66 computation type, 66 computability theory on natural numbers, 319-320, 322,330-331 on algebras, 320-321,330-331, 340-342 generalised, 320-321,330-331 abstract, 321,330-331,336-340 abstract versus concrete, 333335,475^78 history, 335-340 abstract, history, 335-340,474478 generalised, history, 335-340 reasons for generalising, 335336 type two, 476 computable analysis, 321 computable real number, 475 computation local, 372-373,387 sequence, 364 tree, 342, 423-430, 436-438, 468-469 theory, 490 concrete representation, 477 cons, 62 cons x, 62 continuous domain, 477
INDEX condition inheritance, 302 subtype, 302 conditional equational logic, 241 CEL, 241 confluent, 263 congruence relation, 225 induced, 226 conservativity for terms, 383-387,429 consistent, 285 constant, 220 constraint, 267 construction term, 300 constructive specification, 267 abstract syntax, 267 concrete syntax, 268 semantics, 268 constructor, 231 constructors, 255 context, 44, 101 T/z-provably equal, 69 a-equivalence of, 69 identity morphism, 70 morphism, 69 morphism composition, 69 contextual categories, 101 (Contract), 79 Coste, M., 41 countability/cofiniteness condition, 442 countable connectivity condition, 445 course of values recursion, 483 Curry-Howard interpretation, 3 (Cut), 79 ctxt, 103 data types, 320, 325,329,351 data type theory, 329,330-332,340 declaration, 280 default terms and values, 349 density/codensity condition, 442 dependent type, 120 depth, 139 derivable formula, 249 design specification, 253
INDEX disjoint union type, 53 domain, 243,476-477 Duret, J.-L., 207 dynamic signature, 304 dynamic sort, 304 dynamical systems, 328, 447^51, 484 emptyT, 56 EdalatA.,477,508 Egidi, L., 208 Ehrenfeucht games, 200 effective algebra, 321 effective domains, 476 effective definitional schemes, 339, 487 element generalized, 49 global, 49 elementary recursive, 140 Emerson, E. A., 136 empty type, 57 Engeler, E., 338-339,408,425,429, 430, 434, 435, 446, 489, 509 Engeler's lemma, 425,428,429,434, 435,438,446 environment, 278 equation, 240 equation-in-context, 45 equational calculus, 250 equational logic, 45,240 dependently typed, 105-106 equivalence sequence, 263 Ergov.Y, 131, 142,192,208 Esik, Z., 75 essentially algebraic, 42,123 evaluation morphism, 62 exact computation, 320-321,451 evaluation homomorphism, 234 exception, 303 (Exchange), 79 explicit definition, 144 exponential object, 62
529
export signature, 284 extension, 238 ^-extension, 238 a set of formulas persistent, 248 of a set of formulas, 248 persistent free, 276 quotient term, 275
fsat(L0), 153 JFp,74 false, 85 fst, 59 factorization, 226 Fagin,R., 136 Feferman, S., 209 Fenstad, J. E., 336,343,490, 510 Ferrante, J., 146,148,186,191,194, 196,202,210,211 (false-Adj), 87 (false-Elim), 86 final algebra, 224 final specification, 299 finite algorithmic procedure, 339,484 finite algorithmic procedure with counting, 485 finite algorithmic procedure with stacking, 486 finite algorithmic procedures with index registers, 487 finite computation, 320-321,331 finite product category with, 45 preservation of, 68 strictly associative, 71 strictly unital, 71 strict preservation of, 68 finite sequences, 324 first-order languages, 499 first-order logics, 138 Fischer, M. J., 136, 148, 159, 160, 193,194,195,198,207 flattening, 281 Fleischmann, K., 132
530
formal variables, 138 formula, 239 atomic, 77 derivable, 249 value of, 242 well-formed, 77 formula-in-context, 78 flowchart 336-337,342 for programming languages, 376 formula morphism, 239 free (ip), 143 free extension, 274 occurrence, 242 persistent, 276 freely generated, 233 Freyd, P. J., 42,123 Fridman, E. I., 209 Fried, M., 207 Friedman, H., 339-340,484,487,510 Frobenius reciprocity, 91 function while computable, 324,326-329, 336,341,369 while N computable, 377 a-computable, 333 continuous, 342, 451-478 passim while-array computable, 325,335, 378 order, 404-405 discontinuous, 451 partial, 317-532 passim uniformly continuous, 474 equationally definable, 491 selection, 497 types, 347 function symbol introductory axiom, 102 term-valued, 101 type-valued, 101 function type, 60 fundamental theorem of algebra, 442 Purer, M., 210,211
INDEX generalised Church-Turing thesis, 338, 342, 422, 478, 487, 493500, 503 generalised element, 49 generalised quantifiers, 95 generated, 231 in some sorts, 232 generic T/i-algebra, 72 model, 77,99, 118-119 Gentzen, G., 85, 87,123 Girard, J.-Y., 40,100, 123 global element, 49 global section, 114 Godel numbering, 388 Godel completeness thorem, 139 Gradel.E., 136 Grandjean, E., 137, 141,211 Grothendieck, A., 114 Grothendieck fibration, 114 ground equation, 240 term, 227 type, 51 group, 321,327,328,346-347,353, 370,395,416 Grzegorczyk, A., 474,475 guarded command language, 488 Gurevich, Y., 207, 208 Halpern.J. Y., 136 halting formula, 42^429,433,437 halting problem, 417 halting set, 324,408,414,422,428, 436,457 hard, 141 Hardy, G. H., 195,197 Harel, D., 136 height, 139 Henkin,L.,210 Henson, C. W., 206 hereditary, 140 hereditary lower bounds, 131, 132, 140
INDEX
531
hierarchical specification, 284 higher-order logic, 123 Hofmann, M., 113 homomorphic extension, 274 homomorphism, 223 bijective, 223 evaluation, 234 image of, 223 initial, 244 homomorphism condition, 223 Hopcroft, J., 140, 159, 200 Horn clause languages, 500 Hyland,J.M.E.,41 hyperdoctrine, 80
internal language, 41,48, 95 interpretation, 167 simple, 167 prenex, 167 iterative, 167 invariance isomorphism, 320,341,358,475, 495 from numberings, 334,475—478 homomorphism, 371-372,422423,454 isomorphism, 223 isomorphism property, 239 iterated map, 448 iterative definition, 145 iteration theory, 75
imV,53 inr^, 53
junk, 230
inv(L), 132, 139 inv(Lo), 153 Immerman, N., 200 implementation, 297, 300 implicit definitions, 145 import signature, 284 inclusive subset, 80 indexed type, 110 induced subalgebra, 225 inductive closure, 246 consequence, 244 type, 62 inference rule, 249 infinite streams, 324, 326, 328, 359360,451,454,501-503 inheritance condition, 302 inherited, 284 initial algebra, 224 initial homomorphism, 244 initial module specification, 286 initial specification, 257 initialisations, 408, 413-414, 436 instantiation assumption, 349, 360 institution, 310
K, 88 AC*, 80
Kaufmann, M., 164, 165 Ko.K.I.,475,513 Kochen, S., 108 Kokorin, A. I., 209 Konig's lemma, 469 Kozlov, G. T., 209 Korec, I., 185 Kozen, D., 136,140, 193 Kreisel.H., 211 Kripke, S., 100 Kutty, G., 136 L*. 143 Lo,138 Lt, 138, 171 IX, 62 listit, 64 listrec, 62 listreci, 62 lifti, 67 label sort, 304 Ladner,R., 136 Lafont, Y., 42
INDEX
532
Lambek, J., 65, 123 Lawvere, F. W., 40, 42, 65, 79, 80, 91,93,96,123 LCF,4 length of a computation, 365 let, 66 Lewis, H. R., 136, 193 linear logic, 123 linear ATIME lower bounds, 175 linearly bounded, 141 Lo,L., 196 locality of computation theorem, 387 locally confluent, 263 log-lin reduction, 141 logic, 239 conditional equational, 241 equational, 240 isomorphism property, 239 predicate logic, 241 satisfaction condition, 239 with equality, 239 logic with equality, 239 logical consequence, 244 in a domain, 244 loose module specification, 286 loose specification, 253 Loveland,D., 210 Lynch,!. F., 161, 162
ML0, 138 MLt, 138 ME r , 135,171 MSoo, 135, 171 MLt, 171 Machtey, M., 140 Makkai,M., 81 many-sorted signatures, see signatures Martin-L6f,P.,51, 100 McCarthy,!., 338,340,515 Macintyre, A., 210 McNaughton, R., 211 Maurin, F., 136, 195, 196
merging two procedures, 409-410, 420 meta-expression, 51 Meyer, A., 159,160, 184, 185,193 Michel, P., 136, 196 model, 243 of a dependently typed theory, 117 of a predicate theory, 97 of computation, 320, 323, 325, 335-340, 458-460, 475503 passim oriented semantics, 283 modularized abstract data type, 285 module, 285 module signature, 284 module specification initial, 286 loose, 286 module specifications, 287 Moggi, E., 41,66 interpretation, 175 iterative, 175 monadic, 175 prenex, 175 simple, 175 monadic interpretability, 175 monadic second-order logics, 138 monomorphic, 224,285 morphism formula morphism, 239 signature, 237 Moschovakis, Y. N., 145, 148, 336, 476, 490, 493, 500, 516, 517 Moses, Y., 136 multicategory, 123
NT I ME, 140 ATT/M J5(T(cra))-inseparable, 153 NTIME lower bounds, 166 mU62 n ilx, 62 numbering, 332
533
INDEX natural number object, 65 weak, 65 next state function, 447 Noetherian, 263 non-deterministic assignment, 488 normal form, 263 Normann,D.,478,493,517 null, 57 Objc, 112 object, 307 class, 307 identities, 307 instances, 307 type, 307 observable sorts, 298 Oles, R, 50 one-element-type, 59 only positively, 145 operation, 220 constant, 220 operation name, 220 operator formula, 145 orbit, 447 order-sorted algebra, 302 order-sorted signature, 301
P,88 Pi, 88 Po,88 pair, 58 proj, 60 prop,78 Papert,S.,211 parameterization A-calculus approach, 295 pushout approach, 296 Peano arithmetic, 246 periodic points, 447 persistent, 238,248,274,285 free extension, 276 Poigne, A., 40 Point, F., 207 polymorphic, 224
lambda calculus, 123 positive and negative occurrences, 144 Post's theorem 342, 407, 410, 411412,415,420 Pour-El, M. B., 474,476, 518 poewr, 138 predicate transition, 304 predicate logic, 241 prenex definition, 144 prescribed set of formulas, 150 Prest, M., 207,209 primary subtree, 138 problem, 140, 141 procedures 362 product type, 57, 344 program scheme, 489 program schematology 339,489 projections of relations 348 projective equivalence theorem 422, 434-435 projection morphism, 110 proof theory, 123 Pmpc, 79 prop-category, 79 classifying, 98 has equality, 94 has existential quantification, 91 has finite joins, 83 has finite meets, 82 has Heyting implications, 84 has universal quantification, 91 PSL, 291 pullback of an indexed type, 110 of a property, 79 quotient algebra, 226 quotient homomorphism, 226 quotient term algebra, 235 of a set of formulas, 244 quotient term extension, 275 Rabin, M., 131, 142, 148, 184, 192,
534
193, 194, 195, 198, 207, 208 Rabinovich, A., 136 Rackoff,C, 146,148,186,191,193, 194,196,202,210,211 Ramakrishna, Y., 136 rapid prototyping, 253 random assignments, 408,435-438, 488 Rautenberg, W., 185 reachable, 231 realizability, 89 realization, 300 Reddy.U., 210 reduct, 237 and expansion, 347, 354, 356, 358 of a homomorphism, 238 reduct of a homomorphism, 238 reduction ordering, 264 reduction system, 263 reductions sequence, 263 yu-reduct, 237 register machines, 484-487 register machines with counting, 485 register machine with stacking, 485 remainder set, 380 relations, 348 relation symbol, 77 relativization, 140 relative homomorphism, 350-351 relative while computability, 375 renaming, 235 representations of semantic functions, 387-394 requirement specification, 253 reset log-lin reduction, 141 rewrite ordering, 264 Reyes, G. E., 81 Reynolds,!. C,41, 50, 100 Richards, J. I., 474,476, 518 Robertson, E. L., 184
INDEX Robinson, A., 209, 210 Roman, L., 65 rules adjoint style, 86, 89,93 natural deduction style, 85, 89, 93 S, 88 Set, 80, 111 Sg,43 Sgc, 48 £ r , 171 Soo,171 snd,59 split, 58 sat(S), 132 sat*(£), 144 sat^(S), 144 satr(£), 139 satr(L), 139 satr(ME+), 161 sat^(L), 144 sat£(£), 139 satT(Lo), 132 satT(ML0), 132 Sacerdote, G., 207 satisfaction, 239 condition, 239 of an equation, 47 of a judgement, 117 ' of sequent, 82 relation, 239 satisfiability problem, 132 Scarpellini, B., 136,210 Scedrov, A., 123 Schmitt, P., 209 Schoning, U., 136 Scott, D. S., 41 search, 333,412-413,461 search procedure, 413 Seiferas,!., 159,160 Seiferas-Fischer-Meyer Theorem, 159 semantics model oriented, 283 of while programs, 363-36
INDEX presentation oriented, 284 specification oriented, 284 theory oriented, 284 Semenov,. L., 189,210 semicomputability equivalence theorem, 431 semicomputability with search, 413414 sentence, 144 sequent, 78 set while computable, 324,326-329, 407,409,438^51 passim, while semicomputable, 324,326329,407-451 passim halting, 324,408,414,422,428, 436,457 a-decidable, 333 a-semidecidable, 333 a-cosemidecidable, 333 projective semicomputable, 407451 passim definable, 408,431^35 semicomputable with search, 414, 416,421-422 semialgebraic, 444 Julia, 449-451 Open, 451,464, Closed, 451,464 Clopen, 451,464 recursion, 493 Shelah.S., 164, 165 Shepherdson, J. C., 339, 342, 473, 475, 484, 487, 489, 518, 519 Shub, M, 438,484, 506 E-homomorphism, 223 £(A")-term, 227 signature, 43, 101, 220, 322, 344360 passim dynamic, 304 module, 284 morphism, 235, 237 inclusion, 236
535
order-sorted, 301 strongly typed, 228 simultaneous course of values recursion, 337,483 simultaneous iterative definition, 148 slice category, 111 Slobodskoi, A. M., 209 Smale, S., 438,484,506 snapshot function, 382,402,417 sort, 43, 220 argument sort, 220 dynamic, 304 label sort, 304 observable, 298 target sort, 220 sound, 250 soundness, 47 specification adequate, 252 atomic, 252 design, 253 e-specification, 278 final, 299 initial, 257 language 496-500 loose, 253 loose with constructors, 255 requirement, 253 strictly adequate, 252 specification morphism, 284 specification oriented semantics, 284 stable coproduct, 56, 57 initial object, 57 join, 87 stage, 49 standardness assumption, 353 standard signatures, 351-352 statement remainder function, 417 Statman, R., 210 Stern,!., 191 Stirling, C., 136 Stoltenberg-Hansen, V., 330,332,335, 343,476,477, 520
536
Stockmeyer, L., 137, 140, 184, 21 1 streams, see infinite streams strict TV-standardness, 355 strictly adequate specification, 252 strictness condition, 111 strong monad, 66 strongly typed, 228 structure for an algebraic theory, 46 for a dependency typed theory, 114 for a predicate theory, 80 structural induction 362 subalgebra, 225, 349 induced, 225 subobject, 80 (Subst), 78 substitution, 229 ground, 229 theorem, 230 substitutivity condition, 225 subtype condition, 302 sufficiently complete, 231 synchronous concurrent algorithms, 501 true, 85 type, 103 7i, 171 Tarski, A., 79 Tarski's quantifier-elimination theorem, 444 tautology, 244 TERMS, 51 term, 227, 237, 349, 361-364, 383387 algebra, 234 construction, 300 evaluation, 329, 341, 389-390, 394-397,399-402,405,410, 412,415,416,418-421,431, 439, 472 ground, 227
INDEX signature morphism on, 237 rewriting system, 264 value of a, 228 term-in-context, 44 term-model, 41 T/t-algebra, 47 JTi-context, 107 The, 73 theory, 245 algebraic, 45 axioms of, 45 dependently typed algebraic, 102 in predicate logic, 77 morphism, 284 oriented semantics, 284 theorems of, 45,78, 102 translation, 74 time resource bound, 140 Tiuryn, J., 136 topos, 112,122 total object, 110 Touraille, A., 208 Trakhtenbrot, B. A., 131,153 Trakhtenbrot-Vaught Inseparability Theorem, 153 transition predicate, 304 Tucker, 3. V., 317, 330, 332, 335, 343, 365, 369, 396, 432, 452, 475, 576, 476, 477, 478, 483, 494, 495, 496, 520, 521 Turing, A., 154 type computation, 66 dependent product, 120 disjoint union, 52 empty, 57 function, 60 ground, 51 indexed, 110 inductive, 62 one-element, 59 product, 57 type-category, 110
537
INDEX type-category, cont classifying, 107-108 has dependent products, 120 reachable, 119 TYPES, 51 Typec, 110 unit, 60 Ullman, J. D., 140,159,200 uniform computation, 324 uniform convergence, 470 union amalgamated, 283 universe, 243 universality, 341,387-388,399-401, 439,490 val, 66 val(S), 132 valid, 244 in a domain, 244 inductively valid, 244 logically valid, 244 validity problem, 132 value of a formula, 242 Var, 44 uar(r), 44 Vardy.M., 136 variable free occurrence of, 242
Vaught,R., 131,153,209 vocabulary, 138 Volger, H., 192 Vorobynov, S., 137,210 weak model, 138 weak product, 59 weak second-order language, 408,431435 (Weaken), 78 Weierstrass approximability, 470-474 Weihrauch, K., 476,477,523 well-formed theory, 105 well-pointed, 49 while-array programming language, 317-523 passim while programming language, 317523 passim Wood, C, 209 Wright, E. M., 195, 197 Young, P., 140, 153, 195 Zakharyaschev, M., 136 Zucker, J.I., 317,365,369,432,452, 475, 478, 483, 494, 496, 497, 500, 501, 503, 521, 522