Deriving Logical Relations from Interpretations of Predicate Logic

This paper extends the results of Hermida’s thesis about logical predicates to more general logical relations and a wider collection of types. The extension of type constructors from types to logical relations is derived from an interpretation of those constructors on a model of predicate logic. This is then further extended to n-ary relations by pullback. Hermida’s theory shows how right adjoints in the category of ﬁbrations are composed from a combination of Cartesian lifting and a local adjunction. This result is generalised to make it more applicable to left adjoints, and then shown to be stable under pullback, deriving an account of n-ary relations from standard predicate logic. A brief discussion of lifting monads to predicates includes the existence of an initial such lifting, generalising existing results.


Introduction
The purpose of this paper is to illustrate a link between logical relations and predicate logics. We begin by revisiting the conditions under which the predicates in a predicate logic for reasoning about a type theory can be shown to carry the structure of that type theory. We then show that similar structure on binary and more generally n-ary relations can be derived from that on unary predicates. Finally, we take a look at structure defined via monads. The core of this material is already known. We extend the results to bring out more clearly what is needed, handle n-ary predicates via change of base, and discuss monadic types.
In order to do this we make use of the tools of category theory. From this perspective, predicate logic is formalised as a fibration over a category representing the type theory. More accurately the base can be taken to have objects representing contexts consisting of variable:type bindings, and morphisms given by substitutions. We concentrate first on type theoretic structure that is defined by adjunction (products, function spaces and sums), but we then discuss monadic structure.
Logical relations were introduced by Gordon Plotkin [13,15]. But he is generous in giving credit to others, notably Hans Laüchli, Mike Gordon and Robert Milne. Milne had come up with a similar idea in connection with proving the equivalence of different semantics for programming languages (under the name of inclusive predicates) [12]. It is Milne's insight, that these structures can be used to establish a formal link between different semantics, that has led to most of the modern work using them.
Since this time, the basic idea has been interpreted in a variety of settings. Calculi have been introduced for working with them, [14] and others, and the idea has been explained in terms of structure-preserving functor from categories of logical relations to the underlying types.
In this paper we build on that, starting out with Hermida's work on logical predicates and how the structure of adjunctions between fibrations leads to an account of the interpretation of type theory in logical predicates.
We mine Hermida's work slightly to show that we do not always need the full structure of fibrations. The key point where this has impact in the case of coproducts. Hermida's account along with successors, requires all cocartesian liftings. This is a strong condition that does not hold in all the syntactic fibrations corresponding to logics.
We then prove a change of base theorem for Hermida's account, and use it to derive the formation of the same type constructions in n-ary relations. The example of function spaces shows that this is not as straightforward as first appears.
We conclude the paper with a discussion of monadic types. These behave differently from the conventional type-theoretic structures. We emphasise this with examples: monads on Set preserves monics, and hence extend to functors on Pred, but not all are fibred (the continuation monad); even though we immediately get an extension to Pred we need more work to get one for Rel (continuations again and also some algebraic theories like Mal'cev algebras). We also present a sufficient condition to have an initial lifting of a monad, relating it to recent work of Kammar and McDermott [8].
This work forms part of a programme, starting with [6], in which we attempt to relate the theory of logical relations to other forms of programme logic and standard forms of mathematical reasoning. The work in this paper supports deriving logical relations from predicates in the standard way that we expect. An issue with this approach is that it requires relations to have a single logical metastructure, rather than to give a systematic link between two different metastructures. This can be mitigated to some extent because the structures considered are closed under products, so can always be combined into a single entity. The work also contains the start of a treatment of monadic types. We expect to put more detail on that in future work.

Predicates and relations
To illustrate the concepts we use the categories of unary and binary relations: Pred and Rel.

Definition 2.1 [Pred]
The objects of the category Pred are pairs (P, A) where A is a set and P is a subset of Identities and composition are inherited from Set.
Pred also has a logical reading. We can take (P, A) as a predicate on the type A, and associate it with a judgement of the form a : A P (a) (read "in the context a : A, P (a) is a proposition"). A morphism (a : A P (a)) → (b : B Q(b)) has two parts: a substitution b → t(a), and the logical consequence P (a) ⇒ Q(t(a)) (read "whenever P (a) holds, then so does Q(t(a))).

Definition 2.2 [Rel and
Rel n ] The objects of the category Rel are triples (R, A 1 , A 2 ) where A 1 and A 2 are sets and R is a subset of A 1 × A 2 (a relation between A 1 and A 2 ). A morphism (R, A 1 , A 2 ) → (S, B 1 , B 2 ) is a pair of functions f 1 : A 1 → B 1 and f 2 : A 2 → B 2 such that ∀a 1 ∈ A 1 , a 2 ∈ A 2 .(a 1 , a 2 ) ∈ R ⇒ (f 1 (a 1 ), f 2 (a 2 )) ∈ S. Identities and composition are inherited from Set × Set.
Rel n is the obvious generalisation of Rel to n-ary relations.
Pred has a forgetful functor p : Pred → Set, p(P, A) = A, and similarly Rel has a forgetful functor q : Rel → Set × Set, q(R, A 1 , A 2 ) = (A 1 , A 2 ). These functors carry a good deal of structure and are critical to a deeper understanding of the constructions.
Moreover, both Pred and Rel are cartesian closed categories.

Cartesian closed structure
The terminal object in Pred is (1, 1), a singleton set with itself as designated subset. In Rel the terminal object is (1 × 1, 1, 1), the total relation on two singletons. Products are not much more complex. In Pred the product of (P, A) and (Q, B) is (P × Q, A × B). And in Rel the product of (R, A 1 , A 2 ) and (S, The last part of the cartesian closed structure is the function space construction. In Pred, the function So, both Pred and Rel are not only cartesian closed categories, but the forgetful functors p and q preserve all of that structure.

Sums
These properties extend to sums (coproducts). In Pred (P, A) + (Q, B) = (P + Q, A + B) where c ∈ P + Q if and only if c ∈ P or c ∈ Q.
Sums in Rel are constructed similarly.

Fibrations
We start with an interpretation of predicate logic such as p : Pred → Set. This has structure beyond being a homomorphism of cartesian closed categories. It is a fibration equipped with structure that supports an interpretation of predicate logic. See Jacobs [7] for a comprehensive introduction to fibrations and the interpretation of logic in them.
Given a functor p : E → C, and an object A of C, then p −1 (A) forms a subcategory in which the morphisms are those mapping onto the identity of A. This is called the fibre of p over A, written E A . In the context of fibrations, the morphisms of E A are called vertical maps. In the context of logic, the object A represents a context in the sense of a structure giving variable:type bindings, and the fibre over it represents propositions definable in that context ordered by consequence.
For any functor p : E → C, each object of E is an object of a unique fibre. Hence the objects of E are the disjoint union of the objects of the fibres, ob E = A∈ob C E A . But for a general functor p the fibres over distinct objects A and B may be entirely unrelated, even when there is a morphism f : A → B. That is not the case in p : Pred → Set, or in fibrations more generally.
In p : Pred → Set, pulling back along f : A → B induces a functor f * : Pred B → Pred A and rewriting the defining property of the pullback of p along f in terms of the functor p we get the definition of a cartesian map.   (i) f : (P, A) → (Q, B) is cartesian if and only if P = f −1 (Q) (i.e. the implicit commutative square is a pullback) (ii) p is a fibration (iii) the fibre of p over A is the lattice of subsets of A.
It follows easily from the definition that cartesian liftings are unique up to unique isomorphism. Specifically, if F : e 1 → e 2 and F : e 1 → e 2 are both cartesian liftings of f : c 1 = p(e 1 ) = p(e 1 ) → e 2 , then there is a unique map i : e 1 → e 1 such that F = i; F and p(i) is the identity on c 1 . The map i is necessarily an isomorphism.
Moreover, suppose we are given f : A → B and for each object e 2 of E B a chosen cartesian lifting of f , F e : f * (e) → e. Then f * (defined on objects) extends uniquely to a functor f * : E A → E B . This does not mean that if we are given chosen cartesian liftings, then we can use these to derive a functor p * : C op → Cat. We may not be able to choose our cartesian liftings so that the composite of the liftings along morphisms g and f are always the liftings along the composite gf . Instead we get a pseudo-functor, in which the functor p * (gf ) is naturally isomorphic to (p * g) • (p * f ). The components of these natural isomorphisms are vertical, they are maps in the relevant fibres.
However, we will be working mainly with fibrations where the fibres are partial orders. In this case, the only isomorphisms in a fibre are identities, cartesian liftings are thus unique, and we do get a functor.
Note that in any fibration p : E → C, any morphism f : e 1 → e 2 in E factors as a vertical map followed by a cartesian (the cartesian is the lifting of p(f ), and the vertical is obtained by factoring f through the cartesian over the triangle id; p(f ) = p(f )). This factorisation is unique up to isomorphism, so when fibres are partially ordered it is unique. That applies in particular to p : Pred → Set and to q : Rel → Set × Set.
A morphism of fibrations (or cartesian functor) is given by a commutative square in Cat as on the left below in which the topmost functor preserves cartesian maps. Since any Φ over φ preserves vertical maps, a cartesian functor also preserves the factorisation of morphisms into vertical and cartesian. In any square of functors as on the left below, Φ induces functors between the fibres: . Since a morphism of fibrations preserves cartesian maps, those functors are natural with respect to the reindexing functors f * , at least up to isomorphism, as on the right: The exact formal expression of this naturality for general fibrations requires detailed coherence conditions for pseudo-natural transformations, while the formal definition in the fibrational approach is simple. In our case, we are dealing with partial orders and might reasonably adopt this alternative approach.
The interpretation of logical relations requires extending type structure from the base category C to the global category E. In order to do that we need structure defined by adjunctions. Formalisation of that requires 2-cells between functors.
Definition 3.4 The 2-category Cat ↓ has: The 2-category Fib is the subcategory of Cat ↓ in which objects are fibrations, morphisms are cartesian functors and 2-cells are as in Cat ↓ (it is a locally full sub-2-category).
Suppose f : C → C and p : E → C is a fibration. Then a simple check shows that the pullback of p along f in Cat is also a fibration, and that the pullback square is a morphism of fibrations.
Note that if A is an object of C, then the fibre of f * p over A is (isomorphic to) the fibre of p over f (A). A particular example of this is Rel, which is the pullback of Pred along the product map Set × Set → Set.

Rel Pred
We shall be particularly interested in two kinds of fibrations, semantic and type-theoretic/logical. Our paradigmatic example of a semantic fibration is Pred. In a semantic fibration, the underlying category C is a category of (semantic) mathematical objects, such as Set. The fibre of E over an object A of C is (derived from) a class of maps into A in C. In the case of Pred, these are the inclusions of subsets. Reindexing is given by pullback, and hence cartesian maps correspond to pullback squares. If we need to interpret logical formulae, then we use the standard trick in which an n-ary predicate on A 1 , . . . , A n is interpreted as an element of the fibre over A 1 × . . . × A n . In the case of Pred this says that an n-ary predicate on A 1 , . . . , A n is interpreted as a subset of, and hence a unary predicate on A 1 × . . . × A n .
In a logical/type-theoretic fibration, the objects of C consist of contexts, usually a list of variable/type bindings: x 1 : A 1 , . . . , x n : A n . Objects of the fibre over a context consist of types (if modelling type theory) or predicates (if logic) in the given context. An example would be: x : A, y : A, z : B x = y. Morphisms in C are substitutions. So a morphism from y 1 : B 1 , . . . , y m : B m to x 1 : A 1 , . . . , x n : A n is given an n-tuple of terms in context y 1 : B 1 , . . . , y m : B m , y 1 : Reindexing, and hence the cartesian maps of the fibration, corresponds to performing these substitutions in the types or in the predicates. If contexts admit the laws of contraction, weakening and exchange, then the base category has finite products. If (in addition) the type theory itself has finite product types, then the context x 1 : A 1 , . . . , x n : A n can be replaced by x : A 1 × . . . × A n , and so can be taken to consist only of a single type.

Adjunctions
Much type-theoretic structure is defined categorically through adjunctions. This includes products, coproducts and function spaces, though not monadic structure.
The standard definition of an adjunction between a functor F : C → D and a functor G : But this is equivalent to a formulation that allows us to define an adjunction between morphisms in an arbitrary 2-category: This gives us the definition of an adjunction in Cat ↓ and an adjunction in Fib. Unpacking these definitions we see that in both cases an adjunction between amounts to an adjunction in the base φ ψ and an adjunction between the global categories Φ Ψ which live over each other in the appropriate sense. Specifically, this means that an adjunction (Φ, φ) (Ψ, ψ) in Cat ↓ is exactly a map (p, p ) of adjunctions as in Mac Lane [11] IV.7. We will also use a third characterisation of adjunctions. This tells us that if we consider the comma category (F ↓ d), whose objects are morphisms in D F c → d, and whose morphisms are maps f in C, such that F (f ) makes the obvious triangle commute, then : F Gd → d is terminal in (F ↓ d). A converse is also true. Given F , and for each object d of D a choice of terminal object , then there is a unique functor G : D → C such that Gd = c d , F G and is the counit of the adjunction.
A dual result links the other direction of the adjunction and the unit (the adjoint of id : F a → F a): for any g : a → Gb,ĝ, the adjoint of g, is the unique mapĝ : F a → b such that g = η; G(ĝ).

Adjunctions between Fibrations
Each map in a fibration factors as a vertical part (something that lives in a single fibre), followed by a cartesian part (something that represents a straightforward translation between fibres). In this section we reproduce Hermida's result that adjunctions between fibrations factor in a similar way, and extend it slightly to morphisms of categories.

Change of base
The equivalent of a cartesian map in a fibration, is a cartesian functor that arises through change of base. The first result says that an adjunction in the base extends to an adjunction between a fibration and its change of base.
Lemma 5.1 (Hermida,[4,5]) Suppose p : C → A is a fibration, and f g : B → A is an adjunction, then there is a fibred adjunction Proof. Let be the counit of f g and c an object of C. Then defineĝ(c) = (g(c), * c), where : * c → c is a (chosen) cartesian lifting of pc : f gpc → pc. 2 Looking closely at the proof, we have only used the fibration structure to justify the existence of . So the same proof gives a result for arbitrary categories: Corollary 5.2 Suppose q : C → A, and f g : B → A is an adjunction, and for all c ∈ C, the counit of f g, : gf pc → pc has a cartesian lifting to c, then there is an adjunction p * f ĝ : p * C → C over the original adjunction, as in section 4, giving an adjunction in Cat ↓ .
Taking the opposite of all categories we get a corresponding result for left adjoints: Corollary 5.3 Suppose q : C → A, and f : B → A has a left adjoint g. Suppose moreover that the unit of the adjunction has a cocartesian lifting to C, then p * f : p * C → C has a left adjointĝ, and the adjunctionĝ p * f lies over the original adjunction g f .

Factorisation of adjunctions
These results can now be extended to arbitrary adjunctions. We show that under some lifting conditions, an adjunction can be composed of an adjunction over a fixed based (the vertical part) and an adjunction obtained from change of base as in Lemma 5.2 (the cartesian, horizontal part). The following is also a vanilla extension of Hermida, [4,5]. We do not require the functors p and q to be fibrations.
Proposition 5.4 Suppose f : D → C over f : B → A, that f has a right (resp. left) adjoint g, and that both the unit, η and counit of that adjunction have cartesian liftings to arbitrary objects of C and D Let f factor through the pullback f * C as follows: Then the following are equivalent: (i) f has a right (resp. left) adjoint g over the adjunction f g (ii)f has a right (resp. left) adjointg over the identity on B.
To establish the adjunction, suppose β = (β 1 , β 2 ) :f d = (qd, f d) → (b, c) in f * C. We have f β 1 = pβ 2 : f qd = pf d → f b = pc. Using the adjunction in the base, the right adjoint of this is (gf β 1 )η : qd → gf b. But η is natural, so (gf β 1 )η = ηβ 1 . Turning now to the adjunction f g, the right adjoint β : d → gc of β 2 : f d → c lives over ηβ 1 . Sinceη is cartesian over η, there is a uniqueβ : d → η * c =g(b, c), lying over β 1 , such that ηβ = β. This construction is natural in both variables, and hence gives an adjunction lying over the identity adjunction on B as required.
For left adjoint: apply the result to the duals of all categories. 2 This decomposition of adjoints says that right adjoints are obtained in two parts. The first part is a cartesian lifting. In terms of standard predicate structure, this amounts to substituting terms into the predicate given as argument. The second part is an adjunction between two fibrations over the same base. This part depends on the existence of particular logical structure. For example, we will see that conjunction is used to give products, disjunction is used for sums (using the dual result for left adjoints), and implication and first order quantification produce function spaces.

Examples
In this section we look out how the construction above helps define structure on Pred → Set.

Example 5.5 [Products] Product is right adjoint to the diagonal: Set
Set × Set ⊥ ∆ × Consider the pullback of Pred × Pred along ∆: On Pred, ∆ maps a predicate P on set A to the pair of predicates (P, P ) on the pair of sets (A, A). The fibre of ∆ * (Pred × Pred) over the set A is Pred(A) × Pred(A), so ∆ factors through ∆ * (Pred × Pred) by∆, wherẽ ∆ maps P to (P, P ) in the fibre of ∆ * (Pred × Pred) over A. (p × p) * ∆ now maps this to (P, P ) in the fibre of Pred × Pred over A × A. The adjoint of (p × p) * ∆, as per Lemma 5.1, is given by lifting along the counit of the adjunction in the base. That counit is the product of the projections : (a 0 × a 1 , a 0 × a 1 ) → (a 0 , a 1 ): λ(x, y). (π 0 (x), π 1 (y)). Hence, given predicates P on A and Q on B,ĝ maps (P, Q) over (A, B) to (π * 0 P, π * 1 Q) over A × B. Putting this in more logical terms: if a : A P (a) : Pred and b : B Q(b) : Pred, then the result of applyingĝ to this pair of predicates is the pair got by substituting a → π 0 (x) into P (a), and b → π 1 (x) into Q(b): x : A × B (P (π 0 x), Q(π 1 x)) : Pred × Pred.
The point of this operation is to get two predicates on the same type. This is obscured if we write something like: a : A, b : B (P (a), Q(b)) : Pred × Pred.
The adjoint of∆ is ∧, which takes a pair (P 1 , P 2 ) of predicates on A to their intersection, P 1 ∧ P 2 . From a logical perspective, this is conjunction.
Putting this together, we get that the right adjoint to ∆ : Pred → ∆ × ∆ takes a pair of predicates (P, Q) over (A, B) (written as (P (a), Q(b)) to the predicate P (a)∧Q(b) on A×B. This is what we expect. It would be easy to calculate this directly, but the point is to see this as coming from our general framework for adjunctions.

Example 5.6 [Function spaces] For function spaces we have:
Here, P is a predicate on A, and −×P is the functor just calculated, sending a predicate Q on B to Q(b)∧P (a) on B × A. As before, we compute the right adjoint in stages.
Given (Q, B) in Pred(B), the counit in the base is evaluation: (Q, B), the pullback of (Q, B) along ev B . Reading this from a logical perspective, this amounts to a substitution b → f (a) in Q(b). We write the result informally as f : A → B, a : A Q(f (a)) Pred, or more formally as x : Now, the fibre of (− × A) * Pred over a set C is Pred(C × A), and − × P factors through this via − ∧ P . Specifically, if R is a predicate on C, then R ∧ P is R(c) ∧ P (a), a predicate on C × A.
The right adjoint to this,g, takes a predicate S(c, a) to ∀a ∈ A.P (a) → S(c, a). This exists in Pred, but if we are working in a fibration encoding a more general logic, it will be sufficient for that logic to have implication and first-order quantification.
Putting this with the previous adjoint, we get that Q is sent to a predicate on A → B which holds of f iff ∀a ∈ A, P (a) → Q(f (a)), as expected.
Example 5.7 [Coproducts] The theory for coproducts is similar to that for products. The overall structure of the diagram below is identical to that for products, but we have left adjoints rather than right. In particular, ∆,∆ and ∆ * (Pred × Pred), etc are exactly as before. The left adjoint to∆ is disjunction in the fibres. To get a left adjoint to (p × p) * ∆ we use a cocartesian lifting along the unit in the base. The unit in the base is λ (a, b).(inl a, inr b) : (A, B) → (A + B, A + B). The cocartesian lifting of this takes a pair of predicates P on A and Q on B to the predicates case x of {inl a -> P(a); inr b -> False} and case x of {inl a -> False; inr b -> Q(b)}, both predicates on A + B. This is a weak form of existential quantification, significantly weaker than having cocartesian liftings along arbitrary maps. Cocartesian liftings along product projections correspond to standard existential quantification.
Change of base

Results
This section is about the implication of the results in section 5 for situations obtained by change of base. We want to transfer structure from a primary fibration to another obtained from it by pullback along a suitable change of base. The key example is pullback of Pred along Π : Set n → Set, which expresses the fact that an n-ary relation can be regarded as a unary predicate on the product of the underlying sets. First, we observe that pullback preserves cartesianness, even when the categories involved are not fibrations.
Lemma 6.1 Suppose the diagram below is a pullback of categories, and that α : P 0 → P 1 is cartesian in P over F α where α : B 0 → B 1 . Then (α, α) is cartesian in F * P over α.
For our purposes we consider the following situation in the base. We have a commutative square, as below, in which the horizontal arrows F and G have right adjoints F r and G r . It is not necessarily the case that KG r = F r H, though there is a canonical natural transformation between them, the mate of the identity on F K = HG. We will consider an adjunction of categories over F F r , pulled back along H and K. Lemma 6.2 Suppose we are given a commutative square as above, and a category P over A. This produces the cube below in which the front face and the left and right sides are pullbacks. The functor G is obtained as the obvious pullback factorisation. The functors F and G have right adjoints F r and G r .
Suppose is the counit of G G r , and that H has cartesian liftings to P . Then G has a right adjoint over G r .
Proof. Since pullbacks compose, the composite of the front and left faces is also a pullback. Hence so is the composite of the back and right faces. This in turn implies that the back face is a pullback. We now apply lemma 6.1, to show that has cartesian liftings to H * P , and lemma 5.2 to yield the result. Proof. Pullback along K gives a 2-functor K * : Cat/B → Cat/D. K * therefore preserves unit and counit of the adjunction in Cat/B, and the fact that they satisfy the triangle identities. It therefore preserves the adjunction. 2 The following proposition assembles these results together to give an account of changing the base of an adjunction between p and q by puling back along functors H and K as in the diagram below. The input data here consists of the front and bottom faces of the cube ) is a map of adjunctions and HG = F K. G is the map K * Q → H * P obtained by factorisation through pullback.
Proposition 6.4 Given a cube as above, suppose the front face is a map of adjunctions obtained by factorisation through the pullback as in proposition 5.4, and that HG = F K, Suppose further that the counit : GG r → 1 C of G G r has cartesian liftings to H * P (e.g. if H has cartesian liftings to P ). Then G : K * Q → H * p is the left adjoint in an adjunction living over G G r , in which the right adjoint is also constructed by factorisation through the pullback as in 5.4.
Proof. This follows immediately from lemmas 6.2 and 6.3. 2

Examples
Example 6.5 [products] We consider the binary product of n-ary relations.
The front face of the cube is the construction of the binary product of logical predicates that we saw in example 5.5.
Relations are constructed by pullback from Pred along the product functor Π : Set n → Set. This leads us to the bottom face of the cube, which commutes. It is worth spelling this out.
Given an n-tuple of sets: (A i ) i∈{1...n} , taking this along the rear and right hand sides gives (Π × Π)∆(A i ) = (ΠA i , ΠA i ) And taking it along the left and front gives ∆Π(A i ) = (ΠA i , ΠA i ). These are equal, not just canonically isomorphic, and so we can apply the theory developed above immediately to show that the product of n-ary relations is constructed as we expect. There are at least two ways out of this problem. The more principled is to redo the theory so that it will cope with commutation up to natural isomorphism. The technically simpler alternative is to fix the square so that it commutes. Replace the front left vertical edge of the cube by its product with the indiscrete category on ob Set n . The objects of ob Set n × Set are pairs ((B i ), C) where (B i ) is an n-tuple of sets and C is a set. Morphisms ((B i ), C) → (B i ), C ) are functions C → C . This gives us a structure equivalent to the original, and with the same formal properties. But we can tinker with the two functors that form edges of the bottom square. We take the first to be given by (B i ) → ((B i ), ΠB i ), and the second to be given by the natural extension to morphisms of: The square now commutes and our theory applies. But since everything is equivalent to the original, the logical description of the function space still works.
Example 6.7 [coproducts] As before, the story for coproducts is the same as the story for products. It makes use of the same diagrams, but the theory is applied to the opposite categories, yielding left adjoints rather than right. In particular the bottom face of the cube is obtained from the bottom face of the diagram for products by applying op to all of the categories involved. It therefore commutes exactly.

Monads
Monads provide another approach to defining structure. Given a category B representing types, a category P representing a predicate logic for B, and a monad T on B, then there is no fully general method of extending T to a monad on P . But there are ways that work under some circumstances.

Initial cocartesian lifting of a monad
In [8,9,10] such an extension of a monad from the base B to the total category P of a fibration (logic) is called a lifting. Katsumata's method involves embedding into a given continuation or codensity monad, which relies both on closed structure and a somewhat arbitrary parameter. Kammar's method seeks an initial lift for the given monad. We can indeed provide such an initial lift under very minimal conditions on p: Proof. Define the lifted monad (T : E → E, η, µ) as follows: for an object X ∈ E, let η X : X → T X be a cocartesian lifting of η pX : pX → T pX at X. This defines both T and η. Using both unit equations, we have µ • (η • η) = η and since η • η is cocartesian, there is a unique transformation µ : T T → T over µ such that µ • (η • η) = η. Cocartesianness also proves the monad equations for these data, as well as the initiality. 2 In general the lifted monad functor T will not be fibred even when p is a fibration, but it is cofibred. The initial lifting of [8,Theorem 4.8] is a special case of this, under the assumption that the fibres of the functor p are small complete preorders. When p admits cartesian as well as cocartesian liftings, we have for η X : X → T X the adjunction Σ η X η * X : E T X → E X . Under the assumption that the fibres are small complete preorders, the adjoint functor theorem tells us that the left adjoint (= cocartesian lift) is computed as Σ η X (y) = {x ∈ E T X |y ≤ η * X x}. The condition y ≤ η * X x is equivalent, for a faithful functor p, to the existence of a morphism y → x over η X . This latter is precisely the condition the unit respects y in the construction of the initial lifting of T in p. 254 of [8]. We are ignoring here the presence of algebraic operations in T , which we deal with separately in a follow up article.
It is worth noticing that the 'formula' for initial lift of a monad T , T = Σ η (id ) as presented in our theorem, is used in [1] for the interpretation of the 3-modality of their FIX-logic but without reference to it being a monad, let alone an initial lift.

Image factorisation and monads on monics
If P is presented as a subcategory of monics in C (e.g. Pred), then T is already defined on the objects of P , and we can take T (P A) to be defined from T P → T A. If T preserves monics in our subcategory, then this is fine. If not we can hope to use someimage factorisation T P T P T A, as in [3]. This method of lifting has been recast in fibrational language, using cocartesian liftings and comprehension, in place of image factorisation in [2].
We use two particular monads as running examples: the list monad, L, and the continuation monad, C. The list monad is an example of algebraic structure, and the continuation monad is not.

Monads on Set and unary predicates
Let T be a monad on Set. Then T preserves monics.
The continuation monad is defined by CA = (A → K) → K, where K is the set of continuations. C∅ is isomorphic to K and contains the constant functionals. These are included in any type CA. If B ⊆ A, then CB = (B → K) → K, and if j : B → A is the inclusion of B in A, then Cj sends CB to But there is a difference from the point of view of fibrations: L and P are fibred functors, while C is not. From the logical perspective, this means that L works well with substitution, but C does not. Now, for any g : A → K, ((Cf )Θ)g = Θ(g • f ), but (g • f )b = g1 = (g • f )c, so ((Cf )Θ)g = g1. It follows that (Cf )Θ is in CP , and hence Θ is in (Cf ) * (CP ). However, the result of applying Θ to h can clearly depend on ha. Θ is therefore not in C(f * P ). It follows that C is not a fibred functor. 2

Monads on Set and binary relations
There is also a difference when it comes to binary, and more generally, n-ary relations. Suppose Proof. CX = (X → K) → K. Consider the example where K = 2, A = B = 2. Then a simple cardinality argument shows that no map C(A×B) → CA×CB can be monic. |C(A×B)| = 2 2 4 = 2 16 , while |CA×CB| = 2 2 2 * 2 2 2 = 2 8 . 2 Some monads, such as the list monad, do have the property that this map is monic, and hence that they preserve binary relations. It may appear that this is because the list monad is algebraic, but not all algebraic monads have normal forms that can be used like this.  ((a, 0), (a, 1), (b, 1)) maps to m(a, a, b) = b in M A and to m(0, 1, 1) = 0 in M B, but m((a, 0), (a, 1), (b, 1)) is not equal to (b, 0) in M (A × B). This can be shown by exhibiting any algebra with a Mal'cev operation and four elements u, v, w, x such that m(u, v, w) = x.
As a consequence, if M is the monad corresponding to the theory of a free Mal'cev operator, then M 4 does not map injectively into M 2 × M 2.
But factorisation will always work in Set. If M is any monad, then M A × M B has a natural M -algebra structure, and M (A × B) → M A × M B is an M -algebra homomorphism. Just as with standard algebraic varieties, sub-algebras are closed under arbitrary intersecion, and therefore we can take M R to be the intersection of all the sub-algebras containing the image of R under η.