Type Checking and Inference Are Equivalent in Lambda Calculi with Existential Types

Size: px
Start display at page:

Download "Type Checking and Inference Are Equivalent in Lambda Calculi with Existential Types"

Transcription

1 Type Checking and Inference Are Equivalent in Lambda Calculi with Existential Types Yuki Kato and Koji Nakazawa Graduate School of Informatics, Kyoto University, Kyoto , Japan Abstract. This paper shows that type-checking and type-inference problems are equivalent in domain-free lambda calculi with existential types, that is, type-checking problem is Turing reducible to typeinference problem and vice versa. In this paper, the equivalence is proved for two variants of domain-free lambda calculi with existential types: one is an implication and existence fragment, and the other is a negation, conjunction and existence fragment. This result gives another proof of undecidability of type inference in the domain-free calculi with existence. Keywords. undecidability, existential type, type checking, type inference, domain-free type system. 1 Introduction Existential types correspond to second-order existence in logic by the Curry- Howard isomorphism, and so they are a natural notion from the point of view of logic. They have been also studied actively from the point of view of computer science since Mitchell and Plotkin [11] showed that abstract data types are existential types. Furthermore, calculi with existential types work as suitable target calculi of continuation-passing-style (CPS) translations. Some studies on CPS translations for polymorphic calculi have shown that the negation (, which corresponds to continuation types), conjunction (, which corresponds to product types), and existence ( ) fragment of lambda calculus is an essence of a target calculus of CPS translations for various systems, such as the polymorphic lambda calculus [5], the lambda-mu calculus [3, 8], and delimited continuations. Hasegawa [9] showed that a -fragment is even more suitable as a target calculus of a CPS translation for delimited continuations such as shift and reset [2]. These can be seen as an extension of the study of Thielecke [18], in which he showed that the negation and conjunction fragment of a lambda calculus suffices as a target of CPS translations of various first-order calculi. Domain-free type systems [1], which are in an intermediate style between Church and Curry style, are useful to study some extensions of polymorphic typed calculi and for theoretical studies on CPS translations. In domain-free style lambda calculi, types of parameters of functions are not explicitly annotated in lambda abstraction terms λx.m as in the Curry style, while as in the Church yuki@kuis.kyoto-u.ac.jp knak@kuis.kyoto-u.ac.jp

2 style, terms contain type information for second-order quantifiers, such as a type abstraction λx.m for -introduction rule, and a term A, M with a witness A for -introduction rule. In [7], it is shown that an extension of the Damas- Milner polymorphic type assignment system, which can be seen as a Currystyle formulation, with a control operator destroys the type soundness. Similarly, Fujita [3] showed that the Curry-style lambda-mu calculus, which is an extension of the polymorphic lambda calculus and introduced by Parigot [14], does not enjoy the subject reduction property. Fujita introduced a domain-free lambdamu calculus to have the subject reduction. In addition, the -fragment of the domain-free typed lambda calculus works as a target calculus of a CPS translation for the domain-free lambda-mu calculus. Some decision problems on typability of terms in typed calculi have been widely studied. One is type-checking problem (TC), which is a problem deciding whether Γ M : A is derivable for given Γ, M, and A. Type-inference problem (TI) is another problem deciding whether there exist Γ and A such that Γ M : A is derivable for given M. In the usual notation, TC asks Γ M : A? for given Γ, M, and A, and TI asks? M :? for given M. In this paper, TC 0 and TI 0 denote type checking and inference for closed terms, respectively. These questions are fundamentally important in typed lambda calculi. For polymorphic types, we have already had some results on these problems. Wells [19] showed that TC and TI in the Curry-style polymorphic lambda calculus are equivalent and these problems are undecidable. Two problems are said to be equivalent if one is Turing reducible to the other and vice versa, where a decision problem P is said to be Turing reducible to another problem Q when there exists computable function F such that for each instance p of P, F (p) is an instance of Q which holds if and only if p holds. Nakazawa and Tatsuta [13] showed that TC and TI in the domain-free polymorphic lambda calculus are equivalent, and these are undecidable. On the other hand, despite of their computational importance, properties of existential types have not been studied enough yet. It is only recent that inhabitation problem, which corresponds to provability of formulas, in the -fragment was proved to be decidable in [17]. TC and TI in domain-free lambda calculi with existential types were proved to be undecidable in [12, 13]. However any direct relation between TC and TI for existential types has not been known yet. This paper proves that TC and TI are equivalent in two variants of domainfree lambda calculi with existential types: implication and existence fragment DF-λ, and negation, conjunction, and existence fragment DF-λ. Moreover, this result gives another proof of undecidability of TI in DF-λ and DF-λ. First, we prove that TC and TI are equivalent in DF-λ. In DF-λ, it is easy to prove that TI is Turing reducible to TC. The reduction from TC to TI is proved by adapting the idea of [13]. The key of the proof is the fact that, for given a closed term M and a type A, we can construct another closed term J M,A which is typable if and only if M : A holds. Secondly, we prove that TC and TI are equivalent in DF-λ. Similarly to DF-λ, the proof of the reduction from TC to TI consists of two parts: the 2

3 reduction from TC to TC 0 and that from TC 0 to TI. However, since DF-λ does not have implication, we need a non-trivial idea to prove the reduction from TC to TC 0. In this paper, using the well-known fact that the implication A B is (classically) equivalent to (A B), we show that TC can be reduced to TC 0 in DF-λ. The proof of the other direction from TI to TC also consists of two parts: TI can be reduced to TI 0, and TI 0 can be reduced to TC. In order to prove the former part, the above idea can be used. Figure 1 summarizes the related results including ours. In the diagram, P Q means that the problem P is Turing reducible to Q, and P Q means that P and Q are equivalent, that is, both P Q and Q P hold. F denotes the polymorphic lambda calculus. SUP means the semi-unification problem and 2UP means the second-order-unification problem. Since undecidability of SUP and 2UP has been already proved by Kfoury et al. [10] and Schubert [15], respectively, all of the problems in the diagram are undecidable. is the main result of this paper, and it gives a new proof of undecidability of TI in DF-λ and DF-λ. Curry style: SUP [19] TC in F [19] TI in F domain-free style: 2UP [4] TC in DF-F [13] TI in DF-F [12] [12] domain-free style: TC in DF-λ /λ TI in DF-λ /λ Fig. 1. TC and TI for polymorphic and existential types The section 2 introduces the domain-free lambda calculi with existence: DF-λ and DF-λ. We state our main theorems in the section 3, and we prove them in the sections 4 and 5. 2 Domain-Free Lambda Calculi with Existence In this section, we define the domain-free lambda calculi with Existential types: DF-λ and DF-λ. These calculi are expressive enough to represent every function which is representable in System F, because we can interpret every term of System F in each of DF-λ and DF-λ by CPS translations [5, 8]. Furthermore, as pointed out in [11], the existential types can be seen as the abstract data types in the following sense. If a term M has a type B[X := A], we can hide the information of the 3

4 type A by constructing the term A, M, which has the existential type X.B. A term N of the existential type X.B can be used with N[Xx.P ], which intuitively means let X, x = N in P. In this paper, we use the notation M[Xx.N] following [12, 13]. We can write the term A, M in the style of modules of Standard ML as struct type X = A val x = M end. Here are examples of terms with the existential type. First, we define a term of the type X. X X.. F : int 1 : int (Ax) F, 1 : int int ( I) int, F, 1 : X. X X ( I) We can consider this term int, F, 1 as a module, which is implemented as F, 1 by the type int, but the information of int is hidden in the type X. X X. We can give a name to this module by the binding mechanism of λ-calculus such as (λm.m[xp.(pπ 1 )(pπ 2 )]) int, F, 1. The term λm.m[xp.(pπ 1 )(pπ 2 )] is typed as follows, where Γ denotes the type assignment p : X X. Γ p : X X (Ax) (Ax) m : X. X X m : X. X X (Ax) Γ pπ 1 : X ( E1) Γ p : X X Γ pπ 2 : X ( E2) ( E) Γ (pπ 1)(pπ 2) : ( E) m : X. X X m[xp.(pπ 1 )(pπ 2 )] : λm.m[xp.(pπ 1 )(pπ 2 )] : ( X. X X) ( I) Users of the module do not need to know which type is used in the implementation of the module. We can consider that the term (λm.m[xp.(pπ 1 )(pπ 2 )]) int, F, 1 corresponds to the following program of Standard ML. structure m = struct type X = int val p = (F,1) end let val (f,a) = m.p in f a end The signatures of Standard ML corresponds to type annotations to terms of the existential type such as A, M X.B. We have no such annotations in the domain-free style. 2.1 Lambda Calculus with Implication and Existence First, we define the domain-free lambda calculus DF-λ with implication ( ) and existence ( ). 4

5 Definition 1. The types (denoted by A, B,..., and called -types) and the terms (denoted by M, N,...) of DF-λ are defined by A ::= X A A X.A, M ::= x λx.m A, M MM M[Xx.M]. X and x denote a type variable and a term variable, respectively. In the type X.A, the variable X in A is bound. In the term λx.m, the variable x in M is bound. In the term N[Xx.M], the variables X and x in M are bound. A variable is free if it is not bound. A term is closed if it contains no free term variable. We use to denote syntactic identity modulo renaming of bound variables. For n 3, A 1 A n 1 A n denotes A 1 ( (A n 1 A n )), and M 1 M 2 M n denotes ((M 1 M 2 ) )M n. Γ denotes a finite set of type assignments in the form of x : A. Typing rules of DF-λ are the following. Γ, x : A x : A (Ax) Γ, x : A M : B Γ λx.m : A B ( I) Γ 1 M : B A Γ 2 N : B Γ 1, Γ 2 MN : A Γ N : A[X := B] Γ B, N : X.A ( I) Γ 1 M : X.A Γ 2, x : A N : C Γ 1, Γ 2 M[Xx.N] : C In the rule ( E), Γ 2 and C must not contain X as a free variable. ( E) ( E) 2.2 Lambda Calculus with Negation, Conjunction, and Existence Then we define the domain-free lambda calculus DF-λ with negation ( ), conjunction ( ), and existence ( ). From the point of view of computation, the negation corresponds to the type of continuations, and the conjunction to the product type. Definition 2. The types (denoted by A, B,..., and called -types) and the terms (denoted by M, N,...) of DF-λ are defined by A ::= X A A A X.A, M ::= x λx.m M, M A, M MM Mπ 1 Mπ 2 M[Xx.M]. Bound and free variables, and closed terms are defined similarly to DF-λ. For n 3, A 1 A n 1 A n denotes A 1 ( (A n 1 A n )). Typing rules of DF-λ are the following. Γ, x : A x : A (Ax) Γ, x : A M : Γ λx.m : A ( I) Γ 1 M : A Γ 2 N : A Γ 1, Γ 2 MN : ( E) 5

6 Γ 1 M : A Γ 2 N : B Γ 1, Γ 2 M, N : A B ( I) Γ M : A 1 A 2 Γ Mπ 1 : A 1 ( E 1 ) Γ M : A 1 A 2 Γ Mπ 2 : A 2 ( E 2 ) Γ N : A[X := B] Γ B, N : X.A ( I) Γ 1 M : X.A Γ 2, x : A N : C Γ 1, Γ 2 M[Xx.N] : C ( E) In the rule ( E), Γ 2 and C must not contain X as a free variable. Note that the typing rules of DF-λ for the terms λx.m and MN differ from those of DF-λ. 3 Type Checking and Type Inference In this section, we introduce two decision problems on typability of terms, and state our main theorem. Type checking (TC) is a problem deciding whether Γ M : A is derivable for given Γ, M, and A. Type inference (TI) is a problem deciding whether there exist Γ and A such that Γ M : A is derivable for given M. In the usual notation, TC asks Γ M : A? for given Γ, M, and A, and TI asks? M :? for given M. These two problems are equivalent in the Curry-style polymorphic lambda calculus [19], and in the domain-free polymorphic lambda calculus [13]. Two problems are said to be equivalent if one is Turing reducible to the other and vice versa. Hence the equivalence of TC and TI means that (i) for any instance Γ M : A? of TC, we can effectively construct a term N such that the answer of the given instance of TC is the same as that of the instance? N :? of TI, and (ii) for any instance? M :? of TI, we can effectively construct an instance Γ N : A? of TC whose answer is the same as the given instance of TI. TC 0 and TI 0 denote type checking and type inference for closed terms, respectively. In general, if a decision problem P 1 is Turing reducible to another decision problem P 2, then decidability of P 2 implies decidability of P 1, and equivalently undecidability of P 1 implies undecidability of P 2. In [19, 13], they showed undecidability of TI in the polymorphic lambda calculi by the Turing reducibility of TC to TI. On the other hand, undecidability of TC and TI in the domainfree lambda calculi with existential types has been proved in [12, 13] by the reducibility of each problems for polymorphic types to those for existential types. However, direct relationship between TC and TI for existential types has not been known yet. In this paper, we will prove that TC and TI are equivalent in DF-λ and DF-λ. Theorem Type checking and type inference are equivalent in DF-λ, that is, type checking in DF-λ is Turing reducible to type inference in DF-λ and vice versa. 2. Type checking and type inference are equivalent in DF-λ. 6

7 Since TC is undecidable in these calculi, this result gives another proof of undecidability of TI in them. For each system, the proof of the reduction from TC to TI consists of two parts. First, we show that TC can be reduced to TC 0. Secondly, we show that TC 0 can be reduced to TI. The key of the proof of the reduction from TC 0 to TI is the fact that we can effectively construct a term J M,A from a given pair of a closed term M and a type A such that the instance M : A of TC 0 is equivalent to the instance J M,A :? of TI. By this fact, we can conclude that TC 0 can be reduced to TI. In order to show that, we borrow the idea of [13] for polymorphic types. In DF-λ, the reduction from TC to TC 0 is easy, whereas the reduction is not easy to prove for DF-λ due to absence of implication. In our proof, we show that we can construct a DF-λ -term λx.m for a DF-λ -term M and a variable x such that Γ, x : A M : B holds if and only if Γ λx.m : (A B) holds. By this construction, we can prove that TC can be reduced to TC 0 in DF-λ. Similarly, the proof of the reduction from TI to TC consists of two parts: the reduction from TI to TI 0, and the reduction from TI 0 to TC. For DF-λ, the proof of the reduction from TI to TI 0 has the similar difficulties to the case of the reduction from TC to TC 0. We can also use the same technique by λx.m to prove it. We prove the equivalence in DF-λ in the section 4, where we show how to construct J M,A from M and A. In the section 5, we show the reduction from problems for open terms to those for closed terms, and prove the equivalence in DF-λ. 4 TC and TI are Equivalent in DF-λ In this section, we prove that TC and TI are equivalent in DF-λ. At first, we show that TI is Turing reducible to TC (that is denoted by TI TC). Proposition 1. TI in DF-λ is Turing reducible to TC in DF-λ. Proof. For a given instance? M :? of TI in DF-λ, we can effectively construct the list (x 1,, x n ) of all of the free variables in M. Then the TI problem? M :? is equivalent to a TC problem λy.(λx.y)(λx 1. λx n.m) : X X?, where x and y are fresh variables. In fact, if the term λy.(λx.y)(λx 1. λx n.m) has the type X X, then M has some type. Conversely, if Γ M : A holds for some Γ and A, we have the following for some B, y : X, x : B y : X (Ax) y : X λx.y : B X ( I) Γ M : A. λx 1 λx n.m : B ( E) y : X (λx.y)(λx 1 λx n.m) : X λy.(λx.y)(λx 1 λx n.m) : X X ( I), 7

8 where we can suppose that {x 1,, x n } = {z (z : C) Γ } without loss of generality because the left-hand side is the set of all of the free variables of M. As we have stated in the previous section, the proof of TC TI consists of two steps: TC TC 0 and TC 0 TI. It is easy to prove TC TC 0 for DF-λ. In the following, we show TC 0 TI, that is, for a given instance M : A? of TC 0, we effectively construct a DF-λ -term J M,A such that the instance? J M,A :? of TI is equivalent to the given instance of TC 0. In the rest of this section, O is supposed to be a fixed type variable, and not to be bound by any existential quantifier. O A denotes A O. First, we define some auxiliary functions on types to prove the key lemma. Definition lvar(a) is the leftmost variable of A when it is free in A, and otherwise lvar(a) is undefined. lvar(a) is defined by lvar(x) X, lvar(a B) lvar(a), { undefined (lvar(a) = X), lvar( X.A) lvar(a) (otherwise). 2. The left depth ldep(a) is the depth from the root to the leftmost variable in the syntax tree of A. It does not depend on whether the variable is free or bound. ldep(a) is defined by ldep(x) = 0, ldep(a B) = ldep(a) + 1, ldep( X.A) = ldep(a) The left-bound-variable depth lbdep(a) is ldep(b) when A includes a subexpression X.B and the leftmost variable of A is bound by this quantifier. When the leftmost variable of A is free, lbdep is undefined. lbdep(a) is defined by lbdep(x) = undefined, lbdep(a B) = lbdep(a), { ldep(a) (lvar(a) = X), lbdep( X.A) = lbdep(a) (otherwise). Lemma ldep(a[y := B]) ldep(a) implies lvar(a) Y, 2. lvar(a) X implies lbdep(a[x := B]) = lbdep(b) and lvar(a[x := B]) lvar(b). Proof. 1. By induction on A. When A is X(X Y ), ldep(x[y := B]) = ldep(x) holds. When A is Y, we have lvar(y ) Y. 8

9 and When A is C D, we have ldep((c D)[Y := B]) = ldep((c[y := B]) (D[Y := B])) = ldep(c[y := B]) + 1 ldep(c D) = ldep(c) + 1. Therefore, if ldep((c D)[Y := B]) ldep(c D) holds, we have ldep(c[y := B]) ldep(c). From the induction hypothesis, ldep(c[y := B]) ldep(c) implies lvar(c) Y. Hence, lvar(c D) Y holds. When A is X.C, we have and ldep(( X.C)[Y := B]) = ldep(c[y := B]) + 1 ldep( X.C) = ldep(c) + 1. Therefore, if ldep(( X.C)[Y := B]) ldep( X.C) holds, we have ldep(c[y := B]) ldep(c). From the induction hypothesis, ldep(c[y := B]) ldep(c) implies lvar(c) Y. Hence, lvar( X.C) Y holds. 2. By induction on A. When A is a variable, since we have lvar(a) X, A is X. Hence, we have lbdep(x[x := B]) = lbdep(b) and lvar(x[x := B]) lvar(b). When A is C D, if lvar(c D) Y holds, we have lvar(c) Y. From the induction hypothesis, lvar(c) Y implies lbdep(c[y := B]) = lbdep(b), and so we have lbdep((c D)[Y := B]) = lbdep(c[y := B] D[Y := B]) = lbdep(c[y := B]) = lbdep(b). Moreover, from the induction hypothesis, lvar(c) Y implies lvar(c[y := B]) lvar(b), and so we have lvar((c D)[Y := B]) lvar(c[y := B] D[Y := B]) lvar(c[y := B]) lvar(b). When A is X.C, if lvar( X.C) Y holds, we have lvar(c) Y X. We can suppose that X is not contained freely in B by renaming the bound variable X. From the induction hypothesis, we have lvar(c[y := B]) lvar(b) X, and then we have lbdep(( X.C)[Y := B]) = lbdep( X.C[Y := B]) = lbdep(c[y := B]). 9

10 From the induction hypothesis, lvar(c) Y implies lbdep(c[y := B]) = lbdep(b). Hence we have lbdep(( X.C)[Y := B]) = lbdep(b). Furthermore, from the induction hypothesis, lvar(c) Y implies lvar(c[y := B]) lvar(b) and so we have lvar(( X.C)[Y := B]) lvar( X.C[Y := B]) lvar(c[y := B]) lvar(b), since lvar(c[y := B]) X holds. By Lemma 1, the following key lemma is proved. Lemma 2. If Γ x O X.X, x : A is derivable in DF-λ, then Γ contains x : O X.X. Proof. Suppose that Γ x O X.X, x : A is derivable, and the type assignment for x in Γ be x : C x. Since the term x O X.X, x is typable, its type derivation is as follows for some C. (Ax) Γ x : Y.C A (Ax) Γ x : C[X := O X.X] Γ O X.X, x : Y.C ( I) ( E) Γ x O X.X, x : A From the form of (Ax) rules in the derivation, we have Then we have Y.C A C x C[Y := O X.X]. ldep(c x ) = ldep( Y.C A) = ldep( Y.C) + 1 = ldep(c) + 2, ldep(c x ) = ldep(c[y := O X.X]). Hence we have ldep(c[y := O X.X]) ldep(c), and then lvar(c) Y holds by Lemma 1.1. By Lemma 1.2, we have lbdep(c[y := O X.X]) = lbdep( O X.X) = lbdep( X.X) = ldep(x) = 0. On the other hand, since lvar(c) Y holds, we have lbdep( Y.C A) = lbdep( Y.C) = ldep(c). Therefore, we have ldep(c) = 0, and then C must be a variable. Hence, C is identical to Y because of lvar(c) Y, and therefore C x must be O X.X. Then we can show the following proposition, from which TC 0 TI follows directly. 10

11 Proposition 2. For a closed DF-λ -term M and a -type A, we can effectively construct a closed DF-λ -term J M,A such that M : A is derivable if and only if J M,A : B is derivable for some type B. Proof. Define J M,A as λx.(λy.x A, M )(x O X.X, x ), where both x and y are fresh variables. It is easy to see that M : A implies J M,A : O O X.X, because x : O X.X x A, M : O is derivable as follows.. x : O X.X x : O X.X (Ax) M : A A, M : X.X ( I) ( E) x : O X.X x A, M : O For the converse direction, we use Lemma 2. Suppose that J M,A : B is derivable for some B. Since J M,A includes x O X.X, x as a subterm, the derivation of J M,A : B includes a derivation of Γ x O X.X, x : B for some Γ and B as a subderivation. Then Γ contains x : O X.X by Lemma 2. Because of this, the derivation of J M,A has to include a subderivation of x : O X.X x A, M : O which is the same as the above one. Hence it includes the derivation of M : A. Proof (of Theorem 1.1). TI TC is proved in Proposition 1. TC TC 0 is easily proved in a similar way to Proposition 1. TC 0 TI immediately follows from Proposition 2. 5 TC and TI are Equivalent in DF-λ In this section, we prove that TC and TI are equivalent in DF-λ. The proof is similar to DF-λ, and consists of the following four parts: (i) TC TC 0, (ii) TC 0 TI, (iii) TI TI 0, and (iv) TI 0 TC. In contrast to DF-λ, neither (i) nor (iii) is easy to prove for DF-λ due to absence of implication. 5.1 Translation to Closed Terms First, we show TC TC 0 and TI TI 0. In DF-λ, we cannot type the term λx 1. λx n.m, because N has to be typed with in order to type the lambda abstraction λx.n. Therefore, we define a construction λx.m, which can be considered as an interpretation of the implication introduction in DF-λ. It should be noted that the construction can be defined as long as we have negation and conjunction, and so existence is not essential for the discussion in this subsection. Definition 4. For any -types A and B, A B denotes the type (A B). Similarly to the ordinary implication, A 1 A n B denotes A 1 ( (A n B)). For a DF-λ -term M and a variable x, we define λx.m as λc.(λx.(cπ 2 )M)(cπ 1 ), where c is a fresh term variable. 11

12 It is easy to see that the set of free variables of λx.m is the set obtained by removing x from the set of free variables of M. Lemma 3. Γ, x : A M : B holds if and only if Γ λx.m : A B. Proof. Suppose that Γ, x : A M : B holds, and then we have the following type derivation for Γ λx.m : (A B). c : A B c : A B. c : A B cπ 2 : B Γ, x : A M : B Γ, c : A B, x : A (cπ 2 )M : c : A B c : A B Γ, c : A B λx.(cπ 2 )M : A c : A B cπ 1 : A Γ, c : A B (λx.(cπ 2 )M)(cπ 1 ) : Γ λx.m : (A B) Conversely, if we have Γ λx.m : (A B), then its derivation must be in the above form. Proposition TC in DF-λ is Turing reducible to TC 0 in DF-λ. 2. TI in DF-λ is Turing reducible to TI 0 in DF-λ. Proof. 1. For a given instance x 1 : A 1,, x n : A n M : B of TC, we can effectively construct an instance λx 1. λx n.m : A 1 A n B of TC 0, which is equivalent to the given instance by Lemma For a given DF-λ -term M, let the list of free variables of M be x 1,, x n. It should be noted that we can effectively construct the list. We show that the instance λx 1. λx n.m :? of TI 0 is equivalent to the given instance? M :? of TI. If Γ M : B is derivable for some Γ and B, then Γ M : B is derivable, where Γ is {x 1 : A 1,, x n : A n } and each x i : A i is contained in Γ. Then we have λx 1. λx n.m : A 1 A n B by Lemma 3, hence λx 1. λx n.m has a type. Conversely, if λx 1. λx n.m has a type, then M has some type because it is a subterm of λx 1. λx n.m. From the point of view of logic, the translation λx.m becomes clearer. The judgment x : A M : B implicitly means the implication A B. Since DF-λ has no implication, we have to interpret the implication by means of negation and conjunction. In order to do that, we use the well-known fact that A B is (classically) equivalent to (A B), which is denoted by A B in this paper. Since we cannot conclude B from A B and A in the intuitionistic logic, A B is not an intuitionistic implication. We can consider an elimination rule for such as Γ 1 M : A B Γ 2 N : A Γ 1, Γ 2 M@N : B, where M@N is defined as λk.m N, k. We can consider that the constructions λx.m and M@N realize the interpretation of the variant of implication, which is implicitly implemented by, in DF-λ. 12

13 The translation which maps λx.m to λx.m and MN to is also important from the point of view of computer science, because it can be considered as a variant of continuation-passing-style translations into the lambda calculus with continuation types and product types. Such translations have been studied in [18, 5, 8]. In addition, note that we can construct a simpler closed term N and a type C from a given instance x 1 : A 1,, x n : A n M : B of TC. N and C can be defined as follows: N λc.(λx 1. (λx n 1.(λx n.(cπn+1 n+1 )M)(cπn+1 n ))(cπn 1 n+1 ) )(cπn+1 1 ) :, C (A 1 A n B), where π n m is the m-th projection for n-tuples, which can be constructed by π 1 and π 2. Then we can show that x 1 : A 1,, x n : A n M : B holds if and only if N : C holds. This construction can be used to prove TI TI 0 as well. 5.2 Proof of Equivalence We complete the proof of equivalence in DF-λ. TC 0 similarly to DF-λ by replacing O by. TI can be proved Lemma 4. If Γ x X.X, x : A is derivable in DF-λ, then Γ contains x : X.X. Proof. The definitions of the auxiliary functions for negation and conjunction are lvar( A) lvar(a), lvar(a B) lvar(a), ldep( A) = ldep(a) + 1, ldep(a B) = ldep(a) + 1, lbdep( A) = lbdep(a), lbdep(a B) = lbdep(a), and the same statement as Lemma 1 holds for DF-λ. Hence the claim is proved similarly to Lemma 2. The following proposition is also proved similarly to DF-λ. Proposition 4. For a closed DF-λ -term M and a -type A, we can effectively construct a closed DF-λ -term J M,A such that M : A is derivable if and only if J M,A : B is derivable for some type B. 13

14 Proof. Define J M,A as λx.(λy.x A, M )(x X.X, x ), where both x and y are fresh variables. The proof is similar to Proposition 2, using Lemma 4. Note that the lambda abstractions and function applications in J M,A correspond to the introduction and elimination rules of negation. The theorem for DF-λ is proved as follows. Proof (of Theorem 1.2). TC TC 0 and TI TI 0 are proved by Proposition 3. TC 0 TI immediately follows from Proposition 4. TI 0 TC is easily proved similarly to DF-λ, that is, each instance M :? of TI 0 can be translated to an equivalent instance λy.(λx.y)m : of TC. 6 Concluding Remarks In this paper, we show equivalence between the type checking and the type inference in the domain-free lambda calculi with existential types: DF-λ and DF-λ. As another style for existential types, we can consider a system with no type annotations in terms. The system was introduced in [16], and it has the following rules for existential types. Γ N : A[X := B] Γ, N : X.A ( I) Γ 1 M : X.A Γ 2, x : A N : C Γ 1, Γ 2 M[x.N] : C ( E) Fujita and Schubert [6] call such a style the type-free style, and they showed that TC and TI are undecidable in the type-free-style λ by the reduction of the second-order unification problem. However, decidability of the problems in the type-free-style λ has not been studied. The direct relations between TC and TI in these type-free-style calculi with existence are not known, either. The technique in this paper essentially use type annotations in terms, and so it cannot be directly adapted to the type-free-style calculi. The undecidability of the type inference is a negative result for automatic check on safety of program execution. Therefore it is also future work to study on type systems with the existential type in which the type inference problems are decidable. In particular, the type annotations for existential types such as A, M X.B correspond to the signatures in Standard ML, and so it is important future work to study on the type-related problems in the type systems with such type annotations. Acknowledgments We are grateful to Professor Santiago Escobar and the anonymous referees for comments to the previous version of this paper. References 1. G. Barthe and M.H. Sørensen, Domain-free pure type systems. Journal of Functional Programming 10: ,

15 2. O. Danvy and A. Fillinski, Representing Control: a Study of the CPS Translation. Mathematical Structures in Computer Science 2(4): , K. Fujita, Explicitly typed λµ-calculus for polymorphism and call-by-value. In Proceedings of 4th International Conference on Typed Lambda Calculi and Applications (TLCA 1999), LNCS 1581, pp , K. Fujita and A. Schubert, Partially Typed Terms between Church-Style and Curry- Style. In International Conference IFIP TCS 2000, LNCS 1872, pp , K. Fujita, Galois embedding from polymorphic types in to existential types. In Proceedings of 7th International Conference on Typed Lambda Calculi and Applications (TLCA 2005), LNCS 3461, pp , K.Fujita and A.Schubert, Existential Type Systems with No Types in Terms. In Proceedings of 9th International Conference on Typed Lambda Calculi and Applications (TLCA 2009), LNCS 5068, pp , R. Harper and M. Lillibridge, Polymorphic Type Assignment and CPS Conversion. Lisp and Symbolic Computation, 6: , M. Hasegawa, Relational parametricity and control. Logical Methods in Computer Science, 2(3:3):1 22, M. Hasegawa, Unpublished manuscript, A.J. Kfoury, J. Tiuryn and P. Urzyczyn, The Undecidability of the Semi-unification Problem. Information and Computation 102:83 101, J.C. Mitchell and G.D. Plotkin, Abstract types have existential type. ACM Transactions on Programming Languages and Systems 10(3): , K. Nakazawa, M. Tatsuta, Y. Kameyama, and H. Nakano, Undecidability of Type- Checking in Domain-Free Typed Lambda-Calculi with Existence. In the 17th EACSL Annual Conference on Computer Science Logic (CSL 2008), LNCS 5213, pp , K. Nakazawa and M. Tatsuta, Type Checking and Inference for Polymorphic and Existential Types. In the 15th Computing: the Australasian Theory Symposium (CATS 2009), Conferences in Research and Practice in Information Technology (CRPIT), Vol. 94, M. Parigot, λµ-calculus: an algorithmic interpretation of classical natural deduction. In Proceedings of the International Conference on Logic Programming and Automated Reasoning, LNCS 624, pp , A. Schubert, Second-order unification and type inference for Church-style polymorphism. In the 25th Annual ACM Symposium on Principles of Programming Languages (POPL 98), pp , M. Tatsuta, Simple saturated sets for disjunction and second-order existential quantification. In Proceedings of 8th International Conference on Typed Lambda Calculi and Applications (TLCA 2007), LNCS 4583, pp , M. Tatsuta, K. Fujita, R. Hasegawa, and H. Nakano, Inhabitance of Existential Types is Decidable in Negation-Product Fragment. In Proceedings of 2nd International Workshop on Classical Logic and Computation (CLC2008), H. Thielecke, Categorical Structure of Continuation Passing Style. Ph.D. Thesis, University of Edinburgh, J.B. Wells, Typability and type checking in the second-order λ-calculus are equivalent and undecidable. In Proceedings of 9th Symposium on Logic in Computer Science (LICS 94), pp ,

Less naive type theory

Less naive type theory Institute of Informatics Warsaw University 26 May 2007 Plan 1 Syntax of lambda calculus Why typed lambda calculi? 2 3 Syntax of lambda calculus Why typed lambda calculi? origins in 1930s (Church, Curry)

More information

Lecture slides & distribution files:

Lecture slides & distribution files: Type Theory Lecture slides & distribution files: http://www.cs.rhul.ac.uk/home/zhaohui/ttlectures.html Zhaohui Luo Department of Computer Science Royal Holloway, University of London April 2011 2 Type

More information

Logical Verification Course Notes. Femke van Raamsdonk Vrije Universiteit Amsterdam

Logical Verification Course Notes. Femke van Raamsdonk Vrije Universiteit Amsterdam Logical Verification Course Notes Femke van Raamsdonk femke@csvunl Vrije Universiteit Amsterdam autumn 2008 Contents 1 1st-order propositional logic 3 11 Formulas 3 12 Natural deduction for intuitionistic

More information

Typed Lambda Calculus for Syntacticians

Typed Lambda Calculus for Syntacticians Department of Linguistics Ohio State University January 12, 2012 The Two Sides of Typed Lambda Calculus A typed lambda calculus (TLC) can be viewed in two complementary ways: model-theoretically, as a

More information

Runtime Behavior of Conversion Interpretation of Subtyping

Runtime Behavior of Conversion Interpretation of Subtyping Runtime Behavior of Conversion Interpretation of Subtyping Yasuhiko Minamide Institute of Information Sciences and Electronics University of Tsukuba and PRESTO, JST minamide@is.tsukuba.ac.jp Abstract.

More information

Constrained Types and their Expressiveness

Constrained Types and their Expressiveness Constrained Types and their Expressiveness JENS PALSBERG Massachusetts Institute of Technology and SCOTT SMITH Johns Hopkins University A constrained type consists of both a standard type and a constraint

More information

Typed Lambda Calculus

Typed Lambda Calculus Department of Linguistics Ohio State University Sept. 8, 2016 The Two Sides of A typed lambda calculus (TLC) can be viewed in two complementary ways: model-theoretically, as a system of notation for functions

More information

Type raising, continuations, and classical logic

Type raising, continuations, and classical logic Type raising, continuations, and classical logic Philippe de Groote Inria-Lorraine Abstract. There is a striking analogy between type raising, as introduced by Montague (973), and the notion of continuation

More information

Polymorphic lambda calculus Princ. of Progr. Languages (and Extended ) The University of Birmingham. c Uday Reddy

Polymorphic lambda calculus Princ. of Progr. Languages (and Extended ) The University of Birmingham. c Uday Reddy 06-02552 Princ. of Progr. Languages (and Extended ) The University of Birmingham Spring Semester 2016-17 School of Computer Science c Uday Reddy2016-17 Handout 6: Polymorphic Type Systems 1. Polymorphic

More information

Beluga: A Framework for Programming and Reasoning with Deductive Systems (System Description)

Beluga: A Framework for Programming and Reasoning with Deductive Systems (System Description) Beluga: A Framework for Programming and Reasoning with Deductive Systems (System Description) Brigitte Pientka and Joshua Dunfield McGill University, Montréal, Canada {bpientka,joshua}@cs.mcgill.ca Abstract.

More information

Lambda Calculus. Type Systems, Lectures 3. Jevgeni Kabanov Tartu,

Lambda Calculus. Type Systems, Lectures 3. Jevgeni Kabanov Tartu, Lambda Calculus Type Systems, Lectures 3 Jevgeni Kabanov Tartu, 13.02.2006 PREVIOUSLY ON TYPE SYSTEMS Arithmetical expressions and Booleans Evaluation semantics Normal forms & Values Getting stuck Safety

More information

Subsumption. Principle of safe substitution

Subsumption. Principle of safe substitution Recap on Subtyping Subsumption Some types are better than others, in the sense that a value of one can always safely be used where a value of the other is expected. Which can be formalized as by introducing:

More information

Introduction to dependent types in Coq

Introduction to dependent types in Coq October 24, 2008 basic use of the Coq system In Coq, you can play with simple values and functions. The basic command is called Check, to verify if an expression is well-formed and learn what is its type.

More information

1.3. Conditional expressions To express case distinctions like

1.3. Conditional expressions To express case distinctions like Introduction Much of the theory developed in the underlying course Logic II can be implemented in a proof assistant. In the present setting this is interesting, since we can then machine extract from a

More information

Extracting the Range of cps from Affine Typing

Extracting the Range of cps from Affine Typing Extracting the Range of cps from Affine Typing Extended Abstract Josh Berdine, Peter W. O Hearn Queen Mary, University of London {berdine, ohearn}@dcs.qmul.ac.uk Hayo Thielecke The University of Birmingham

More information

The Essence of Reynolds

The Essence of Reynolds The Essence of Reynolds 3. State and Abstraction Uday S. Reddy 1 1 University of Birmingham POPL, 2014 John C. Reynolds, 1935-2013 Emmy Noether, 1882-1935 According to Mac Lane, she emphasized the importance

More information

CLF: A logical framework for concurrent systems

CLF: A logical framework for concurrent systems CLF: A logical framework for concurrent systems Thesis Proposal Kevin Watkins Carnegie Mellon University Committee: Frank Pfenning, CMU (Chair) Stephen Brookes, CMU Robert Harper, CMU Gordon Plotkin, University

More information

Programming Language Concepts: Lecture 19

Programming Language Concepts: Lecture 19 Programming Language Concepts: Lecture 19 Madhavan Mukund Chennai Mathematical Institute madhavan@cmi.ac.in http://www.cmi.ac.in/~madhavan/courses/pl2009 PLC 2009, Lecture 19, 01 April 2009 Adding types

More information

the application rule M : x:a: B N : A M N : (x:a: B) N and the reduction rule (x: A: B) N! Bfx := Ng. Their algorithm is not fully satisfactory in the

the application rule M : x:a: B N : A M N : (x:a: B) N and the reduction rule (x: A: B) N! Bfx := Ng. Their algorithm is not fully satisfactory in the The Semi-Full Closure of Pure Type Systems? Gilles Barthe Institutionen for Datavetenskap, Chalmers Tekniska Hogskola, Goteborg, Sweden Departamento de Informatica, Universidade do Minho, Braga, Portugal

More information

ALGORITHMIC DECIDABILITY OF COMPUTER PROGRAM-FUNCTIONS LANGUAGE PROPERTIES. Nikolay Kosovskiy

ALGORITHMIC DECIDABILITY OF COMPUTER PROGRAM-FUNCTIONS LANGUAGE PROPERTIES. Nikolay Kosovskiy International Journal Information Theories and Applications, Vol. 20, Number 2, 2013 131 ALGORITHMIC DECIDABILITY OF COMPUTER PROGRAM-FUNCTIONS LANGUAGE PROPERTIES Nikolay Kosovskiy Abstract: A mathematical

More information

Pure Lambda Calculus. Lecture 17

Pure Lambda Calculus. Lecture 17 Pure Lambda Calculus Lecture 17 Lambda Calculus Lambda Calculus (λ-calculus) is a functional notation introduced by Alonzo Church in the early 1930s to formalize the notion of computability. Pure λ-calculus

More information

Topic 3: Propositions as types

Topic 3: Propositions as types Topic 3: Propositions as types May 18, 2014 Propositions as types We have seen that the main mathematical objects in a type theory are types. But remember that in conventional foundations, as based on

More information

Basic Elements of Logical Graphs

Basic Elements of Logical Graphs Basic Elements of Logical Graphs Lucas Dixon CAM-CAD 2009 Abstract We considers how a particular kind of graph corresponds to multiplicative intuitionistic linear logic formula. The main feature of the

More information

(Refer Slide Time: 4:00)

(Refer Slide Time: 4:00) Principles of Programming Languages Dr. S. Arun Kumar Department of Computer Science & Engineering Indian Institute of Technology, Delhi Lecture - 38 Meanings Let us look at abstracts namely functional

More information

Lecture 9: Typed Lambda Calculus

Lecture 9: Typed Lambda Calculus Advanced Topics in Programming Languages Spring Semester, 2012 Lecture 9: Typed Lambda Calculus May 8, 2012 Lecturer: Mooly Sagiv Scribe: Guy Golan Gueta and Shachar Itzhaky 1 Defining a Type System for

More information

A Canonical 1 Locally Named Representation of Binding. α -equivalence is identity. Randy Pollack. Masahiko Sato. LFCS, University of Edinburgh

A Canonical 1 Locally Named Representation of Binding. α -equivalence is identity. Randy Pollack. Masahiko Sato. LFCS, University of Edinburgh A Canonical 1 Locally Named Representation of Binding Randy Pollack LFCS, University of Edinburgh Masahiko Sato Graduate School of Informatics, Kyoto University Version of December 7, 2009 1 α -equivalence

More information

HOL DEFINING HIGHER ORDER LOGIC LAST TIME ON HOL CONTENT. Slide 3. Slide 1. Slide 4. Slide 2 WHAT IS HIGHER ORDER LOGIC? 2 LAST TIME ON HOL 1

HOL DEFINING HIGHER ORDER LOGIC LAST TIME ON HOL CONTENT. Slide 3. Slide 1. Slide 4. Slide 2 WHAT IS HIGHER ORDER LOGIC? 2 LAST TIME ON HOL 1 LAST TIME ON HOL Proof rules for propositional and predicate logic Safe and unsafe rules NICTA Advanced Course Forward Proof Slide 1 Theorem Proving Principles, Techniques, Applications Slide 3 The Epsilon

More information

Computer Science 190 (Autumn Term, 2010) Semantics of Programming Languages

Computer Science 190 (Autumn Term, 2010) Semantics of Programming Languages Computer Science 190 (Autumn Term, 2010) Semantics of Programming Languages Course instructor: Harry Mairson (mairson@brandeis.edu), Volen 257, phone (781) 736-2724. Office hours Monday and Wednesday,

More information

2.1 The λ-calculus Syntax

2.1 The λ-calculus Syntax 2- The λ-calculus 2. The λ-calculus In the previous section, we introduced the concepts of logic and proofs. We shall now present the notion of programs and computations through the so-called λ-calculus.

More information

Type Systems. Parametric Polymorphism. 1. Recall Let-Polymorphism. 1. Recall Let-Polymorphism. Lecture 9 Dec. 15th, 2004 Sebastian Maneth

Type Systems. Parametric Polymorphism. 1. Recall Let-Polymorphism. 1. Recall Let-Polymorphism. Lecture 9 Dec. 15th, 2004 Sebastian Maneth Today Parametric Polymorphism Type Systems Lecture 9 Dec. 15th, 2004 Sebastian Maneth 1. Recall Let-Polymorphism 4. System F-sub 5. Properties of F-sub http://lampwww.epfl.ch/teaching/typesystems/2004

More information

Introduction to the Lambda Calculus

Introduction to the Lambda Calculus Introduction to the Lambda Calculus Overview: What is Computability? Church s Thesis The Lambda Calculus Scope and lexical address The Church-Rosser Property Recursion References: Daniel P. Friedman et

More information

SORT INFERENCE \coregular" signatures, they derive an algorithm for computing a most general typing for expressions e which is only slightly more comp

SORT INFERENCE \coregular signatures, they derive an algorithm for computing a most general typing for expressions e which is only slightly more comp Haskell Overloading is DEXPTIME{complete Helmut Seidl Fachbereich Informatik Universitat des Saarlandes Postfach 151150 D{66041 Saarbrucken Germany seidl@cs.uni-sb.de Febr., 1994 Keywords: Haskell type

More information

Comparing Cubes. Steffen van Bakel Luigi Liquori Simona Ronchi della Rocca Paweł Urzyczyn

Comparing Cubes. Steffen van Bakel Luigi Liquori Simona Ronchi della Rocca Paweł Urzyczyn Comparing Cubes Steffen van Bakel Luigi Liquori Simona Ronchi della Rocca Paweł Urzyczyn Afdeling Informatica, Universiteit Nijmegen, Toernooiveld 1, 6525 ED Nijmegen, Nederland. E-mail steffen@cs.kun.nl.

More information

Verifying Program Invariants with Refinement Types

Verifying Program Invariants with Refinement Types Verifying Program Invariants with Refinement Types Rowan Davies and Frank Pfenning Carnegie Mellon University Princeton and Yale Colloquium Talks February, 2001 Acknowledgments: Robert Harper 1 Overview

More information

An Implementation of the Language Lambda Prolog Organized around Higher-Order Pattern Unification

An Implementation of the Language Lambda Prolog Organized around Higher-Order Pattern Unification An Implementation of the Language Lambda Prolog Organized around Higher-Order Pattern Unification SUBMITTED TO THE FACULTY OF THE GRADUATE SCHOOL OF THE UNIVERSITY OF MINNESOTA BY Xiaochu Qi IN PARTIAL

More information

Type Systems COMP 311 Rice University Houston, Texas

Type Systems COMP 311 Rice University Houston, Texas Rice University Houston, Texas 1 Type Systems for Programming Language were invented by mathematicians before electronic computers were invented. What is a type? A meaningful subset of the set of the domain

More information

Calculus of Inductive Constructions

Calculus of Inductive Constructions Calculus of Inductive Constructions Software Formal Verification Maria João Frade Departmento de Informática Universidade do Minho 2008/2009 Maria João Frade (DI-UM) Calculus of Inductive Constructions

More information

Introduction to the Lambda Calculus. Chris Lomont

Introduction to the Lambda Calculus. Chris Lomont Introduction to the Lambda Calculus Chris Lomont 2010 2011 2012 www.lomont.org Leibniz (1646-1716) Create a universal language in which all possible problems can be stated Find a decision method to solve

More information

Introduction to Lambda Calculus. Lecture 7 CS /08/09

Introduction to Lambda Calculus. Lecture 7 CS /08/09 Introduction to Lambda Calculus Lecture 7 CS 565 02/08/09 Lambda Calculus So far, we ve explored some simple but non-interesting languages language of arithmetic expressions IMP (arithmetic + while loops)

More information

Lexicografie computationala Feb., 2012

Lexicografie computationala Feb., 2012 Lexicografie computationala Feb., 2012 Anca Dinu University of Bucharest Introduction When we construct meaning representations systematically, we integrate information from two different sources: 1. The

More information

VU Semantik von Programmiersprachen

VU Semantik von Programmiersprachen VU Semantik von Programmiersprachen Agata Ciabattoni Institute für Computersprachen, Theory and Logic group (agata@logic.at) (A gentle) Introduction to λ calculus p. 1 Why shoud I studyλcalculus? p. 2

More information

Lecture 3: Typed Lambda Calculus and Curry-Howard

Lecture 3: Typed Lambda Calculus and Curry-Howard Lecture 3: Typed Lambda Calculus and Curry-Howard H. Geuvers Radboud University Nijmegen, NL 21st Estonian Winter School in Computer Science Winter 2016 H. Geuvers - Radboud Univ. EWSCS 2016 Typed λ-calculus

More information

Mathematics for Computer Scientists 2 (G52MC2)

Mathematics for Computer Scientists 2 (G52MC2) Mathematics for Computer Scientists 2 (G52MC2) L07 : Operations on sets School of Computer Science University of Nottingham October 29, 2009 Enumerations We construct finite sets by enumerating a list

More information

Goal. CS152: Programming Languages. Lecture 15 Parametric Polymorphism. What the Library Likes. What The Client Likes. Start simpler.

Goal. CS152: Programming Languages. Lecture 15 Parametric Polymorphism. What the Library Likes. What The Client Likes. Start simpler. Goal Understand what this interface means and why it matters: CS152: Programming Languages Lecture 15 Parametric Polymorphism Dan Grossman Spring 2011 type a mylist; val mt_list : a mylist val cons : a

More information

Introduction to Lambda Calculus. Lecture 5 CS 565 1/24/08

Introduction to Lambda Calculus. Lecture 5 CS 565 1/24/08 Introduction to Lambda Calculus Lecture 5 CS 565 1/24/08 Lambda Calculus So far, we ve explored some simple but non-interesting languages language of arithmetic expressions IMP (arithmetic + while loops)

More information

Type Inference with Inequalities

Type Inference with Inequalities Type Inference with Inequalities Michael I. Schwartzbach mis@daimi.aau.dk Computer Science Department Aarhus University Ny Munkegade DK-8000 Århus C, Denmark Abstract Type inference can be phrased as constraint-solving

More information

ML Has Principal Typings

ML Has Principal Typings Electronic Notes in Theoretical Computer Science 38 (2005) URL: http://www.elsevier.nl/locate/entcs/volume38.html ML Has Principal Typings Carlos Camarão and Lucília Figueiredo Abstract Is there a type

More information

A Modality for Recursion

A Modality for Recursion A Modality for Recursion (Technical Report) March 31, 2001 Hiroshi Nakano Ryukoku University, Japan nakano@mathryukokuacjp Abstract We propose a modal logic that enables us to handle self-referential formulae,

More information

Symmetry in Type Theory

Symmetry in Type Theory Google May 29th, 2012 What is Symmetry? Definition Symmetry: Two or more things that initially look distinct, may actually be instances of a more general underlying principle. Why do we care? Simplicity.

More information

A MECHANIZATION OF TYPE THEORY. Gerard P. HUBT IRIA - LABORIA Rocquencourt FRANCE

A MECHANIZATION OF TYPE THEORY. Gerard P. HUBT IRIA - LABORIA Rocquencourt FRANCE Session 6 Logic: II Theorem Proving and A MECHANIZATION OF TYPE THEORY Gerard P. HUBT IRIA - LABORIA Rocquencourt FRANCE ABSTRACT A refutational system of logic for a language of order w ia presented.

More information

Part III. Chapter 15: Subtyping

Part III. Chapter 15: Subtyping Part III Chapter 15: Subtyping Subsumption Subtype relation Properties of subtyping and typing Subtyping and other features Intersection and union types Subtyping Motivation With the usual typing rule

More information

CS152: Programming Languages. Lecture 11 STLC Extensions and Related Topics. Dan Grossman Spring 2011

CS152: Programming Languages. Lecture 11 STLC Extensions and Related Topics. Dan Grossman Spring 2011 CS152: Programming Languages Lecture 11 STLC Extensions and Related Topics Dan Grossman Spring 2011 Review e ::= λx. e x e e c v ::= λx. e c τ ::= int τ τ Γ ::= Γ, x : τ (λx. e) v e[v/x] e 1 e 1 e 1 e

More information

Simply-Typed Lambda Calculus

Simply-Typed Lambda Calculus #1 Simply-Typed Lambda Calculus #2 Back to School What is operational semantics? When would you use contextual (small-step) semantics? What is denotational semantics? What is axiomatic semantics? What

More information

Lambda Calculus. Variables and Functions. cs3723 1

Lambda Calculus. Variables and Functions. cs3723 1 Lambda Calculus Variables and Functions cs3723 1 Lambda Calculus Mathematical system for functions Computation with functions Captures essence of variable binding Function parameters and substitution Can

More information

1 Introduction. 3 Syntax

1 Introduction. 3 Syntax CS 6110 S18 Lecture 19 Typed λ-calculus 1 Introduction Type checking is a lightweight technique for proving simple properties of programs. Unlike theorem-proving techniques based on axiomatic semantics,

More information

Elf: A Meta-Language for Deductive Systems (System Description)

Elf: A Meta-Language for Deductive Systems (System Description) Elf: A Meta-Language for Deductive Systems (System Description) Frank Pfenning Department of Computer Science, Carnegie Mellon University, Pittsburgh, PA 15213, U.S.A. 1 Overview Elf is a uniform meta-language

More information

Proofs-Programs correspondance and Security

Proofs-Programs correspondance and Security Proofs-Programs correspondance and Security Jean-Baptiste Joinet Université de Lyon & Centre Cavaillès, École Normale Supérieure, Paris Third Cybersecurity Japanese-French meeting Formal methods session

More information

Foundations of AI. 9. Predicate Logic. Syntax and Semantics, Normal Forms, Herbrand Expansion, Resolution

Foundations of AI. 9. Predicate Logic. Syntax and Semantics, Normal Forms, Herbrand Expansion, Resolution Foundations of AI 9. Predicate Logic Syntax and Semantics, Normal Forms, Herbrand Expansion, Resolution Wolfram Burgard, Andreas Karwath, Bernhard Nebel, and Martin Riedmiller 09/1 Contents Motivation

More information

Formal Systems and their Applications

Formal Systems and their Applications Formal Systems and their Applications Dave Clarke (Dave.Clarke@cs.kuleuven.be) Acknowledgment: these slides are based in part on slides from Benjamin Pierce and Frank Piessens 1 Course Overview Introduction

More information

Theory and Implementation of a Functional Programming Language

Theory and Implementation of a Functional Programming Language Rose-Hulman Undergraduate Mathematics Journal Volume 1 Issue 2 Article 3 Theory and Implementation of a Functional Programming Language Ari Lamstein University of Michigan Follow this and additional works

More information

A Typed Calculus Supporting Shallow Embeddings of Abstract Machines

A Typed Calculus Supporting Shallow Embeddings of Abstract Machines A Typed Calculus Supporting Shallow Embeddings of Abstract Machines Aaron Bohannon Zena M. Ariola Amr Sabry April 23, 2005 1 Overview The goal of this work is to draw a formal connection between steps

More information

Lambda Calculus and Type Inference

Lambda Calculus and Type Inference Lambda Calculus and Type Inference Björn Lisper Dept. of Computer Science and Engineering Mälardalen University bjorn.lisper@mdh.se http://www.idt.mdh.se/ blr/ August 17, 2007 Lambda Calculus and Type

More information

Lambda Calculi With Polymorphism

Lambda Calculi With Polymorphism Resources: The slides of this lecture were derived from [Järvi], with permission of the original author, by copy & x = 1 let x = 1 in... paste or by selection, annotation, or rewording. [Järvi] is in turn

More information

Propositional Logic. Part I

Propositional Logic. Part I Part I Propositional Logic 1 Classical Logic and the Material Conditional 1.1 Introduction 1.1.1 The first purpose of this chapter is to review classical propositional logic, including semantic tableaux.

More information

Automata and Formal Languages - CM0081 Introduction to Agda

Automata and Formal Languages - CM0081 Introduction to Agda Automata and Formal Languages - CM0081 Introduction to Agda Andrés Sicard-Ramírez Universidad EAFIT Semester 2018-2 Introduction Curry-Howard correspondence Dependent types Constructivism Martin-Löf s

More information

Harvard School of Engineering and Applied Sciences CS 152: Programming Languages

Harvard School of Engineering and Applied Sciences CS 152: Programming Languages Harvard School of Engineering and Applied Sciences CS 152: Programming Languages Lecture 19 Tuesday, April 3, 2018 1 Introduction to axiomatic semantics The idea in axiomatic semantics is to give specifications

More information

Reducibility and -lifting for Computation Types

Reducibility and -lifting for Computation Types Reducibility and -lifting for Computation Types Sam Lindley and Ian Stark Laboratory for Foundations of Computer Science School of Informatics, The University of Edinburgh, Scotland {Ian.Stark,Sam.Lindley}@ed.ac.uk

More information

CMSC 330: Organization of Programming Languages

CMSC 330: Organization of Programming Languages CMSC 330: Organization of Programming Languages Lambda Calculus CMSC 330 1 Programming Language Features Many features exist simply for convenience Multi-argument functions foo ( a, b, c ) Use currying

More information

COMP4418 Knowledge Representation and Reasoning

COMP4418 Knowledge Representation and Reasoning COMP4418 Knowledge Representation and Reasoning Week 3 Practical Reasoning David Rajaratnam Click to edit Present s Name Practical Reasoning - My Interests Cognitive Robotics. Connect high level cognition

More information

7. Relational Calculus (Part I) 7.1 Introduction

7. Relational Calculus (Part I) 7.1 Introduction 7. Relational Calculus (Part I) 7.1 Introduction We established earlier the fundamental role of relational algebra and calculus in relational databases (see 5.1). More specifically, relational calculus

More information

Stable Harmony. Nils Kurbis

Stable Harmony. Nils Kurbis Stable Harmony Nils Kurbis 1. Gentzen s Thesis and Two Notions of Harmony Gentzen observed that there is a remarkable systematic in the inference patterns for symbols of the calculus of natural deduction.

More information

EXTENSIONS OF FIRST ORDER LOGIC

EXTENSIONS OF FIRST ORDER LOGIC EXTENSIONS OF FIRST ORDER LOGIC Maria Manzano University of Barcelona CAMBRIDGE UNIVERSITY PRESS Table of contents PREFACE xv CHAPTER I: STANDARD SECOND ORDER LOGIC. 1 1.- Introduction. 1 1.1. General

More information

CS 6110 S11 Lecture 25 Typed λ-calculus 6 April 2011

CS 6110 S11 Lecture 25 Typed λ-calculus 6 April 2011 CS 6110 S11 Lecture 25 Typed λ-calculus 6 April 2011 1 Introduction Type checking is a lightweight technique for proving simple properties of programs. Unlike theorem-proving techniques based on axiomatic

More information

1 Scope, Bound and Free Occurrences, Closed Terms

1 Scope, Bound and Free Occurrences, Closed Terms CS 6110 S18 Lecture 2 The λ-calculus Last time we introduced the λ-calculus, a mathematical system for studying the interaction of functional abstraction and functional application. We discussed the syntax

More information

A Prolog-based Proof Tool for Type Theory TA λ and Implicational Intuitionistic-Logic

A Prolog-based Proof Tool for Type Theory TA λ and Implicational Intuitionistic-Logic for Type Theory TA λ and Implicational Intuitionistic-Logic L. Yohanes Stefanus University of Indonesia Depok 16424, Indonesia yohanes@cs.ui.ac.id and Ario Santoso Technische Universität Dresden Dresden

More information

One of a number of approaches to a mathematical challenge at the time (1930): Constructibility

One of a number of approaches to a mathematical challenge at the time (1930): Constructibility λ Calculus Church s λ Calculus: Brief History One of a number of approaches to a mathematical challenge at the time (1930): Constructibility (What does it mean for an object, e.g. a natural number, to

More information

The Typed λ Calculus and Type Inferencing in ML

The Typed λ Calculus and Type Inferencing in ML Notes on Types S. Arun-Kumar Department of Computer Science and Engineering Indian Institute of Technology New Delhi, 110016 email: sak@cse.iitd.ernet.in April 14, 2002 2 Chapter 1 The Typed λ Calculus

More information

Lambda Calculus. Lecture 4 CS /26/10

Lambda Calculus. Lecture 4 CS /26/10 Lambda Calculus Lecture 4 CS 565 10/26/10 Pure (Untyped) Lambda Calculus The only value is a function Variables denote functions Functions always take functions as arguments Functions always return functions

More information

The Untyped Lambda Calculus

The Untyped Lambda Calculus Resources: The slides of this lecture were derived from [Järvi], with permission of the original author, by copy & x = 1 let x = 1 in... paste or by selection, annotation, or rewording. [Järvi] is in turn

More information

Polymorphic Delimited Continuations

Polymorphic Delimited Continuations Polymorphic Delimited Continuations Kenichi Asai 1 and Yukiyoshi Kameyama 2 1 Department of Information Science, Ochanomizu University asai@is.ocha.ac.jp 2 Department of Computer Science, University of

More information

Foundational Aspects of Syntax 1

Foundational Aspects of Syntax 1 Foundational Aspects of Syntax 1 Introduction Dale Miller and Catuscia Palamidessi Department of Computer Science and Engineering The Pennsylvania State University 220 Pond Laboratory University Park,

More information

Programming Languages

Programming Languages CSE 230: Winter 2008 Principles of Programming Languages Ocaml/HW #3 Q-A Session Push deadline = Mar 10 Session Mon 3pm? Lecture 15: Type Systems Ranjit Jhala UC San Diego Why Typed Languages? Development

More information

The three faces of homotopy type theory. Type theory and category theory. Minicourse plan. Typing judgments. Michael Shulman.

The three faces of homotopy type theory. Type theory and category theory. Minicourse plan. Typing judgments. Michael Shulman. The three faces of homotopy type theory Type theory and category theory Michael Shulman 1 A programming language. 2 A foundation for mathematics based on homotopy theory. 3 A calculus for (, 1)-category

More information

Proofs are Programs. Prof. Clarkson Fall Today s music: Proof by Paul Simon

Proofs are Programs. Prof. Clarkson Fall Today s music: Proof by Paul Simon Proofs are Programs Prof. Clarkson Fall 2017 Today s music: Proof by Paul Simon Review Previously in 3110: Functional programming in Coq Logic in Coq Today: A fundamental idea that goes by many names...

More information

Encryption as an Abstract Datatype:

Encryption as an Abstract Datatype: June 2003 1/18 Outline Encryption as an Abstract Datatype: an extended abstract Dale Miller INRIA/Futurs/Saclay and École polytechnique 1. Security protocols specified using multisets rewriting. 2. Eigenvariables

More information

Functions as data. Massimo Merro. 9 November Massimo Merro The Lambda language 1 / 21

Functions as data. Massimo Merro. 9 November Massimo Merro The Lambda language 1 / 21 Functions as data Massimo Merro 9 November 2011 Massimo Merro The Lambda language 1 / 21 The core of sequential programming languages In the mid 1960s, Peter Landin observed that a complex programming

More information

CSCI.6962/4962 Software Verification Fundamental Proof Methods in Computer Science (Arkoudas and Musser) Chapter p. 1/27

CSCI.6962/4962 Software Verification Fundamental Proof Methods in Computer Science (Arkoudas and Musser) Chapter p. 1/27 CSCI.6962/4962 Software Verification Fundamental Proof Methods in Computer Science (Arkoudas and Musser) Chapter 2.1-2.7 p. 1/27 CSCI.6962/4962 Software Verification Fundamental Proof Methods in Computer

More information

Part III Chapter 15: Subtyping

Part III Chapter 15: Subtyping Part III Chapter 15: Subtyping Subsumption Subtype relation Properties of subtyping and typing Subtyping and other features Intersection and union types Subtyping Motivation With the usual typing rule

More information

Formal Predicate Calculus. Michael Meyling

Formal Predicate Calculus. Michael Meyling Formal Predicate Calculus Michael Meyling May 24, 2013 2 The source for this document can be found here: http://www.qedeq.org/0_04_07/doc/math/qedeq_formal_logic_v1.xml Copyright by the authors. All rights

More information

The Untyped Lambda Calculus

The Untyped Lambda Calculus Resources: The slides of this lecture were derived from [Järvi], with permission of the original author, by copy & x = 1 let x = 1 in... paste or by selection, annotation, or rewording. [Järvi] is in turn

More information

A New Proof of P-time Completeness of Linear Lambda Calculus

A New Proof of P-time Completeness of Linear Lambda Calculus A New Proof of P-time Completeness of Linear Lambda Calculus National Institute of Advanced Industrial Science and Technology (AIST), 1-1-1 Umezono, Tsukuba, Ibaraki, 305-8563 Japan arxiv:1301.2763v1 [cs.lo]

More information

An Introduction to Programming and Proving in Agda (incomplete draft)

An Introduction to Programming and Proving in Agda (incomplete draft) An Introduction to Programming and Proving in Agda (incomplete draft) Peter Dybjer January 29, 2018 1 A first Agda module Your first Agda-file is called BoolModule.agda. Its contents are module BoolModule

More information

CS-XXX: Graduate Programming Languages. Lecture 9 Simply Typed Lambda Calculus. Dan Grossman 2012

CS-XXX: Graduate Programming Languages. Lecture 9 Simply Typed Lambda Calculus. Dan Grossman 2012 CS-XXX: Graduate Programming Languages Lecture 9 Simply Typed Lambda Calculus Dan Grossman 2012 Types Major new topic worthy of several lectures: Type systems Continue to use (CBV) Lambda Caluclus as our

More information

Programming Proofs and Proving Programs. Nick Benton Microsoft Research, Cambridge

Programming Proofs and Proving Programs. Nick Benton Microsoft Research, Cambridge Programming Proofs and Proving Programs Nick Benton Microsoft Research, Cambridge Coffee is does Greek 1. To draw a straight line from any point to any point. 2. To produce a finite straight line continuously

More information

A Polymorphic Record Calculus and Its Compilation

A Polymorphic Record Calculus and Its Compilation A Polymorphic Record Calculus and Its Compilation ATSUSHI OHORI Kyoto University The motivation of this work is to provide a type-theoretical basis for developing a practical polymorphic programming language

More information

Interpretations of Classical Logic Using λ-calculus. Freddie Agestam

Interpretations of Classical Logic Using λ-calculus. Freddie Agestam Interpretations of Classical Logic Using λ-calculus Freddie Agestam Abstract Lambda calculus was introduced in the 1930s as a computation model. It was later shown that the simply typed λ-calculus has

More information

Lambda Calculus alpha-renaming, beta reduction, applicative and normal evaluation orders, Church-Rosser theorem, combinators

Lambda Calculus alpha-renaming, beta reduction, applicative and normal evaluation orders, Church-Rosser theorem, combinators Lambda Calculus alpha-renaming, beta reduction, applicative and normal evaluation orders, Church-Rosser theorem, combinators Carlos Varela Rennselaer Polytechnic Institute February 11, 2010 C. Varela 1

More information

CIS 500 Software Foundations Fall December 4

CIS 500 Software Foundations Fall December 4 CIS 500 Software Foundations Fall 2006 December 4 Administrivia Homework 11 Homework 11 is currently due on Friday. Should we make it due next Monday instead? More on Evaluation Contexts Progress for FJ

More information

λ calculus Function application Untyped λ-calculus - Basic Idea Terms, Variables, Syntax β reduction Advanced Formal Methods

λ calculus Function application Untyped λ-calculus - Basic Idea Terms, Variables, Syntax β reduction Advanced Formal Methods Course 2D1453, 2006-07 Advanced Formal Methods Lecture 2: Lambda calculus Mads Dam KTH/CSC Some material from B. Pierce: TAPL + some from G. Klein, NICTA Alonzo Church, 1903-1995 Church-Turing thesis First

More information

Theories of Information Hiding in Lambda-Calculus

Theories of Information Hiding in Lambda-Calculus Theories of Information Hiding in Lambda-Calculus Logical Relations and Bisimulations for Encryption and Type Abstraction Eijiro Sumii University of Pennsylvania Main Results Proof methods for two forms

More information