Functors are Type Refinement Systems


 Vernon Floyd
 3 years ago
 Views:
Transcription
1 Functors are ype Reinement Systems PaulAndré Melliès CNRS, niversité Paris Diderot Sorbonne Paris Cité Noam Zeilberer MSRInria Joint Centre Abstract he standard readin o type theory throuh the lens o cateory theory is based on the idea o viewin a type system as a cateory o welltyped terms. We propose a basic revision o this readin: rather than interpretin type systems as cateories, we describe them as unctors rom a cateory o typin derivations to a cateory o underlyin terms. hen, turnin this around, we explain how in act any unctor ives rise to a eneralized type system, with an abstract notion o typin judment, typin derivations and typin rules. his leads to a purely cateorical reormulation o various natural classes o type systems as natural classes o unctors. he main purpose o this paper is to describe the eneral ramework (which can also be seen as providin a cateorical analysis o reinement types), and to present a ew applications. As a larer case study, we revisit Reynolds paper on he Meanin o ypes (2000), showin how the paper s main results may be reconstructed alon these lines. F.3.2 [Semantics o Pro Cateories and Subject Descriptors rammin Lanuaes] Keywords 1. Introduction type theory cateory theory reinement types One basic diiculty with type theory as a mathematical theory is that in practice, the word type actually covers two very dierent usaes: 1. Sometimes, like the syntactician s parts o speech, types serve to deine the basic rammar o wellormed expressions in this usae, all expressions carry a type, and there is no need (or even sense) to consider the meanin o untyped expressions. 2. Other times, like the semanticist s predicates, types serve as a way o identiyin subsets o expressions with certain desirable properties in this usae, every expression carries an independent meanin, and typin judments serve to assert some property o that meanin. Permission to make diital or hard copies o all or part o this work or personal or classroom use is ranted without ee provided that copies are not made or distributed or proit or commercial advantae and that copies bear this notice and the ull citation on the irst pae. Copyrihts or components o this work owned by others than the author(s) must be honored. Abstractin with credit is permitted. o copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior speciic permission and/or a ee. Request permissions rom POPL 15, January 15 17, 2015, Mumbai, India. Copyriht is held by the owner/author(s). Publication rihts licensed to ACM. ACM /15/01... $ hese two dierent uses o types are oten associated respectively with Alonzo Church and Haskell Curry (hence types à la Church and types à la Curry ), while John Reynolds reerred to these as the intrinsic and the extrinsic views o typin in his book, heories o Prorammin Lanuaes [30]. raditionally, readins o type theory throuh the lens o cateory theory have sided towards the intrinsic ( à la Church ) view. his is natural iven the analoy type system cateory which observes or example that a welltyped term x 1 : A 1,..., x n : A n e : B o the simplytyped lambda calculus may be interpreted as a morphism A 1 A n e B in a cartesianclosed cateory [17]. his avors the intrinsic interpretation, since any morphism o a cateory A is intrinsically associated with a pair o types, namely, its domain dom( ) = A and codomain cod( ) = B. On the other hand, there are typetheoretic situations where such an interpretation is plainly problematic. For example, type systems includin a notion o intersection or subtypin Γ e : B Γ e : C Γ e : B C B Γ e : B B C Γ e : C involve makin multiple judments about the same expression, but in a cateory, it is not even rammatical to write the same morphism between a dierent pair o objects 1 * A A B C What Reynolds oriinally observed [29, 30] is that an intrinsic semantics or such a type system must really interpret typin derivations rather than terms. his leads to questions o coherence (i.e., whether two derivations o the same typin judment have the same meanin), and in later work [31], Reynolds ave a particularly eleant proo o coherence, as a corollary to a pair o more eneral results (a loical relations theorem and a bracketin theorem) relatin an intrinsic semantics o typin derivations to an extrinsic semantics deined directly on untyped terms. 1 Here and below we adopt the linuist s practice o writin an asterisk to the let o an expression which is unrammatical (with respect to some linuistic conventions made clear rom context).
2 Conceptually, Reynolds intrinsic semantics may be ormulated as a unctor D : Derivations Meanins rom a cateory o typin derivations to some semantic cateory o meanins, while his extrinsic semantics may be seen as a unctor : erms Meanins rom a cateory o untyped terms to the same cateory o meanins. On the other hand, albeit somewhat hidden in Reynolds oriinal analysis, implicitly there is also a oretul unctor : Derivations erms rom typin derivations to terms, since every typin derivation is about some underlyin term. he loical relations and bracketin theorems can then be phrased as describin relationships amon these three unctors. Our startin point here will be the observation that this analysis may be turned around: in act, any unctor : D may be alternatively viewed as a type system in a eneralized sense, i we interpret the (arbitrary) cateory D as a cateory o typin derivations and the (arbitrary) cateory as a cateory o terms. his will lead us to a purely cateorical way o speakin about typin derivations and terms but also conversely to a purely typetheoretic way o speakin about unctors. In some ways, this very abstract view oes back to ideas developed ater Grothendieck, in particular by Jean Bénabou, who promoted the idea that any unctor may be seen as a eneralized ibration [2] (we will describe how Grothendieck ibrations themselves can be expressed quite naturally in typetheoretic terms, as type systems with inverse imae types ). Our approach is also closely related to and partly inspired by the concept o reinement in type theory, viewin as the unctor which orets reinement inormation. In the paper, we will adopt some o the lanuae typically used to speak about reinement type systems [27] in order to speak about eneral unctors in eect providin a simple and natural cateorical semantics o reinement types. 2. Readin a unctor as a reinement system For completeness and in order to ix notations, we bein by recallin the ormal deinitions o cateory and unctor. Deinition 1. A cateory consists o: A collection o objects (A, B,... ). A collection o morphisms (,,... ), toether with operations dom and cod assinin to each morphism a unique source and taret. We write : A B to indicate that dom( ) = A and cod( ) = B. Composition and identity: or any pair o morphisms : A B and : B C, a morphism ( ) : A C, as well as or every object A, a morphism id A : A A (we oten omit the subscript on id when it can be deduced rom context). Such that associativity and unit laws hold: ( ) h = ( h) id = = id Deinition 2. Let D and be cateories. We say that is a unctor rom D to when it determines the ollowin: or each object S o D, an object (S) o, and or each morphism : S o D, a morphism () : (S) () o, such that composition and identity are preserved: ( ) = (() ()) (id S ) = id (S) Now, or the remainder o the section we will assume a ixed, arbitrary unctor : D, and consider various notions relative to. Deinition 3. We say that an object S D reines an object A i (S) = A. Deinition 4. A typin judment is a triple (S,, ) such that S and reine the domain and codomain o, respectively, i.e., such that : A B, (S) = A and () = B, or some arbitrary A and B. In the special case where = id (implyin that (S) = ()), we also call this a subtypin judment. Deinition 5. A derivation o a typin judment (S,, ) is a morphism : S in D such that () =. We emphasize aain that these deinitions are all parameterized by a ixed unctor, and in some situations to be completely explicit we could speak o reinement, typin judments, and so on. In i. 1, we ive a raphical illustration o the deinitions relative to a ew miniature examples. Alon with these deinitions, we introduce some notation (also appearin in i. 1) and conventions inspired rom loic and proo theory: 1. We write S A to indicate that S reines A (i.e., (S) = A). In eneral, we reer to objects o as types, to objects o D as reinement types, and to morphisms o as terms. 2. We write to indicate that (S,, ) is a typin judment in the sense o Den. 4 (i.e., (S) = dom( ) and () = cod( )), and to indicate that (, id, ) is a subtypin judment (i.e., () = ()). Since subtypin is just a special case o typin, the two judments and = id have precisely the same meanin. 3. We write to indicate that is a derivation o the typin judment (S,, ) in the sense o Den. 5 (i.e., : S and () = ). We also write to simply indicate that such a derivation exists (without namin it), or to indicate the absence o such a derivation, in which case we say that the typin judment is valid or invalid, respectively.
3 S then ( ) is a derivation o (S, ( ), ), since ( ) : S and ( ) = (() ()) = ( ). A B C S, A C Proposition 7. Subtypin is relexive and transitive, and admits rules o covariant and contravariant subsumption: S S S S S = S (a) ype reinement Proo. Relexivity o subtypin is by deinition just another way o writin the id typin rule o Prop. 6, while transitivity and subsumption are all special cases o with one or both o the terms (i.e., morphisms o ) and set to the identity term id. S A B C (b) ypin and subtypin judments A B C (c) Derivations o typin and subtypin judments Fiure 1: An illustration o various typetheoretic concepts associated to a unctor. 4. More enerally, we say that a typin rule S 1 = S n = n n is valid i, iven derivations o the premises, we can construct a derivation o the conclusion. We will sometimes ive an explicit name to a typin rule (as a way o reerrin to the correspondin construction on derivations), by placin it to the riht o the horizontal bar. For example, any derivation can be treated as a valid typin rule with no premises: Proposition 6. he ollowin typin rules are always valid: = id S id Proo. hese are immediate consequences o the unctoriality o. For example, suppose is a derivation o (S,, ) and is a derivation o (,, ). By deinition, this means that : S and () =, and : and () =. But As the proo o Prop. 7 illustrates, sometimes constructin a typin derivation involves reasonin about equality o terms (i.e., morphisms o ). In eneral, we allow ourselves to work modulo this equality, but or clarity it is sometimes useul to make the move between equal terms explicit by indicatin a conversion step: For example, the covariant subsumption rule o Prop. 7 can be more explicitly derived as ollows: id Finally, we should mention that the cateorical axioms also imply various equations on typin derivations. For example, the associativity axioms imply that the derivation named by = ( )h is equal to the derivation named by = (h) while the unit laws imply that = id = id ( )id = = id(h) = id γ = h = h = h id γ = h γ = h = = = = γ = h = h
4 hese various simple observations motivate our adoptin the ollowin deinition: Deinition 8. A reinement system is a unctor : D. Example 1. o try to provide a bit o intuition or this way o readin unctors, we will consider a simple and naive example, which is indeed perhaps the olk model o reinement types. For we take the cateory Set o sets and unctions, while or D we take the cateory SubSet o subsets and imae inclusions. An object o SubSet is a pair (A, S) o a set A and a subset o that set S A, while a morphism (A, S) (B, ) is a unction between the underlyin sets : A B such that the imae o the irst subset is included in the second a.a S (a) As the unctor : SubSet Set we take the irst projection, sendin a subset to its underlyin set. Puttin aside ormal questions o what exactly sets are (e.., whether axiomatized by ZFC, etc.), by most interpretations, the cateory Set is already quite rich with types. For example we can probably suppose it contains types o natural numbers, inteers, sequences o inteers, N, Z, Z N and many more besides. But i one could attribute a philosophy to type reinement, it is that rather than tryin to say everythin at once in the lanuae o types, it is sometimes better to start rom a rouh statement, and then explore ways o makin it more precise while keepin the oriinal statement. So, or instance, we miht consider the reinement types o odd, even, or prime natural numbers, 2 odd de = { n k.n = 2k + 1 } N even de = { n k.n = 2k } N prime de = { n n > 1 k.(k > 1 k n) k = n } N o nonzero or nonneative inteers, o linear or bounded sequences, nonzero de = { x x 0 } Z nonne de = { x x 0 } Z linear de = { a, b n. (n) = a n + b } Z N bounded de = { x n. (n) x } Z N and so on. he point o the unctor : SubSet Set is that these reinement types (in SubSet) will always be considered with respect to the oriinal types (in Set) they reine. For example, the question whether every prime number is odd may be sensibly posed as a subtypin problem, prime odd whose answer happens to be neative (i.e., the judment is invalid). On the other hand, the question o whether every linear sequence is odd is not really sensible without resort to some encodin, and the correspondin subtypin judment * linear odd 2 Here we allow ourselves the sliht abuse o writin S A, althouh strictly speakin the pair (A, S) is the object o SubSet. is not wellormed, since the two sides reine dierent types. As another example, i we take λx.x 2 : Z Z to be the squarin unction on the inteers, then the ollowin three typin judments are respectively valid, invalid, and illormed: nonzero = nonne λx.x 2 nonne = nonzero λx.x 2 * nonne = bounded λx.x 2 3. Monoidal and loical reinement systems In the previous section, we described how an arbitrary unctor ives rise to a reinement system, in the sense o an abstract notion o typin judment, typin rules, etc. O course, i all we could say were restricted to such eneralities, then we could not say very much. But we have several strateies or carvin out richer classes o reinement systems : D : 1. By askin or additional structure on D and, and that it is preserved by. 2. By askin or additional properties o (like or instance that it is a ibration). 3. By considerin speciic (reinement) type sinatures, under assumption o some existin structure and properties. In this section we will pursue the irst stratey (the others will be considered later on). We bein by recallin the standard deinition o a monoidal cateory: Deinition 9. A monoidal structure on a cateory D consists o a unctor (called the tensor product) : D D D toether with an object I D, satisyin associativity and unity axioms up to natural isomorphism, (A B) C A (B C) A I A I A Moreover, these natural isomorphisms have to satisy certain coherence laws which we omit here (see [21]). A monoidal cateory is a cateory equipped with a monoidal structure. here are many examples o monoidal cateories, and oten the tensor product satisies additional properties, such as bein symmetric or cartesian [21]. However, here we just want to start rom the most basic situation. Deinition 10. A monoidal reinement system is a unctor : D between monoidal cateories, preservin the monoidal structure in the strict sense that we have a pair o commutative squares: D D D D o read these conditions in typetheoretic lanuae, we irst allow ourselves to introduce another natural convention: we say that a reinement rule 1 1 S 1 A 1... S n A n S A I D I D
5 is valid i (S 1 ) = A 1,..., (S n ) = A n implies that (S) = A. hen the commutative squares o den. 10 translate straihtorwardly to the ollowin proposition (we omit subscripts on the monoidal operations, since they are always clear rom context). Proposition 11. In any monoidal reinement system, the ollowin reinement rules and typin rules are valid: S 1 A 1 S 2 A 2 S 1 S 2 A 1 A 2 I I S 1 = 1 1 S 2 = 2 2 S 1 S 2 = I = I I I Likewise, the axioms o monoidal cateories translate to various equations on derivations constructed usin the typin rules. We elide these here, and instead move on to considerin what we call loical reinement systems. First we recall more standard material on cateory theory. Deinition 12. Let A and C be two objects o a monoidal cateory. A let residual o C by A is an object B equipped with a letevaluation map A B C and a transormation λ[ ] rom maps A B (where B is any object) to maps C (1) B λ[ ] B (2) called letcurryin, such that or any : A B C and : B B we have equations ((id λ[ ]) ) = = λ[(id ) ] hese equations ensure that there is a onetoone correspondence between maps o the orm (1) and maps o the orm (2). Similarly, or any two objects B and C, a riht residual o C by B is an object A equipped with a rihtevaluation map A B C and a transormation ρ[ ] rom maps A B (where A is any object) to maps A ρ[ ] A called rihtcurryin, such that or any : A B C and : A A we have C ((ρ[ ] id) ) = = ρ[( id) ] Proposition 13. Residuation is determined up to isomorphism, i.e., i B and B are two let residuals o C by A, then B B, and i A and A are two riht residuals o C by B, then A A. Because o this proposition, we allow ourselves to speak o the let residual o C by A whenever it exists, writin A \ C to denote it and similarly C / B or the riht residual. Deinition 14. A loical reinement system is a monoidal reinement system : D which preserves let and riht residuals. It is worth mentionin that the deinition o a loical reinement system in our sense does not require that all let and S A C S \ A \ C S S \ = id S id S = = S \ λ λ[ ] S = id λ[ ] S S \ S S \ = = S \ = S = (id λ[ ]) S = = S \ λ λ[ ] = S = S S id = S \ S = S S \ S S \ = id S = (id ) = λ[(id )] S \ λ Fiure 2: he deinin rules o a loical reinement system (restricted to the rules involvin let residuals). riht residuals exist in D and (i.e., that the cateories are closed), but only that preserves any which exist in D. In i. 2, we illustrate how den. 14 (limited to the part involvin let residuals) may be equivalently ormulated in the lanuae o type theory, usin the appropriate reinement rules, typin rules, and equations. hese rules are actually quite standard in the literature on reinement types (see, or example, the system o simple sorts described by Pennin [27, 6]), except or our use o the notation o the Lambek calculus [16] (justiied by the act that we are workin in a eneral monoidal rather than a cartesian settin). Perhaps one rule rom i. 2 that bears emphasizin is the reinement rule: S A C S \ A \ C nder the conventions we have established, the rule simply restates the condition that the unctor preserves let residuals. In particular, the reinement rule should not be conused with the amiliar rule o subtypin or unction types, which mixes contravariance in the domain with covariance in the codomain: Proposition 15. he ollowin subtypin rules are valid in any loical reinement system, i the correspondin residuals exist: S 2 S S 1 \ 1 S 2 \ / 1 2 / 2 Proo. We can derive the rule or let residuals as ollows (the case o riht residuals is symmetric): id S 2 S 1 S 1 \ 1 S 1 \ 1 S 2 S 1 \ 1 S 1 S 1 \ 1 S 1 S 1 \ 1 = 1 S 2 S 1 \ 1 = S 2 S 1 \ 1 = 2 S 1 \ 1 = λ[] S 2 \ 2 S 1 \ 1 S 2 \ 2 λ
6 Example 2. he reinement system SubSet Set considered in Section 2 extends to a loical reinement system. he monoidal structure on Set is the usual cartesian structure, A B de = A B I de = 1 which also lits to a (cartesian) monoidal structure on SubSet: (S A) ( B) de = { (a, b) a S, b } A B (I I) de = { } 1 Both cateories are also closed, with let and riht residuals both deined in terms o the unction space (we describe only the underlyin sets/subsets, not evaluation and curryin): A \ C de = C A C / B de = C B (S A) \ ( C) de = { a.a S (a) } C A ( C) / ( B) de = { b.b (b) } C B he oretul unctor SubSet Set evidently sends products and residuals in SubSet to products and residuals in Set, and thus deines a loical reinement system. As an example, writin + : N N N or addition o natural numbers, we can state various easy arithmetic acts and nonacts as valid and invalid judments: odd = odd \ even λ[+] odd = even \ odd λ[+] even = prime \ odd λ[+] 4. Readin Grothendieck in translation In this section we will pursue the second stratey mentioned at the beinnin o Section 3, and bein by recallin the deinition o when a unctor : D is a ibration à la Grothendieck [13]. Deinition 16. A morphism : in D is said to be cartesian i or every object S D and every pair o morphisms : S and : (S) ( ) such that () = (), there is a unique morphism : S such that = and ( ) =. Deinition 17. Let : A B be a morphism in, and be an object o D such that () = B. A morphism in D is said to be a cartesian litin o to i () =, cod() =, and is cartesian. Deinition 18. A unctor : D is said to be a ibration i or every morphism : A B in and object D such that () = B, has a cartesian litin to. he deinition o ibration plays a undamental role in cateory theory as well as in the semantics o dependent types, and we may thus wonder whether we can understand it rom our point o view on reinement type systems. Aain, we assume : D is ixed, with the notational and terminoloical conventions o Section 2 (we do not assume any other structure on D and ). Deinition 19. Let : A B and B. A pullback (or inverse imae ) o alon is a reinement type A equipped with a pair o valid typin rules = L R such that or all derivations and we have a pair o equalities and R = L = = = L R Now, it is essentially immediate by unwindin the deinitions that we have just redubbed Grothendieck to a typetheoretic soundtrack: Proposition 20. : is a cartesian litin o to i and only i the triple (, L, R ) is a pullback o alon, where L =, and where R is deined usin the universal property o. Proposition 21. is a ibration i or every : A B and B, there exists a pullback o alon. Somewhat remarkably, many standard acts about ibrations can be derived quite mechanically under this translation, reminiscent o proos in the sequent calculus. We bein by showin in this prootheoretic style that pullbacks are determined up to vertical isomorphism. Deinition 22. Let S, A be two reinements o a common type. We say that S and are vertically isomorphic (written S ) when there exist a pair o subtypin derivations S which compose to the identity S S = id S S S S S S S = id Proposition 23. Any two pullbacks o alon are vertically isomorphic. Proo. Let and both be pullbacks o alon, equipped with correspondin valid typin rules = L R and = L R hen we can build derivations o and by = L R = R L
7 : A B B A = L R S A : A B S B L S R R = L = = = L R S R L = = S R L Fiure 3: he deinin rules o pullback reinements. Fiure 4: he deinin rules o pushorward reinements. and easily veriy rom the axioms that these two derivations compose to the identity. Because pullbacks are determined up to vertical isomorphism, we allow ourselves to speak o the pullback o alon whenever one exists, writin or the reinement type and L and R or the correspondin rules (see i. 3). We can now mechanically establish the ollowin acts about pullbacks, which, in cateorical jaron, o into showin that any ibration determines a pseudounctor op Cat: Proposition 24. Whenever the correspondin pullbacks exist: 1. the ollowin subtypin rule is valid: 2. we have vertical isomorphisms Proo ( ) id L 1 = = 2 id 1 = 2 id 1 R 2 2. For the let equation, we construct subtypin derivations in both directions by ( ) L( ) = ( ) = R ( ) R = L = L = ( ) R( ) and aain by an easy calculation, we can show that these two derivations compose to the identity. he riht equation id is essentially immediate (which also means that pullbacks alon the identity always exist). Next, we ive an analoous reconstruction o the dual concept o an opibration. Deinition 25. Let S A and : A B. A pushorward (or imae ) o S alon is a reinement type S B equipped with a pair o valid typin rules S = L S R such that or all derivations and we have equalities and S R S = L S = = S = S R = S = S = L Proposition 26. is a Grothendieck opibration i or every S A and : A B, there exists a pushorward o S alon. Since pushorwards are determined up to vertical isomorphism, we speak o the pushorward o S alon, writin S or the reinement type and L and R or the correspondin rules (see i. 4). Aain, we can mechanically establish some basic acts about pushorwards (which o into showin that any opibration determines a pseudounctor Cat): Proposition 27. Whenever the correspondin pushorwards exist: 1. the ollowin subtypin rule is valid: 2. we have vertical isomorphisms S 1 S 2 S 1 S 2 ( ) S S id S S Proposition 28. Whenever the respective pushorwards and pullbacks exist, we have a threeway correspondence o interderivability, S i i S Example 3. For the reinement system SubSet Set, pushorward and pullback reinements may be constructed as suested by the notation, via imae and inverse imae operations on subsets (alon any unction : A B): S de = { (a) a S } de = { a (a) }
8 For example, the typin judment = is obviously valid, readin as «maps anythin in the inverse imae o alon to somethin in», while reads as «maps anythin in S to somethin in the imae o S alon». Since these operations are deined or any : A B, S A, and B, the unctor SubSet Set is both a ibration and an opibration, i.e., a biibration. Example 4. he eneral approach o Hoare loic [12] provides a natural class o examples o reinement systems, to a irst approximation deined as ollows (we will consider a more nuanced view in Section 5): ake as a cateory with one object W correspondin to the state space, and with morphisms c : W W correspondin to proram commands, identiied with state transormers. ake D as a cateory whose objects are predicates φ over states, and whose morphisms φ ψ are pairs o a state transormer c toether with a veriication that c takes any state satisyin φ to a state satisyin ψ. Let : D be the evident oretul unctor, mappin every φ to W and every veriication about c to c itsel. Indeed, the induced notion o typin judment or the unctor : D corresponds exactly to the classical notion o Hoare triple {φ}c{ψ}. One easily checks that the usual rules o sequential composition, prestrenthenin and postweakenin are valid by Propositions 6 and 7, and moreover that a pullback o ψ alon c is precisely a weakest precondition, while a pushorward o φ alon c is a stronest postcondition: S wp(c, ψ) = c ψ sp(c, φ) = c φ On the other hand, it is not necessarily the case that D is a ibration and/or opibration: whether weakest preconditions/stronest postconditions exist or all predicates and state transormers depends on the speciics o the class o predicates and the class o state transormers. Example 5. he example o SubSet Set can be eneralized in terms o enriched cateory theory [15]. Let (,, I, ) be a symmetric monoidal closed cateory, let Cat be the (bi)cateory o enriched cateories, and let Psh the cateory o presheaves, i.e., the cateory whose objects are valued unctors S : A out o enriched cateories, and where a morphism rom S : A to : B is a pair o a ()unctor : A B toether with a natural transormation : S ( ). hen the reinement system iven by the domain unctor dom : Psh Cat is a biibration, with pullbacks simply deined by precomposition, and pushorwards computed as coends: de = a ( a) a S de = b B( a, b) (a) Note that this is also an example o a loical reinement system the (symmetric) closed monoidal structure on Cat is deined by constructin tensor product cateories and unctor cateories A B de = A B A \ C de = [A, C] C / B de = [B, C] while the tensor product o two presheaves is deined as their external tensor product, S : A B S de = (a, b) S(a) (b) and the let and riht residuals deined as ends: S \ : [A, C] S \ de = S(a) ( a) a / : [B, C] / de = (b) (b) b Example 6. A trivial example o a biibration is the unique unctor! : D 1 rom any cateory D to the terminal cateory 1. Since there is only the identity arrow in 1, all pushorwards and pullbacks exist trivially. (I D is monoidal, this is also trivially a loical reinement system.) 5. Separation Loic and the Frame Rule We have seen how a lot o eneral type theory can be reconstructed as a theory o unctors. In many ways, thouh, the really interestin phenomena arise by takin the various type constructors as buildin blocks, and usin them to deine speciic type sinatures. Eectively, this is a way o viewin reinement systems as a loical ramework, usin them both to deine theories and to construct models. In this section we will ive some basic examples, describin how some aspects o Reynolds and O Hearn s separation loic [32] can be useully explained in terms o reinement systems. Recall (Example 4) that Hoare loic may be considered as a reinement system where terms c : W W are commands (statetransormers), reinements φ, ψ W are predicates over the state space, and where derivations φ = ψ c are proos that the command c will take any state satisyin φ to a state satisyin ψ. Althouh this description suests that is a oneobject cateory, such a restriction is not really necessary, and it turns out to be useul to work more enerally. In particular, suppose we know that is a monoidal cateory and that W is a monoid object in, i.e., that it is equipped with operations : W W W e : 1 W satisyin the monoid axioms. hen or any pair o reinements φ, ψ W, we can deine their separatin conjunction φ ψ W as a pushorward (alon ) o a tensor product: φ ψ de = (φ ψ) We similarly deine the unit o the separatin conjunction emp W as a pushorward (alon e) o the tensor unit: emp de = e I Finally, or any φ, τ W we deine maic wand φ τ W as a pullback (alon the curryin o ) o a residual: 3 φ τ de = λ[ ] (φ \ τ) 3 Incidentally, these kinds o deinitions where in order to deine some loical structure o interest we rely on a similar structure in the
9 Now, interpretin this sinature in the reinement system SubSet Set (Examples 1 to 3) yields the basic settheoretic semantics o the separation loic connectives: φ ψ = { w 1 w 2 w 1 φ, w 2 ψ } emp = { e } φ τ = { w w. w φ w w τ } On the other hand, we can see that the abstract deinition in terms o reinement systems is much more eneral. For example, interpretin the sinature in Psh Cat (Example 5) recovers the wellknown Day construction or litin a monoidal structure on a cateory to a closed monoidal structure on its cateory o presheaves. he next proposition describes the situation more abstractly. Proposition 29. Whenever the operations φ and φ are deined (i.e., when the correspondin pushorwards, pullbacks, and residuals exist), they are unctorial in the sense that subtypin rules ψ 1 ψ 2 φ ψ 1 φ ψ 2 τ 1 τ 2 φ τ 1 φ τ 2 are valid, and adjoint in the sense that the subtypin rule is both valid and invertible. φ ψ τ ψ φ τ his proposition is actually independent o whether and e satisy the monoid axioms, and can even be adapted or a binary operation o arbitrary type : A B C. he unctoriality o φ expressed in Prop. 29 is a trivial instance o O Hearn s rame rule, which can be expressed as ollows or a eneral command c: ψ 1 = c ψ 2 φ ψ 1 = c φ ψ 2 rame here is no reason why the rame rule should be valid in an arbitrary reinement system, and it is impossible to derive it rom the above axioms. On the other hand, in the presence o pullbacks or pushorwards, it is not diicult to see that the rame rule is equivalent to either one o two simple alebraic conditions on the command c: φ c ψ c (φ ψ) c (φ ψ) φ c ψ he correspondence between the rame rule and the lethand side property was noticed already by O Hearn and Yan [24]. Here, we would like to emphasize that the lethand side property says that pullback alon c, seen as an endounctor c : D W D W on the iber o W, is stron with respect to the action φ o the monoidal cateory D W on itsel. his correspondence connects the rame rule to the traditional description o locality as a monadic strenth in the semantics o eects. 6. Reconstructin he Meanin o ypes As we mentioned in the introduction, John Reynolds wrote eloquently on the distinction between the intrinsic and extrinsic views o typin (as he did on many topics), and considered the relationship between these two views careully in loical ramework are a recurrin pattern, and an example o the microcosm principle in the sense o Baez and Dolan. In Section 6.4 we will see this pattern aain in the deinition o the loical relation. his paper on he Meanin o ypes [31]. o conclude our paper, we want to revisit Reynolds analysis, and describe how much o it may be expressed quite naturally in the lanuae o reinement systems. he ollowin Sections 6.1 to 6.5 track Sections 1 5 o [31]. 6.1 Syntax and ypin Rules We deine a cateory and a unctor : D, representin the syntax and typin rules o a small lanuae. he lanuae Reynolds considers in the paper is a simple extension o the lambda calculus includin primitive boolean and arithmetic operations, records, recursion, and subtypin. Since the lanuae is meant to be illustrative rather than interestin o itsel, we will urther simpliy here by ettin rid o records, recursion, and a ew o the primitive operations, in order to ocus on the treatment o subtypin. We will also ollow the LF approach [10] and use hiherorder abstract syntax (rather than explicit identiiers) to describe bindin operations, since this leads to an eleant analysis in terms o cartesian loical reinement systems. Deinition 30. A cartesian loical reinement system is a loical reinement system : D in which the monoidal structures on D and are cartesian [21]. We write X Y and Y X to denote cartesian products and exponentials. he reason we must consider cartesian rather than arbitrary loical reinement systems is that in Reynolds lanuae variables can be used any number o times and in any order. Otherwise, thouh, whether one works with cartesian loical reinement systems or in the eneral monoidal settin, the structure o the analysis is essentially the same. So, we bein by considerin the cateory o terms as a cartesian cateory reely enerated rom a sinle type P o phrases, a pair o morphisms lam : P P P app : P P P representin lambda and application, and morphisms add, sub, lt : P P P not : P P zero, one, true, alse : 1 P representin the operations o addition, subtraction, comparison, neation, and the numerical and boolean constants. We next deine a unctor : D, as a cartesian loical reinement system reely enerated rom the ollowin reinement rules θ 1 P θ 2 P int P nat P bool P n[θ 1, θ 2 ] P the ollowin subtypin rules nat int NI nat bool NB θ 1 θ 1 θ 2 θ 2 n[θ 1, θ 2 ] n[θ 1, θ 2 ] Fn a pair o typin rules or lambda and application θ 2 θ 1 = lam n[θ 1, θ 2 ] Lam n[θ 1, θ 2 ] = app θ 2 θ 1 App and a collection o typin rules or the primitive operations nat nat = add nat N+ int int = add int I+ bool bool = add bool B+ int int = sub int I int int = lt bool I< bool = not bool B
10 1 = zero nat N0 1 = one nat N1 1 = true bool Bt 1 = alse bool B We emphasize that this sinature should be read as speciyin conditions on the cateory D and the unctor. For example, the NI subtypin rule indicates that D contains a morphism NI : nat int and that maps NI to id P, while the App rule says that D contains a morphism App : n[θ 1, θ 2 ] θ 2 θ 1 (or every θ 1, θ 2 P) and that maps App to app. In the spirit o the LF approach (but now at the level o reinements, c. [20, 26]), there is a lot that we don t have to mention in this sinature. For example, we don t have to explicitly include Reynolds subsumption rule, since it is valid in any reinement system (Prop. 7). On the other hand, observe that the Fn subtypin rule is not an instance o Prop. 15, since a priori we do not identiy n[θ 1, θ 2 ] with the exponential object θ 2 θ 1 (the ormer reines P, the latter P P ). Example 7. he unction dec = lam(λ[(id one) sub]) subtractin one rom an inteer may be typed by the ollowin derivation (at the bottom we write Lam or the typin rule deined by postcomposin with Lam): nat N1 nat int NI one int = id int id 1 = int = id one int int 1 = one int int int = int I sub int = int (id one)sub 1 = λ[(id one)sub] intint λ Lam 1 = n[int, int] dec Example 8. It is possible to have more than one typin derivation o the same typin judment. For example, the typin judment nat nat = bool add may be derived either as or as nat nat = add nat N+ nat nat = add bool nat bool NB nat bool NB nat bool NB nat nat bool bool bool bool = bool B+ add nat nat = bool add 6.2 An Intrinsic Semantics We deine a cartesian closed unctor D : D Dom rom derivations to domains. In order to deine the intrinsic semantics we assume domains N, Z, B o naturals, inteers, and booleans, as well as operations + N : N N N + Z : Z Z Z B : B B B Z : Z Z Z < Z : Z Z B B : B B 0, 1 : 1 N tt, : 1 B standin or the componentwisestrict extensions o the evident operations on naturals, inteers, and booleans. We also write i : N Z or the evident inclusion, and j : N B or the strict extension o the ollowin map: { tt i n > 0 n i n = 0 hen we deine the unctor D : D Dom by: nat = N int = Z bool = B n[s, ] = S NI = i NB = j Lam = id Fn[, ] = ( ) App = id N+ = + N I+ = + Z B+ = B I = Z I< =< Z B = B N0 = 0 N1 = 1 Bt = tt B = Note that this data suices or deinin the cartesian closed unctor D, by the requirement that it preserves cartesian products and exponentials. 6.3 An ntyped Semantics We deine a cartesian closed unctor : Dom rom terms to domains. In order to deine the untyped semantics we assume a domain equipped with operations Φ p Z Φ Ψ p such that Φ p Ψ p = id and Φ Ψ = id (i.e., embeddinretraction pairs). We also suppose operations tt Z : 1 Z < Z : Z Z Z Z : Z Z which must at minimum satisy hen is deined by: tt Z > 0 Ψ (x < Z y) > 0 when x < y (x < Z y) = 0 when x y ( Z x) > 0 when x = 0 ( Z x) = 0 when x > 0 P = lam = Φ app = Ψ add = (Ψ p Ψ p ) + Z Φ p lt = (Ψ p Ψ p ) < Z Φ p sub = (Ψ p Ψ p ) Z Φ p not = (Ψ p Ψ p ) Z Φ p zero = alse = 0 i Φ p one = 1 i Φ p true = tt Z Φ p As in Section 6.2, this data suices or deinin as a cartesian closed unctor. 6.4 Loical Relations We ormalize Reynolds loical relations theorem, connectin the intrinsic semantics to the untyped semantics. he loical relations theorem boils down to deinin a cartesian closed unctor ρ : D DRel satisyin a pair o commutin squares: D ρ DRel D (0) 0 D Dom D ρ DRel (1) 1 Dom Here DRel is the cateory whose objects are chaincomplete relations over domains (hence domaintheoretic relations) and whose morphisms are pairs o unctions mappin related aruments to related results, while the i are the evident projection unctors. o deine ρ, we take advantae o the act that the pairin o the projection unctors ( 0, 1 ) : DRel
11 Dom Dom has the structure o a loical reinement system (with all pullbacks and some pushorwards) so let us take a moment to describe this structure (c. [14, Example 3(2)]). A reinement S (A, B) corresponds to a chaincomplete relation S A B between domains, while a derivation o corresponds to a proo that (,) a, b. a S b (a) (b) Products, residuals, pullbacks and pushorwards are deined as ollows on relations: (a 1, a 2 ) S (b 1, b 2 ) i a 1 S b 1 a 2 b 2 S i a, b. a S b (a) (b) a (,) b i (a) (b) c (,) S d i a, b. c = (a) d = (b) a S b Note that pushorward is a partial operation, because the relation (, ) S is not necessarily chaincomplete. However, the pushorward alon a pair o unctions (, ) with lat codomains (or more enerally, with codomains where every element is compact) is always deined. Now, in order to satisy the squares (0) and (1), the object part o the unctor ρ : D DRel must assin to each θ P a relation ρ[θ] (θ, ). Let : Dom DRel be the (cartesian closed) unctor assinin the identity relation to any domain. We deine ρ[θ] as ollows (by induction on θ): ρ[int] = (id, Ψ p ) [Z ] ρ[nat] = (id, Ψ p ) (id, i) [N ] ρ[bool] = (id, Ψ p ) (id, i) (id, j) [B ] ρ[n[θ 1, θ 2 ]] = (id, Ψ ) ρ[θ 2 ] ρ[θ 2] By unwindin the interpretation o the loical reinement system DRel Dom Dom, it is easy to check that these deinitions aree with Reynolds Deinitions 4.1 and 4.2. For example, we have b ρ[bool] p i b (id,i) (id,j) [B] Ψ p (p) i i n.ψ p (p) = i(n) b (id,j) [B] n n.ψ p (p) = i(n) b = j(n) We can now prove that ρ extends to a unctor and that the two squares (0) and (1) commute, which modulo our treatment o variables (usin hiherorder abstract syntax rather than explicit environments) is an exact transcription o Reynolds Loical Relations heorem (4.8). heorem 31. I θ 1 = θ 2 then ρ[θ 1 ] = ρ[θ 2 ]. p (,p) Proo. By induction on. he content o the proo is basically identical with the proo in [31], but the trip throuh reinement systems ives the proo considerably more structure. We illustrate with a ew cases: = NI: [N ] = (i,i) [Z ] [i] (id, i) [N ] = (i,id) [Z ] L(id, i) (id, Ψ p ) (id, i) [N ] = (i,id) (id, Ψ p ) [Z ] (un) ρ[nat] = (NI,id) ρ[int] where we write a double line or expansion o deinitions, (un) or unctoriality o pullbacks (Prop. 24), and [i] or the application o the unctor to the map i : N Z. = Lam: ρ[θ 2 ] ρ[θ 1] = ρ[θ 2] ρ[θ id 1] (id,id) = N+: ρ[θ 2 ] ρ[θ 1] ρ[θ 2 ] ρ[θ 1] = ρ[θ 2] ρ[θ 1] (id,(φ Ψ )) = (id, Ψ ) ρ[θ 2 ] ρ[θ 1] (id,φ ) ρ[θ 2 θ 1 ] = (Lam,lam) ρ[n[θ 1, θ 2 ]] [N ] [N ] = (+ N,+ N ) [N ] [+ N] [N ] [N ] = (+ N,(+ N i)) (id, i) [N ] [N ] [N ] = (+ N,(i i+ Z )) (id, i) [N ] R(id, Ψ ) ( ) ρ[nat] ρ[nat] = ρ[nat] (+ N,((Ψp Ψp)+ Z Φp)) ρ[nat nat] = (N+,add) ρ[nat] R(id, i) [N ] = (id, i) [N ] (id,i) where at ( ) we have elided several easy steps o reasonin, and at we use the act that (+ N i) = (i i + Z ). 6.5 Bracketin We ormalize Reynolds bracketin theorem, which combined with the loical relations theorem yields coherence. We bein by deinin or each domain θ in the imae o the intrinsic semantics a pair o unctions θ φ[θ] ψ[θ] which will turn out to be an embeddinretraction pair. he amily is deined as ollows (by induction on θ): φ[int] = Φ p ψ[int] = Ψ p φ[nat] = i Φ p ψ[nat] = Ψ p i φ[bool] = j i Φ p ψ[bool] = Ψ p i j φ[n[θ 1, θ 2 ]] = φ[θ 2 ] ψ[θ 1] Φ ψ[n[θ 1, θ 2 ]] = Ψ ψ[θ 2 ] φ[θ 1] Here de = λ[ id ], while i : Z N is the unction sendin nonneative inteers to naturals and everythin else to, and j : B N is the strict extension o the unction sendin tt to 1 and to 0. Note that this amily o pairs may be seen as a pair o transormations between unctors φ : D ( ) ψ : ( ) D albeit not a pair o natural transormations. Instead, φ and ψ are related by Reynolds bracketin theorem. heorem 32 (Bracketin). he two judments are derivable or all θ. θ = ρ[θ] = θ (id,φθ ) (id,ψ θ ) Proo. By induction on θ. Once aain, the proo is hihly structured, and we include it in ull in Appendix A. Finally, by combinin the bracketin theorem with the loical relations theorem, we can show that the intrinsic semantics
12 is coherent, i.e., that any two derivations o the same judment have the same interpretation (the ollowin statements correspond to Reynolds heorem 5.7 and Corollary 5.8). Corollary 33 (Coherence). We have: 1. I θ 1 = θ 2 then = φ θ1 p ψ θ2. p 1 2. I θ 1 = p 2 θ 2 and θ 1 = θ 2 then 1 = 2. p 7. Related work and conclusions Reinement type systems are the hiherorder version o Hoare loic, and as such, they are reconized today as a undamental tool in proram analysis and certiication. An important contribution to this line o research has been the work by Frank Pennin and his collaborators [9] who have developed alon the years a comprehensive theory o reinement type systems, includin a clean account o the relationship between extrinsic and intrinsic typin [27]. Here, by oin back to Reynolds [31] we establish a very natural connection between reinement type systems and unctorial semantics, based on the idea that every unctor deines a reinement type system. Functorial semantics is an old idea oin back to Lawvere in alebra [18] and loic [19], and which plays a central role in the study o imperative lanuaes since Reynolds and Oles [25, 28]. Functorial semantics has also played a deinin role in the early development o separation loic [23] as well as in more recent extensions o the loic to hiherorder imperative lanuaes [3, 4]. One distinctive eature o the present work is to develop a ormal lanuae o typin judments and derivations relectin the basic reasonin principles o unctorial semantics. his lanuae has been desined in order to be amenable to mechanization and could eventually serve as an intermediate lanuae in a proo assistant. We demonstrated the power o the lanuae in Section 6, by recastin the sophisticated semantic aruments used by Reynolds [31] in a concise and hihly structured way. One o the oriinal motivations or this lanuae was to better understand eect type systems and their ibrational aspects, alon the lines o [8, 14]. he idea o usin product and implicationpreservin ibrations in the study o loical predicates and loical relations may be traced back to Hermida [11], with later developments by Katsumata. Investiatin eects and reinement type systems led us to replace ibrations by eneral unctors, and in particular to appreciate the expressive power o closed unctors. oether with the existence o speciic pullbacks and pushorwards, one recovers many o the operations o dependent types but in a more lexible and eneral settin. he principle o reinin types while payin careul attention to the dual act o orettin also appears in McBride s notion o ornament [22], which have been analyzed in ibrational terms [1, 6]. We would like to clariy the connection with our work in the uture. Finally, the idea o usin closed unctors as a loical ramework (capable o speakin about both syntax and semantics in a uniied way) is very much in the spirit o de Groote s abstract cateorial rammars [7], as well as Carette, Kiselyov and Shan s taless interpreters [5]. Reerences [1] Robert Atkey, Patricia Johann, and Neil Ghani. Reinin Inductive ypes. LMCS, 8:2, [2] Jean Bénabou. Distributors at work. Notes rom a course at Darmstadt in June 2000, taken by homas Streicher. [3] Bodil Bierin, Lars Birkedal, and Noah orpsmith. BI Hyperdoctrines, Hiherorder Separation Loic, and Abstraction. ACM rans. Proram. Lan. Syst., 5:29, [4] Lars Birkedal, Noah orpsmith, and Honseok Yan. Semantics o SeparationLoic ypin and Hiherorder Frame Rules or Alollike lanuaes. LMCS, 5:2, [5] Jacques Carette, Ole Kiselyov, and Chunchieh Shan. Finally taless, partially evaluated: aless staed interpreters or simpler typed lanuaes. JFP, 5:19, [6] PierreEvariste Daand and Conor McBride. A Cateorical reatment o Ornaments. LICS [7] Philippe de Groote. owards Abstract Cateorial Grammars. In Assoc. or Computational Linuistics, 39th Annual Meetin, [8] Andrzej Filinski. Monads in Action. POPL [9] im Freeman and Frank Pennin. Reinement ypes or ML. PLDI [10] Robert Harper, Furio Honsell and Gordon Plotkin. A Framework For Deinin Loics. Journal o the ACM, 40(1): , [11] Claudio Hermida. Fibrations, Loical predicates and indeterminates, PhD thesis, niversity o Edinburh, November [12] C.A.R. Hoare. An Axiomatic Basis or Computer Prorammin, Communications o the ACM, 12:10, [13] Bart Jacobs. Cateorical Loic and ype heory. Studies in Loic and the Foundations o Mathematics 141. North Holland, [14] Shinya Katsumata. Relatin Computational Eects by  Litin. ICALP [15] Max Kelly. Basic concepts in enriched cateory theory. CP, [16] Joachim Lambek. he mathematics o sentence structure. American Mathematical Monthly, 65:3, [17] Joachim Lambek and Philip Scott. Introduction to Hiherorder Cateorical Loic. CP, [18] F. William Lawvere. Functorial Semantics o Alebraic heories, PhD thesis, Columbia niversity, [19] F. William Lawvere. Adjointness in Foundations, Dialectica 23, 1969, [20] William Lovas. Reinement types or loical rameworks, PhD thesis, Carneie Mellon niversity, September [21] Saunders Mac Lane. Cateories or the Workin Mathematician. Spriner, [22] Conor McBride. Ornamental Alebras, Alebraic Ornaments. JFP (to appear). 9/8/2010 version available on author s website. [23] Peter W. O Hearn and David J. Pym. he Loic o Bunched Implications. BSL 5:2, [24] Peter W. O Hearn and Honseok Yan. A Semantic Basis or Local Reasonin. FOSSACS [25] Frank J. Oles. A Cateoryheoretic Approach to the Semantics o Prorammin Lanuaes, PhD thesis, Syracuse niversity, [26] Frank Pennin. Reinement ypes or Loical Frameworks. Workshop on ypes or Proos and Prorams, May [27] Frank Pennin. Church and Curry: Combinin Intrinsic and Extrinsic ypin. Studies in Loic 17, 2008, [28] John C. Reynolds. he Essence o Alol. Alorithmic Lanuaes, 1981, [29] John C. Reynolds. he Coherence o Lanuaes with Intersection ypes, ACS [30] John C. Reynolds. heories o Prorammin Lanuaes. CP, [31] John C. Reynolds. he Meanin o ypes: rom Intrinsic to Extrinsic Semantics. BRICS Report RS0032, Aarhus niversity, December [32] John C. Reynolds. Separation loic: A Loic or Shared Mutable Data Structures. LICS 2002.
13 A. Proo o the Bracketin heorem Recall that the bracketin theorem (hm. 32) says that the pair o judments θ = (id,φ[θ]) ρ[θ] = (id,ψ[θ]) θ are derivable in the loical reinement system DRel Dom Dom. We prove this by induction on θ. (Case θ = n[θ 1, θ 2 ]). In one direction we build the ollowin derivation: i.h. [] ρ[θ 1 ] = θ 1 θ 1 θ 2 θ 1 = θ 2 (id,ψ[θ 1 ]) (,) ρ[θ 1 ] θ 2 θ 1 = (,(ψ[θ 1 ] idφ[θ 2 ])) ρ[θ 2] θ 2 θ 1 = ρ[θ 2 ] ρ[θ 1] (id,φ[θ 2 ] ψ[θ 1 ] ) θ 2 θ 1 = ρ[θ 2 ] ρ[θ 1] (id,(φ[θ 2 ] ψ[θ 1 ] Φ Ψ )) θ 2 θ 1 = (id, Ψ ) ρ[θ 2 ] ρ[θ 1] (id,(φ[θ 2 ] ψ[θ 1 ] Φ )) n[θ 1, θ 2 ] = (id,φ[n[θ 1,θ 2 ]]) ρ[n[θ 1, θ 2 ]] i.h. θ 2 = (id,φ[θ 2 ]) ρ[θ 2] λ R(id, Ψ ) where at ( ) we apply composition twice (the order is irrelevant by associativity), ater multiplyin the letmost premise by the identity on the riht to brin it to the appropriate type. In the other direction we build the ollowin derivation: i.h. θ 1 = ρ[θ i.h. 1] ρ[θ 2 ] = θ 1 (id, Ψ ) ρ[θ 2 ] ρ[θ 1] = ρ[θ L(id, Ψ 2] ρ[θ ) (id,φ[θ 1 ]) (id,ψ[θ 2 ]) 1] θ 1 ρ[θ 2 ] ρ[θ 1] = θ 2 L\ (id,ψ ) (,(φ[θ 1 ] idψ[θ 2 ])) θ 1 (id, Ψ ) ρ[θ 2 ] ρ[θ 1] = θ ( ) 2 (,(φ[θ 1 ] Ψ ψ[θ 2 ])) λ (id, Ψ ) ρ[θ 2 ] ρ[θ 1] = θ 2 θ 1 (id,(ψ ψ[θ 2 ] φ[θ 1 ] )) ρ[n[θ 1, θ 2 ]] = n[θ 1, θ 2 ] (id,ψ[n[θ 1,θ 2 ]]) where at ( ) aain we multiply the letmost premise by the identity on the let beore composin, and at L\ we apply an instance o the ollowin rule (which is valid in any loical reinement system): S = v S = k S S \ = v idk L\ ( ) (Case θ = int). [Z ] = [Z ] id (id,id) [Z ] = [Z ] (id,(φ pψ p)) [Z ] = (id,φp) (id, Ψ p) [Z ] R(id, Ψ p) int = (id,φ[int]) ρ[int] (id, Ψ p ) [Z ] = (id,ψp) [Z ] L(id, Ψ p) ρ[int] = (id,ψ[int]) int
14 (Case θ = nat). (Case θ = bool). R(id, i) [N ] = (id, i) [N ] (id,i) [N ] = (id, i) [N ] (id,(iφ pψ p)) [N ] = (id,(iφ p)) (id, Ψ p) (id, i) [N ] R(id, Ψ p) nat = (id,φ[nat]) ρ[nat] [B ] = [B ] id (id,id) [B ] = [B ] (id,(j j)) [B ] = (id,j ) (id, j) [B ] [B ] = (id,(j i)) (id, i) (id, j) [B ] R(id, j) R(id, i) [B ] = (id,(j iφ pψ p)) (id, i) (id, j) [B ] [B ] = (id,(j iφ p)) (id, Ψ p) (id, i) (id, j) [B ] R(id, Ψ p) bool = (id,φ[bool]) ρ[bool] [N ] = [N ] id (id,id) [N ] = [N (id,(ii ] )) (id, i) [N ] = (id,i ) [N ] L(id, i) (id, Ψ p ) (id, i) [N ] = (id,(ψ pi )) [N ] L(id, Ψ p) ρ[nat] = (id,ψ[nat]) nat (id, j) L(id, j) [B ] = [B ] (id,j) (id, j) [B ] = [B ] (id,(ii j)) (id, i) (id, j) [B ] = (id,(i j)) [B ] L(id, i) (id, Ψ p ) (id, i) (id, j) [B ] = (id,(ψ pi j)) [B ] L(id, Ψ p) ρ[bool] = (id,ψ[bool]) bool
Dependent Types at Work
Dependent Types at Work Ana Bove and Peter Dybjer Chalmers University of Technology, Göteborg, Sweden {bove,peterd}@chalmers.se Abstract. In these lecture notes we give an introduction to functional programming
More informationPhysics, Topology, Logic and Computation: A Rosetta Stone
Physics, Topology, Logic and Computation: A Rosetta Stone John C. Baez Department of Mathematics, University of California Riverside, California 92521, USA Mike Stay Computer Science Department, University
More informationHow many numbers there are?
How many numbers there are? RADEK HONZIK Radek Honzik: Charles University, Department of Logic, Celetná 20, Praha 1, 116 42, Czech Republic radek.honzik@ff.cuni.cz Contents 1 What are numbers 2 1.1 Natural
More informationFrom IF to BI. A Tale of Dependence and Separation. Samson Abramsky Oxford University Computing Laboratory. 1. Introduction
From IF to BI A Tale of Dependence and Separation Samson Abramsky Oxford University Computing Laboratory Jouko Väänänen ILLC Amsterdam Abstract. We take a fresh look at the logics of informational dependence
More informationHow to Make Ad Hoc Proof Automation Less Ad Hoc
How to Make Ad Hoc Proof Automation Less Ad Hoc Georges Gonthier Microsoft Research gonthier@microsoft.com Beta Ziliani MPISWS beta@mpisws.org Aleksandar Nanevski IMDEA Software Institute aleks.nanevski@imdea.org
More informationREEDY CATEGORIES AND THEIR GENERALIZATIONS MICHAEL SHULMAN
REEDY CATEGORIES AND THEIR GENERALIZATIONS MICHAEL SHULMAN Abstract. We observe that the Reedy model structure on a diagram category can be constructed by iterating an operation of bigluing model structures
More informationNotions of computation and monads
Notions of computation and monads Eugenio Moggi Abstract The λcalculus is considered an useful mathematical tool in the study of programming languages, since programs can be identified with λterms. However,
More informationSwitching Algebra and Logic Gates
Chapter 2 Switching Algebra and Logic Gates The word algebra in the title of this chapter should alert you that more mathematics is coming. No doubt, some of you are itching to get on with digital design
More informationThe Conception, Evolution, and Application of Functional Programming Languages
The Conception, Evolution, and Application of Functional Programming Languages Paul Hudak Yale University Department of Computer Science March 1989 Final Draft Abstract The foundations of functional programming
More informationTYPES, SETS AND CATEGORIES
TYPES, SETS AND CATEGORIES John L. Bell This essay is an attempt to sketch the evolution of type theory from its beginnings early in the last century to the present day. Central to the development of the
More informationWelltyped programs can t be blamed
Welltyped programs can t be blamed Philip Wadler University of Edinburgh Robert Bruce Findler University of Chicago Abstract We introduce the blame calculus, which adds the notion of blame from Findler
More informationZombies cannot be there
Zombies cannot be there Marco Giunti University of Cagliari email: giunti@unica.it homepage: http://giuntihome.dadacasa.supereva.it 1 THE PROBLEM OF PHENOMENAL CONSCIOUSNESS IN LATE 20 TH CENTURY 2 THE
More informationOn Understanding Types, Data Abstraction, and Polymorphism
On Understanding Types, Data Abstraction, and Polymorphism LUCA CARDELLI AT&T Bell Laboratories, Murray Hill, N. J. 07974 PETER WEGNER Department of Computer Science, Brown University, Providence, R. I.
More informationAn untitled book project about symmetric spectra
An untitled book project about symmetric spectra This document is a preliminary and incomplete version of what may one day become a book about symmetric spectra. It probably contains an embarrassing number
More informationMonads for functional programming
Monads for functional programming Philip Wadler, University of Glasgow Department of Computing Science, University of Glasgow, G12 8QQ, Scotland (wadler@dcs.glasgow.ac.uk) Abstract. The use of monads to
More informationOn Understanding Types, Data Abstraction, and Polymorphism
1 Computing Surveys, Vol 17 n. 4, pp 471522, December 1985 On Understanding Types, Data Abstraction, and Polymorphism Luca Cardelli AT&T Bell Laboratories, Murray Hill, NJ 07974 (current address: DEC
More informationA Puzzle about Ontology
NO ^US 39:2 (2005) 256 283 A Puzzle about Ontology THOMAS HOFWEBER University of North Carolina at Chapel Hill 1 Ontology Ontology is the philosophical discipline that tries to find out what there is:
More informationMatthias Beck Gerald Marchesi Dennis Pixton Lucas Sabalka
Matthias Beck Gerald Marchesi Dennis Pixton Lucas Sabalka Version.5 Matthias Beck A First Course in Complex Analysis Version.5 Gerald Marchesi Department of Mathematics Department of Mathematical Sciences
More informationIn the last fifty years, the use of the notion of 'category' has led to a remarkable unification and simplification of mathematics.
In the last fifty years, the use of the notion of 'category' has led to a remarkable unification and simplification of mathematics. Written by two of the bestknown participants in this development, Conceptual
More informationProgramming up to Congruence (Extended version)
Programming up to Congruence (Extended version) Vilhelm Sjöberg Stephanie Weirich University of Pennsylvania, Philadelphia, PA, USA {vilhelm,sweirich}@cis.upenn.edu Abstract This paper presents the design
More informationCommunication Theory of Secrecy Systems
Communication Theory of Secrecy Systems By C. E. SHANNON 1 INTRODUCTION AND SUMMARY The problems of cryptography and secrecy systems furnish an interesting application of communication theory 1. In this
More informationPropositions as Types
Propositions as Types Philip Wadler University of Edinburgh wadler@inf.ed.ac.uk 1. Introduction Powerful insights arise from linking two fields of study previously thought separate. Examples include Descartes
More informationYou know from calculus that functions play a fundamental role in mathematics.
CHPTER 12 Functions You know from calculus that functions play a fundamental role in mathematics. You likely view a function as a kind of formula that describes a relationship between two (or more) quantities.
More informationOn the Decidability and Complexity of Query Answering over Inconsistent and Incomplete Databases
On the Decidability and Complexity of Query Answering over Inconsistent and Incomplete Databases Andrea Calì Domenico Lembo Riccardo Rosati Dipartimento di Informatica e Sistemistica Università di Roma
More informationHypercomputation: computing more than the Turing machine
Hypercomputation: computing more than the Turing machine Abstract: Toby Ord Department of Philosophy * The University of Melbourne t.ord@pgrad.unimelb.edu.au In this report I provide an introduction to
More informationFourier Theoretic Probabilistic Inference over Permutations
Journal of Machine Learning Research 10 (2009) 9971070 Submitted 5/08; Revised 3/09; Published 5/09 Fourier Theoretic Probabilistic Inference over Permutations Jonathan Huang Robotics Institute Carnegie
More informationProofs are Programs: 19th Century Logic and 21st Century Computing
Proofs are Programs: 19th Century Logic and 21st Century Computing Philip Wadler Avaya Labs June 2000, updated November 2000 As the 19th century drew to a close, logicians formalized an ideal notion of
More informationHILBERT S PROGRAM THEN AND NOW
HILBERT S PROGRAM THEN AND NOW Richard Zach 1 INTRODUCTION Hilbert s program is, in the first instance, a proposal and a research program in the philosophy and foundations of mathematics. It was formulated
More informationDiscovering All Most Specific Sentences
Discovering All Most Specific Sentences DIMITRIOS GUNOPULOS Computer Science and Engineering Department, University of California, Riverside RONI KHARDON EECS Department, Tufts University, Medford, MA
More informationA Modern Course on Curves and Surfaces. Richard S. Palais
A Modern Course on Curves and Surfaces Richard S. Palais Contents Lecture 1. Introduction 1 Lecture 2. What is Geometry 4 Lecture 3. Geometry of InnerProduct Spaces 7 Lecture 4. Linear Maps and the Euclidean
More information