Indexed Induction and Coinduction, Fibrationally

This paper extends the fibrational approach to induction and coinduction pioneered by Hermida and Jacobs, and developed by the current authors, in two key directions. First, we present a dual to the sound induction rule for inductive types that we developed previously. That is, we present a sound coinduction rule for any data type arising as the carrier of the final coalgebra of a functor, thus relaxing Hermida and Jacobs' restriction to polynomial functors. To achieve this we introduce the notion of a quotient category with equality (QCE) that i) abstracts the standard notion of a fibration of relations constructed from a given fibration; and ii) plays a role in the theory of coinduction dual to that played by a comprehension category with unit (CCU) in the theory of induction. Secondly, we show that inductive and coinductive indexed types also admit sound induction and coinduction rules. Indexed data types often arise as carriers of initial algebras and final coalgebras of functors on slice categories, so we give sufficient conditions under which we can construct, from a CCU (QCE) U:E \rightarrow B, a fibration with base B/I that models indexing by I and is also a CCU (resp., QCE). We finish the paper by considering the more general case of sound induction and coinduction rules for indexed data types when the indexing is itself given by a fibration.


Introduction
Iteration operators provide a uniform way to express common and naturally occurring patterns of recursion over inductive types.Expressing recursion via iteration operators makes code easier to read, write, and understand; facilitates code reuse; guarantees properties of programs such as totality and termination; and supports optimising program transformations such as fold fusion and short cut fusion.Categorically, iteration operators arise from the initial algebra semantics of data types: the constructors of an inductive type are modelled as a functor F , the data type itself is modelled as the carrier µF of the initial F -algebra in : F (µF ) → µF , and the iteration operator fold : (F A → A) → µF → A for µF is the map sending each F -algebra h : F A → A to the unique F -algebra morphism from in to h.
Initial algebra semantics therefore provides a comprehensive theory of iteration that is i) principled, in that it ensures that programs have rigorous mathematical foundations that can be used to give them meaning; ii) expressive, in that it is applicable to all inductive types -i.e., all types that are carriers of initial algebras -rather than just to syntactically defined classes of data types such as polynomial ones; and iii) sound, in that it is valid in any model -set-theoretic, domain-theoretic, realisability, etc. -in which data types are interpreted as the carriers of initial algebras.
Final coalgebra semantics gives an equally comprehensive understanding of coinductive types.The destructors of a coinductive type are modelled as a functor F , the data type itself is modelled as the carrier νF of the final F -coalgebra out : νF → F (νF ), and the coiteration operator unfold : (A → F A) → A → νF for νF is the map sending each Fcoalgebra k : A → F A to the unique F -coalgebra morphism from k to out .Final coalgebra semantics thus provides a theory of coiteration that is as principled, expressive, and sound as that for induction.
Since induction and iteration are closely linked, we might expect initial algebra semantics to give a principled, expressive, and sound theory of induction as well.But most theories of induction for a data type µF , where F : B → B, are sound only under significant restrictions on the category B, the functor F , or the form and nature of the property to be established.Recently, however, a conceptual breakthrough in the theory of induction was made by Hermida and Jacobs [9].They first showed how to lift an arbitrary functor F on a base category B of types to a functor F on a category of properties over those types.Then, taking the premises of an induction rule for µF to be an F -algebra, their main theorem shows that such a rule is sound if the lifting F preserves truth predicates.Hermida and Jacobs work in a fibrational, and hence axiomatic, setting and treat any notion of property that can be suitably fibred over B.Moreover, they place no stringent requirements on B. Thus, they overcome two of the aforementioned limitations.But since they give sound induction rules only for polynomial data types, the limitation on the functors treated remains in their work.The current authors [5] subsequently removed this final restriction to give sound induction rules for all inductive types under conditions commensurate with those in [9].
In this paper, we extend the existing body of work in three key directions.First, Hermida and Jacobs developed a fibrational theory of coinduction to complement their theory of induction.But this theory, too, is sound only for polynomial data types, and so does not apply to final coalgebras of some key functors, such as the finite powerset functor.In this paper, we derive a sound fibrational coinduction rule for every coinductive type.Secondly, data types arising as initial algebras of functors are fairly simple.More sophisticated data types -e.g., untyped lambda terms and red-black trees -are often modelled as inductive indexed types arising as initial algebras of functors on slice categories, presheaf categories, and similar structures.In this paper, we derive sound induction rules for such inductive indexed types.We do this by considering first the special case of indexing via slice categories, and then the general case where indexing is itself given by a suitable fibration.Finally, since we can derive sound induction rules for inductive types and inductive indexed types, and sound coinduction rules for coinductive types, we might expect to be able to derive sound coinduction rules for coinductive indexed types, too.In this paper, we confirm that this is the case and, again, consider first the special case of indexing via slice categories and then the general situation.
We now describe the structure of the rest of this paper.After describing the results in each section, we give a concrete example of a widely-used data type and a corresponding logic for which the results of that section can derive a sound induction or coinduction rule, as appropriate, but for which such a rule cannot be derived from previously known techniques of comparable generality.We thus show that our framework not only facilitates an abstract conceptualisation that reveals the essence of induction and coinduction, but also significantly advances the state-of-the-art by being instantiable to a larger class of data types and logics than ever before.The rest of this paper is structured as follows.
• In Section 2, we recall the fibrational approach to induction pioneered in [9] and extended in [5].We also present a number of fibrations, each of which captures a different logic of interest.Finally, we recall conditions under which the fibrational induction rule we derive in [5] can be instantiated to give a sound concrete induction rule for any inductive data type with respect to any such logic.• In Section 3 we extend the fibrational approach to coinduction from [9] to derive a coinduction rule that can be instantiated to give a sound concrete coinduction rule for any coinductive data type.We illustrate this by deriving a sound coinduction rule for the coinductive data type determined by the finite powerset functor.This functor is fundamental in the theory of bisimulation and labelled transition systems, but it is not a polynomial functor and so cannot be handled using the techniques of Hermida and Jacobs.
• In Section 4 we use slice categories to model indexing of data types, and thus to give sound concrete induction rules for all inductive indexed data types.We apply this result to derive a sound induction rule for inductive type determined by indexed containers with respect to the families fibration, and then further specialise this rule to the inductive indexed data type of untyped lambda terms.The data type of untyped lambda terms is not determined by a polynomial functor, so the sound induction rule we derive for it is not simply an instantiation of Hermida and Jacobs' results.• In Section 5 we use slice categories again, this time to give sound concrete coinduction rules for all coinductive data types.We apply our results to derive sound coinduction (i.e., bisimulation) rules for coinductive types determined by indexed containers.These coinductive types are equivalent to Hancock and Hyvernat's interaction structures [10].However, since they are not determined by polynomial functors, the coinduction rules we derive for them are not simply instantiations of Hermida and Jacobs' results.
• In Section 6 we study fibrational indexed induction by generalising the indexing of data types from slice categories to fibrations.We derive an induction rule that extends the one in Section 4 and show how it can be instantiated to give sound induction rules for set-indexed data types.Set-indexing occurs, for example, in mutually recursive definitions of data types.• In Section 7 we similarly study fibrational indexed coinduction, derive a coinduction rule that extends the one in Section 5, and point out that this rule can be instantiated to give sound coinduction rules for set-indexed data types.• In Section 8 we summarise our conclusions and discuss related work and possibilities for future research.This paper is a revised and expanded version of the conference paper [4].Whereas the conference paper covers only indexing modelled by slice categories, this paper also treats general indexing.Accordingly, the material in Sections 6 and 7 is entirely new.

Induction in a Fibrational Setting
Fibrations support a uniform axiomatic approach to induction and coinduction that is widely applicable and abstracts over the specific choices of the category in which types are interpreted, the functor on that category giving rise to the data type whose rules are to be constructed, and the predicate those rules may be used to establish.This is advantageous because i) the semantics of data types in languages involving recursion and other effects usually involves categories other than Set; ii) in such circumstances, the standard set-based interpretations of predicates are no longer germane; iii) in any setting, there can be more than one reasonable notion of predicate; and iv) fibrations allow induction and coinduction rules for many classes of data types to be obtained by the instantiation of a single generic theory, rather than developed on an ad hoc basis.The genericness supported by fibrations provides a predictive power that is the hallmark of any good scientific theory.
A fibration is simply a functor U : E → B that guarantees a large supply of cartesian morphisms.The exact definition is as follows: Definition 2.2.Let U : E → B be a functor.Then U is a fibration if for every object P of E and every morphism f : X → U P in B, there is a cartesian morphism above f with codomain P .
If U : E → B is a fibration, we call B the base category of U and E its total category.Objects of E are thought of as properties, objects of B are thought of as types, and U is thought to map each property P in E to the type U P about which it is a property.An object P in E is said to be above its image U P under U , and similarly for morphisms.For any object X of B, we write E X for the fibre above X, i.e., for the subcategory of E comprising objects above X and morphisms above the identity morphism id X on X. Morphisms within a fibre are said to be vertical.
If U : E → B is a fibration, P is an object of E, and f : X → U P , we write f § P for the cartesian morphism above f with codomain P .We omit the subscript P when it can be inferred from context.As with all entities defined via universal properties, f § P is defined up to isomorphism; we write f * P for the domain of f § P .If f : X → Y is a morphism in the base of a fibration, then the function mapping each object P of E Y to f * P extends to a functor f * : E Y → E X called the reindexing functor induced by f .If we think of f as performing type-level substitution, then f * can be thought of as lifting f to perform substitution of types into predicates.
Example 2.3.The category Fam(Set) has as objects pairs (X, P ) with X a set and P : X → Set.We call X the domain of (X, P ) and write P for (X, P ) when convenient.A morphism from P : X → Set to P ′ : X ′ → Set is a pair (f, f ∼ ) of functions f : X → X ′ and f ∼ : ∀x : X. P x → P ′ (f x).The functor U : Fam(Set) → Set mapping (X, P ) to X is called the families fibration.Here, the cartesian morphism associated with the object P : Y → Set in Fam(Set) and the morphism f : X → Y in Set is the morphism (f, id) in Fam(Set) from P f : X → Set to P .
Example 2.4.The arrow category of B, denoted B → , has morphisms of B as its objects.A morphism from f : The codomain functor cod : A useful restriction of the previous fibration considers (equivalence classes of) monic maps only: Example 2.5.Let B be a category with pullbacks.Let Sub(B) be the category of subobjects of B, i.e., let the objects of Sub(B) be equivalence classes of monos (where m : X → I and n : X → I are equivalent iff they are isomorphic in the slice category B/I).The subobject fibration over B is the fibration U : Sub(B) → B that sends an equivalence class [m] to the codomain of m.Reindexing is well-defined because the pullback of a mono along any morphism is again a mono.Note that every fibre Sub(B) I is a preorder, and thus that U is a fibred preorder.Fibred preorders can be thought of logically as modelling just provability, rather than proofs themselves.
The following fibration appears as Example 4.8.7 (iii) in [12]: Example 2.6.Let CL be the category of complete lattices with functions preserving all joins between them.If X is a complete lattice, then a subset A ⊆ X is admissible if A is closed under joins in X.We write ASub(CL) for the category whose objects are pairs (X, A), where X is a complete lattice and A is an admissible subset of X, and whose morphisms from Admissible subsets of complete lattices form a fibration U : 2.1.1.Bifibrations.We will later need the generalisation of the notion of a fibration to that of a bifibration.Since bifibrations are defined in terms of opfibrations, we begin by defining these.Abstractly, U : E → B is an opfibration if U op : E op → B op is a fibration.This characterisation has the merit of allowing us to use duality to establish properties of opfibrations from properties of fibrations, but a more concrete definition can be obtained by unwinding the characterisation above.Definition 2.7.Let U : E → B be a functor.A morphism Just as a fibration is simply a functor that has a plentiful supply of cartesian morphisms in its domain, so an opfibration is a functor that has a plentiful supply of opcartesian morphisms in its domain.We have: Definition 2.8.If U : E → B is a functor, then U is an opfibration if for every object P of E and every morphism f : U P → Y in B there is an opcartesian morphism in E above f with domain P .A functor U is a bifibration if it is simultaneously a fibration and an opfibration.
If U is an opfibration, P is an object of E and f : U P → Y is a morphism of B, then we denote the opcartesian morphism above f with domain P by f P § and note that, as with cartesian morphisms, this is defined up to isomorphism.We write Σ f P for the codomain of f P § and omit the superscript P when it can be inferred from context.If f : X → Y is a morphism in the base of an opfibration, then the function mapping each object P of E X to Σ f P extends to a functor Σ f : E X → E Y called the opreindexing functor induced by f .The following useful result is from [13]: Lemma 2.9.Let U : E → B be a fibration.Then U is a bifibration iff, for every morphism Both the families fibration and the codomain fibration are opfibrations, and thus bifibrations.In the families fibration, if f : X → Y is a function, and P : X → Set is an object of Fam(Set) above X, then the associated opcartesian morphism has as codomain the function from Y to Set that maps y ∈ Y to the disjoint union {x∈X|f x=y} P x.The first component of the opcartesian morphism is f , and its second component maps x ∈ X and p ∈ P x to the pair (x, p).In the codomain fibration, if f : X → Y is a morphism in the base category and g : Z → X is above X, then we can construct the opcartesian morphism consisting of the pair of morphisms (id Z , f ) from g to f g.In general, the subobject fibration over B is not an opfibration, and hence not a bifibration.However, as shown in Lemma 4.4.6 of [12], if B is a regular category then it is.
2.1.2.Beck-Chevalley Conditions and Fibred Adjunctions.Beck-Chevalley conditions are used to guarantee that reindexing satisfies desirable commutativity properties.See [12] for an expanded treatment of the following discussion.Definition 2.10.Let U : E → B be a bifibration.We say that U satisfies the Beck-Chevalley condition (for opreindexing) if for any pullback square in B, the canonical natural transformation Σ s t * .− → g * Σ f defined as is an isomorphism.Here, η f is the unit of the adjunction Σ f ⊣ f * and ǫ s is the counit of the adjunction Σ s ⊣ s * .
It is easy to check that the families fibration, the codomain fibration, and the fibration of admissible subsets of complete lattices satisfy the Beck-Chevalley condition.In addition, the subobject fibration over B satisfies the Beck-Chevalley condition if B is regular.In addition, we have: Lemma 2.11.Let U : E → B be a bifibration that satisfies the Beck-Chevalley condition.
Then for any mono f : X → Y in B, (1) the functor Σ f : E X → E Y is full and faithful, and (2) any opcartesian morphism above f is also cartesian.
Given that fibrations are the fundamental structures used in this paper, it is natural to ask what morphisms between such structures might be.In general, we can consider this question in a setting where the fibrations can have different base categories.However, for our purposes we only need consider the special case where the base categories of the fibrations involved are the same.In this situation we have the following definition: Definition 2.12.Let B be a category.Given two fibrations U : E → B and U ′ : E ′ → B with base category B, a fibred functor from U to U ′ above B is a functor H : E → E ′ such that H preserves cartesian morphisms and the following diagram commutes: One of the key points about fibred functors is that they allow us to define fibred adjunctions, and thus to lift standard categorical structures to the fibred setting.In the special case when the base categories of the fibrations are the same, a fibred adjunction is defined as follows: Definition 2.13.Let B be a category and U : E → B and U ′ : E ′ → B be fibrations.Given two fibred functors G : U → U ′ and F : U ′ → U above B, we say that G is a fibred right adjoint of F above B iff G is right adjoint to F and the unit (or, equivalently, counit) of the adjunction F ⊣ G is vertical.We say that the adjunction F ⊣ G is a fibred adjunction above B.
Henceforth, we speak only of fibred functors and fibred adjunctions, and leave implicit the fact they are above a particular category.
The definition of a fibred adjunction can be given an alternative form in terms of a collection of adjunctions between corresponding fibres of fibrations and a coherence property linking these adjunctions together.To see this, we first introduce the following helpful notation.Given fibrations U : E → B and U ′ : E ′ → B, a fibred functor F : U → U ′ , and an object X of B, we denote by F X : E X → E ′ X the restriction of F to the fibre E X .We know the image of F X lies within E ′ X because F is fibred.We have: Lemma 2.14.Let B be a category, let U : E → B and U ′ : E ′ → B be fibrations, and let G : U → U ′ be a fibred functor.Then G has a fibred left adjoint iff the following two conditions hold: (1) for any X in B, G X has a left adjoint F X , and (2) for every morphism f : X → Y in B with associated reindexing functors f * and f † with respect to U and U ′ , respectively, the canonical natural transformation from from the fact that G, and hence G X , preserves cartesian morphisms.
Suppose X is in B and P is in E ′ X in the setting of Lemma 2.14.Then F P = F X P , and if η is the unit of F ⊣ G and η X is the unit of F X ⊣ G X , then η P = (η X ) P .
We conclude this section with a lemma about (non-fibred) adjunctions and the preservation of cartesian and opcartesian morphisms.
Lemma 2.15.Let U : E → B and U ′ : E ′ → B be fibrations.Further, let F : E → E ′ and G : E ′ → E be adjoint functors F ⊣ G with vertical unit (or equivalently, counit) such that U = U ′ F and U ′ = U G. Then the functor F preserves opcartesian morphisms and the functor G preserves cartesian morphisms.
Proof.We prove only that G preserves cartesian morphisms; the second result is then obtained by dualising.Let f : X → Y be a morphism in B and let u : Q → P be the cartesian morphism above f in E ′ .We will prove that Gu is cartesian above f in E. To do this, let l : R → GP be a morphism in E above f g for some g in B. Then the transpose ǫ P (F l) of l is above f g in E ′ because the counit ǫ of the adjunction F ⊣ G is vertical.We then have a unique morphism v : F R → Q in E ′ above g such that uv = ǫ P (F l) since u is cartesian.Because η is vertical, this gives us a unique morphism (Gv)η R : R → GQ in E above g such that (Gu)(Gvη R ) = l.

2.2.
Fibrational Induction in Another Nutshell.At the heart of Hermida and Jacobs' approach to induction is the observation that if U : E → B is a fibration and F : B → B is a functor, then F can be lifted to a functor F : E → E and the premises of the induction rule for µF can be taken to be an F -algebra.Hermida and Jacobs observed that, crucially, this lifting must be truth-preserving.We define these terms now.Definition 2.16.Let U : E → B be a fibration and F : B → B be a functor.A lifting of F with respect to U is a functor F : E → E such that U F = F U .If each fibre E X has a terminal object, and if reindexing preserves terminal objects, then we say that U has fibred terminal objects.In this case, the map assigning to every X in B the terminal object in E X defines a full and faithful functor K U that is called the truth functor for U and is right adjoint to U .We omit the subscript on K U when this can be inferred.A lifting The families fibration has fibred terminal objects: the terminal object in the fibre above X is the function mapping each x ∈ X to the one-element set.The codomain fibration cod also has fibred terminal objects: the terminal object in the fibre above X is id X .The subobject fibration has fibred terminal objects: the terminal object in the fibre above X is the equivalence class of id X .A truth-preserving lifting F → of F with respect to cod is given by the action of F on morphisms.Truth-preserving liftings of functors with respect to the families fibration and the subobject fibration over a regular category can be obtained from the results of this section.
As mentioned in the introduction, in the fibrational approach to induction the premises of an induction rule for a data type µF are taken to be an F -algebra α : F P → P .But what about the conclusion of such an induction rule?Since its premises are an F -algebra, it is reasonable to expect its conclusion to be the unique mediating morphism from the initial F -algebra to α.But this expectation is thwarted because an initial F -algebra is not, in general, guaranteed to exist.We therefore seek conditions ensuring that, for every functor F on the base category of a fibration U , its lifting F has an initial algebra.Moreover, our examples below suggest that the carrier of this initial F -algebra should be K(µF ), where K is the truth functor for U .Fortunately, we already know that any truth-preserving lifting F of F defines a functor K-Alg F : Alg F → Alg F mapping an F -algebra α : F X → X to the F -algebra Kα : KF X ∼ = F KX → KX.Soundness of the induction rule thus turns out to be equivalent to requiring that applying K-Alg F to the initial F -algebra gives the initial F -algebra.We capture this discussion formally as follows: Definition 2.17.Let U : E → B be a fibration with truth functor K : B → E and let F : B → B be a functor whose initial algebra has carrier µF .We say that a truth-preserving lifting F of F defines a sound induction rule for µF in U if the functor K-Alg F : Alg F → Alg F preserves initial objects.
We will omit explicit reference to U when it is clear from context.In the situation of Definition 2.17, the generic fibrational induction rule is given by ind F : (∀P : E X ). ( F P → P ) → K(µF ) → P and its soundness ensures that if α : F P → P is above f , then ind F P α is above fold f .
To see how the above categorical definition of an induction rule corresponds to our intuitive understanding, we look at an example before returning to the general discussion of fibrational induction.
Example 2.18.The data type Nat of natural numbers is µN , where N is the functor on Set defined by N X = 1 + X.A lifting N of N from Set to Fam(Set) is given by An N -algebra with carrier P : Nat → Set can be given by in : 1 + Nat → Nat and in ∼ : ∀t : 1 + Nat.N P t → P (in t).Since in (inl * ) = 0 and in (inr n) = n + 1, we see that in ∼ consists of an element h 1 : P 0 and a function h 2 : ∀n : Nat.P n → P (n + 1).These are exactly the premises of the standard induction rule we learn on the playground.As for the conclusion of the induction rule, we first note that fold in = id, so that the induction rule has as its conclusion a morphism of predicates from KNat to P whose first component is id .The second component will be a function with type ∀n : Nat. 1 → P n, i.e., a function that gives, for n ∈ Nat, a proof in P n.This is exactly as expected.
Definition 2.17 naturally leads us to ask for conditions on a fibration U guaranteeing that a truth-preserving lifting of a functor F defines a sound induction rule for µF .Hermida and Jacobs' key theorem states that a sufficient condition is that U be a comprehension category with unit.Definition 2.19.A comprehension category with unit (CCU) is a fibration U : E → B with a truth functor K U that has a right adjoint {−} U .In this case, {−} U is called the comprehension functor for U .
We omit the subscript on {−} U when this can be inferred from context.
The families fibration is a CCU: the comprehension functor maps a predicate P : X → Set to the set Σx : X. P x.The fibration cod is the canonical CCU: the comprehension functor is the domain functor dom : The subobject fibration over a category B is a CCU: the comprehension functor maps an equivalence class to the domain of a (chosen) representative.As shown in [9], truth-preserving liftings for CCUs define sound induction rules.That is, Theorem 2.20.Let U : E → B be a CCU and F : B → B be a functor whose initial algebra has carrier µF .Then every truth-preserving lifting F of F with respect to U defines a sound induction rule for µF .
The proof of this theorem is conceptually simple: Hermida and Jacobs show that under the assumptions of the theorem, each functor K-Alg F has a right adjoint and therefore preserves all colimits, including the initial object.This very elegant theorem shows that fibrations provide just the right structure to derive sound induction rules for inductive types whose underlying functors have truth-preserving liftings.And it's amazing to see such structure captured so smoothly as the existence of a pair of adjoints to the fibration itself.However, there is still one missing ingredient, namely, a set of conditions under which functors are guaranteed to have truth-preserving liftings.Hermida and Jacobs [9] provided truth-preserving liftings, and thus sound induction rules, only for polynomial functors.This situation was rectified in [5], where it was shown that every functor has a truth-preserving lifting with respect to every CCU that is also a bifibration.Such CCUs are called Lawvere categories.
Definition 2.21.A fibration U : E → B is a Lawvere category if it is a CCU that is also a bifibration.
If ǫ is the counit of the adjunction K ⊣ {−} for a CCU U , then π P = U ǫ P defines a natural transformation π : {−} → U .Moreover, π extends to a functor π : E → B → in the obvious way.
Lemma 2.22.Let U : E → B be a Lawvere category.Then π has a left adjoint I : For any functor F , the composition F = IF → π : E → E defines a truth-preserving lifting with respect to the Lawvere category U [6].Here, F → is the lifting given after Definition 2.16 of F to the total category of the codomain fibration.Concretely, F P = Σ F π P KF {P }.Thus, if U is a Lawvere category and F has an initial algebra µF , then Theorem 2.20 guarantees that F defines a sound induction rule for µF .Indeed, we have: Theorem 2.23.If U : E → B is a Lawvere category and F : B → B is a functor whose initial algebra has carrier µF , then there exists a sound induction rule for µF in U .
If B has pullbacks, so that the functor cod is actually a fibration, then the following diagram establishes that we have actually given a uniform modular construction of a lifting with respect to any Lawvere category by factorisation through the lifting for cod : In [9], Hermida and Jacobs augmented their sound fibrational induction rules for carriers of initial algebras of polynomial functors with a sound coinduction rule for carriers of final coalgebras of polynomial functors.The goals of this section are to recall the results of Hermida and Jacobs, and to extend them to give sound coinduction rules for carriers of final coalgebras of functors.Hermida and Jacobs begin by observing that coinduction is concerned with relations.Given a fibration U whose total category is thought of as a category of predicates, they therefore construct a new fibration Rel(U ) whose total category is thought of as a category of relations.Definition 3.1.Let U : E → B be a fibration where B has products, and let ∆ : B → B be the diagonal functor sending an object X to X ×X.Then the fibration Rel(U ) : Rel(E) → B is obtained by the pullback of U along ∆.We call Rel(U ) the relations fibration for U .
That the pullback of a fibration along any functor is a fibration is well-known [14], and the process of pulling back a fibration along a functor F to obtain a new fibration is called change of base along F .Since an opfibration from E to B is a fibration from E op to B op , change of base preserves opfibrations as well as fibrations, and therefore preserves bifibrations.Below we denote the pullback of any functor If U : E → B is a bifibration, then change of base along a natural transformation α : F → G induces an adjunction between F * E and G * E. We have: Lemma 3.2.For U : E → B a bifibration and α : F → G a natural transformation with F, G : A → B. There is an adjunction Furthermore, if U satisfies the Beck-Chevalley condition and the components of α are monos, then Σ α is full and faithful.
Proof.Straightforward from the definitions of Σ α and α * and Lemmas 2.9 and 2.11.Definition 3.1 entails that the fibre of Rel(E) above X is the fibre Change of base is well-known to preserve fibred terminal objects [8].It therefore preserves truth functors, so that Rel(U ) has a truth functor whenever U does.This is given by K Rel(U ) X = K U (X × X).
Example 3.3.Let U be the families fibration.Then the fibre of Rel(U ) above a set X consists of functions R : X × X → Set.These are, as intended, just (set-valued) relations.The truth functor for Rel(U ) maps a set X to the relation R : X × X → Set that maps each pair (x, x ′ ) to the one-element set.
In the inductive setting, truth-preserving liftings were needed.In the coinductive setting, we need equality-preserving liftings, where the equality functor is defined as follows: Definition 3.4.Let U : E → B be a bifibration where B has products, and let K be the truth functor for U .Let δ : Id B → ∆ be the diagonal natural transformation for ∆ with components δ X : X → X × X, and let Σ δ : E → Rel(E) be the functor mapping an object P above X to the object Σ δ X P .Note that Σ δ X P is above X × X in E and above X in Rel(E).The equality functor for U is the functor Eq U : B → Rel(E) defined by Eq U = Σ δ K.The functor Eq U maps each morphism f to the unique morphism above f × f induced by the naturality of δ at f and the opcartesian morphism We suppress the subscripts on Eq U and Q U when convenient.The notion of an equalitypreserving lifting of a functor is then defined as follows: Definition 3.5.Let U : E → B be a bifibration where B has products, suppose U has a truth functor, and let F : B → B be a functor.A lifting F of F with respect to Rel(U ) is said to be equality-preserving if Eq F ∼ = F Eq. Just as truth-preserving liftings are the key to defining induction rules, equality-preserving liftings are the key to defining coinduction rules.The following definition is pleasantly dual to Definition 2.17: Definition 3.6.Let U : E → B be a bifibration where B has products, suppose U has a truth functor, and let F : B → B be a functor whose final coalgebra has carrier νF .We say that an Eq-preserving lifting F of F defines a sound coinduction rule for νF in U if the functor Eq-CoAlg F : CoAlg F → CoAlg F sending each F -coalgebra α : X → F X to the F -coalgebra Eq α : Eq X → EqF X ∼ = F EqX preserves terminal objects.
As before, we omit explicit reference to U when it is clear from context.
As in [9], there is a simple condition under which Eq-preserving liftings define sound coinduction rules, namely, that U has a quotient functor.Note the duality: in the inductive setting the truth functor K must have a right adjoint, whereas in the coinductive setting the equality functor Eq must have a left adjoint.Theorem 3.7.Let U : E → B be a bifibration where B has products, suppose U has a truth functor and a quotient functor, and let F : B → B be a functor whose final coalgebra has carrier νF .Then every equality-preserving lifting F of F with respect to Rel(U ) defines a sound coinduction rule for νF .
As before, Hermida and Jacobs' proof is conceptually simple: If U has a quotient functor, then each functor Eq-CoAlg F has a left adjoint and hence preserves all limits, including the terminal object.As a result, the carrier of the final F -coalgebra is obtained by applying Eq to the final F -coalgebra, and the generic fibrational coinduction rule is therefore given by coind F : (∀R : Soundness of the rule ensures that if α : R → F R is above f , then coind F Rα is above unfold f .
As was the case for induction, Hermida and Jacobs provided Eq-preserving liftings only for polynomial functors, and thus sound coinduction rules only for carriers of their final coalgebras.The outstanding issue is then to establish a set of conditions under which functors are guaranteed to have equality-preserving liftings.
3.1.Generic Coinduction For All Coinductive Types.The first contribution of this paper is to give a sound coinduction rule for every coinductive type, i.e., for every data type that is the carrier νF of the final coalgebra for a functor F .This entails determining conditions sufficient to guarantee that functors have equality-preserving liftings.To do this, we step back a little and show how to construct liftings that can be instantiated to give both the truth-preserving liftings required for deriving sound induction rules and, by duality, the equality-preserving liftings required for deriving sound coinduction rules.Lemma 3.8.Define a quotient category with equality (QCE) to be a fibration U : E → B with a full and faithful functor E : B → E such that U E = Id B and E has a left adjoint Q with unit η.Let F : B → B be a functor, and define functors ρ, J, and F by Proof.To prove U F = F U , note that the morphisms ρ P each have domain U P , that dom F → ρ = F U , and that U J = dom.Together these give U F = U JF → ρ = F U .To prove F E ∼ = EF , we first assume that i) for every X in B, ρEX is an isomorphism in B, and ii) for every isomorphism f in B, J f ∼ = E(dom f ).Then since U E = Id B , we have that i) and ii) imply that To discharge assumption i), note that the counit ǫ : QE → Id of Q ⊣ E is a natural isomorphism because E is full and faithful.We thus have that Eǫ is also a natural isomorphism and, using the equality Eǫ .ηE = id E , that ηE is a natural isomorphism as well.As a result, ρE = U ηE is a natural isomorphism.To discharge ii), let f be an isomorphism in B. Since cartesian morphisms above isomorphisms are isomorphisms, we have Here, the first isomorphism is witnessed by f § and the second by Although it is not needed in our work, we observe that if U is a QCE, then ρ is left adjoint to J. The proof is a straightforward application of the universal property of reindexing; see Lemma 2.2.10 in [3].The lifting F has as its dual the lifting F given in the following lemma.Lemma 3.9.Let U : E → B be an opfibration, let K : B → E a full and faithful functor such that U K = Id B , and let C : E → B be a right adjoint to K with counit ǫ.Let F : B → B be a functor, and define functors π, I, and F by Then U F = F U (i.e., F is a lifting of F ) and F K ∼ = KF .
Proof.By dualisation of Lemma 3.8.The setting on the left below with U an opfibration is equivalent to the setting on the right with U a fibration.
We can instantiate Lemmas 3.8 and 3.9 to derive both the truth-preserving lifting for all functors from [5] (presented above) and an equality-preserving lifting for all functors.The latter gives the sound induction rules for inductive types presented in [5], and the former gives our sound coinduction rules for all coinductive types.To obtain the lifting for induction, let U : E → B be a Lawvere category, K be the truth functor for U , and C be the comprehension functor for U .Since a Lawvere category is an opfibration, Lemma 3.9 ensures that any functor F : B → B lifts to a truth-preserving lifting F : E → E. This is exactly the lifting of [5].To obtain the lifting for coinduction, let U : E → B be a bifibration satisfying the Beck-Chevalley condition, let B have products, and let K be a truth functor for U .Now, consider the relations fibration Rel(U ) for U , and let Eq be the equality functor for U .Since δ is a mono, since Eq = Σ δ K, and since both K and Σ δ are full and faithful, Lemma 2.11 ensures that Eq is full and faithful.Moreover, since, for every X in B, Eq X is in the fibre of Rel(U ) above X, we have Rel(U ) Eq = Id B .We can therefore take E to be Eq in Lemma 3.8 provided Eq has a left adjoint Q.In this case, every functor F : B → B has an equality-preserving lifting F : Rel(E) → Rel(E), and so if F has a final coalgebra νF , then νF has a sound coinduction rule.We record this in the following theorem.Henceforth, we call a QCE of the form Rel(U ) obtained by change of base of U along ∆ by the above construction, and for which the functor E is thus the equality functor for U , a relational QCE.
Theorem 3.10.If Rel(U ) : Rel(E) → B is a relational QCE obtained from a fibration U : E → B, and if F : B → B is a functor whose final coalgebra has carrier νF , then there exists a sound coinduction rule for νF in U.
Just as cod is the canonical CCU, if dom is the canonical QCE.Indeed, if U is dom : then F is exactly F → .Thus, just as the lifting F with respect to an arbitrary fibration U satisfying the hypotheses of Lemma 3.9 can be modularly constructed from the specific lifting F → with respect to cod [5], so the lifting F with respect to an arbitrary fibration U satisfying the hypotheses of Lemma 3.8 can be modularly constructed from the specific lifting F → with respect to dom.
What we have seen is that dom plays a role in the coinductive setting similar to that played by cod in the inductive one.We think of a morphism f : X → Y in the total category of cod as a predicate on Y whose proofs constitute X. Intuitively, f maps each p in X to the element y in Y about which it is a proof.Similarly, we think of a morphism f : X → Y in the total category of dom as a relation on X, the quotient of X by which has equivalence classes comprising Y .Intuitively, f maps each x in X to its equivalence class in that quotient.
The following two examples of relational QCEs appear in Propositions 4.8.6 and 4.8.7(iii) in [12].
Example 3.11.Let B be a regular category.The relations fibration for the subobject fibration U : Sub(B) → B is a relational QCE iff B has coequalisers.In this case, the equality functor maps an object X of B to the equivalence class of δ X : X → X ×X in Sub(B).The quotient functor maps an equivalence class [m], with m = m 0 , m 1 : R X ×X, to the codomain X/R of the coequaliser c R of m 0 and m 1 : Example 3.12.Consider the fibration U : ASub(CL) → CL of admissible subsets of complete lattices and its associated relations fibration U ′ : Rel(ASub(CL)) → CL.We have that U ′ is a relational QCE.Indeed, the equality functor Eq : CL → Rel(ASub(CL)) maps a complete lattice X to the admissible subset {(x, x) | x ∈ X} ⊆ X×X.The quotient functor Example 3.13.As we have seen, if U is the families fibration, then the fibre above X in Rel(U ) consists of functions R : X × X → Set.We think of these functions as constructive relations, with R(x, x ′ ) giving the set of proofs that x is related to x ′ .In Lemma 3.8 we can take U to be the families fibration, E to map each set X to the relation eq X defined by eq X (x, x ′ ) = 1 if x = x ′ and eq X (x, x ′ ) = 0 otherwise, and Q to map each relation R : X × X → Set to the quotient X/R of X by the least equivalence relation containing R. We can then instantiate Lemma 3.8 by taking ρ : Rel(U ) → Set → to map a relation R : X × X → Set to the quotient map ρ R : X → X/R, taking J : Set → → Rel(U ) to map f : X → Y to the relation f mapping (x, x ′ ) to 1 if f x = f x ′ and to 0 otherwise, and taking F : F A × F A → Set to be given by F R = F ρ R .
The following example demonstrates that our approach goes beyond the current state-ofthe-art.We derive the coinduction rule for finitary hereditary sets in the relations fibration for the families fibration.Finitary hereditary sets are elements of the carrier of the final coalgebra of the functor P fin mapping a set to its finite powerset.Since P fin is not polynomial, it lies outside the scope of Hermida and Jacobs' work [9].In fact, as far as we aware, the coinduction rule for finitary hereditary sets that we derive in the next example is more general than any appearing elsewhere in the literature; indeed, the relations in Rel(U ) are not required to be equivalence relations.The functor P fin is, however, important, not least because a number of canonical coalgebras are built from it.For example, a finitely branching labelled transition system with state space S and labels from an alphabet A is a coalgebra with carrier S for the functor P fin (A × −).
Example 3.14.By Example 3.13, the lifting Pfin maps a relation R : A × A → Set to the relation Pfin R : P fin A × P fin A → Set defined by Pfin R = P fin ρ R .Thus, if X and Y are finite subsets of A, then (X, Y ) ∈ Pfin R iff P fin ρ R X = P fin ρ R Y .Since the action of P fin on a morphism f maps any subset of the domain of f to its image under f , P fin ρ R X = P fin ρ R Y iff (∀x : X). (∃y : Y ).x Ry ∧ (∀y : Y ).(∃x : X). x Ry, where R = ρ R is the least equivalence relation containing R. From Pfin we have that the resulting coinduction rule has as its premises a Pfin -coalgebra, i.e., a function α : A → P fin A and a function α † : (∀a, a ′ : A). aRa ′ → (αa) Pfin R (αa ′ ).If we regard α : A → P fin A as a transition function, i.e., if we define a → b iff b ∈ αa, then α † is a bisimulation whenever R is an equivalence relation.In this case, the coinduction rule thus asserts that any two bisimilar states have the same interpretation in the final coalgebra.However, when R is not an equivalence relation, α † is slightly weaker since it only requires transitions to map R-related elements R-related elements.Since it is easier to prove that two elements are R-related than it is to prove them R-related, our coinduction rule is slightly stronger than might be expected at first glance.

Indexed Induction
Data types arising as initial algebras and final coalgebras on traditional semantic categories such as Set and ωcpo ⊥ are of limited expressivity.More sophisticated data types arise as initial algebras of functors on their indexed versions.To build intuition about the resulting inductive indexed types, first consider the inductive type List X of lists of X.It is clear that defining List X for some particular type X does not require any reference to List Y for Y = X.That is, each type List X is inductive all on its own.We call List an indexed inductive type to reflect the fact that it is a family of types, each of which is inductive.By contrast, for each n in Nat, let Fin n be the data type of n-element sets, and consider the inductive definition of the Nat-indexed type Lam : Nat → Set of untyped λ-terms up to α-equivalence with free variables in Fin n.This type is given by Unlike List X, the type Lam n cannot be defined in isolation using only the elements of Lam n that have already been constructed.Indeed, the third inference rule above shows that elements of Lam (n + 1) are needed to construct elements of Lam n.In effect, then, all of the types Lam n must be inductively constructed simultaneously.We call Lam an inductive indexed type to reflect the fact that it is an indexed type that is defined inductively.There is considerable interest in inductive and coinductive indexed types.If types are interpreted in a category B, and if I is a set of indices considered as a discrete category, then an inductive I-indexed type can be modelled by the initial algebra of a functor on the functor category I → B. Alternatively, indices can be modelled by objects of B, and inductive I-indexed types can be modelled by initial algebras of functors on slice categories B/I.Coinductive indexed types can similarly be modelled by final coalgebras of functors on slice categories.
Initial algebra semantics for inductive indexed types has been developed extensively [2,16].Pleasingly, no fundamentally new insights were required: the standard initial algebra semantics needed only to be instantiated to categories such as B/I.By contrast, the theory of induction for inductive indexed types has received comparatively little attention.The second contribution of this paper is to derive sound induction rules for inductive indexed types by similarly instantiating the fibrational treatment of induction to appropriate categories.The key technical question to be solved turns out to be the following: Given a Lawvere category of properties fibred over types, can we construct a new Lawvere category fibred over indexed types from which sound induction rules for inductive indexed types can be derived?To answer this question, we first make the simplifying assumption that the inductive indexed types of interest arise as initial algebras of functors on slice categories, i.e., functors F : B/I → B/I, where I is an object of B. We treat the general case in Section 6.
We conjecture that the total category of the fibration with base B/I that we seek should be a slice category of E. We therefore make the canonical choice to slice over KI, where K is the truth functor for U .We then define U/I : E/KI → B/I by (U/I) (f : P → KI) = (U f : U P → I).Here, cod (U f ) really is I because U K = Id .
We first show that U/I is indeed a bifibration.We do this by proving a more general result that we can reuse in Section 5. Proof.Let α : Y → GI and β : X → GI be objects of B/GI, and let φ : Y → X be a morphism in B/GI from α to β, i.e., let φ be such that α = βφ.Let f : P → F I be an object of E/F I such that (U/F )f = U f = β, and let φ § P : φ * P → P be the cartesian morphism in E above φ with respect to U .Then φ § P is a morphism in E/F I with domain f φ § P and codomain f , and it is cartesian above φ with respect to U/F .Thus, U/F is a fibration if U is. Now, let g : Q → F I be an object of E/F I such that (U/F )g = U g = α, and let § is a morphism in E/F I with domain g and codomain k, and it is opcartesian above φ with respect to U/F .Thus, U/F is an opfibration if U is. Combining these results gives that if U is a bifibration then so is U/F .We can now show that U/I is a bifibration as desired.Lemma 4.2.If U : E → B is a fibration (bifibration) with a truth functor K and I is an object of B, then U/I is a fibration (resp., bifibration).
Proof.This follows from Lemma 4.1 by taking F to be the truth functor K for U and G to be Id B , and then observing that, for this instantiation, U/F is precisely the fibration U/I defined before Lemma 4.1.
There is an alternative characterisation of E/KI that both clarifies the conceptual basis of our treatment of indexed induction and simplifies our calculations.The next lemma is the key observation underlying this characterisation.Lemma 4.3.Let U : E → B be a fibration with truth functor K, let I be an object of B, and let α : Proof.One half of the isomorphism maps the object f : P → KI of (E/KI) α to P .For the other half, note that since truth functors map objects to terminal objects, and since reindexing preserves terminal objects, we have that α * KI is terminal in E X .Thus, for any object Q above X, we get a morphism from Q to KI by composing α § KI and the unique morphism !from Q to α * KI.Since ! is vertical and α § KI is above α, this composition is above α.Thus each object Q in E X maps to an object of (E/KI) α .It is routine to verify that these maps constitute an isomorphism.By Lemma 4.3 we can identify objects (morphisms) of (E/KI) α and objects (resp., morphisms) of E X .This gives our abstract characterisation of U/I: Proof.As noted in Section 3, the pullback of a fibration along a functor is a fibration.The objects (morphisms) of the fibre above α : X → I of the pullback of U along dom are the objects (resp., morphisms) of E X .By Lemma 4.3, the pullback of U along dom is therefore U/I.
As observed just after Definition 3.1, pulling back a fibration along a functor preserves fibred terminal objects so, by Lemma 4.4, U/I has fibred terminal objects if U does.Concretely, the truth functor K U/I : B/I → E/KI maps an object f : X → I to Kf : KX → KI.To see that U/I is a Lawvere category if U is, we must also show that K U/I has a right adjoint if K U does.For this, we use an abstract theorem due to Hermida [7] to transport adjunctions across pullbacks along fibrations.U E E, GU E).Lemma 4.6.Change of base along a fibration preserves CCUs, i.e., if U : E → B is a CCU and U ′ : E ′ → B is a fibration, then the pullback U ′ * U is a CCU.
Proof.We already have that U ′ * U is a fibration with fibred terminal objects.To see that K U ′ * U has a right adjoint, consider the pullback of K U along U * U ′ .This pullback is given by E ′ , K U ′ * U : E ′ → U ′ * E, and U ′ : E ′ → B. Note that U * U ′ is a fibration since it is obtained by pulling U ′ back along U .Lemma 4.5 then ensures that, since K U has a right adjoint, so does K U ′ * U .Thus U ′ * U is a CCU.
If U : E → B is a fibration, I is an object of B, and U ′ is dom : B/I → B, then the comprehension functor for U ′ * U -i.e., for U/I -maps an object f : P → KI to (U f )π P : {P } → I. Combining Lemma 4.6 and the fact that change of base preserves bifibrations, we have: We can use Theorem 4.8 to derive a sound induction rule for the indexed containers of Morris and Altenkirch [16].
Example 4.9.If I is a set, then the category of I-indexed sets is the fibre Fam(Set) I .An I-indexed set is thus a function X : I → Set, and a morphism h from X to X ′ , written h : X → I X ′ , is a function of type (Πi : I).Xi → X ′ i. Morris and Altenkirch denote this category I → Set and define an I-indexed container to be a pair (S, P ) with S : I → Set and P : (Πi : I).Si → I → Set.An I-indexed container defines a functor [S, P ] : (I → Set) → I → Set by [S, P ]Xi = (Σs : Si).P i s → I X.Thus, if t : [S, P ] X i, then t is of the form (s, f ).If g : X → I Y is a morphism of I-indexed sets, then [S, P ]g maps a pair (s, f ) to (s, gf ).
If i ∈ I, then we can think of Si as a collection of operators that produce data of sort i, and we can think of P as assigning to every i and every operator producing data of sort i an I-indexed collection of positions in which data is stored.That is, P i s j is the set of positions associated with the operator s where data of sort j must be stored.This shapes and positions metaphor is also reflected in the functor associated with an indexed container, since we can think of [S, P ]Xi as containing terms of sort i produced by (S, P ) whose input data is drawn from X.Such a term consists of an operator s producing data of sort i and, for each position storing data of sort j, an element of X of sort j.
The initial algebra of [S, P ] is denoted in : [S, P ]W S,P → I W S,P .Since I → Set is equivalent to Set/I, we can use the results of this section to extend those of [16] by giving sound induction rules for data types of the form W S,P .A predicate over an I-indexed set X is a function Q : (Πi : I).Xi → Set.To simplify notation, this is written Q : X → I Set.The lifting [S, P ] of [S, P ] maps each Q : X → I Set to the predicate [S, P ]Q : [S, P ]X → I Set defined by [S, P ] Q i (s, f ) = (Πj : I).(Πp : P i s j).Q j (f j p).Altogether, this gives the following sound induction rule for W S,P : While admittedly rather dense in its type-theoretic formulation, the above induction rule is conceptually clear.The premise says that, for any term in i (s, f ) in W S,P i, we must be able to prove that a property Q : W S,P → I Set holds at in i (s, f ) if Q is assumed to hold of all the immediate subterms of in i (s, f ).The conclusion of the rule says that Q holds for all terms.Of course this is what we naturally expect, and our point is precisely that we can derive it in a principled manner from the fibrational approach to induction rather than simply having to postulate that it is reasonable.
We can instantiate the above induction rule for W S,P for the data type of untyped lambda terms from the beginning of this section.The resulting induction rule cannot be derived using Hermida and Jacobs' techniques because the data type of untyped lambda terms is not the initial algebra of a polynomial functor.The resulting rule is precisely what we expect.For any predicate Q : Lam → Nat Set:

Indexed Coinduction
We now present our third contribution, namely sound coinduction rules for coinductive indexed types.Examples of such types are infinitary versions of inductive indexed types, such as infinitary untyped lambda terms and interaction structures.Following the approach of Section 4, we consider indexing by slice categories in this section.In more detail, we show that for any relational QCE over a base category B and for any object I of B, change of base along dom : B/I → B yields a relational QCE over B/I.
Recall that if B has products and U : E → B is a bifibration that satisfies the Beck-Chevalley condition and has truth functor K, then the equality functor Eq for U is given by Eq = Σ δ K. Let Rel(U ) : Rel(E) → B be a relational QCE, so that Eq has a left adjoint Q.To define a relational QCE over B/I we must first see that B/I has products.But the product of f and g in B/I is determined by their pullback: if W , j : W → Z, and i : W → X give the pullback of f and g, then their product in B/I is the morphism f i or, equivalently, gj.Below, we write f 2 for the product of f : X → I with itself in B/I and X f X for the domain of f 2 .Now, if B has pullbacks, then we can construct the relations fibration Rel(U/I) : Rel(E/KI) → B/I from the pullback of U/I along the product functor ∆/I : B/I → B/I mapping f to f 2 .Concretely, an object of Rel(E/KI) above f : X → I is an object of E/KI above f 2 with respect to U/I.This is, in turn, equivalent to an object of E above X f X with respect to U .5.1.The Equality Functor for U/I.In Section 4 we showed that if U is a bifibration where B has products, and U has a truth functor K, then for any object I of B, U/I is a bifibration that has a truth functor whose action is also that of K, and so is denoted K as well.Furthermore, we have just seen that if B has pullbacks, then B/I also has products.Thus, by Definition 3.4, U/I has an equality functor Eq U/I .To define this functor concretely, note that the component of the diagonal natural transformation δ/I : Id B/I → ∆/I at f : X → I is the mediating morphism in the diagram below on the left.Thus, Eq U/I maps an object f : X → I of B/I to the unique morphism above f 2 in the diagram on the right induced by the opcartesian morphism m above (δ/I) f : Note that if U satisfies the Beck-Chevalley condition, so that opreindexing for U defines a full and faithful functor, then the fact that the action of opreindexing for U/I is the same as opreindexing for U means that opreindexing for U/I defines a full and faithful functor as well.Since truth functors are always full and faithful, so is Eq U/I = Σ δ/I K U/I .

5.2.
The Quotient Functor for U/I.Whereas defining the equality functor for U/I was straightforward, defining its quotient functor is actually tricky.To do so, for each object I of B, we we write Rel(U )/I : Rel(E)/Eq I → B/I for the fibration obtained as the instantiation of Lemma 4.1 in which Eq : B → Rel(E) plays the role of F and Rel(U ) plays the role of U .Concretely, the objects of Rel(E)/Eq I above f : X → I are morphisms α : P → Eq I, for some object P of Rel(E), such that U α = ∆f .Our first result identifies conditions under which Rel(U )/I is a QCE.Proof.Let Eq : B → Rel(E) and Q : Rel(E) → B be the equality and quotient functors for U , respectively.We construct a full and faithful functor E ′ : B/I → Rel(E)/Eq I such that (Rel(U )/I) E ′ = Id B/I , and a left adjoint Q ′ for E ′ , as follows.Take E ′ to be Eq.Then E ′ is full and faithful since Eq is.Moreover, for any f : X → I, Definition 3.4 ensures that Eq f is above f × f with respect to U , so (Rel(U )/I) E ′ f = f , and thus (Rel(U )/I) E ′ = Id B/I .Finally, we define Q ′ to map each object α : P → Eq I of Rel(E)/Eq I to its transpose α ′ : QP → I under the adjunction Q ⊣ Eq.That Q ′ ⊣ E ′ follows directly from Q ⊣ Eq.
We can now define the quotient functor for Rel(U/I) using the functor Q ′ from the proof of Lemma 5.1.The key step is to use Lemma 3.2 to define an adjunction τ ⊣ σ such that the following diagram commutes: Rel(U )/I y y r r r r r r r r r r

B/I
Then if E ′ and Q ′ are the functors witnessing the fact that Rel(U )/I is a QCE, compositionality of adjoints ensures that σE ′ and Q ′ τ give equality and quotient functors for Rel(U/I), respectively.
Proof.In order to prove this lemma, we first instantiate Lemma 4.1, with Eq playing the role of F and ∆ playing the role of G, to obtain the fibration U/Eq : E/Eq I → B/I×I.We then have the following three changes of base: Here, the functor δ I • _ maps f : X → I to δ I • f : X → I × I, and _ × _ maps f to f ×f : X×X → I ×I.The square on the left is a pullback square by definition of Rel(U/I), and the one on the right is a pullback square by direct calculation.To see that the middle square is a pullback square, first observe that since every morphism δ I : I → I×I is a mono, Lemma 2.11 ensures that each opcartesian morphism (δ I ) § : KI → Eq I is also cartesian.For any f : X → I, the fibre above f of the pullback of U/Eq along (δ I ) § : KI → Eq I consists of all morphisms of the form g : P → EqI such that U g = δ I • f .Similarly, the fibre of U/I above f consists of all morphisms of the form g : P → KI such that U g = f .The universal property of (δ I ) § considered as a cartesian morphism ensures that these two fibres are isomorphic, and thus that U/I is indeed the pullback of U/Eq along δ I • _.Now, let f : X → I be a morphism in B, and let i and j be the projections for the pullback square defining X f X.The universal property of the product X × X ensures the existence of a morphism v f : X f X → X×X such that π 1 v = i and π 2 v = j.Moreover, by the universal property of the pullback of f along itself, v f is a mono.In fact, it is easy to check that there is a natural transformation v : dom • ∆/I → ∆ • dom whose component at any f is given by v f .Finally, v extends to a natural transformation α : (δ Indeed, for any f , the fact that commutes by the universal property of the product I × I.By Lemma 3.2, α induces the desired adjunction. Recall that our candidate for the quotient functor Q U/I for Rel(U/I) is Q ′ τ .To see that Q ′ τ ⊣ Eq U/I , we need only verify that Eq U/I is σE ′ .It is routine to check that τ Eq U/I = E ′ , from which Eq U/I = σE ′ follows.We therefore have that Rel(U/I), together with Eq U/I and Q U/I as defined above, form a relational QCE.Thus, by Theorem 3.10, we have Theorem 5.3.Let U : E → B, where B has products and pullbacks, be a bifibration that satisfies the Beck-Chevalley condition.Suppose U has a truth functor.Let I be an object of B and F : B/I → B/I be a functor whose final coalgebra has carrier νF .Then there exists a sound coinduction rule for νF in U/I.
We can use the results of this section to give a sound coinduction rule for final coalgebras of indexed containers that is dual to the sound induction rule of Example 4.9.
Example 5.4.Let (S, P ) be an I-indexed container with final coalgebra out : M S,P → I [S, P ]M S,P .A relation above an I-indexed set X : I → Set is an I-indexed family of relations Ri on Xi.The relational lifting of [S, P ] maps a relation R above an I-indexed set X to the relation R ′ above the I-indexed set [S, P ]X that relates (s, f ) ∈ [S, P ]Xi and (s ′ , f ′ ) ∈ [S, P ]Xi iff s = s ′ and, for all j : I and p : P i s j, f j p is related to f ′ j p in the least equivalence relation containing Rj.This gives the following notion of bisimulation for [S, P ]-coalgebras k : X → I [S, P ]X.Let ρ 0 (s, f ) = s and ρ 1 (s, f ) = f .Then if x, x ′ ∈ Xi, then x ∼ i x ′ iff ρ 0 (kx) = ρ 0 (kx ′ ) and, for all j : I and p : P i (π 0 (kx)) j, we have that ρ 1 (kx)jp ∼ j ρ 1 (kx ′ )jp.As in Example 3.14, the coinduction rule thus asserts that any two bisimilar states have the same interpretation in the final coalgebra.
Stepping back, we see that the above coinduction rule is as expected.To understand it, we think of a term t : M S,P as being part of a transition system whose terms are the subterms of t (including t itself), and suppose there is a transition from every subterm to each of the immediate subterms of that term.Then two terms are bisimilar iff they share the same root operator and each of their subterms are bisimilar.The point is, of course, that the fibrational approach to coinduction derives the rule in a principled manner rather than simply having to postulate it.

Fibred Induction
In Section 4 we saw how the fibrational approach to induction can be instantiated to derive sound induction rules for inductive indexed types when the indexing is given using slice categories.Although it provides a good example of how to exploit the abstract power of fibrations, this instantiation suffers from two limitations: • First, the instantiation successfully treats indexing that is modelled by slice categories, but neither it nor its abstract generalisation can successfully handle more general forms of indexing.Indeed, in Section 4, the fact that the comprehension functor dom is a fibration was critical to showing that U/I is a Lawvere category, but the abstract generalisation of this result does not hold because, in general, a comprehension functor need not be a fibration.To handle general forms of indexing, we therefore need a genuinely new idea.• Secondly, in Section 4 we handle I-indexed types by deriving from a Lawvere category U : E → B a Lawvere category U/I with base category B/I.But this is inelegant because it requires the construction of a new Lawvere category for every possible index I, and because the uniformity over I that connects the different fibrations U/I is completely ignored.Indeed, if we think of fibrations as modelling logics over types, then the results of Section 4 ostensibly choose entirely different logics for different indices.A better approach would formalise the uniformity of the fibrations U/I over the indices I.
In this section we extend the work of Section 4 to derive sound induction rules for general indexed types.This is accomplished by adding an abstraction layer that models the way types are indexed, and thus allows us to treat indexing modelled by structures other than slice categories.More specifically, we consider indexed types to be given by a second fibration r : B → A, so that the objects of B are types indexed by the objects of A. Of course, the logical layer still forms a fibration U : E → B over types, so we get the following basic picture, which captures the move from a single fibration U to a fibration U above a fibration r:

A
Note that rU is a fibration because the composition of two fibrations is again a fibration.Taking A to be the category with one object and one morphism, the sound induction rules in the unindexed setting will be recoverable from the sound induction rules for general indexed types that we develop in this section; see Example 6.8 below.The sound induction rules in the indexed setting of Section 4 will similarly be recoverable by taking r to be the codomain fibration; see Lemma 6.9.In addition, taking r to be the families fibration, we will be able to derive the sound induction rules for carriers of initial algebras of indexed containers directly, rather than deriving them indirectly, as we did in Example 4.9, using the equivalence of the families fibration and the codomain fibration.Let U : E → B and r : B → A be two fibrations.Then an inductive indexed type with index a, where a is an object of A, is the carrier µF of the initial algebra of an endofunctor F : B a → B a , where B a is the fibre of B above a.To derive a sound induction rule for µF using Theorem 2.23, we will ultimately need a Lawvere category with base B a ; indeed, by the discussion immediately following Lemma 2.22, this will ensure the existence of a lifting of F to the total category of that Lawvere category.So, what might we take as that Lawvere category?Since F has domain B a rather than all of B, we cannot expect F to lift to the whole of E. On the other hand, U does restrict to a fibration U a : E a → B a , where E a is the fibre of rU above a.As we will see in Corollary 6.6 below, U a is precisely the Lawvere category we seek.
We begin by establishing the properties of U a that we will need.The following lemma uses change of base to deduce several of them.Lemma 6.1.Let U : E → B and r : B → A be two fibrations.For any object a in A, the fibration U restricts to a fibration U a : E a → B a , where E a is the fibre above a of the fibration rU .Similarly, if U is an opfibration or a bifibration, then so is U a .Finally, if U has a truth functor, then so does U a .
Proof.The fibration U a : E a → B a arises by change of base of U along the inclusion functor Pulling back an opfibration along a functor produces an opfibration, so U a is an opfibration if U is.As a result, U a is a bifibration if U is.Moreover, change of base preserves truth functors, so U a has a truth functor if U does.Indeed, the truth functor for U a is just the restriction of the truth functor for U to B a .
We write K a for the truth functor for U a .Note that while a truth functor always restricts to a subfibration U a , the existence of a truth functor K a for every U a does not necessarily imply that U itself has a truth functor.For this to be the case, reindexing must preserve truth functors from one subfibration to another.Of course, if U is a bifibration, then reindexing is a right adjoint, so it preserves terminal objects, and in this case the individual truth functors K a actually do collectively define a truth functor for U .Our interest in the above results is that they show that the basic structure of a logic (reindexing, opreindexing, and truth functors) over a fibration of indexed types restricts to a corresponding logic over types with a specific index.We may therefore consider truthpreserving (i.e., K a -preserving) liftings of functors F : B a → B a , and ask when such a lifting defines a sound induction rule for µF .From Theorem 2.20 we know the answer: this occurs when the fibration U a : E a → B a is a CCU.But now we face a choice.Is it enough to simply ask that, for every object a of A, U a is a CCU?Or should we require that these different CCUs, when taken collectively, ensure that U is a CCU?
While the former choice is indeed possible, we believe that the latter choice better highlights the uniformity connecting the different fibrations U a .In fact, we have already implicitly made the latter choice when we started with a single fibration U and constructed from it the collection of individual fibrations U a .Unfortunately, asking that each fibration U a is a CCU does not ensure that U itself is a CCU.On the other hand, we cannot simply require U to be a CCU either, since that is not enough to guarantee that each U a is a CCU.But if we require U to be a fibred CCU in the sense of Definition 4.4.5 of [11], then U will indeed be a CCU whose restriction to each subfibre U a is also a CCU.We have: Definition 6.2.Let U : E → B and r : B → A be two fibrations, and let K : B → E the truth functor for U .We say that U is a fibred CCU above r if K has a fibred right adjoint {−} : rU → r: A That K : r → rU is a fibred functor follows from the fact that K : id B → U is also a fibred functor (see Lemma 1.8.8 of [12]).A first consequence of Definition 6.2 is that, if a fibration U : E → B is a fibred CCU above r then U is a CCU.Furthermore, from Lemma 2.14 we have that if U is a fibred CCU above r, then each fibration U a is a CCU.In fact, we have the following correspondence: Lemma 6.3.Let U : E → B and r : B → A be fibrations.The fibration U is a fibred CCU above r with fibred adjunction K ⊣ {−} iff U is a CCU with truth functor K : B → E and comprehension functor {−} : E → B and, for each a in A, the fibration U a : E a → B a is a CCU with comprehension functor {−} a : E a → B a given by restricting {−} to E a .
Proof.Let U be a CCU with truth functor K : B → E and comprehension functor {−} : E → B. Further, suppose that, for every a in A, the fibration U a : E a → B a is a CCU whose comprehension functor {−} a : E a → B a is given by restricting {−} to E a .Then, by Lemma 2.15, we have that {−} is fibred from rU to r.Moreover, since the adjunction {−} ⊢ K restricts to the adjunctions {−} a ⊢ K a , the unit of {−} ⊢ K is vertical with respect to r.The other direction of the equivalence is straightforward.
We have thus shown that a fibred CCU U above r is just the right structure for deriving sound induction rules when indexing of types is described by r.We wanted a structure to guarantee that each U a is a CCU and that these individual CCUs collectively ensure that U is also a CCU.Lemma 6.3 shows that a fibred CCU above r guarantees exactly thisno more, no less.Definition 6.2 straightforwardly extends to Lawvere categories as follows: Definition 6.4.Let U : E → B and r : B → A be fibrations.We say that U is a fibred Lawvere category above r if U is a fibred CCU above r and U is a bifibration.
The next two corollaries are immediate.
Corollary 6.5.Let U : E → B and r : B → A be fibrations.Then U is a fibred Lawvere category above r iff U is a Lawvere category and, for every a in A, U a : E a → B a is a Lawvere category whose unit and comprehension are given by the restrictions of the unit and comprehension, respectively, of U to E a .
Corollary 6.6.Let U : E → B be a fibred Lawvere category above r : B → A. For any object a of A and functor F : B a → B a , any K a -preserving lifting F : E a → E a of F defines a sound induction rule for µF .In particular, the canonical K a -preserving lifting from Section 2 defines a sound induction rule for µF .
Our first example shows that fibred induction is applicable in situations in which indexed induction is not.E).However, we may wish to index data types by sets other than 2. The codomain fibration cod : F am(Set) → → F am(Set) defines a fibred Lawvere category over the families fibration.We therefore have the following induction rule in the families fibration for any predicates P : evens → Set and Q : odds → Set: We can also see the induction rule of Theorem 2.23 as an instance of fibred induction: Example 6.8.Let U : E → B be a Lawvere category.If 1 is the category with one object and one morphism, then U is a fibred Lawvere category above the fibration r : B → 1.Moreover, the treatment of induction from Section 2 is equivalent to the treatment of induction for this fibred Lawvere category.
And we can see indexed induction as an instance of fibred induction: Lemma 6.9.Let U : E → B be a Lawvere category.The fibration q : E ′ → B → obtained by the change of base is a fibred Lawvere category above the codomain fibration and, for any I in B, q I = U/I.
Proof.Consider the following setting: B By Lemma 4.7, q is a Lawvere category because it arises by change of base along the fibration dom.Moreover, for any object I of B, the fibration q I can be obtained by the change of base where i I is the inclusion functor.Thus q I arises as the pullback of U along the composition of dom : B → → B and i I : B/I → B → .But this composition is simply dom : B/I → B, so it is clearly a fibration.Thus, q I is a Lawvere category, and q is itself a fibred Lawvere category above the codomain fibration.Finally, q I = U/I by construction.

Fibred Coinduction
In this section we extend the methodology of Section 6 to give sound coinduction rules for coinductive indexed types in the case when the indexing is not modelled by slice categories.
As in Section 6, we consider a fibration r : B → A, where we think of the objects of B as being indexed by the objects of A, and a fibration U : E → B that we think of as a logic over B. Our aim is to derive sound coinduction rules for final coalgebras of functors F : B a → B a , where a is any object of A.
Our experience from Section 3 suggests that a minimal requirement for deriving a sound coinduction rule for a functor F : B a → B a is that the fibration U a is a QCE.As in Section 6, we want to highlight the uniformity connecting the different fibrations U a but, unfortunately, requiring that each fibration U a is a QCE does not automatically imply that U is a QCE.On the other hand, if we define a (full) section of a functor F : C → D to be a (resp., full and faithful) functor E : D → C such that F E = id D then, for fibrations U : E → B and r : B → A, a (full) section E : B → E of U straightforwardly restricts to a (resp., full) section E a : B a → E a of U a for any object a of A. Then, by contrast with the situation in the inductive case, requiring that each fibration U a is a QCE with section E a actually does ensure that U is a QCE with section E, provided E preserves cartesian morphisms.Indeed, observing that the notion of a cartesian morphism and the notion of a fibre both make sense for arbitrary functors whether or not they are fibrations, and extending our notation for fibres of fibrations to fibres of functors, we have the following: Lemma 7.1.Let r : B → A be a fibration, and let q : E → A and e : B → E be functors such that qe = r.The functor e has a left adjoint Q : E → B with vertical unit (or, equivalently, counit) iff e preserves cartesian morphisms and, for each object a in A, the restriction e a : B a → E a of e has a left adjoint Q a .
Proof.Suppose e preserves cartesian morphisms, let Q a : E a → B a be a collection of left adjoints to the restrictions e a : B a → E a of e, and let η a be the unit of Q a ⊣ e a .We will prove that, for each a in A and R in E a , the morphism (η a ) R : R → eQ a R is universal from R to e (and not just to e a ).By part (ii) of Theorem 2 of Chapter 4 of [15], this gives an adjunction Q ⊣ e.The unit of this adjunction is vertical because it comprises the various units η a .
To this end, consider a morphism l : R → eY in E above h : a → b in A. Then Y is above b, and so there is a cartesian morphism h § Y : h * Y → Y above h with respect to r.Because e preserves cartesian morphisms, we know that e(h § Y ) is cartesian above h with respect to q.Thus l = e(h § Y )u for a unique vertical morphism u : R → e(h * Y ) with respect to q.Now, since u is in E a , we can use the universal property of (η a ) R to deduce a unique morphism g : Q a R → h * Y in B a such that u = e(g)η R .Therefore, we have a unique morphism f = h § Y g such that l = e(f )η R .Conversely, suppose Q is left adjoint to e with vertical unit.Then e preserves cartesian morphisms by Lemma 2.15, and the adjunction Q ⊣ e restricts to adjunctions Q a ⊣ e a because the unit of Q ⊣ e is vertical and qe = r.
We can now give the central definitions we need to state our sound coinduction rules for coinductive indexed types.Definition 7.2.Let U : E → B and r : B → A be two fibrations, and let E : B → E a full section of U .We say that U is a QCE above r if E has a left adjoint Q : E → B and the adjunction Q ⊣ E is fibred above A: Note that, in this case, both E and Q are necessarily fibred.A weak QCE above r is similar to a QCE above r, except that the left adjoint to E need not be fibred (although E itself must still be).
With this definition in place, we have the following analogue of Corollary 6.5: Lemma 7.3.Let U : E → B and r : B → A be fibrations.Then U is a weak QCE above r iff U is a QCE and, for any object a of A, U a : E a → B a is a QCE whose full section and quotient functors are given by the restrictions of the full section and quotient functors, respectively, of U to E a .
Proof.If U is a weak QCE above r, then the fact that U and the fibrations U a are QCEs is straightforward.For the other direction, we observe that the unit (equivalently, counit) of Q ⊢ E is vertical.Lemma 2.15 therefore guarantees that E preserves cartesian morphisms, i.e., is fibred.
Corollary 7.4.Let U : E → B be a weak QCE above r : B → A. For any object a of A and functor F : B a → B a , any E a -preserving lifting F : E a → E a of F defines a sound coinduction rule for νF .In particular, the canonical E a -preserving lifting from Section 3 defines a sound coinduction rule for νF .
We can see Theorem 3.10 as a special case of Corollary 7.4.
Example 7.5.Let U : E → B be a relational QCE.If 1 is the category with one object and one morphism, then U is a weak QCE above the fibration r : B → 1.Moreover, the treatment of coinduction from Section 3 is equivalent to the treatment of coinduction for this weak QCE above r.
We can also see Theorem 5.3 as a special case of Corollary 7.4.This entails constructing, from the data assumed in Lemma 5.1, a weak QCE above the codomain fibration cod .To do this, we first define an analogue of a relational QCE in the setting where we are working above a fibration r.We have the following definition: Definition 7.6.Let U : E → B be a bifibration with truth functor K : B → E, let r : B → A be a fibration, and assume that r has fibred cartesian products, i.e., products in the fibres that are preserved by reindexing.Let ∆ r : r → r be the fibred diagonal functor mapping each object X in B a to the product with itself in B a .Then, the relations fibration above r is defined to be the fibration Rel r (U ) : Rel r (E) → B above r that is obtained by change of base of U along ∆ r .If δ r : Id B → ∆ r is the diagonal natural transformation for ∆ r , then the equality functor for U above r is defined to be the functor Eq r : B → Rel r (E) that maps an object X of B to Σ δr KX.Furthermore, if Eq r has a left adjoint Q r , then Q r is called the quotient functor for U above r.A relational QCE above r is a QCE above r obtained via this construction.A weak relational QCE above r is similar to a relational QCE above r, except that the left adjoint to the fibred equality functor need not be fibred.
The main difficulty in constructing a weak relational QCE U above a fibration r is proving that the equality functor for U is fibred.If B has pullbacks and r : B → → B is the codomain fibration, then r has fibred products given by pullbacks.In this case, we write ∆ → : B → → B → for the functor mapping an object f in (B → ) I to the product f 2 of f with itself in the fibre (B → ) I .We denote the diagonal natural transformation for ∆ → by δ → : Id B → → ∆ → .Lemma 7.7.Let U : E → B be a bifibration with a truth functor, and suppose U satisfies the Beck-Chevalley condition.Furthermore, assume that B products and pullbacks.Let ′ : E ′ → B → be obtained from U by change of base along the fibration dom, and let Rel(U ′ ) : Rel(E ′ ) → B → be obtained from U ′ by change of base along ∆ → : B → → B → : Finally, let Σ δ → : E ′ → Rel(E ′ ) be the functor that maps an object (h : U P → I, P ) of E ′ to the object (h 2 , Σ δ → h P ) of Rel(E ′ ).Then Σ δ → is a fibred functor from cod•U ′ to cod•Rel(U ′ ).Proof.Let (h : U P → I, P ) be an object of E ′ , let f : J → I be a morphism of B, and consider the pullback (X, ψ : X → J, φ : X → U P ) of h along f .Then the cartesian morphism above f with codomain (h, P ) is the morphism (f, φ § P ) : (ψ, φ * P ) → (h, P ) in E ′ .We must show that the morphism Σ δ → (f, φ § P ) : Σ δ → ψ φ * P → Σ δ → h P is cartesian.We begin by considering the morphism (f, φ) : ψ → h in B → .The fact that (X, ψ, φ) is a pullback means that (f, φ) is cartesian.Because ∆ → is fibred, we know that ∆ → (f, φ) is cartesian.Thus, if ∆ → (f, φ) = (f, α), then (X f X, ψ 2 , α) is the pullback of h 2 along f .From part b of Exercise 8 on page 72 of [15], together with the facts that (X, ψ, φ) and (X f X, ψ 2 , α) are pullbacks, we have that (X, δ → ψ , φ) is the pullback of δ → h along α.The Beck-Chevalley condition thus ensures that Σ δ → ψ φ * P is isomorphic to α * Σ δ → h P .Letting Q stand for Σ δ → h P , we therefore have that Σ δ → (f, φ § P ) is (α § Q , (f, α)).Since α § Q , is cartesian with respect to U by definition, and since (f, α) is cartesian with respect to cod , we have that Σ δ → (f, φ § P ) is cartesian with respect to cod • Rel(U ′ ), as required.Proof.We have the following situation: Let I be an object of B. First, by the same reasoning as in the proof of Lemma 6.9 we have that U ′ I = U/I.Now, note that if i I : B/I → B → is the inclusion functor, then ∆ → i I = ∆/I.Thus, Rel(U ′ ) I is obtained by change of base of U/I along the functor ∆/I, i.e., the fibrations Rel(U ′ ) I and Rel(U/I) coincide.Moreover, the equality functor Eq → : B → → Rel(E ′ ) is defined by Σ δ → K → , where K → is the truth functor for U ′ .Then Eq → restricts to the equality functor Eq U/I since δ/I is the restriction of δ → to the corresponding fibres.This ensures that the equality functors for Rel(U ′ ) I and Rel(U/I) coincide.Finally, because adjoints are defined up to isomorphism, the quotient functors for Rel(U ′ ) I and Rel(U/I) coincide.Putting this all together, we have that Rel(U ′ ) I and Rel(U/I) are in fact the same QCE.Now, each restriction Eq → a of Eq → has a left adjoint Q → a .Moreover, Eq → preserves cartesian morphisms because K → preserves cartesian morphisms by construction, and Lemma 7.7 ensures that Σ δ → preserves cartesian morphisms.By Lemma 7.1, we have that Q → is a left adjoint to Eq → , and thus that Rel(U ′ ) is a weak QCE above cod .
The coinduction rule for the mutually recursive data type of odds and evens in the families fibration shows that fibred coinduction is applicable in situations where indexed coinduction is not.

Conclusions, Related Work, and Future Work
In this paper, we have extended the fibrational approach to induction and coinduction pioneered by Hermida and Jacobs, and further developed by the current authors, in three key directions: we have given sound coinduction rules for all (unindexed) coinductive types, and we have extended our results from the unindexed setting to the indexed one to derive sound induction and coinduction rules for all inductive and coinductive indexed types.We derived our rules for indexed types first in the case when indexing is modelled by the codomain fibration, and then in the case when it is modelled by an arbitrary fibration.
The work of Hermida and Jacobs is most closely related to ours, but there is, of course, a large body of work on induction and coinduction in a broader setting.In dependent type theory, for example, data types are usually presented along with elimination rules that are exactly induction rules.Along these lines, [17] has heavily influenced the development of induction in Coq.Another important strand of related work concerns inductive families and their induction rules [2].On the coinductive side, papers such as [1,19,20] have had immense impact in bringing bisimulation into the mainstream of theoretical computer science.
There are several directions for future work.First, we would like to explore more applications of the results in Sections 6 and 7.More generally, we would like to exploit the predictive power of our theory to provide induction and coinduction rules for advanced data types -such as inductive recursive types -for which these rules are not discernible by sheer intuition.In such circumstances, our generic fibrational approach should provide rules whose use is justified by their soundness proofs.In a different direction, we would like to see our induction and coinduction rules for advanced data types incorporated into implementations such as Agda and Coq.
pullbacks, then cod is a fibration, called the codomain fibration over B. Indeed, given an object f : X → Y in the fibre above Y and a morphism f ′ : X ′ → Y in B, the pullback of f along f ′ gives the cartesian morphism above f ′ .Similarly, the domain functor dom : B → → B is a fibration, called the domain fibration over B. No conditions on B are required.

i
: Fin n Var i : Lam n f : Lam n a : Lam n App f a : Lam n b : Lam (n + 1) Abs b : Lam n

Lemma 4 . 1 .
Let U : E → B be a fibration (bifibration) with a functor F : A → E and G : A → B such that U F = G.This, of course, uniquely determines G.For any I in A, the functor U/F : E/F I → B/GI is a fibration (resp., bifibration).

Lemma 4 . 4 .
Let U : E → B be a fibration with a truth functor and let I be an object of B. Then U/I can be obtained by change of base of U along dom : B/I → B.

Lemma 4 . 5 .
Let F ⊣ G : A → B be an adjunction with counit ǫ, and let U : E → B be a fibration.Then the functor U * F : U * A → E has a right adjoint G U : E → U * A mapping each object E to the object (ǫ *

Lemma 4 . 7 .Theorem 4 . 8 .
Let U : E → B be a Lawvere category and U ′ : E ′ → B be a fibration.Then ′ * U -i.e., U/I -is a Lawvere category.Let U : E → B be a Lawvere category, let I be an object of B, and let F : B/I → B/I be a functor whose initial algebra has carrier µF Then there exists a sound induction rule for µF in U/I.

Lemma 5 . 1 .
Let U : E → B be a fibration, let B have pullbacks, let I be an object of B, and let Rel(U ) : Rel(E) → B be a relational QCE.Then Rel(U )/I is a QCE.

Example 6 . 7 .
Consider the mutually recursive data type zero : evens n : odds evenSucc n : evens n : evens oddSucc n : odds If we model types in a category B, then we can model the 2-indexed data type of odds and evens using the initial algebra of the functor F : B 2 → B 2 defined by F (E, O) = (O + 1,

Lemma 7 . 8 ./
Let U : E → B be a bifibration such that the Beck-Chevalley condition holds and B has pullbacks.Let Rel(U ) : Rel(E) → B be the relational QCE derived from U , with equality functor Eq : B → Rel(E) and quotient functor Q : Rel(E) → B. Then the bifibration Rel(U ′ ) : Rel(E ′ ) → B → obtained from the following change of base Rel(E ′ ) Rel(U ′ ) / B → is a weak QCE above cod.In addition, for any I in B, Rel(U ′ ) I ∼ = Rel(U/I).