Functors are Type Refinement Systems


 Vernon Floyd
 1 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
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