UUniform Elgot Iteration in Foundations
Sergey Goncharov
FAU Erlangen-Nü[email protected]
Abstract
Category theory is famous for its innovative way of thinking of concepts by their descriptions, inparticular by establishing universal properties . Concepts that can be characterized in a universalway receive a certain quality seal, which makes them easily transferable across application domains.The notion of partiality is however notoriously difficult to characterize in this way, although theimportance of it is certain, especially for computer science where entire research areas, such as synthetic and axiomatic domain theory revolve around notions of partiality. More recently, thisissue resurfaced in the context of (constructive) intensional type theory . Here, we provide a genericcategorical iteration-based notion of partiality, which is arguably the most basic one. We showthat the emerging free structures, which we dub uniform-iteration algebras enjoy various desirableproperties, in particular, yield an equational lifting monad . We then study the impact of classicalityassumptions and choice principles on this monad, in particular, we establish a suitable categorialformulation of the axiom of countable choice entailing that the monad is an
Elgot monad . Author: Please fill in 1 or more \ccsdesc macro
Keywords and phrases
Author: Please fill in \keywords macro
Funding
Sergey Goncharov : Natural numbers form a prototypical domain for programming and reasoning. Both in category theory and in type theory they are characterized by a universal property, whichconsists of two parts: a definitional principle – (structural) primitive recursion and a reasoningprinciple – induction . Dualization yields respectively co-natural numbers , co-recursion and co-induction . Amid these two structuralist extremes, here, we analyse the challenging case ofnon-structural recursion in the form of iteration, which arises as follows. A map h : S Ñ X ` S presents the simplest possible model of a computation process: with S regarded as a statespace, h sends any state either to a successor state or to a terminal value in X . We wish to beable to form an object KX of denotations potentially reachable via such processes. Besidesthe values of X reachable in a finite number of steps, KX must also contain a designatedvalue for divergence, generated by the right injection h “ inr . We then ask: what would bethe generic universal characterization of KX and what properties it would imply? Somewhatsurprisingly, this question has not been addressed yet on a level of generality, sufficientlyclose to the settings where the question can be posed, although many similar closely relatedquestions have been addressed, mostly couched in type-theoretic terms.The question trivializes whenever one of the two following perspectives is adopted. intensional perspective: the domain KX keeps track not only of results, but also of thenumber of steps needed to reach them. This leads to the identification of KX as the finalcoalgebra DX “ νγ. X ` γ , known as Capretta’s monad or the delay monad [12]. non-constructive perspective: assuming non-constructive principles, such as the law ofexcluded middle , leads to the identification of KX as the maybe monad X ` a r X i v : . [ c s . L O ] F e b Uniform Elgot Iteration in Foundations
Here, we generally keep aloof from these interpretations of KX and work both extensionallyand generically, using the language of the category theory to analyse the issue in the abstract,and keeping the potential class of models possibly large.We introduce KX as a certain free structure, equipped with an iteration operator, whichsends any f : S Ñ KX ` S to f : S Ñ KX , and satisfies the following two basic anduncontroversial principles: fixpoint: f is in a suitable sense a fixpoint of f ; uniformity: the structure of the state space S is ineffective (i.e. merging or adding newstates done coherently does not influence the result).We dub such structures uniform-iteration algebras and show that on a high level of generality(in any extensive category with finite limits and a stable natural number object) if KX existsthen it satisfies a number of other properties: K extends to a monad K , which is an equationallifting monad [11], the Kleisli category of K is enriched over partial orders and monotonemaps, and the iteration operator is a least fixpoint operator w.r.t. this order; moreover, theiteration operator satisfies an additional principle, previously dubbed compositionality [2].In some environments, such as the homotopy type theory (HoTT) , K can be constructeddirectly, by using higher inductive types . One can then define a universal map from the delaymonad D to K and regard it is a form of extensional collapse . However, proving K to be aquotient of D seems to be impossible without using (weak) choice principles [13, 5, 17]. Weinterpret this categorically, first by introducing a categorical limited principle of omniscience(LPO) under which K turns out to be isomorphic to the maybe-monad p -- ` q and alsoturns out to be an Elgot monad . This generalizes slightly previous results [19] obtained for hyperextensive categories [3]. Second, we identify other cases of K being a quotient of D andadditionally being an (initial) Elgot monad, by introducing certain coequalizer preservationconditions, abstractly capturing the corresponding instances of the axiom of countable choice.From the type-theoretic perspective, in our work we revisit the familiar waymarks ofusing/avoiding principles of classical/constructive mathematics in view of the tradoffs inexpressive power of the corresponding constructions. Our present approach of uniform-iteration algebras as a fundamental primitive is entirely new, though. Moreover, we wouldlike to emphasize that our results, being generic, apply to a wide range of categories, whoseobjects need not be like sets, or types in any conventional sense. This has a massive impacton the underlying proofs. In topos theory, calculations are facilitated by existence of thesubobject classifier Ω, which is used as a global parent space for propositions. Predicativetheories, such as HoTT make do without Ω, but it is still possible to form predicative typesof propositions per universe, implying that the style of proofs can to a significant extent bemaintained, with Ω intuitively regarded as “scattered” over the cumulative universe hierarchy.Contrastingly, here we do not assume any kind of general reference spaces for propositions,resulting in completely different proof methods. Nevertheless, we conjecture that our resultscan be implemented in HoTT. This is clear for the universe of sets, which in HoTT forms apretopos, and hence directly satisfy our assumptions. For higher universes this should bepossible by using standard recipes of formalizing precategoris of types [33]. Previous related work.
We relate to the work on iteration theories, starting from a seminalpaper of Elgot [16], who identified iteration as a fundamental unifying notion. Equationalproperties of Elgot iteration were extensively explored by Bloom and Ésik [10] with theinitial iteration structure playing a prominent role, however, since the whole setup therein isinherently classical, most of our present agenda is essentially moot there. The uniformityproperty occurred under the name functorial dagger implication in Bloom and Ésik’s mono- . Goncharov 3 graph, and is an established and powerful principle, thus notably recognized in Simpson andPlotkin’s work [32], in the context of generic recursion (as opposed to the present dual caseof generic iteration). Adámek et al [2] introduced axioms of
Elgot algebras , and it followsfrom their results that these axioms are complete w.r.t. the algebras of the delay monad. Itis one of our results that all these axioms hold for our free uniform-iteation algebras KX .Another line of research we relate to is concerned with notions of partiality, via dominances ,in particular the Rosolini dominance in synthetic domain theory [31], via equational liftingmonads [11], and via restriction categories [14]. We remark that these approaches are ratherconcerned with specifying a notion of partiality than with definiting it. This distinction isparticularly significant in the context of constructive type theories, such as HoTT, whichrevitalized the interest to defining a notion of partiality both predicatively and constructivelyand to understanding the impact of (restricted) choice principles. Chapman et al [13]provided a construction of a partiality monad as a quotient of the delay monad. Altenkirchet al [6] constructed the same monad in HoTT as a certain quotient inductive-inductive type without using any choice whatsoever, and reestablished a connection to the delay monadunder countable choice. Recently, Escardó and Knapp [17] reinforced the issue of discrepancybetween the quotient of the delay monad and partiality monads, by showing that the quotientprecisely captures extensions of Turing computable values, whereas in the absence of anychoice, the reasonable partiality monads seem to yield strictly larger carriers. The latterview is particularly fine grained, and involves a monad, which is essentially our monad K .According to them, showing the desired connection between K and the delay monad stillamounts to (very week) choice principles (albeit still not natively available in HoTT), whileequivalence to more expressive monads would again require countable choice. Further relevantdetails of type-theoretic analysis of partiality can be found in resent theses [35, 26]. We assume familiarity with standard categorical concepts [29, 7]. In what follows, we generallywork in an ambient extensive category C with finite products, a stable natural numberobject N and exponentials X N . By | C | we refer to the objects of C . We often drop indicesof natural transformations to avoid clutter. Let us clarify this and fix some conventions. Extensive categories and pointful reasoning.
Extensiveness means existence of disjointfinite coproducts and stability of them under pullbacks (which must exist). Every extensivecategory is distributive , that is, every morphism r id ˆ inl , id ˆ inr s : X ˆ Y ` X ˆ Z Ñ X ˆp Y ` Z q is an isomorphism whose inverse we denote dstr : X ˆ p Y ` Z q Ñ X ˆ Y ` X ˆ Z . Let dstl : p X ` Y q ˆ Z Ñ X ˆ Z ` Y ˆ Z be the obvious dual to dstr .In order to simplify reasoning, we occasionally use a rudimentary pointful notation forstating equalities in C , most notably we use the case distinction operator case , e.g. we write f p x q “ case g p x q of inl y ÞÑ h p y q ; inr z ÞÑ u p z q meaning f “ r h, u s g where f : X Ñ W , g : X Ñ Y ` Z , h : Y Ñ W and u : Z Ñ W . Natural numbers and primitive recursion. A stable natural number object (NNO) in aCartesian category C , is an object N equipped with two morphisms o : 1 Ñ N ( zero ) and s : N Ñ N ( successor ) such that for any X, Y
P | C | and any f : X Ñ Y and g : Y Ñ Y there Uniform Elgot Iteration in Foundations is unique init r f, g s : X ˆ N Ñ Y such that X X ˆ N X ˆ N Y Y h id , o ! i f init r f,g s id ˆ s init r f,g s g commutes. This combines two separate properties: there exists an initial p ` -- q -algebra p N , r o , s s : 1 ` N Ñ N q , and p X ˆ N , r h id , o ! i , id ˆ s s : X ` X ˆ N Ñ X ˆ N q is an initial p X ` -- q -algebra. The latter property follows from the former in Cartesian closed categories.More generally, we need the derivable Lawvere’s internalization of primitive recursion [28]:Given f : X Ñ Y and g : Y ˆ X ˆ N Ñ Y there is unique p - rec p f, g q : X ˆ N Ñ Y such that p - rec p f, g qp x, o q “ f p x q , p - rec p f, g qp x, s n q “ g p p - rec p f, g qp x, n q , x, n q . We thus say that p - rec p f, g q is defined by (primitive) recursion, whereas induction is a proofprinciple , stating that p - rec p f, g q “ w for any w : X ˆ N Ñ Y satisfying the same equations.Exponentials X N are adjoint to products X ˆ N , meaning that there is an isomorphism curry : C p X ˆ N , Y q Ñ C p X, Y N q natural in X . This induces an evaluation morphism ev “ curry - id : X N ˆ N Ñ X with the standard properties. Strong functors and monads.
A functor T is strong if it is equipped with a naturaltransformation strength τ X,Y : X ˆ T Y Ñ T p X ˆ Y q , satisfying standard coherence conditionsw.r.t. the monoidal structure p , ˆq of C [27]. This induces the obvious dual ˆ τ X,Y : T X ˆ Y Ñ T p X ˆ Y q . A natural transformation α : F Ñ G between two strong functors is itself strong if it preserves strength in the obvious sense, i.e. α τ “ τ p id ˆ α q .A monad T (in the form of a Klesli triple) consists of an endomap T : | C | Ñ | C | , a familyof morphisms p η X P C p X, T X qq X P| C | and a lifting operation p -- q ‹ : C p X, T Y q Ñ C p T X, T Y q ,satisfying standard laws [30]. It then follows that T is an endofunctor with T f “ p η f q ‹ , η extends to a natural transformation, and the multiplication transformation µ : T T Ñ T isdefinable as id ‹ . For every monad T , whose underlying functor T is strong, η and µ arestrong (with id being a strength of Id and p T τ q τ being a strength of µ ). Such monad T isthen called strong if both η and µ are strong. A strong monad is commutative if τ ‹ ˆ τ “ ˆ τ ‹ τ .We adopt Moggi’s perspective [30] to strong monads as carriers of computational effects,and thus say that a morphism f : X Ñ T Y computes a value in Y . Since, the only effect wedeal with here is divergence, f can either produce a value or diverge (modulo the inherentlinguistic inaccuracy of the excluded middle law baked into the natural language). Functor algebras and monad algebras.
For an endofunctor T , we distinguish T -algebras,which are pairs p A, a : T A Ñ A q , from T -algebras, which can only be formed for monads T on T : a T -algebra is a T -algebra p A, a q , which additionally satisfies a η “ id and a µ “ a T µ .Both T - and T -algebras form categories under the standard structure preserving morphisms,the latter fully embeds into the latter.With our assumptions on C , we mean to cover the following (classes of) categories. Zermello-Fraenkel set theory with choice (ZFC) sets and further variants of set theory:ETCS, ZF, CZF, etc. Toposes satisfying countable choice, e.g. the topological topos [25]. Toposes not satisfying countable choice, e.g. nominal sets . Pretoposes, e.g. Π W -pretoposes, compact Hausdoff spaces. The category of topological spaces
Top , and its subcategories, such as the category ofdirected complete sets dCpo . . Goncharov 5 The final coalgebras DX “ νγ. X ` γ jointly yield a monad D , called the delay monad [12].Capretta [12] showed that D is strong, which remains valid in our setting. By Lambek’slemma, the final coalgebra structure out : DX Ñ X ` DX is an isomorphism. Its inverse out -1 “ r now , later s : X ` DX Ñ DX is composed of the morphisms, conventionally called now and later , of which the first one is the monad unit, and the effect of the second one isintuitively to postpone the argument computation by one time unit. In what follows, wewill write . instead of later for the sake of succinctness. As a final coalgebra, DX comestogether with a coiteration operator : for any f : Y Ñ X ` Y , coit f : Y Ñ DX is the uniquemorphism, such that out p coit f q “ p id ` coit f q f . We denote D N , and think of it asan object of co-natural or possibly infinite natural numbers. The obvious, componentwisemonic, natural transformation ι X : X ˆ N , Ñ DX instantiates to ˆ ι : N , Ñ ¯ N .In our setting, DX need not be postulated, for it is in fact definable as a retract of theobject p X ` q N of infinite streams, which is elaborated in detail by Chapman et al [13].Intuitively, DX consists of precisely those streams, which contain at most one element of theform inl x . This intuition becomes precise in (possibly non-classical) set theory, where now x “ p inl x, inr ‹ , inr ‹ , . . . q . p e , e , . . . q “ p inr ‹ , e , e , . . . q This explains why classically, more precisely, under the law of excluded , DX is isomorphic to X ˆ N `
1. We provide a stronger result to this effect further below. Let us record somegeneral facts about D first. (cid:73) Proposition 1.
The monad D admits the following characterization: unit now : X Ñ DX of D satisfies out now “ inl ; Klesli lifting of f : X Ñ DY is the unique morphism f ‹ : DX Ñ DY satisfying equation out f ‹ “ r out f, inr f ‹ s out ; strength τ : X ˆ DY Ñ D p X ˆ Y q is a unique such morphism that out τ “p id ` τ q dstr p id ˆ out q . Proof. (1) and (2) follow from a more general characterization by Uustalu [34]; (3) isestablished in [21]. (cid:74)(cid:73)
Proposition 2. D is commutative.
Let us proceed with a characterization of the situations when DX – X ˆ N `
1. Recall thata monic σ is called complemented if there exists σ : X , Ñ Y , such that Y is a coproductof X and X with σ and σ as coproduct injections. The law of excluded middle states thatany monic is complemented. We involve a rather more specific property. (cid:73) Proposition 3.
The monic ˆ ι : N , Ñ ¯ N is complemented iff DX – X ˆ N ` . Proof (Sketch).
The necessity is obvious. Let us proceed with the sufficiency. Usingextensiveness of C one can obtain the following pullback: X ˆ N N DX ¯ N (cid:65) snd ι ˆ ιD ! By assumption, ˆ ι is complemented, and since C is extensive, so is ι . We obtain that DX – N ˆ X ` R for some R , and then it follows from finality of DX that R – (cid:74) Uniform Elgot Iteration in Foundations
The property of ˆ ι : N , Ñ ¯ N to be complemented is a categorical formulation of the limitedprinciple of omniscience (LPO) , which is rejected in constructive mathematics. Informally,LPO states that every infinite bit-stream either contains 1 at some position or containsonly 0 everywhere (the constraint that the stream contains at most one 1, does not make adifference). We say that C is an LPO category if ˆ ι : N , Ñ ¯ N is complemented. (cid:73) Corollary 4.
Suppose that (i) C has countable products and (ii) given a family p σ i : A i Ñ A q i P ω of complemented pairwise disjoint monos, the induced universal morphism š i A i Ñ A is complemented. Then C satisfies LPO and hence DX – X ˆ N ` . Proof.
It is folklore that in categories with countable products N is isomophic to the sum of ω copies of 1. Thus ˆ ι : N Ñ ¯ N is the induced universal map, which is complemented by (ii). (cid:74)(cid:73) Example 5.
As expected, Proposition 3 does not apply to models, designed with construct-ivist principles in mind, such as intensional type theories, or realizability toposes, although,it is technically possible to design a realizability topos, satisfying LPO [9], in which thus DX – X ˆ N `
1. Another class of examples to which Proposition 3 does not apply stemsfrom topology. In
Top , ¯ N is a subspace of the Cantor space N whose topology is generatedby the base of opens of the form t sr | r P t , u ω u with s P ‹ . Then ¯ N is isomorphic to a one-point compactification of N , i.e. it is a set N Y t8u , whose opens are all subsets of N andadditionally all complements of finite subsets of N in N Y t8u . Clearly, ¯ N fl N `
1. Thiskind of arguments is inherited by higher order topology-based models, such as Johnstone’s topological topos [25], which is a Grothendieck topos not satisfying LPO. (cid:73)
Example 6.
Proposition 3 and Corollary 4 cover quite a few models constructed in thescope of classical mathematics. Every set theory satisfying the law of excluded middle satisfiesLPO. Every presheaf topos (w.r.t. a classical set theory) inherits countable coproducts from
Set and those satisfy (ii) of Corollary 4. As we indicated in Example 5, a Grothendiecktopos generally need not satisfy LPO, but, e.g.
Schanuel topos (aka the topos of nominalsets) does satisfy it, because this topos is Boolean. As we indicated in Example 5,
Top doesnot satisfy LPO, but curiously the full subcategory of directed complete partial orders dCpo (under Scott topology) does. Both
Top and dCpo have countable coproducts, but
Top failsto satisfy condition (ii), of Corollary 4, while dCpo does satisfy it. This can be read as amanifestation of (undesirable) effects, which motivated synthetic domain theory [24].Conditions (i) and (ii) in Corollary 4 are essentially the axioms of hyper-extensive categories by Adámek et al [3] (modulo our background extensiveness assumption). An example of anLPO category that fails (i) is Lawvere’s ETCS. Another example of a Grothendieck toposthat fails (ii) is constructed as a certain category of
Jónsson-Tarski algebras [3].The above examples indicate that in models developed w.r.t. constructive foundations LPOfails by design, while in models developed w.r.t. classical foundations, depending on thepurposes, constructively questioned principles may leak from the metalogic level inside ofthe category, possibly in a weakened form, resulting in an explicit expression for DX . Recall the following notion from [2] where the term complete Elgot algebra over H is used. (cid:73) Definition 7 (Guarded Elgot Algebras) . Given an endofunctor H , an ( H -)guarded Elgotalgebra is a tuple p A, a : HA Ñ A, p -- q q where the iteration f : X Ñ A for every given f : X Ñ A ` HX , satisfies the following axioms: . Goncharov 7 ( Fixpoint ) for every f : X Ñ A ` HX , f “ r id , a Hf s f ; ( Uniformity ) for every f : X Ñ A ` HX every g : Y Ñ A ` HY and every h : X Ñ Y , p id ` Hh q f “ g h implies f “ g h ; ( Compositionality ) for every h : Y Ñ X ` HY and f : X Ñ A ` HX , pp f ` id q h q “prp id ` H inl q f, inr p H inr qs r inl , h s : X ` Y Ñ A ` H p X ` Y qq inr . H -guarded Elgot algebras form a category together with iteration preserving morphismsdefined in an obvious way. The axioms of guarded Elgot algebras are complete in the following sense. (cid:73)
Theorem 8. [2, Theorem 5.4,Corollary 5.7,Theorem 5.8]
For every X , a final coalgebra νγ. X ` Hγ is a free H -guarded algebra over X , in particular, existence of final coalgebras isequivalent to existence of free H -guarded algebras. The categories of H -guarded Elgot algebrasand algebras of the monad νγ. X ` Hγ are isomorphic. Free algebras of the delay monad are thus precisely the free Id-guarded Elgot algebras. Wethen introduce un-guarded Elgot algebras as a certain subcategory of Id-guarded ones. (cid:73)
Definition 9 (Unguarded Elgot Algebras) . We call Id -guarded Elgot algebras of the form p A, id : A Ñ A, p -- q q unguarded Elgot algebras , or simply Elgot algebras if no confusionarises. Given two Elgot algebras A and B , we call f : X ˆ A Ñ B right iteration preserving if f p id ˆ h q “ ` X ˆ Z id ˆ h ÝÝÝÑ X ˆ p A ` Z q dstr ÝÝÑ X ˆ A ` X ˆ Z f ` id ÝÝÝÑ B ` X ˆ Z ˘ for any h : Z Ñ A ` Z . This generalizes Elgot algebra morphisms under X “ . The unguarded Elgot algebras thus differ from the Id-guarded ones in that the Id-algebrastructures a : A Ñ A in the former case are forced to be trivial. This has an impact onforming the corresponding free structures: in the guarded case, the Id-algebra structuresmust be maximally unrestricted, which is the reason why we obtain a free Id-guardedElgot algebra DX with the Id-algebra structures playing roles of delays. Intuitively, a freeunguarded Elgot algebra must be a quotient of a free guarded one under removing delays,which is indeed what happens for LPO categories, as we show later. Otherwise, the situationis much more subtle, and it is one of our goals to demonstrate that free unguarded Elgotalgebras are exactly the semantic carriers generated by unguarded iteration.In the unguarded case Compositionality can be replaced by a simpler law: (cid:73)
Proposition 10.
Given A P | C | , p A, p -- q q is an Elgot algebra iff p -- q satisfies ( Fixpoint ) for every f : X Ñ A ` X , f “ r id , f s f ; ( Uniformity ) for every f : X Ñ A ` X every g : Y Ñ A ` Y and every h : X Ñ Y , p id ` h q f “ g h implies f “ g h ; ( Folding ) for every h : Y Ñ X ` Y and f : X Ñ A ` X , rp id ` inl q f, inr h s “ p f ` h q . As expected, products and exponents of Elgot algebras can be formed in a canonical way. (cid:73)
Lemma 11.
Given two Elgot algebras p A, p -- q q and p B, p -- q q and an object X P | C | , p A ˆ B, p -- q ˆ q is an Elgot algebra with h ˆ “ h pp fst ` id q h q , pp snd ` id q h q i for any h : Z Ñ A ˆ B ` Z . If A X exists then p A X , p -- q ˆ q is an Elgot algebra with h ˆ “ curry pp ev ` id q dstl p h ˆ id qq for any h : Z Ñ A X ` Z . Uniform Elgot Iteration in Foundations
Every Elgot algebra p A, p -- q q comes together with a divergence constant K : 1 Ñ A “p inr : 1 Ñ A ` q . Note that K is automatically preserved by Elgot algebra morphisms.By omitting the not quite self-motivating Compositionality (or
Folding ), we obtain whatwe dub uniform-iteration algebras . (cid:73) Definition 12 (Uniform-Iteration Algebras) . A uniform-iteration algebra is a tuple p A, p -- q q as in Definition 9 but p -- q is only required to satisfy Fixpoint and
Uniformity . Morphismsof uniform-iteration algebra are defined in the same way.
The goal of this section is to show that free uniform-iteration algebras coincide with freeElgot algebras, and enjoy a number of other characteristic properties. In particular, wecharacterize the functor sending any X to a free uniform-iteration algebra on X as an initialpre-Elgot monad. We define pre-Elgot monads as follows. (cid:73) Definition 13 (Pre-Elgot Monads) . We call a monad T pre-Elgot if every T X is equippedwith an Elgot algebra structure, in such a way that h ‹ f “ pp h ‹ ` id q f q for any f : Z Ñ T X ` Z and any h : X Ñ T Y . A pre-Elgot monad T is strong pre-Elgot if T is strong as amonad and strength is iteration preserving. Pre-Elgot monads are to be compared with Elgot monads, which support a stronger typeprofile for the iteration operator, and satisfy more sophisticated axioms. (cid:73)
Definition 14 (Elgot Monads [16, 4]) . A monad T is an Elgot monad if it is equipped withan iteration operator sending each f : X Ñ T p Y ` X q to f : : X Ñ T Y and satisfying: ( Fixpoint ) f : “ r η, f : s ‹ f ; ( Naturality ) g ‹ f : “ prp T inl q g, η inr s ‹ f q : for f : X Ñ T p Y ` X q , g : Y Ñ T Z ; ( Codiagonal ) p T r id , inr s f q : “ f :: for f : X Ñ T pp Y ` X q ` X q ; ( Uniformity ) f h “ T p id ` h q g implies f : h “ g : for f : X Ñ T p Y ` X q , g : Z Ñ T p Y ` Z q and h : Z Ñ X .If T is additionally strong then T is strong Elgot if moreover: ( Strength ) τ p id ˆ f : q “ pp T dstr q τ p id ˆ f qq : for any f : X Ñ T p Y ` X q . (cid:73) Proposition 15. (Strong) Elgot monads are (strong) pre-Elgot under f “ pr T inl , η inr s f q : . It has been argued [19, 22] that strong Elgot monads are minimal semantic structures forinterpreting effectful while-languages. In that sense, we acknowledge an expressivity gapbetween Elgot and pre-Elgot monads, which generally happen to be too weak. (cid:73)
Lemma 16.
If for every X P | C | a free uniform-iteration algebra KX exists then K extends to a monad K whose algebras are precisely uniform-iteration algebras. As in the case of natural numbers, one cannot make much progress without stability. (cid:73)
Definition 17 (Stable Free Uniform-Iteration Algebras) . A free uniform-iteration algebra KY over Y is stable if for every X P | C | , fst : X ˆ KY Ñ X is a free uniform-iteration algebrain the slice category C { X . (cid:73) Lemma 18.
For Y P | C | , KY is stable iff for every uniform-iteration A and every f : X ˆ Y Ñ A , there is unique iteration preserving f : X ˆ KY Ñ A such that f “ f p id ˆ η q . . Goncharov 9 Using Lemma 11, it is easy to show that in Cartesian closed categories every KX is stable.For the rest of the section, we assume that all KX exist and are stable. (cid:73) Proposition 19.
The monad K is strong, with the components of strength τ : X ˆ KY Ñ K p X ˆ Y q uniquely identified by the conditions: τ p id ˆ η q “ η, τ p id ˆ h q “ pp τ ` id q dstr p id ˆ h qq p h : Z Ñ KY ` Z q Proof.
In the notation of Lemma 18 we define strength of K as p η : X ˆ Y Ñ K p X ˆ Y qq .The axioms of strength are easy to verify. (cid:74) As a next step, we show that K is an equational lifting monad in the sense of Bucalo etal [11]. This means precisely that K is commutative and satisfies the equational law: τ ∆ “ K h η, id i . (1)This law is rather restrictive, and roughly means that some form of non-termination is theonly possible effect of the monad. Proving (1) is nontrivial. The key step is the followingproperty, which allows for a splitting a loop involving a product of algebras into two loops. (cid:73) Lemma 20.
Given uniform-iteration algebras A and B , f : Z Ñ A ˆ B ` Z and h : A ˆ B Ñ C , pp h ` id q f q “ pp h ` id q dstr p id ˆ p snd ` id q f qq h pp fst ` id q f q , id i . (cid:73) Lemma 21.
Given
X, Z
P | C | , and h : Z Ñ KX ` Z , then τ h h , h i “ pp τ ∆ ` id q h q . Proof.
It follows from Lemma 20 that pp τ ` id q dstr p id ˆ h qq h h , id i “ pp τ ∆ ` id q h q . Onthe other hand, by Proposition 19, pp τ ` id q dstr p id ˆ h qq h h , id i “ τ h h , h i . By combiningthe last two identities, we obtain the goal. (cid:74)(cid:73) Theorem 22. K is an equational lifting monad.
Proof.
Let us sketch the proof of (1). Since K h η, id i “ p η h η, id i q ‹ , using the definition ofKleisli star for K , it suffices to show that τ ∆ is a unique iteration preserving morphism forwhich η h η, id i “ τ ∆ η Indeed, τ ∆ η “ τ p id ˆ η q h η, id i “ η h η, id i , and τ ∆ is iterationpreserving by Lemma 21. (cid:74) The fact that K is an equational lifting monad has a number of implications, in particular, theKleisli category of K is a restriction category [14]. That is, we can calculate the domain (ofdefiniteness) , represented by an idempotent Kleisli morphism as follows: given f : X Ñ KY , dom f “ p K fst q τ h id , f i : X Ñ KX,
We additionally use the notation f ç g “ fst ‹ τ h f, g i , meaning: restrict f to the domainof g . It is easy to see that dom f “ η ç f and f ç g “ f ‹ p dom g q . Let f v g abbreviate f “ g ç f . Under this definition, every C p X, KY q is partially ordered, which is a generalfact about restriction categories. In our case, moreover, this partial order additionally has abottom element K “ inr ; dom p η f q “ η for any f : X Ñ KY , and dom f v η for any f . (cid:73) Proposition 23.
The Kleisli category of K is enriched over pointed complete partial ordersand strict monotone maps. Moreover, strength preserves K and v as follows: τ p id ˆ Kq “ K f v g implies τ p id ˆ f q v τ p id ˆ g q (cid:73) Corollary 24. K ∅ – . D -algebrasuniform-iteration algebas/search-algebras D -algebrasElgot algebras Figure 1
Connections between classes of D -algebras. Proof.
Since !
K “ id : 1 Ñ K ! “ id : K ∅ Ñ K ∅ , we obtain an isomorphism K ∅ – (cid:74)(cid:73) Proposition 25.
The monad K is copyable and weakly discardable [20], i.e.: ˆ τ ‹ τ ∆ “ K ∆ and p K fst q ˆ τ ‹ τ h f, g i v f for f : X Ñ KY and g : X Ñ KZ . (cid:73) Definition 26 (Bounded Iteration) . Let A be a pointed object , i.e. an object with a canonicalmap K : 1 Ñ A . Then we define bounded iteration p -- q h : C p X, A ` X q Ñ C p X ˆ N , A q byprimitive recursion as follows: f h p x, o q “ K f h p x, s n q “ case f p x q of inl a ÞÑ a ; inr y ÞÑ f h p y, n q . Intuitively, f h p x, n q behaves as f p x q except that at each iteration the counter n is decreased,and K is returned once n “ o . We next show that f p x q is in a suitable sense a limit of the f h p x, n q as n tends to infinity. This is, of course, a form of Kleene fixpoint theorem . (cid:73) Theorem 27 (Kleene Fixpoint Theorem) . Given f : X Ñ KY ` X , and g : X Ñ KY ,(i) f h v f fst , and (ii) f h v g fst implies f v g . (cid:73) Corollary 28.
Given f : X Ñ KY ` X , f : X Ñ KY is the least pre-fixpoint of the map r id , -- s f : C p X, KY q Ñ C p X, KY q . Finally, we obtain (cid:73)
Theorem 29. K is an initial pre-Elgot monad and an initial strong pre-Elgot monad.
By Theorem 8, Id-guarded Elgot algebras are precisely the D -algebras. We proceed tocharacterize uniform-iteration and Elgot algebras as certain D -algebras. (cid:73) Definition 30 (Search-Algebra) . We call a D -algebra p A, a : DA Ñ A q a search-algebra ifit satisfies the conditions: a now “ id , a . “ a . Search-algebras form a full subcategory ofthe category of all D -algebras. Uniform-iteration algebras capture the structure of search-algebras independently of theassumption that D exists. This and further connections between categories of D -algebrasillustrated in Fig. 1 (arrows indicate full embeddings of categories) is formalized as follows. (cid:73) Proposition 31. 1.
The categories of uniform-iteration algebras and search-algebras areisomorphic under: p A, p -- q q ÞÑ p A, out : DA Ñ A q , p A, a : DA Ñ A q ÞÑ p A, a coit p -- q : C p X, A ` X q Ñ C p X, A qq . . Goncharov 11 Elgot algebras are precisely those D -algebras, which are search-algebras and D -algebras. (cid:73) Lemma 32.
Every Elgot algebra p DA, a : DA Ñ A q satisfies a ι ‹ “ a p D fst q . We proceed to model the construction of quotienting D by weak bisimilarity « , previouslydescribed in type-theoretic terms [13]. Modulo identification of DX with the object of thosestreams σ : N Ñ X ` σ p n q ‰ inr ‹ for at most one n , « can be described asfollows: σ « σ if for every a , σ p n q “ a for some n iff σ p n q “ a for some n .Recall the embedding ι : X ˆ N , Ñ DX , and define the quotient of DX by the coequalizer D p X ˆ N q DX ~ DX D fst ι ‹ ρ X (2)which we assume to exist and be preserved by products. It is then straightforward that ~ D is a functor and ρ X is natural in X . It also follows that X now ÝÝÝÑ DX ρ ÝÝÑ ~ DX is strong.Following tradition, we denote ~ D (cid:73) Lemma 33. ρ . “ ρ . Defining ρ as a coequalizer of . and id in the first place does not seem to be sufficient, though,in particular, for showing the following property. We leave open the question of identifyingconditions under which it is possible. (cid:73) Proposition 34.
The following is a coequalizer: D p X ` p X ˆ N ` X ˆ N qq DX ~ DX r η, r η fst , ι p id ˆ s qss ‹ r η, r ι p id ˆ s q , η fst ss ‹ ρ X (3)The last proposition brings the definition of ρ in accordance with the intuition; the coproduct X ` p X ˆ N ` X ˆ N q covers three alternatives for σ « σ : either σ “ σ , or σ terminatesearlier that σ by a specified number, or the other way around. It can be verified that theembedding D p X ` p X ˆ N ` X ˆ N qq , Ñ DX ˆ DX is an internal equivalence relation. (cid:73) Theorem 35.
The following conditions are equivalent: for every X , coequalizer (2) is preserved by D ; every ~ DX extends to a search-algebra, so that each ρ X is a D -algebra morphism; for every X , p ~ DX, ρ now : X Ñ ~ DX q is a stable free Elgot algebra on X , ρ X is a D -algebra morphism and ρ X “ pp ρ X now ` id q out q ; ~ D extends to a strong monad, so that ρ is a strong monad morphism. (cid:73) Example 36 (Maybe-Monad) . Suppose that C is an LPO category, and recall that DX isisomorphic to X ˆ N `
1. It is then easy to check that (2) exists, it is preserved by products,~ DX – X ` ρ “ fst ` id : X ` Ñ X ˆ N `
1. Since D is the composition of p -- ˆ N q and p -- ` q , and both these functors preserve coequalizers (first as a left adjoint, and second byextensiveness of C ), D preserves (2). We thus obtain that D is an initial pre-Elgot monad.This covers instances of LPO categories from Example 6. Moreover, the initial pre-Elgotmonad is in fact an Elgot monad in this case: the profiles of the iteration operators p -- q and p -- q : agree up to rearrangement of summands, and the axioms of Definition 14 becomethe axioms of Definition 13, except for Codiagonal , which can be checked directly.Another direction for obtaining an initial pre-Elgot monad from (2) is by using a suitableinstance of the axiom of countable choice . In our setting this takes the following form. (cid:73)
Theorem 37.
Suppose that the coequalizers (2) are preserved by the exponentiation p -- q N . The equivalent conditions of Theorem 35 hold, in particular, ~ D is an initial (strong)pre-Elgot monad. If every (3) is an effective quotient, i.e. D p X ` p X ˆ N ` X ˆ N qq is a kernel pair of ρ X ,then ~ D is a strong Elgot monad with f : being the least fixpoint of r η, -- s ‹ f : C p X, T Y q Ñ C p X, T Y q for any f : X Ñ T p Y ` X q . The effectiveness assumption in clause is satisfied in any exact category (e.g. in anypretopos) – by definition, every internal equivalence relation there is effective. (cid:73) Example 38.
Recall that in
Top , coequalizers are computed as in
Set and are equippedwith the quotient topology. Note that DX is the set X ˆ N Y t8u whose base opens are tp x, n q | x P O u and tp x, k q | x P X, k ě n u Y t8u with n P N and O ranging over the opensof X . The collapse ~ DX computed with (2) is thus the set X Y t8u , whose opens are thoseof X and additionally the entire space X Y t8u , in particular, ~ D Sierpiński space .To obtain that (2) is preserved by p -- q N , it suffices to show that the opens of p X Y t8uq N are precisely those, whose inverse images under ρ N are open. This is in fact true for anyregular epi in Top . The effectiveness condition in is not vacuous for Top , which is not anexact category (and not even regular), but it can be checked manually.In every pretopos, preservation of (2) by p -- q N is a proper instance of the internal axiomof countable choice , or internal projectivity of N , which means preservation of epis by p -- q N ,roughly because every topos is exact and our quotienting morphism ρ is associated withan internal equivalence relation by Proposition 34. Theorem 37 can thus be related to theexisting result in synthetic domain theory, that Rosolini dominance, i.e. our Σ, is indeed adominance [31], which applies to Hyland’s effective topos [23], as it satisfies countable choice.Contrastingly, we cannot apply Theorem 37 to nominal sets, which falsify countable choice,however, as a Boolean topos, nominal sets fall into the scope of Example 36. Iteration and iteration theories emerged as unifying concepts for computer science semanticsand reasoning. By interpreting iteration suitably, one obtains a basic extensible equationallogic of programs, shown to be sound and complete across various models [10]. Elgot monadsimplement this inherently algebraic view in the general categorical realm of abstract datatypes and effects. The class of Elgot monads (over a fixed category) is stable under variouscategorial constructions (monad transformers), and thus one can build new Elgot monadsfrom old, but the most simple Elgot monad, the initial one, does not arise in this way.Here, we proposed an approach to defining an initial iteration structure from firstprinciples, characterized it in various ways, analysed conditions, under which it can beconcretely described, and to yield an Elgot monad. Unsurprisingly, these conditions generallycannot be lifted, as the previous research in type theory indicates. We consider broadeningthe scope in which results about notions of partiality apply, and unifying both classicaland non-classical models, as an important part of our contribution. Universal propertiesplay a central role in category theory, but many important concepts are not covered bythem. One example is Sierpiński space, which is fundamental in topology, duality theoryand domain theory. It follows from our results, that it is in fact a free uniform-iterationalgebra on one generator. We believe that the structure of our results can be reused in moresophisticated setting, such as semantics of hybrid systems , which require a notion of partiality, . Goncharov 13 combined with continuous evolution, and rise semantic issues, structurally similar to those,we considered here [15]. Another potential for taking further the present work is to considermore general shapes of the basic functor (instead of the current p X ` -- q ), prospectivelyleading to more sophisticated (non-)structural recursion scenarios (see e.g. [1]). References J. Adámek, S. Milius, and L. S. Moss. On well-founded and recursive coalgebras. In J. Goubault-Larrecq and B. König, editors,
Foundations of Software Science and Computation Structures ,pages 17–36, Cham, 2020. Springer International Publishing. J. Adámek, S. Milius, and J. Velebil. Elgot algebras.
Log. Meth. Comput. Sci. , 2, 2006. J. Adámek, S. Milius, and J. Velebil. Iterative algebras: How iterative are they.
Theory Appl.Categ , 19:61–92, 2008. J. Adámek, S. Milius, and J. Velebil. Elgot theories: a new perspective of the equationalproperties of iteration.
Math. Struct. Comput. Sci. , 21:417–480, 2011. T. Altenkirch and N. Danielsson. Partiality, revisited. In
Types for Proofs and Programs,TYPES 2016 , 2016. T. Altenkirch, N. Danielsson, and N. Kraus. Partiality, revisited - the partiality monad as aquotient inductive-inductive type. In J. Esparza and A. Murawski, editors,
Foundations ofSoftware Science and Computation Structures, FOSSACS 2017 , volume 10203 of
LNCS , pages534–549, 2017. S. Awodey.
Category Theory . Oxford University Press, Inc., New York, NY, USA, 2nd edition,2010. M. Barr. Fixed points in cartesian closed categories.
Theoretical Computer Science , 70(1):65–72,1990. A. Bauer. An injection from the Baire space to natural numbers.
Mathematical Structures inComputer Science , 25(7):1484–1489, 2015. S. Bloom and Z. Ésik.
Iteration theories: the equational logic of iterative processes . Springer,1993. A. Bucalo, C. Führmann, and A. K. Simpson. An equational notion of lifting monad.
Theor.Comput. Sci. , 294(1/2):31–60, 2003. V. Capretta. General recursion via coinductive types.
Log. Meth. Comput. Sci. , 1(2), 2005. J. Chapman, T. Uustalu, and N. Veltri. Quotienting the delay monad by weak bisimilarity.In
Theoretical Aspects of Computing, ICTAC 2015 , volume 9399 of
LNCS , pages 110–125.Springer, 2015. J. R. B. Cockett and S. Lack. Restriction categories I: categories of partial maps.
Theoreticalcomputer science , 270(1-2):223–259, 2002. T. L. Diezel and S. Goncharov. Towards Constructive Hybrid Semantics. In Z. M. Ariola,editor, , volume 167 of
Leibniz International Proceedings in Informatics (LIPIcs) , pages24:1–24:19, Dagstuhl, Germany, 2020. Schloss Dagstuhl–Leibniz-Zentrum für Informatik. C. Elgot. Monadic computation and iterative algebraic theories. In
Logic Colloquium 1973 ,volume 80 of
Studies in Logic and the Foundations of Mathematics , pages 175 – 230. Elsevier,1975. M. H. Escardó and C. M. Knapp. Partial Elements and Recursion via Dominances inUnivalent Type Theory. In V. Goranko and M. Dam, editors, , volume 82 of
Leibniz International Proceedings inInformatics (LIPIcs) , pages 21:1–21:16, Dagstuhl, Germany, 2017. Schloss Dagstuhl–Leibniz-Zentrum fuer Informatik. S. Goncharov, S. Milius, and C. Rauch. Complete Elgot monads and coalgebraic resumptions.In
Mathematical Foundations of Programming Semantics, MFPS 2016 , ENTCS, 2016. S. Goncharov, C. Rauch, and L. Schröder. Unguarded recursion on coinductive resumptions.In
Mathematical Foundations of Programming Semantics, MFPS 2015 , ENTCS, 2015. S. Goncharov and L. Schröder. A relatively complete generic Hoare logic for order-enrichedeffects. In
Proc. 28th Annual Symposium on Logic in Computer Science (LICS 2013) , pages273–282. IEEE, 2013. S. Goncharov, L. Schröder, C. Rauch, and J. Jakob. Unguarded recursion on coinductiveresumptions.
Logical Methods in Computer Science , 14(3), 2018. . Goncharov 15 S. Goncharov, L. Schröder, C. Rauch, and M. Piróg. Unifying guarded and unguarded iteration.In J. Esparza and A. Murawski, editors,
Foundations of Software Science and ComputationStructures, FoSSaCS 2017 , volume 10203 of
LNCS , pages 517–533. Springer, 2017. J. Hyland. The effective topos. In A. Troelstra and D. van Dalen, editors,
The L. E. J. BrouwerCentenary Symposium , volume 110 of
Studies in Logic and the Foundations of Mathematics ,pages 165–216. Elsevier, 1982. J. M. E. Hyland. First steps in synthetic domain theory. In
Category Theory , volume 1144 of
LNM , pages 131–156. Springer, 1992. P. T. Johnstone. On a topological topos.
Proceedings of the London mathematical society ,3(2):237–271, 1979. C. M. Knapp.
Partial functions and recursion in univalent type theory . PhD thesis, Universityof Birmingham, UK, 2018. A. Kock. Strong functors and monoidal monads.
Archiv der Mathematik , 23(1):113–120, 1972. B. Lawvere. An elementary theory of the category of sets.
Proceedings of the National Academyof Sciences of the United States of America , 52:1506–1511, 1964. S. Mac Lane.
Categories for the Working Mathematician . Springer, 1971. E. Moggi. Notions of computation and monads.
Inf. Comput. , 93:55–92, 1991. G. Rosolini.
Continuity and Effectiveness in Topoi . PhD thesis, University of Oxford, 1986. A. Simpson and G. Plotkin. Complete axioms for categorical fixed-point operators. In
Logicin Computer Science, LICS 2000 , pages 30–41, 2000. T. Univalent Foundations Program.
Homotopy Type Theory: Univalent Foundations ofMathematics . https://homotopytypetheory.org/book , Institute for Advanced Study, 2013. T. Uustalu. Generalizing substitution.
ITA , 37:315–336, 2003. N. Veltri.
A Type-Theoretical Study of Nontermination . PhD thesis, Tallinn University ofTechnology, 2017.
A Appendix: Omitted Details and ProofsA.1 Axioms of Strength X ˆ T Y T YT p X ˆ Y q τ snd T snd p X ˆ Y q ˆ T Z T pp X ˆ Y q ˆ Z q X ˆ p Y ˆ T Y q X ˆ T p Y ˆ Z q T p X ˆ p Y ˆ Z qq assoc τ T associd ˆ τ τ X ˆ Y T p X ˆ Y q X ˆ T Y id ˆ η η τ X ˆ T T Y X ˆ T YT p X ˆ T Y q T T p X ˆ Y q T p X ˆ Y q τ id ˆ µ τT τ µ A.2 Proof of Proposition 2
We will need the following (cid:73)
Lemma 39.
Let f : X Ñ DY . Then . f ‹ “ p . f q ‹ “ f ‹ . ; τ p id ˆ . q “ . τ . Proof.
For the first clause, note that out r f, p . f q ‹ s out “ r out f, r out . f, inr p . f q ‹ s out s out “ r out f, inr r f, p . f q ‹ s out s out , which implies r f, p . f q ‹ s out “ f ‹ , for the resulting equation is uniquely satisfied by f ‹ . Now, out p . f q ‹ “ r out . f, inr p . f q ‹ s out “ inr r f, p . f q ‹ s out “ inr f ‹ “ out p . f ‹ q , which implies . f ‹ “ p . f q ‹ , since out is an isomorphism.Analogously, out f ‹ . “ r out f, inr f ‹ s out . “ r out f, inr f ‹ s out inr “ inr f ‹ “ out . f ‹ , and therefore f ‹ . “ . f ‹ .Let us proceed with the second clause. By definition, out τ “ p id ` τ q dstr p id ˆ out q ,which implies τ p id ˆ out -1 q “ out -1 p id ` τ q dstr . Hence, τ p id ˆ . q “ τ p id ˆ out -1 q p id ˆ inr q“ out -1 p id ` τ q dstr p id ˆ inr q“ out -1 p id ` τ q inr “ out -1 inr τ “ . τ, and we are done. (cid:74) Let us continue with the proof of Proposition 2. It is easy to see that the dual ˆ τ : DX ˆ Y Ñ D p X ˆ Y q of τ is a final coalgebra morphism from p DX ˆ Y, dstl p out ˆ id q : DX ˆ Y Ñ X ˆ Y ` DX ˆ Y q to p D p X ˆ Y q , out q where dstl is the obvious dual of dstr . We needto to check that ˆ τ ‹ τ “ τ ‹ ˆ τ . Using the elementary properties of strength, distributivitytransformations and Lemma 39, we obtain: out ˆ τ ‹ τ “ r out ˆ τ, inr ˆ τ ‹ s out τ . Goncharov 17 “ r out ˆ τ, inr ˆ τ ‹ s p id ` τ q dstr p id ˆ out q“ rp id ` ˆ τ q dstl p out ˆ id q , inr ˆ τ ‹ τ s dstr p id ˆ out q“ rp id ` ˆ τ q dstl , inr ˆ τ ‹ τ p out -1 ˆ id qs dstr p out ˆ out q“ rp id ` ˆ τ q dstl , inr ˆ τ ‹ D p out -1 ˆ id q τ s dstr p out ˆ out q“ rp id ` ˆ τ q dstl , inr p ˆ τ p out -1 ˆ id qq ‹ τ s dstr p out ˆ out q“ rp id ` ˆ τ q dstl , inr p out -1 p id ` ˆ τ q dstl q ‹ τ s dstr p out ˆ out q“ rp id ` ˆ τ q dstl , inr p out -1 p id ` ˆ τ qq ‹ p D dstl q τ s dstr p out ˆ out q“ rp id ` ˆ τ q dstl , inr p out -1 p id ` ˆ τ qq ‹ rp D inl q τ, p D inr q τ s dstl s dstr p out ˆ out q“ r id ` ˆ τ, inr rp out -1 inl q ‹ τ, p out -1 inr ˆ τ q ‹ τ ss p dstl ` dstl q dstr p out ˆ out q“ r id ` ˆ τ, inr r η ‹ τ, p out -1 inr ˆ τ q ‹ τ ss p dstl ` dstl q dstr p out ˆ out q“ r id ` ˆ τ, inr r τ, p . ˆ τ q ‹ τ ss p dstl ` dstl q dstr p out ˆ out q“ r id ` ˆ τ, inr r τ, . ˆ τ ‹ τ ss p dstl ` dstl q dstr p out ˆ out q . That is, ˆ τ ‹ τ is a fixpoint of f ÞÑ out -1 r id ` ˆ τ, inr r τ, . f ss p dstl ` dstl q dstr p out ˆ out q . (4)on C p DX ˆ DY, D p X ˆ Y qq . By a symmetric argument, also τ ‹ ˆ τ is a fixpoint of the samemap. Let us denote p dstl ` dstl q dstr p out ˆ out q by w . For every fixpoint f of (4): f “ out -1 r id ` ˆ τ, inr r τ, . f ss w “ out -1 rr inl , out f s , inr r η, f s ‹ s r inl `p D inl q ˆ τ, inr rp D inl q τ, . η inr ss w “ r η, f s ‹ out -1 r inl `p D inl q ˆ τ, inr rp D inl q τ, η inr ss w and, clearly, out -1 r inl `p D inl q ˆ τ, inr rp D inl q τ, η inr ss w : DX ˆ DY Ñ D p X ˆ Y ` DX ˆ DY q is guarded. By Proposition 1 (4) this implies τ ‹ ˆ τ “ ˆ τ ‹ τ . (cid:74) A.3 Proof of Proposition 10
Of course, the first two axioms are just corresponding instances of their guarded versions.We only need to show that
Folding is equivalent to
Compositionality in presence of theother two axioms. Let us first equivalently reformulate the
Folding axiom. Note thatby uniformity, rp id ` inl q f, inr h s inl “ f and also by Fixpoint , p f ` h q inl “ r id , p f ` h q s p f ` h q inl “ f . Analogously, p f ` h q inr “ r id , p f ` h q s p f ` h q inr “ p f ` h q h ,and subsequently, by uniformity, p f ` h q inr “ pp f ` id q h q . We have thus equivalentlyreduced Folding to rp id ` inl q f, inr h s inr “ pp f ` id q h q . Now, the task of checking that this is equivalent to
Compositionality amounts to showingthat prp id ` inl q f, inr inr s r inl , h sq inr “ rp id ` inl q f, inr h s inr follows from Fixpoint and
Uniformity . Indeed, by
Uniformity , prp id ` inl q f, inr inr s r inl , h sq “ pp id ` r inl , h sqrp id ` inl q f, inr inr sq r inl , h s“ prp id ` inl q f, inr h sq r inl , h s , hence prp id ` inl q f, inr inr s r inl , h sq inr “ prp id ` inl q f, inr h sq h. On the other hand, using
Fixpoint , rp id ` inl q f, inr h s inr “ r id , rp id ` inl q f, inr h s s inr h “ rp id ` inl q f, inr h s h. In summary, we obtain the desired identity. (cid:74)
A.4 Proof of Lemma 16
Existence of all free unguarded uniform-iteration algebras yields an adjunction between C and the category of unguarded uniform-iteration algebras over C . Let us call the lattercategory E and the corresponding adjunction U $ F . The only nonobvious condition ofBeck’s monadicity theorem is existence and preservation of U -split coequalizers. Consider asplit coequalizer U A U B Z
UgUf e (5)in C , i.e. for suitable t : U B Ñ U A , s : Z Ñ U B , e s “ id , s t “ g t , and f t “ id . Let C beuniform-iteration algebra whose carrier is Z and whose iteration operator is defined as follows p h : X Ñ Z ` X q ˆ “ e pp s ` id q h q . Hence e lifts to an uniform-iteration algebra morphism,which is moreover a coequalizer of f and g in E . The image of the resulting coequalizer in E is precisely (5), and thus we have shown that U preserves U -split coequalizers. Therefore, L extends to a monad whose category of algebras is precisely E . (cid:74) A.5 Proof of Lemma 18
Assume stability of KY . It is easy to check that fst : X ˆ A Ñ X is a uniform-iterationalgebra in C { X , which implies that id ˆ η : X ˆ Y Ñ X ˆ KY is the unit morphism for X ˆ KY . Let us fix some f : X ˆ Y Ñ A and note that h fst , f i : X ˆ Y Ñ X ˆ A is amorphism in C { X . Using the universal property of fst : X ˆ A Ñ X in C { X we obtain aunique iteration preserving morphism u : X ˆ KY Ñ X ˆ A in C { X for which the diagram X ˆ KY X ˆ AX ˆ Y X u fst fstid ˆ η h fst ,f i fst commutes. This entails that u is of the form h fst , f i where the requisite property of f follows from the fact that u is iteration preserving in C { X . Conversely, from a unique f ,subject to the declared properties we can render u as h fst , f i . (cid:74) A.6 Proof of Lemma 20
It suffices to show that p h ` id q dstr p id ˆ p snd ` id q f q h pp fst ` id q f q , id i “ p id ` h pp fst ` id q f q , id i q p h ` id q f . Goncharov 19 from which the claim follows by uniformity. After simplifications we obtain p h ` id q dstr h pp fst ` id q f q , p snd ` id q f i “ p h ` h pp fst ` id q f q , id i q f, which is verified directly as follows: p h ` id q dstr ppp fst ` id q f q p z q , p snd ` id q p f p z qqq“ case f p z q of inl p p, q q ÞÑ inl h ppp fst ` id q f q p z q , q q ; inr z ÞÑ inr ppp fst ` id q f q p z q , z q“ case f p z q of inl p p, q q ÞÑ inl h pr fst , pp fst ` id q f q sp f p z qq , q q ; inr z ÞÑ inr pr fst , pp fst ` id q f q sp f p z qq , z q“ case f p z q of inl p p, q q ÞÑ inl h pr fst , pp fst ` id q f q s inl p p, q q , q q ; inr z ÞÑ inr pr fst , pp fst ` id q f q s inr z , z q“ case f p z q of inl p p, q q ÞÑ inl p p, q q ; inr z ÞÑ inr ppp fst ` id q f q p z q , z q“ p h ` h pp fst ` id q f q , id i qp f p z qq . This completes the proof. (cid:74)
A.7 Proof of Theorem 22 (cid:73)
Lemma 40. K is a commutative monad.
Proof.
Let τ : X ˆ KY Ñ K p X ˆ Y q be strength of K and let ˆ τ : KX ˆ Y Ñ K p X ˆ Y q be its obvious transpose. We need to show that ˆ τ ‹ τ “ τ ‹ ˆ τ . Note that KX ˆ KY is anuniform-iteration algebra by Lemma 11 (1). It is easy to see that both diagrams KX ˆ KY K p X ˆ Y q X ˆ Y τ ‹ ˆ τη ˆ η η KX ˆ KY K p X ˆ Y q X ˆ Y ˆ τ ‹ τη ˆ η η commute. It is therefore sufficient for obtaining the desired identity ˆ τ ‹ τ “ τ ‹ ˆ τ to showthat both ˆ τ ‹ τ and τ ‹ ˆ τ are iteration preserving. We confine to the former case, from whichthe second case is obtained by a symmetric argument. Let f : Z Ñ KX ˆ KY ` Z . We needto show thatˆ τ ‹ τ h pp fst ` id q f q , pp snd ` id q f q i “ pp ˆ τ ‹ τ ` id q f q . This in fact essentially follows from Lemma 20: pp ˆ τ ‹ τ ` id q f q “ ˆ τ ‹ pp τ ` id q f q “ ˆ τ ‹ pp τ ` id q dstr p id ˆ p snd ` id q f qq h pp fst ` id q f q , id i “ ˆ τ ‹ τ p id ˆ pp snd ` id q f q q h pp fst ` id q f q , id i “ ˆ τ ‹ τ h pp fst ` id q f q , pp snd ` id q f q i . This completes the proof. (cid:74)
Let us continue the proof of the theorem.
We have already shown that K is strong and commutative. It remains to establish thelaw (1). Since K h η, id i “ p η h η, id i q ‹ , using the definition of Kleisli star for K , it suffices toshow that τ ∆ is a unique iteration preserving morphism for which the diagram KX K p KX ˆ X q X τ ∆ η η h η, id i commutes. Indeed, τ ∆ η “ τ p id ˆ η q h η, id i “ η h η, id i , and τ ∆ is iteration preserving byLemma 21. (cid:74) A.8 Restriction Categories and Equational Lifting Monads
Recall the axioms of restriction categories [14] for further reference. f ‹ p dom f q “ f ( RST ) p dom f q ‹ p dom g q “ p dom g q ‹ p dom f q ( RST ) dom p g ‹ p dom f qq “ p dom g q ‹ p dom f q ( RST ) p dom h q ‹ f “ f ‹ dom p h ‹ f q ( RST )where f : X Ñ KY , g : X Ñ KZ and h : Y Ñ KZ .For the rest of the section, let us fix an equational lifting monad T , whose Kleislicategory C T is thus a restriction category. We then collect miscellaneous facts about T forfurther reference. (cid:73) Lemma 41.
Given f : X Ñ T Z , g : Y Ñ T Z , dom r f, g s “ rp T inl q dom f, p T inr q dom g s . Proof.
By definition, dom r f, g s “ p T fst q τ h id , r f, g s i “ p T fst q τ r h inl , f i , h inr , g i s“ rp T fst q τ h inl , f i , p T fst q τ h inr , g i s“ rp T inl q p T fst q τ h id , f i , p T inr q p T fst q τ h id , g i s“ rp T inl q dom f, p T inr q dom g s and we are done. (cid:74)(cid:73) Lemma 42.
For any f : X Ñ T Y , p T η q f “ T f p dom f q . Proof.
Note that
T f p dom f q “ p η f q ‹ p id ‹ η f q , and hence, by RST , T f p dom f q “p dom id q ‹ η f “ p dom id q f . Since dom id “ p T fst q τ h id , id i “ p T fst q T h η, id i “ T η , andwe are done. (cid:74)(cid:73)
Lemma 43. ˆ τ ‹ τ h T fst , T snd i “ id . Proof.
Indeed, ˆ τ ‹ τ h T fst , T snd i “ ˆ τ ‹ T p T fst ˆ snd q τ ∆ “ ˆ τ ‹ T p T fst ˆ snd q T h η, id i “ ˆ τ ‹ T h η fst , snd i “ p ˆ τ p η ˆ id qq ‹ “ η ‹ “ id . (cid:74)(cid:73) Lemma 44.
Suppose that T is equipped with an operator p -- q : : C p X, T p Y ` X qq Ñ C p X, T Y q that satisfies Fixpoint , and
Uniformity . Then for any f : X Ñ T p Y ` X q , f : “ p f ‹ p dom f : qq : . . Goncharov 21 Proof.
Using
Uniformity , f : “ p T p id ` η q f q : η . Next, using Lemma 42, f : “ p f : q ‹ p dom f : q“ pp T p id ` η q f ‹ q : η q ‹ p dom f : q“ pp T p id ` η q f ‹ q : q ‹ p T η q p dom f : q“ pp T p id ` η q f ‹ q : q ‹ T p dom f : q dom p dom f : q“ pp T p id ` η q f ‹ q : p dom f : qq ‹ p dom f : q . We then show that p T p id ` η q f ‹ q : p dom f : q “ p f ‹ p dom f : qq : . (6)This will entail the goal using Fixpoint as follows: f : “ pp T p id ` η q f ‹ q : p dom f : qq ‹ p dom f : q“ pp f ‹ p dom f : qq : q ‹ p dom f : q“ r η, p f ‹ p dom f : qq : s ‹ f ‹ p dom f : q ‹ p dom f : q“ r η, p f ‹ p dom f : qq : s ‹ f ‹ p dom f : q ‹ “ p f ‹ p dom f : qq : . We show (6) by
Uniformity after establishing another auxiliary property: f ‹ p dom f : q “ r η inl , p T inr q p dom f : qs ‹ f Indeed, by
Fixpoint and
RST , f ‹ p dom f : q “ f ‹ dom pr η, f : s ‹ p dom f qq“ p dom r η, f : sq ‹ f “ p T fst q p τ h id , r η, f : s i q ‹ f “ p T fst q r τ h inl , η i , τ h inr , f : i s ‹ f “ rp T fst q η h inl , id i , p T fst q τ h inr , f : i s ‹ f “ r η inl , p T inr q p dom f : qs ‹ f. Finally, T p id ` η q f ‹ p dom f : q“ T p id ` η q r η inl , p T inr q p dom f : qs ‹ f “ r η inl , p T inr q p T η q p dom f : qs ‹ f “ r η inl , p T inr q T p dom f : q p dom f : qs ‹ f // Lemma 42 “ T p id ` dom f : q f ‹ p dom f : q , which entails (6) by Uniformity . (cid:74) A.9 Proof of Proposition 23 (cid:73)
Lemma 45.
For any f : Z Ñ Y ` Z , ` X ˆ Z p η fst ` id q dstr p id ˆ f q ÝÝÝÝÝÝÝÝÝÝÝÝÝÝÑ KX ` X ˆ Z ˘ v ` X ˆ Z η fst ÝÝÝÑ KX ˘ . Proof.
The goal is equivalent to pp η fst ` id q dstr p id ˆ f qq “ p K fst q dom ppp η fst ` id q dstr p id ˆ f qq q . By transforming the right-hand expression as follows p K fst q dom ` pp η fst ` id q dstr p id ˆ f qq ˘ “ p K fst q p K fst q τ h id , pp η fst ` id q dstr p id ˆ f qq i “ K p fst fst q ` p τ ` id q dstr p id ˆ p η fst ` id q dstr p id ˆ f qq ˘ ∆ “ ` p K p fst fst q τ p id ˆ η fst q ` id q dstr p id ˆ dstr p id ˆ f qq ˘ ∆ “ ` p K p fst fst q η p id ˆ fst q ` id q dstr p id ˆ dstr p id ˆ f qq ˘ ∆ “ ` p η fst fst ` id q dstr p id ˆ dstr p id ˆ f qq ˘ ∆Next, p id ` fst ˆ snd q p η fst fst ` id q dstr p id ˆ dstr p id ˆ f qq“ p η fst p fst ˆ snd q ` fst ˆ snd q dstr p id ˆ dstr p id ˆ f qq“ p η fst ` id q dstr p fst ˆp snd ` snd q dstr p id ˆ f qq“ p η fst ` id q dstr p fst ˆ f snd q“ p η fst ` id q dstr p id ˆ f q p fst ˆ snd q , Hence, by uniformity, pp η fst ` id q dstr p id ˆ f qq “ pp η fst ` id q dstr p id ˆ f qq p fst ˆ snd q ∆ “ pp η fst fst ` id q dstr p id ˆ dstr p id ˆ f qqq ∆ “ p K fst q dom pp η fst ` id q dstr p id ˆ f qq , and we are done. (cid:74) We are left to show that the order and the bottom elements are respected by the Kleislicomposition.
Right monotonicity of composition:
Let f v g , i.e. f “ g p dom f q . Then h g dom p h f q “ h g dom p h g p dom f qq “ h g dom p h g q p dom f q “ h g p dom f q “ h f , hence h f v h g . Left monotonicity of composition:
Analogously, if f “ g p dom f q then g u dom p f u q “ g u dom p g p dom f q u q “ g dom p g p dom f qq u “ g p dom g q p dom f q u “ g p dom f q u “ f u ,hence f u v g u . Monotonicity of strength:
Suppose that f v g , i.e. f “ g ‹ p dom f q . Then p τ h id , g i q ‹ dom p τ h id , f i q“ p τ h id , g i q ‹ p K fst q τ h id , τ h id , f ii “ p τ h id , g i q ‹ p K fst fst q τ hh id , id i , f i “ p τ h id , g i q ‹ p K fst q K p fst ˆ id q τ hh id , id i , f i “ p τ h id , g i q ‹ p K fst q τ h id , f i “ p τ p id ˆ g q fst q ‹ τ hh id , id i , f i “ p τ p id ˆ g fst qq ‹ τ h id , τ h id , f ii . Goncharov 23 “ p τ p id ˆ g qq ‹ τ h id , p K fst q τ h id , f ii “ p τ p id ˆ g qq ‹ τ h id , dom f i “ τ p id ˆ g ‹ q h id , dom f i “ τ h id , g ‹ p dom f q i . Strictness of strength: τ p id ˆ Kq “ τ p id ˆ inr q“ pp τ ` id q dstr p id ˆ inr qq “ pp τ ` id q inr q “ inr “ K . Right strictness of composition:
The equation f ‹ K “ K follows from the fact that f ‹ preserves iteration. Left strictness of composition:
The equation K ‹ f “ K is much more subtle. First,observe that K f “ K , which easily follows by uniformity. We are left to show that K ‹ “ K . Since K η “ K ‹ η “ K , by definition of the lifting K ‹ , it suffices to show that K isiteration preserving, i.e. for any f : X Ñ KY ` X , K f “ ppK ` id q f q , equivalently, that ppK ` id q f q “ K . Note that ppK ` id q f q “ ppK ` id q dstr p id ˆ f qq ∆. Indeed, pK ` snd q dstr p id ˆ f q “ pK ` id q f snd , hence, by uniformity, ppK ` id q f q “ ppK ` id q f q snd ∆ “ ppK ` id q dstr p id ˆ f qq ∆ . Now, ppK ` id q f q “ ppK ` id q dstr p id ˆ f qq ∆ “ ppK ‹ η fst ` id q dstr p id ˆ f qq ∆ “ K ‹ pp η fst ` id q dstr p id ˆ f qq ∆ v K ‹ η fst ∆ // Lemma 45, monotonicity “ K . Therefore, indeed, ppK ` id q f q “ K . (cid:74) A.10 Proof of Proposition 25
For the identity, we haveˆ τ ‹ τ ∆ “ ˆ τ ‹ K h η, id i “ p ˆ τ h η, id i q ‹ “ p η ∆ q ‹ “ K ∆ . For the inequality, note that p K fst q ˆ τ ‹ τ h f, g i “ fst ‹ τ h f, g i “ p fst p f ˆ id qq ‹ τ h id , g i “ f ‹ p K fst q τ h id , g i “ f ‹ p dom g q . Hence, p K fst q ˆ τ ‹ τ h f, g i “ f ‹ p dom g q v f ‹ η “ f . (cid:74) A.11 Proof of Theorem 27
For the first clause we need to show that f h “ f fst ç f h . Since p f fst ç f h q p x, o q “ f x ç K“ K , p f fst ç f h q p x, s n q “ case f p x q of inl r ÞÑ r ç f h p x, o q ; inl y ÞÑ f p x q ç f h p x, s n q“ case f p x q of inl r ÞÑ r ; inl y ÞÑ f p y q ç f h p y, n q ,f fst ç f h satisfies the definition for f h , and therefore we obtain the identity in question.We proceed with the second clause. Suppose that f h v g fst , and show f v g . The ideais to introduce such h : X ˆ N Ñ K N ` X ˆ N that h p x, o q runs like f p x q , but instead ofthe final result of f p x q delivers the number of steps needed to reach the result. We thenshow that f “ p f h q ‹ τ h id , h h id , o ! ii , which entails the desired property: f “ p f h q ‹ τ h id , h h id , o ! iiv p g fst q ‹ τ h id , h h id , o ! ii “ fst ‹ τ h g, h h id , o ! ii “ g ç h h id , o ! iv g. Thus we are left to produce the requisite h . Let h “ p η snd ` id q dstl p f ˆ s q . We then have p f h q ‹ τ h id , h h id , o ! ii “ p f h q ‹ τ p id ˆ h q h id , h id , o ! ii “ p f h q ‹ pp τ ` id q dstr p id ˆ h qq h id , h id , o ! ii // Proposition 19 “ ppp f h q ‹ τ ` id q dstr p id ˆ h qq h id , h id , o ! ii We are left to show that the latter is equal to f . We strengthen the goal slightly and show ppp f h q ‹ τ ` id q dstr p id ˆ h qq h fst , h w, snd ii “ f w (7)instead, where w : X ˆ N Ñ X is defined by primitive recursion as follows: w p x, o q “ x, w p x, s n q “ case f p x q of inl r ÞÑ x ; inr y ÞÑ w p y, n q . We will need the following facts: w p x, s n q “ case f p w p x, n qq of inl r ÞÑ w p x, n q ; inr y ÞÑ y, (8) f h p x, s n q “ case f p w p x, n qq of inl r ÞÑ r ; inr y ÞÑ y, (9)which both follow by induction. The former one follows from case f p w p x, o qq of inl r ÞÑ w p x, o q ; inr y ÞÑ y “ w p x, s o q , . Goncharov 25 case f p w p x, s n qq of inl r ÞÑ w p x, s n q ; inr y ÞÑ y “ case f p x q of inl r ÞÑ w p x, s n q ; inr y ÞÑ case f p w p y, n qq of inl r ÞÑ w p x, s n q ; inr z ÞÑ z “ case f p x q of inl r ÞÑ x ; inr y ÞÑ case f p w p y, n qq of inl r ÞÑ w p y, n q ; inr z ÞÑ z. To show (9), observe that f p w p x, s n qq “ case f p x q of inl r ÞÑ f p x q ; inr y ÞÑ f p w p y, n qq“ case f p x q of inl r ÞÑ inl r ; inr y ÞÑ f p w p y, n qq . Hence, case f p w p x, o qq of inl r ÞÑ r ; inr y ÞÑ K “ f p x, s o q , case f p w p x, s n qq of inl r ÞÑ r ; inr y ÞÑ y “ case f p x q of inl r ÞÑ r ; inr y ÞÑ case f p w p y, n qq of inl r ÞÑ r ; inr y ÞÑ K . Now, ppp f h q ‹ τ ` id q dstr p id ˆ h qq p x, p w p x, n q , n qq“ case f p w p x, n qq of inl r ÞÑ inl f h p x, s n q ; inr y ÞÑ inr p x, p y, s n qq“ case f p w p x, n qq of inl r ÞÑ inl f h p x, s n q ; inr y ÞÑ inr p x, p w p x, s n q , s n qq // (8) “ case f p w p x, n qq of inl r ÞÑ inl r ; inr z ÞÑ inr p x, p w p x, s n q , s n qq . // (9) “ pp snd ` fst q dstr h id ˆ s , f w i q p x, n q . Therefore, by
Uniformity , ppp f h q ‹ τ ` id q dstr p id ˆ h qq h fst , h w, snd ii “ pp snd ` fst q dstr h id ˆ s , f w i q (10)Next, pp id ` w q pp snd ` fst q dstr h id ˆ s , f w i qq p x, n q“ case f p w p x, n qq of inl r ÞÑ inl r ; inr y ÞÑ inr w p x, s n q“ case f p w p x, n qq of inl r ÞÑ inl r ; inr y ÞÑ inr y // (8) “ f p w p x, n qq , from which, again by Uniformity , we obtain pp snd ` fst q dstr h id ˆ s , f w i q “ f w. (11)By combining (10) with (11), we obtain (7), which completes the proof. (cid:74) A.12 Proof of Corollary 28
Suppose that r id , g s f v g for some g : X Ñ KY , i.e. r id , g s f “ g ‹ dom pr id , g s f q . Thisyields case f p x q of inl r ÞÑ r ; inr y ÞÑ g p y q “ case f p x q of inl r ÞÑ g p x q ç r ; inr y ÞÑ g p x q ç g p y q This entails g p x q ç f h p x, o q “ K ,g p x q ç f h p x, s n q “ case f p x q of inl r ÞÑ r ; inr y ÞÑ g p x q ç f h p y, n q . By induction, f h “ g fst ç f h , i.e. f h v g fst , hence, by Theorem 27, f v g . (cid:74) A.13 Proof of Theorem 29 (cid:73)
Corollary 46.
Each KX is a free Elgot algebra on X . Proof.
By Proposition 10, it remains to show
Folding . Let h : Y Ñ X ` Y and f : X Ñ KZ ` X . It easily follows by uniformity that rp id ` inl q f, inr h s inl “ f . Then rp id ` inl q f, inr h s “ r id , rp id ` inl q f, inr h s s rp id ` inl q f, inr h s“ r f , rp id ` inl q f, inr h s h s“ r id , rp id ` inl q f, inr h s s p f ` h q , p f ` h q “ r id , p f ` h q s p f ` h q“ rr id , f s f, p f ` h q h s“ rr id , p f ` h q inl s f, p f ` h q h s“ r id , p f ` h q s rp id ` inl q f, inr h s . That is, both rp id ` inl q f, inr h s and p f ` h q mutually satisfy the fixpoint identities ofeach other. Hence, by Theorem 27 they are mutually smaller under v , and hence equal. (cid:74) We build on Corollary 46. To show that K is pre-Elgot, we are left to check the remainingproperty: h ‹ f “ pp h ‹ ` id q f q where f : Z Ñ KX ` Z and h : X Ñ KY . This is, in fact aconsequence of Compositionality : pp h ‹ ` id q f q “ ppp inl h ‹ q ` id q f q “ prp id ` inl q inl h ‹ , inr inr s r inl , f sq inr “ pp h ‹ ` inr q r inl , f sq inr “ pp h ‹ ` id q f q . Now, given any pre-Elgot monad T , for every X we define α X : KX Ñ T X as the uniqueElgot algebra morphism such that α X η X “ η X by Corollary 46. Naturality of α X in X follows from the diagram: KX KY T YT XX
Kfα αT fη η where we make use of the fact that both Kf “ p η f q ‹ and T f “ p η f q ‹ are iterationpreserving since both K and T are pre-Elgot, hence both α p Kf q and p T f q α are iterationpreserving. Analogously, since for every f : X Ñ KY , f ‹ is iteration preserving and α f ‹ η “ α f “ p α f q ‹ α η , α f ‹ “ p α f q ‹ α , α respects Kleisli lifting.Finally, to show that K is initial strong pre-Elgot, we are left to show that for strong pre-Elgot T , the induced α : K Ñ T respects strength, i.e. α τ “ τ p id ˆ α q . Since α τ p id ˆ η q “ α η “ η “ τ p id ˆ η q “ τ p id ˆ α q p id ˆ η q , we are done by stability of the KX . (cid:74) . Goncharov 27 A.14 Proof of Proposition 31
Let us show the first clause. First, let us check that given a : DA Ñ A , the induced operator p -- q indeed satisfies the axioms of uniform-iteration algebras. Fixpoint
Let every f : X Ñ A ` X . Then f “ a p coit f q“ a r now , . s out p coit f q“ r a now , a . s out p coit f q“ r id , a s p id ` coit f q f “ r id , a p coit f qs f “ r id , f s f, Uniformity
Let f : X Ñ A ` X , g : Y Ñ A ` Y and h : X Ñ Y , and assume that p id ` h q f “ g h . We have to show that f “ g h . Indeed, f “ a p coit f q“ a p coit g q h “ g h. Conversely, given a uniform-iteration algebra structure p A, p -- q q , observe that out now “r id , out s out now “ r id , out s inl “ id and out . “ r id , out s out . “ r id , out s inr “ out .Let us show that the given passages are mutually inverse. On the one hand, a p coit out q “ a , and on the other hand, out p coit f q “ f by uniformity, since out p coit f q “p id ` coit f q f .Finally, given two uniform-iteration algebras p A, p -- q q and p B, p -- q q and a morphism h : A Ñ B , show that iteration preservation by h is equivalent to being a D -algebra morphism.If h is iteration preserving then out p Dh q “ p h ` Dh q out , which by uniformity entails out p Dh q “ pp h ` id q out q . Therefore, h out “ pp h ` id q out q “ out p Dh q , i.e. h is a D -coalgbra morphism. Conversely, if h is a D -algebra morphism, then for any f : X Ñ A ` X , h f “ h out p coit f q“ pp h ` id q out q p coit f q“ pp h ` id q f q , where the last step is by uniformity, for p h ` id q out p coit f q “ p h ` id q p id ` coit f q f “p id ` coit f q p h ` id q f .Let us proceed with the second clause. In the guarded case, the requisite equival-ence between Elgot algebras and D -algebras is shown previously [18, Theorem 5.7]. Weare left to check that the “unguardedness condition” a “ r id , a s out of search-algebras p A, a : DA Ñ A q corresponds to the requirement that ˆ a “ id on the respective Id-guardedElgot algebras p A, ˆ a : A Ñ A, p -- q q . The involved connection between a and ˆ a is pre-cisely: a “ out . Now, if ˆ a “ id then out “ r id , out s out and if out “ r id , out s out then ˆ a “ r id , r ˆ a, ˆ a ˆ a out s out s out . now “ r id , ˆ a out s out . now “ out . now “r id , r id , out s out s out . now “ id . (cid:74) A.15 ~ D is a strong functor ~ D is a strong functor and ρ is a strong natural transformation. Proof.
Recall that D is strong with a strength τ : X ˆ DY Ñ D p X ˆ Y q . By the axiomsof strength, τ p id ˆ ι ‹ q “ p τ p id ˆ ι qq ‹ τ , and it is easy to obtain by coinduction that τ p id ˆ ι q “ ι assoc - . In summary, τ p id ˆ ι ‹ q “ p ι assoc - q ‹ τ “ ι ‹ p D assoc - q τ . Using thefact that (2) is preserved by products, we introduce strength for ~ D as the universal map in X ˆ D p Y ˆ N q X ˆ DY X ˆ ~ DYD pp X ˆ Y q ˆ N q D p X ˆ Y q ~ D p X ˆ Y q id ˆ D fstid ˆ ι ‹ p D assoc - q τ X,Y ˆ N id ˆ ρ Y τ X,Y D fst ι ‹ ρ X ˆ Y The axioms of strength then follow automatically, as well as the fact that ρ is a strong naturaltransformation. (cid:74)(cid:73) Lemma 47.
The morphism h D fst , D snd i : D p X ˆ Y q Ñ DX ˆ DY is a section. Proof.
We define the requisite retraction DX ˆ DY Ñ D p X ˆ Y q as the composition w ˆ τ ‹ τ : DX ˆ DY Ñ D p X ˆ Y q where w “ ` D p X ˆ Y q r now inl , . now out s out ÝÝÝÝÝÝÝÝÝÝÝÝÝÑ D p X ˆ Y ` D p X ˆ Y qq ˘ . It is easy to check that out w factors through p inl ` id q , hence the application of the iterationoperator is legit. We next show that u “ ˆ τ ‹ τ h D fst , D snd i satisfies the following equation out u “ p id ` . u q out . From (2), recall that out ˆ τ ‹ τ “ r id ` ˆ τ, inr r τ, . ˆ τ ‹ τ ss p dstl ` dstl q dstr p out ˆ out q . Also, using the fact that dstr and dstl are isomorphisms, it is easy to show that p dstl ` dstl q dstr ∆ “ inl ∆ ` inr ∆. Therefore out u “ r id ` ˆ τ, inr r τ, . ˆ τ ‹ τ ssp dstl ` dstl q dstr h out p D fst q , out p D snd q i “ r id ` ˆ τ, inr r τ, . ˆ τ ‹ τ ssp dstl ` dstl q dstr h fst ` D fst , snd ` D snd i out “ r id ` ˆ τ, inr r τ, . ˆ τ ‹ τ ss ` p fst ˆ snd ` D fst ˆ snd q ` p fst ˆ D snd ` D fst ˆ D snd q ˘ p dstl ` dstl q dstr ∆ out “ r id ` ˆ τ, inr r τ, . ˆ τ ‹ τ ss ` p fst ˆ snd ` D fst ˆ snd q ` p fst ˆ D snd ` D fst ˆ D snd q ˘ p inl ` inr q out “ r id ` ˆ τ, inr r τ, . ˆ τ ‹ τ ss ` inl ∆ p fst ˆ snd q ` inr ∆ p D fst ˆ D snd q ˘ out “ r inl , inr . ˆ τ ‹ τ h D fst , D snd i s out . Goncharov 29 “ p id ` . u q out . Now wu “ r now inl , . now out s out u “ r now inl , . now out sp id ` . u q out “ r now inl , . now out . u s out “ r now inl , . now inr u s out “ D p id ` u q r now inl , . now inr s out . By uniformity, w u “ pr now inl , . now inr s out q . But id satisfies the fixpoint equation for w u : r now , id s ‹ r now inl , . now inr s out “ r now , . r now , id s ‹ now inr s out “ r now , . s out “ id . Therefore w u “ id . (cid:74)(cid:73) Lemma 48.
Let p A, a q be a search-algebra. Then for any X , τ A,X : A ˆ DX Ñ D p A ˆ X q is a retraction, whose section is h a p D fst q , D snd i : D p A ˆ X q Ñ A ˆ DX . Proof.
Using Lemma 47, we proceed to show that h D fst , D snd i “ h D fst , D snd i τ A,X h a p D fst q , D snd i , which is equivalent to D fst “ p Da q p D fst q τ h D fst , D snd i and D snd “ D snd . To obtainthe former equation, we show commutativity of the diagram D p A ˆ X q A ˆ X ` D p A ˆ X q DA ˆ DX DA ˆ p X ` DX q DA ˆ X ` DA ˆ DXD p DA ˆ X q DA ˆ X ` D p DA ˆ X q DDA DA ` DDADA A ` DA h D fst ,D snd i out now ˆ id ` h . p D fst q ,D snd i τ id ˆ out dstl id ` τD fst out fst ` D fst Da out a ` Da out Except for the top cell, the remaining ones commute by definition. Assume commutativityof the top cell for the time being. Then the composition on the right vertical edge is easilyseen to be equal to fst `p Da q p D fst q τ h D fst , D snd i . The resulting diagram then witnessesthe fact that p Da q p D fst q τ h D fst , D snd i is a coalgebra morphism, which must be equalto D fst by finality of the coalgebra p DA, out q .Finally, let us show commutativity of the top cell. Using the fact that out is an isomorph-ism, this amounts to showing dstl p id ˆ out q h D fst , D snd i out -1 inl “ inl p now ˆ id q , dstl p id ˆ out q h D fst , D snd i out -1 inr “ inr h . p D fst q , D snd i . Indeed, dstl p id ˆ out q h D fst , D snd i out -1 inl “ dstl p id ˆ out q h D fst , D snd i now “ dstl p id ˆ out q h now fst , now snd i “ dstl h now fst , inl snd i “ inl h now fst , snd i “ inl p now ˆ snd q , dstl p id ˆ out q h D fst , D snd i out -1 inr “ dstl p id ˆ out q h D fst , D snd i . “ dstl p id ˆ out q h . p D fst q , . p D snd q i “ dstl h . p D fst q , inr p D snd q i “ inr h . p D fst q , D snd i , and we are done. (cid:74) A.16 Proof of Lemma 32
Indeed, consider the commutative diagram D p A ˆ N q DDA X ˆ N Y Y
DιD fst
Da µ aa where the square commutes, since p DA, a q is a D -algebra (Proposition 31) and the trianglecommutes, because a ι “ fst , which easily follows by induction. (cid:74) A.17 Proof of Proposition 34
First, note that ρ r η, r η fst , ι p id ˆ s qss ‹ “ ρ ι ‹ r η h id , o ! i , r η h id , o ! i fst , id ˆ s ss ‹ “ ρ D fst r η h id , o ! i , r η h id , o ! i fst , id ˆ s ss ‹ “ ρ r η, r η fst , η fst ss ‹ . By combining it with a symmetric argument, we obtain that ρ r η, r η fst , ι p id ˆ s qss ‹ “ ρ r η, r η fst , η fst ss ‹ “ ρ r η, r ι p id ˆ s q , η fst ss ‹ .Now, given a morphism f : DX Ñ A that equalizes ρ r η, r η fst , ι p id ˆ s qss ‹ and ρ r η, r ι p id ˆ s q , η fst ss ‹ , we obtain that f ι ‹ “ f r η, r η fst , ι p id ˆ s qss ‹ D inr inr “ f r η, r ι p id ˆ s q , η fst ss ‹ D inr inr “ f D fst , by assumption, there is a unique factorizationof f through ρ . (cid:74) A.18 Proof of Theorem 35
We show the following implications: ñ ñ ñ and ñ ñ . Goncharov 31 ñ Using the assumption, we define α X : D ~ DX Ñ ~ DX by the universal property: DD p X ˆ N q DDX D ~ DXDX ~ DX DD fst Dι ‹ Dρ X µ X α X ρ X where we call on the calculation: ρ µ Dι ‹ “ ρ µ Dµ DDι “ ρ µ µ DDι “ ρ µ Dι µ “ ρ ι ‹ µ “ ρ D fst µ “ ρ µ DD fst . By definition, p ~ DX, α X q is a D -algebra and ρ X is a D -algebra morphism. Let us show that p ~ DX, α X q is a search-algebra, i.e. that α X now “ id and α X . “ α X . For the first equation,note that α X now ρ “ α X Dρ now “ ρ µ now “ ρ , which entails α X now “ id using thefact that ρ is an epi. Analogously, α X . Dρ “ α X Dρ . “ ρ µ . “ ρ . µ “ ρ µ “ α X Dρ using Lemmas 39 and 33, and again, we are done by discarding Dρ , which is epic byassumption. ñ Let p ~ DX, α X : D ~ DX Ñ ~ DX q be a search-algebra structure, which exists byassumption. To show that ~ DX is an Elgot algebra, by Proposition 31, it suffices to showthat it is a D -algebra, i.e. α X now “ id , which is by assumption, and α X µ “ α X Dα X ,which we can prove, using the assumption that ρ is a D -algebra morphism and assuming forthe time being that DDρ is epic, as follows: α X µ DDρ “ α X Dρ µ “ ρ µ µ “ ρ µ Dµ “ α X Dρ Dµ “ α X Dα X DDρ . The proof that
DDρ is epic is entailed by the followingcommutative diagram: DX ˆ D ¯ N ~ DX ˆ D ¯ N D p DX ˆ ¯ N q D p ~ DX ˆ ¯ N q DD p DX ˆ q DD p ~ DX ˆ q ρ ˆ id τ τD p ρ ˆ id q Dτ DτDD p ρ ˆ id q where, up to the obvious isomorphisms, our morphism of interest is the horizontal bottomone. To show that it is epic, it suffices to show that any path from the left top corner to theright bottom corner is epic, specifically, we consider the composition Dτ τ p ρ ˆ id q . This isepic, because ρ ˆ id is a coequalizer and the involved τ are retractions by Lemma 48.To prove that ρ “ pp ρ now ` id q out q , note that, by definition, pp ρ now ` id q out q “ α X coit pp ρ now ` id q out q . It is easy to see by the universal property of coit that coit pp ρ now ` id q out q “ D p ρ now q . Hence pp ρ now ` id q out q “ α X D p ρ now q , which isequal to ρ µ p D now q “ ρ , since, by assumption, ρ is a D -algebra morphism.Finally, let us show freeness. Given an Elgot algebra A and f : X ˆ Y Ñ A , we provide aunique right iteration preserving f : X ˆ ~ DY Ñ A such that f “ f p id ˆ ρ now q . UsingProposition 31, again, we assume a search-algebra p A, a q such that a : DA Ñ A is a D -algebra.We define f by a universal property from the diagram: X ˆ D p Y ˆ N q X ˆ DY X ˆ ~ DYDA A id ˆ D fstid ˆ ι ‹ id ˆ ρ Y p Df q τ f a which is justified by the following calculation: a p Df q τ p id ˆ ι ‹ q “ a ι ‹ D p f ˆ id q D assoc - τ “ a D fst D p f ˆ id q D assoc - τ // Lemma 32 “ a Df D fst D assoc - τ “ a Df D p id ˆ fst q τ “ a p Df q D p id ˆ fst q τ “ a p Df q τ p id ˆ D fst q We then immediately have f p id ˆ ρ now q “ a p Df q τ p id ˆ now q“ a p Df q now “ a now f “ f. Let us show that f is right iteration preserving, i.e. given g : Z Ñ ~ DY ` Z , f p id ˆ α Y p coit g qq “ a coit pp f ` id q dstr p id ˆ g qq . First, we show that f p id ˆ α Y q “ a p Df q τ. To that end we compose both sides with id ˆ Dρ , and make use the fact that it is an epi. f p id ˆ α Y q p id ˆ Dρ q “ f p id ˆ ρ µ q“ a p Df q τ p id ˆ µ q“ a p Df q µ p Dτ q τ “ a µ p DDf q p Dτ q τ “ a p Da q p DDf q p Dτ q τ “ a p Df q D p id ˆ ρ q τ “ a p Df q τ p id ˆ Dρ q . This reduces the goal to p Df q τ p id ˆ coit g q “ coit pp f ` id q dstr p id ˆ g qq , and the latter follows from the fact that the left hand side satisfies the characteristic equationfor the right hand side: out p Df q τ p id ˆ coit g q“ p f ` Df q out τ p id ˆ coit g q“ p f ` Df q p id ` τ q dstr p id ˆ out q p id ˆ coit g q“ p f ` Df q p id ` τ q dstr p id ˆ p id ` coit g q g q“ p f ` Df q p id ` τ p id ˆ coit g qq dstr p id ˆ g q“ p id ` p Df q τ p id ˆ coit g qq p f ` id q dstr p id ˆ g q . . Goncharov 33 Finally, let g : X ˆ ~ DY Ñ A be right iteration preserving, such that f “ g p id ˆ ρ now q andshow that g “ f . By definition of f , we need to show that g p id ˆ ρ q “ a p Df q τ . Usingthe equation ρ “ pp ρ now ` id q out q , we proved above, we derive the goal as follows: g p id ˆ ρ q “ g p id ˆ pp ρ now ` id q out q q“ pp g ` id q dstr p id ˆ p ρ now ` id q out qq “ pp g p id ˆ ρ now q ` id q dstr p id ˆ out qq “ pp f ` id q dstr p id ˆ out qq “ a coit pp f ` id q dstr p id ˆ out qq“ a p Df q coit p dstr p id ˆ out qq“ a p Df q τ. ñ Let p ~ DX, α X : D ~ DX Ñ ~ DX q be the relevant Elgot algebra structure, which existsby definition. Let w : DX ˆ ¯ N Ñ DX ` DX ˆ ¯ N be as follows: w p p, now ‹q “ inl p w p p, . n q “ inr p / p, n q . Analogously, let u : D p X ˆ N q ˆ ¯ N Ñ D p X ˆ N q ` D p X ˆ N q ˆ ¯ N be as follows: u p p, now ‹q “ inl p, u p . p, . n q “ inr p p, n q ,u p now p x, o q , . n q “ inr p now p x, o q , n q , u p now p x, s p k qq , . n q “ inr p now p x, k q , n q . We thus obtain two morphisms: coit w : DX ˆ ¯ N Ñ DDX and coit u : D p X ˆ N q ˆ ¯ N Ñ DD p X ˆ N q . To build intuition, let us replace X with 1. Then coit w : ¯ N ˆ ¯ N Ñ D ¯ N essentiallycomputes truncated difference: it subtracts a possibly infinite second number m from apossibly infinite first number n and produces a process D ¯ N , which runs m time units, and incase of termination returns the truncated difference n . ´ m . Since subtraction is inverse tosummation, this explains why coit w is a section, whose retraction is h µ, D ! i : D ¯ N Ñ ¯ N ˆ ¯ N ,which remains true for arbitrary X . The morphism coit u : D N ˆ ¯ N Ñ DD N refines coit w inthe following sense. The first argument can be regarded as a sum of a possibly infinite n witha finite k (so that n ` k “ n if n is infinite) and then coit u again computes the truncateddifference n ` k . ´ m in the form of a formal sum p n . ´ m q ` k if n is greater than m and p n ` k q . ´ m otherwise.Now, consider the following diagram, which summarizes the argument. DDX D ~ DXD p X ˆ N q ˆ ¯ N DX ˆ ¯ N ~ DX ˆ ¯ N DD p X ˆ N q DDX D ~ DX Y Dρ X h µ,D ! i h α, D ! i coit u D fst ˆ id ι ‹ ˆ id ρ X ˆ idcoit w p D fst q τ cDD fst Dι ‹ Dρ X a b We would like to show that Dρ is a coequalizer of the bottom parallel pair of morphisms. Tothat end, we fix a : D ~ DX Ñ Y , such that a ι ‹ “ a p D fst q and construct such b : D ~ DX Ñ Y that a “ b p Dρ q . Assuming, for the moment, that all rectangular cells (with coherentlychosen edges of the corresponding parallel pairs) commute, we obtain that a p coit w q co-equalizes ι ‹ , D fst , which produces a suitable c , by a coequalizer property. Let b “ c h α, D ! i and using the fact that the two vertical morphisms from DDX to DDX and from D ~ DX to D ~ DX are identities, obtain the desired equation b Dρ “ a . The fact that the verticalmorphism from D ~ DX to D ~ DX is the identity is by Lemma 48. The fact that the verticalmorphism from DDX to DDX is the identity, we show directly. We will show that out p coit w q h µ, D ! i “ p id ` p coit w q h µ, D ! i q out This identifies p coit w q h µ, D ! i as a unique final coalgebra morphism, which thus must beequal to id . Since out p coit w q h µ, D ! i “ p id ` coit w q w h µ, D ! i , we reduce the previous equation to w h µ, D ! i “ p id ` h µ, D ! i q out By composing both sides with now and . correspondingly, we reduce to w h id , now ! i “ inl , w h µ ., p D ! q . i “ inr h µ, D ! i . The first equation directly follows by definition of w . For the second equation, w h µ ., p D ! q . i “ w h . µ, . p D ! q i “ inr h µ, D ! i , using Lemma 39 (1).We proceed to show non-trivial commutativity conditions for the square cells of ourdiagram. These are the following: p coit w q p ι ‹ ˆ id q “ Dι ‹ p coit u q (12) p coit w q p D fst ˆ id q “ p DD fst q p coit u q (13) p Dρ q p coit w q “ p D fst q τ p ρ ˆ id q (14)To obtain (12), we show that both sides are equal to coit pp ι ‹ ` id q u q , which in turn amountsto proving that the left and the right hand are both universal coalgebra maps, i.e. out p Dι ‹ q p coit u q “ p id ` p Dι ‹ q coit u q p ι ‹ ` id q u out p coit w q p ι ‹ ˆ id q “ p id ` p coit w q p ι ‹ ˆ id qq p ι ‹ ` id q u The first one is obvious, and we proceed with the second one. Since out p coit w q p ι ‹ ˆ id q “ p id ` coit w q w p ι ‹ ˆ id q , we are left to show that p ι ‹ ` ι ‹ ˆ id q u “ w p ι ‹ ˆ id q . By case distinction: p ι ‹ ` ι ‹ ˆ id q p u p p, now ‹qq “ p ι ‹ ` ι ‹ ˆ id q p inl p q“ inl p ι ‹ p p qq“ w p ι ‹ p p q , now ‹q , p ι ‹ ` ι ‹ ˆ id q p u p . p, . n qq “ p ι ‹ ` ι ‹ ˆ id q p inr p p, n qq“ inr p ι ‹ p p q , n q“ inr p / p ι ‹ p . p qq , n q . Goncharov 35 “ w p ι ‹ p . p q , . n q , p ι ‹ ` ι ‹ ˆ id q p u p now p x, o q , . n qq “ p ι ‹ ` ι ‹ ˆ id q p inr p now p x, o q , n qq“ inr p ι ‹ p now p x, o qq , n q“ inr p ι p x, o q , n q“ inr p now x, n q“ inr p / p now x q , n q“ inr p / p ι ‹ p now p x, o qqq , n q“ w p ι ‹ p now p x, o qq , . n q , p ι ‹ ` ι ‹ ˆ id q p u p now p x, s p k qq , . n qq “ p ι ‹ ` ι ‹ ˆ id q p inr p now p x, k q , n qq“ inr p ι ‹ p now p x, k qq , n q“ inr p ι p x, k q , n q“ inr p / p ι p x, s p k qqq , n q“ inr p / p ι ‹ p now p x, s p k qqqq , n q“ w p ι ‹ p now p x, s p k qqq , . n q . The proof of (13) runs analogously. To obtain (14), again, we show that both sides are equalto coit pp ρ ` id q w q , by establishing equations out p Dρ q p coit w q “ p id ` p Dρ q coit w q p ρ ` id q w, out p D fst q τ p ρ ˆ id q “ p id ` p D fst q τ p ρ ˆ id qq p ρ ` id q w. The first equation is again easy to see. Since out p D fst q τ p ρ ˆ id q “ p fst `p D fst q τ q dstr p ρ ˆ out q “ p ρ fst `p D fst q τ p ρ ˆ id qq dstr p id ˆ out q , we reduce to p fst ` ρ ˆ id q dstr p id ˆ out q “ p id ` ρ ˆ id q w. This is however easy to see by definition of w .Finally, we have to show that b is the unique morphism for which a “ b p Dρ q . We obtainthis by proving that Dρ is an epi. To this end, consider the following diagram DX ˆ ¯ N ~ DX ˆ ¯ N D p DX ˆ q D p ~ DX ˆ q Y ρ ˆ id τ τD p ρ ˆ id q fg where we assume that f D p ρ ˆ id q “ g D p ρ ˆ id q . Then, also f τ p ρ ˆ id q “ g τ p ρ ˆ id q .Since ρ ˆ id is an epi, and τ is a retraction by Lemma 48, their composition is epic, hence f “ g . We have thus shown that D p ρ ˆ id q is epic, and since DY ˆ – DY , so is Dρ . ñ The proof that ~ D extends to a monad is analogous to that of Lemma 16. Strengthis defined and characterized in the same way as in Proposition 19. We are left to showthat ρ is a strong monad morphism. By definition, ρ respects monad unit. Let us showthat it respects multiplication, i.e. ρ µ “ µ ρ Dρ . By assumption, every ρ X is a D -algebramorphism, i.e. ρ X µ X “ out Dρ X (using the definition of the D -algebra structure for~ DX from Proposition 31). Thus, we are left to show that µ ρ “ out . By assumption, ρ “ pp ρ now ` id q out q , and µ : ~ D ~ DX Ñ ~ DX is iteration preserving, hence µ ρ “ µ pp ρ now ` id q out q “ pp µ ρ now ` id q out q “ out . Finally, let us show that ρ preserves strength, i.e. ρ τ “ τ p id ˆ ρ q . Using assumption ρ “ pp ρ now ` id q out q , we have τ p id ˆ ρ q “ τ p id ˆ pp ρ now ` id q out q q“ pp τ ` id q dstr p id ˆ p ρ now ` id q out qq “ pp τ p id ˆ ρ now q ` id q dstr p id ˆ out qq “ pp ρ now ` id q dstr p id ˆ out qq “ pp ρ now ` id q out q τ “ ρ τ. where the second to last step is the characterization of τ from Proposition 1 and Uniformity . ñ Suppose that ~ D extends to a strong monad ~ D and ρ to a strong monad morphism.Let us define the search-algebra structure on ~ DX as α X “ µ X ρ ~ DX : D ~ DX Ñ ~ DX . Theaxioms of search-algebras follow by definition and by Lemma 33. By assumption, ρ is amonad morphism, in particular, ρ µ “ µ ρ Dρ , hence ρ X µ X “ µ X ρ DX Dρ X “ α X Dρ X ,i.e. ρ X is a D -algebra morphism. (cid:74) A.19 Proof of Theorem 37
The difficult clause is In order to show it, some preparatory work is needed. (cid:73)
Lemma 49.
Suppose that the equivalent conditions of Theorem 35 hold. Then Σ “ ~ D isan internal distributive lattice with K : 1 Ñ ~ D as the bottom, J “ η : 1 Ñ ~ D as the top and ^ “ ~ D ! ˆ τ ‹ τ : ~ D ˆ ~ D Ñ ~ D . Proof. T T with a point K : 1 Ñ T ∅ , which is easy to check. We proceed to define binary joins _ : Σ ˆ Σ Ñ Σ intwo steps. First, we define an auxiliary map j : ¯ N ˆ Σ Ñ ¯ N as a universal arrow from thediagram: ¯ N ˆ D N ¯ N ˆ ¯ N ¯ N ˆ Σ D N ¯ N Σ id ˆ D ! id ˆ ˆ ι ‹ D r o ! ,t s ζ , N id ˆ ρD ! ζ , jD !ˆ ι ‹ ρ where ζ X,Y : DX ˆ DY Ñ D p X ˆ DY ` DX ˆ Y q runs the arguments in parallel until oneof the computations terminates and t : ¯ N ˆ N Ñ N returns the minimum of the first and thesecond arguments, concretely, by primitive recursion: t p p, o q “ o , t p p, s p n qq “ case p out p q of inl ‹ ÞÑ o ; inr q ÞÑ s p t p q, n qq . Then we define _ from the diagram D N ˆ ¯ N ¯ N ˆ ¯ N Σ ˆ ¯ N D N ˆ Σ ¯ N ˆ Σ Σ ˆ ΣΣ D ! ˆ id ˆ ι ‹ ˆ idid ˆ ρ ρ ˆ idid ˆ ρ id ˆ ρD ! ˆ id ˆ ι ‹ ˆ id ρ ˆ id j _ . Goncharov 37 where the fact that j equalizes D ! ˆ id and ˆ ι ‹ ˆ id follows from the next calculation and thefact that ρ ˆ id is epic: j p D ! ˆ id q p id ˆ ρ q “ j p id ˆ ρ q p D ! ˆ id q“ j ρ p D ! q ζ , p D ! ˆ id q“ j ρ p D ! q ζ , swap p D ! ˆ id q“ j ρ p D ! q ζ , p id ˆ D ! q swap “ j ρ p D ! q ζ , p id ˆ ˆ ι ‹ q swap “ j ρ p D ! q ζ , swap p ˆ ι ‹ ˆ id q“ j ρ p D ! q ζ , p ˆ ι ‹ ˆ id q“ j p id ˆ ρ q p ˆ ι ‹ ˆ id q“ j p ˆ ι ‹ ˆ id q p id ˆ ρ q where we used the obvious fact that ζ is commutative. By definition, _ p ρ ˆ ρ q “ ρ p D ! q ζ , which immediately entails that _ is commutative using the fact that ρ ˆ ρ is epic. In asimilar way, we can transfer the distributivity law a ^ p b _ c q “ p a ^ b q _ p a ^ c q . To thatend, we use the following analogue of that law for D :¯ N ˆ p ¯ N ˆ ¯ N q p ¯ N ˆ ¯ N q ˆ p ¯ N ˆ ¯ N q ¯ N ˆ ¯ N ¯ N ˆ ¯ N ¯ N id ˆp D ! q ζ , h id ˆ fst , id ˆ snd i pp D ! q ˆ τ ‹ τ qˆpp D ! q ˆ τ ‹ τ qp D ! q ζ , p D ! q ˆ τ ‹ τ This law essentially states that the operation of minimum on ¯ N distributes over the operationof summation. By postcomposing this law with ρ and using the property that ρ ˆ p ρ ˆ ρ q is epi again, we obtain the desired distributivity law for Σ. In a similar way we obtain theabsorption law a _ p a ^ b q “ a .The laws that we obtained are sufficient to show that _ is a join. On the one hand, bythe absorbtion law a ^ p a _ b q “ p a ^ a q _ p a ^ b q “ a _ p a ^ b q “ a , which is equivalent to a ď a _ b , and analogously, b ď a _ b . On the other hand, if a ď c and b ď c , then a ^ c “ a , b ^ c “ b and hence p a _ b q ^ c “ p a ^ b q _ p a ^ c q “ a _ b , i.e. a _ b ď c . (cid:74)(cid:73) Lemma 50.
Suppose that the equivalent conditions of Theorem 35 hold, and additionallythe coequalizer (2) with X “ is preserved by p -- q N . Then Σ is an internal ω -frame, i.e. thereis an ω -join Ž : Σ N Ñ Σ , which satisfying the frame distributive law a ^ Ž i b i “ Ž i p a ^ b i q . Proof.
The approach is similar to that of Lemma 49: we construct Ž : Σ N Ñ Σ by thefollowing universal property p D N q N ¯ N N Σ N ¯ N Σ p D ! q N p ˆ ι ‹ q N ρ N Ž ρ where the morphism ¯ N N Ñ ¯ N converts a countable collections of infinite streams into a singlestream, which is possible using the standard diagonalization argument. (cid:74) Recall the bounded iteration operator p -- q h from Definition 26. For a monad T with aconstant K : 1 Ñ T X , we can instantiate this definition in the Kleisli category C T of T ,which yields p -- q h : : C p X, T p Y ` X qq Ñ C p X ˆ N , T Y q for any Y (because every Y has apoint K : 1 Ñ T Y in C T ). (cid:73) Lemma 51.
Let T be an equational lifting monad, and suppose that it is equipped with anoperator p -- q : : C p X, T p Y ` X qq Ñ C p X, T Y q that satisfies Fixpoint , Naturality , Uniformity and
Strength . This induces a divergence constant
K “ p η inr q : : 1 Ñ T X .Given f : X Ñ T p Y ` X q , and g : X Ñ T Y , (i) f h : v f : fst , and (ii) f h : v g fst implies f : v g . Proof.
The clauses (i) and (ii) are analogous to those of Theorem 27. The first clause isshown in exactly the same way. For the second clause, analogously, we define h : X ˆ N Ñ T p N ` X ˆ N q with the property that f : “ p f h : q ‹ τ h id , h : h id , o ! ii (15)which will entail (ii) using the same argument as in Theorem 27, using Naturality and
Strength . Here, we take h “ T p snd ` id q p T dstl q ˆ τ p f ˆ s q This function runs just like f , but produces the number of computation steps as a final result.For the sake of brevity, let us denote h : h id , o ! i : X Ñ T N by c . First of all, we show thefollowing auxiliary property: dom f : “ dom c. (16)It easily follows by Naturality and
Uniformity that p T ! q h : “ p T p ! ` id q f q : fst . Then dom p h : h id , o ! i q “ dom pp T ! q h : h id , o ! i q “ dom pp T p ! ` id q f q : fst h id , o ! i q “ dom f : .The main step of the proof is showing commutativity of the following diagram: X T p Y ` X q X ˆ T N T p Y ` X ˆ T N q f ‹ p dom f : q τ h id ,c i T p id ` τ h id ,c i q T p fst ` η q p T dstl q ˆ τ ‹ p τ p f ˆ d qq ‹ where d : N Ñ T N is as follows: d p o q “ K , d p s n q “ η p n q . By Uniformity , this entails the equation p f ‹ p dom f : qq : “ p T p fst ` η q p T dstl q ˆ τ ‹ p τ p f ˆ d qq ‹ q : τ h id , c i (17)Roughly, this says that iterating f is equivalent to iterating f and additionally checking thatthe counter that is initialized by c and decreased at each iteration remains non-zero. Theterm dom f : is needed to balance the effect of recalculating c at each iteration out. We have T p fst ` η q p T dstl q ˆ τ ‹ p τ p f ˆ d qq ‹ τ h id , c i “ T p fst ` η q p T dstl q ˆ τ ‹ τ p f ˆ d ‹ q h id , c i “ T p fst ` η q p T dstl q ˆ τ ‹ τ h f, d ‹ c i . Goncharov 39 “ T p fst ` η q p T dstl q ˆ τ ‹ τ h f, d ‹ r η, h : s ‹ h h id , o ! ii “ T p fst ` η q p T dstl q ˆ τ ‹ τ h f, d ‹ r η s o ! , h : h id , s o ! i s ‹ f i “ T p fst ` η q p T dstl q ˆ τ ‹ τ h f, r η o ! , c s ‹ f i “ T p fst ` η q p T dstl q ˆ τ ‹ τ p id ˆ r η o ! , c s ‹ q h f, f i “ T p fst ` η q p T dstl q τ ‹ ˆ τ p id ˆ r η o ! , c s ‹ q h f, f i “ T p fst ` η q p T dstl q τ ‹ T p id ˆ r η o ! , c s ‹ q ˆ τ h f, f i “ T p fst ` η q p T dstl q τ ‹ T p id ˆ r η o ! , c s ‹ q T h id , η i f “ T p fst ` η q p T dstl q τ ‹ T h id , r η o ! , c s i f “ T p fst ` η q rp T inl q τ h id , η o ! i , p T inr q τ h id , c i s ‹ f “ r η inl , p T inr q p T η q τ h id , c i s ‹ f “ r η inl , p T inr q T p τ h id , c i q dom c s ‹ f “ T p id ` τ h id , c i q r η inl , p T inr q dom c s ‹ f “ T p id ` τ h id , c i q r η inl , p T inr q dom f : s ‹ f “ T p id ` τ h id , c i q p dom r η, f : sq ‹ f “ T p id ` τ h id , c i q f ‹ dom pr η, f : s ‹ f q“ T p id ` τ h id , c i q f ‹ p dom f : q . The proof of (15) now runs as follows: f : “ p f : q ‹ p dom f : q // RST “ p f : dom f : q ‹ p dom f : q // Lemma 44 “ p f : dom f : q ‹ p dom c q // (16) “ pp T p fst ` η q p T dstl q ˆ τ ‹ p τ p f ˆ d qq ‹ q : τ h id , c i q ‹ p dom c q // (17) “ pp T p fst ` η q p T dstl q ˆ τ ‹ p τ p f ˆ d qq ‹ q : q ‹ T p τ h id , c i q dom p τ h id , c i q“ pp T p fst ` η q p T dstl q ˆ τ ‹ p τ p f ˆ d qq ‹ q : q ‹ p T η q τ h id , c i // Lemma 42 “ pp T p fst ` η q p T dstl q ˆ τ ‹ p τ p f ˆ d qq ‹ q : η q ‹ τ h id , c i “ pp T p fst ` id q p T dstl q ˆ τ ‹ τ p f ˆ d qq : q ‹ τ h id , c i // Uniformity “ p f h : q ‹ τ h id , c i . Here, the last step requires checking that f h : “ p T p fst ` id q p T dstl q ˆ τ ‹ τ p f ˆ d qq : , which iseasy, since f h : is defined by primitive recursion. (cid:74) Let us call a pair p M P | C | , M v Ď M ˆ M q a (internal) regular poset if M v is a regular monic,i.e. an equalizer of some pair l, r : M ˆ M Ñ E and the relation v on Hom p X, M q , definedby putting f v g iff l h f, g i “ r h f, g i , is a partial order for every X . By definition, f v g iff h f, g i factors through M v Ď M ˆ M . Because of the equalizer property, this factorization isunique. Our notion of a regular poset is thus an instance of Barr’s notion of an (internal)poset [8] to which we added the regularity requirement. We will follow Barr’s work furtheron in internalizing further relevant notions of order theory. First, observe the following. (cid:73) Lemma 52.
For every X P | C | , the equalizer of the pair fst , p snd ‹ q ˆ τ : T X ˆ T X Ñ T X defines a regular poset.
Proof.
Obvious by definition of the enrichment of C T . (cid:74) Given a regular poset p M P | C | , M v Ď M ˆ M q , we define the object of monotone se-quences M ω from the pullback: M ω M N p M v q N p M ˆ M q N M N ˆ M N (cid:65) h id ,M s i – Now, a regular poset p M P | C | , M v Ď M ˆ M q is an internal ω -cpo if it is equipped with anoperation Ů : M ω Ñ M , such that for every f : X Ñ M ω , Ů f : X Ñ M is the least upperbound for ˆ f “ curry - p X f ÝÑ M ω , Ñ M N q in C p X, M q , meaning that (i) ˆ f v p Ů f q fst and(ii) ˆ f v g fst implies Ů f v g for any g : X Ñ M . (cid:73) Proposition 53.
An equational lifting monad T is a strong Elgot monad if T N is aninternal ω -cpo. Proof.
First, given f : X Ñ T p N ` X q , we define f : : X Ñ T N as the least fixpoint of themap r η, -- s ‹ f : C p X, T N q Ñ C p X, T N q . Then we extend p -- q : to all f : X Ñ T p Y ` X q usingthe formula (15) from Lemma 51. Fixpoint , Naturality , Uniformity and
Strength follow fromthis definition, which enables the characterization of Lemma 51, and then
Compositionality follows analogously to an existing argument [21, Theorem 5.8]. (cid:74)
Finally, we proceed with the proof of Theorem 37. In extensive categories coequalizers are preserved by p -- ` q , hence, by assumption, (2)is preserved by p -- ` q N . Recall that DX is a retract of p X ` q N naturally in X . It is easyto verify that coequalizers are preserved by retractions, hence (2) is preserved by D . The claim follows from Proposition 53 and Lemma 51. We only need to extend ~ D N toan ω -cpo. The effectiveness assumption implies that ~ D N is isomorphic to Σ ω . By Lemma 50,we have internal joins on Σ, which extend to Σ ω pointwise.pointwise.