<<

arXiv:1904.06538v1 [cs.LO] 13 Apr 2019 eksbttto tutr scntutduigabicateg a using constructed is structure substitution Weak weak eko fn nlgu euti h ieauefrclosed for literature the in result analogous no of know we logic o atsa lsdbctgre,adteeystu the elsewhere. presented up be to thereby strategy coherence and the , for closed scene cartesian for ssmtmscle the called sometimes is hr r elkonchrnersls[3,[4;however [14]; [13], results coherence (bilimits well-known limits are bicategorical there and bicategories For for mute. looks strategy One theorems . to up defined unsatisfactory. categoric often is to infor intensional entails of structure this loss the bicategorical but quotienting, reduce by structure to is approach tutr.Aohrsrtg mly yeter htmatc (see that structure theory categorical type the a employs strategy Another structure. itvt n ntlw ae acltn nbctgre ( bicategories in calculating makes laws unit [1 and ciativity [9], algebra categorical [6] [2], and [5], [1], models [8], [11]. algebra datatype [7], [4], in logic [3], categorical instance computation for of semantics arising of science, that is up computer structure hold resulting only the laws isomorphism: property—these universal coherent compositio a to where by the particular defined situations—in settings is many (‘ such strictly In hold In nose’). composition of laws transformations. unit and natural associativity and aeois uha h 2- the as such categories, at aimed programme a in bicategories. closed step cartesian first for the explic coherence is proving and L work Simply-Typed theory This the type Calculus. generalises directly 2-dimensional em and of that substitution, theory combination type algeb novel a universal synthesised is a are from result exponentials The clone and considerations. products abstract semantic for of rules the notion and the prac of and fication principled is approach prop Our universal setting. appropriate t bicategorical correspondence an Curry-Howard-Lambek the satisfies lifting sh thereby model and theory bicategory syntactic closed type cartesian its a a of introduce structure the we elling Precisely, bicategories. closed ur-oadLme orsodne atsa lsdbi gories closed cartesian correspondence, Curry-Howard-Lambek nti ae ecryotteitra-agaestrategy internal-language the out carry we paper this In hr r w ansrtge o okn ihstructures with working for strategies main two are There h aeso oeec aarqie owtesteasso- the witness to required data coherence of layers The 2-categories Abstract ne Terms Index [18]. n yeter o atsa lsdbicategories closed cartesian for theory type A ctgre oegnrly ooiul ifiut One difficult. notoriously generally) more -categories salsigta oecaso igasawy com- always diagrams of class some that establishing W osrc nitra agaefrcartesian for language internal an construct —We iaeoisaerf nmteaisadtheoretical and mathematics in rife are Bicategories . tpdlmd acls ihrctgr theory, category higher calculus, lambda —typed xoaietesrcue omdb lse of classes by formed structures the axiomatise .I I. eateto optrSineadTcnlg,University Technology, and Science Computer of Department NTRODUCTION nenllanguage internal e.g. 1] 1] 8) uhasystem a such [8]); [16], [15], acl ir hlpSaville Philip Fiore Marcelo Cat fsalcategories, small of 1]or [17] coherence internal wthat ow mation ambda nthe on ploys [12]) the o from mod- tical. cate- erty, and hes ori- ra, 0], al it n a , , Λ ecntuta nenllanguage internal an construct We al ste18si h oko yeer tl 2]and [22] that Stell suggested & [24] Rydeheard Seely of STLC, work For a the [23]. explored in Power was 1980s idea the the This terms, as terms. are early between rewrites and are types 2-cells are objects If rewriting. r epcieyitrrtdi abksyesmnis[ maps semantics equal Lambek-style the a by in interpreted respectively are and yLct apr[31]. Harper introdu been & has 2-dimensiona Licata Martin-L¨of [30] of directed by style a the- the while in [29] programming-language theory theory type in proof and pursued [28] c ory been cartesian con have strict type-theoretic with structure recently, More 2-categories 2- [27]. modelling a [26], advocated structions Jay and in & [25] exponentials Ghani Hilken (lax) by by followed defining approach an adjunction category, the of counit em hni TC o ntne oeta em uhas such terms that note instance, For STLC. in distinguishi than entails terms This bicategories. closed cartesian .2dmninltp hoisadbctgrclcomposit bicategorical and theories type 2-dimensional A. cartesian examples: [10 [21]. other algebra semantics categorical to game in appear applies also bicategories present closed we int language the However, [20]. appli theory their category for higher-dimensional specifically [9], [ distributors species cartesian generalised of of bicategories closed cartesian the [19]. Calculus) genera Lambda directly (Simply-Typed and STLC settings the such in reasoning for calculus h rbe fchrnefrcreincoe bicategories closed cartesian of for property a coherence to of problem the oitv)sbttto prto saplbc (associat pullback ca t a closed interpreting as cartesian by isomorphism). operation locally caused substitution theory between sociative) type mismatch dependent the Martin-L¨of rectify to -aeoia ol fpeiu ok swl ssetting as the well outside as us work, places previous This of isomorphism. world to 2-categorical up only tive isomorphic. the only in contrast, In iaeois(hr p’sad for stands ‘ps’ (where bicategories ps x J 1 , hr santrlcneto ewe -aeoisand 2-categories between connection natural a is There ti rca oorapoc htteeutoa hoyof theory equational the that approach our to crucial is It u oki oiae ytecmlxte fcluaigin calculating of complexities the by motivated is work Our t t hsisei iia ota dnie yCre 3] h at who [32], Curien by identified that to similar is issue This Ñ r K β u x ˝ 1 cnrcinmyntrlyb nepee steui and unit the as interpreted be naturally may -contraction osntietf n oesrcueta h xosof axioms the than structure more any identify not does { x J u 1 u , 1 K , 2 J { u x 2 2 K Λ 1 sr ˝ y ps x v bi ec,sbttto uh ob associa- be to ought substitution Hence, , Ñ { aeoia etn hs opstsare composites these setting categorical J y v hstp hoypoie practical a provides theory type This . s fCambridge of K and and J t t K r u x ˝ Λ 1 r ps x J v pseudo , u Ñ { 1 y K s{ o atsa closed cartesian for ˝ x J 1 ,tu reducing thus ), v u , v pt coherent to up ive K , 2 J r e(tityas- (strictly he η u v -expansion 2 eoisand tegories { K y ainto cation gmore ng ˝ s{ ]and 7] J x tempts losed v and ] ernal 2 lises K s ced 17] ion y n s l - our work apart from type theories in which weak structure The functoriality of horizontal composition gives rise to is modelled in a strict language, such as Type an interchange law: for suitable 2-cells τ, τ 1, σ, σ1 one has Theory (c.f. [33], [34]). pτ 1 ‚ τq ˝ pσ1 ‚ σq “ pτ 1 ˝ σ1q ‚pτ ˝ σq.

x,Ñ A of bicategories is called a pseudofunctor (or B. The Λps x,Ñ homomorphism). It is a mapping on objects, 1-cells and 2-cells We will construct the internal language Λps in stages. that preserves horizontal composition up to isomorphism. First we will construct the internal language of bicategories b B C Λps (Section V) and then the internal language of bicate- Definition II.2 ([1]). A pseudofunctor F : Ñ between x B C gories with finite products Λps (Section VII); the type theory bicategories and consists of x,Ñ Λps extends both these systems (Section IX). In each case ‚ a mapping F : obpBq Ñ obpCq, we construct the syntactic model and prove an appropriate ‚ a FX,Y : BpX, Y q Ñ CpFX,FY q for every 2-dimensional freeness . X, Y P obpBq, We introduce substitution formally using a version of ex- ‚ an invertible 2-cell ψX : IdF X ñ F pIdX q for every plicit substitution [35], [36]. This syntactic structure and the X P obpBq, axioms it is subject to are synthesised from a bicategorification ‚ an invertible 2-cell φf,g : F pfq˝ F pgq ñ F pf ˝ gq for of the abstract clones [37] of universal algebra (Section IV). every g : X Ñ Y and f : Y Ñ Z, natural in f and g Abstract clones are a natural bridge between syntactic structure subject to three coherence laws. A pseudofunctor for which ψ (in the form of intuitionistic type theories or calculi) and se- and φ are both the identity is called strict. mantic structure (in the form of Lawvere theories or cartesian ). Example II.3. Every 2-category is a bicategory and every Cartesian closed structure is synthesised from universal 2-functor is a strict pseudofunctor. A one-object bicategory arrows at both the global (2-dimensional) and the local is equivalently a ; a monoidal functor is (1-dimensional) levels. From this approach we recover ver- equivalently a pseudofunctor between one-object bicategories. sions of the usual βη-laws of STLC, while keeping the rules Bicategorical products and exponentials are defined using to a minimum (Sections VII and Section IX). Our formulation the appropriate notion of adjunction, called a biadjunction. points towards similar constructions for (weak For our purposes, the characterisation of biadjoints in terms 3-categories [38], [39]) or even 8-categories. of biuniversal arrows [41] is most natural (c.f. [7]); this is x,Ñ The type theory Λps is, in a precise sense, a language for the bicategorical version of the well-known description of cartesian closed bicategories. It is capable of being formalised adjunctions via universal arrows (e.g. [42, Chapter III, §1]). in proof assistants such as Agda [40] and the principled nature For biuniversal arrows and their relationship to biadjunctions, of its construction makes it readily amenable to the addition see e.g. [43]. of further structure. We leave such extensions for future work. Definition II.4 ([12]). Let F : B Ñ C be a pseudofunctor. To II. BICATEGORIES give a right biadjoint U to F is to give C B We recall the definition of bicategory, pseudofunctor and 1) a mapping U : obp q Ñ obp q on objects, biequivalence. For leisurely introductions consult e.g. [1], [2, 2) a family of 1-cells pqC : F UC Ñ CqCPobpCq, 3) for every B P obpBq and C P obpCq an adjoint equiva- §9]. lence q F Definition II.1 ([1]). A bicategory B consists of C ˝ p´q BpB,UCq % CpFB,Cq ‚ a class of objects obpBq, ‚ for every X, Y P obpBq a hom-category `BpX, Y q, ‚, id˘ p´q5 with objects 1-cells f : X Ñ Y and morphisms Morphisms of pseudofunctors are called pseudonatural 2-cells α : f ñ f 1 : X Ñ Y ; composition of 2-cells is transformations [12] and morphisms of pseudonatural transfor- called vertical composition, mations are called modifications [1]. Bicategories, pseudofunc- ‚ for every X, Y , Z P obpBq an identity functor tors, pseudonatural transformations and modifications organise Id : 1 Ñ BpX,Xq and a horizontal composition functor X themselves into a we denote Bicat. ˝X,Y,Z : BpY,Zqˆ BpX, Y q Ñ BpX,Zq, ‚ invertible 2-cells Example II.5. For every pair of bicategories B and C there is a bicategory HompB, Cq of pseudofunctors, pseudonatural ah,g,f : ph ˝ gq˝ f ñ h ˝ pg ˝ fq : W Ñ Z transformations and modifications. lf : IdX ˝ f ñ f : W Ñ X Bicategories provide a convenient setting for abstractly rg : g ˝ IdX ñ g : X Ñ Y describing many categorical concepts (e.g. [44], [45]). for every f : W Ñ X, g : X Ñ Y and h : Y Ñ Definition II.6. Let B be a bicategory. Z, natural in each of their arguments and satisfying two 1) An adjunction pA,B,f,g,η,ǫq in B is a pair of objects coherence laws. pA, Bq with arrows f : A Ô B : g and 2-cells η : IdA ñ g ˝ f and ǫ : f ˝ g ñ IdB subject to two ‚ distinguished projection functors pi : 1 Ñ CpX‚; Xiq for triangle laws. 1 ď i ď n, 2) An equivalence pA,B,f,g,η,ǫq in B is a pair of objects ‚ a substitution functor pA, Bq with arrows f : A Ô B : g and invertible 2-cells m – – C C C η : IdA ùñ g ˝ f and ǫ : f ˝ g ùñ IdB. subX‚;Y‚;Z : pY‚; Zqˆ ź pX‚; Yj q Ñ pX‚; Zq 3) An adjoint equivalence is an adjunction that is also an j“1 equivalence. which we denote by The appropriate notion of equivalence between bicategories subX ;Y ;Z f, pg1,...,gmq :“ frg1,...,gms is called biequivalence [46]. ‚ ‚ ` ˘ (we write trv rw ss or trv rw s,...,v rw ss for the it- Definition II.7. A biequivalence between bicategories B and ‚ ‚ 1 ‚ n ‚ erated substitution trv rw ,...,w s,...,v rw ,...,w ss, C consists of pseudofunctors F : B Ô C : G with equivalences 1 1 l n 1 l c.f. Notation III.1), G ˝ F » idB and F ˝ G » idC in the bicategories HompB, Bq ‚ natural families of invertible 2-cells and HompC, Cq, respectively. assoct,u ,v : tru1,...,unsrv‚s ñ tru1rv‚s,...,unrv‚ss III. SIGNATURES FOR 2-DIMENSIONALTYPETHEORIES ‚ ‚ ιu : u ñ urp1,..., pns The STLC with constants is determined by a choice of base pkq ̺ : p ru1,...,u s ñ u pk “ 1,...,nq types and constant terms (e.g. [17]). For constants defined in u1,...,un k n k arbitrary contexts such a choice is determined by a multigraph; for every t P CpY‚,Zq, uj P CpX‚, Yj q, vi P CpW‚,Xiq that is, a set of nodes A ,...,A ,B,... connected by mul- 1 n and u P CpX‚, Y q (i “ 1,...,n and j “ 1,...,m). tiedges rA1,...,Ans Ñ B. A multigraph consisting solely of This data is subject to two compatibility laws: edges (i.e. multiedges of the form rAs Ñ B) is called a graph. ιru1,...,uns Notation III.1. In the following definition, and throughout, we tru1,...,uns trp1,..., pnsru1,...,uns write A‚ for a finite sequence rA1,...,Ans pn P Nq. id assoc Definition III.2. A 2-multigraph G is a set G of nodes 0 tru1,...,uns trp1ru1,...,uns,..., pnru1,...,unss 1 equipped with a graph GpA‚; Bq of edges and surfaces for tr̺p q ,...,̺pnqs every n P N and A1,...,An,B P G0. A homomorphism of 1 1 2-multigraphs h : G Ñ G is a map h : G0 Ñ G0 together with assocrw‚s assoc functions tru‚srv‚srw‚s tru‚rv‚ssrw‚s tru‚rv‚srw‚ss

1 assoc trassoc,...,assocs hA1,...,An;B : GpA‚; Bq Ñ G prhA1,...,hAns ; hBq 1 tru‚srv‚rw‚ss tru‚rv‚rw‚sss hf,g : GpA‚; Bqpf,gq Ñ G prhA1,...,hAns ; hBqphf,hgq assoc When the set S of sorts is clear we refer to an S-biclone as for every n P N, A1,...,An,B P G0 and f,g P GpA‚; Bq. simply a biclone. We denote the category of 2-multigraphs by 2-MGrph. The full 2-Grph of 2-graphs is formed by restricting Thinking of a bicategory as roughly a 2-category with struc- ture up to isomorphism, one may think of a biclone as roughly to 2-multigraphs G such that GprA1,...,Ans ; Bq “ H whenever n ‰ 1. a Cat-enriched clone with structure up to isomorphism. In- deed, the definition of clone may be generalised to hold in any IV. SUBSTITUTIONSTRUCTUREUPTOISOMORPHISM cartesian category (and even more generally, e.g. [47], [48]): The type theory we shall construct has types, terms, rewrites if the structural 2-cells ι,̺ and assoc are all the identity, a and an explicit substitution operation. It is therefore deter- biclone is equivalently a 2-clone, i.e. a clone in the cartesian mined by a 2-multigraph together with a specified substitution category Cat. We have directed the 2-cells to match the structure. Accordingly, to synthesise our language we intro- definition of a skew monoidal category [49]; the definition duce an intermediate step between 2-multigraphs and bicate- should therefore generalise to the lax setting (c.f. also the lax gories, which we call biclones. These are a bicategorification bicategories of Leinster [50, §3.4]). of the abstract clones of universal algebra [37], which capture Every S-biclone C has an underlying linear-core bicate- a presentation-independent notion of equational theory with gory Cℓc with objects S and hom-categories CℓcpX, Y q “ substitution. C`rXs ; Y ˘ (c.f. [51]). Every 2-multigraph freely induces a sorted biclone, and one may introduce bicategorical substitu- Definition IV.1. An S-biclone C is a set S of sorts tion structure into a type theory with base types, constant terms equipped with the following for all n, m P N and and constant rewrites specified by a 2-graph G by postulating X1,...,Xn,Y,Y1,...,Ym,Z P S: the structure of the free sorted biclone on G and then restricting ‚ a category CpX‚; Y q with objects 1-cells f : X‚ Ñ Y it to its underlying linear core. This is the gist of the following and morphisms 2-cells α : f ñ g : X‚ Ñ Y , section. var p1 ď k ď nq `c P GpA1,...,An; Bq˘ x1 : A1,...,xn : An $ xk : Ak const x1 : A1,...,xn : An $ cpx1,...,xnq : B

x1 : A1,...,xn : An $ t : B p∆ $ ui : Aiqi“1,...,n horiz-comp ∆ $ ttx1 ÞÑ u1,...,xn ÞÑ unu : B

Figure 1. Introduction rules on basic terms

x1 : A1,...,xn : An $ t : B ι-intro x1 : A1,...,xn : An $ ιt : t ñ ttxi ÞÑ xiu : B ´1 x1 : A1,...,xn : An $ ιt : ttxi ÞÑ xiuñ t : B

x1 : A1,...,xn : An $ xk : Ak p∆ $ ui : Aiqi“1,...,n ̺pkq -intro p1 ď k ď nq pkq ∆ $ ̺u1,...,un : xktxi ÞÑ uiuñ uk : Ak p´kq ∆ $ ̺u1,...,un : uk ñ xktxi ÞÑ uiu : Ak

y1 : B1,...,yn : Bn $ t : C px1 : A1,...,xm : Am $ vi : Biqi“1,...,n p∆ $ uj : Aj qj“1,...m assoc-intro ∆ $ assoct,v‚,u‚ : ttyi ÞÑ viutxj ÞÑ uj uñ ttyi ÞÑ vitxj ÞÑ uj uu : C ∆ assoc´1 : : $ t,v‚,u‚ ttyi ÞÑ vitxj ÞÑ uj uu ñ ttyi ÞÑ viutxj ÞÑ uj u C

Figure 2. Introduction rules on structural rewrites

1 Γ $ t : A `σ P GpA1,...,An; Bqpc, c q˘ id-intro 2-const 1 Γ $ idt : t ñ t : A x1 : A1,...,xn : An $ σpx1,...,xnq : cpx1,...,xnqñ c px1,...,xnq : B

Figure 3. Introduction rules on basic rewrites

Γ $ τ 1 : t1 ñ t2 : A Γ $ τ : t ñ t1 : A vert-comp Γ $ τ 1 ‚ τ : t ñ t2 : A

1 1 x1 : A1,...,xn : An $ τ : t ñ t : B p∆ $ σi : ui ñ ui : Aiqi“1,...,n horiz-comp 1 1 ∆ $ τtxi ÞÑ σiu : ttxi ÞÑ uiuñ t txi ÞÑ uiu : B

Figure 4. Constructors on rewrites

b x x,Ñ b Introduction rules for Λps, Λps and Λps . For Λps these rules are restricted to unary contexts.

V. A TYPE THEORY FOR BICATEGORIES term u and term t with free variable x we postulate a term ttx ÞÑ uu; this is a formal analogue of the term tru{xs We follow the tradition of 2-dimensional type theories con- defined by the meta-operation of capture-avoiding substitu- sisting of types, terms and rewrites, e.g. [24], [25], [31], [29]. tion (c.f. [35], [36]). The variable x is bound by this operation, Following Hilken [25], we consider two forms of judgement. and we work with terms up to α-equivalence defined in the Alongside the usual Γ $ t : A to indicate ‘term t has type standard way. Instead of being typed in the empty context, 1 A in context Γ’, we write Γ $ τ : t ñ t : A to indicate ‘τ G 1 constants are given by the edges of . The restriction to is a rewrite from term t of type A to term t of type A, in unary contexts ensures the syntactic model is a bicategory, context Γ’. rather than a biclone. When we construct the type theory for For now we do not want to assume our model has products bicategories with finite products we shall allow constants and so we restrict to unary contexts. Base types, constants and explicit substitution to be multi-ary. rewrites are therefore specified by a 2-graph G. The term introduction rules are collected in Figure 1 and the rewrite The grammar for rewrites is synthesised from the free introduction rules in Figures 2–4. We denote the language thus biclone on G. The structural rewrites assoc, ι and ̺ witness b defined by ΛpspGq. the three laws of a biclone; we slightly abuse notation by The terms are variables x, y, . . . , constant terms cpxq, simultaneously introducing these rewrites and their inverses. c1pxq,... and explicit substitutions ttx ÞÑ uu. Thus for every The constant rewrites σpxq are specified by the surfaces of G b b and for every term t we have an identity rewrite idt. The The bicategories SpspGq and TpspGq are biequivalent, and b explicit substitution operation mirrors that for terms while the restricted model SpspGq is free on G in the following sense. vertical composition is captured by a binary operation on Theorem V.5. Let G be a 2-graph. For any bicategory B and rewrites (c.f. [25], [29]). We make use of the same conventions 2- h : G Ñ B, there exists a unique on binding and α-equivalence as for terms. # b # strict pseudofunctor h : SpspGq Ñ B such that h ˝ ι “ h, Notation V.1. We adopt the following abuses of notation. b for ι : G ãÑ SpspGq the inclusion. 1) Writing t for id in a rewrite. t The full model T b pGq therefore satisfies the universal 2) Writing t x u n or simply t x u for ps t i ÞÑ iui“1 t i ÞÑ iu property up to biequivalence. Proving the freeness universal t x u ,...,x u , and similarly on rewrites. t 1 ÞÑ 1 n ÞÑ nu property in this way has the benefit of allowing us to establish 3) Writing c t ,...,t for the explicit substitution t 1 nu uniqueness without reasoning about uniqueness of pseudonat- c x ,...,x x t for constants c, and similarly on p 1 nqt i ÞÑ iu ural transformations or modifications. It follows that Λb is an rewrites. ps internal language for bicategories. By Example II.3, restricting The equational theory ” on rewrites is derived directly from to a single base type gives rise to an internal language for the axioms of a biclone; these are collected in Figures 5–8. monoidal categories. In this extended abstract, the rules for the invertibility of the The argument in this section applies with only minor ad- b structural rewrites and the congruence rules on ” are omitted. justments to biclones. Thus, allowing ΛpspGq to have contexts b The type theory ΛpspGq satisfies the expected well- with fixed variables over a 2-multigraph G gives rise to formedness properties (c.f. [52, Chapter 4] for STLC). Unique- the free biclone on G in the sense of Theorem V.5. This ness of typing is obtained by adding type annotations on bound relies on a straightforward generalisation of the notions of variables, constants and vertical compositions; we omit this pseudofunctor, transformation and modification. Details will extra information for readability. be given elsewhere.

VI. FP-BICATEGORIES A. The syntactic model for Λb ps We recall the notion of bicategory with finite products, b We construct the syntactic model for ΛpspGq and prove defined as a bilimit [12]. To avoid confusion with the ‘cartesian that it enjoys a 2-dimensional freeness universal property bicategories’ of Carboni and Walters [53], [54], we use the b analogous to that of [39, §2.2.1]. Put colloquially, ΛpspGq term fp-bicategories. fp-Bicategories are the objects of a is the internal language for bicategories with signature a 2- tricategory fp-Bicat. graph G. The bicategorical structure is induced directly from It is convenient to work directly with n-ary prod- the biclone structure. ucts pn P Nq. This reduces the need to deal with the equiv- alent objects given by rebracketing binary products. For bi- Construction V.2. For any 2-graph G, define a bicat- categories B ,..., B the product bicategory n B has egory T b pGq as follows. Objects are unary contexts 1 n śi“1 i ps objects pB ,...,B q P n obpB q and structure given px : Aq. The hom-category T b pGq px : Aq, py : Bq 1 n śi“1 i ps ` ˘ pointwise. An fp-bicategory is therefore a bicategory B has objects α-equivalence classes of derivable terms equipped with a right biadjoint to the diagonal pseudofunc- px : A $ t : Bq and morphisms α”-equivalence classes of tor ∆ : B Ñ Bˆn : B ÞÑ pB,...,Bq for each n P N. This rewrites px : A $ τ : t ñ t1 : Bq under vertical composition. n unwinds to the following definition. Horizontal composition is given by explicit substitution and the identity on px : Aq by the var rule px : A $ x : Aq. Definition VI.1. An fp-bicategory is a bicategory B equipped ´1 The structural l, r and a are ̺, ι and assoc, with the following data for every n P N and A1,...,An P B: respectively. 1) a product object śnpA1,...,Anq, 2) projection 1-cells π : A ,...,A A for Construction V.3. For any 2-graph G, bicategory B and k śnp 1 nq Ñ k 1 ď k ď n, 2-graph homomorphism h : G Ñ B, the semantics of b 3) for every X P B an adjoint equivalence Figure 13 restricted to TpspGq induces a strict pseudofunctor # b pπ1˝´,...,πn˝´q h : TpspGq Ñ B. # B X, A ,...,A % n B X,A The universal extension pseudofunctor h cannot be char- ` śnp 1 nq˘ śi“1 p iq (1) acterised by a strict universal property; for instance, for b x´,...,“y each type A the bicategory TpspGq contains countably many equivalent objects px : Aq for x ranging over variables. To We call the right adjoint x´,..., “y the n-ary tupling. obtain the desired universal property, we restrict to a sub- Remark VI.2. One obtains a lax n-ary product structure by bicategory in which there is a single variable name. merely asking for an adjunction in diagram (1). Sb G B Construction V.4. Let psp q denote the bicategory with Example VI.3. Every small fp-bicategory ` , Πnp´q˘ defines objects unary contexts px : Aq for x a fixed variable and an obpBq-biclone Bcℓ by setting BcℓprX1,...,Xns ; Y q to be T b G B horizontal and vertical composition operations as in psp q. `śnpX1,...,Xnq, Y ˘. Γ $ τ : t ñ t1 : A Γ $ τ : t ñ t1 : A ‚-right-unit -left-unit 1 1 ‚ Γ $ τ ‚ idt ” τ : t ñ t : A Γ $ τ ” idt1 ‚ τ : t ñ t : A

Γ $ τ 2 : t2 ñ t3 : A Γ $ τ 1 : t1 ñ t2 : A Γ $ τ : t ñ t1 : A ‚-assoc Γ $pτ 2 ‚ τ 1q ‚ τ ” τ 2 ‚pτ 1 ‚ τq : t ñ t3 : A

Figure 5. Categorical structure of vertical composition

x1 : A1,...,xn : An $ t : B p∆ $ ui : Aiqi“1,...,n id-preservation ∆ $ idttxi ÞÑ uiu” idttxiÞÑuiu : ttxi ÞÑ uiuñ ttxi ÞÑ uiu : B

1 1 x1 : A1,...,xn : An $ τ : t ñ t : B p∆ $ σi : ui ñ ui : Aiqi“1,...,n 1 1 2 1 1 2 x1 : A1,...,xn : An $ τ : t ñ t : B p∆ $ σi : ui ñ ui : Aiqi“1,...,n interchange 1 1 1 1 2 2 ∆ $ τ txi ÞÑ σiu ‚ τtxi ÞÑ σiu”pτ ‚ τqtxi ÞÑ σi ‚ σiu : ttxi ÞÑ uiuñ t txi ÞÑ ui u : B

Figure 6. Preservation rules

1 p∆ $ σi : ui ñ ui : Aiqi“1,...,n p1 ď k ď nq pkq pkq 1 ∆ $ ̺ 1 1 ‚ xktxi ÞÑ σiu” σk ‚ ̺u1,...,un : xktxi ÞÑ uiuñ uk : Ak u1,...,un

1 x1 : A1,...,xn : An $ τ : t ñ t : B 1 x1 : A1,...,xn : An $ ιt1 ‚ τ ” τtxi ÞÑ xiu ‚ ιt : t ñ t txi ÞÑ xiu : B

: : : 1 : : : : 1 : ∆ : 1 : y1 B1,...,yn Bn $ τ t ñ t C px1 A1,...,xm Am $ σi vi ñ vi Biqi“1,...,n p $ µj uj ñ uj Aj qj“1,...m 1 1 1 ∆ 1 : : $ assoct ,v‚,u‚ ‚ τtyi ÞÑ σiutxj ÞÑ µj u” τtyi ÞÑ σitxj ÞÑ µj uu ‚ assoct,v‚,u‚ ttyi ÞÑ viutxj ÞÑ uj uñ t tyi ÞÑ vitxj ÞÑ uj uu C

Figure 7. Naturality rules on structural rewrites

x1 : A1,...,xn : An $ t : B p∆ $ ui : Aiqi“1,...,n piq ∆ $ ttxi ÞÑ ̺u‚ u ‚ assoct,x‚,u‚ ‚ ιttxi ÞÑ uiu” idttxiÞÑuiu : ttxi ÞÑ uiuñ ttxi ÞÑ uiu : B

: : : z1 : C1,...,zl : Cl $ t : D px1 A1,...,xm Am $ vi Biqi“1,...,n

py1 : B1,...,yn : Bn $ wj : Ckqk“1,...,l p∆ $ uj : Aj qj“1,...m ∆ assoc assoc assoc assoc assoc $ ttzk ÞÑ wk ,v‚,u‚ u ‚ t,w‚tyj ÞÑvj u,u‚ ‚ t,w‚,v‚ txj ÞÑ uj u” t,w‚,v‚txj ÞÑuiu ‚ ttzkÞÑwk u,v‚,u‚

: ttzk ÞÑ wkutyi ÞÑ viutxj ÞÑ uj uñ ttzk ÞÑ wktyi ÞÑ vitxj ÞÑ uj uuu : D

Figure 8. Biclone laws

b x x,Ñ b Equational theory for structural rewrites in Λps, Λps and Λps . For Λps the rules are restricted to unary contexts.

Notation VI.4. for any finite family of 1-cells pti : X Ñ Aiqi“1,...,n n we require a 1-cell xt ,...,t y : X Ñ pA ,...,A q 1) We write A1ˆ¨¨¨ˆAn or Ai for pA1,...,Anq 1 n śn 1 n śi“1 śn pkq and denote the terminal object by 1. and a family of 2-cells p̟ 1 : πk ˝xt‚y ñ tkqk“1,...,n, ś0pq t ,...,tn 2) We write xfiyi“1,...,n or simply xf‚y for the n-ary universal in the sense that for any family of 2-cells tupling xf1,...,fny. pαi : πi ˝ u ñ ti :Γ Ñ Aiqi“1,...,n there exists a unique 2- cell p:pα ,...,α q : u ñxt y :Γ Ñ n A such that There are different ways of specifying the adjoint equiv- 1 n ‚ śi“1 i alence (1) (see e.g. [42, Chapter IV]). One option is to pkq : ̟ ‚ π ˝ p pα1,...,α q “ α : π ˝ u ñ t specify an invertible unit and counit subject to natural- t1,...,tn ` k n ˘ k k k ity and triangle laws. This matches the η-expansion and for k “ 1,...,n. β-reduction rules of STLC (c.f. [24], [26], [27], [29]), but Example VI.5. In any bicategory, unary-product structure may in the pseudo or lax settings requires a cumbersome pro- be chosen to be canonically given as follows: Π pAq “ A, liferation of introduction rules. Instead, we characterise the 1 πA “ Id , xty“ t and ̟ “ l : Id ˝ t ñ t. counit ̟ “ p̟p1q,...,̟pnqq as a universal arrow. Thus, 1 A t t Remark VI.6. As it is well-known, product structure On top of this, we fix a 2-multigraph G with G0 “ T0pSq. is unique up to equivalence. Given adjoint equivalences We generally abuse notation by adopting the conventions n pg : C Ô Πi“1Bi : hq and pei : Bi Ô Ai : fiqi“1,...,n in a bi- of Notation VI.4(1). For the biuniversal arrows we introduce category B, the composite distinguished constants πkppq : Ak (k “ 1,...,n) for every context p : pA ,...,A q . As for adjunction (1), we pπ1˝´,...,πn˝´q ` śn 1 n ˘

n % n postulate an operator tupp´,..., “q, a family of rewrites B X, B B X, B Πn pe ˝´q g˝´ p śi“1 iq śi“1 p iq i“1 i % % x´,...,“y pkq ̟t1,...,tn “ ̟t1,...,tn : πkttuppt1,...,tnqu ñ tk h˝´ Πn n ` ˘k“1,...,n B X,C 1pfi˝´q B X,A p q i“ śi“1 p iq (recall Notation V.1(3)) for every family of derivable terms yields an adjoint equivalence pΓ $ ti : Aiqi“1,...,n, and provide a natural bijective corre- pppe1˝π1q˝gq˝´,...,ppen˝πnq˝gq˝´ q spondence between rewrites as follows:

% n BpX, Cq BpX, A q αi : πituu ñ ti pi “ 1,...,nq śi“1 i (2) : p pα1,...,αnq : u ñ tuppt1,...,tnq h˝xf1˝´,...,fn˝“y The rules of Figure 11 achieve this by making ̟ universal: presenting C as the product of A1,...,An. this is precisely the content of Lemma VII.2 below. These x Definition VI.7. An fp-pseudofunctor pF, k q between rules define lax products. To obtain the adjoint equivalence (1) fp-bicategories `B, Πnp´q˘ and `C, Πnp´q˘ is a pseudofunc- one introduces explicit inverses for the unit and counit. In this tor F : B Ñ C equipped with adjoint equivalences extended abstract these are omitted. n n x F Ai , F pAiq, xF π1,...,Fπny, k Remark VII.1. The product structure arises from two nested ` ` śi“1 ˘ śi“1 A1,...,An ˘ universal transposition structures. We conjecture that a cal- N B for every n P and A1,...,An P . culus for fp-tricategories (resp. fp-8-categories) would have x We call pF, k q strict if F is strict and satisfies three (resp. a countably infinite tower of) such correspon- dences. F `ΠnpA1,...,Anq˘ “ ΠnpF A1,...,FAnq A1,...,An FA1,...,FAn F pπi q“ πi x A. The product structure of Λps F xt1,...,tny“xFt1,...,Ftny The product structure derives from the following universal F̟piq “ ̟piq t1,...,tn F t1,...,Ftn property of ̟. x Id kA1,...,An “ ΠnpFA1,...,FAnq Lemma VII.2. If the judgements pΓ $ αi : πituu ñ ti : x : and the adjoint equivalences are canonically induced by the Aiqi“1,...,n are derivable in ΛpspGq then p pα1,...,αnq : : – tup is the unique rewrite (modulo 2-cells p prπ1 ,..., rπn q : Id ùñxπ1,...,πny. u ñ pt1,...,tnq γ α”-equivalence) such that the following equality is derivable Thus, a strict fp-pseudofunctor strictly preserves both for k “ 1,...,n: (global) biuniversal arrows and (local) universal arrows. pkq Γ $ ̟ ‚ πktγu” αk : πituu ñ tk : Ak VII. A TYPE THEORY FOR FP-BICATEGORIES t1,...,tn b x We extend the basic language Λps to a type theory Λps From this lemma it follows that the tupp´,..., “q operator with finite products. The addition of products enables us to extends to a functor on rewrites, and that one may define the use arbitrary contexts, defined as finite lists of variable-and- unit of adjunction (1) by applying the universal property to type pairs in which variable names must not be repeated. the identity. The underlying signature is therefore a 2-multigraph and the b Definition VII.3. bicategorical structure of Λps is extended to a biclone. The additional structure required for products is synthesised 1) For every family of derivable rewrites pΓ $ τi : 1 directly from the cases in Definition VI.1. These additional ti ñ ti : Aiqi“1,...,n define tuppτ1,...,τnq : b 1 1 rules are collected in Figures 9–11. As for Λps, we work up tuppt1,...,tnq ñ tuppt1,...,tnq to be the rewrite p: p1q pnq Γ to α-equivalence of terms and rewrites. The well-formedness pτ1 ‚ ̟t1,...,tn ,...,τn ‚ ̟t1,...,tn q in context . Λb Λx Γ : properties of ps extend to ps. 2) For every derivable term $ t śnpA1,...,Anq For every n P N and types A1,...,An we introduce a define the unit ςt : t ñ tuppπ1ttu,...,πnttuq to be product type pA ,...,A q; the case n “ 0 yields the unit the rewrite p:pid ,..., id q in context Γ. śn 1 n π1ttu πnttu type 1. We fix a set of base types S and let the set of types Likewise, one obtains naturality and the triangle laws re- T pSq be generated by the grammar 0 lating the unit ς and counit ̟ “ p̟p1q,...,̟pnqq, thereby A1,...,An ::“ X P S recovering a presentation of products in the style of [24], [25], N [29]. These admissible rules are collected in Figure 12. | śnpA1,...,Anq pn P q Γ $ t1 : A1 . . . Γ $ tn : An n-pair k-proj (1 ď k ď n) Γ tup : p : pA1,...,Anq$ πkppq : Ak $ pt1,...,tnq śnpA1,...,Anq śn

Figure 9. Terms for product structure

Γ $ t1 : A1 . . . Γ $ tn : An ̟pkq-intro (1 ď k ď n) pkq Γ $ ̟t1,...,tn : πkttuppt1,...,tnqu ñ tk : Ak

Γ $ u : npA1,...,Anq Γ $ α1 : π1tuuñ t1 : A1 . . . Γ $ αn : πntuuñ tn : An ś p:-intro Γ p: : tup : $ pα1,...,αnq u ñ pt1,...,tnq śnpA1,...,Anq

Figure 10. Rewrites for product structure

Γ $ α1 : π1tuuñ t1 : A1 . . . Γ $ αn : πntuuñ tn : An U1 (1 ď k ď n) pkq : Γ $ αk ” ̟t1,...,tn ‚ πktp pα1,...,αnqu : πktuuñ tk : Ak

Γ $ γ : u ñ tuppt1,...,tnq : npA1,...,Anq ś U2 : p1q pnq Γ $ γ ” p p̟ ‚ π1tγu,...,̟ ‚ πntγuq : u ñ tuppt1,...,tnq : pA1,...,Anq t1,...,tn t1,...,tn śn Γ α α1 : π u t : A ` $ i ” i it uñ i i˘i“1,...,n cong Γ p: p: 1 1 : tup : $ pα1,...,αnq” pα1,...,αnq u ñ pt1,...,tnq śnpA1,...,Anq

Figure 11. Universal property of ̟

x Rules for ΛpspGq.

x x B. The syntactic model for Λps contexts in TpspGq with unit ς and counit ̟ “ x p̟p1q,...,̟pnqq. We construct the syntactic model for Λps and prove the freeness universal property establishing that it is the internal Lemma VII.5. For any 2-multigraph G, the following holds language of fp-bicategories. We begin with a model in which in T x pGq. we allow arbitrary variables and consider all contexts. We then ps N n : restrict to unary contexts and a single named variable (c.f. Con- 1) For any n P the n-ary product śi“1pxi Aiq exists and is given by p : n A . structions V.2 and V.4) in order to obtain a strict universal p śi“1 iq property (c.f. Theorem V.5). 2) For any context Γ “ px1 : A1,...,xn : Anq there exists an adjoint equivalence Γ Ô p : pA1,...,Anq . x ` śn ˘ Construction VII.4. Define a bicategory TpspGq as fol- lows. The objects are contexts Γ, ∆,... . The 1-cells Remark VII.6. The existence of the adjoint equivalence of Lemma VII.5(2) in T x pGq is equivalent to the existence of a Γ Ñ pyj : Bjqj“1,...,m are m-tuples of α-equivalence classes ps x pseudo-universal multimap rA1,...,Ans Ñ pA1,...,Anq of terms pΓ $ tj : Bj qj“1,...,m derivable in Λ pGq; the śn ps x G 2-cells are m-tuples of α”-equivalence classes of rewrites in the biclone associated to Λpsp q (c.f. [51]). 1 pΓ $ τ : tj ñ tj : Bj qj“1,...,m. We define products of arbitrary contexts using Remark VI.6 Vertical composition is given pointwise by the ‚ operation, and the preceding lemma. Define the product of and horizontal composition by explicit substitution: p1q p1q pnq pnq pt1,...,tlq, pu1,...,umq ÞÑ pt1txi ÞÑ uiu,...,tltxi ÞÑ uiuq pxi : Ai qi“1,...,m1 ˆ¨¨¨ˆpxi : Ai qi“1,...,mn

m1 p1q m pnq pτ1,...,τlq, pσ1,...,σmq ÞÑ pτ1txi ÞÑ σiu,...,τltxi ÞÑ σiuq p : A p : n A to be the product p 1 śi“1 i qˆ¨¨¨ˆp n śi“1 i q of unary contexts. The identity on ∆ “ pyj : Bj qj“1,...,m is given by the var rule p∆ $ yj : Bj qj“1,...,m. The structural isomorphisms l, r Corollary VII.7. For any 2-multigraph G, the syntactic model and a are given pointwise by ̺, ι´1 and assoc, respectively. x x TpspGq of ΛpspGq is an fp-bicategory. x The first step in showing that TpspGq is an fp-bicategory x TpspGq contains redundancy in two ways: as well as the is constructing n-ary products of unary contexts. Much equivalent objects given by bijectively renaming variables in of the work required is contained in the admissi- contexts, every context pxi : Aiqi“1,...,n is equivalent to the ble rules of Figure 12. For example, there is an ad- n context pp : Aiq. To obtain a strict universal property T x G : : śi“1 joint equivalence psp q`px Xq, pp śnpA1,...,Anq˘ » we cut out such multiplicities (c.f. Construction V.4). n T x G x : X , x : A śi“1 psp q`p q p i iq˘ defining products of unary pΓ $ idti : ti ñ ti : Aiqi“1,...,n Γ tup id ,..., id id : tup t ,...,t tup t ,...,t : A ,...,A $ p t1 tn q” tuppt1,...,tnq p 1 nqñ p 1 nq śnp 1 nq Γ 1 : 1 2 : Γ : 1 : p $ τi ti ñ ti Aiqi“1,...,n p $ τi ti ñ ti Aiqi“1,...,n Γ 1 1 1 1 : 2 2 : $ tuppτ1,...,τnq ‚ tuppτ1,...,τnq” tuppτ1 ‚ τ1,...,τn ‚ τnq tuppt1,...,tnqñ tuppt1 ,...,tnq śnpA1,...,Anq 1 Γ $ σ : u ñ u : npA1,...,Anq ś ς-nat 1 1 Γ 1 tup : tup : $ ςu ‚ σ ” pπ1tσu,...,πntσuq ‚ ςu u ñ pπ1tu u,...,πntu uq śnpA1,...,Anq 1 pΓ $ τi : ti ñ ti : Aiqi“1,...,n ̟pkq-nat p1 ď k ď nq pkq pkq Γ $ ̟ 1 1 ‚ πkttuppτ1,...,τnqu ” τk ‚ ̟t1,...,t : πkttuppt1,...,tnqu ñ tk : Ak t1,...,tn n

Γ $ tuppt1,...,tnq : npA1,...,Anq ś triangle-law-1 p1q pnq Γ $ tupp̟ ,...,̟ q ‚ ς ” id : tuppt qñ tuppt q : pA1,...,Anq t‚ t‚ tuppt‚q tuppt‚q ‚ ‚ śn

Γ $ πktuu : Ak triangle-law-2 p1 ď k ď nq pkq Γ $ ̟t1,...,tn ‚ πktςuu” idπktuu : πktuuñ πktuu : Ak

Λx Figure 12. Admissible rules for pspGq

hJXK :“ hpXq for X a base type : n hJśnpB1,...,BnqK “ śi“1hJBiK hJA “⊲ BK :“ hJAK “⊲ hJBK : : : n hJx1 A1,...,xn AnK “ śi“1hJAiK on n-ary contexts

A1,...,An hJx1 : A1,...,xn : An $ xk : AiK :“ πk hJx1 : A1,...,xn : An $ cpx1,...,xnq : BK :“ hpcq for c P GpA‚; Bq

Ai n hJ∆ $ ttxi ÞÑ uiui“1 : BK :“ hJx1 : A1,...,xn : An $ t : BK ˝xhJ∆ $ ui : AiKyi“1,...,n Γ tup : : Γ : Γ : hJ $ pt1,...,tnq śnpB1,...,BnqK “xhJ $ t1 B1, K,...,hJ $ tn BnKy : : : B1,...,Bn hJp śnpB1,...,Bnq$ πkppq BkK “ πk hJf : A “⊲ B,a : A $ evalpf,aq : BK :“ evalA,B hJΓ $ λx.t : A “⊲ BK :“ λ`hJΓ, x : A $ t : BK˝» ˘

hJΓ $ idt : t ñ t : BK :“ idhJΓ$t:BK 1 1 hJx1 : A1,...,xn : An $ σpx‚q : cpx‚q ñ c px‚q : BK :“ hpσq for σ P GpA‚,Bqpc,c q pkq pkq hJΓ $ ̟ : πkttuppt1,...,tnqu ñ tk : BkK :“ ̟ t1,...,tn hJt1K,...,hJtnK : : hJΓ $ p pα1,...,αnq : u ñ tuppt1,...,tnq : śnpB1,...,BnqK :“ p phJΓ $ αi : πituu ñ ti : BiKqi“1,...,n hJΓ, x : A $ ǫt : evaltpλx.tqtincxu, xu ñ t : BK :“ ǫphJΓ,x:A$t:BK˝»q : : hJΓ $ e px.αq : u ñ λx.t : A “⊲ BK :“ e phJΓ, x : A $ α : evaltutincxu, xu ñ t : BK˝ »q hJΓ $ τ 1 ‚ τ : t ñ t2 : BK :“ hJΓ $ τ 1 : t1 ñ t2 : BK ‚ hJΓ $ τ : t ñ t1 : BK

Ai n Ai n 1 Ai 1 n 1 hJ∆ $ τtxi ÞÑ σiui“1 : ttxi ÞÑ uiui“1 ñ t txi ÞÑ uiui“1 : BK :“ hJx1 : A1,...,xn : An $ τ : t ñ t : BK 1 ˝xhJ∆ $ σi : ui ñ ui : AiKyi“1,...,n

Figure 13. Bicategorical semantics x x “⊲ x Construction VII.8. Let SpspGq denote the bicategory with A CC-pseudofunctor pF, k , k q is strict if pF, k q is strict objects unary contexts px : Aq for x a fixed variable and and satisfies horizontal and vertical composition operations as in T x pGq. ps F pA “⊲ Bq “ pF A “⊲ FBq The product structure of T x pGq restricts to Sx pGq and the ps ps F pevalFA,FBq“ evalFA,FB two bicategories are equivalent as fp-bicategories. To obtain x F pλtq“ λpFtq the freeness universal property for TpspGq with respect to 2- x F ǫ ǫ multigraphs G, it suffices to show that SpspGq is the free p tq“ F t G “⊲ fp-bicategory for 2-graphs . Universal extensions are induced kA,B “ IdFA “⊲ F B by the semantics in Figure 13 restricted to Sx pGq. ps and the adjoint equivalences are canonically induced by the – Theorem VII.9. Let G be a 2-graph with G0 “ T0pSq : 2-cells e pκq : IdFA “⊲ F B ùñ λpevalFA,FBq where κ is the for a set of base types S. For every fp-bicategory B following composite of canonical 2-cells and 2-graph homomorphism h : G Ñ B such that ˝ pId ˆ F Aq– eval ˝ Id – eval h`ΠnpA1,...,Anq˘ “ ΠnphA1,...,hAnq, there exists a FA,FB FA,FB FA,FB # x unique strict fp-pseudofunctor h : SpspGq Ñ B such that # x TYPE THEORY FOR CARTESIAN CLOSED h ˝ ι “ h, where ι : G ãÑ SpspGq denotes the inclusion. IX. A BICATEGORIES VIII. CARTESIAN CLOSED BICATEGORIES x x,Ñ We extend Λps to the full language Λps by synthesising To give a cartesian closed structure on an fp-bicategory B the additional rules from the cases of Definition VIII.1; these is to specify a biadjunction p´q ˆ A % pA “⊲ ´q for each rules are Figures 14–16. object A P B. Cartesian closed bicategories are the objects of We extend the grammar for types with an arrow type a tricategory CCBicat. former p´q“⊲p“q. We henceforth fix a set of base types S, T Definition VIII.1. A cartesian closed bicategory or let pSq denote the set of all types over S, and consider 2-multigraphs G with set of nodes G T S . CC-bicategory is an fp-bicategory B, Π p´q equipped with 0 “ p q ` n ˘ We postulate a constant eval f, x for every context the following data for every A, B P B: p q pf : A “⊲ B, x : Aq; the usual application operation becomes 1) an pA “⊲ Bq, a derived rule: 2) an evaluation 1-cell evalA,B : pA “⊲ Bqˆ A Ñ B, ⊲ 3) for every X P B an adjoint equivalence Γ $ t : A “ B Γ $ u : A Γ $ evaltt,uu : B evalA,B ˝p´ˆAq The adjunction (3) requires the functor p´q ˆ A on the syntac- % BpX, A “⊲ Bq BpX ˆ A, Bq (3) tic model. As for STLC, this corresponds to context extension

λ and an associated notion of weakening. The explicit nature of substitution in our type theory gives rise to correspondingly Remark VIII.2. The uniqueness of exponentials up to equiv- explicit structural operations on contexts. alence manifests itself in the same way as for products. For instance, given an adjoint equivalence e : E » pA “⊲ Bq : f, Definition IX.1. A context renaming the object E inherits an exponential structure by composition with e and f (c.f. Remark VI.6). r : pxi : Aiqi“1,...,n Ñ pyj : Bj qj“1,...,m

As for products, we choose to define the adjunction (3) is a map r : tx1,...,xnuÑty1,...,ymu such that Ai “ Bj by characterising its counit ǫ as a universal arrow (c.f. the whenever rpxiq“ yj. discussion after Notation VI.4). Thus, for every 1-cell It is immediate that for every context renaming r :Γ Ñ ∆ ⊲ t : X ˆ A Ñ B we require a 1-cell λt : X Ñ pA “ Bq and x,Ñ the following rules are admissible in Λps pGq: a 2-cell ǫt : evalA,B ˝ pλt ˆ Aq ñ t that is universal in the sense that for any 2-cell α : evalA,B ˝ pu ˆ Aq ñ t Γ $ t : A r :Γ Ñ ∆ : there exists a unique 2-cell e pαq : u ñ λt such that ∆ $ ttxi ÞÑ rpxiqu : A : ǫt ‚ evalA,B ˝ pe pαqˆ Aq “ α. ` ˘ Γ $ τ : t ñ t1 : A r :Γ Ñ ∆ 1 Definition VIII.3. A cartesian closed pseudofunctor or ∆ $ τtxi ÞÑ rpxiqu : ttxi ÞÑ rpxiqu ñ t txi ÞÑ rpxiqu : A CC-pseudofunctor between CC-bicategories B, Π p´q, “⊲ ` n ˘ Notation IX.2. For a context renaming r we write ttru and and C, Π p´q, “⊲ is an fp-pseudofunctor pF, kxq equipped ` n ˘ τtru for the terms and rewrites formed using the preceding with equivalences admissible rules. ⊲ ⊲ “⊲ `F pA “ Bq, pF A “ FBq,sA,B, kA,B˘ Weakening arises by taking the inclusion of contexts ã for every A, B P B, where sA,B : F pA “⊲ Bq Ñ incx :Γ Ñ pΓ, x : Aq. For the counit of (3) we therefore pF A “⊲ FBq is the transpose of postulate a rewrite

x ⊲ F pevalA,Bq˝ kA “⊲ B,A : F pA “ Bqˆ F A Ñ FB ǫt : evaltpλx.tqtincxu, xu ñ t Γ,x : A $ t : B lam eval Γ $ λx.t : A “⊲ B f : A “⊲ B,a : A $ evalpf,aq : B

Figure 14. Terms for cartesian closed structure

Γ,x : A $ t : B Γ $ u : A “⊲ B Γ,x : A $ t : B ǫ-intro Γ,x : A $ α : evaltutincxu,xuñ t : B Γ,x : A $ ǫt : evaltpλx.tqtincxu,xuñ t : B e:-intro Γ $ e:px.αq : u ñ λx.t : A “⊲ B

Figure 15. Rewrites for cartesian closed structure

Γ,x : A $ α : evaltutincxu,xuñ t : B U1 : Γ,x : A $ α ” ǫt ‚ evalte px.αqtincxu,xu : evaltutincxu,xuñ t : B Γ $ γ : u ñ λx.t : A “⊲ B U2 : Γ $ γ ” e px.ǫt ‚ evaltγtincxu,xuq : u ñ λx.t : A “⊲ B

1 Γ,x : A $ α ” α : evaltutincxu,xuñ t : B cong Γ $ e:px.αq” e:px.α1q : u ñ λx.t : A “⊲ B

Figure 16. Universal property of ǫ

x,Ñ Rules for Λps pGq.

Γ,x : A $ t : B Γ,x : A $ τ 1 : t1 ñ t2 : B Γ,x : A $ τ : t ñ t1 : B ⊲ 1 1 2 Γ $ λx.idt ” idλx.t : λx.t ñ λx.t : A “ B Γ $ λx.pτ ‚ τq”pλx.τ q ‚pλx.τq : λx.t ñ λx.t : A “⊲ B

Γ $ σ : u ñ u1 : A “⊲ B η-nat 1 Γ $ ηu1 ‚ σ ” λx.evaltσtincxu,xu ‚ ηu : u ñ λx.evaltu tincxu,xu : A “⊲ B Γ,x : A $ τ : t ñ t1 : B ǫ-nat 1 Γ,x : A $ τ ‚ ǫt ” ǫt1 ‚ evaltpλx.τqtincxu,xu : evaltpλx.tqtincxu,xuñ t : B Γ,x : A $ t : B triangle-law-1 Γ $pλx.ǫtq ‚ ηt ” idλx.t : λx.t ñ λx.t : A “⊲ B Γ $ u : A “⊲ B triangle-law-2 Γ,x : A $ ǫevaltutincxu,xu ‚ evaltηutincxu,xu” idevaltutincxu,xu : evaltutincxu,xuñ evaltutincxu,xu : B

x,Ñ Figure 17. Admissible rules for Λps pGq for every term t typeable in a context extended by the in Figures 15–16; these provide lax exponentials (c.f. [25]). variable x. Finally, one requires explicit inverses for the unit and counit. The encoding of the universal property of ǫt in the type In this extended abstract they are omitted. theory yields a bijective correspondence of rewrites modulo α”-equivalence as follows (c.f. (2)): Remark IX.3. As for products (c.f. Remark VII.1), we obtain a nesting of two universal transposition structures. In the px : Aq α : evaltutincxu, xu ñ t : B same vein, we conjecture that a calculus for cartesian closed : e px.αq : u ñ λx.t : A “⊲ B tricategories (cartesian closed 8-categories) would have three (a countably infinite tower of) of such correspondences. In- where we write px : Aq to indicate that the variable deed, this should extend to general type structures arising from x of type A is in the context (c.f. [30]). Our approach weak adjunctions. to achieving this matches that for products. For every rewrite α : evaltutincxu, xu ñ t we introduce the rewrite e:px.αq : u ñ λx.t and make it unique in inducing a fac- We continue to work up to α-equivalence of terms and b x torisation of α through ǫt; the variable x is bound by this rewrites. The well-formedness properties of Λps and Λps x,Ñ operation. The rules governing this construction are given to Λps . x,Ñ x,Ñ A. Cartesian closed structure of Λps Corollary IX.9. The syntactic model Tps pGq is a The ǫ-introduction rule (Figure 15) only ‘evaluates’ lambda CC-bicategory. abstractions at variables. The general form of explicit From Sections V-A and VII-B one might expect that restrict- β-reduction is derivable. ing to a sub-bicategory with unary contexts and a fixed variable Definition IX.4. For derivable terms Γ, x : A $ t : B and name is sufficient to obtain the required freeness universal property. This suggests the following definition. Γ $ u : A define βx.t,u : evaltλx.t, uu ñ ttidΓ, x ÞÑ uu to be the rewrite ǫ id , x u τ in context Γ (recall Nota- x,Ñ tt Γ ÞÑ u‚ Construction IX.10. Let Sps pGq denote the bicategory with tion IX.2), where τ is a composite of structural isomorphisms. objects unary contexts px : Aq for x a fixed variable and T x,Ñ G As expected, the remaining exponential structure follows horizontal and vertical composition operations as in ps p q. from the universal property of ǫ (c.f. Lemma VII.2). x,Ñ The cartesian closed structure of Tps pGq restricts to x,Ñ Lemma IX.5. For every rewrite pΓ, x : A $ α : Sps pGq and the two are equivalent as cartesian closed bicate- x,Ñ : evaltutincxu, xu ñ t : Bq in Λps pGq, the rewrite e px.αq gories. However, one does not obtain a strict freeness universal is the unique γ (modulo α”-equivalence) such that property. We recover uniqueness by restricting to cartesian closed bicategories in which the product structure is strict. Γ,x : A $ α ” ǫt ‚ evaltγtincxu,xu : evaltutincxu,xuñ t : B G G It follows that the lambda-abstraction operator extends to a Theorem IX.11. Let be a 2-graph with 0 “ TpSq functor, and we obtain a unit for the adjunction (3). for a set of base types S. For every cartesian 2-category (i.e. 2-category with 2-categorical products) with pseudo- Definition IX.6. exponentials C and every 2-graph homomorphism h : G Ñ C 1 1) For any derivable rewrite pΓ, x : A $ τ : t ñ t : Bq de- such that h`ΠnpA1,...,Anq˘ “ ΠnphA1,...,hAnq and 1 : ⊲ ⊲ fine λx.τ : λx.t ñ λx.t to be the rewrite e px.τ ‚ ǫtq hpA “ Bq “ phA “ hBq, there exists a unique strict # x,Ñ # in context Γ. CC-pseudofunctor h : Sps pGq Ñ C such that h ˝ ι “ h, ⊲ x,Ñ 2) For any derivable term pΓ $ u : A “ Bq define the for ι : G ãÑ Sps pGq the inclusion. unit η : u λx.eval u inc , x to be the rewrite u ñ t t xu u Thus, one obtains the same result as for Sections V-A e:px.id q in context Γ. evaltutincxu,xu and VII-B, albeit with a restricted freeness universal property. The unit η and counit ǫ satisfy naturality and triangle laws, This, modulo the coherence result of Power [14] applied to collected in Figure 17. Thus we recover the unit-counit presen- fp-bicategories, yields that tation of both products and exponentials (c.f. [24], [25], [29]). x,Ñ Λps is the internal language of x,Ñ B. The syntactic model for Λps cartesian closed bicategories. We finally turn to constructing the syntactic model for In fact, it is possible to adjust the definition of exponentials x,Ñ Λps pGq and proving its freeness universal property. The con- to obtain another type theory for which the induced syntactic struction of the syntactic model follows the pattern established models are equivalent as CC-bicategories to those above and b x by Λps and Λps. satisfy a strict freeness universal property with respect to arbi- trary CC-bicategories. This type theory is however no longer Construction IX.7. Define a bicategory T x,ÑpGq as fol- ps in the spirit of STLC, and so will be presented elsewhere. lows. The objects are contexts Γ, ∆,... . The 1-cells Γ Ñ pyj : Bjqj“1,...,m are m-tuples of α-equivalence classes ACKNOWLEDGEMENTS x,Ñ G of terms pΓ $ tj : Bj qj“1,...,m derivable in Λps p q; We thank Dylan McDermott and Ian Orton for helpful 2-cells are m-tuples of α”-equivalence classes of rewrites discussions on type theories with weak substitution. 1 pΓ $ τ : tj ñ tj : Bj qj“1,...,m. Horizontal and vertical com- position are as in Construction VII.4. REFERENCES T x,Ñ G T x G [1] J. B´enabou, “Introduction to bicategories,” in Reports of the Midwest ps p q inherits the product structure of psp q. To con- Category Seminar. Springer Berlin Heidelberg, 1967, pp. 1–77. struct cartesian closed structure it suffices to construct ex- [2] R. Street, “Categorical structures,” in Handbook of Algebra, ponentials of unary contexts. Much of the work required is M. Hazewinkel, Ed. Elsevier, 1995, vol. 1, ch. 15, pp. 529–577. [3] G.L. Cattani, M. Fiore, and G. Winskel, “A theory of recursive domains contained in the admissible rules of Figure 17. with applications to concurrency,” in Proceedings of the 13th Annual IEEE Symposium on Logic in Computer Science. IEEE Computer Lemma IX.8. For unary contexts px : Aq, py : Bq, the expo- Society, 1998, pp. 214–225. ⊲ x,Ñ nential px : Aq“ py : Bq in Tps pGq exists and is given by [4] S. Castellan, P. Clairambault, S. Rideau, and G. Winskel, pf : A “⊲ Bq. “Games and strategies as event structures,” Logical Methods in Computer Science, vol. 13, no. 3, 2017. [Online]. Available: Using Remark VIII.2 and the preceding lemma, we define https://doi.org/10.23638/LMCS-13(3:35)2017 [5] M. G. Abbott, “Categories of containers,” Ph.D. dissertation, University ⊲ the exponential object pΓ “ ∆q for Γ:“ pxi : Aiqi“1,...,n and of Leicester, 2003. ∆ :“ pyj : Bjqj“1,...,m using the equivalent unary contexts, as [6] P.-E. Dagand and C. McBride, “A categorical treatment of ornaments,” in Proceedings of the 28th Annual ACM/IEEE Symposium on Logic in : ⊲ : Computer Science. IEEE Computer Society, 2013, pp. 530–539. `p śnpA1,...,Anq˘ “ `q śmpB1,...,Bmq˘. [7] M. Fiore, N. Gambino, M. Hyland, and G. Winskel, “The cartesian [31] D. R. Licata and R. Harper, “2-dimensional directed type theory,” closed bicategory of generalised species of structures,” Journal of the Electronic Notes in Theoretical Computer Science, vol. 276, pp. 263– London Mathematical Society, vol. 77, no. 1, pp. 203–220, 2007. 289, 2011, twenty-seventh Conference on the Mathematical Foundations [8] N. Gambino and J. Kock, “Polynomial functors and polynomial monads,” of Programming Semantics (MFPS XXVII). Mathematical Proceedings of the Cambridge Philosophical Society, vol. [32] P.-L. Curien, “Substitution up to isomorphism,” Fundam. Inf., vol. 19, 154, no. 1, pp. 153–192, 2013. no. 1-2, pp. 51–85, Sep. 1993. [9] M. Fiore and A. Joyal, “Theory of para-,” talk at [33] The Program, : Uni- the 2015 Conf., Departamento de Matematica, valent Foundations of Mathematics. Institute for Advanced Study: Universidade de Aveiro, Aveiro (Portugal), 2015. [Online]. Available: https://homotopytypetheory.org/book, 2013. http://sweet.ua.pt/dirk/ct2015/abstracts/fiore m.pdf [34] E. Riehl and M. Shulman, “A type theory for synthetic 8-categories,” [10] N. Gambino and A. Joyal, “On operads, bimodules and analytic func- Higher Structures, vol. 1, no. 1, pp. 147–224, November 2017. tors,” Memoirs of the American Mathematical Society, vol. 249, no. 1184, [35] M. Abadi, L. Cardelli, P.-L. Curien, and J.-J. Levy, “Explicit substitu- pp. 153–192, 2017. tions,” in Proceedings of the 17th ACM SIGPLAN-SIGACT Symposium [11] M. Fiore, N. Gambino, M. Hyland, and G. Winskel, “Relative pseu- on Principles of Programming Languages, ser. POPL ’90. ACM, 1990, domonads, Kleisli bicategories, and substitution monoidal structures,” pp. 31–46. Selecta Mathematica New Series, 2017. [36] E. Ritter and V. de Paiva, “On explicit substitutions and names (ex- [12] J. W. Gray, Formal Category Theory: Adjointness for 2-Categories, ser. tended abstract),” in Automata, Languages and Programming, P. Degano, Lecture Notes in Mathematics. Springer, 1974, vol. 391. R. Gorrieri, and A. Marchetti-Spaccamela, Eds. Springer Berlin [13] S. Mac Lane and R. Par´e, “Coherence for bicategories and indexed Heidelberg, 1997, pp. 248–258. categories,” Journal of Pure and Applied Algebra, vol. 37, pp. 59–80, [37] B. Plotkin, Universal Algebra, Algebraic Logic, and Databases. 1985. Springer, 1994. [14] A. J. Power, “Coherence for bicategories with finite bilimits I,” in [38] R. Gordon, A. Power, and R. Street, Coherence for tricategories. Categories in Computer Science and Logic: Proceedings of the AMS- Memoirs of the American Mathematical Society, 1995. IMS-SIAM Joint Summer Research Conference Held June 14-20, 1987, [39] N. Gurski, Coherence in Three-Dimensional Category Theory. Cam- J. W. Gray and A. Scedrov, Eds. American Mathematical Society, 1989, bridge University Press, 2013. vol. 92, pp. 341–349. [40] Agda contributors, “The Agda proof assistant,” [15] P. T. Johnstone, Sketches of an Elephant. Oxford University Press, https://wiki.portal.chalmers.se/agda/pmwiki.php. 2002. [41] A. J. Power, “2-categories,” BRICS Notes Series, 1998. [16] N. Gambino and M. Hyland, “Wellfounded trees and dependent polyno- [42] S. Mac Lane, Categories for the Working Mathematician, 2nd ed., ser. mial functors,” in Types for Proofs and Programs, S. Berardi, M. Coppo, Graduate Texts in Mathematics. Springer-Verlag New York, 1998, and F. Damiani, Eds. Springer Berlin Heidelberg, 2004, pp. 210–225. vol. 5. [17] J. Lambek, “Cartesian closed categories and typed lambda- calculi,” in [43] T. Fiore, Pseudo Limits, Biadjoints, and Pseudo Algebras: Categorical Proceedings of the Thirteenth Spring School of the LITP on Combinators Foundations of Conformal Field Theory, ser. Memoirs of the American and Functional Programming Languages. Springer-Verlag, 1986, pp. Mathematical Society. AMS, 2006. 136–175. [44] F. W. Lawvere, “Adjoints in and among bicategories,” in Logic & [18] M. Makkai and G. Reyes, First Order Categorical Logic: Model- Algebra, ser. Lecture Notes in Pure and Applied Algebra, vol. 180, 1996, Theoretical Methods in the Theory of Topoi and Related Categories. pp. 181–189. Springer, 1977. [45] S. Lack and R. Street, “Skew monoidales, skew warpings and quantum [19] A. Church, “A formulation of the simple theory of types,” The Journal categories,” Theory and Applications of Categories, 2012. of Symbolic Logic, vol. 5, no. 2, pp. 56–68, 1940. [46] R. Street, “Fibrations in bicategories,” Cahiers de Topologie et [20] M. Fiore, “An algebraic combinatorial approach to opetopic G´eom´etrie Diff´erentielle Cat´egoriques, vol. 21, no. 2, pp. 111–160, 1980. structure,” talk at the Seminar on Higher Structures, Program [47] S. Staton, “An algebraic presentation of predicate logic,” in Foundations on Higher Structures in Geometry and Physics, Max Planck of Software Science and Computation Structures, F. Pfenning, Ed. Institute for Mathematics, Bonn (Germany), 2016. [Online]. Available: Springer Berlin Heidelberg, 2013, pp. 401–417. https://www.mpim-bonn.mpg.de/node/6586 [48] M. Fiore, “On the concrete representation of discrete enriched abstract [21] N. Yamada and S. Abramsky, “Dynamic game semantics,” arXiv, 2018. clones,” Tbilisi Mathematical Journal, vol. 10, no. 3, pp. 297–328, 2017. [Online]. Available: https://arxiv.org/abs/1601.04147 [49] K. Szlach´anyi, “Skew-monoidal categories and bialgebroids,” Advances [22] D. E. Rydeheard and J. G. Stell, “Foundations of equational deduction: in Mathematics, vol. 231, no. 3, pp. 1694–1730, 2012. A categorical treatment of equational proofs and unification algorithms,” [50] T. Leinster, Higher operads, higher categories, ser. London Mathemat- in Category Theory and Computer Science, D. H. Pitt, A. Poign´e, and ical Society Lecture Note Series. Cambridge University Press, 2004, D. E. Rydeheard, Eds. Springer Berlin Heidelberg, 1987, pp. 114–139. no. 298. [23] A. J. Power, “An abstract formulation for rewrite systems,” in Category [51] C. Hermida, “Representable multicategories,” Advances in Mathematics, Theory and Computer Science, D. H. Pitt, D. E. Rydeheard, P. Dybjer, vol. 151, no. 2, pp. 164–225, 2000. A. M. Pitts, and A. Poign´e, Eds. Springer Berlin Heidelberg, 1989, pp. [52] R. L. Crole, Categories for Types. Cambridge University Press, 1994. 300–312. [53] A. Carboni and R. Walters, “Cartesian bicategories I,” Journal of Pure [24] R. A. G. Seely, “Modelling computations: A 2-categorical framework,” and Applied Algebra, vol. 49, no. 1, pp. 11–32, 1987. in Proceedings of the Second Annual IEEE Symp. on Logic in Computer [54] A. Carboni, G. Kelly, R. Walters, and R. Wood, “Cartesian bicategories Science, D. Gries, Ed. IEEE Computer Society Press, June 1987, pp. II,” Theory and Applications of Categories, vol. 19, no. 6, pp. 93–124, 65–71. 2008. [25] B. P. Hilken, “Towards a proof theory of rewriting: the simply typed 2λ- calculus,” Theoretical Computer Science, vol. 170, no. 1, pp. 407–444, 1996. [26] C. B. Jay and N. Ghani, “The virtues of eta-expansion,” Journal of Functional Programming, vol. 5, no. 2, pp. 135–154, 1995. [27] N. Ghani, “Adjoint rewriting,” Ph.D. dissertation, University of Edin- burgh, 1995. [28] N. Tabareau, “Aspect oriented programming: A language for 2- categories,” in Proceedings of the 10th International Workshop on Foundations of Aspect-oriented Languages, ser. FOAL ’11. ACM, 2011, pp. 13–17. [29] T. Hirschowitz, “Cartesian closed 2-categories and permutation equiva- lence in higher-order rewriting,” Logical Methods in Computer Science, vol. 9, pp. 1–22, 07 2013. [30] P. Martin-L¨of, Intuitionistic Type Theory. Bibliopolis, 1984.