Zine El-Abidine Benaissa(1), Eugenio Moggi(2), Walid Taha(1), Tim Sheard(1)

Size: px
Start display at page:

Download "Zine El-Abidine Benaissa(1), Eugenio Moggi(2), Walid Taha(1), Tim Sheard(1)"

Transcription

1 Logical Modalities and Multi-Stage Programming Zine El-Abidine Benaissa(1), Eugenio Moggi(2), Walid Taha(1), Tim Sheard(1) (1) Oregon Graduate Inst., Portland, OR, USA (2) DISI, Univ. di Genova, Genova, Italy E.Moggi, DISI, Univ. di Genova, v. Dodecaneso 35, Genova, Italy tel: , fax: , Abstract. Multi-stage programming is a method for improving the performance of programs through the introduction of controlled program specialization. This paper makes a case for multi-stage programming with open code and closed values. We argue that a simple language exploiting interactions between two logical modalities is well suited for multi-stage programming, and report the results from our study of categorical models for multi-stage languages. Keywords: Multi-stage programming, categorical models, semantics, type systems (multi-level typed calculi), combination of logics (modal and temporal). 1 Introduction Multi-stage programming is a method for improving the performance of programs through the introduction of controlled program specialization [TS97, Tah99]. MetaML was the rst language designed specically to support this method. It provides a type constructor for \code" and staging annotations for building, combining, and executing code, thus allowing the programmer to have ner control over the evaluation order. Unfortunately, the single type constructor h i that MetaML provides for code does not allow for a natural way of executing code. This means that \generated code" cannot be easily integrated with the rest of the run-time system. Previously published attempts to provide a consistent type system for MetaML where code can be executed have had limited expressivity [TBS98]. The method we propose is based on a study of 1. The operational semantics and pragmatics of staged computation [TS97, TBS98, MTBS99, Tah99], 2. Previous work on the applications of logical modalities to staged computation [DP96, Dav96], 3. Categorical models for multi-stage languages [Mog97, BMTS98]. Our study has been consolidated into a new language for multi-stage programming called BN. 1.1 Multi-Stage Programming The main steps of multi-stage programming are: 1. Write the conventional program program: t S! t D! t where t S is the type of the \static" or \known" parameters, t D is the type of the \dynamic", or \unknown" parameters, and t is the type of the result of the program. 2. Add staging annotations to the program to derive annotated program: t S! ht D i! hti In partial evaluation, this step is performed automatically, and is known as Binding-Time Analysis. However, there are reasons for carrying it out interactively (see [TS97]). 3. Compose the annotated program with an unfolding combinator back: (hai! hbi)! ha! Bi code generator: t S! ht D! ti 4. Construct or read the static inputs: s: t S 5. Apply the code generator to the static inputs to get specialized code: ht D! ti 6. Run the specialized code to re-introduce the generated function as a rst-class value in the current environment: specialized program: t D! t 1

2 Problem and Solution In MetaML the last step is generally carried out in ad hoc ways [TS99]. The problem is that there is no general way for going from MetaML's code type hai to a MetaML value of type A. We have not been able to nd reasonable models where a function unsafe run: hai! A can exists. Operationally, a code fragment of type hai can contain \free dynamic variables". Because the code type of MetaML does not provide us with any information as to whether or not there are \free dynamic variables" in the fragment, there is no way of ensuring that this code fragment can be safely executed. At the level of language constructs, MetaML provides a construct Run. Run allows the execution of a code fragment. For example, run h3 + 4i is well-typed and evaluates to 7, but this construct has limited expressivity, e.g. the lambda abstraction x:run x is not typable. Without such a function code fragments declared at top-level can never be executed using welltyped terms. At the same time, we don't want a function like unsafe run: hai! A, since it would break type safety for MetaML [TBS98]. The crucial advance presented in this paper is that there are useful models where a function safe run: [hai]! [A] exists. Safe-Run has the same operational behavior that unsafe run was intended to achieve, namely running code. The dierence is only in the typing of this function. In a nutshell, safe run allows the programmer to exploit the fact that closed code can be safely executed. 1.2 The Rened Method We propose a renement of multi-stage programming with explicit assertions about closedness, and where these assertions are checked by the type system: 1. Write the conventional program program: t S! t D! t Exactly the same as before. 2. Add staging annotations to the program to achieve closed annotated program: [t S! ht D i! hti] Almost the same as before. The dierence is that the programmer must use the Closed type constructor [ ] to demonstrate to the type system that the annotated program does not introduce any \free dynamic variables". This means that in constructing the annotated program, the programmer will only be allowed to use Closed values. 3. Compose the annotated program with an unfolding combinator to get closed code generator: [t S! ht D! ti] Now back must itself be closed if we are to use it inside a closed value, that is, we use a slightly dierent combinator closed back: [(hai! hbi)! ha! Bi] 4. Turn the closed code-generator into generator of closed code: [t S ]! [ht D! ti] This is done by applying a combinator closed apply: [A! B]! [A]! [B]. 5. Construct or read the static inputs as closed values: cs: [t S ] This is similar to multi-stage programming with explicit annotations. However, requiring the value to be closed is much more specic than in the original method. This means that we have to make sure that all combinators used in constructing this value are themselves closed. 6. Apply the code generator to the static inputs to get closed specialized code: [ht D! ti] 7. Run the above result to get: closed specialized program: [t D! t] This step exploits an interaction between the closed and code types in our categorical model. The step is performed by applying a function safe run: [hai]! [A]. 8. Forget that the specialized program is closed: specialized program: t D! t The step is performed by applying a function open:[a]! A. The full development of various examples from [TS97, MTBS99] can be expressed in BN (the language proposed in this paper), but not in the core type system for MetaML [TBS98].

3 1.3 Overview The paper is organized as follows: To begin, we introduce multi-stage languages, and review the connections that have been established between code types and logical modalities. Next, we analyze, from a categorical point of view, the logical modalities and how they interact. Borrowing ideas from the work by Benton and others on categorical models for linear logic (and more specically the adjoint calculus [Ben95, BW96]), we give a denition of what constitutes a categorical model for three simply typed multi-stage languages, namely 2,, and BN, and consider some examples. Then, we investigate the interaction between modalities and computational monads, since computational eects are a pervasive feature of programming languages. In particular, we rene the interpretation of BN in the presence of computational eects. Notation 1.1 We introduce notation and terminology used throughout the paper. C; D Categories jcj Objects of the category A; B Objects (in some category) C(A; B) The set of arrows from A to B F; G Functors (between categories) GF G F GF A G(F A) - Full and faithful functor F a G An adjunction. F and G are the left- and right-adjoints (x n jn 2 N) Innite sequence (x i ji 2 m) Finite sequence of length m x i Short for (x i ji 2 m) when m is clear from context x: : s The sequence obtained by adding x in front of s n + 1 dofx i e i ; eg, ret e let x i ( e i in e and [e] of [Mog91] op: i M A i! M B op(u i ) = dofx i u i ; op(x i )g, i.e., the monadic extension of op: i A i! M B 2 Multi-Stage Languages Multi-stage languages provide generic constructs building, combining and executing code fragments. The three languages we have studied have the following main features: 2 [DP96], provides constructs for building and the executing closed code. Such a language is useful in machine-code generation. [Dav96], provides constructs for building and combining open code fragments. Such a language is useful in high-level program generation and inlining. MetaML [TS97, TBS98], extends by providing an additional construct for the execution of code fragments, and cross-stage persistence. Cross-stage persistence is the ability to bind a variable at \stage" n and use it at \stage" n + 1. Both features are important for pragmatic reasons. 2 and have clean, logical foundations [DP96, Dav96, Mas93, MM96]: there is a Curry-Howard isomorphism between and linear time temporal logic, and between 2 and modal logic S4. MetaML emphasizes the pragmatic importance of being able to combine cross-stage persistence, \evaluation under lambda" (or \symbolic computation"), and being able to execute code. The combination of these three goals is not achieved by either 2 or separately (See [TS97]). At the same time, MetaML had no logical foundations, nor the formal hygiene that such foundations often promote. For example, MetaML could only avoid the expressivity problem of Run through ad hoc extensions (see [TS99]), which demanded deeper investigation and possibly simplication. 2.1 BN Types, Syntax, and Semantics BN has the following types: 2 T : : = b j t 1! t 2 j hti j [t] i.e. base types, functions, (open) code fragments, and closed values. The syntax of BN is as follows: e 2 E: : = c j x j x:e j e 1 e 2 j hei j ~e j close e with fx i = e i ji 2 mg j open e j safe run e The rst four constructs are the standard ones in a -calculus with constants. Bracket and Escape allow building and combining open code. Brackets construct code, and Escape splices a code fragment into the context of a bigger code fragment. A term such as (fn x => <(~x,~x)>) <5> yields <(5,5)> when evaluated. The Close-With construct asserts that e is closed except for a set of variables x i, each of which is bound to a closed term e i. Open forgets the closedness assertion on e. Finally Safe-Run executes a closed code fragment and returns a closed value.

4 ? ` c: t n c? ` x: t n if t n =?(x)?; x: t n 1 ` e: t n 2? ` x:e: (t 1! t 2 ) n? ` e 1 : (t 1! t 2 ) n? ` e 2 : t n 1? ` e 1 e 2 : t n 2? ` e: t? ` hei: hti n? ` e: hti n? ` ~e: t? ` x: [t] k if [t] n =?(x) and k >? ` e i : [t i ] n fx i : [t i ] ji 2 mg ` e: t? ` close e with x i = e i : [t] n? ` e: [t] n? ` open e: t n? ` e: [hti] n? ` safe run e: [t] n Figure 1: BN Type System Figure 1 presents the type system of BN. Typing judgments have the form? ` e: t n, where? fx i : t ni i ji 2 mg and n is a natural called the level of the term. The level of the term is the number of surrounding Brackets less the number of surrounding Escapes. The big-step operational semantics of BN is presented in Figure 2. The set of values for BN is dened as follows: v 2 V : : = x:e j hv 1 i j close v v 1 2 V 1 : : = c j x j v 1 v 1 j x:v 1 j hv 2 i j close e with x i = vi 1 j open v 1 j safe run v 1 v 2 2 V 2 : : = c j x j v 2 v 2 j x:v 2 j hv 3 i j ~v 1 j close e with x i = v 2 i j open v 2 j safe run v 2 3 Categorical Models In this section we dene what is a model of BN (see Denition 3.9). We ignore computational eects, and focus instead on the logical modalities underpinning this multi-stage language. Notation 3.1 We use the FP- prex to indicate any 2-categorical notion (e.g. category, functor, monad, adjunction) specialized to the 2-category of categories with nite products and functors preserving them. Similarly we use the CCC- prex to indicate any 2-categorical notion specialized to the 2-category of cartesian closed categories and functors preserving the CCC structure. Remark 3.2 An FP-adjunction F a G is simply an adjunction s.t. the left adjoint F is an FP-functor. Denitions 3.3 and 3.5 recast in categorical terms the correspondence established by Davies and Pfenning between and linear time temporal logic, and between 2 and S4 modal logic. Denition 3.3 A -model is given by a CCC D and a full and faithful CCC-functor D N - D. Remark 3.4 The pattern for interpreting is to interpret a type t by an object [[t]] of D, namely [[hti]] = N[[t]] and [[t 1! t 2 ]] = [[t 2 ]] [t 1 ] and a term fx i : t ni i ji 2 mg ` e: t n by a map in D( Y i2m N ni [[t i ]]; N n [[t]]). The properties of N ensure that one may safely confuse N n [[t 1! t 2 ]] with (N n [[t 2 ]]) Nn [t 1 ]. This isomorphism formalizes the property of in linear time temporal logic, and was also observed in [TS97]. Denition 3.5 A 2 -model is given by a CCC D and G - an FP-adjunction D > C. F Remark 3.6 The denition of 2 -model is consistent with the topos-theoretic approach to modalities of [RZ91]. The FP-adjunction induces an FP-comonad B = FG on D. B is all that is needed for interpreting 2. In fact, a type t is interpreted by an object [[t]] of D, namely [[[t]]] = B[[t]] and [[t 1! t 2 ]] = [[t 2 ]] [t 1 ] and a term fx i : t i ji 2 mg; fx j : t j jj 2 ng `2 e: t is interpreted by a map in D(B( Q i2m [[t i]]) ( Q j2n [[t j]]); [[t]]). The separation of typing contexts in two parts is not essential. In fact, there is a bijection (modulo semantic equality) between terms of the form ; x: t;? `2 e 1 : t and those of the form ; x: [t];? `2 e 2 : t given by e 1 7! let box x = x in e 1 e 2 7! e 2 [x: = box x] By analogy with the adjoint calculus [Ben95, BW96]), one may consider a variant of 2 in which the category C and context separation have a more prominent role.

5 hei,! n hvi e 1,! x:e e2 1 e[x: = v 1 ] 2 x:e,! x:e e 1 e 2 2 e i i e[x i : = v i ] e,! close v close e with x i = e i,! close v x,! x c,! c e i i close e with x i = e i,! close e with xi = v i open e,! v e 1 1 e 2 2 e 1 e 2 1 v 2 open,! open v e,! hvi ~e 1 e,! close hv i v safe run e,! close v x:,! x:v ~+,! ~v safe run,! safe run v Figure 2: Big-Step Operational Semantics of BN In BN the closed types and open code types coexists, so the key point is to clarify how the modalities of 2 and interact. The basic idea is that a BN -model is a 2 -model where the category D has the structure of a -model parameterized w.r.t. C. To formalize this notion of parameterization, we introduce the following auxiliary denition: Denition 3.7 Given an FP-functor F : C! D the simple C-indexed FP-category D F : C op! Cat is de- ned as follows jd F X j = jdj and D F X (A; B) = D(F X A; B). composition of g 2 DX F (A; B) and h 2 DF X (B; C) is F X A h 1; gi ẖ - F X B C 2 D F X (A; C), while the identity for A in DX F is the second projection 2 : F X A! A. substitution functor f : D F X! DF Y along f 2 C(Y; X) is given by f (A) = A and f (g) = g (F f id). D F is called simple because the action on objects of the substitution functor f is the identity. Proposition 3.8 The simple indexed category D F of Denition 3.7 has: Y Y nite products, i.e. DX F (A; B i) = DX F (A; B i ) i2m i2m exponentials, i.e. D F X (C A; B) = D F X (C; BA ), provided D is CCC simple comprehension, i.e. D F X (1; A) = C(X; GA), provided F a G is an FP-adjunction (c.f. [Mog97]). Denition 3.9 An BN -model is given by a CCC D, G - an FP-adjunction D > C, and a C-indexed full and faithful CCC-functor D F F N - DF. Remark 3.1 The pattern for interpreting BN is like that for, i.e. a type t is interpreted by an object [[t]] of D, namely [[[t]]] = B[[t]], [[hti]] = N[[t]] and [[t 1! t 2 ]] = [[t 2 ]] [t 1 ] where B is the FP-comonad induced by the FPadjunction F a G, and a term Y fx i : t ni i ji 2 mg ` e: tn is interpreted by a map in D( N ni [[t i ]]; N n [[t]]). i2m Any BN -model supports both a restricted form of cross-stage persistence, and the possibility of executing closed code: Proposition 3.11 (Cross-stage persistence) In a BN -model there is a canonical morphism up: FX! NFX in D. Proof: We have the natural isomorphisms (note that the adjunction F a G is not used) D(FX; FY ) = by denition of D F X D F X (1; FY ) = because N is full and faithful D F X (N1; NFY ) = because N is a CCC-functor D F X (1; NFY ) = by denition of D F X D(FX; NFY )

6 We dene up: FX! NFX as the morphism corresponding to the identity over FX when Y = X (in general up is not an isomorphism). Proposition 3.12 (Compile) In a BN -model there is a canonical iso compile: GNA! GA in C. Proof: We have the natural isomorphisms C(X; GA) = by F a G D(FX; A) = by denition of D F X D F X (1; A) = because N is full and faithful D F X (N1; NA) = because N is a CCC-functor D F X (1; NA) = by denition of D F X D(FX; NA) = by F a G C(X; GNA) We dene compile: GNA! GA as the morphism corresponding to the identity over GNA when X = GNA, while the inverse of compile is the morphism corresponding to the identity over GA when X = GA. 3.1 Examples We give examples of BN -models parameterized w.r.t. a category A, making explicit what additional structure or properties are needed on A in each instance. For each example we dene the categories C and D, and the action on objects of the functors N, F and G. Example 3.13 Let N be the set of naturals. Given a CCC A with N-indexed products, take C = A and D = A N, hence an object A 2 jdj is a sequence (A n 2 jajjn 2 N) and a map f 2 D(A; B) is a sequence (f n 2 A(A n ; B n )jn 2 N). NA = 1: : A, where 1 is the terminal object of A FX = (Xjn 2 N), i.e. the sequence which is constantly X, while GA = Y n2n A n. Exponentials in D are dened pointwise in terms of exponentials in A, i.e. (B A ) n = B An n. Example 3.14 Let! op be the category of natural numbers with the reverse order, i.e. 1 : : : n : : : Given a CCC A with nite and! op -limits, take C = A and D = A!op, hence a map f 2 D(A; B) amounts to a commuting diagram A a f f 1?? B B 1 b A 1 : : : A n a n A : : : : : : f n f : : :?? : : : B n B : : : b n while an object of D is a sequence of maps in A. NA =! A : : A, where! A is the map 1 A in A FX = (id: X Xjn 2 N), i.e. the sequence which is constantly id X, while GA = lim n2! op A n. Exponentials in D are not dened pointwise, but existence of exponentials and nite limits in A ensures that D has exponentials (and nite limits). In this model we have a natural transformation up: A! NA, namely up =!: A! 1 and up = a n : A! A n, which provides cross-stage persistence for arbitrary types. Finally we give an example which is both a 2 - and -model, but fails to be a BN -model. More precisely, it has the structure of a BN -model, but the C-indexed functor N fails to be full and faithful, so we don't have the iso compile: GNA! GA of Proposition Example 3.15 Given a CCC A with nite limits, take C = A!op and D = A N NA = 1: : A, where 1 is the terminal object of A (FX) n = X n, i.e. forget the maps x n : X! X n, while (GA) n = Y in A i with the obvious projection : (GA)! (GA) n. N extends to a C-indexed CCC-functor on D F, namely its action on morphisms of DX F maps f 2 DF X (A; B) to g 2 DX F (NA; NB), where g =!: X 1! 1 and g = X A n x n iḏ Xn A n f n - Bn Therefore N fails to be full and faithful on D F X, unless X 2 C is a constant sequence.

7 [[? ` c: t n c ]] = [[c]] n!: C! N n [[t c ]] [[? ` x: t k ]] = up k;n x : C! N k (BA) if [t] n =?(x) and k > [[? ` x: t n ]] = x : C! N n A if t n =?(x) [[?; x: t n ` e: t n ]] = f: C N n A! N n B [[? ` x:e: t! t n ]] = n (f): C! N n (B A ) [[? ` e: t ]] = f: C! N A [[? ` hei: hti n ]] = f: C! N n (NA) [[? ` e i : [t i ] n ]] = f i : C! N n (BA i ) [[fx i : [t i ] jig ` e: t ]] = f: Q i BA i! A [[? ` close e with x i = e i : [t] n ]] = close n (f) hf i jii: C! N n (BA) [[? ` e: [hti] n ]] = f: C! N n (BNA) [[? ` safe run e: [t] n ]] = run n f: C! N n (BA) [[? ` e: [t] n ]] = f: C! N n (BA) [[? ` open e: t n ]] = open n f: C! N n A [[? ` e: hti n ]] = f: C! N n (NA) [[? ` ~e: t ]] = f: C! N A where C = [[?]], A = [[t]], B = [[t ]] and A i = [[t i ]]. [[? ` e 1 : t! t n ]] = f 1 : C! N n (B A ) [[? ` e 2 : t n ]] = f 2 : C! N n A [[? ` e 1 e 2 : t n ]] n hf 1 ; f 2 i: C! N n B Figure 3: Pure Interpretation in BN -Models 3.2 Interpretation of terms We have already given the interpretation of types in a BN -model without computational eects, namely [[[t]]] = B[[t]], [[hti]] = N[[t]] and [[t 1! t 2 ]] = [[t 2 ]] [t 1 ] This section gives the corresponding interpretation of terms. Before doing that, we introduce some auxiliary morphisms in D, which simplify the denition of the interpretation, and clarify the similarities with the interpretation of the simply typed -calculus in a CCC. Given op: Q i A i! A we dene op n = N n op: Y i N n A i! N n A where we exploit that N preserves nite products. n : (N n B) NnA! N n B A. Since N preserves the CCC structure, n is the iso (N n B) NnA! N n B n = eval n : N n B A N n A! N n B. Since N preserves the CCC n is (up to iso) an instance of evaluation eval: (N n B) NnA N n A! N n B. open n = n : N n BA! N n A, where : BA! A is the co-unit of the co-monad B. close n (f) = (Bf ) n : Q i Nn BA i! N n BC, where f: Q i BA i! C and : BA! B 2 A is the comultiplication of B, and we exploit that N and B preserve nite products. up k;n = (up k ) n : N n BA! NkBA, where up: BA! NBA is the morphism of Proposition run n = (F compile) n : N n BNA! NnBA, where compile: GNA! GA is the iso of Proposition Figure 3 denes the interpretation of a well-formed term? ` e: t n by induction on the typing derivation in the type system of Figure 1. 4 Modalities and monads We have given a simplied interpretation of BN (and its multi-stage sub-languages) in the absence of computational eects. This interpretation is the analog of the interpretation of the simply typed -calculus in a CCC. However, we are interested in multistage programming languages, like Mini-ML 2 [DP96], Mini-ML [Dav96], and MetaML [TS97], where logical modalities coexist with computational eects. In this section we dene monadic BN -models and give a monadic CBV interpretation of BN in such models, extending the interpretation sketched in [Mog91]. Denition 4.1 A monadic BN -model consists of a BN -model equipped with a strong monad M over D s.t. the canonical morphism M NB A! (M NB) NA is an iso, and we call : (M NB) NA! M NB A its inverse

8 a strong natural transformation : BM A! M BA respecting the structure of the strong monad M and the FP-comonad B, i.e. M preserves pullbacks, and the commuting square M(B A ) e - (M B) A M A BM 2 A M - M BM A - M 2 BA BM A - M BA BM A - M @? B 2 M A BM BA - M B B- 2 A BA Remark 4.2 The intuition here is that the strong monad M models conventional computations, i.e. those at level. Staged computations are achieved by an alternation of M and N, namely we dene the type M n A of n-staged computations of type A as (M N) n M A. In general, M n is not a monad, however the natural transformations and for M induces natural transformations n : N n A! M n A and n : (M 2 N) n M 2 A! M n A. The isomorphism : (M NB) NA! M NB A renes the isomorphism (NB) NA! NB A corresponding to preservation of exponentials by N. is essential to de- ne the interpretation of -abstraction at level n >, and also to dene the analog of let: (M B) A M A! M B for M n, namely let n : (M n B) NnA M n A! M n B. The natural transformation : BM A! M BA and its properties can be intuitively justied as follows. Think of BA as the subset of values of type A without \free dynamic variables", so is saying that a computation without \free dynamic variables" is guaranteed to return a value without \free dynamic variables". is essential for interpreting Safe-Run and Close-With. Example 3.13 fails to extend to a monadic BN -model for monads as simple as lifting, because does not exists. However, we can extend the BN -model of Example 3.14: Example 4.3 Given a strong monad M over A s.t. M!? M1 (M)? - (M1) A k (M!) A is a pullback, where k(u) = x: A:u and e(u) = x: A:doff u; ret (fx)g M preserves! op -limits the induced strong monad M over A!op, i.e. M A = M A M a M A 1 : : : M A n M a n M A : : : satises the additional requirements for having a monadic BN -model, namely the rst property of M over A ensures the existence of the isomorphism : (M NB) NA! M NB A (exponentials in A!op are computed using exponentials and pullbacks in A); the second property of M over A allows us to dene the natural transformation : BM A! M BA as the isomorphism corresponding to preservation of! op - limits by M. Remark 4.4 Many monads over the category of cpos (e.g. lifting) satisfy the additional properties required in Example 4.3, moreover several monad transformers (e.g. for adding a global state or exceptions) preserve such properties. However, there are monads which fail to satisfy the additional properties, notably powerdomains and continuations. Interpretation of types. A type t is interpreted (as usual) by an object [[t]] of D, namely: [[[t]]] = B[[t]]; [[hti]] = NM[[t]]; [[t 1! t 2 ]] = (M[[t 2 ]]) [t 1 ] In a monadic BN -model a term Y fx i : t ni i ji 2 mg ` e: tn is interpreted by a map in D( N ni [[t i ]]; M n [[t]]). i2m Remark 4.5 This interpretation is a renement of the interpretation given in Section 3.2, which is recovered by replacing M with the identity monad, and it extends the monadic CBV interpretation of the simply typed -calculus (in a CCC with a strong monad).

9 [[? ` c: t n c ]] = [[c]] n!: C! M n [[t c ]] [[? ` x: t k ]] = up k;n x : C! M k (BA) if [t] n =?(x) and k > [[? ` x: t n ]] = n x : C! M n A if t n =?(x) [[? ` e: [hti] n ]] = f: C! M n (BNM A) [[? ` safe run e: [t] n ]] = run n f: C! M n (BA) [[?; x: t n ` e: t n ]] = f: C N n A! M n B [[? ` e: [t] ]] = f: C! M n (BA) [[? ` x:e: t! t n ]] = n (f): C! M n (M B) A [[? ` open e: t n ]] = open n f: C! M n A [[? ` e: t ]] = f: C! M A [[? ` hei: hti n ]] = f: C! M n (NM A) [[? ` e i : [t i ] n ]] = f i : C! M n (BA i ) [[fx i : [t i ] jig ` e: t ]] = f: Q i BA i! M A [[? ` close e with x i = e i : [t] n ]] = close n (f) hf i jii: C! M n (BA) [[? ` e: hti n ]] = f: C! M n (NM A) [[? ` ~e: t ]] = f: C! M A where C = [[?]], A = [[t]], B = [[t ]] and A i = [[t i ]]. [[? ` e 1 : t! t n ]] = f 1 : C! M n (M B) A [[? ` e 2 : t n ]] = f 2 : C! M n A [[? ` e 1 e 2 : t n ]] n hf 1 ; f 2 i: C! M n B Figure 4: Monadic Interpretation in BN -Models Auxiliary morphisms. We introduce some auxiliary morphisms in D (see also Notation 1.1), similar to those given Q Q in Section 3.2. Given op: i A i! M B we dene op n : i M na i! M n B by induction on n: Y op ) M A i - M B i Y ) i M A i - M N Y M n A M Nop n R M B Q Q where : i M A i! M( i A i) is given by (u i ji) = dofx i u i ; ret (x i ji)g, and we exploit that N preserves nite products. n : N n A! M n A is given by induction: ) A - M A ) N A - M N A M N ṉ M A where : A! M A is the unit of the monad M. n : (M n B) NnA! M n (M B) A is given by induction: ) (M B) A - M(M B) A ) (M B) N A - M N(M n B) M N n R M (M B) n = eval n : M n (M B) A M n A! M n B, where eval: (M B) A A! M B is evaluation. open n = M n : M n BA! M n A, where : BA! A is the co-unit for B. close n (f) = ( (Bf) ) n : Q i M nba i! M n BC, where f: Q i BA i! M C and : BA! B 2 A is the comultiplication for B, and we exploit that B preserves nite products. up k;n = N n BA Nn (up k ) - N k BA ḵ Mk BA, where up: BA! NBA is the morphism of Proposition run n = ( F compile) n : M n BNM A! M n BA, where compile: GNA! GA is the iso of Proposition The interpretation of terms. Figure 4 denes the interpretation of a well-formed term? ` e: t n by induction on the typing derivation in the type system of Figure 1. 5 Discussion Searching for a categorical semantics of MetaML has beneted us in a number of ways: It has suggested simplications and extensions. We have simplied the type system of MetaML and proposed an extension with closed code types called AIM

10 (see [MTBS99]). BN is the result of further simpli- cation of AIM and the associated model. Explaining multi-stage languages in terms of more primitive concepts, namely logical modalities (in the sense that the modalities are characterized by universal properties) and computational monads. We have shown that a simple interaction between the two modalities in our models accounts for execution of closed code. Finally, we have pointed out what kinds of computational eects should be expected to integrate easily with multi-stage languages. 5.1 BN Compared to AIM Recently, we presented AIM (An Idealized MetaML) [MTBS99], which extends MetaML with an analog of the Box type of 2 yielding a more expressive language, yet has a simpler typing judgment than MetaML. We have shown that we can embed all three languages into AIM. BN can be viewed as a cut-down version of AIM which we believe is suciently expressive for the purposes of multi-stage programming. The Closed type constructor of BN is essentially a strict version of the Box type constructor of AIM. In AIM, the Box construct delayed its argument. To the programmer, this meant that there were two \code" types. This causes some confusion from the point of view of multi-stage programming, because manipulating values of type [hai] would be read as \closed code of open code of A". Not only is this a cumbersome reading, it makes it harder for the programmer to reason about when computations are performed. In BN, we have made the pragmatic decision that Closed should not delay its argument, and so, types such as [hai] can be read as simply \closed code of A". In other words, we propose to use the Necessity modality only for asserting closedness, and not for delaying evaluation. Another dierence is that AIM was a \superset" of the three languages that we had studied (i.e., 2, and MetaML), while BN is not. We have shown that can be embedded into the open fragment of AIM, and 2 into the closed fragment. This establishes a strong relation between the closed code and open code types of AIM and the Necessity and Next modalities of modal and temporal logic. The embedding of and 2 in AIM can be turned into an embedding in BN (the embedding of 2 needs to be modied to take into account the fact that Closed in BN is strict, i.e. it does not delay the evaluation of its argument). On the other hand, the embedding of MetaML in AIM cannot be adapted for the following two reasons: 1. BN does not have full cross-stage persistence. Not having cross-stage persistence simplies the model. At the same time, from the pragmatic point of view, cross-stage persistence for closed types is sucient, 2. BN does not have Run. We were not able to nd a general categorical interpretation for this construct, though [BMTS98] shows how to interpret Run in A!op. At the same time, the pragmatic need for Run disappears in the presence of safe run. References [Ben95] N. Benton. A mixed linear and non-linear logic: Proofs, terms and models. LNCS, 933, [BMTS98] Z. Benaissa, E. Moggi, W. Taha, and T. Sheard. A categorical analysis of multilevel languages (extended abstract). Technical Report CSE-98-18, Oregon Graduate Institute, December ftp://cse.ogi.edu/pub/tech-reports/. [BW96] N. Benton and P. Wadler. Linear logic, monads and the lambda calculus. In 11 th LICS, New Brunswick, New Jersey, 27{3 July IEEE Computer Society Press. [Dav96] R. Davies. A temporal-logic approach to binding-time analysis. In 11 th LICS, New Brunswick, New Jersey, July IEEE Computer Society Press. [DP96] R. Davies and F. Pfenning. A modal analysis of staged computation. In 23rd POPL, St.Petersburg Beach, Florida, January [Mas93] A. Masini. 2-Sequent calculus: Intuitionism and natural deduction. Journal of Logic and Computation, 3(5), [MM96] S. Martini and A. Masini. A computational interpretation of modal proofs. In H. Wansing, editor, Proof Theory of Modal Logic. Kluwer, [Mog91] E. Moggi. Notions of computation and monads. Information and Computation, 93(1), [Mog97] E. Moggi. A categorical account of twolevel languages. In MFPS 1997, 1997.

11 [MTBS98] E. Moggi, W. Taha, Z. Benaissa, and T. Sheard. An idealized MetaML: Simpler, and more expressive (includes proofs). Technical Report CSE-98-17, Oregon Graduate Institute, October ftp://cse.ogi.edu/pub/tech-reports/. [MTBS99] E. Moggi, W. Taha, Z. Benaissa, and T. Sheard. An idealized MetaML: Simpler, and more expressive (includes proofs). In European Symposium on Programming (ESOP), volume 1576 of LNCS. Springer- Verlag, [RZ91] G.E. Reyes and H. Zolfaghari. Topostheoretic approaches to modalities. In A. Carboni, C. Pedicchio, and G. Rosolini, editors, Conference on Category Theory '9, volume 1488 of LNM. Springer-Verlag, [Tah99] W. Taha. Multi-Stage Programming: Its Theory and Applications. PhD thesis, Oregon Graduate Institute of Science and Technology, June To appear. [TBS98] [TS97] W. Taha, Z. Benaissa, and T. Sheard. Multi-stage programming: Axiomatization and type-safety. In 25th ICALP, Aalborg, Denmark, W. Taha and T. Sheard. Multi-stage programming with explicit annotations. In PEPM. ACM, [TS99] W. Taha and T. Sheard. MetaML and multi-stage programming with explicit annotations. Technical Report CSE-99-7, Oregon Graduate Institute, January ftp://cse.ogi.edu/pub/tech-reports/. ;? ` c: t c ;? ` x: t if t = (x) or?(x) ;?; x: t 1 ` e: t 2 ;? ` x:e: t 1! t 2 ; ; ` e: t ;? ` box e: [t] ;? ` e 1 : t 1! t 2 ;? ` e 2 : t 1 ;? ` e 1 e 2 : t 2 ;? ` e 1 : [t 1 ] ; x: t 1 ;? ` e 2 : t 2 ;? ` let box x = e 1 in e 2 : t 2 Figure 5: 2 Type System? ` c: t n c? ` x: t n if t n =?(x)?; x: t n 1 ` e: t n 2? ` x:e: (t 1! t 2 ) n? ` e 1 : (t 1! t 2 ) n? ` e 2 : t n 1? ` e 1 e 2 : t n 2? ` e: t? ` hei: hti n? ` e: hti n? ` ~e: t Figure 6: Type System? ` x: t n if t m =?(x) and m n? + ` e: hti n? ` run e: t n Figure 7: MetaML Type System (+ Figure 6) A Multi-Stage Languages For completeness, this appendix reproduces the syntax and type system of the multi-stage languages 2,, MetaML and AIM (see [MTBS99, MTBS98] for details). We adopt the following unied notation for types: 2 T : : = b j t 1! t 2 j hti j [t] i.e. base types, functions, open code fragments, and closed code fragments.? ` x: t n if t m =?(x) and m n? ` e i : [t i ] n? +1 ; fx i : [t i ] n ji 2 mg ` e: hti n? ` run e with x i = e i : t n? ` e i : [t i ] n fx i : [t i ] ji 2 mg ` e: t? ` box e with x i = e i : [t] n? ` e: [t] n? ` unbox e: t n Figure 8: AIM Type System (+ Figure 6)

12 e 1,! x:e e2 1 e[x: = v 1 ] 2 x:e,! x:e e 1 e 2 2 e i i box e with x i = e i,! box e[xi : = v i ] hei,! n hvi x:,! x:v x,! x c,! c ~+,! ~v e,! box e e unbox e,! v e 1 1 e 2 2 e 1 e 2 1 v 2 unbox,! unbox v e,! hvi ~e 1 e i i e[x i : = v i ],! hv i v run e with x i = e i e i i box e with x i = e i,! box e with xi = v i e i i run e with x i = e i,! run v with xi = v i Figure 9: Big-Step Operational Semantics for AIM (including and MetaML) 2 of [DP96] features function and closed code types. Typing judgments have the form ;? ` e: t, where ;? fx i : t i ji 2 mg. The syntax for 2 is as follows: e 2 E: : = c j x j x:e j e 1 e 2 j box e j let box x = e 1 in e 2 They are needed to establish Subject Reduction. The type system of 2 is given in Figure 5. Promotion for BN reects the fact that cross-stage persistence is available only for closed types., MetaML and AIM feature function and open code types. Typing judgments have the form? ` e: t n, where? fx i : t ni i ji 2 mg and n is a natural called the level of the term. The syntax for is as follows: e 2 E: : = c j x j x:e j e 1 e 2 j hei j ~e MetaML [TS97, TBS98] uses a more relaxed type rule for variables than, in that variables can be bound at a level lower than the level where they are used. This is called cross-stage persistence. Furthermore, MetaML extends the syntax of to e 2 E: : = c j x j x:e j e 1 e 2 j hei j ~e j run e B Technical Lemmas We state some technical lemmas for BN, which are adaptations of those establised for AIM in [MTBS98]. Lemma B.1 (Promotion) If ;? ` e: t n then ;? +1 ` e: t 1, where is of the form fx i : [t i ] ni g. Proof: Induction on the derivation of ;? ` e: t n. In BN Weakening and Orthogonality are as in AIM, while Substitution holds only in a very restricted form, which suces for proving Subject Reduction. Lemma B.2 (Weakening) If? 1 ;? 2 ` e 2 : t n 2 and x is fresh, then? 1 ; x: t n 1 ;? 2 ` e 2 : t n 2. Lemma B.3 (Orthogonality) If v 2 V and? ` v: [t] then ; ` v: [t]. AIM [MTBS99] extends MetaML with an analog of the Box type of 2 yielding a more expressive language, and yet has a simpler typing judgment than MetaML. The syntax of AIM extends that of MetaML as follows: e 2 E: : = c j x j x:e j e 1 e 2 j hei j ~e j run e with fx i = e i ji 2 mg j box e with fx i = e i ji 2 mg j unbox e Run-With generalizes Run of MetaML, in that it allows the use of additional variables x i in the body of e if they satisfy certain typing requirements. The type systems of, MetaML and AIM are given in Figure 6, 7 and 8, while the big-step operational semantics of AIM and its sub-languages is in Figure 9. Proposition B.4 (Substitution) If? 1 ` v: t 1 with v 2 V and? 1 ; x: t 1 ;? 2 ` e: t n 2 then? 1 ;? 2 ` e[x: = v]: t n 2. In BN one cannot dene demotion (as in AIM). This is not a problem, since the Demotion Lemma was used only in the case run e with x i = e i of Subject Reduction. However, we still need Orthogonality and Value Reection in the case safe run e. Proposition B.5 (Value Reection) If v 2 V 1 and? +1 ` v: t 1, then? ` v: t n. Proof: Induction on the derivation of? +1 ` v: t 1, and case analysis on v 2 V 1.

A categorical model for a quantum circuit description language

A categorical model for a quantum circuit description language A categorical model for a quantum circuit description language Francisco Rios (joint work with Peter Selinger) Department of Mathematics and Statistics Dalhousie University CT July 16th 22th, 2017 What

More information

Constructive Linear-Time Temporal Logic: Proof Systems and Kripke Semantics

Constructive Linear-Time Temporal Logic: Proof Systems and Kripke Semantics Constructive Linear-Time Temporal Logic: Proof Systems and Kripke Semantics Kensuke Kojima, Atsushi Igarashi Graduate School of Informatics Kyoto University Kyoto, Japan Abstract In this paper we study

More information

Parameterizations and Fixed-Point Operators on Control Categories

Parameterizations and Fixed-Point Operators on Control Categories Parameterizations and Fixed-Point Operators on Control Categories oshihiko Kakutani 1 and Masahito Hasegawa 12 1 Research Institute for Mathematical Sciences, Kyoto University {kakutani,hassei}@kurims.kyoto-u.ac.jp

More information

Sequents are written as A, where A; B represent formulae and ; represent multisets of formulae. Where represents the multiset A 1 ; : : : ; A n, then!

Sequents are written as A, where A; B represent formulae and ; represent multisets of formulae. Where represents the multiset A 1 ; : : : ; A n, then! What is a Categorical Model of ntuitionistic Linear Logic G.M. Bierman University of Cambridge Computer Laboratory Abstract. This paper re-addresses the old problem of providing a categorical model for

More information

by Say that A is replete (wrt ) if it is orthogonal to all f: X Y in C such that f : Y X is iso, ie for such f and all there is a unique such that the

by Say that A is replete (wrt ) if it is orthogonal to all f: X Y in C such that f : Y X is iso, ie for such f and all there is a unique such that the Electronic Notes in Theoretical Computer Science 6 (1997) URL: http://wwwelseviernl/locate/entcs/volume6html 6pages Studying Repleteness in the Category of Cpos Michael Makkai 1 Department of Mathematics

More information

2 M. Hasegawa thus strengthens the claim that Girard translation is the canonical translation from intuitionistic logic to linear logic. This seems to

2 M. Hasegawa thus strengthens the claim that Girard translation is the canonical translation from intuitionistic logic to linear logic. This seems to Under consideration for publication in J. Functional Programming 1 Girard Translation and Logical Predicates Masahito Hasegawa Research Institute for Mathematical Sciences, Kyoto University Kyoto 606-8502

More information

Boolean Algebra and Propositional Logic

Boolean Algebra and Propositional Logic Boolean Algebra and Propositional Logic Takahiro Kato September 10, 2015 ABSTRACT. This article provides yet another characterization of Boolean algebras and, using this characterization, establishes a

More information

The equivalence axiom and univalent models of type theory.

The equivalence axiom and univalent models of type theory. The equivalence axiom and univalent models of type theory. (Talk at CMU on February 4, 2010) By Vladimir Voevodsky Abstract I will show how to define, in any type system with dependent sums, products and

More information

Staged Notational Definitions

Staged Notational Definitions Staged Notational Definitions Walid Taha 1 and Patricia Johann 2 1 Department of Computer Science, Rice University, taha@cs.rice.edu 2 Department of Computer Science, Rutgers University, pjohann@crab.rutgers.edu

More information

Boolean Algebra and Propositional Logic

Boolean Algebra and Propositional Logic Boolean Algebra and Propositional Logic Takahiro Kato June 23, 2015 This article provides yet another characterization of Boolean algebras and, using this characterization, establishes a more direct connection

More information

Elements of Category Theory

Elements of Category Theory Elements of Category Theory Robin Cockett Department of Computer Science University of Calgary Alberta, Canada robin@cpsc.ucalgary.ca Estonia, Feb. 2010 Functors and natural transformations Adjoints and

More information

A General Semantics for Evaluation Logic

A General Semantics for Evaluation Logic A General Semantics for Evaluation Logic Eugenio Moggi moggi@disi.unige.it DISI, Univ. of Genova v.le Benedetto XV 3, 16132 Genova, ITALY Abstract The semantics of Evaluation Logic proposed in [14] relies

More information

Non-elementary Lower Bound for Propositional Duration. Calculus. A. Rabinovich. Department of Computer Science. Tel Aviv University

Non-elementary Lower Bound for Propositional Duration. Calculus. A. Rabinovich. Department of Computer Science. Tel Aviv University Non-elementary Lower Bound for Propositional Duration Calculus A. Rabinovich Department of Computer Science Tel Aviv University Tel Aviv 69978, Israel 1 Introduction The Duration Calculus (DC) [5] is a

More information

Towards Modal Type Theory

Towards Modal Type Theory Towards Modal Type Theory Frank Pfenning Constructivism in Non-Classical Logics and Computer Science In Memoriam Pierangelo Miglioli Mantova, Italy October 2, 2000 Disclaimer: Work in Progress! Acknowledgments:

More information

Higher Order Containers

Higher Order Containers Higher Order Containers Thorsten Altenkirch 1, Paul Levy 2, and Sam Staton 3 1 University of Nottingham 2 University of Birmingham 3 University of Cambridge Abstract. Containers are a semantic way to talk

More information

Semantics for algebraic operations

Semantics for algebraic operations MFPS 17 Preliminary Version Semantics for algebraic operations Gordon Plotkin and John Power 1 Laboratory for the Foundations of Computer Science University of Edinburgh King s Buildings, Edinburgh EH9

More information

1 Categorical Background

1 Categorical Background 1 Categorical Background 1.1 Categories and Functors Definition 1.1.1 A category C is given by a class of objects, often denoted by ob C, and for any two objects A, B of C a proper set of morphisms C(A,

More information

COMMUTATIVE ALGEBRA LECTURE 1: SOME CATEGORY THEORY

COMMUTATIVE ALGEBRA LECTURE 1: SOME CATEGORY THEORY COMMUTATIVE ALGEBRA LECTURE 1: SOME CATEGORY THEORY VIVEK SHENDE A ring is a set R with two binary operations, an addition + and a multiplication. Always there should be an identity 0 for addition, an

More information

Logic for Computational Effects: work in progress

Logic for Computational Effects: work in progress 1 Logic for Computational Effects: work in progress Gordon Plotkin and John Power School of Informatics University of Edinburgh King s Buildings Mayfield Road Edinburgh EH9 3JZ Scotland gdp@inf.ed.ac.uk,

More information

The category of open simply-typed lambda terms

The category of open simply-typed lambda terms The category of open simply-typed lambda terms Daniel Murfet based on joint work with William Troiani o Reminder on category theory Every adjunction gives rise to a monad C F / G D C(Fx,y) = D(x, Gy) C(FGx,x)

More information

1. Introduction and preliminaries

1. Introduction and preliminaries Quasigroups and Related Systems 23 (2015), 283 295 The categories of actions of a dcpo-monoid on directed complete posets Mojgan Mahmoudi and Halimeh Moghbeli-Damaneh Abstract. In this paper, some categorical

More information

distinct models, still insists on a function always returning a particular value, given a particular list of arguments. In the case of nondeterministi

distinct models, still insists on a function always returning a particular value, given a particular list of arguments. In the case of nondeterministi On Specialization of Derivations in Axiomatic Equality Theories A. Pliuskevicien_e, R. Pliuskevicius Institute of Mathematics and Informatics Akademijos 4, Vilnius 2600, LITHUANIA email: logica@sedcs.mii2.lt

More information

University of Oxford, Michaelis November 16, Categorical Semantics and Topos Theory Homotopy type theor

University of Oxford, Michaelis November 16, Categorical Semantics and Topos Theory Homotopy type theor Categorical Semantics and Topos Theory Homotopy type theory Seminar University of Oxford, Michaelis 2011 November 16, 2011 References Johnstone, P.T.: Sketches of an Elephant. A Topos-Theory Compendium.

More information

Semantics and syntax of higher inductive types

Semantics and syntax of higher inductive types Semantics and syntax of higher inductive types Michael Shulman 1 Peter LeFanu Lumsdaine 2 1 University of San Diego 2 Stockholm University http://www.sandiego.edu/~shulman/papers/stthits.pdf March 20,

More information

Adjoint Logic and Its Concurrent Semantics

Adjoint Logic and Its Concurrent Semantics Adjoint Logic and Its Concurrent Semantics Frank Pfenning ABCD Meeting, Edinburgh, December 18-19, 2017 Joint work with Klaas Pruiksma and William Chargin Outline Proofs as programs Linear sequent proofs

More information

Compositionality in SLD-derivations and their abstractions Marco Comini, Giorgio Levi and Maria Chiara Meo Dipartimento di Informatica, Universita di

Compositionality in SLD-derivations and their abstractions Marco Comini, Giorgio Levi and Maria Chiara Meo Dipartimento di Informatica, Universita di Compositionality in SLD-derivations and their abstractions Marco Comini Giorgio Levi and Maria Chiara Meo Dipartimento di Informatica Universita di Pisa Corso Italia 40 56125 Pisa Italy fcomini levi meog@di.unipi.it

More information

J. Functional Programming 1 (1): 1{000, January 1993 c 1993 Cambridge University Press 1 V.C.V. DE PAIVA

J. Functional Programming 1 (1): 1{000, January 1993 c 1993 Cambridge University Press 1 V.C.V. DE PAIVA J. Functional Programming 1 (1): 1{000, January 1993 c 1993 Cambridge University Press 1 Computational Types from a Logical Perspective P.N. BENTON Persimmon IT Inc., Cambridge G.M. BIERMAN Gonvil le and

More information

and one into the linear calculus, yielding a semantics in L. For we use a trivial mapping into the monadic calculus and Girard's translation into the

and one into the linear calculus, yielding a semantics in L. For we use a trivial mapping into the monadic calculus and Girard's translation into the Linear Logic, Monads and the Lambda Calculus Nick Benton University of Cambridge Computer Laboratory New Museums Site Pembroke Street Cambridge CB2 3QG, UK Nick.Benton@cl.cam.ac.uk Philip Wadler University

More information

Denotational semantics of linear logic

Denotational semantics of linear logic Denotational semantics of linear logic Lionel Vaux I2M, Université d Aix-Marseille, France LL2016, Lyon school: 7 and 8 November 2016 L. Vaux (I2M) Denotational semantics of linear logic LL2016 1 / 31

More information

1 The Hyland-Schalke functor G Rel. 2 Weakenings

1 The Hyland-Schalke functor G Rel. 2 Weakenings 1 The Hyland-Schalke functor G Rel Let G denote an appropriate category of games and strategies, and let Rel denote the category of sets and relations. It is known (Hyland, Schalke, 1996) that the following

More information

Information and Computation

Information and Computation Information and Computation 209 (2011) 1491 1503 Contents lists available at SciVerse ScienceDirect Information and Computation www.elsevier.com/locate/yinco Constructive linear-time temporal logic: Proof

More information

for Propositional Temporal Logic with Since and Until Y. S. Ramakrishna, L. E. Moser, L. K. Dillon, P. M. Melliar-Smith, G. Kutty

for Propositional Temporal Logic with Since and Until Y. S. Ramakrishna, L. E. Moser, L. K. Dillon, P. M. Melliar-Smith, G. Kutty An Automata-Theoretic Decision Procedure for Propositional Temporal Logic with Since and Until Y. S. Ramakrishna, L. E. Moser, L. K. Dillon, P. M. Melliar-Smith, G. Kutty Department of Electrical and Computer

More information

Wolfgang Jeltsch. Seminar talk at the Institute of Cybernetics Tallinn, Estonia

Wolfgang Jeltsch. Seminar talk at the Institute of Cybernetics Tallinn, Estonia in in Brandenburgische Technische Universität Cottbus Cottbus, Germany Seminar talk at the Institute of Cybernetics Tallinn, Estonia February 10, 2011 in in in trueness of a proposition depends on time

More information

The Morita-equivalence between MV-algebras and abelian l-groups with strong unit

The Morita-equivalence between MV-algebras and abelian l-groups with strong unit The Morita-equivalence between MV-algebras and abelian l-groups with strong unit Olivia Caramello and Anna Carla Russo December 4, 2013 Abstract We show that the theory of MV-algebras is Morita-equivalent

More information

Categories and Modules

Categories and Modules Categories and odules Takahiro Kato arch 2, 205 BSTRCT odules (also known as profunctors or distributors) and morphisms among them subsume categories and functors and provide more general and abstract

More information

2 C. A. Gunter ackground asic Domain Theory. A poset is a set D together with a binary relation v which is reexive, transitive and anti-symmetric. A s

2 C. A. Gunter ackground asic Domain Theory. A poset is a set D together with a binary relation v which is reexive, transitive and anti-symmetric. A s 1 THE LARGEST FIRST-ORDER-AXIOMATIZALE CARTESIAN CLOSED CATEGORY OF DOMAINS 1 June 1986 Carl A. Gunter Cambridge University Computer Laboratory, Cambridge C2 3QG, England Introduction The inspiration for

More information

UNIVERSAL DERIVED EQUIVALENCES OF POSETS

UNIVERSAL DERIVED EQUIVALENCES OF POSETS UNIVERSAL DERIVED EQUIVALENCES OF POSETS SEFI LADKANI Abstract. By using only combinatorial data on two posets X and Y, we construct a set of so-called formulas. A formula produces simultaneously, for

More information

7. F.Balarin and A.Sangiovanni-Vincentelli, A Verication Strategy for Timing-

7. F.Balarin and A.Sangiovanni-Vincentelli, A Verication Strategy for Timing- 7. F.Balarin and A.Sangiovanni-Vincentelli, A Verication Strategy for Timing- Constrained Systems, Proc. 4th Workshop Computer-Aided Verication, Lecture Notes in Computer Science 663, Springer-Verlag,

More information

Lecture 9: Sheaves. February 11, 2018

Lecture 9: Sheaves. February 11, 2018 Lecture 9: Sheaves February 11, 2018 Recall that a category X is a topos if there exists an equivalence X Shv(C), where C is a small category (which can be assumed to admit finite limits) equipped with

More information

Duality in Probabilistic Automata

Duality in Probabilistic Automata Duality in Probabilistic Automata Chris Hundt Prakash Panangaden Joelle Pineau Doina Precup Gavin Seal McGill University MFPS May 2006 Genoa p.1/40 Overview We have discovered an - apparently - new kind

More information

Categories, Proofs and Programs

Categories, Proofs and Programs Categories, Proofs and Programs Samson Abramsky and Nikos Tzevelekos Lecture 4: Curry-Howard Correspondence and Cartesian Closed Categories In A Nutshell Logic Computation 555555555555555555 5 Categories

More information

Lecture Notes on Intuitionistic Kripke Semantics

Lecture Notes on Intuitionistic Kripke Semantics Lecture Notes on Intuitionistic Kripke Semantics 15-816: Modal Logic Frank Pfenning Lecture 15 March 18, 2010 1 Introduction In this lecture we present an intuitionistic approach to describing a multipleworld

More information

Complete Partial Orders, PCF, and Control

Complete Partial Orders, PCF, and Control Complete Partial Orders, PCF, and Control Andrew R. Plummer TIE Report Draft January 2010 Abstract We develop the theory of directed complete partial orders and complete partial orders. We review the syntax

More information

About categorical semantics

About categorical semantics About categorical semantics Dominique Duval LJK, University of Grenoble October 15., 2010 Capp Café, LIG, University of Grenoble Outline Introduction Logics Effects Conclusion The issue Semantics of programming

More information

Decomposing Modalities

Decomposing Modalities Decomposing Modalities Frank Pfenning Department of Computer Science Carnegie Mellon University Logical Frameworks and Meta-Languages: Theory and Practice (LFMTP 15) Berlin, Germany August 1, 2015 1 /

More information

In a second part, we concentrate on interval models similar to the traditional ITL models presented in [, 5]. By making various assumptions about time

In a second part, we concentrate on interval models similar to the traditional ITL models presented in [, 5]. By making various assumptions about time Complete Proof Systems for First Order Interval Temporal Logic Bruno Dutertre Department of Computer Science Royal Holloway, University of London Egham, Surrey TW0 0EX, United Kingdom Abstract Dierent

More information

Denoting computation

Denoting computation A jog from Scott Domains to Hypercoherence Spaces 13/12/2006 Outline Motivation 1 Motivation 2 What Does Denotational Semantic Mean? Trivial examples Basic things to know 3 Scott domains di-domains 4 Event

More information

only nite eigenvalues. This is an extension of earlier results from [2]. Then we concentrate on the Riccati equation appearing in H 2 and linear quadr

only nite eigenvalues. This is an extension of earlier results from [2]. Then we concentrate on the Riccati equation appearing in H 2 and linear quadr The discrete algebraic Riccati equation and linear matrix inequality nton. Stoorvogel y Department of Mathematics and Computing Science Eindhoven Univ. of Technology P.O. ox 53, 56 M Eindhoven The Netherlands

More information

On Controllability and Normality of Discrete Event. Dynamical Systems. Ratnesh Kumar Vijay Garg Steven I. Marcus

On Controllability and Normality of Discrete Event. Dynamical Systems. Ratnesh Kumar Vijay Garg Steven I. Marcus On Controllability and Normality of Discrete Event Dynamical Systems Ratnesh Kumar Vijay Garg Steven I. Marcus Department of Electrical and Computer Engineering, The University of Texas at Austin, Austin,

More information

The synthetic theory of -categories vs the synthetic theory of -categories

The synthetic theory of -categories vs the synthetic theory of -categories Emily Riehl Johns Hopkins University The synthetic theory of -categories vs the synthetic theory of -categories joint with Dominic Verity and Michael Shulman Vladimir Voevodsky Memorial Conference The

More information

Semantical study of intuitionistic modal logics

Semantical study of intuitionistic modal logics Semantical study of intuitionistic modal logics Department of Intelligence Science and Technology Graduate School of Informatics Kyoto University Kensuke KOJIMA January 16, 2012 Abstract We investigate

More information

Quantum groupoids and logical dualities

Quantum groupoids and logical dualities Quantum groupoids and logical dualities (work in progress) Paul-André Melliès CNS, Université Paris Denis Diderot Categories, ogic and Foundations of Physics ondon 14 May 2008 1 Proof-knots Aim: formulate

More information

Lecture Notes on Combinatory Modal Logic

Lecture Notes on Combinatory Modal Logic Lecture Notes on Combinatory Modal Logic 15-816: Modal Logic Frank Pfenning Lecture 9 February 16, 2010 1 Introduction The connection between proofs and program so far has been through a proof term assignment

More information

Vector Space Basics. 1 Abstract Vector Spaces. 1. (commutativity of vector addition) u + v = v + u. 2. (associativity of vector addition)

Vector Space Basics. 1 Abstract Vector Spaces. 1. (commutativity of vector addition) u + v = v + u. 2. (associativity of vector addition) Vector Space Basics (Remark: these notes are highly formal and may be a useful reference to some students however I am also posting Ray Heitmann's notes to Canvas for students interested in a direct computational

More information

Linear Algebra (part 1) : Vector Spaces (by Evan Dummit, 2017, v. 1.07) 1.1 The Formal Denition of a Vector Space

Linear Algebra (part 1) : Vector Spaces (by Evan Dummit, 2017, v. 1.07) 1.1 The Formal Denition of a Vector Space Linear Algebra (part 1) : Vector Spaces (by Evan Dummit, 2017, v. 1.07) Contents 1 Vector Spaces 1 1.1 The Formal Denition of a Vector Space.................................. 1 1.2 Subspaces...................................................

More information

What are Iteration Theories?

What are Iteration Theories? What are Iteration Theories? Jiří Adámek and Stefan Milius Institute of Theoretical Computer Science Technical University of Braunschweig Germany adamek,milius @iti.cs.tu-bs.de Jiří Velebil Department

More information

Algebraic Geometry

Algebraic Geometry MIT OpenCourseWare http://ocw.mit.edu 18.726 Algebraic Geometry Spring 2009 For information about citing these materials or our Terms of Use, visit: http://ocw.mit.edu/terms. 18.726: Algebraic Geometry

More information

TOPOSES ARE SYMMETRIC MONOIDAL CLOSED CATEGORIES

TOPOSES ARE SYMMETRIC MONOIDAL CLOSED CATEGORIES Please cite this article as: Viliam Slodičák, Toposes are symmetric monoidal closed categories, Scientific Research of the Institute of Mathematics and Computer Science, 2012, Volume 11, Issue 1, pages

More information

2 logic, such as those for resolution and hyperresolution. A number of recent developments serve as the motivation for the current paper. In [2, 3], i

2 logic, such as those for resolution and hyperresolution. A number of recent developments serve as the motivation for the current paper. In [2, 3], i Sequents, Frames, and Completeness Thierry Coquand 1 and Guo-Qiang Zhang 2?? 1 Department of Computer Science, University of Goteborg S 412 96, Goteborg, Sweden coquand@cs.chalmers.se 2 Department of Computer

More information

Denition A category A is an allegory i it is a locally ordered 2-category, whose hom-posets have binary meets and an anti-involution R 7! R sat

Denition A category A is an allegory i it is a locally ordered 2-category, whose hom-posets have binary meets and an anti-involution R 7! R sat Two Categories of Relations (Technical Report no. 94-32) Peter Knijnenburg Frank Nordemann Dept. of Computer Science, Leiden University, Niels Bohrweg 1, 2333 CA Leiden, the Netherlands. E-mail: peterk@cs.leidenuniv.nl

More information

Locally cartesian closed categories

Locally cartesian closed categories Locally cartesian closed categories Clive Newstead 80-814 Categorical Logic, Carnegie Mellon University Wednesday 1st March 2017 Abstract Cartesian closed categories provide a natural setting for the interpretation

More information

A brief Introduction to Category Theory

A brief Introduction to Category Theory A brief Introduction to Category Theory Dirk Hofmann CIDMA, Department of Mathematics, University of Aveiro, 3810-193 Aveiro, Portugal Office: 11.3.10, dirk@ua.pt, http://sweet.ua.pt/dirk/ October 9, 2017

More information

Rewriting Concepts Using Terminologies Revisited Franz Baader, Ralf Kusters, and Ralf Molitor LuFg Theoretical Computer Science, RWTH Aachen fb

Rewriting Concepts Using Terminologies Revisited Franz Baader, Ralf Kusters, and Ralf Molitor LuFg Theoretical Computer Science, RWTH Aachen   fb LTCS{Report Aachen University of Technology Research group for Theoretical Computer Science Revised Version of LTCS-Report 99-12: Rewriting Concepts Using Terminologies - Revisited Franz Baader, Ralf Kusters,

More information

Relational Reasoning for Recursive Types and References

Relational Reasoning for Recursive Types and References Relational Reasoning for Recursive Types and References Nina Bohr and Lars Birkedal IT University of Copenhagen (ITU) {ninab,birkedal}@itu.dk Abstract. We present a local relational reasoning method for

More information

On some Metatheorems about FOL

On some Metatheorems about FOL On some Metatheorems about FOL February 25, 2014 Here I sketch a number of results and their proofs as a kind of abstract of the same items that are scattered in chapters 5 and 6 in the textbook. You notice

More information

Interpreting Polymorphic FPC into domain theoretic models of parametric polymorphism

Interpreting Polymorphic FPC into domain theoretic models of parametric polymorphism Interpreting Polymorphic FPC into domain theoretic models of parametric polymorphism Rasmus Ejlers Møgelberg DISI, Università di Genova mogelberg@disi.unige.it Abstract. This paper shows how parametric

More information

Subtyping and Intersection Types Revisited

Subtyping and Intersection Types Revisited Subtyping and Intersection Types Revisited Frank Pfenning Carnegie Mellon University International Conference on Functional Programming (ICFP 07) Freiburg, Germany, October 1-3, 2007 Joint work with Rowan

More information

A Linear/Producer/Consumer model of Classical Linear Logic

A Linear/Producer/Consumer model of Classical Linear Logic A Linear/Producer/Consumer model of Classical Linear Logic Jennifer Paykin Steve Zdancewic February 14, 2014 Abstract This paper defines a new proof- and category-theoretic framework for classical linear

More information

{},{a},{a,c} {},{c} {c,d}

{},{a},{a,c} {},{c} {c,d} Modular verication of Argos Programs Agathe Merceron 1 and G. Michele Pinna 2 1 Basser Department of Computer Science, University of Sydney Madsen Building F09, NSW 2006, Australia agathe@staff.cs.su.oz.au

More information

Primitive recursion in niteness spaces

Primitive recursion in niteness spaces Primitive recursion in niteness spaces Lionel Vaux Laboratoire de Mathématiques de l'université de Savoie UFR SF, Campus Scientique, 73376 Le Bourget-du-Lac Cedex, France E-mail: lionel.vaux@univ-savoie.fr

More information

Formal power series rings, inverse limits, and I-adic completions of rings

Formal power series rings, inverse limits, and I-adic completions of rings Formal power series rings, inverse limits, and I-adic completions of rings Formal semigroup rings and formal power series rings We next want to explore the notion of a (formal) power series ring in finitely

More information

Topos Theory. Lectures 17-20: The interpretation of logic in categories. Olivia Caramello. Topos Theory. Olivia Caramello.

Topos Theory. Lectures 17-20: The interpretation of logic in categories. Olivia Caramello. Topos Theory. Olivia Caramello. logic s Lectures 17-20: logic in 2 / 40 logic s Interpreting first-order logic in In Logic, first-order s are a wide class of formal s used for talking about structures of any kind (where the restriction

More information

form, but that fails as soon as one has an object greater than every natural number. Induction in the < form frequently goes under the fancy name \tra

form, but that fails as soon as one has an object greater than every natural number. Induction in the < form frequently goes under the fancy name \tra Transnite Ordinals and Their Notations: For The Uninitiated Version 1.1 Hilbert Levitz Department of Computer Science Florida State University levitz@cs.fsu.edu Intoduction This is supposed to be a primer

More information

A fully abstract semantics for a nondeterministic functional language with monadic types

A fully abstract semantics for a nondeterministic functional language with monadic types A fully abstract semantics for a nondeterministic functional language with monadic types Alan Jeffrey 1 School of Cognitive and Computing Sciences University of Sussex, Brighton BN1 9QH, UK alanje@cogs.susx.ac.uk

More information

MISHA GAVRILOVICH, ALEXANDER LUZGAREV, AND VLADIMIR SOSNILO PRELIMINARY DRAFT

MISHA GAVRILOVICH, ALEXANDER LUZGAREV, AND VLADIMIR SOSNILO PRELIMINARY DRAFT A DECIDABLE EQUATIONAL FRAGMENT OF CATEGORY THEORY WITHOUT AUTOMORPHISMS MISHA GAVRILOVICH, ALEXANDER LUZGAREV, AND VLADIMIR SOSNILO Abstract. We record an observation of Nikolai Durov that there is a

More information

The tensor product of commutative monoids

The tensor product of commutative monoids The tensor product of commutative monoids We work throughout in the category Cmd of commutative monoids. In other words, all the monoids we meet are commutative, and consequently we say monoid in place

More information

Theories With Duality DRAFT VERSION ONLY

Theories With Duality DRAFT VERSION ONLY Theories With Duality DRAFT VERSION ONLY John C. Baez Department of athematics, University of California Riverside, CA 9252 USA Paul-André elliès Laboratoire PPS Université Paris 7 - Denis Diderot Case

More information

Fuzzy and Non-deterministic Automata Ji Mo ko January 29, 1998 Abstract An existence of an isomorphism between a category of fuzzy automata and a cate

Fuzzy and Non-deterministic Automata Ji Mo ko January 29, 1998 Abstract An existence of an isomorphism between a category of fuzzy automata and a cate University of Ostrava Institute for Research and Applications of Fuzzy Modeling Fuzzy and Non-deterministic Automata Ji Mo ko Research report No. 8 November 6, 1997 Submitted/to appear: { Supported by:

More information

Decision Problems Concerning. Prime Words and Languages of the

Decision Problems Concerning. Prime Words and Languages of the Decision Problems Concerning Prime Words and Languages of the PCP Marjo Lipponen Turku Centre for Computer Science TUCS Technical Report No 27 June 1996 ISBN 951-650-783-2 ISSN 1239-1891 Abstract This

More information

Modèles des langages de programmation Domaines, catégories, jeux. Programme de cette seconde séance:

Modèles des langages de programmation Domaines, catégories, jeux. Programme de cette seconde séance: Modèles des langages de programmation Domaines, catégories, jeux Programme de cette seconde séance: Modèle ensembliste du lambda-calcul ; Catégories cartésiennes fermées 1 Synopsis 1 the simply-typed λ-calculus,

More information

Electronic Notes in Theoretical Computer Science 18 (1998) URL: 8 pages Towards characterizing bisim

Electronic Notes in Theoretical Computer Science 18 (1998) URL:   8 pages Towards characterizing bisim Electronic Notes in Theoretical Computer Science 18 (1998) URL: http://www.elsevier.nl/locate/entcs/volume18.html 8 pages Towards characterizing bisimilarity of value-passing processes with context-free

More information

A Fixed Point Theorem in a Category of Compact Metric Spaces

A Fixed Point Theorem in a Category of Compact Metric Spaces A Fixed Point Theorem in a Category of Compact Metric Spaces Fabio Alessi, Paolo Baldan, Gianna Bellè Dipartimento di Matematica e Informatica, via Zanon 6, 33100 Udine (Italy) {alessi,baldan,gbelle}@dimi.uniud.it

More information

Math 210B. Profinite group cohomology

Math 210B. Profinite group cohomology Math 210B. Profinite group cohomology 1. Motivation Let {Γ i } be an inverse system of finite groups with surjective transition maps, and define Γ = Γ i equipped with its inverse it topology (i.e., the

More information

Parsing MELL Proof Nets

Parsing MELL Proof Nets University of Pennsylvania ScholarlyCommons IRCS Technical Reports Series Institute for Research in Cognitive Science October 1996 Parsing MELL Proof Nets Stefano Guerrini University of Pennsylvania Andrea

More information

Towards a Flowchart Diagrammatic Language for Monad-based Semantics

Towards a Flowchart Diagrammatic Language for Monad-based Semantics Towards a Flowchart Diagrammatic Language or Monad-based Semantics Julian Jakob Friedrich-Alexander-Universität Erlangen-Nürnberg julian.jakob@au.de 21.06.2016 Introductory Examples 1 2 + 3 3 9 36 4 while

More information

Consequence Relations and Natural Deduction

Consequence Relations and Natural Deduction Consequence Relations and Natural Deduction Joshua D. Guttman Worcester Polytechnic Institute September 9, 2010 Contents 1 Consequence Relations 1 2 A Derivation System for Natural Deduction 3 3 Derivations

More information

PART I. Abstract algebraic categories

PART I. Abstract algebraic categories PART I Abstract algebraic categories It should be observed first that the whole concept of category is essentially an auxiliary one; our basic concepts are those of a functor and a natural transformation.

More information

Serre A -functors. Oleksandr Manzyuk. joint work with Volodymyr Lyubashenko. math.ct/ Notation. 1. Preliminaries on A -categories

Serre A -functors. Oleksandr Manzyuk. joint work with Volodymyr Lyubashenko. math.ct/ Notation. 1. Preliminaries on A -categories Serre A -functors Oleksandr Manzyuk joint work with Volodymyr Lyubashenko math.ct/0701165 0. Notation 1. Preliminaries on A -categories 2. Serre functors 3. Serre A -functors 0. Notation k denotes a (ground)

More information

CS522 - Programming Language Semantics

CS522 - Programming Language Semantics 1 CS522 - Programming Language Semantics Simply Typed Lambda Calculus Grigore Roşu Department of Computer Science University of Illinois at Urbana-Champaign 2 We now discuss a non-trivial extension of

More information

Monads Need Not Be Endofunctors

Monads Need Not Be Endofunctors Monads Need Not Be Endofunctors Thorsten Altenkirch, University of Nottingham James Chapman, Institute of Cybernetics, Tallinn Tarmo Uustalu, Institute of Cybernetics, Tallinn ScotCats, Edinburgh, 21 May

More information

Lecture Notes on Inductive Definitions

Lecture Notes on Inductive Definitions Lecture Notes on Inductive Definitions 15-312: Foundations of Programming Languages Frank Pfenning Lecture 2 September 2, 2004 These supplementary notes review the notion of an inductive definition and

More information

involving the dynamic creation of mutable locations (such as ML-style references). See [17, 2, 7, 3, 18, 12, 13, 6, 4]. Our interest in this subject s

involving the dynamic creation of mutable locations (such as ML-style references). See [17, 2, 7, 3, 18, 12, 13, 6, 4]. Our interest in this subject s Observable Properties of Higher Order Functions that Dynamically Create Local Names, or: What's new? Andrew M. Pitts? and Ian D. B. Stark?? University of Cambridge Computer Laboratory, Pembroke Street,

More information

A Preference Semantics. for Ground Nonmonotonic Modal Logics. logics, a family of nonmonotonic modal logics obtained by means of a

A Preference Semantics. for Ground Nonmonotonic Modal Logics. logics, a family of nonmonotonic modal logics obtained by means of a A Preference Semantics for Ground Nonmonotonic Modal Logics Daniele Nardi and Riccardo Rosati Dipartimento di Informatica e Sistemistica, Universita di Roma \La Sapienza", Via Salaria 113, I-00198 Roma,

More information

Monads and More: Part 4

Monads and More: Part 4 Monads and More: Part 4 Tarmo Uustalu, Tallinn Nottingham, 14-18 May 2007 Coeffectful computation and comonads For coeffectful notions of computation, we have a comonad (D, ε, δ) on the base category C

More information

1 Introduction. 2 Categories. Mitchell Faulk June 22, 2014 Equivalence of Categories for Affine Varieties

1 Introduction. 2 Categories. Mitchell Faulk June 22, 2014 Equivalence of Categories for Affine Varieties Mitchell Faulk June 22, 2014 Equivalence of Categories for Affine Varieties 1 Introduction Recall from last time that every affine algebraic variety V A n determines a unique finitely generated, reduced

More information

Extended Abstract: Reconsidering Intuitionistic Duality

Extended Abstract: Reconsidering Intuitionistic Duality Extended Abstract: Reconsidering Intuitionistic Duality Aaron Stump, Harley Eades III, Ryan McCleeary Computer Science The University of Iowa 1 Introduction This paper proposes a new syntax and proof system

More information

Reinhold Heckmann. FB 14 { Informatik. D-6600 Saarbrucken. Bundesrepublik Deutschland. September 10, Abstract

Reinhold Heckmann. FB 14 { Informatik. D-6600 Saarbrucken. Bundesrepublik Deutschland. September 10, Abstract Power Domain Constructions Reinhold Heckmann FB 14 { Informatik Universitat des Saarlandes D-6600 Saarbrucken Bundesrepublik Deutschland email: heckmann@cs.uni-sb.de September 10, 1998 Abstract The variety

More information

Supplementary Notes on Inductive Definitions

Supplementary Notes on Inductive Definitions Supplementary Notes on Inductive Definitions 15-312: Foundations of Programming Languages Frank Pfenning Lecture 2 August 29, 2002 These supplementary notes review the notion of an inductive definition

More information

Localizations as idempotent approximations to completions

Localizations as idempotent approximations to completions Journal of Pure and Applied Algebra 142 (1999) 25 33 www.elsevier.com/locate/jpaa Localizations as idempotent approximations to completions Carles Casacuberta a;1, Armin Frei b; ;2 a Universitat Autonoma

More information

For a xed value of, we will prove that there are some simple constraints on the triple of cardinals (b(); d(); 2 ). We will also prove that any triple

For a xed value of, we will prove that there are some simple constraints on the triple of cardinals (b(); d(); 2 ). We will also prove that any triple Cardinal invariants above the continuum James Cummings Hebrew University of Jerusalem cummings@math.huji.ac.il Saharon Shelah Hebrew University of Jerusalem shelah@math.huji.ac.il y February 25, 1998 Abstract

More information