arXiv:2010.09111v3 [math.CT] 2 Feb 2021 opeint nabtayeeetr otie u nter the in but doctrine, elementary arbitrary an to completion doctrine. existential and elementary an again doi: Computer in Structures Mathematical otie hc rs sisacso xseta completi a existential admits of formula instances as arise s which and completion doctrines existential the between connection strong theory. construct homotopy dialectica in of applications framework the in completions these Keywords: xxx) xxx xx accepted xxx; xxx xx revised xxx; xxx xx (Received [email protected] UK Leeds, Leeds, of University [email protected] Italy, VR, Verona Verona, of University Spadetto Matteo and Trotta, Davide applications and principles choice completions, Quantifier ARTICLE opeinpeevsteltiesrcueo h be fa of fibres the of under show structure we lattice First the . preserves of fragment pre completion Coherent are the structures on logical focus other a which study we completion, neeetr n xseta otie hnisexistenti its then doctrine, existential and elementary an Hofstr in instance, For logic. categorical of qua areas involving several completions logical relevant years recent In Introduction 1. rget fagvnter hc aif h ueo Choice, of Rule the satisfy which theory given a t satisfying of theories fragments to theories principl regular constructive extend to strong applied of validity the with together abig nvriyPes2020 Press University Cambridge © n.Ti osrcinpeevstefamn fRglrLo Regular of fragment existen the an preserves providing construction construction This free one. a is which doctrine, h hr sta hs recntutoscryo oerele some on carry constructions free applicati these the that regards is second third the the well; as preserved be to structu out lattice distributive point the following and structure the lattice convey the to prop wish We to us quantifiers. allows universal presentation algebraic completions This quantifier doctrines. the of of knowledge the to contribute We Abstract 10.1017/xxxxx rgnly n ftemi plctoso hsconstructi this of applications main the of one Originally, nTot ( Trotta In oiae yteeitrsigpicpe hc odi eve in hold which principles interesting these by Motivated otie;cmltos hiepicpe;daetc ca dialectica principles; choice completions; doctrines; 2020 rnxnra form normal prenex h rtato nrdcstento of notion the introduces author first the ) 22) 1–00 (2020), rsnain h rsraino h eua structure, Regular the of preservation The presentation. eo h be ne potn yohsswihturn which hypotheses opportune under fibres the of re tegories. ryaayetebhvoro h xseta and existential the of behaviour the analyse erly atcoc principles. choice vant n,i atclrt h ilciaconstruction; dialectica the to particular in ons, eRl fCoc,o ocaatrs those characterise to or Choice, of Rule he :tefis sta hs opein preserve completions these that is first the s: ( a lcompletion al n hi plctosb sn h language the using by applications their and s ugssta hscntuto a be can construction this that suggests es, nstsyteRl fCoc n every and Choice of Rule the satisfy on tfir aebe xesvl tde in studied extensively been have ntifiers cn okTot n aet ( Maietti and Trotta work ecent 2010 m hiepicpe spoie,e.g. provided, is principles choice ome o,wiei ry( Frey in while ion, ildcrn trigfo primary a from starting doctrine tial evdb hsfe opein with completion, free this by served nwst xedtento fexact of notion the extend to was on ie doctrine given xseta completion existential i,ie if i.e. gic, e rtaadMiti( Maietti and Trotta see h uhrsosapiain of applications shows author the ) ydcrn rsn sexistential as arising doctrine ry hc yohssteexistential the hypotheses which P ex P : : C C P 2019 op op : C op r provided are ) faprimary a of 2020 / / InfSL InfSL 2020 ). / Lat ,a ), is is , 2 LaTeX Supplement

where Lat is the category of lattices. Here the crucial assumption is the existence of left-adjoints for the family of reindexings along coproduct injections. Moreover, requiring the objects of C to be inhabited, we get the existential completion of P to satisfy this property as well. Then we show that the distributivity of meets over joins in the fibres is preserved by the exis- tential completion as well, and this preservation depends on the assumption that the family of left-adjoints to reindexings along coproduct injections satisfies the Frobenius Reciprocity. These results allow to apply the existential completion to extend, for example, theories whose predicative part is written in the fragment of Coherent Logic or, more generally, in the fragment of Geometric Logic. A by-product of our previous analysis regards the notion of universal completion, which can be presented as the dual counterpart of the existential completion. In detail, observing that the universal completion Pun of a doctrine is nothing but the doctrine (−)op((−)opP)ex, where (−)op : Pos / Pos denotes the functor which inverts the order of a poset, it is the case that all our results regarding the preservation properties of the existential completion dualise in the setting of the universal completion. For instance, we automatically get when it is the case the universal completion preserves the lattice structure of the fibres and thier distributivity. Moreover, since the existential completion satisfies the Rule of Choice, we show that the universal comple- tion of a doctrine satisfies a property which we call Counterexample Property, which corresponds to saying that if ∀xψ(x) ⊢ ⊥ then there exists a term t such that ψ(t) ⊢ ⊥. This term t repre- sents the counterexample. For sake of readability and thanks to the notable symmetry between these completions, we present any given result regarding the universal completion right after the corresponding one for the existential completion. Finally we study how these constructions interact and their applications. Whenever the base category of a given universal doctrine is also cartesian closed, it is the case that its existentialcom- pletion preserves the universal structure, i.e. is universal as well. In other words by sequentially applying the universal and the existential completions to a given doctrine P: C op / Lat , we get a doctrine (Pun)ex : C op / Lat which is both existential and universal. Moreover it validates a form of choice principle called AC by Troelstra in G¨odel et al. (1986): ∀x∃yα(x, y) → ∃ f ∀xα(x, fx). An relevant application of our study about preservations regards the dialectica construction, see de Paiva (1991); Hyland (2002). As pointed out in Hofstra (2010) in the framework of fibra- tion theory, the interaction of constructions which freely add quantifiers plays a crucial rule in the abstract presentation of the dialectica interpretation G¨odel (1958), in particular in the construction of the dialectica monad. In Hofstra (2010) the author shows that this monad can be decomposed as first a simple product completion, followed by simple co-product completion. The original pre- sentation of the dialectica construction has always made it difficult to analyse the properties of the dialectica categories. This recent alternative characterisation in terms of quantifier completions, suggests that several results of preservation of these constructions might have a crucial role in spotting categorical features of diaelctica categories. For instance, our results yield a proof that the poset reflection of the dialectica category Dial(P) associated to a doctrine P: C op / Lat is a lattice, as well as a sufficient condition over a given doctrine that makes the poset reflection of the corresponding dialectica category into a distributive lattice. Such results give grounds for hope in further applications of this deep relation between the dialectica construction and the quantifier additions.

Synopsis. In Section 2 we recall definitions about universal and existential doctrines, and we fix the notation. In Section 3 we recall from Trotta (2020) the existential completion, we introduce the universal one, and we prove a form a duality between the two notions. In Section 4 we display a set of hypotheses under which the existential and universal completions preserve the lattice Mathematical Structures in Computer Science 3

structure of the fibres of a given doctrine. In Section 5 we show that the same hypotheses, together with the additional request regarding the Frobenius Reciprocity, also allow the preservation of the distributivity in the fibres. In Section 6 we present the interaction between the two constructions and the applications. In Section 7 we show which choice principles arise in doctrines which are instances of free quantifier constructions. Conclusions and future works are treated in Section 8.

2. Brief recap on doctrines The notion of hyperdoctrine was introduced by F.W. Lawvere in a series of seminal papers Lawvere (1969, 1970), and in the following years this notion has been revisited and generalised in several ways, see Maietti and Rosolini (2013b,a,c). In this work we start by considering a more general notion, which we call pos-doctrine. We specialise this notion during the next sections.

Definition 1. A pos-doctrine is a functor P: C op / Pos , where C is a category with finite products, and Pos is the category of posets.

We think of the base category C of a pos-doctrine as the category of types or contexts and, for every object A ∈ C , we have a poset P(A) = (P(A), ⊢) of predicates on A.

Examples 2. Let C be a category with finite limits. The functor: op SubC : C / Pos assigning to an object A in C the poset SubC (A) of subobjects of A and such that for an arrow f B / A the morphism SubC ( f ): SubC (A) / SubC (B) is given by pulling a subobject back along f , is a pos-doctrine.

Examples 3. Consider the set-theoretic doctrine S: Setop / Pos . In this case Set is the category of sets and functions and, for every set A, S(A) is the poset category of subsets of the set −1 A together with the inclusions. A functor S f : S(B) / S(A) acts as the inverse image f U on a subset U of B.

Examples 4. Let T be a theory in a first order language L . We define a pos-doctrine: op LT : CT / Pos

where CT is the category of contexts, i.e. of lists of variables and term substitutions:

• objects of CT are finite lists of variables~x := (x1,..., xn), and we include the empty list (); • a morphism from (x1,..., xn) into (y1,..., ym) is a substitution:

[t1/y1,..., tm/ym]

where the terms ti are built in L on the variables x1,..., xn; • the composition of two morphisms [~t/~y]: ~x / ~y and [~s/~z]: ~y /~z is given by substitution.

op The functor LT : CT / InfSL sends a list (x1,..., xn) to the set:

LT(x1,..., xn) 4 LaTeX Supplement

of all well-formed formulas in the context (x1,..., xn). We say that ψ ≤ φ, where φ, ψ ∈ LT(x1,..., xn), if ψ ⊢T φ, and we consider its poset reflection. Given a morphism:

[t1/y1,..., tm/ym]: (x1,..., xn) / (y1,..., ym) C of T , the functor LT[~t/~y] acts as the substitution LT[~t/~y](ψ(y1,..., ym)) = ψ[~t/~y].

op Definition 5. A pos-doctrine P: C / Pos is existential if, for every A1 and A2 in C , for any projection pri : A1 × A2 / Ai ,i = 1, 2, the functor:

Ppri : P(Ai) / P(A1 × A2)

has a left adjoint prE i , and these satisfy the Beck-Chevalley condition: for any pullback diagram:

pr′ X′ / A′

f ′ f   X pr / A

with pr and pr′ projections, for any β in P(X) the canonical arrow:

prE ′ Pf ′ (β) ≤ Pf prE (β) is an isomorphism.

Examples 6. The pos-doctrine Sub: C op / Pos presented in Example 2 is existential if and only if the base category C is regular. See Maietti and Rosolini (2013b).

op Definition 7. A pos-doctrine P: C / Pos is universal if, for every A1 and A2 in C , for any projection pri : A1 × A2 / Ai ,i = 1, 2, the functor

Ppri : P(Ai) / P(A1 × A2) A

has a right adjoint pri , and these satisfy the Beck-Chevalley condition.

op Examples 8. The pos-doctrine LT : CT / Pos as defined in Example 4 for a first order theory T , is universal and existential. The right adjoints are computed by quantifying universally the variables that are not involved in the substitution given by the projection, and similarly left adjoints are computed by quantifying existentially the variables which are not involved in the substitution given by the projection.

Examples 9. The pos-doctrine S: Setop / Pos presented in Example 3 is existential and A

universal: on a subset U of A × B, for a projection prA : A × B / A , the right adjoint prA is A −1 given by the assignment prA (U) := {a ∈ A | prA (a) ⊂ U}, and the left adjoint prE A is given by −1 prE A (U) := {a ∈ A |∃b ∈ A × B(b ∈ prA (a) ∩ U)}.

The category of pos-doctrines SD is a 2-category, where: Mathematical Structures in Computer Science 5

• a 1-cell is a pair (F, b) C op ❖❖❖ ❖❖❖ P ❖❖❖ ❖❖❖ ❖' Fop b Pos ♦♦7 ♦♦♦ ♦♦ ♦ ♦♦ R  ♦♦♦ Dop

such that F : C / D is a finite product preserving functor and:

b: P / R ◦ Fop is a natural transformation. • a 2-cell is a natural transformation θ : F / G such that for every A in C and every α in PA, we have:

bA(α) ≤ RθA (cA(α)).

We denote as ExD the 2-full subcategory of SD whose elements are existential pos-doctrines, and whose 1-cells are those 1-cells of SD which preserve the existential structure. Similarly, we denote by UnD the 2-full subcategory of SD whose elements are universal pos-doctrines, and whose 1-cells are those 1-cells of SD which preserve the universal structure.

3. Quantifiers and completions In this section we recall from Trotta (2020) the existential completion and we show how this construction can be dualised to obtain a free construction which adds right adjoints along the projections, called universal completion.

Existential completion. Let P: C op / Pos be a pos-doctrine. The existential completion Pex : C op / Pos of P is a pos-doctrine such that, for every object A of C , the poset Pex(A) is defined as follows:

• objects: triples (A, B, α), where A and B are objects of C and α ∈ P(A × B). • order: (A, B, α) ≤ (A, C, β) if there exists an arrow f : A × B / C of C such that: P α ≤ hprA, f i(β)

where prA : A × B / A is the projection on A.

ex ex ex ex The functor Pf : P (C) / P (A) sends an object (C, D, γ) of P (C) to the object ex (A, D, Pf ×1D (γ)) of P (A), where prA, prD are the projections from A × D.

The logical is that an element (A, B, α) of the fibre Pex(A) represents a predicate [a : A, b : B] | ∃b : Bφ(a, b). Recall from Trotta (2020) that the previous construction provides a free completion, i.e. it extends to a 2-functor which is left adjoint to the forgetful functor. We summarise the main prop- erties of the existential completion in the following and we refer to Trotta (2020) for all details. Notice that this construction was originally presented for pos-doctrines factoring through 6 LaTeX Supplement the inclusion functor InfSL ֒→ Pos. However, as observed in Trotta (2020) itself, this notion works for general pos-doctrines as well.

Theorem 10. The pos-doctrine Pex is existential, and the 2-monad (Tex, µex, ηex) on SD is lax-idempotent. Moreover we have the isomorphism ExD =∼ Tex-Alg between the 2-category of existential pos-doctrines, and that of strict algebras for Tex.

Remark 11 (Prenex normal form). Observe that in the existential completion of a pos-doctrine P, every object (A, B, α) ∈ Pex(A) equals: (A, B, α) = E ex ηex (α). prA A×B

By dualizing the previous construction, we define the universal completion of a pos-doctrine. Similarly to the existential case, the intuition is that an element (A, B, α) of the fibre Pun(A) of the new doctrine that we are going to define represents a predicate [a : A, b : B] | ∀b : Bφ(a, b).

Universal completion. Let P: C op / Pos be a pos-doctrine. The universal completion Pun : C op / Pos of P is a pos-doctrine such that, for every object A of C , the poset Pun(A) is defined as follows:

• objects: triples (A, B, α), where A and B are objects of C and α ∈ P(A × B). • order: (A, B, α) ≤ (A, C, β) if there exists an arrow g: A × C / B of C such that: P α β hprA,gi( ) ≤

where prA : A × C / A is the projection on A.

C un un un Whenever f : A / C is an arrow of , the functor Pf : P (C) / P (A) is defined as for the existential completion.

Theorem 12. The pos-doctrine Pun is universal.

Proof. Part I. Existence of right adjoints. Let P: C op / Pos be a pos-doctrine and let for every A1 and A2 be objects of C . The assignment (A1 × A2, B, β) 7→ (A1, A2 × B, β) defines

a functor unA : Pun(A × A ) / Pun(A ) since, whenever g: A × A × C / B is an pr1 1 2 1 1 2 arrow witnessing that:

(A1 × A2, B, β) ≤ (A1 × A2, C, γ) in P A A , then the arrow pr g : A A C A B witnesses that A A ( 1 × 2) h A2 , i 1 × 2 × / 2 × ( 1, 2 ×

B, β) ≤ (A , A × C, γ) in P(A ). Let us verify that unA is right adjoint to Pun . Let (A , B, β) 1 2 1 pr1 pr1 1 un un be an object of P (A1) and let (A1 × A2, C, γ) be an object of P (A1 × A2). If Pun (A , B, β) = (A × A , B, P (β)) ≤ (A × A , C, γ) pr1 1 1 2 pr1 ×1B 1 2

then there is an arrow g: A1 × A2 × C / B such that:

Phpr ,gi(β) = P(pr ×1 )hpr ,gi(β) = Phpr ,gi(Ppr ×1B (β)) ≤ γ. A1 1 B A1×A2 A1×A2 1

This means that (A , B, β) ≤ (A , A × C, γ) = unA (A × A , C, γ). 1 1 2 pr1 1 2 Mathematical Structures in Computer Science 7

Viceversa, if the latter holds, that is, there is an arrow h: A1 × A2 × C / B such that Phpr ,hi(β) ≤ γ, then: A1

Phpr ,gi(Ppr ×1B (γ)) = Phpr ,hi(β) ≤ γ A1×A2 1 A1 which implies that Pun (A , B, β) ≤ (A × A , C, γ). pr1 1 1 2 Part II. Beck-Chevalley condition. Let us consider the pullback square of a projection along a given arrow f of C , which is of the form:

prB B × C / B

f ×1C f   A × C / A. prA

Then the corresponding: unA prA Pun(A × C) / Pun(A)

Pun Pun f ×1C f

un  un P (B × C) unA / P (B) prB commutes, since it is the case that:

Pun unA (A × C, D, δ) = Pun(A, C × D, δ) = (B, C × D, P (δ)) f prA f ( f ×1C)×1D

and that: A

unA Pun (A × C, D, δ) = un (B × C, D, P (δ)) prB f ×1C prB ( f ×1C)×1D

= (B, C × D, P( f ×1C)×1D (δ)) whenever (A × C, D, δ) is an object of Pun(A × C).

Notation. We denote by (−)op : Pos / Pos the functor which inverts the order of a poset. op In other words, if (A, ≤A) is a poset, then (A, ≤A) := (A, ≤Aop ) is the poset whose objects are the ones of A and a ≤Aop b if and only if b ≤A a.

Proposition 13. Whenever P: C op / Pos is a pos-doctrine, it is the case that: Pun =∼ (−)op((−)opP)ex.

Proof. Let A be an object of C . The categories: ((−)op((−)opP)ex)(A) = (((−)opP)exA)op and ((−)opP)exA share the object class. Hence an object of the former is a triple: (A, B, β ∈ ((−)opP))(A × B) = P(A × B)op), that is, a triple of the form (A, B, β ∈ P(A × B)), since P(A × B) and P(A × B)op share the object un op op ex un class. This is nothing but an object of P (A). As the functors ((−) ((−) P) ) f and Pf both C send such an objectto (C, B, Pf ×1B (β)) (being f : C / A an arrow of ), we are left to verify that the morphism classes (that is, the ordering relations) of (((−)opP)exA)op and Pun(A) coincide. 8 LaTeX Supplement

Let (A, D, δ) be another object of the common object class and let us assume that (A, B, β) ≤ (A, D, δ) in (((−)opP)exA)op, which means that (A, D, δ) ≤ (A, B, β) in ((−)opP)exA. This corresponds to the existence of an arrow g: A × D / B such that:

δ opP β P op β P β ≤ ((−) )hprA,gi( ) = ( hprA,gi) ( ) = hprA,gi( ) in P A D op, that is, P β δ in P A D . This condition is nothing but the existence of ( × ) hprA,gi( ) ≤ ( × ) the arrow (A, B, β) ≤ (A, D, δ) in Pun(A).

Notice that by to Proposition 13, one can prove the analogous result of Theorem 10.

Theorem 14. The universal completion extends to a 2-adjunction, and the corresponding 2- monad (Tun, µun, ηun) on SD is colax-idempotent. Moreover we have the isomorphism UnD =∼ Tun-Alg between the 2-category of universal pos-doctrines, and that of strict algebras for Tun.

Remark 15 (Prenex normal form). Observe that as for the existential completion, in the universal completion of a doctrine we have that every formula admits a prenex normal form.

Remark 16. Note that, as Trotta (2020), the universal and existential completions can be gen- eralised for an arbitrary class Λ of morphisms closed under pullbacks, compositions and which contains identities, i.e. they can be used to freely add right (and left) adjoints along the morphisms of the class Λ.

Remark 17. Recall from Hofstra (2010) that the dialectica construction de Paiva (1991); Hyland (2002) decomposes into two steps from a modern categorical perspective, following the quantifier pattern of the original translation. The dialectica category Dial(p) associated to a fibration p, hence in particular to an indexed category (see Jacobs (1999)), is obtained by first applying the monad which freely adds simple universal quantification and then applying the monad which freely adds simple existential quantification. Analogously, by applying the corresponding additions of quantifiers to a given pos-doctrine P: C op / Pos one gets the poset reflection of the dialectica category Dial(P) to coincide with the category (Pun)ex(1).

4. Preservation of logical structures When a new free completionis introduced,it is naturalto study and to understand which structures are preserved by this construction. This section is completely devoted to this analysis of the two quantifier completions presented in the previoussection. Note that, by Proposition 13, we can easily translate a result of preservation for the existential completion in its dual version for the universal completion. This argument will be heavily used along our presentation. We start by recalling a first result in this direction provided in Trotta (2020).

Proposition 18. Let P: C op / Pos be a pos-doctrine such that every fibre P(A) has finite meets and such that every re-indexing functor Pf preserves them. Then the existential doctrine ex C op ex ex P : / Pos has finite meets in every fibre P (A) and the functors Pf preserve them.

By Proposition 13 the dual result holds for the universal completion. Mathematical Structures in Computer Science 9

Proposition 19. Let P: C op / Pos be a pos-doctrine such that every fibre P(A) has finite joins and such that every re-indexing functor Pf preserves them. Then the universal doctrine un C op un un P : / Pos has finite joins in every fibre P (A) and the functors Pf preserve them.

The two previous propositions reflect the logical distributive property of the quantifiers over disjunctions and conjunctions. Observe that, under the hypotheses of Proposition 18, it is the case ex that the family of functors prE , where pr is a projection, satisfies the Frobenius reciprocity (see Trotta (2020)). The dual property holds for the universal completion. Now we show that, under the right hypotheses,the existential completion preserves finite joins, and then, dually, that the universal completion preserves finite meets. Recall from Carboni et al. (1993) that a category with finite products and finite sums is said to be distributive if the canonical arrow: θ : (A × B) + (A × C) / A × (B + C)

′ hprA, jC prCi is an isomorphism. The canonical arrow is θ := ′ , i.e. it is the unique arrow such that hprA, jB prBi the diagram:  

jA×C jA×B A × C / (A × C) + (A × B) o A × B ❑❑❑ s ❑❑ sss ❑❑❑ ss ❑❑ sss ❑❑ θ ss ′ ❑❑ ss ′ hprA, jC prCi ❑❑❑ ss hprA, jB prBi ❑❑ sss ❑%  yss A × (B + C) commutes, where j′ are the injections in B + C. To simplify the notation and the readability of the statements we introduce the following definition.

Definition 20. A lat-doctrine isafunctor P: C op / Lat , where C is a distributive category and Lat is the category of lattices, i.e. finitely complete and finitely cocomplete posets, and finite sup&inf-preserving maps, i.e. finite limit and finite colimit preserving functors.

Theorem 21. Let P: C op / Lat be a lat-doctrine such that the images through P of the

injections jA : A / A + B have left adjoints E jA which satisfy the Beck-Chevalley condition for pullbacks (when they exist) of injections which are injections themselves. Then the following properties hold.

(1) The pos-doctrine Pex is a lat-doctrine. (2) Suppose that there is an arrow c: 1 / C for every non-initial object C of C (C has points). Then the images through Pex of the injections:

jA : A / A + B have left adjoints E ex which satisfy the Beck-Chevalley condition for pullbacks (when they jA exist) of injections which are injections themselves.

(3) Suppose that C has points and that the images through P of the injections j have right A A

adjoints jA which satisfy the Beck-Chevalley condition for pullbacks (when they exist) of injections which are injections themselves. Then the images through Pex of the injections

j have right adjoints exA which satisfy the Beck-Chevalley condition for pullbacks (when A jA they exist) of injections which are injections themselves. 10 LaTeX Supplement

Proof. (1) Let A be an object of C and let us verify that Pex(A) has finite coproducts (Part I). Moreover, let us verify that finite coproducts are preserved by the images through Pex of any arrow of C of target A (Part II). ex ex Part I. Finite coproducts in P (A). It is the case that (A, 0, ⊥A×O) is initial in P (A) whenever 0 is initial in C . Moreover, whenever (A, B, α) and (A, C, β) are two elements of Pex(A), it is the case that:

(A, B, α) ∨ (A, C, β) := (A, B + C, Pθ −1 ( E jA×B (α) ∨ E jA×C (β))) is their coproduct. In order to verify this, at first we prove that (A, B, α) ≤ ((A, B +

C, E jA×B (α) ∨ E jA×C (β)). Observe that the diagram: A × B ♥♥ jA×B ♥♥ ♥♥♥ ♥♥♥ w♥♥ (A × B) + (A × C) prA ♠♠ θ ♠♠♠ ♠♠♠ ♠♠♠ v♠♠  A B C A × ( + ) ′ / prA commutes by definition of θ. Moreover it is the case that:

Pθ jA×B (Pθ −1 ( E jA×B α ∨ E jA×C β)) = PjA×B ( E jA×B α) ∨ PjA×B ( E jA×C β) ≥ α

since α ≤ PjA×B E jA×B (α). Similarly one can prove that (A, C, β) ≤ (A, B, α) ∨ (A, C, β). Now assume that (A, B, α) ≤ (A, D, γ) and (A, C, β) ≤ (A, D, γ), i.e. that there exist f A B D f A C D P P 1 : × / and 2 : × / such that α ≤ hprA, f1i(γ) and β ≤ hprA, f2i. By the universal property of coproducts, the diagram:

jA×C jA×B A × C❏ / (A × C) + (A × B) o A × B ❏❏ tt ❏❏ tt ❏❏ tt ❏❏ tt ❏❏ pr f tt ❏❏ h A, 2i tt ❏ hpr , f i t hprA, f2i ❏❏  A 1  tt hprA, f1i ❏❏ tt ❏❏ tt ❏❏ tt ❏%  ytt A × D

commutes. In order to simplify the notation, let c := hprA, f2i . First notice that the following hprA, f1i equality holds again by the universal property of coproduct s: ′ prA c = prA θ ′ where prA : A × D / A and prA : A × (B + C) / A . Hence the diagram:

A × (B + C) ♠♠ θ −1 ♠♠♠ ♠♠♠ ♠♠♠ v♠♠ (A × B) + (A × C) prA ♥♥♥ c♥♥♥ ♥♥♥ w♥♥  A D A × ′ / prA Mathematical Structures in Computer Science 11

commutes. Now by our assumption, and since hprA, f1i = cjA×B, it is the case that α ≤ PjA×B (Pc(γ)). Since E jA×B ⊣ PjA×B , it holds that E jA×B (α) ≤ Pc(γ) and hence:

Pθ −1 ( E jA×B (α)) ≤ Pθ −1 Pc(γ).

Similarly one gets that Pθ −1 ( E jA×C (β)) ≤ Pθ −1 Pc(γ) and therefore we can conclude that:

Pθ −1 ( E jA×B (α) ∨ E jA×C (β)) ≤ Pθ −1 Pc(γ) that is, (A, B, α) ∨ (A, C, β) ≤ (A, D, γ).

Part II. Preservation of finite coproducts. Let f : D / A be an arrow of C . Then it is ex the case that Pf (A, 0, ⊥A×0) = (D, 0, ⊥D×0). Moreover, one might observe that:

Pf ×1B+C Pθ −1 ( E jA×B α ∧ E jA×C β) = Pθ −1 ( E jD×B (Pf ×1B α) ∧ E jD×C (Pf ×1C β)) by naturality of the class of isomorphisms:

θ : X × B + X × C / X × (B + C) , where X is any object of C , and by the Beck-Chevalleyproperty of the class of left adjoints to the injectionsof coproducts. Observe indeed that the left-hand square of the commutative diagram:

jD×B θ πD D × B / (D × B) + (D × C) / D × (B + C) / D

f ×1B ( f ×1B)+( f ×1C) f ×1B+C f     A × B / (A × B) + (A × C) / A × (B + C) / A jA×B θ πA is a pullback, since the right-hand square and the outer one (whose horizontal arrows are projections from D × B and from A × B) are pullbacks (and θ are isos). The same holds ex with with jD×C and jA×C instead of jD×B and jA×B respectively. This implies that Pf preserves binary joins. (2) Part I. Existence of left adjoints. Let (A + B, C, α) ∈ Pex(A + B) and let (A, D, δ) ∈ Pex(A). ex We define E A D δ to be theobject A B D P −1 E δ being θ the isomorphism jA ( , , ) ( + , , θ jA×D ( )) (A × D) + (B × D) → (A + B) × D and jA×D the injection A × D → (A × D) + (B × D). Then the conditions E ex (A, D, δ) ≤ (A + B, C, α) and (A, D, δ) ≤ Pex(A + B, C, α) are jA jA equivalent to the conditions:

thereis g: (A + B) × D / C

such that P −1 E δ P α (1) θ jA×D ( ) ≤ hprA+B,gi( ) and: thereis h: A × D / C such that δ P P α (2) ≤ hprA,hi jA×1C ( )

respectively. Being θ an isomorphism and by left adjointness of E jA×D , (1) is equivalent to the existence of an arrow g: A B D C such that δ P P α . ( + ) × / ≤ jA×D hprA+B θ,gθi( ) If (1) holds for some g, then let h := gθ jA×D. Viceversa, if (2) holds for some h, then let g :=[h, c!]θ −1, where ! is the unique arrow B × D → 1 (intuitively, we do not take care of the “C-values” that g assumes over “B × D-part of its domain”, hence we might define its “restriction” to B × D as the arrow c!, which is the c-constant map B × D → C). In both 12 LaTeX Supplement

cases one might verify that:

hprA+B θ, gθi jA×D = ( jA × 1C)hprA, hi which implies that (1)and(2) are equivalent. Hence E ex is left adjoint to Pex and one might jA jA as usual verify it to satisfy the Beck-Chevalley condition. Part II. Beck Chevalley condition. Let us assume that the square:

jC C / C + D

f g   A / A + B jA is a pullback and let (A, E, ε) be an object of Pex(A). We are left to prove ex ex ex ex that E P A E ε C D E P −1 E P ε and P E A E ε jC f ( , , ) = ( + , , θ jC×E f ×1E ) g jA ( , , ) =

(C + D, E, Pg×1E Pϕ−1 E jA×E ε) are equal, where θ and ϕ are the isomorphisms C × E + D × E → (C + D) × E and A × E + B × E → (A + B) × E respectively. Let us consider the following commutative diagram:

jC×E θ −1 prC+D C × E / C × E + D × E o (C + D) × E / C + D

−1 f ×1E ϕ (g×1E )θ g×1E g     A × E / A × E + B × E o (A + B) × E pr / A + B jA×E ϕ−1 A+B

which is a pullback, since its horizontal arrow A × E → A + B equals the arrow jA prA, the arrow f × 1E is the pullback of f along prA and f is the pullback of g along jA (hence f × 1E is indeed the pullback of g along jA prA). As the right-hand square is pullback, we deduce that the left-hand square is a pullback as well. Therefore, by Beck Chevalley condition on E , it is the case that:

P −1 P ε P −1 P −1 ε θ E jC×E f ×1E = θ ϕ (g×1E )θ E jA×E

= Pg×1E Pϕ−1 E jA×E ε and we are done.

(3) Let (A + B, C, α) ∈ Pex(A + B) and let (A, D, δ) ∈ Pex(A). Then we define exA (A, D, δ) A jA to be the object (A + B, D, Pθ −1 jA×D (δ)) being θ the isomorphism (A × D) + (B ×

D) → (A + B) × D and j the injection A × D → (A × D) + (B × D). Then the condi- A A×D tions (A + B, C, α) ≤ ex(A, D, δ) and Pex(A + B, C, α) ≤ (A, D, δ) are equivalent to the jA jA conditions: thereis g: (A + B) × C / D

such that α P P −1 A δ (3) ≤ hprA+B,gi θ jA×D ( ) and: thereis h: A × C / D such that P α P δ (4) jA×1C ( ) ≤ hprA,hi( ) respectively. Observe that if (3) holds, then:

Pj (α) ≤ P −1 A j (δ) A×1C θ hprA+B,gi jA×1C A×D Mathematical Structures in Computer Science 13 and it is the case that: −1 −1 θ hprA+B, gi jA × 1C = θ h jA prA, g( jA × 1C)i = jA×DhprA, g( jA × 1C)i because in our case θ −1 : (A + B) × D / (A × D) + (B × D) and

θ jA×D = h jA prA, prDi. A A

Moreover PjA×D jA×D ≤ id since PjA×B ⊣ jA×D , and then:

Pj (α) ≤ P −1 A j (δ) A×1C θ hprA+B,gi jA×1C A×D

P P A δ = hprA,g( jA×1C)i jA×D jA×D ( ) P δ ≤ hprA,g( jA×1C)i( ). Then we can set:

h := g( jA × 1C): A × C / D P P so that jA×1C (α) ≤ hprA,hi(δ) as required in (4). Suppose that (4) holds. First notice that jA × 1C = θ jA×C, hence:

α P −1 A P δ ≤ θ jA×C hprA,hi( ). Now we define g: (A + B) × C / D as the following composition of arrows:

h θ −1 idA×C +! d (A + B) × C / (A × C) + (C × B) / (A × C) + 1 / D where ! is the terminal arrow, and h is the coproduct of h: A × C / D and the d constant d : 1 / D . Let us verify that the commutative diagram:

jA×C A × C / (A × C) + (B × C)

−1 hprA,hi θ hprA+B,giθ

  A × D / (A × D) + (B × D). jA×D is a pullback, in order to use the Beck-Chevalley condition. Consider the following diagram:

E ha1,a2i

ha3,a2i

! jA×C θ ' A × C / (A × C) + (B × C) / (A + B) × C

ha3,a4i

hprA,hi hprA+B,gi $   A × D / (A × D) + (B × D) / (A + B) × D. jA×D θ and assume that hprA+B, giha1, a2i = jA×Dθha3, a4i. By the equality θ jA×D = h jA prA, prDi, the following ones hold: 14 LaTeX Supplement

– a1 = jAa3; – gha1, a2i = a4. First we prove that the choice of ha3, a2i makes the left triangle commutes:

ha3, a4i = ha3, hha3, a2ii.

Then we need to show that hha3, a2i = a4 = gha1, a2i = gh jAa3, a2i. Observe that h jAa3, a2i = ( jA × 1C)ha3, a2i = θ jA×Cha3, a2i, and then, by definition of g, it is the case that: h −1 gha1, a2i = ( (idA×C +!)θ )(θ jA×Cha3, a2i) = hha3, a2i d where the last equality holds as the composition:

jA×C idA×C +! A × C / (A × C) + (B × C) / (A × C) + 1

jA×C equals the arrow A × C / (A × C) + 1 and, by the universal property of the coproduct, it is the case that h j = h. Hence the left triangle commutes. d A×C Now we consider the top triangle.  This commutes because:

θ jA×Cha3, a2i = h jA prA, prCiha3, a2i = h jAa3, a2i

which is equal to ha1, a2i by the hypothesis a1 = jAa3. This concludes that the previous commutative square is indeed a pullback, and then, since θ is invertible, the first square is a pullback. Therefore, by the Beck-Chevalley condition, we get that:

α P P −1 A δ ≤ hprA+B,gi θ jA×D ( ).

Hence Pex ⊣ exA , and one can directly check that these satisfy the Beck-Chevalley jA jA condition. The proof is analogous to Part II of 2.

Remark 22 (Considerations about the hypotheses of Theorem 21). In the general hypotheses of our statement, the class of the injections of C is not necessarily closed under pullback. However, here we require the Beck-Chevalley condition for left/right adjoints to the pullback functor along the injections to hold just for existing pullbacks of injections which are injections as well. We do so for sake of generality: this hypothesis is clearly satisfied in any concrete framework where injections are fully stable under pullback and the Beck-Chevalley condition holds w.r.t. them (e.g. extensive categories). From now on, whenever we deal with a class C of arrows of C which are not necessarily stable under pullback and a family of functors indexed by C which are respectively left (or right) adjoint to the images through P of the arrows of C, we commit the following abuse of notation: instead of talking about the Beck-Chevalley condition for pullbacks (when they exist) of arrows of C which are in C themselves, we simply write the Beck-Chevalley condition. Secondly, we underline the importance of the request that C has points in the statement of Theorem 21 in order to prove that the functor E ex is actually left adjoint to Pex. If (A + jA jA B C α Pex A B and A D δ Pex A then the conditions E ex A D δ A B C α , , ) ∈ ( + ) ( , , ) ∈ ( ) jA ( , , ) ≤ ( + , , ) and (A, D, δ) ≤ Pex(A + B, C, α) (that we want to be equivalent) are witnessed by some arrows: jA g: (A + B) × D / C and h: A × D / C respectively, which satisfy the usual inequalities. If the former condition is witnessed by an arrow g, then one verifies that its restriction to A × D witnesses the latter. However, if an arrow h wit- nesses the latter condition, then, in order to get an arrow g witnessing the former, we need to Mathematical Structures in Computer Science 15 arbitrarily expand it to the full domain (A × D) + (B × D). Here is precisely where we need the

existence of constant living in D, when D is non-initial. The same consideration holds for exA . jA

Remark 23. The way we define the binary join of two objects in a fiber of the existential com- pletion of a given doctrine P: C op / Lat generalises to arbitrary joins, assuming that these exist in the fibres of P and that C has arbitrary products.

op Examples 24. Let us consider the subobject lat-doctrine SubC : C / Lat over a finitely complete category C with disjoint coproducts which are stable under pullback. Observe that these are the usual assumptions over C in de Paiva (1991), and they imply that C is a distributive category. Let A, B be objects of C and let jA be the monic injection A → A + B. Observe that

SubjA has the left adjoint, which is given by the functor E jA : Sub(A) / Sub(A + B) which acts as the post-composition by jA.

Again by Proposition 13 the dual result of Theorem 21 holds for the universal completion.

Theorem 25. Let C be a distributive category and let P: C op / Lat be a lat-doctrine such A

that the images through P of the injections jA : A / A + B have right adjoints jA which satisfy the Beck-Chevalley condition. Then the following properties hold.

(1) The pos-doctrine Pun is a lat-doctrine. (2) Suppose that C has points. Then the images through Pun of the injections:

jA : A / A + B

have right adjoints unA which satisfy the Beck-Chevalley condition. jA (3) Suppose that C has points and that the images through P of the injections jA have left un adjoints E jA which satisfy the Beck-Chevalley condition. Then the images through P of the injections j have left adjoints E un which satisfy the Beck-Chevalley condition. A jA

Proof. Let Q := (−)opP. Then Q is a lat-doctrine satisfying the hypotheses of Theorem 21. Hence Qex satisfies the theses of Theorem 21, which corresponds to saying that Pun = (−)opQex (see Proposition 13) satisfies the theses of the current statement.

Examples 26. Observe that the subobject lat-doctrine Sub: C op / Lat presented in

Example 24 has right adjoints along the inclusions. In particular the right adjoint A

jA : Sub(A) / Sub(A + B) of SubjA is the functor sending a subobject represented by a mono s: S / A to the subobject represented by the arrow:

s + 1B : S + B / A + B which is indeed a mono: if a be an arrow X → S + B then X has a structure of coproduct together ∗ ∗ with the injections a iS : XS / X and a iB : XB / X obtained by pulling back along a the injections:

iS : S / S + B and iB : B / S + B respectively. Let us denote as a1 and a2 the unique arrows XS → S and XB → B respectively such that a = a1 + a2. Observe that the injections iS : S / S + B and iB : B / S + B are the ∗ ∗ pullbacks along s + 1B of the arrows jA and jB, hence a iS and a iB are the pullbacks of jA and jB alons (s + 1B)a. This implies that, whenever b is another arrow X → S + B such that 16 LaTeX Supplement

(s + 1B)a = (s + 1B)b then, by appliying the same procedure to b, we obtain the same coprod- ∗ ∗ ∗ ∗ uct structure (a iS, a iB) over X. In particular jAsa1 = (s + 1B)a(a iS) = (s + 1B)b(a iS) = jAsb1, which implies that a1 = b1, as jAs is a monomorphism. Analogously a2 = b2, hence a = b and s + 1B is proven to be a monomorphism.

Let s: S / A be a subobjectof A and let t : T / A + B be a subobjectof A + B. Then ∗ A the conditions jA t = SubjA (t) ≤ s and t ≤ jA (s) = s + 1B are equivalent: if the latter holds then a mono witnessing the former exists by the universal property of the pullback; if the former holds ∗ for a mono m: jA T / S then m + 1B : T / S + B witnesses the latter.

5. On the distributive structure In the previous sections we proved that, under given hypotheses, the existential and universal completion of a lat-doctrine is a lat-doctrine as well. It is natural to ask under which hypoteses these completions preserve also the distributivity of the fibres. Essentially this depends on the Frobenius reciprocity (or on its dual version, which we call the co-Frobenius reciprocity - i.e. the

one with A and ∨ in place of E and ∧ respectively) of the left (or right, respectively) adjoints to the pullbacks along the injections. Let us present this phenomenon in detail.

Definition 27. A distributive lat-doctrine isafunctor P: C op / DistLat , where C is a dis- tributive category and DistLat is the category of distributive lattices and finite co/limit-preserving (i.e. finite sup/inf-preserving) maps between them.

Theorem 28. Let P: C op / DistLat be a distributive lat-doctrine such that the images

through P of the injections jA : A / A + B have left adjoints E jA which satisfy the Beck- Chevalley condition and the Frobenius reciprocity. Then the following properties hold.

(1) The pos-doctrine Pex (which is a lat-doctrine by Theorem 21) is a distributive lat-doctrine. (2) Suppose that C has points. Then the left adjoints ex to the images through Pex of the E jA injections jA (which exist and satisfy the Beck-Chevalley condition by Theorem 21) happen to satisfy the Frobenius reciprocity.

Proof. Part I. Distributivity in Pex(A). Let (A, B, β), (A, C, γ) and (A, D, δ) be objects of Pex(A) and let us consider the objects ((A, B, β) ∨ (A, C, γ)) ∧ (A, D, δ) and ((A, B, β) ∧ (A, D, δ)) ∨ ((A, C, γ) ∧ (A, D, δ)), which are respectively (A, (B + C) × D, x) and (A, B × D + C × D, y) whose third components x and y equal:

P P −1 E β E γ P δ hprA,prB+Ci θ ( jA×B ∨ jA×C ) ) ∧ hprA,prDi and:

P −1 P β P δ P γ P δ ϕ ( E jA×B×D ( hprA,prBi ∧ hprA,prDi ) ∨ E jA×C×D ( hprA,prCi ∧ hprA,prDi ) ) respectively, where θ and ϕ are the isomorphisms (A × B + A × C) → A × (B + C) and A × B × D + A × C × D → A × (B × D + C × D) of C . As the following diagram of isomor- phisms:

−1 θ ×1D A × (B + C) × D / (A × B + A × C) × D

−1 −1 1A×ω ψ   A × (B × D + C × D) / A × B × D + A × C × D ϕ−1 Mathematical Structures in Computer Science 17

−1 commutes, in order to verify that 1A × ω constitutes an isomorphism ((A, B, β) ∨ (A, C, γ)) ∧ (A, D, δ) → ((A, B, β) ∧ (A, D, δ)) ∨ ((A, C, γ) ∧ (A, D, δ)), it is enough to verify the elements: P β P γ P δ ( E jA×B×D hprA,prBi ∨ E jA×C×D hprA,prCi ) ∧ [hprA,prDi,hprA,prDi] and: P β P δ P γ P δ E jA×B×D ( hprA,prBi ∧ hprA,prDi ) ∨ E jA×C×D ( hprA,prCi ∧ hprA,prDi ) of P(A × B × D + A × C × D) to be equal, since they are the images through P(θ×1D)ψ and Pφ respectively of the third components of the objects ((A, B, β) ∨ (A, C, γ)) ∧ (A, D, δ) and ((A, B, β) ∧ (A, D, δ)) ∨ ((A, C, γ) ∧ (A, D, δ)) respectively. This is the case, by distributivity of P(A × B × D + A × C × D) and being: P β P δ E jA×B×D hprA,prBi ∧ [hprA,prDi,hprA,prDi] = P β P P δ = E jA×B×D ( hprA,prBi ∧ jA×B×D [hprA,prDi,hprA,prDi] ) = P β P δ = E jA×B×D ( hprA,prBi ∧ hprA,prDi ) by the Frobenius reciprocity on the injection:

jA×B×D : A × B × D / A × B × D + A × C × D (and the same holds with C in place of B). Part II. Frobenius reciprocity. Let (A, C, γ) and (A + B, D, δ) be objects of Pex(A) and Pex(A + B). We are left to verify the objects ( E ex(A, C, γ) ) ∧ (A + B, D, δ) and E ex ( (A, C, γ) ∧ Pex(A + jA jA jA B, D, δ) ), which equal:

A B C D P P −1 γ P δ ( + , × , ( hprA+B,prCi θ E jA×C ) ∧ hprA+B,prDi ) and:

A B C D P −1 P γ P P δ ( + , × , ϕ E jA×C×D ( hprA,prCi ∧ hprA,prDi jA×1D ) ) respectively, to be equal, where jA is the injection A → A + B and θ and ϕ are the isomor- phisms A × C + B × C → (A + B) × C and A × C × D + B × C × D → (A + B) × C × D respec- tively. This is the case, since:

P −1 P γ P P δ ϕ E jA×C×D ( hprA,prCi ∧ hprA,prDi jA×1D ) =

P −1 E P γ P P P δ = ϕ jA×C×D ( hprA,prCi ∧ jA×C×D ϕ hprA+B,prDi ) =

{Frobenius r.} P −1 E P γ P δ = ( ϕ jA×C×D hprA,prCi ) ∧ hprA+B,prDi =

{Beck-Chevalley c.} P −1 P E γ P δ = ( ϕ [hprA,prCi,hprB,prCi] jA×C ) ∧ hprA+B,prDi =

P P −1 γ P δ = ( hprA+B,prCi θ E jA×C ) ∧ hprA+B,prDi and we are done. By Proposition 13, as usual we deduce the following dual statement:

Theorem 29. Let P: C op / DistLat be a distributive lat-doctrine such that the images A

through P of the injections jA : A / A + B have right adjoints jA which satisfy the Beck-Chevalley condition and the co-Frobenius reciprocity. Then the following properties hold.

(1) The pos-doctrine Pex (which is a lat-doctrine by Theorem 25) happens to be a distributive lat-doctrine.

(2) Suppose that C has points. Then the right adjoints exA to the images through Pex of the jA injections jA (which exist and satisfy the Beck-Chevalley condition by Theorem 25) happen to satisfy the co-Frobenius reciprocity. 18 LaTeX Supplement

Theorem 28 represents a specialisation of points 1. and 2. of Theorem 21 for distributive lat- doctrines. An analogous specialisation of point 3. is not as natural as those ones:

Proposition 30. Let P: C op / DistLat be a distributive lat-doctrine such that the images through P of the injections jA : A / A + B have left adjoints E jA which satisfy the Beck- Chevalley condition and the Frobenius reciprocity. Then the following property holds.

3. Suppose that C has points and that the images through P of the injections j have right A A

adjoints which satisfy the Beck-Chevalley condition and the co-Frobenius reciprocity. jA A Then the right adjoints ex to the images through Pex of the injections j (which exist and jA A satisfy the Beck-Chevalley condition by Theorem 21) happen to satisfy the co-Frobenius

reciprocity if and only if the following equation: A

1 A 1 1 1 Pφ − jA×(C+D) Pθ − E jA×C = Pω− E j(A+B)×C Pψ− jA×C (5) holds for every commutative diagram of the form:

θ jA×(C+D) A × C + A × D / A × (C + D) / A × (C + D) + B × (C + D) O jA×C φ  A × C (A + B) × (C + D) O jA×C ω  ψ j(A+B)×C A × C + B × C / (A + B) × C / (A + B) × C + (A + B) × D.

Proof. Assuming the equality (5) to hold for any commutative diagram as in the statement, one

directly gets the co-Frobenius reciprocity: A

exA A C γ A B D δ ex A C γ Pex A B D δ ( jA ( , , ) ) ∨ ( + , , ) = jA ( ( , , ) ∨ jA ( + , , ) )

to hold for every (A, C, γ) ∈ Pex(A) and (A + B, D, δ) ∈ Pex(A + B). Viceversa, if: A

exA A C γ A B D δ ex A C γ Pex A B D δ ( jA ( , , ) ) ∨ ( + , , ) = jA ( ( , , ) ∨ jA ( + , , ) ) ex ex for every (A, C, γ) ∈ P (A) and (A + B, D, δ) ∈ P (A + B), by taking δ = 0(A+B)×D this equality collapses into the equality (5) (being γ an arbitrary element of P(A × C)). As usual, Theorem 30 dualises for the universal completion. We conclude the current section with the following:

Remark 31. We observe that Theorem 28 tells us that the existential completion preserves type theories whose predicative part is written in the Coherent fragment of logic. More generally, by Remark 23, the same holds for type theories whose predicative part is written in the Geometric fragment of logic. See Remark 41 for more details and examples.

6. Combining quantifier completions In the previous section we showed some preservation properties of the existentialand the universal completion. Here we show how to combine these two constructions.

Theorem 32. Let P: C op / Pos be a universal pos-doctrine and suppose that C has expo- nents. Then Pex : C op / Pos is existential and universal, i.e. the existential completion preserves the universal structure. Mathematical Structures in Computer Science 19

Sketch of Proof. See the details in the Appendix A. Let A1, A2 be objects of C , and let pr : A A A be the first projection. Let:

A1 1 × 2 / 1 exA ex ex pr : P (A1 × A2) / P (A1) A1 be defined by:

A A B A BA2 A P ( 1 × 2, , α) 7→ ( 1, , hpr1,pr3i hpr1,pr2,evhpr2,pr3ii(α))

A2 A2 where pri are the projections from A1 × A2 × B and ev: A2 × B / B is the evaluation map. The intuition is that the right adjoints act by mapping a formula ∃b : Bα(a1, a2, b) 7→ ∃ f : A B 2 ∀a2 : A2α(a1, a2, f (a2)).

Let SDexp be the 2-full subcategory of SD whose objects are pos-doctrines whose base category has exponents, and whose 1-cells are the 1-cells of SD which preserve the exponents. Similarly, we denote by UnDexp and ExDexp the two subcategories of SDexp of the universal and existential pos-doctrines whose base category has exponents.

ex Theorem 33. The 2-monad T : SDexp / SDexp induces a 2-monad:

ex T : UnDexp / UnDexp . f Sketch of Proof. See the details in the Appendix B. By Theorem 32 the 2-monad Tex preserves the universal structure. A direct verification provides the right preservation of 1-cells as well as the fact that the unit and the counit preserve the universal structure.

∼ un By Theorem 14 it is the case that UnDexp = T -Algexp and then we can conclude that the existential completion induces a 2-monad

ex un un T : T -Algexp / T -Algexp .

ex ex un Observe that the 2-monad T is a lifting of T on T -Algexp, hence by the well-known charac- terization of the distributive laws of 2-monads, see for instance Tanaka and Power (2006a,b), we have the following result. See Hofstra (2010) for the general case of arbitrary fibrations.

Theorem 34. There exists a distributive law λ : TunTex / TexTun and the 2-functor ex un T T : SDexp / SDexp is a 2-monad.

By combining all previous statements, we finally infer the following result about existential and universal completion of lat-doctrines.

Theorem 35. Let P: C op / Lat be a lat-doctrine such that:

• the category C has points; • the category C has exponents;

• the images Pj of the injections jA : A / A + B have left and right adjoints E j ⊣ Pj ⊣ A A A A

jA , which satisfy BC. 20 LaTeX Supplement

Then (Pun)ex : C op Lat is an existential and universal lat-doctrine and the images (Pun)ex / jA

of the injection j : A / A + B have left and right adjoints ( E un)ex ⊣ (Pun)ex ⊣ ( unA )ex, A jA jA jA which satisfy BC.

Proof. The statement is a consequence of Theorem 21, Theorem 25 and Theorem 32.

Remark 36. Let P: C op / Lat be a lat-doctrine which satisfies the hypotheses of Theorem 35. As exposed in Remark 17, remind that Dial(P) is nothing but the fiber of (Pun)ex over the terminal object of C . Hence, by Theorem 35, we can conclude that the poset reflection of the dialectica category Dial(P) is a lattice.

The characterisation that we presented in the Proposition 30 of the preservation by the existen- tial completion of the co-Frobenius reciprocity consists of a very strong condition that does not even hold in very natural enviroments, as shown in the following Example. Therefore, we con- clude that the dialectica monad does not necessarily preserve the fibred-distributivity unless very restrictive and unusual conditions hold.

Examples 37. Let us consider the usual subset-doctrine Sub: Setop / DistLat , which is a distributive lat-doctrine having both left and right adjoints to the pullbacks along injections which satisfy the Beck-Chevalley condition and the (co-)Frobenius reciprocity. Referring to the commutative diagram in the statement of Proposition 30, whenever S ⊆ A × C, it is the case that the left-hand side and the right-hand side of the equality (1) in Proposition 30 produce the subsets:

S + B × (C + D) and S + B × C of (A + B) × (C + D) respectively. Therefore the equality (1) is not always satisfied. Hence, the doctrine Subex is a distributive lat-doctrine that has both left and right adjoints to the pull- backs along the injections, but by Proposition 30 the right ones do not satisfy the co-Frobenius reciprocity anymore. In particular, by the dual statement of Proposition 30, it is the case that the lat-doctrine (Subun)ex has both left and right adjoints to the pullbacks along the injections, but they do not satisfy the (co-)Frobenius reciprocities. Hence we cannot deduce that (Subun)ex is distributive by applying Theorem 28 or Theorem 29.

7. Choice principles and quantifier completions The constructive features of choice principles play a fundamental role in several areas of math- ematics and theoretical computer science. For example in a dependent type theory satisfying the propositions as types correspondence together with the proofs-as-programs paradigm, the validity of the unique choice rule or even more of the choice rule says that the extraction of a computable witness from an existential statement under hypothesis can be performed within the same theory. However in Maietti (2017) the author shows that the unique choice rule, and hence the choice rule, are not valid in some important constructive theories such as Coquand’s Calculus of Constructions with indexed sum types, list types and binary disjoint sums and in its predicative version implemented in the intensional level of the Minimalist Foundation Maietti (2017, 2009). In this section we show that quantifier completions carry on some strong choice principles, and the preservation of the logical structures suggests that this free-operation could be applied to extend a given theory to another one which satisfies the following principles. Recall from Trotta and Maietti (2020) that the existential completion of a doctrine satisfies the rule of choice. Mathematical Structures in Computer Science 21

Theorem 38 (Rule of Choice). If the fibres of a pos-doctrine P: C op / Pos have finite meets, then the existential completion of a primary doctrine satisfies the Rule of Choice (see Trotta and Maietti (2020)), i.e. if: a : A |⊤⊢∃b : B α(a, b) then there exists a term a : A | f (a) : B called witness such that: a : A |⊤⊢ α(a, f (a)).

Again we can prove the dual property for the universal completion,and we call it counterexam- ple property.In this case, the logicalintuitionis that the witness playstheruleof a counterexample, i.e. if we have ∀x : A α(x) ⊢ ⊥, then there exists a term t such that α(t) ⊢ ⊥. In other words, t is the counterexample.

Theorem 39 (Counterexample Property). If P: C op / Pos is a pos-doctrine whose fibres have finite joins, then the universal completion satisfies Counterexample Property, i.e. if: a : A | ∀b : B α(a, b) ⊢ ⊥ then there exists a term a : A | g(a) : B, which represents the counterexample of the previous statement, such that: a : A | α(a, g(a)) ⊢ ⊥.

We conclude the section by proving that, under the assumption of Theorem 32, the existential completion of a universal doctrine satisfies the so called Skolemization principle.

Theorem 40 (Skolemization). Let P: C op / Pos be a universal pos-doctrine with expo- ex nents, and consider its existential completion P . For every A1, A2 objects of C and every

ex

α = (A1 × A2, B, α) ∈ P (A1 × A2) it holds that:

A exA ex ex ex pr E ηA1×A2×B(α) = E ′ η A2 Phpr ,pr ,evhpr ,pr ii(α)). 1 hpr1,pr2i pr1 hpr1,pr3i A1×A2×B 1 2 2 3

C Proof. Let A1, A2 be objects of , andlet pr1 : A1 × A2 / A1 be the first projection. Recall

that exA : Pex(A × A ) / Pex(A ) is defined by: pr1 1 2 1

A A B A BA2 A P ( 1 × 2, , α) 7→ ( 1, , hpr1,pr3i hpr1,pr2,evhpr2,pr3ii(α)).

By Remark 11, it is the case that:

A exA ex pr (α) = E ′ η A2 hpr ,pr iPhpr ,pr ,evhpr ,pr ii(α). 1 pr1 A1×B 1 3 1 2 2 3

By Theorem 33, the unit of the 2-monad preserves the universal structure, hence we have that A A ex

η A = η A and then:

A1×B 2 hpr1,pr3i hpr1,pr3i A1×A2×B 2

A exA ex ex pr (α) = E ′ η A2 Phpr ,pr ,evhpr ,pr ii(α). 1 pr1 hpr1,pr3i A1×A2×B 1 2 2 3

On the other hand, by Remark 11, it is the case that:

A exA ex ex (A1 × A2, B, α) = E ηA A B(α) pr1 pr1 hpr1,pr2i 1× 2× that is, the stated equality holds.

The property proved in Theorem 40 reflects the principle of Skolemization introduced by G¨odel in his work on the dialectica interpretation G¨odel (1958). It is called (AC) by Toelstra in G¨odel 22 LaTeX Supplement

et al. (1986), since this principle is a form of choice, and it has the following presentation: ∀x∃yα(x, y) → ∃ f ∀xα(x, fx).

Remark 41. Combining Theorem 38 and Theorem 28, we obtain an interesting tool to extend a type theory whose predicative part is written in the coherent fragment of first-order logic to another type theory which moreover satisfies the rule of choice. More generally, we can extend a type theory whose predicative part is written in the geometric logic -e.g. the subobject-doctrine over a (quasi)topos- to another type theory which moreover satisfies the Rule of Choice (see Remark 23 and Remark 31). Observe indeed that the subobject- doctrine over a quasitopos is both existential and elementary. Hence all the reindexing functors -and in particular the ones along the injections- have a left adjoint, so that the required hypotheses are satisfied. A deeper analysis of the link between the existential completion and the validity of choice principles in toposes and quasitoposes is left as a future work.

8. Conclusions and further works We introduced and characterised the universal and existential completions, by showing those log- ical properties that are preserved by these constructions. We remark that the properties we needed in order to get them preserved (e.g. the existence of left and right adjoints over the injections) are all natural: they are true in many concrete instances enjoying a satisfying “power-set” algebra, like subobject doctrines over lextensive categories (see de Paiva (1991) and Example 3). One of the major benefits of this property-preservationanalysis appears during its applicationto dialectica construction. During the current essay we only focused on the notion of poset-reflection of the dialecticacategory associated to a lattice-doctrine.In the future work we intendto generalise our approach in order to examine properties of the dialectica category itself and not just of its poset-reflection. Moreover we are going to find the right hypothesessuch that the universal and existential com- pletion preserves the implication of intuitionistic logic, focusing on the applications. Finally, we are interested in applying our results about the quantifier completions to extend concrete theories or to characterise their fragments that satisfy the choice principles of our analysis. A comparison with the dialectica tripos and the results presented in Biering (2008) is left as a future work.

Aknowledgements. We would like to thank Nicola Gambino, Maria Emilia Maietti and Margherita Zorzi for their comments and suggestions.

References Biering, B. 2008. Dialectica interpretations – a categorical analysis (PhD Thesis). Carboni, A., Lack, S., and Walters, R. 1993. Introduction to extensive and distributive categories. Journal of Pure and Applied Algebra, 84(2):145 – 158. de Paiva, V. 1991. The Dialectica categories. PhD thesis, University of Cambridge. Frey, J. 2019. Categories of partial equivalence relations as localizations. Godel,¨ K. 1958. Uber¨ eine bisher noch nicht ben¨utzte erweiterung des finiten standpunktes. Dialectica, 12(3-4):280–287. Godel,¨ K., Feferman, S., Dawson, J., Kleene, S., Moore, G., and others 1986. Kurt G¨odel: Collected Works: Volume II: Publications 1938-1974. Collected Works. OUP USA. Hofstra, P. 2010. The dialectica monad and its cousins. In Models, , and Higher-dimensional Categories: A Tribute to the Work of Mihaly Makkai, volume 53, pp. 107–139. American Mathematical Society. Hyland, J. 2002. Proof theory in the abstract. Annals of Pure and Applied Logic, 114:43–78. Mathematical Structures in Computer Science 23

Jacobs, B. 1999. Categorical Logic and Type Theory, volume 141 of Studies in Logic and the foundations of . North Holland Publishing Company. Lawvere, F. 1969. Adjointness in foundations. Dialectica, 23:281–296. Lawvere, F. 1970. Equality in hyperdoctrines and comprehension schema as an adjoint functor. In Heller, A., editor, New York Symposium on Application of Categorical Algebra, volume 2, pp. 1–14. American Mathematical Society. Maietti, M. 2009. A minimalist two-level foundation for constructive mathematics. Annals of Pure and Applied Logic, 160(3):319 – 354. Maietti, M. 2017. On choice rules in dependent type theory. In TAMC. Maietti, M. and Rosolini, G. 2013a. Elementary quotient completion. Theory App. Categ., 27(17):445–463. Maietti, M. and Rosolini, G. 2013b. Quotient completion for the foundation of constructive mathematics. Log. Univers., 7(3):371–402. Maietti, M. and Rosolini, G. 2013c. Unifying exact completions. Appl. Categ. Structures, 23:43–52. Tanaka, M. and Power, J. 2006a. Pseudo-distributive laws and axiomatics for variable binding. Higher-Order Symb. Comput., 19:305–337. Tanaka, M. and Power, J. 2006b. A unified category-theoretic semantics for binding signatures in substructural logics. Oxford Univ. Press, 16(1). Trotta, D. 2020. Existential completion. Theory and Applications of Categories, 35(43). Trotta, D. and Maietti, M. 2020. Choice principles via completions. Preprint.

Appendix A. Proof of Theorem 32 We remind that the following argument shows a proof-irrelevant version of the corresponding result in Hofstra (2010).

Proof. Part I. Existence of right adjoints along projections. Let A1, A2 be objects of C , and let pr : A A A be the first projection. Let:

A1 1 × 2 / 1 exA ex ex pr : P (A1 × A2) / P (A1) A1 be defined by:

A A B α A BA2 A P α ( 1 × 2, , ) 7→ ( 1, , hpr1,pr3i hpr1,pr2,evhpr2,pr3ii( ))

A2 A2 where pri are the projections from A1 × A2 × B and ev: A2 × B / B is the evaluation

map. The intuition is that the right adjoints act by mapping a formula ∃b : Bα(a , a , b) 7→ ∃ f : A 1 2 BA2 ∀a : A α(a , a , f (a )). Let us verify that ex is right adjoint to Pex . 2 2 1 2 2 pr1 pr1 un un Let (A1, C, γ) ∈ P (A1) and (A1 × A2, B, α) ∈ P (A1 × A2). We are left to verify that the conditions: ex (A1 × A2, C, Ppr ×1C (γ)) = Ppr (A1, C, γ) ≤ (A1 × A2, B, α) A1 A1

and:

A exA A2 (A1, C, γ) ≤ pr (A1 × A2, B, α) = (A1, B , hpr ,pr iPhpr ,pr ,evhpr ,pr ii(α)) A1 1 3 1 2 2 3 are equivalent. The former disequality is equivalent to the condition: there is an arrow g: A1 × A2 × C / B suchthat Ppr ×1 (γ) ≤ Phpr ,gi(α), that is: A1 C A1×A2

thereis g: A1 × A2 × C / B A such that γ ≤ pr ×1 Phpr ,gi(α) (6) A1 C A1×A2 24 LaTeX Supplement

while the latter holds precisely when:

A

thereis h: A1 × C / B 2 A such that γ ≤ Phpr ,hi hpr ,pr iPhpr ,pr ,evhpr ,pr ii(α) (7) A1 1 3 1 2 2 3 ′ so that we are left to prove (6) and (7) to be equivalent. Let pri be the three projections A2 ′ from A2 × A1 × B , pri the projections from A1 × A2 × C and pri the projections from A2 × A1 × C. Moreover let us assume that (6) holds for a given arrow g. We define the arrow A2 ′ ′ ′ h: A1 × C / B to be the exponential transpose of ghpr2, pr1, pr3i, hence it holds that

′ ′ ′

ev(1A2 × h) = ghpr2, pr1, pr3i. We are going to prove that this choice of h is such that:

A A pr ×1 Phpr ,gi = Phpr ,hi hpr ,pr iPhpr ,pr ,evhpr ,pr ii (8) A1 C A1×A2 A1 1 3 1 2 2 3 allowing to conclude that (7) holds. Moreover observe that, from a given arrow h satisfying (7), one can always recover the corresponding arrow g by anti-transposing h and precompos- ′ ′ ′ ing by hpr2, pr1, pr3i (as hpr2, pr1, pr3i is an isomorphism whose inverse is indeed hpr2, pr1, pr3i). Therefore (8) would also imply that (6) follows from (7), concluding our adjointness proof. Hence we are left to prove that (8) holds. A2 Let ϕ be the arrow (1A2 × h)hpr2, pr1, pr3i: A1 × A2 × C / A2 × B , and observe that the equality: pr pr ev pr pr pr ϕ pr pr g pr g h 1, 2, h 2, 3iih 1, i = h 1, 2, i = h A1×A2 , i

holds. Hence it is the case that Phpr ,gi = Phpr ,ϕiPhpr ,pr ,evhpr ,pr ii and therefore (3) follows if A A A A1×A2 1 1 2 2 3 we prove that pr ×1 Phpr ,φi = Phpr ,hi hpr ,pr i holds. By the Beck-Chevalley condition for A1 C 1 A1 1 3 it is enough to prove that the right-hand square of the commutative diagram:

′ ′ ′ pr ×1 =hpr ,pr i hpr2,pr1,pr3i A1 C 1 3 A2 × A1 × C / A1 × A2 × C / A1 × C

′ ′ ′ ′ hpr ,hi hpr1,pr2,hhpr1,pr3ii hpr1,ϕi A1    A A BA2 A A BA2 A BA2 2 × 1 × ′ ′ ′ / 1 × 2 × / 1 × hpr2,pr1,pr3i hpr1,pr3i is a pullback. This is the case: the outer square is a pullback, as its horizontal arrows are the pro- A2 A2 ′ ′ ′ ′ jections A2 × A1 × C → A1 × C and A2 × A1 × B → A1 × B and as hpr1, pr2, hhpr1, pr3ii = 1 pr h , and moreover the horizontal arrows of the left-hand square are isos, therefore A2 × h A1 , i the right-hand square is indeed a pullback as well. Part II. Beck-Chevalley condition. Let us consider a pullback of a projection along a given arrow f , which is of the form:

pr D × C D / D

f ×1C f  

A × C / A.

prA A

and let us verify that the corresponding equality Pex exA = ex Pex holds. Whenever (A × f prA prD f ×1C C, B, β) ∈ P(A × C) we get (by applying the left and right member of the wannabe equality respectively) the elements:

(D, BC, P A P (β)) f ×1BC hpr1,pr3i hpr1,pr2,evhpr2,pr3ii Mathematical Structures in Computer Science 25 and

D BC A P P β ( , , hpr1,pr3i hpr1,pr2,evhpr2,pr3ii f ×1C×B ( ))

of P(D), being pr the projections from A × C × BC and pr the projections from D × C × BC. i i A

We are left to prove them to be equal. By Beck-Chevally condition for it is the case that A

P A = P , hence we are left to observe that: f ×1BC hpr1,pr3i hpr1,pr3i f ×1C×1BC P P = P P f ×1C×1BC hpr1,pr2,evhpr2,pr3ii hpr1,pr2,evhpr2,pr3ii f ×1C×B which holds because the class of arrows

C hpr1, pr2, evhpr2, pr3ii: X × C × B / X × C × B

for X in C is a natural transformation (−) × C × BC → (−) × (C × B).

Appendix B. Proof of Theorem 33 We divide the proof of Theorem 33 into the following Lemmas. We remind that the following argument shows a proof-irrelevant version of the corresponding results in Hofstra (2010).

Lemma 42. The unit of the 2-monad Tex preserves the universal structure.

Proof. Recall from Trotta (2020) that the unit of the 2-monad Tex is provided by the 1-cell ex ex ex ex ηP : P / P of SD, where ηP = (idC , ι), with ιA : P(A) / P (A) acting as α 7→

(A, 1, α). Then one might check that the diagram: A pr P(A × B) A / P(A)

ιA×B ιA

ex  ex P (A × B) exA / P (A) prA commutes, since 1B =∼ 1. Therefore the unit of the 2-monad preserves the universal structure.

Lemma 43. The multiplication of the 2-monad Tex along universal pos-doctrines with exponents preserves the universal structure.

Proof. Recall that the multiplication of the 2-monad µex : (Tex)2 / Tex is given by the ex ex assignment µP = εPex , where ε is the counit of the existential completion εP : P / P and ex it is given by the pair (id, ζ), with ζA : P (A) / P(A) acting as (A, B, α) 7→ prE 1 (α), where

pr1 : A × B / A is a projection. Then we conclude that the multiplication preserves the uni- ex ex 2 ex versal structure since, for every universal pos-doctrine P, the map µP : (T ) (P) / T (P) has as domain and codomain two pos-doctrines satisfying the (AC) principle by Theorem 40.

Lemma 44. Let (F, f ): P / R be a 1-cell of universal pos-doctrines with exponents. Then Tex(F, f ): Pex / Rex preserves the universal structure. 26 LaTeX Supplement

Proof. Recall that the 1-cell Tex(F, f ) = (F, f ): Pex / Rex is given by F itself and the functor f : Pex(A) / RexF(A) acting on the poset Pex(A) as:

A B FA FB R f ( , , α) 7→ ( , , hprFA,prFBi A×B(α)). A

Since, by hypothesis, f is natural with respect to PA and by definition of ex, one might check, by using the naturality of f , that the 1-cell of (F, f ) preserves the universal structure.