Abstract 1 Introduction 2 Motivating Example: the Fibonacci sequence 3 Preliminaries and notation 4 Coinduction up-to 5 Induction up-to 6 Strong Induction is an up-to technique 7 From Lattice to Categories 8 Conclusions and future work References Appendix A Appendix to Section 5 Appendix B Details on Section 7.4

Strong Induction Is an Up-To Technique

Filippo Bonchi ORCID Universitá di Pisa, Italy Elena Di Lavore ORCID Universitá di Pisa, Italy Anna Ricci Universitá di Pisa, Italy
Abstract

Up-to techniques are enhancements of the coinduction proof principle which, in lattice theoretic terms, is the dual of induction. What is the dual of coinduction up-to? By means of duality, we illustrate a theory of induction up-to and we observe that an elementary proof technique, commonly known as strong induction, is an instance of induction up-to. We also show that, when generalising our theory from lattices to categories, one obtains an enhancement of the induction definition principle known in the literature as comonadic recursion.

Keywords and phrases:
Induction, Coinduction, Up-to Techniques, Induction up-to, Lattices, Algebras
Funding:
Filippo Bonchi: Supported by the Ministero dell’Università e della Ricerca of Italy grant PRIN 2022 PNRR No. P2022HXNSC - RAP (Resource Awareness in Programming).
Copyright and License:
[Uncaptioned image] © Filippo Bonchi, Elena Di Lavore, and Anna Ricci; licensed under Creative Commons License CC-BY 4.0
2012 ACM Subject Classification:
Theory of computation Proof theory
; Theory of computation Logic and verification
Acknowledgements:
The authors would like to thank Jurriaan Rot for the inspiring discussions.
Funding:
This study was carried out within the National Centre on HPC, Big Data and Quantum Computing - SPOKE 10 (Quantum Computing) and received funding from the European Union Next-GenerationEU - National Recovery and Resilience Plan (NRRP) – MISSION 4 COMPONENT 2, INVESTMENT N. 1.4 – CUP N. I53C22000690001. This research was partly funded by the Advanced Research + Invention Agency (ARIA) Safeguarded AI Programme.
Editors:
Jörg Endrullis and Sylvain Schmitz

1 Introduction

Induction is a fundamental tool frequently used by mathematicians, logicians, and computer scientists without much thought. It includes both definition and proof principles. The definition principle allows for the specification of data types, such as natural numbers, lists, or trees, and to define functions from them; the proof principle enables proving properties on such inductively defined structures.

The coinduction proof principle, which is formally the dual of induction, is less familiar. It first emerged in the 1970s [33] in three independent fields: set theory [14], modal logic [40], and concurrency theory [27]. Since then, it has been recognized as a fundamental principle in computer science and has been applied in various contexts [24, 1, 11, 16, 12, 31, 25, 17, 22].

Up-to techniques are enhancements of the coinduction proof principle, originally introduced by Milner in [23] to simplify coinductive arguments. Coinduction up-to has proven useful, if not essential, in numerous proofs about concurrent systems (see [30] for references). It has been used to establish decidability results [9], improve standard automata algorithms [6], and prove the completeness of domains in abstract interpretation [3].

The theory of up-to techniques was initially developed by Sangiorgi [32] and later generalized to the abstract setting of complete lattices by Pous [28, 29]. In particular, Pous introduced the notion of f-compatible techniques for some monotone map f. Intuitively, these are are sound up-to techniques with advantageous composition properties.

A curiosity that may have occurred to many is the following:

Since coinduction is the dual of induction, what is the dual of coinduction up-to?

In this paper, we introduce a theory of induction up-to by simply dualizing the work of Pous [28]. Our main finding is that the well-known principle of strong induction over the set natural numbers , a principle familiar even to undergraduate students, is an example of an inductive up-to technique.

More precisely, we dualize the notion of f-compatible techniques from [28] to that of f-cocompatible (Definition 5) up-to techniques, which, as expected, are sound (Theorem 7) and enjoy good composition properties (Proposition 8). We show that, under mild conditions, any proof by coinduction up-to can equivalently be carried out by means of induction up-to, and vice versa (Proposition 11).

For any monotone map f, its down-closure, denoted by f, is always f-cocompatible (Corollary 9). We name induction up-to f strong induction since, when f is the monotone map with the least fixed point , induction up-to f coincides with the usual strong induction over (Section 6.1). Unsurprisingly, the same approach can be applied to obtain strong induction on words (Section 6.2) and other inductive data types.

Overall, this shows that induction up-to, and in particular strong induction, provide enhancements for the induction proof principle. At this point, another curiosity arises:

What are enhancements of the induction definition principle?

Intuitively, one can think of recursion schemes as enhancements of the induction definition principle: they ensure that the specification of a recursive function is well-defined.

To formalize this intuition, we exploit the fact that Pous’ theory [28] has a beautiful categorical meaning [5]: when generalizing this theory from lattices to categories, one obtains Bartel’s λ-coinduction [2], an enhancement of the coinduction definition principle that generalizes several specification techniques common in computer science [36, 20], notably the abstract GSOS by Turi and Plotkin [37, 21].

We illustrate that, following the same pattern, the theory of induction up-to generalize to a certain recursion scheme known as comonadic recursion by Capretta, Uustalu, Vene and Pardo [39, 8] (Proposition 18). In particular, strong induction generalises to a scheme known as course-of-value iteration [38, 7] (Proposition 20). These correspondences are summarised in Table 1.

Table 1: The lattices-to-categories correspondence. On the left, the proof and definition principles with their enhacement; On the right, the corresponding inductive invariants and algebras.
induction proof principle induction definition principle
induction up-to comonadic recursion
strong induction course-of-value iteration
f(x)x a:FXX
fd(x)x a:FDXX
ff(x)x a:FFXX

Related Work

An elegant theory of inductive enhancements has been recently introduced by Sangiorgi in [35]. This theory substantially differs from ours in its goals: Sangiorgi aims to enhance the proof methods for those behavioural equivalences and preorders [41, 42], such as trace, failure, and ready, that are defined inductively. These relations can usually be stratified, and the proposed inductive enhancements are functions on relations preserving such stratification. Like in the theory of coinductive enhancements [32, 28], the starting notion is the one of (semi-)progression and enhancements are up-closures, which is a crucial difference from our inductive invariants.

Another approach, similar in spirit to [35], is based on the techniques of unique solutions of equations [13, 34]. However, to the best of our understanding, its applicability seems to be strongly tailored to equivalence relations.

Synopsis

We begin our exposition in Section 2 with a simple example of proof by strong induction for the Fibonacci sequence. We recall the lattice-theoretic understanding of induction and coinduction in Section 3 and the theory of coinductive up-to techniques in Section 4; its dual, the theory of inductive up-to techniques, is illustrated in Section 5. In particular, Section 5.1 links coinduction up-to and induction up-to by means of an involution operator; Example 12 illustrates how, following this link, the coinductive technique of up-to equivalence becomes up-to apartness. Section 6.2 introduces strong induction as a certain up-to technique. The fact that this generalises strong induction on is not obvious and its proof is detailed in Section 6.1. Strong induction on words is discussed in Section 6.2. In Section 7, we turn from the proof principle to the definition principle: Section 7.1 quickly recalls the induction definition principle by means of initial algebras; Section 7.2 recalls comonadic corecursion and Section 7.3 course-of-value iteration, a special case of comonadic corecursion. Finally, Section 7.4, revisits the Fibonacci, by recalling that its definition is by means of course of value iteration. The appendix contains the missing proofs and some additional material.

Until Section 7, the reader only requires some familiarity with lattice theory. Then, we expect the reader to be familiar with category theory.

2 Motivating Example: the Fibonacci sequence

Induction is a proof principle that applies to inductively defined structures. For instance, for proving that a predicate P(n) hold for all natural numbers n, one has to find a predicate Q(n) that implies P(n), that is true for 0 and that, when true for n, then it is true for n+1.

Q(0)n.Q(n)Q(n+1)QPn.P(n) (1)

Sometimes, induction might be too weak to prove certain properties. As an example, consider the Fibonacci sequence defined as

𝖿𝗂𝖻(0) =def1 𝖿𝗂𝖻(1) =def1 𝖿𝗂𝖻(n+2) =def𝖿𝗂𝖻(n+1)+𝖿𝗂𝖻(n),

and suppose that one would like to prove that 𝖿𝗂𝖻(n)n for all n. One could start a proof by induction by checking the base case, 𝖿𝗂𝖻(0)=10. For the inductive case, one would need to bound 𝖿𝗂𝖻(n+1)=𝖿𝗂𝖻(n)+𝖿𝗂𝖻(n1). At this point, one would be stuck because there is no information on 𝖿𝗂𝖻(n1) from the inductive hypothesis.

Strong induction comes to our rescue by allowing a stronger inductive hypothesis. We still need to find a predicate Q(n) that implies P(n) and that holds at 0, but when showing that it is true for n+1, we may assume that it holds for all kn.

Q(0)n(n[0,n].Q(n))Q(n+1)QPn.P(n) (2)

We conclude the proof of 𝖿𝗂𝖻(n)n for all n by strong induction. For n=0, 𝖿𝗂𝖻(0)=10. For the inductive step, we assume that 𝖿𝗂𝖻(k)k for all kn+1, and we seek to bound 𝖿𝗂𝖻(n+1)=𝖿𝗂𝖻(n)+𝖿𝗂𝖻(n1). If n=1 then 𝖿𝗂𝖻(2)=𝖿𝗂𝖻(1)+𝖿𝗂𝖻(0)=1+12. Otherwise, if n>1, we use the strong inductive hypothesis:

𝖿𝗂𝖻(n+2)=𝖿𝗂𝖻(n+1)+𝖿𝗂𝖻(n)n+1+nn+2.

We want to draw the reader’s attention to the fact that, here, strong induction is necessary because 𝖿𝗂𝖻 is not–strictly speaking–inductively defined: the value of 𝖿𝗂𝖻(n+1) does not depend only on 𝖿𝗂𝖻(n). We will revisit the relationship between definitions and proofs in Section 7. Until then, we will focus only on the proof principles.

3 Preliminaries and notation

A complete lattice is a partially ordered set (L,) with joins (), meets (), a top () and a bottom () elements, least upper bounds () and greatest lower bounds (). Henceforth, we use (L,),(L1,1),(L2,2) to range over complete lattices and x,y,z to range over their elements. One lattice that we will often use is 𝒫(X), the power set of a set X, ordered by set inclusion.

Recall that a function f:L1L2 is said to be a monotone map if it preserves the order: for all x,yL1, if x1y then f(x)2f(y). The identity 𝗂𝖽L:LL and the composition fg:L1L3 of two monotone maps g:L1L2 and f:L2L3 are monotone. Therefore, if f:LL is a monotone map, then its powers fn are also monotone, where the functions fn:LL are defined inductively as

f0=def𝗂𝖽Lfn+1=defffn. (3)

We will implicitly use the fact that monotone maps form a complete lattice with their natural point-wise order: whenever f,g:L1L2 we write fg iff f(x)g(x) for all xL1.

A monotone map f:LL is an up-closure operator if xf(x) and ff(x)f(x). It is a down-closure operator if f(x)x and f(x)ff(x). Particularly relevant to our exposition are the up-closures and the down-closure generated by a (co)continuous map f:LL, namely a monotone map preserving arbitrary least upper bounds and greatest lower bounds:

f=defifif=defifi . (4)

Given a monotone map f:LL, the element xL is said to be a post-fixed point iff xf(x); a pre-fixed point iff f(x)x; a fixed point iff x=f(x). We write μf and νf for the least and greatest fixed point. For a monotone map f on a complete lattice L, the Knaster-Tarski fixed point theorem characterises μf as the least upper bound of all pre-fixed points of f and μf as the greatest lower bound of all its post-fixed points:

μf={xf(x)x}νf={xxf(x)}.

This immediately leads to the induction and coinduction proof principles, illustrated by the inference rules below, on the left and on the right, respectively [26].

f(y)yyxμfxyf(y)xyxνf (5)

The induction proof principle states that in order to prove that μfx, one should provide an inductive invariant –namely, a pre-fixed point of f– that is below x; dually, the coinduction proof principle states that in order to prove that xνf, one should provide a coinductive invariant, i.e., a post-fixed point of f, that is above x.

 Remark 1.

From this lattice theoretic perspective, it is easy to see that the coinduction proof principle is simply the dual of induction. Indeed, whenever (L,) is a lattice, then so is (L,). Similarly, if f:(L,)(L,) is monotone, then so is f:(L,)(L,), and the greatest fixed point of f over (L,) becomes the least fixed point of f over (L,).

We illustrate inductive and coinductive invariants with an example from automata theory.

Example 2 (cf. [6, Remark 2]).

We denote by A the set of words over an alphabet A; ϵ denotes the empty word and uw the word obtained by concatenating uA with wA. For a word wA, we indicate its length with |w|.

A deterministic automaton on the alphabet A is a triple (X,o,t), where X is a set of states, o:X{0,1} is the output function, determining if a state x is accepting (o(x)=1) or not (o(x)=0) and t:XXA is the transition function which returns the next state, for each letter aA. Every automaton (X,o,t) induces a function 𝗅𝖺𝗇:X{0,1}A defined inductively for all xX, aA and wA as 𝗅𝖺𝗇x(ε)=o(x) and 𝗅𝖺𝗇x(aw)=𝗅𝖺𝗇t(x)(a)(w). Two states x,yX are said to be language equivalent, in symbols xy, iff 𝗅𝖺𝗇x=𝗅𝖺𝗇y.

Alternatively, () can be defined as the greatest fixed point of some map on 𝒫(X×X), the lattice of relations over X. The functions l,q:𝒫(X×X)𝒫(X×X) are defined as

l(R)=def{(x,y)for all aA,(t(x)(a),t(y)(a))R}q(R)=def{(x,y)o(x)=o(y)} (6)

for all RX×X. One can easily check that both l and q are monotone and that ν(lq)=(). Thanks to this characterisation, one can prove that two states x,yX are language equivalent by means of the coinduction proof principle in (5): to show that {(x,y)}(), it is enough to provide a relation R that is a post-fixed point of lq and such that {(x,y)}R. Such coinductive invariants are often called bisimulations.

For an example, consider the following deterministic automaton, where final states are overlined and the transition function is represented by labelled arrows. The relation consisting of dashed and dotted lines is a bisimulation witnessing that {(x,u)}().

(7)

One can prove that {(x,y)}() by means of induction as well: for all RX×X, the functions l,p:𝒫(X×X)𝒫(X×X) are defined as follows.

l(R)=def{(t(x)(a),t(y)(a))aA,(x,y)R}p(R)=def{(x,y)} (8)

Note that p above, as well as q in (6), are constant functions: we will sometime take the freedom to identify them with the corresponding element in the lattice. Intuitively, μ(lp) represents the subset of all pairs of states that are reachable from the pair (x,y). Thus, {(x,y)}() if and only if all those pairs of states are in q, i.e., if and only if μ(lp)q. The latter can be proved by exhibiting a relation R that is a pre-fixed point of lp and such that Rq: the relation formed by the dashed and dotted lines in (7) satisfies this condition when taking (x,y) to be (x,u).

4 Coinduction up-to

Coinduction is a technique for proving xνf for some map f on a lattice (L,) by providing a coinductive invariant for f. In many situations, providing such an invariant is far too complicated. Motivated by this fact, Milner [23] introduced enhancements of the coinduction proof principle which are nowadays widely known as up-to techniques. In a nutshell, an up-to technique is an up-closure d:(L,)(L,). An f-coinductive invariant up-to d is some yL such that yfd(y), namely a post-fixed point of fd. An up-to technique d is said to be sound w.r.t. f if the following coinduction up-to principle holds.

yf(d(y))xyxνf (Coinduction Up-To)

In (5), one has to find an invariant y such that yf(y). In (Coinduction Up-To), the search of such a y is simplified since it is enough that yf(d(y)). Since d is an up-closure, f(y)f(d(y)), which simplifies the task of finding coinductive invariants.

Example 3 (Up-to equivalence).

We continue Example 2 to illustrate a coinductive invariant up-to. We instantiate (Coinduction Up-To) by taking f to be lq and d to be the function e:𝒫(X×X)𝒫(X×X) mapping any relation RX×X into its equivalence closure. One can check () by exhibiting a relation R such that Rlq(e(R)).

Consider for instance the relation S consisting of only the dashed lines in (7). Note that (y,w)e(S) but (y,w)S. It is thus easy to see that Slq(e(S)), but S is not included in lq(S). In other words, S is a coinductive invariant up-to e but not a coinductive invariant. In Example 2, to prove that xu by means of coinduction, we need to take the relation consisting of both dashed and dotted lines in (7). With coinduction up-to e, it is thus enough to take only the dashed lines.

Of course, before using an up-to technique, one should prove it to be sound. Since this might be quite challenging, several theories [32, 28, 10, 29, 4] have been introduced for simplifying this task. In this paper we will consider the theory of Pous in [28] that focuses on the notion of compatible techniques: d is f-compatible iff dffd. The key results in [28] state that compatible techniques are sound and can be nicely composed.

5 Induction up-to

Recall that for applying the induction proof principle in (5), one has to find a yL such that f(y)y. The idea of induction up-to is to simplify this task by weakening such constraint to f(d(y))y for some d:LL.

Note that if the map d is an up-closure, as it is the case of coinduction up-to, then this would only complicate our task by imposing additional constraints; indeed f(y)f(d(y)).

Example 4.

Recall from Example 2 that the relation R consisting of both dashed and dotted lines in (7) is an inductive invariant, i.e., (lp)(R)R. Note that, instead lp(e(R)) is not included into R since, e.g., (v,w) is in lp(e(R)) but not in R.

As expected, the solution consists in considering down closures. An (inductive) up-to technique is a down closure d:(L,)(L,). An f-inductive invariant up-to d is some yL such that fd(y)y, namely a pre-fixed point of fd. An up-to technique d is said to be sound w.r.t. f if the following induction up-to principle holds.

f(d(y))yyxμfx (Induction Up-To)

To prove the soundness of inductive up-to techniques, we consider the dual of the notion of compatible functions from [28].

Definition 5 (Cocompatible map).

Let f,d:(X,)(X,) be two monotone maps. We say that d is cocompatible with f, shortly f-cocompatible, if fddf.

When d is f-cocompatible, any inductive invariant up-to gives rise to an inductive invariant.

Proposition 6.

Let d be a down closure that is cocompatible with some monotone map f. If y is a pre-fixed point for fd, then d(y) is a pre-fixed point for f.

Proof.
fd(y) fdd(y) (d down closure)
dfd(y) (d is f-cocompatible)
d(y) (y is a pre-fixed point of fd)

Theorem 7.

If d is f-cocompatible, then it is sound.

Proof.

We have to prove the conclusion of (Induction Up-To) assuming its premise. By fd(y)y and Proposition 6, it holds that

fd(y)d(y).

Since d(y)y, as d is a downclosure, and yx it holds that

d(y)x.

Thus by replacing y with d(y) in (5), it holds that μfx.

It is worth mentioning that the two results above also hold by dualising the theory in [28]. We have reported their proofs since they will be relevant in Section 7. The following result also follows easily from [28]. For convenience of the reader we report its proof in Appendix A.

Proposition 8 (The algebra of cocompatible maps).

Let f,d,e:(X,)(X,) be monotone maps. Let {di}i be an -indexed family of monotone maps.

  1. 1.

    The identity 𝗂𝖽X is f-cocompatible;

  2. 2.

    f is f-cocompatible;

  3. 3.

    If d and e are f-cocompatible, then de is f-cocompatible;

  4. 4.

    If d is f-cocompatible then, for all n, dn is f-cocompatible;

  5. 5.

    If d and e are f-cocompatible, then de is f-cocompatible;

  6. 6.

    If, for all i, di is f-cocompatible, then idi is f-cocompatible;

  7. 7.

    If d is f-cocompatible, then d is f-cocompatible.

Corollary 9.

Let f:(X,)(X,) be a continuous monotone map. Then, its down-closure f is f-cocompatible.

Proof.

By point 2 and 7 in Proposition 8.

 Remark 10.

Note that we have defined up-to techniques to be down-closures, while compatible maps are defined as arbitrary monotone maps. This choice is justified by the fact that monotone maps compose nicely, while down-closures do not. This motivated Pous to introduce up-to techniques in the original theory in [28] as monotone maps rather than up-closures. Here, we preferred to stay with closures, as this simplifies the proofs of Proposition 6 and Theorem 7, which will be relevant in the categorical generalisation illustrated in Section 7.

Note also that restricting to down-closures does not limit the applicability of the theory: indeed, if d is an f-compatible monotone map, not necessarily a down-closure, then, by Proposition 8.7, d is also f-compatible. Moreover, if fd(y)x, then

fd(y)fd(y)x

since dd. In other words, any proof up-to d is also a proof up-to d.

5.1 Relating Coinduction up-to and Induction Up-to via Involution

Coinduction and induction are equivalent whenever the lattice (L,) comes with an involution operator ¬:(L,)(L,), namely a function on L such that

if xy, then ¬x¬y¬¬x=x (9)

for all x,yL. In this case, for any monotone map f on (L,), one has that f¯=def¬f¬ is a monotone map. Moreover, assuming that f preserves of ω-chains, it holds that:

xνf¬(νf)¬xμf¯¬x.

Such correspondence lifts to up-to techniques: whenever one can prove the leftmost by coinduction up-to d, for some f-compatible technique d, one can equivalently prove the rightmost by induction up-to to d¯. This is made formal by the following result.

Proposition 11.

Let f,d:(L,)(L,) be monotone maps and y be an element of L.

  1. 1.

    d is an up-closure iff d¯ is a down-closure;

  2. 2.

    d is f-compatible iff d¯ is f¯-cocompatible;

  3. 3.

    y is an f-coinductive invariant up-to d iff ¬y is an f¯-inductive invariant up-to d¯.

Example 12 (Up-to apartness).

Following the above considerations, one can transform coinduction up-to equivalence in Example 3 into induction up-to apartnesses. Apartness relations are standard in constructive reals analysis and has been first axiomatised in [19]: RX×X is a an apartness relation if it is

  • irreflexive: (x,x)R for all xX;

  • symmetric: if (x,y)R, then (y,x)R for all x,yX;

  • co-transitive: if (x,y)R, then (x,z)R or (z,y)R, for all x,y,zX.

The reader can easily check that R is an apartness relation iff ¬R is an equivalence relation, where ¬ indicates the complement of a relation. Recall from Example 3 that the up-closure e:𝒫(X×X)𝒫(X×X) mapping any relation R into its equivalence closure. By Proposition 11.1, e¯ is a down closure: it maps any R into the largest apartnesses relation contained in R. Since e is (lq)-compatible, by Proposition 11.2, e¯ is (lq¯)-cocompatible. Since 𝒫(X×X) is a boolean algebra, then lq¯=l¯q¯; it is easy to check that l¯ and q¯ map any RX×X into the following relations.

l¯(R)={(x,y)exists aA,(t(x)(a),t(y)(a))R}q¯(R)={(x,y)o(x)o(y)}.

With this characterisation, one can see that inductive invariants for l¯q¯ are exactly those introduced [15, Definition 2.2]. Our work enhances this proof method with up-to apartness.

For an example of an inductive invariant up-to apartness, consider again the relation S consisting of the dashed lines in (7). Since S is a (lq)-coinductive invariant up to e, then by Proposition 11.3, ¬S is a (l¯q¯)-inductive invariant up-to e¯.

6 Strong Induction is an up-to technique

This section studies the proof principle given by a particular f-cocompatible map: the down-closure of f. Indeed, by Corollary 9, f is f-compatible and, by Theorem 7, the following proof principle is always sound.

f(f(y))yyxμfx (Strong Induction)

We call such principle strong induction. Indeed, as we illustrate below, when instantiated to usual induction on natural numbers, the above proof principle coincides with the well-known strong induction illustrated in Section 2.

6.1 Strong Induction on natural numbers

We begin by illustrating how (5) generalises standard induction over natural numbers. Consider the lattice 𝒫() and the monotone map b:𝒫()𝒫() defined as

b(X)=def{0}{x+1xX} (10)

for all X𝒫(). The least fixed point of b is the set of natural numbers, μb=. We take the sets X and Y to be the sets of natural numbers on which P(n) and Q(n) are true, respectively.

X ={nP(n)} Y ={nQ(n)}

With these choices, set inclusion corresponds to predicate implication: YX iff QP. The least fix point of b is contained in X iff all natural numbers are contained in X, which means that P(n) holds for all n.

μbX iff X iff n.P(n)

Similarly, Y is a pre-fixed point of b iff Y contains 0 and it contains n+1 for each nY, which means that Q holds at 0 and it holds at n+1 whenever it holds at n.

b(Y)Y iff {0}{n+1nY}Y iff Q(0) and n.Q(n)Q(n+1)

These considerations show that (1) is a particular instance of (5), when we instantiate it to b:𝒫()𝒫().

b(Y)YYXμbXiffQ(0)n.Q(n)Q(n+1)QPn.P(n)

We can now illustrate our main observation: when instantiating (Strong Induction) to b one obtains exactly the strong induction on natural numbers reported in (2). We start by computing the powers bn of b.

Lemma 13.

For all n, and all X𝒫(),

bn(X)={xx<n}{x+nxX}.
Proof.

By induction. For the base case, we have the following derivation.

b0(X) =id𝒫()(X) (3 )
=X
=X
={xx<0}{x+0xX}

For the inductive case, we have the following derivation.

bn+1(X) =bbn(X) (3 )
=b({xx<n}{x+nxX}) (Ind. Hyp.)
={0}{x+1x<n}{x+n+1xX} (10)
={0}[1,n]{x+n+1xX}
={xx<n+1}{x+n+1xX}

The core of our argument relies on the following result, stating that b(X) is the largest closed interval from including 0 that is a subset of X.

Lemma 14.

For any set X𝒫(), b(X) is characterised as b(X)={x[0,x]X}.

Proof.

By definition b=n=0bn. Thus,

mb(X) n.mbn(X)
n.(m{xx<n}m{x+nxX})(Lemma 13)
n.(m<nm{x+nxX})
n.(¬(mn)m{x+nxX})
n.((mn)m{x+nxX})
n.((nm)xX.m=x+n)
n.((nm)xX.x=mn)
n.((nm)(mn)X)

In short,

mb(X)n.((nm)(mn)X) (11)

We use (11) to prove the two inclusions of b(X)={x[0,x]X} separetely:

  • b(X){x[0,x]X}. We assume that mb(X) and we need to prove that [0,m]X. Let us take an arbitrary y[0,m]. Since by (11), (mn)X for all nm, then one can take n to be my and have that m(my)X, that is, yX.

  • b(X){x[0,x]X}. We assume that [0,m]X. Thus n.((nm)(mn)X) that, by (11), means that mb(X).

Proposition 15.

For any set Y𝒫(), the following are equivalent

  • bb(Y)Y;

  • 0X and (n.[0,n]Yn+1Y).

Proof.
bb(Y)Y {0}{y+1yb(Y)}Y (10)
0Y and {y+1yb(Y)}Y
0Y and ({y+1y{n[0,n]Y}}Y) (Lemma 14)
0Y and (n.[0,n]Yn+1Y)

The above proposition allows us to easily see that strong induction (2) is induction up-to b. The latter is illustrated below on the left. The former is reported on the right.

bb(Y)YYXμbXiffQ(0)n(n[0,n].Q(n))Q(n+1)QPn.P(n)

The correspondence between the two rules mirrors that of induction. The conclusions of the two rules coincide in the same way that they did for induction. For the premise, observe that, by Proposition 15,

bb(Y)YiffQ(0)(n(n[0,n].Q(n))Q(n+1)).

6.2 Strong Induction on Words

As expected, one can use strong induction not only on but on any inductive data type. Below, we illustrate strong induction on A, the set of words over an alphabet A.

As we did for natural numbers, we need to give a monotone map c:𝒫(A)𝒫(A) that gives induction on words, i.e. whose least fixed point is A. The candidate monotone map c mimics the definition of the monotone map b for natural numbers: it maps a set X to the set containing the empty word and all the successors of words in X.

c(X)=def{ϵ}{awwX,aA} (12)

Since the least fixed point of c is A, the induction principle (5) instantiated to c give us the usual induction principle on words.

c(Y)YYXμcXiffQ(ϵ)aA.wA.Q(w)Q(aw)QPwA.P(w)

We now turn our attention to (Strong Induction) instantiated with c:

cc(Y)YYXμcX

What does this means in practice? To answer this question, the key is to have a handy characterisation of c. This is going to resemble that of b but, instead of the ordering on natural numbers, we consider the suffix partial ordering of words:

vAwiffuA.w=uv.

The analogue of the interval [0,n] for natural numbers is, then, the set of suffixes of a word, 𝖲𝗎𝖿(w)=def{uAuw}. With this, we obtain that the down closure of c gives the biggest subset that is closed under suffixes.

c(X)={xA𝖲𝗎𝖿(x)X}

With this result, we can explicit the strong induction principle on words.

Q(ϵ)aA.wA.(y𝖲𝗎𝖿(w).Q(y))Q(aw)QPwA.P(w)

Compare this principle with strong induction on natural numbers: consider the singleton set A={}. Then, words on A are determined by their length, so A is in bijection with the natural numbers . Through this bijection, 𝖲𝗎𝖿(w) coincides with the interval [0,|w|]. This further justifies the name of strong induction.

7 From Lattice to Categories

Induction is both a proof principle and a definition principle. The latter can be obtained as generalisation of the former by moving from lattices to categories. As (inductive) up-to techniques are enhancements of the induction proof principle, by means of a similar generalisation, one can obtain enhancements of the induction definition principle. In this section, we illustrate that induction up-to generalises to a recursion scheme known as comonadic recursion [8] and strong induction generalises to course-of-value iteration [38, 7].

7.1 Initial agebras and the induction definition principle

Hereafter, we write × and + for products and coproducts in some category 𝐂, a,b:XY×Z for the pairing of a:XY and b:XZ and [c,d]:Y+ZX for the copairing of c:YX and d:ZX. The singleton set {ϵ} is denoted by 1.

Given a functor F:𝐂𝐂 on some category 𝐂, an F-algebra is a pair (X,a) where X is an object of 𝐂 and a:FXX is an arrow. Given two F-algebras (X,a) and (Y,b), an algebra morphism h:(X,a)(Y,b) is an arrow h:XY of 𝐂 making the diagram below commute. An F-algebra (μF,𝗂) is said to be initial if for any F-algebra (X,a), there exists a unique algebra morphism (|a|)F:(μF,𝗂)(X,a).

Initial algebras give the induction definition principle: in order to specify a morphism from μF to some object X it is enough to give an F-algebra on X.

 Remark 16.

When the category 𝐂 is a complete lattice, a functor F on 𝐂 is simply a monotone map; an F-algebra is a pre-fixed point for F and an initial F-algebra is a least fixed-point. In this perspective, the induction definition principle collapses to the induction proof principle: specifying an arrow μFX means exactly proving that μFX.

Consider 𝐒𝐞𝐭 –the category of sets and functions– and N:𝐒𝐞𝐭𝐒𝐞𝐭 the functor mapping a set X into 1+X and a function a into id1+a. An initial algebra for N is provided by (,[𝟢,𝗌]) where 𝟢:1 assigns to ϵ the number 0 and 𝗌: assigns to any n, its successor n+1. Now, given an F-algebra [p,a]:1+XX, one obtains, by initiality, a function (|[p,a]|)N:X, as illustrated below on the left.

The fact that the diagram on the left commutes is expressed by the conditions on the right. The first condition provides the base case of an inductive definition; the second one provides the inductive case. Note that, in order to define (|[p,a]|)N(n+1), one uses the value (|[p,a]|)N(n). Sometimes, as in the Fibonacci sequence in Section 2, functions are specified by using not just their value at n but also their values at some smaller numbers. This can be done by enhancing the induction definition principle by means of recursion schemes.

7.2 Comonadic Recursion

A comonad on a category 𝐂 is a functor D:𝐂𝐂 together with two natural transformations, the counit ε:DId and the comultiplication δ:DDD, such that εDXδX=idDX=DεXδX and DδXδX=δDXδX for all objects X. A distributive law of a functor F:𝐂𝐂 over the comonad D is a natural transformation ζ:FDDF such that εFXζX=FεX and δFXζX=DζXζDXFδX.

Comonadic recursion exploits a comonad D and a distributive law ζ:FDDF to enhance the induction definition principle. In order to define a morphism from μF to X, rather than specifying an F-algebra, one can specify an FD-algebra a:FDXX. Indeed, such a gives rise to

which is an F-algebra and thus, by initiality of μF, one obtains (|a|)F:μFDX that can be composed with the counit εX:DXX to obtain the desired morphism from μF to X.

 Remark 17.

Following Remark 16, when 𝐂 is a complete lattice, a comonad D is simply a down-closure; a distributive law ζ:FDDF witnesses that FDDF, namely that D is cocompatible with F. The algebra a:FDXX is just an inductive invariant up-to D and a:FDXDX is the corresponding inductive invariant provided by Proposition 6: observe that the three arrows in the definition of a are exactly the three steps in the proof of Proposition 6. The morphism of εX(|a|)F:μFX gives us the proof of Theorem 7. All this justifies the following statement.

Proposition 18.

When 𝐂 is a complete lattice, comonadic recursion is induction up-to.

7.3 Course-of-Value Iteration

Course-of-value iteration is a recursion scheme that is obtained from comonadic recursion by taking D to be the cofree comonad generated by F. Below, we shortly recall this.

Coalgebras are the dual of algebras: a coalgebra for a functor F:𝐂𝐂 is a pair (X,a) with a:XFX. Given two F-coalgebras (X,a) and (Y,b), a coalgebra morphism h:(X,a)(Y,b) is an arrow h:XY of 𝐂 such that Fha=bh. An F-coalgebra (νF,𝖺) is said to be final if for any F-coalgebra (X,a), there exists a unique coalgebra morphism [[a]]F:(X,a)(νF,𝖺).

For an object A of 𝐂, we denote with FA:𝐂𝐂 the functor mapping an object X into FX×A and arrow a into Ff×idA. Whenever FA has a final coalgebra 𝗍A,𝗈A:νFAF(νFA)×A for all objects A, one can define a comonad (F,ε,δ) on 𝐂. The functor F:𝐂𝐂 maps an object X into the final coalgebra νFX and an arrow a:XY into the unique final coalgebra morphism [[𝗍X,a𝗈X]]FY:νFXνFY. For all objects X, the counit ε:FId is defined as 𝗈X:νFXX; the comultiplication δ:FFF as [[𝗍X,idνFX]]FνFX:νFXνFνFX.

Crucially, there exists a distributive law of F over F, denoted by ζ:FFFF, that is defined for all objects X as [[Fπ1,Fπ2F𝗍X,𝗈X]]FFX:F(νFX)νFFX.

 Remark 19.

Following Remarks 16 and 17, when 𝐂 is a complete lattice, an F-coalgebra is a post-fixed point for F and a final F-algebra is a greatest fixed-point. The cofree comonad F simplifies to the down-closure generated by the monotone map F, as defined in (4). The condition on the existence of a final FA-coalgebra for all objects A trivially holds when 𝐂 is a lattice. The existence of the distributive law ζ:FFFF simplifies to Corollary 9. All this justifies the following statement.

Proposition 20.

When 𝐂 is a complete lattice, course of value iteration is strong induction.

7.4 Back to Fibonacci

We conclude by illustrating course of value iteration in the case when F is the functor N introduced in Section 7.1. First, it is convenient to recall some auxiliary ingredients.

For a set A, we write Ane for the set of all finite and infinite sequences over A that are non-empty. For a sequence σAne, we write σ(0)σ(1) whenever σ is infinite and σ(0)σ(1)σ(n)ϵ whenever σ has length n+1. Appending ϵ at the end of the word is a convenient notation to avoid confusing an element aA with the sequence aϵAne. For all σAne, we define 𝗁𝖽:AneA and 𝗍𝗅:Ane1+Ane as follows.

𝗁𝖽(σ)=defσ(0)𝗍𝗅(σ)=def{σ(1)σ(2)σ(n)ϵif σ has length n+1σ(1)σ(2)otherwise

The pairing 𝗍𝗅,𝗁𝖽:Ane(1+Ane)×A forms a coalgebra for the functor NA:𝐒𝐞𝐭𝐒𝐞𝐭. Actually, (Ane,𝗍𝗅,𝗁𝖽) is a final coalgebra for NA: for all NA-coalgebra t,o:X(1+X)×A there exists a unique morphism making the following diagram on the left commute.

Commutation of the diagram is expressed by the conditions on the right: these provide a coinductive definition for [[t,o]]NA.

Since for all sets A there exists a final NA-coalgebra, then there exists the cofree comonad N and a distributive law ζ:NNNN (more details in Appendix B). Most importantly, given a function a:1+AneA (i.e, an NN-algebra), one can extend it to a function a:1+AneAne (i.e, an N-algebra) coinductively defined for all x1+Ane as

𝗁𝖽(a(x))=defa(x)𝗍𝗅(a(x))=def{ϵif x=ϵa(𝗍𝗅(x))otherwise. (13)

By initiality of (,[𝟢,𝗌]), one has a morphism (|a|)N inductively defined

(|a|)N(𝟢)=a(ϵ)(|a|)N(𝗌(n))=a((|a|)N(n)) (14)

that can be composed with the counit 𝗁𝖽 to obtain the desired morphism A.

The inductive case in (14) can be conveniently rephrased (see Lemma 22 in Appendix B) as

(|a|)N(𝗌(n))=a((|a|)N(n))(|a|)N(n).

In summary, (|a|)N(0)=a(ϵ)ϵ and

(|a|)N(𝗌(n))=a((|a|)N(n))a((|a|)N(n1))a((|a|)N(0))a(ϵ)ϵ.

Intuitively,(|a|)N(n+1) may depend on (|a|)N(n), (|a|)N(n1)

For a concrete example take A to be and a to be fib:1+ne defined as

fib(x)=def{1if x=ϵ or x has length 1x(0)+x(1)otherwise

for all x1+ne. The reader can easily check that (|fib|)N(0)=1ϵ, (|fib|)N(1)=11ϵ, (|fib|)N(2)=211ϵ and so on. By composing (|fib|)N with 𝗁𝖽:AneA is clear that one obtains the Fibonacci sequence recalled in Section 2.

8 Conclusions and future work

We have introduced induction up-to by dualising the framework of coinduction up-to from [28]. More precisely, we defined the notion of cocompatible functions (Definition 5) and proved that such functions provide sound up-to techniques (Theorem 7) that can be conveniently composed in various ways (Proposition 8). In particular, for any monotone function f, its downclosure f is always f-cocompatible (Corollary 9). We refer to induction up-to f as strong induction. Our main insight is that the well-known principle of strong induction over the natural numbers is induction up-to b (Section 6.1), where b is the map having as its least fixed point.

We then demonstrated that, by applying comonadic recursion [39] to lattices, we obtain exactly our theory of induction up-to (Proposition 18), while strong induction corresponds to the lattice-theoretic version of course-of-value iteration [38, 7] (Proposition 20).

We believe that these results shed light on the relationship between the schemes used to define programs and the techniques employed to prove their properties. It is no coincidence that, in Section 2, we required strong induction to prove properties of the Fibonacci sequence, which is defined by course-of-value iteration.

By dualising the results in [5], which enhance the fibrational framework of Hermida and Jacobs [18], we can distill compatible inductive up-to techniques from each comonad D. Verifying all the details is a substantial task that we leave for future work.

References

  • [1] Roberto M Amadio and Luca Cardelli. Subtyping recursive types. ACM Transactions on Programming Languages and Systems (TOPLAS), 15(4):575–631, 1993. doi:10.1145/155183.155231.
  • [2] Falk Bartels. Generalised coinduction. Mathematical Structures in Computer Science, 13(2):321–348, 2003. doi:10.1017/S0960129502003900.
  • [3] Filippo Bonchi, Pierre Ganty, Roberto Giacobazzi, and Dusko Pavlovic. Sound up-to techniques and complete abstract domains. In Proceedings of the 33rd Annual ACM/IEEE Symposium on Logic in Computer Science, pages 175–184, 2018. doi:10.1145/3209108.3209169.
  • [4] Filippo Bonchi, Barbara König, and Daniela Petrisan. Up-to techniques for behavioural metrics via fibrations. Math. Struct. Comput. Sci., 33(4-5):182–221, 2023. doi:10.1017/s0960129523000166.
  • [5] Filippo Bonchi, Daniela Petrisan, Damien Pous, and Jurriaan Rot. A general account of coinduction up-to. Acta Informatica, 54(2):127–190, 2017. doi:10.1007/S00236-016-0271-4.
  • [6] Filippo Bonchi and Damien Pous. Checking NFA equivalence with bisimulations up to congruence. In Roberto Giacobazzi and Radhia Cousot, editors, The 40th Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL ’13, Rome, Italy - January 23 - 25, 2013, pages 457–468. ACM, 2013. doi:10.1145/2429069.2429124.
  • [7] Daniela Cancila, Furio Honsell, and Marina Lenisa. Generalized coiteration schemata. Electronic Notes in Theoretical Computer Science, 82(1):76–93, 2003. doi:10.1016/S1571-0661(04)80633-9.
  • [8] Venanzio Capretta, Tarmo Uustalu, and Varmo Vene. Recursive coalgebras from comonads. Information and Computation, 204(4):437–468, 2006. doi:10.1016/j.ic.2005.08.005.
  • [9] Didier Caucal. Graphes canoniques de graphes algébriques. RAIRO Theor. Informatics Appl., 24:339–352, 1990. doi:10.1051/ita/1990240403391.
  • [10] Konstantinos Chatzikokolakis, Catuscia Palamidessi, and Valeria Vignudelli. Up-to techniques for generalized bisimulation metrics. In Josée Desharnais and Radha Jagadeesan, editors, 27th International Conference on Concurrency Theory, CONCUR 2016, August 23-26, 2016, Québec City, Canada, volume 59 of LIPIcs, pages 35:1–35:14. Schloss Dagstuhl – Leibniz-Zentrum für Informatik, 2016. doi:10.4230/LIPIcs.CONCUR.2016.35.
  • [11] Thierry Coquand. Infinite objects in type theory. In International Workshop on Types for Proofs and Programs, pages 62–78. Springer, 1993. doi:10.1007/3-540-58085-9_72.
  • [12] Erik P. de Vink and Jan J.M.M. Rutten. Bisimulation for probabilistic transition systems: a coalgebraic approach. Theoretical Computer Science, 221(1):271–293, 1999. doi:10.1016/S0304-3975(99)00035-3.
  • [13] Adrien Durier, Daniel Hirschkoff, and Davide Sangiorgi. Divergence and unique solution of equations. Logical Methods in Computer Science, 15, 2019. doi:10.23638/LMCS-15(3:12)2019.
  • [14] Marco Forti and Furio Honsell. Set theory with free construction principles. Annali della Scuola Normale Superiore di Pisa-Classe di Scienze, 10(3):493–522, 1983.
  • [15] Herman Geuvers and Bart Jacobs. Relating apartness and bisimulation. Logical Methods in Computer Science, 17, 2021. doi:10.46298/lmcs-17(3:15)2021.
  • [16] Ichiro Hasuo, Bart Jacobs, and Ana Sokolova. Generic trace semantics via coinduction. Logical Methods in Computer Science, 3, 2007. doi:10.2168/LMCS-3(4:11)2007.
  • [17] Ichiro Hasuo, Shunsuke Shimizu, and Corina Cîrstea. Lattice-theoretic progress measures and coalgebraic model checking. In Proceedings of the 43rd Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, pages 718–732, 2016. doi:10.1145/2837614.2837673.
  • [18] Claudio Hermida and Bart Jacobs. Structural induction and coinduction in a fibrational setting. Information and computation, 145(2):107–152, 1998. doi:10.1006/inco.1998.2725.
  • [19] Arend Heyting. Zur intuitionistischen axiomatik der projektiven geometrie. Mathematische Annalen, 98(1):491–538, 1928.
  • [20] Bart Jacobs, Alexandra Silva, and Ana Sokolova. Trace semantics via determinization. In International Workshop on Coalgebraic Methods in Computer Science, pages 109–129. Springer, 2012. doi:10.1007/978-3-642-32784-1_7.
  • [21] Bartek Klin. Bialgebras for structural operational semantics: An introduction. Theor. Comput. Sci., 412(38):5043–5069, 2011. doi:10.1016/j.tcs.2011.03.023.
  • [22] Dexter Kozen and Alexandra Silva. Practical coinduction. Mathematical Structures in Computer Science, 27(7):1132–1152, 2017. doi:10.1017/S0960129515000493.
  • [23] Robin Milner. Communication and concurrency, volume 84 of PHI Series in computer science. Prentice Hall, 1989.
  • [24] Robin Milner and Mads Tofte. Co-induction in relational semantics. Theoretical computer science, 87(1):209–220, 1991. doi:10.1016/0304-3975(91)90033-X.
  • [25] Keiko Nakata and Tarmo Uustalu. Resumptions, weak bisimilarity and big-step semantics for while with interactive I/O: An exercise in mixed induction-coinduction. In In Proceedings of SOS 2010, pages 57–75, 2010. doi:10.4204/EPTCS.32.5.
  • [26] David Park. Fixpoint induction and proofs of program properties. Machine intelligence, 5, 1969.
  • [27] David Park. Concurrency and automata on infinite sequences. In Theoretical Computer Science: 5th GI-Conference Karlsruhe, March 23–25, 1981, pages 167–183. Springer, 2005.
  • [28] Damien Pous. Complete lattices and up-to techniques. In Zhong Shao, editor, Programming Languages and Systems, 5th Asian Symposium, APLAS 2007, Singapore, November 29-December 1, 2007, Proceedings, volume 4807 of Lecture Notes in Computer Science, pages 351–366. Springer, 2007. doi:10.1007/978-3-540-76637-7_24.
  • [29] Damien Pous. Coinduction all the way up. In Proceedings of the 31st Annual ACM/IEEE Symposium on Logic in Computer Science, pages 307–316, 2016. doi:10.1145/2933575.2934564.
  • [30] Damien Pous and Davide Sangiorgi. Enhancements of the bisimulation proof method. In Davide Sangiorgi and Jan J. M. M. Rutten, editors, Advanced Topics in Bisimulation and Coinduction, volume 52 of Cambridge tracts in theoretical computer science, pages 233–289. Cambridge University Press, UK, 2012.
  • [31] Jan J.M.M. Rutten. Behavioural differential equations: a coinductive calculus of streams, automata, and power series. Theoretical Computer Science, 308(1):1–53, 2003. doi:10.1016/S0304-3975(02)00895-2.
  • [32] Davide Sangiorgi. On the bisimulation proof method. Mathematical Structures in Computer Science , Volume 8 , Issue 5, 1998. doi:10.1017/S0960129598002527.
  • [33] Davide Sangiorgi. On the origins of bisimulation and coinduction. ACM Transactions on Programming Languages and Systems (TOPLAS), 31(4):1–41, 2009. doi:10.1145/1516507.1516510.
  • [34] Davide Sangiorgi. Equations, contractions, and unique solutions. ACM Transactions on Computational Logic (TOCL), 18(1):1–30, 2017. doi:10.1145/2971339.
  • [35] Davide Sangiorgi. From enhanced coinduction towards enhanced induction. Proceedings of the ACM on Programming Languages, 6(POPL):1–29, 2022. doi:10.1145/3498679.
  • [36] Alexandra Silva, Filippo Bonchi, Marcello M. Bonsangue, and Jan J. M. M. Rutten. Generalizing the powerset construction, coalgebraically. In Kamal Lodaya and Meena Mahajan, editors, IARCS Annual Conference on Foundations of Software Technology and Theoretical Computer Science, FSTTCS 2010, December 15-18, 2010, Chennai, India, volume 8 of LIPIcs, pages 272–283. Schloss-Dagstuhl-Leibniz Zentrum für Informatik, Schloss Dagstuhl – Leibniz-Zentrum für Informatik, 2010. doi:10.4230/LIPIcs.FSTTCS.2010.272.
  • [37] Daniele Turi and Gordon Plotkin. Towards a mathematical operational semantics. In Proceedings of Twelfth Annual IEEE Symposium on Logic in Computer Science, pages 280–291. IEEE, 1997. doi:10.1109/LICS.1997.614955.
  • [38] Tarmo Uustalu and Varmo Vene. Primitive (co) recursion and course-of-value (co) iteration, categorically. Informatica, 10(1):5–26, 1999. doi:10.3233/INF-1999-10102.
  • [39] Tarmo Uustalu, Varmo Vene, and Alberto Pardo. Recursion schemes from comonads. Nordic Journal of Computing, 8(3):366–390, 2001. URL: http://www.cs.helsinki.fi/njc/References/uustaluvp2001:366.html.
  • [40] Johan Van Benthem. Modal logic and classical logic. 1983.
  • [41] Rob J van Glabbeek. The linear time - branching time spectrum II: The semantics of sequential systems with silent moves extended abstract. In International Conference on Concurrency Theory, pages 66–81. Springer, 1993.
  • [42] Rob J Van Glabbeek. The linear time - branching time spectrum I. In Jan A. Bergstra, Alban Ponse, and Scott A. Smolka, editors, Handbook of Process Algebra, pages 3–99. North-Holland / Elsevier, 2001. doi:10.1016/b978-044482830-9/50019-9.

Appendix A Appendix to Section 5

Proof of Proposition 8.

We prove in sequence each point.

  1. 1.

    fidX=f=idXf;

  2. 2.

    ff=ff;

  3. 3.

    By the following derivation

    fde dfe (d is fcompatible)
    def (e is fcompatible and d is monotone )
  4. 4.

    By induction.

    Base case: n=0. By (3) and point 1.

    Inductive case: n=n+1. By hypothesis d is f-compatible; by induction hypothesis dn is f-compatible; by point 3, ddn is f-compatible. By definition, see (3), dn+1=ddn. Thus dn+1 is f-compatible.

  5. 5.

    Proving f(de)(de)f means proving that: for all xX,

    f(de)(x)(de)f(x).

    Since, for all xX,

    de(x)=d(x)e(x),

    it holds that:

    f(de)(x)=f(d(x)e(x))
    (de)f(x)=df(x)ef(x)

    In summary, to prove f(de)(de)f, we need to prove that, for all xX, f(d(x)e(x))df(x)ef(x). We can proceed separately:

    • First, f(d(x)e(x))df(x) :

      f(d(x)e(x)) fd(x)(d(x)e(x)d(x))
      df(x)(d is fcompatible)
    • Similarly for f(d(x)e(x))df(x).

    Since f(d(x)e(x)) is below both df(x) and ef(x), we have that

    f(d(x)e(x))df(x)ef(x).
  6. 6.

    The proof is analogous to the one of Point 5. We need to prove that, for all xX,

    fidi(x)idif(x)

    Thus, it is enough to prove that i, fjdj(x)dif(x). We proceed as follows:

    fjdj(x) fdi(x) (jdjdi)
    dif(x) (di is fcompatible)
  7. 7.

    By (4) and Lemmas 4 and 6.

Proof of 11.

We prove the two points separately.

  1. 1.

    Assume that d is an up-closure; Thus ¬xd(¬x) and d(d(¬x))d(¬x) for all xL; By (9), ¬¬x¬d(¬x) and ¬d(d(¬x))¬d(¬x), i.e., xd¯(x) and d¯d¯(x)d¯(x). The reverse implication has the same proof.

  2. 2.

    Observe that for all monotone maps i,j on L, it holds that ij iff i¬j¬ iff ¬j¬i. Thus

    dffd df¬fd¬
    ¬fd¬¬df¬
    ¬f¬¬d¬¬d¬¬f¬
    f¯d¯d¯f¯
  3. 3.

    By the following derivation

    yfd(y) ¬fd(y)¬y
    ¬f¬¬d¬(¬y)¬y
    f¯d¯(¬y)¬y

Appendix B Details on Section 7.4

In Section 7.3, we give the recipe to compute the cofree comonad for an arbitrary functor F and in Section 7.4 we used the cofree comonad for the functor N:𝐒𝐞𝐭𝐒𝐞𝐭 in order to illustrate course-of-value Iteration for the natural numbers. For reader convenience, in this appendix we illustrate in details the cofree comonad (N,ϵ,δ) and the distributive law ζ:NNNN by simply unfolding the definitions of Section 7.3.

First we illustrate the endofunctor N:𝐒𝐞𝐭𝐒𝐞𝐭. It maps any set X into the set Xne since, as discussed in the main text, (Xne,𝗍𝗅,𝗁𝖽) is a final NX coalgebra. For a function a:XY, Na:XneYne is the unique map from the NY-coalgebra (Xne,𝗍𝗅X,a𝗁𝖽X) to the final NY-coalgebra (Yne,𝗍𝗅,𝗁𝖽) as illustrated below.

Thus, the function Na:XneYne can be defined conductively as follows.

𝗁𝖽(Na(σ))=a(𝗁𝖽X(σ))𝗍𝗅(Na(σ))={ϵif 𝗍𝗅X(σ)=ϵ;Na(𝗍𝗅X(σ))otherwise.

More explicitly, Na maps σXne into

a(σ(0))a(σ(1))

We can now illustrate the natural transformations. The counit ϵ:NId is given, for all sets X, by 𝗁𝖽X:XneX. The comultiplication δ:NNN is given by the unique morphism from the NXne-coalgebra (Xne,𝗍𝗅X,idXne) to the final NXne-coalgebra ((Xne)ne,𝗍𝗅,𝗁𝖽), as illustrated below.

Thus, the function δX:Xne(Xne)ne can be coinductively defined as follows.

𝗁𝖽(δX(σ))=σ𝗍𝗅(δX(σ))={ϵif 𝗍𝗅X(σ)=ϵ;δX(𝗍𝗅X(σ))otherwise.

Intuitively, σXne is mapped into

σ(0)σ(1)σ(2)σ(1)σ(2)σ(2)

So far, we have described the comonad (N,ϵ,δ). We can now move to the distributive law. For all sets X, the distributive law ζ:NNNN is given by the unique morphism from the N1+X-coalgebra illustrated below on the left to the final N1+X-coalgebra ((1+X)ne,𝗍𝗅,𝗁𝖽).

Thus, the function ζX:1+Xne(1+X)ne can be coinductively defined as follows.

𝗁𝖽(ζX(ϵ))=ϵ𝗍𝗅(ζX(ϵ))=ϵ𝗁𝖽(ζX(σ))=𝗁𝖽X(σ)𝗍𝗅(ζX(σ))={ϵif 𝗍𝗅X(σ)=ϵ;ζX(𝗍𝗅X(σ))otherwise.

Intuitively [[h]]1+X maps ϵ into the sequence ϵϵ and any σXne into the same sequence σ(1+X)ne.

We conclude this appendix with some computation that allows for the handier characterisation of (|a|)N illustrated in the main text.

Lemma 21.

For all n, a(𝗍𝗅((|a|)N(n)))=(|a|)N(n).

Proof.

By induction on .

For 0,

a(𝗍𝗅((|a|)N(0))) =a(𝗍𝗅(a(ϵ))) (14)
=a(ϵ) (13)
=(|a|)N(𝟢) (14)

For n+1,

a(𝗍𝗅((|a|)N(n+1))) =a(𝗍𝗅(a(|a|)N(n))) (14)
=a(a(𝗍𝗅((|a|)N(n)))) (13)
=a((|a|)N(n)) (Induction Hypothesis)
=(|a|)N(n+1) (14)

Lemma 22.

For all n, (|a|)N(𝗌(n))=a((|a|)N(n))(|a|)N(n).

Proof.
(|a|)N(𝗌(n)) =a((|a|)N(𝗌(n))) (14)
=𝗁𝖽(a((|a|)N(𝗌(n))))𝗍𝗅(a((|a|)N(𝗌(n))))
=a((|a|)N(𝗌(n)))a(𝗍𝗅((|a|)N(𝗌(n)))) (13)
=a((|a|)N(𝗌(n)))(|a|)N(n) (Lemma 21)