New Foundations for Fixpoint Computations

New Foundations for Fixpoint Computations

New Foundations for Fixpoint Computations Roy L. Crole* Andrew M. Pittst Computer Laboratory, University of Cambridge CB2 3QG, England Abstract computations using monads introduced by Moggi [SI, where there is a distinction between the ele- This paper introduces a new higher-order typed ments of a type a and computations of elements constructive predicate logic for fixpoint compu- of that type-the latter being grouped into a tations, which exploits the categorical semantics new type T(a). Moggi’s computational meta- of computations introduced by Moggi [8] and language XMLT [lo], contains the following for- contains a strong version of Martin-Lof’s ‘iter- mation rules: ation type’ [ll].The type system enforces a sep- a type aration of computations from values. The logic contains a novel form of fixpoint induction and can express partial and total correctness state- MEa ments about evaluation of computations to val- Val(M) E T(a) ues. The constructive nature of the logic is wit- nessed by strong metalogical properties which are proved using a category-theoretic version of the ‘logical relations’ method. Let x+-E.F(x) E T(P) 1 Computation types Note These rules, and the others which appear in this paper, are presented in natural deduc- It is well known that primitive recursion at tion style, with discharged hypotheses enclosed higher types can be given a categorical character- in square brackets. Since there are several unfa- isation in terms of Lawvere’s concept of natural miliar variable binding operations in the syntax, number object [6]. We show that a similar char- we will also adopt Martin-Lof’s theory of expres- acterisation can be given for general recursion via sions and arities-a Pq-lambda calculus over a fixpoint operators of higher types, in terms of a single ground type of expressions with abstrac- new concept-that of a fixpoint object in a suit- tion denoted (x)e,application denoted f(e) and ably structured category. This notion was partly a multiple application such as (f(e))(e’)abbre- inspired by contemplation of Martin-Lof’s non- viated to f(e,e’); see [la], for example. Finally, standard ‘iteration type’ in his domain theoretic it should be noted that our syntax is a slight interpretation of type theory [ll].However, the variant of Moggi’s. key ingredient which allows the formulation of the concept of fixpoint object is the treatment of Intuitively, Val(M) is the value M regarded as a trivial computation which immediately eval- *Research supported by a SERC Research Let Studentship. uates to itself; and xeE.F(x) denotes the ‘Research supported by the CLICS project (EEC ES- computation which firstly tries to evaluate E to PRIT BR nr 3003). some value x E a and then proceeds to evaluate CH2897-7/90/0000/0489$01.OO 0 1990 IEEE 4H9 F(x). These intended meanings are captured by 0 Lift(Snd; 77) = Snd : a x T(P)-i T(P). three equational axioms: 0 If F : a x ,B -+ T(y) and G : a x y --+ T(S), then Lift((Fst,F); Lift(G)) = Let x+Val(M).F(x) = F(M) (Fst, Lift(F)); Lift(G) : a x T(P)-+ T(S). Letx+E.Val(x) = E Let y+(Let x+E.F(x)).G(y) = Proposition 1.1 There are mutually inverse Let x-e E.Let yeF(z).G( y) translations between the above combinators, F : a ---t P, and XMLpterms, G, satisfying G(z) E In addition, XMLT extends the simply typed lambda calculus: there are function types a-+@ P [x E al. with lambda abstractions Xz E a.F(x)and ap- Combining this proposition with the fact that plications (MN) satisfying the usual ,8 and 77 equational XMLT theories correspond to let-ccc’s equalities. The system also contains product [lo], one concludes that the categorical combina- types a x /? with (surjective) pairing (M,N) and tors give a simple presentation of this variety of projections Fst(M), Snd(M); and it contains a category; in particular, the action of T on mor- type unit with unique element () E unit. phisms, the monad multiplication and the monad The categorical counterpart of this basic meta- strength are all definable from the combinators. language is the notion of a ‘Cartesian closed cat- In terms of the XMLT language, the action of T egory equipped with a strong monad T’ [8, sec- on a morphism F : a -+ /3 yields tion 21. We shall refer to such structures as let Cartesian closed categories, or just let-ccc ’s. Such T(F) %f Xe E T(a).Letz-ee.Val(Fz) categories can be presented very simply using a : T(a)-+ T(P). language of categorical combinators for XMLT, extending Curien’s ccc combinators for the sim- Similarly, the monad multiplication is defined by ply typed lambda calculus [2]. dzf pff - Xe’ E T(Ta).Let e+e’.e Definition 1.1 The let-categorical combinators are defined by the following grammar: : Tya)+ T(a) and the monad strength is defined by dzf tff$ - A typing statement for these combinators takes Xz E a x TP.Let ycSnd(z).Val((Fst(z),y)) the form F : a + P; an equality statement takes : cr x T(P) -+ T(a x P). the form F = F‘ : a + P. The rules for deduc- ing these statements are those for ccc’s (see [6]) A concept which is intimately bound up with augmented by the following rules (where F x G the correspondence between the metalanguage abbreviates (Fst; F, Snd; G)): XMLT and let-ccc’s is functional completeness, as used by Lambek and Scott [6] in the con- 0 q:a+T(a). text of ordinary Cartesian closed categories. Here one must consider polynomial categories over let- 0 If F : a x P -+ T(y), then ccc’s and show that they are functionally com- Lift(F) : a x T(P)+ T(y) (and plete in a suitable sense. Lift(F) = Lift($’’) if F = F’). Definition 1.2 Let C be a let-ccc and let a be 0 If F : a i P and G : /3 x y -+ T(S),then (F x Id); Lift(G) = Lift((F x Id); G) : an object of C. The polynomial category C[X]is specified by the following data: a x T(7)-i T(S). 0 If F : a x p 3 T(y), then 0 The objects of C[X]are just the objects of (Id x 7); Lift(F) = F : a x /3 + T(y). C. 490 0 The morphisms of C[X] are equivalence The usual category-theoretic considerations classes of the let-categorical combinators imply that the structure fix,U, w is determined generated by the morphisms of C, together uniquely up to isomorphism, within the given with an indeterminate global element X : let-ccc, by the above properties. One should unit + a. The equivalence relation is that also note that U, being the structure morphism generated by the equality rules in defini- for the intial algebra of an endofunctor, is it- tion 1.1 and the existing identities in C- self an isomorphism. (This fact will be used so that there is a canonical inclusion of let- later in Proposition 3.1.) Using the relation be- categories i : C - C[X]. tween syntax and category theory discussed in section 1, one can translate the definition of a Theorem 1.1 (Functional Completeness) fixpoint object into a corresponding extension of Let C[X] be as above. For every morphism the metalanguage XMLT. This entails adding a U : ,8 + y in C[X] there is a unique mor- new type fix, together with the term-forming and phism A(U) : a x ,B --+ y in C such that equality rules shown in Figure 1. The last rule ((();X),ld);A(U) = U. (In particular, each in this figure, which expresses the uniqueness of global element of y in C[X] is of the form X;F It,(F), will be redundant in the full FIX logic of for some unique morphism F : a ---f y in C.) section 3: it is derivable from the induction rule for fix introduced in that section. It is possible to prove the functional complete- Fixpoint objects are so called because they en- ness result simply by calculation with the cat- able one to define fixpoint combinators at all egorical combinators. Then one may derive types of the form a+T(P).' the correspondence between the metalanguage and the category theory using the recipe de- Proposition 2.1 (Definability of fixpoint scribed for Cartesian closed categories by Lam- combinators) In the presence of a fixpoint ob- bek and Scott [6]. We make the comment that ject, one may define a combinator when specifying the metalanguage terms gener- ated by a given category, terms Letx+E.U in the metalanguage are instances of morphisms which satisfies (Ya,p F) = (F (Y,,p F))for all (Id, E);Lift((Snd, Fst); A(U)). When construct- F E (a+TP)+a+TP. Indeed, defining ing the category from the metalanguage, all mor- phisms in the category are formed in the way one ya,p = (F)lta+Tp(F, u(w)) would expect. where F is (e)(XxE cr.Let f-+e.F(s,f)), then 2 The fixpoint type [f E a+TP,x E a] F(f,z) E TP Definition 2.1 In a let-ccc, a fixpoint object is specified by the following data: and An initial algebra 0 : T(fix) + fix for the functor T(-).

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    9 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us