Introduction to lambda calculus Part 6

Size: px
Start display at page:

Download "Introduction to lambda calculus Part 6"

Transcription

1 Introduction to lambda calculus Part 6 Antti-Juhani Kaijanaho Untyped lambda calculus 2 Typed lambda calculi 2.1 Dynamically typed lambda calculus with integers 2.2 A model of Lisp 2.3 Simply typed lambda calculus 2.4 A monomorphic model of ML and Haskell At their core, ML (including Standard ML and OCaml) and Haskell are Lisps with a static type system. A fundamental part of them is a (parametrically) polymorphic type discipline due (independently of each other) to Hindley (1969) and Milner (1978). Minor changes made afterward. Last changed :44:01+02:00. 1

2 D TypeName T, U Type T, U ::= D Num T U x, y, z Var c Const A, B, C Constructor t, u Term t, u ::= x C c t + u t u λx t let x = t in u case t of m m Match m ::= p t m p Pattern p ::= C p x Γ, x : T x : T Γ, C : T C : T Γ c : Num Γ t : Num Γ u : Num Γ t + u : Num Γ t : U T Γ u : U Γ t u : T Γ, x : U t : T Γ λx t : U T Γ, x : T t : T Γ, x : T u : U Γ let x = t in u : U Γ t : T Γ m : T U Γ case t of m : U Γ C : T 1 T n T Γ, x 1 : T 1,, x n : T n u : U Γ m : T U Γ C x 1 x n u m : T U Γ : T U 2 (16) (17) (18) (19) (20) (21) (22) (23) (24) (25)

3 2.5 Hindley Milner type discipline The monomorphic system discussed above has a problem: terms do not have unique types. Consider the following type derivation 1 schema using the monomorphic ML/Haskell type system: x : T x : T (λx x) : T T (26) This is not a type derivation, as T is not a type but a metavariable standing for types. We can make a valid type derivation by replacing T uniformly in it by some actual type. For example: Or: Or: x : Num x : Num (λx x) : Num Num x : NumList x : NumList (λx x) : NumList NumList x : (Num Num) x : (Num Num) (λx x) : (Num Num) (Num Num) But there is something inherently right about the derivation schema (26): it somehow captures the essence of the identity function that it takes anything and results in that same anything. We can try to capture this idea by adding to our type language the notion of a type variable (which we usually write using lowercase Greek letters). Similarly, there are many functions (such as the one computing the length of the list) that do not care what the element type of a list is. But remember, the list of numbers was defined earlier as the algebraic type the algebraic type NumList having the constructors Nil : NumList, Cons : Num NumList NumList. We can write the length function for these lists easily enough: let length = λl case l of Cons x xs 1 + (length xs) in length Nil 0 and it is straigthforward to determine that, given the above constructors of NumList in the type environment, this term has the type NumList Num. But if Cons and Nil were instead defined for StringList, this exact same term with no change! would have the type StringList Num. Since a constructor just packs pointers to its arguments to a memory object, there is no real need for these constructors to care what the element type is, so long as the element type information is preserved. Thus, we might as well also allow the use of type variables as parameters to type names so that we can write List α instead of just IntList. 1 Earlier I called these type inference tree but I will be using type inference for something else soon. The term type derivation is better here. 3

4 We now arrive in the following changed abstract syntax. There is no need to make any changes to the term language, and so I will not repeat its abstract syntax. α, β, γ, δ, TypeVar D TypeName d ParametrizedTypeName d ::= D d T T, U Type T, U ::= d α Num T U I will assume in the following that all constructors have sensible types. In a more thorough development I would introduce the idea of a kind system (a type system for types), but I will ignore that wrinkle here Principal types There is a natural partial order between types: α α is quite obviously more general than Num Num and more general than (β β) (β β). To make this more precise, notice that we can produce both of the latter by replacing type variables by more complex types: (α α)[α := Num] = Num Num (α α)[α := β β] = (β β) (β β) In the general case, there may be more than one type variable; the same idea works so long as the substitution is understood to be simultaneous for all type variables involved. For example: (α β)[α := β Int, β := Int] = (β Int) Int Formally we define a type substitution as any function σ : TypeVar Type such that the set { α TypeVar σ(α) α } is finite. The bracket-substitution notation is defined as { T i if β = α i, [α 1 := T 1,, α n := T n ](β) = (27) β otherwise. and the application of a substitution σ to a type (written by appending the substitution to the type) is defined by structural recursion: D σ = D (28) (d α)σ = (dσ)(σ(α)) (29) α σ = σ(α) (30) Num σ = Num (31) (T U)σ = T σ Uσ (32) Example 18 Let us compute the following substitution: (α β)[α := β Int, β := Int] 4

5 = α[α := β Int, β := Int] β[α := β Int, β := Int] by (32) = [α := β Int, β := Int](α) [α := β Int, β := Int](β) by (30) = (β Int) [α := β Int, β := Int](β) by (27) = (β Int) Int by (27) Exercise 14 Compute the substitution (α α)[α := β β]. Now, we will define that a type T is at most as general as a type U, written as T U, if there is some type substitution σ for which T = Uσ holds. Further, we will define that a type substitution σ is a renaming if for all type variables α it holds that σ(α) is a type variable and if for all distinct type variables α and β it holds that σ(α) σ(β). Now, types T and U are identical up to renaming, written T U, if there is a renaming σ such that T σ = U. Example 19 α β β α, because (α β)[α := β, β := α] and [α := β, β := α] is a renaming. Exercise 15 Prove: 1. T T holds for all types T. 2. If T U and U T, then T U, for all types T and U. 3. If T 1 T 2 and T 1 T 3, then T 1 T 3, for all types T 1, T 2, and T 3. Now, it is possible to prove that for any set of types T there is at least one generalization of those types, that is, a type that is at least as general as every type in T. Further, it is possible to prove that there is a unique (up to renaming) least general generalization, that is, some generalization of T that is at most as general as any other generalization of T. Thus, for any term there is a unique (up to renaming) principal type, which is the least general generalization of all types that the monomorphic theory provides. The way to find the principal type of a term is essentially this: 1. Start with a type judgment stating that the type (with respect to an appropriate type environment) of the term is some type variable that does not occur elsewhere in the type judgment (a fresh type variable). 2. Build a type derivation as usual, with the following two provisos: Each time you need to invent a type, use a fresh type variable. Each time you need to determine whether two types are identical, proceed as if they are, but record this identity requirement in a separate list of type equations. 3. Finally, solve the set of type equations. Example 20 Let us proceed with this process, up to but not including solving the equations, for determining the principal type of λf λx f(f x). Start with an empty environment and a fresh type variable: λf λx f(f x) : α We use rule (21), using fresh type variables β and γ for T and U, respectively, and record a type equation to make the rule come out right: f : β λx f(f x) : γ λf λx f(f x) : α α = β γ 5

6 We use rule (21) again, using fresh type variables δ and ε for T and U, respectively, and record a type equation to make the rule come out right: f : β, x : δ f(f x) : ε f : β λx f(f x) : γ λf λx f(f x) : α α = β γ ε Next, we use rule (20), using the fresh type variable ϕ as U: f : β, x : δ f : ϕ ε f : β, x : δ f x : ϕ f : β, x : δ f(f x) : ε f : β λx f(f x) : γ λf λx f(f x) : α α = β γ ε We can now finish one branch of this derivation tree by using axiom (16) and recording a type equation: f : β, x : δ f : ϕ ε f : β, x : δ f x : ϕ f : β, x : δ f(f x) : ε f : β λx f(f x) : γ λf λx f(f x) : α α = β γ ε β = ϕ ε The other branch requires another use of rule (20) and the use of a fresh type variable, this time ζ, for U: f : β, x : δ f : ϕ ε f : β, x : δ f : ζ ϕ f : β, x : δ x : ζ f : β, x : δ f x : ϕ f : β, x : δ f(f x) : ε f : β λx f(f x) : γ λf λx f(f x) : α α = β γ ε β = ϕ ε We can close the two open branches by using axiom (16) and recording the appropriate equations: f : β, x : δ f : ϕ ε f : β, x : δ f : ζ ϕ f : β, x : δ x : ζ f : β, x : δ f x : ϕ f : β, x : δ f(f x) : ε f : β λx f(f x) : γ λf λx f(f x) : α α = β γ ε β = ϕ ε β = ζ ϕ Example 21 Let us proceed with this process, up to but not including solving the equations, for determining the principal type of let x = Cons 1 x in x where, almost like before, Cons : α List α List α. We start with the type environment Γ = Cons : α List α List α and a fresh type variable (which now cannot be α): Use rule (22) and a fresh type variable γ: Γ (let x = Cons 1 x in x) : β Γ, x : γ (Cons 1 x) : γ Γ, x : γ x : β Γ (let x = Cons 1 x in x) : β 6

7 Use rule (20) and a fresh type variable δ: Γ, x : γ (Cons 1) : δ γ Γ, x : γ x : δ Γ, x : γ (Cons 1 x) : γ Γ, x : γ x : β Γ (let x = Cons 1 x in x) : β Use rule (20) and a fresh type variable ε: Γ, x : γ Cons : ε δ γ Γ, x : γ 1 : ε Γ, x : γ (Cons 1) : δ γ Γ, x : γ x : δ Γ, x : γ (Cons 1 x) : γ Γ, x : γ x : β Γ (let x = Cons 1 x in x) : β Now, close the leftmost branch by using axiom (17) and recording the appropriate type equation: Γ, x : γ Cons : ε δ γ Γ, x : γ 1 : ε Γ, x : γ (Cons 1) : δ γ Γ, x : γ x : δ Γ, x : γ (Cons 1 x) : γ Γ, x : γ x : β Γ (let x = Cons 1 x in x) : β α List α List α = ε δ γ Close the leftmost open branch by using axiom (18) and recording the appropriate type equation: Γ, x : γ Cons : ε δ γ Γ, x : γ 1 : ε Γ, x : γ (Cons 1) : δ γ Γ, x : γ x : δ Γ, x : γ (Cons 1 x) : γ Γ, x : γ x : β Γ (let x = Cons 1 x in x) : β α List α List α = ε δ γ Close the remaining open branches by using axiom (16) and recording the appropriate type equations: Γ, x : γ Cons : ε δ γ Γ, x : γ 1 : ε Γ, x : γ (Cons 1) : δ γ Γ, x : γ x : δ Γ, x : γ (Cons 1 x) : γ Γ, x : γ x : β Γ (let x = Cons 1 x in x) : β Solving type equations α List α List α = ε δ γ γ = β The problem of solving these sorts of equations comes up in many different subfields of classical computer science and is known as the syntactic unification problem. The first algorithm was proposed in the field of automatic reasoning by Robinson (1965); a rather clearer nondeterministic algorithm was described by Martelli and Montanari (1982). I will describe the latter. 2 2 Martelli and Montanari (1982) also show how this algorithm can be refined to be easy to implement efficiently on a deterministic computer. I will not discuss it here, as I am dealing with concepts, not efficient implementation. 7

8 The input to this algorithm is a set of type equations; the output is either a solution to the set of type equations or an indication of failure. The solution will be in the form of a set of type equations, each equation having a type variable on the left hand side and a type on the right hand side, and no type variable being the left hand side of more than one type equation of the solution. The algorithm proceeds by picking nondeterministically some equation matching the left hand side of one of the following rules and replacing it with the equations on the right hand side of that same rule, mutatis mutandis. If the right hand side is empty, the equation is simply deleted. T = α α = T (33) α = α (34) Num = Num (35) D = D (36) T 1 U 1 = T 2 U 2 T 1 = T 2, U 1 = U 2 (37) d T = d U d = d, T = U (38) There is one other rule, the variable elimination rule, which proceeds as follows. Choose an equation of the form α = T, where α does not occur in T but does occur in at least one other equation in the set. Do not change this equation; but modify every other equation by applying the substitution [α := T ] to its both sides. This algorithm terminates when no equation matches any rule. If the resulting equation set has none of the following error conditions, the set is a solution: 3 There is an equation of the form α = T, where α occurs in T but is not T. This indicates that there is an infinitely long type involved, which is not allowed. This error condition is often called an occurs check failure. There is an equation of the form T 1 T 2 = U or U = T 1 T 2, where U is not a function type nor a type variable. This indicates a type error where something that is not a function (whatever gave rise to U) is being used as a function. There is an equation of the form D = T or T = D, where T is not D nor a type variable. This indicates a type error involving the algebraic type D. There is an equation of the form Num = T or T = Num, where T is not Num nor a type variable. This indicates that something that is not a number (whatever gave rise to T ) is being used as a number. Note that none of the rules delete an error condition, so an implementation may terminate with error as soon as it finds one even if there are rule-matching equations remaining. Example 22 In example 20, we derived that the type of λf λx f(f x) is α, as constrained by following set of type equations: α = β γ ε β = ϕ ε β = ζ ϕ 3 Corrected on Thanks to a student for pointing out the errors. 8

9 Let us solve this equation set: α = β γ α = β γ ε γ = ζ ε β = ϕ ε β = ϕ ε β = ζ ϕ β = ζ ϕ α = β (ζ ε) γ = ζ ε β = ϕ ε β = ζ ϕ α = (ζ ϕ) (ζ ε) γ = ζ ε ζ ϕ = ϕ ε β = ζ ϕ α = (ζ ϕ) (ζ ε) γ = ζ ε ζ = ϕ ϕ = ε β = ζ ϕ α = (ζ ε) (ζ ε) γ = ζ ε ζ = ε ϕ = ε ζ = ε ϕ = ε β = ε ε δ = ε β = ζ ε α = (ε ε) (ε ε)γ = ε ε eliminate δ eliminate γ eliminate β (3rd eq) by (37) eliminate ϕ eliminate ζ which is a solution. Thus, the principal type of λf λx f(f x) is (ε ε) (ε ε), that is, (ε ε) ε ε. Example 23 In example 21, we derived that the type of let x = Cons 1 x in x (in a type environment defining Cons : α List α List α) is β as constrained by following set of type equations: α List α List α = ε δ γ 9 γ = β

10 Let us solve this type equation set: α List α List α = ε δ γ γ = β α List α List α = ε δ β β = δ γ = β α List α List α = ε δ δ β = δ α List α List δ δ β = δ List α List α = δ δ β = δ List α = δ β = δ δ = List α β = δ δ = List Num β = δ eliminate γ (4th eq) eliminate β eliminate ε by (37) by (37) (see below) by (33) eliminate α 10

11 δ = List Num β = List Num γ = List Num eliminate δ which is a solution. Note that when applying rule (37) to the equation List α List α = δ δ, the resulting two equations are identical and, in a set, are not repeated. Now, thus we have the principal type of let x = Cons 1 x in x: it is List Num. Note that the solution equation that the algorithm gives can be interpreted as a type substitution. It is sometimes called the most general unifier or mgu of the original set of type equations. Exercise 16 Determine the principal type of λx x + 1 using this technique Type schemes This puzzle is not quite solved yet. Suppose that we have defined an ordered pair as the parameric algebraic type Pair α β having the constructor Pair : α β Pair α β. I will call an environment containing this constructor Γ. Now, let us type Pair (Pair 1 2) 3: 4 Γ Pair : δ Num γ Γ Pair : Num Num δ Γ 1 : Num Γ Pair 1 : Num δ Γ Pair 1 2 : δ Γ Pair (Pair 1 2) : Num γ Γ Pair (Pair 1 2) 3 : γ { } α β Pair α β = δ Num γ Γ 2 : Num Γ 3 : Num α β Pair α β = Num Num δ Now, let us solve the resulting set of type equations: { } α β Pair α β = δ Num γ α β Pair α β = Num Num δ α = δ β Pair α β = Num γ α β Pair α β = Num Num δ α = δ β = Num Pair α β = γ α β Pair α β = Num Num δ α = δ β = Num Pair α β = γ β Pair α β = Num δ by (37) (1st eq) by (37) (2nd eq) by (37) (4th eq) 4 For simplicity, I will not invent a type variable where the only possible type is obvious, that is, when typing numeric constants. 11

12 α = δ β = Num Pair α β = γ Pair α β = δ Num = δ β = Num Pair Num β = γ Pair Num β = δ Num = δ β = Num Pair Num Num = γ Pair Num Num = δ δ = Num β = Num Pair Num Num = γ Pair Num Num = δ δ = Num β = Num Pair Num Num = γ Pair Num Num = Num by (37) (5th eq) eliminate α (4th eq) eliminate β by (33) (1st eq) eliminate δ (1st eq) The algorithm terminates with an error condition due to the fifth equation in the final set. Thus Pair (Pair 1 2) 3 has no type at all; but surely it should! The problem here is that the α and β in the environment s Pair : α β Pair α β can have only one type each, but this problem term uses Pair polymorphically. The solution adopted in the Hindley Milner type discipline is to allow variables and constructors to have a truly generic type in the type environment one that signals that, each time the variable or constructor is used, it may have a different instantiation of its principal type. These truly generic types are called in the literature type schemes: types together with a list of type variables that may be instantiated differently in different situations. We write a type scheme using a logic-borrowed notation: α α α means that the α may stand for different types in different uses of the variable or constructor. Thus, we add to the abstract syntax: Σ TypeScheme Σ ::= α 1,, α n T Note that a type scheme is not recursive, and the qualifier can thus appear only once. We allow now type environments to specify variables and constructors a type scheme instead of a type; the idea is that all constructor definitions and all toplevel variable definitions will generalize 12

13 all type variables in the principal type. We now give the following two typing rules that instantiate the type variables at each use: Γ, x : α 1,, α n T x : T [α 1 := β 1,, α n := β n ] (39) Γ, x : α 1,, α n T C : T [α 1 := β 1,, α n := β n ] (40) Note that in both rules, the β 1,, β n must be truly fresh: they must be type variables that do not yet occur anywhere in the type derivation (not just in the type judgment). Otherwise the typing may fail. In practice we use these rules to generate type equations. Thus, if we have a type judgment x : α 1,, α n T x : U we generate from it the following type equation (where β 1,, β n are fresh type variables): T [α 1 := β 1,, α 1 := β 1 ] = U Now, using the environment Pair : α, β α β Pair α β. we may successfully type Pair (Pair 1 2) 3: Γ Pair : δ Num γ Γ Pair : Num Num δ Γ 1 : Num Γ Pair 1 : Num δ Γ Pair 1 2 : δ Γ Pair (Pair 1 2) : Num γ Γ Pair (Pair 1 2) 3 : γ { } ε ϕ Pair ε ϕ = δ Num γ Γ 2 : Num Γ 3 : Num ζ η Pair ζ η = Num Num δ Solve the set of equations: { ε ϕ Pair ε ϕ = δ Num γ } ζ η Pair ζ η = Num Num δ ϕ Pair ε γ ζ η Pair ζ η = Num Num δ Pair ε ϕ = γ ζ η Pair ζ η = Num Num δ Pair ε ϕ = γ η Pair ζ η = Num δ by (37) (1st eq) by (37) (2nd eq) by (37) (4th eq) 13

14 Pair ε ϕ = γ η = Num Pair ζ η = δ Pair δ ϕ = γ η = Num Pair ζ η = δ Pair δ ϕ = γ η = Num Pair Num η = δ Pair δ ϕ = γ η = Num Pair Num Num = δ Pair δ Num = γ η = Num Pair Num Num = δ γ = Pair δ Num η = Num δ = Pair Num Num by (37) (5th eq) eliminate ε eliminate ζ eliminate η eliminate ϕ by (33) (3rd and 6th eq) 14

15 ε = Pair Num Num γ = Pair (Pair Num Num) Num η = Num δ = Pair Num Num eliminate δ The algorithm terminates and the result is a solution (most general unifier). Thus, we have the principal type of Pair (Pair 1 2) 3: it is Pair (Pair Num Num) Num Further developments The classical Hindley Milner system supports generalization of local variables. It turns out this feature is rarely used, and thus Vytiniotis, Peyton Jones, and Schrijvers (2010) argue that implicit generalization of local variables should be abandoned. I have followed their advice above. Odersky, Sulzmann, and Wehr (1999) proposed a general framework, called HM(X), for Hindley Milner style type disciplines, based on an extensible constraint system that is a generalization of the type equation approach I have discussed. The basic Hindley Milner remains a special case of this framework. A number of modern type discipline developments (many in actual use in Haskell at this time) have been formulated and reported using this framework. References Hindley, R. (1969). The Principal Type-Scheme of an Object in Combinatory Logic. In: Transactions of the American Mathematical Society 146, pp doi: / Martelli, Alberto and Ugo Montanari (1982). An Efficient Unification Algorithm. In: ACM Transactions on Programming Languages and Systems 4.2, pp doi: / Milner, Robin (1978). A Theory of Type Polymorphism in Programming. In: Journal of Computer and System Sciences 17.3, pp doi: / (78) Odersky, Martin, Martin Sulzmann, and Martin Wehr (1999). Type Inference with Constrained Types. In: Theory and Practice of Object Systems 5.1, pp doi: /(SICI) (199901/03)5:1<35::AID-TAPO4>3.0.CO;2-4. url: record/ Robinson, J. A. (1965). A Machine-Oriented Logic Based on the Resolution Principle. In: Journal of the ACM 12.1, pp doi: / Vytiniotis, Dimitrios, Simon Peyton Jones, and Tom Schrijvers (2010). Let Should Not Be Generalized. In: Proceedings of the 5th ACM SIGPLAN Workshop on Types in Language Design and Implementation, pp doi: /

Introduction to lambda calculus Part 2

Introduction to lambda calculus Part 2 Introduction to lambda calculus Part 2 Antti-Juhani Kaijanaho 2017-01-24... 1 Untyped lambda calculus 1.1 Syntax... x, y, z Var t, u Term t, u ::= x t u λx t... In this document, I will be using the following

More information

NICTA Advanced Course. Theorem Proving Principles, Techniques, Applications

NICTA Advanced Course. Theorem Proving Principles, Techniques, Applications NICTA Advanced Course Theorem Proving Principles, Techniques, Applications λ 1 CONTENT Intro & motivation, getting started with Isabelle Foundations & Principles Lambda Calculus Higher Order Logic, natural

More information

Type Inference. For the Simply-Typed Lambda Calculus. Peter Thiemann, Manuel Geffken. Albert-Ludwigs-Universität Freiburg. University of Freiburg

Type Inference. For the Simply-Typed Lambda Calculus. Peter Thiemann, Manuel Geffken. Albert-Ludwigs-Universität Freiburg. University of Freiburg Type Inference For the Simply-Typed Lambda Calculus Albert-Ludwigs-Universität Freiburg Peter Thiemann, Manuel Geffken University of Freiburg 24. Januar 2013 Outline 1 Introduction 2 Applied Lambda Calculus

More information

CSCI 490 problem set 6

CSCI 490 problem set 6 CSCI 490 problem set 6 Due Tuesday, March 1 Revision 1: compiled Tuesday 23 rd February, 2016 at 21:21 Rubric For full credit, your solutions should demonstrate a proficient understanding of the following

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

COMP6463: λ-calculus

COMP6463: λ-calculus COMP6463: λ-calculus 1. Basics Michael Norrish Michael.Norrish@nicta.com.au Canberra Research Lab., NICTA Semester 2, 2015 Outline Introduction Lambda Calculus Terms Alpha Equivalence Substitution Dynamics

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 August 28, 2003 These supplementary notes review the notion of an inductive definition and give

More information

Depending on equations

Depending on equations Depending on equations A proof-relevant framework for unification in dependent type theory Jesper Cockx DistriNet KU Leuven 3 September 2017 Unification for dependent types Unification is used for many

More information

Static Program Analysis

Static Program Analysis Static Program Analysis Xiangyu Zhang The slides are compiled from Alex Aiken s Michael D. Ernst s Sorin Lerner s A Scary Outline Type-based analysis Data-flow analysis Abstract interpretation Theorem

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

Limitations of OCAML records

Limitations of OCAML records Limitations of OCAML records The record types must be declared before they are used; a label e can belong to only one record type (otherwise fun x x.e) would have several incompatible types; we cannot

More information

3.2 Reduction 29. Truth. The constructor just forms the unit element,. Since there is no destructor, there is no reduction rule.

3.2 Reduction 29. Truth. The constructor just forms the unit element,. Since there is no destructor, there is no reduction rule. 32 Reduction 29 32 Reduction In the preceding section, we have introduced the assignment of proof terms to natural deductions If proofs are programs then we need to explain how proofs are to be executed,

More information

The Lambda Calculus. Stephen A. Edwards. Fall Columbia University

The Lambda Calculus. Stephen A. Edwards. Fall Columbia University The Lambda Calculus Stephen A. Edwards Columbia University Fall 2014 Lambda Expressions Function application written in prefix form. Add four and five is (+ 4 5) Evaluation: select a redex and evaluate

More information

Type inference in context

Type inference in context Type inference in context Adam Gundry University of Strathclyde Microsoft Research PhD Scholar Conor McBride University of Strathclyde James McKinna Radboud University Nijmegen MSFP 25 September 2010 Two

More information

Lecture Notes on Data Abstraction

Lecture Notes on Data Abstraction Lecture Notes on Data Abstraction 15-814: Types and Programming Languages Frank Pfenning Lecture 14 October 23, 2018 1 Introduction Since we have moved from the pure λ-calculus to functional programming

More information

Mathematical Logic Prof. Arindama Singh Department of Mathematics Indian Institute of Technology, Madras. Lecture - 15 Propositional Calculus (PC)

Mathematical Logic Prof. Arindama Singh Department of Mathematics Indian Institute of Technology, Madras. Lecture - 15 Propositional Calculus (PC) Mathematical Logic Prof. Arindama Singh Department of Mathematics Indian Institute of Technology, Madras Lecture - 15 Propositional Calculus (PC) So, now if you look back, you can see that there are three

More information

Extending the Lambda Calculus: An Eager Functional Language

Extending the Lambda Calculus: An Eager Functional Language Syntax of the basic constructs: Extending the Lambda Calculus: An Eager Functional Language canonical forms z cfm ::= intcfm boolcfm funcfm tuplecfm altcfm intcfm ::= 0 1-1... boolcfm ::= boolconst funcfm

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

A Machine Checked Model of Idempotent MGU Axioms For a List of Equational Constraints

A Machine Checked Model of Idempotent MGU Axioms For a List of Equational Constraints A Machine Checked Model of Idempotent MGU Axioms For a List of Equational Constraints Sunil Kothari, James Caldwell Department of Computer Science, University of Wyoming, USA Machine checked proofs of

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

Simply Typed λ-calculus

Simply Typed λ-calculus Simply Typed λ-calculus Lecture 1 Jeremy Dawson The Australian National University Semester 2, 2017 Jeremy Dawson (ANU) COMP4630,Lecture 1 Semester 2, 2017 1 / 23 A Brief History of Type Theory First developed

More information

Lecture Notes on Heyting Arithmetic

Lecture Notes on Heyting Arithmetic Lecture Notes on Heyting Arithmetic 15-317: Constructive Logic Frank Pfenning Lecture 8 September 21, 2017 1 Introduction In this lecture we discuss the data type of natural numbers. They serve as a prototype

More information

Nominal Rewriting. Maribel Fernández. ISR - June King s College London

Nominal Rewriting. Maribel Fernández. ISR - June King s College London King s College London ISR - June 2009 - Course Syllabus Introduction First-order languages Languages with binding operators Specifying binders: α-equivalence Nominal terms Nominal unification (unification

More information

An extension of HM(X) with bounded existential and universal data-types

An extension of HM(X) with bounded existential and universal data-types Groupe de travail Cristal July, 2003 An extension of HM(X) with bounded existential and universal data-types (To appear at ICFP 03) Vincent Simonet INRIA Rocquencourt Cristal project Vincent.Simonet@inria.fr

More information

Lecture Notes on Unification

Lecture Notes on Unification Lecture Notes on Unification 15-317: Constructive Logic Frank Pfenning Lecture 17 November 5, 2015 In this lecture we investigate unification further to see that the algorithm from the previous lecture

More information

Existential Label Flow Inference via CFL Reachability

Existential Label Flow Inference via CFL Reachability Existential Label Flow Inference via CFL Reachability Polyvios Pratikakis Michael Hicks Jeffrey S. Foster July, 2005 Abstract Label flow analysis is a fundamental static analysis problem with a wide variety

More information

Typing λ-terms. Types. Typed λ-terms. Base Types. The Typing Relation. Advanced Formal Methods. Lecture 3: Simply Typed Lambda calculus

Typing λ-terms. Types. Typed λ-terms. Base Types. The Typing Relation. Advanced Formal Methods. Lecture 3: Simply Typed Lambda calculus Course 2D1453, 200607 Advanced Formal Methods Lecture 3: Simply Typed Lambda calculus Mads Dam KTH/CSC Some material from B. Pierce: TAPL + some from G. Klein, NICTA Typing λterms The uptyped λcalculus

More information

On the Semantics of Parsing Actions

On the Semantics of Parsing Actions On the Semantics of Parsing Actions Hayo Thielecke School of Computer Science University of Birmingham Birmingham B15 2TT, United Kingdom Abstract Parsers, whether constructed by hand or automatically

More information

A proof of correctness for the Hindley-Milner type inference algorithm

A proof of correctness for the Hindley-Milner type inference algorithm A proof of correctness for the Hindley-Milner type inference algorithm Jeff Vaughan vaughan2@cis.upenn.edu May 5, 2005 (Revised July 23, 2008) 1 Introduction This report details a proof that the Hindley-Milner

More information

EDA045F: Program Analysis LECTURE 10: TYPES 1. Christoph Reichenbach

EDA045F: Program Analysis LECTURE 10: TYPES 1. Christoph Reichenbach EDA045F: Program Analysis LECTURE 10: TYPES 1 Christoph Reichenbach In the last lecture... Performance Counters Challenges in Dynamic Performance Analysis Taint Analysis Binary Instrumentation 2 / 44 Types

More information

Rank-2 intersection for recursive definitions

Rank-2 intersection for recursive definitions Fundamenta Informaticae XXI (2001) 1001 1044 1001 IOS Press Rank-2 intersection for recursive definitions Ferruccio Damiani Dipartimento di Informatica Università di Torino Corso Svizzera 185, I-10149

More information

Denotational semantics: proofs

Denotational semantics: proofs APPENDIX A Denotational semantics: proofs We show that every closed term M has a computable functional [[M ] as its denotation. A.1. Unification We show that for any two constructor terms one can decide

More information

Classical Program Logics: Hoare Logic, Weakest Liberal Preconditions

Classical Program Logics: Hoare Logic, Weakest Liberal Preconditions Chapter 1 Classical Program Logics: Hoare Logic, Weakest Liberal Preconditions 1.1 The IMP Language IMP is a programming language with an extensible syntax that was developed in the late 1960s. We will

More information

CSE 505, Fall 2009, Midterm Examination 5 November Please do not turn the page until everyone is ready.

CSE 505, Fall 2009, Midterm Examination 5 November Please do not turn the page until everyone is ready. CSE 505, Fall 2009, Midterm Examination 5 November 2009 Please do not turn the page until everyone is ready Rules: The exam is closed-book, closed-note, except for one side of one 85x11in piece of paper

More information

Introduction to Metalogic

Introduction to Metalogic Philosophy 135 Spring 2008 Tony Martin Introduction to Metalogic 1 The semantics of sentential logic. The language L of sentential logic. Symbols of L: Remarks: (i) sentence letters p 0, p 1, p 2,... (ii)

More information

Church and Curry: Combining Intrinsic and Extrinsic Typing

Church and Curry: Combining Intrinsic and Extrinsic Typing Church and Curry: Combining Intrinsic and Extrinsic Typing Frank Pfenning Dedicated to Peter Andrews on the occasion of his retirement Department of Computer Science Carnegie Mellon University April 5,

More information

Type Inference for Units of Measure

Type Inference for Units of Measure Type Inference for Units of Measure Research Paper Adam Gundry University of Strathclyde, Glasgow adam.gundry@cis.strath.ac.uk Abstract. Units of measure are an example of a type system extension involving

More information

Simply Typed Lambda Calculus

Simply Typed Lambda Calculus Simply Typed Lambda Calculus Mathias Vorreiter Pedersen November 13, 2015 1 Recalling the untyped lambda calculus 1.1 Syntax t ::= x λ x. t t t 1.2 Evaluation x x t t λx.t λx.t t 1 t 1 t 2 t 2 t 1 t 2

More information

Consequence Relations and Natural Deduction

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

More information

Mathematics 114L Spring 2018 D.A. Martin. Mathematical Logic

Mathematics 114L Spring 2018 D.A. Martin. Mathematical Logic Mathematics 114L Spring 2018 D.A. Martin Mathematical Logic 1 First-Order Languages. Symbols. All first-order languages we consider will have the following symbols: (i) variables v 1, v 2, v 3,... ; (ii)

More information

Modern Algebra Prof. Manindra Agrawal Department of Computer Science and Engineering Indian Institute of Technology, Kanpur

Modern Algebra Prof. Manindra Agrawal Department of Computer Science and Engineering Indian Institute of Technology, Kanpur Modern Algebra Prof. Manindra Agrawal Department of Computer Science and Engineering Indian Institute of Technology, Kanpur Lecture 02 Groups: Subgroups and homomorphism (Refer Slide Time: 00:13) We looked

More information

Review. Principles of Programming Languages. Equality. The Diamond Property. The Church-Rosser Theorem. Corollaries. CSE 230: Winter 2007

Review. Principles of Programming Languages. Equality. The Diamond Property. The Church-Rosser Theorem. Corollaries. CSE 230: Winter 2007 CSE 230: Winter 2007 Principles of Programming Languages Lecture 12: The λ-calculus Ranjit Jhala UC San Diego Review The lambda calculus is a calculus of functions: e := x λx. e e 1 e 2 Several evaluation

More information

Nunchaku: Flexible Model Finding for Higher-Order Logic

Nunchaku: Flexible Model Finding for Higher-Order Logic Nunchaku: Flexible Model Finding for Higher-Order Logic Simon Cruanes, Jasmin Blanchette, Andrew Reynolds Veridis, Inria Nancy https://cedeela.fr/~simon/ April 7th, 2016 1 / 21 Summary Introduction Nunchaku

More information

Polymorphism, Subtyping, and Type Inference in MLsub

Polymorphism, Subtyping, and Type Inference in MLsub Polymorphism, Subtyping, and Type Inference in MLsub Stephen Dolan and Alan Mycroft November 8, 2016 Computer Laboratory University of Cambridge The select function select p v d = if (p v) then v else

More information

cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska

cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska LECTURE 6 CHAPTER 2 FINITE AUTOMATA 2. Nondeterministic Finite Automata NFA 3. Finite Automata and Regular Expressions 4. Languages

More information

Notes on Inductive Sets and Induction

Notes on Inductive Sets and Induction Notes on Inductive Sets and Induction Finite Automata Theory and Formal Languages TMV027/DIT21 Ana Bove, March 15th 2018 Contents 1 Induction over the Natural Numbers 2 1.1 Mathematical (Simple) Induction........................

More information

Type Inference Algorithms

Type Inference Algorithms Type Inference Algorithms February 19, 2009 S. Saeidi Mobarakeh ( 0559938 ) Abstract In this paper we are going to describe the Wand s type inference algorithm and we ll try to extend this algorithm with

More information

Interoperation for Lazy and Eager Evaluation

Interoperation for Lazy and Eager Evaluation Interoperation for Lazy and Eager Evaluation 1 Matthews & Findler New method of interoperation Type safety, observational equivalence & transparency Eager evaluation strategies Lazy vs. eager 2 Lambda

More information

Programming Languages and Types

Programming Languages and Types Programming Languages and Types Klaus Ostermann based on slides by Benjamin C. Pierce Subtyping Motivation With our usual typing rule for applications the term is not well typed. ` t 1 : T 11!T 12 ` t

More information

INF3170 / INF4171 Notes on Resolution

INF3170 / INF4171 Notes on Resolution INF3170 / INF4171 Notes on Resolution Andreas Nakkerud Autumn 2015 1 Introduction This is a short description of the Resolution calculus for propositional logic, and for first order logic. We will only

More information

Normalization by Evaluation

Normalization by Evaluation Normalization by Evaluation Andreas Abel Department of Computer Science and Engineering Chalmers and Gothenburg University PhD Seminar in Mathematical Engineering EAFIT University, Medellin, Colombia 9

More information

Simply Typed Lambda Calculus

Simply Typed Lambda Calculus Simply Typed Lambda Calculus Language (ver1) Lambda calculus with boolean values t ::= x variable x : T.t abstraction tt application true false boolean values if ttt conditional expression Values v ::=

More information

Review of The π-calculus: A Theory of Mobile Processes

Review of The π-calculus: A Theory of Mobile Processes Review of The π-calculus: A Theory of Mobile Processes Riccardo Pucella Department of Computer Science Cornell University July 8, 2001 Introduction With the rise of computer networks in the past decades,

More information

Elementary Linear Algebra, Second Edition, by Spence, Insel, and Friedberg. ISBN Pearson Education, Inc., Upper Saddle River, NJ.

Elementary Linear Algebra, Second Edition, by Spence, Insel, and Friedberg. ISBN Pearson Education, Inc., Upper Saddle River, NJ. 2008 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. APPENDIX: Mathematical Proof There are many mathematical statements whose truth is not obvious. For example, the French mathematician

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 17 Tuesday, April 2, 2013 1 There is a strong connection between types in programming languages and propositions

More information

Lecture Notes on The Curry-Howard Isomorphism

Lecture Notes on The Curry-Howard Isomorphism Lecture Notes on The Curry-Howard Isomorphism 15-312: Foundations of Programming Languages Frank Pfenning Lecture 27 ecember 4, 2003 In this lecture we explore an interesting connection between logic and

More information

A Type-Coercion Problem in Computer Algebra

A Type-Coercion Problem in Computer Algebra Lecture Notes in Computer Science 737, pages 188 194 A Type-Coercion Problem in Computer Algebra Andreas Weber Wilhelm-Schickard-Institut Universität Tübingen W-7400 Tübingen, Germany hweber@informatik.uni-tuebingen.dei

More information

Every formula evaluates to either \true" or \false." To say that the value of (x = y) is true is to say that the value of the term x is the same as th

Every formula evaluates to either \true or \false. To say that the value of (x = y) is true is to say that the value of the term x is the same as th A Quick and Dirty Sketch of a Toy Logic J Strother Moore January 9, 2001 Abstract For the purposes of this paper, a \logic" consists of a syntax, a set of axioms and some rules of inference. We dene a

More information

Proving Completeness for Nested Sequent Calculi 1

Proving Completeness for Nested Sequent Calculi 1 Proving Completeness for Nested Sequent Calculi 1 Melvin Fitting abstract. Proving the completeness of classical propositional logic by using maximal consistent sets is perhaps the most common method there

More information

First-Order Logic. Chapter Overview Syntax

First-Order Logic. Chapter Overview Syntax Chapter 10 First-Order Logic 10.1 Overview First-Order Logic is the calculus one usually has in mind when using the word logic. It is expressive enough for all of mathematics, except for those concepts

More information

Write your own Theorem Prover

Write your own Theorem Prover Write your own Theorem Prover Phil Scott 27 October 2016 Phil Scott Write your own Theorem Prover 27 October 2016 1 / 31 Introduction We ll work through a toy LCF style theorem prover for classical propositional

More information

3 The Semantics of the Propositional Calculus

3 The Semantics of the Propositional Calculus 3 The Semantics of the Propositional Calculus 1. Interpretations Formulas of the propositional calculus express statement forms. In chapter two, we gave informal descriptions of the meanings of the logical

More information

A Principled approach to Ornamentation in ML

A Principled approach to Ornamentation in ML 0 0 A Principled approach to Ornamentation in ML THOMAS WILLIAMS, Inria DIDIER RÉMY, Inria Ornaments are a way to describe changes in datatype definitions reorganizing, adding, or dropping some pieces

More information

Induction on Failing Derivations

Induction on Failing Derivations Induction on Failing Derivations Technical Report PL-Sep13 September 2013, with addenda from Spring 2016 ay Ligatti Department of Computer Science and Engineering University of South Florida Abstract A

More information

Theory of Computation (IX) Yijia Chen Fudan University

Theory of Computation (IX) Yijia Chen Fudan University Theory of Computation (IX) Yijia Chen Fudan University Review The Definition of Algorithm Polynomials and their roots A polynomial is a sum of terms, where each term is a product of certain variables and

More information

CMSC 336: Type Systems for Programming Languages Lecture 10: Polymorphism Acar & Ahmed 19 February 2008

CMSC 336: Type Systems for Programming Languages Lecture 10: Polymorphism Acar & Ahmed 19 February 2008 CMSC 336: Type Systems for Programming Languages Lecture 10: Polymorphism Acar & Ahmed 19 February 2008 Contents 1 Polymorphism 1 2 Polymorphic λ-calculus: Syntax 1 3 Static Semantics 2 4 Dynamic Semantics

More information

Reasoning with Higher-Order Abstract Syntax and Contexts: A Comparison

Reasoning with Higher-Order Abstract Syntax and Contexts: A Comparison 1 Reasoning with Higher-Order Abstract Syntax and Contexts: A Comparison Amy Felty University of Ottawa July 13, 2010 Joint work with Brigitte Pientka, McGill University 2 Comparing Systems We focus on

More information

Taming Selective Strictness

Taming Selective Strictness Taming Selective Strictness Daniel Seidel and Janis Voigtländer Technische Universität Dresden, 01062 Dresden, Germany {seideld,voigt}@tcs.inf.tu-dresden.de Abstract: Free theorems establish interesting

More information

The λ-calculus and Curry s Paradox Drew McDermott , revised

The λ-calculus and Curry s Paradox Drew McDermott , revised The λ-calculus and Curry s Paradox Drew McDermott drew.mcdermott@yale.edu 2015-09-23, revised 2015-10-24 The λ-calculus was invented by Alonzo Church, building on earlier work by Gottlob Frege and Moses

More information

7 RC Simulates RA. Lemma: For every RA expression E(A 1... A k ) there exists a DRC formula F with F V (F ) = {A 1,..., A k } and

7 RC Simulates RA. Lemma: For every RA expression E(A 1... A k ) there exists a DRC formula F with F V (F ) = {A 1,..., A k } and 7 RC Simulates RA. We now show that DRC (and hence TRC) is at least as expressive as RA. That is, given an RA expression E that mentions at most C, there is an equivalent DRC expression E that mentions

More information

Safety Analysis versus Type Inference

Safety Analysis versus Type Inference Information and Computation, 118(1):128 141, 1995. Safety Analysis versus Type Inference Jens Palsberg palsberg@daimi.aau.dk Michael I. Schwartzbach mis@daimi.aau.dk Computer Science Department, Aarhus

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

Models of computation

Models of computation Lambda-Calculus (I) jean-jacques.levy@inria.fr 2nd Asian-Pacific Summer School on Formal ethods Tsinghua University, August 23, 2010 Plan computation models lambda-notation bound variables odels of computation

More information

Meta-Circularity, and Vice-Versa

Meta-Circularity, and Vice-Versa 1/60, and Vice-Versa didier@lrde.epita.fr http://www.lrde.epita.fr/ didier ACCU 2011 Thursday, April 14th 2/60 Table of contents 1 2 Symbolic Expressions 3 The of LISP 4 5 6 7 8 Dynamic 9 4/60 circularity

More information

17.1 Correctness of First-Order Tableaux

17.1 Correctness of First-Order Tableaux Applied Logic Lecture 17: Correctness and Completeness of First-Order Tableaux CS 4860 Spring 2009 Tuesday, March 24, 2009 Now that we have introduced a proof calculus for first-order logic we have to

More information

185.A09 Advanced Mathematical Logic

185.A09 Advanced Mathematical Logic 185.A09 Advanced Mathematical Logic www.volny.cz/behounek/logic/teaching/mathlog13 Libor Běhounek, behounek@cs.cas.cz Lecture #1, October 15, 2013 Organizational matters Study materials will be posted

More information

Minimally Strict Polymorphic Functions

Minimally Strict Polymorphic Functions Minimally Strict Polymorphic Functions Jan Christiansen Christian-Albrechts-Universität Kiel Institut für Informatik 24098 Kiel, Germany jac@informatik.uni-kiel.de Daniel Seidel Rheinische Friedrich-Wilhelms-Universität

More information

Parametric Polymorphism and Operational Improvement

Parametric Polymorphism and Operational Improvement Parametric Polymorphism and Operational Improvement JENNIFER HACKETT, University of Nottingham, UK GRAHAM HUTTON, University of Nottingham, UK Parametricity, in both operational and denotational forms,

More information

Programming Languages

Programming Languages CSE 230: Winter 2010 Principles of Programming Languages Lecture 10: Programming in λ-calculusc l l Ranjit Jhala UC San Diego Review The lambda calculus is a calculus of functions: e := x λx. e e 1 e 2

More information

cis32-ai lecture # 18 mon-3-apr-2006

cis32-ai lecture # 18 mon-3-apr-2006 cis32-ai lecture # 18 mon-3-apr-2006 today s topics: propositional logic cis32-spring2006-sklar-lec18 1 Introduction Weak (search-based) problem-solving does not scale to real problems. To succeed, problem

More information

Relating Nominal and Higher-Order Pattern Unification

Relating Nominal and Higher-Order Pattern Unification Relating Nominal and Higher-Order Pattern Unification James Cheney University of Edinburgh UNIF 2005 April 22, 2005 1 Motivation Higher-order unification: studied since ca. 1970 Undecidable, infinitary,

More information

Lecture 10: Gentzen Systems to Refinement Logic CS 4860 Spring 2009 Thursday, February 19, 2009

Lecture 10: Gentzen Systems to Refinement Logic CS 4860 Spring 2009 Thursday, February 19, 2009 Applied Logic Lecture 10: Gentzen Systems to Refinement Logic CS 4860 Spring 2009 Thursday, February 19, 2009 Last Tuesday we have looked into Gentzen systems as an alternative proof calculus, which focuses

More information

Automated Reasoning Lecture 5: First-Order Logic

Automated Reasoning Lecture 5: First-Order Logic Automated Reasoning Lecture 5: First-Order Logic Jacques Fleuriot jdf@inf.ac.uk Recap Over the last three lectures, we have looked at: Propositional logic, semantics and proof systems Doing propositional

More information

One Year Later. Iliano Cervesato. ITT Industries, NRL Washington, DC. MSR 3.0:

One Year Later. Iliano Cervesato. ITT Industries, NRL Washington, DC.  MSR 3.0: MSR 3.0: The Logical Meeting Point of Multiset Rewriting and Process Algebra MSR 3: Iliano Cervesato iliano@itd.nrl.navy.mil One Year Later ITT Industries, inc @ NRL Washington, DC http://www.cs.stanford.edu/~iliano

More information

Prefixed Tableaus and Nested Sequents

Prefixed Tableaus and Nested Sequents Prefixed Tableaus and Nested Sequents Melvin Fitting Dept. Mathematics and Computer Science Lehman College (CUNY), 250 Bedford Park Boulevard West Bronx, NY 10468-1589 e-mail: melvin.fitting@lehman.cuny.edu

More information

Denotational semantics

Denotational semantics Denotational semantics Semantics and Application to Program Verification Antoine Miné École normale supérieure, Paris year 2015 2016 Course 4 4 March 2016 Course 4 Denotational semantics Antoine Miné p.

More information

Propositions and Proofs

Propositions and Proofs Chapter 2 Propositions and Proofs The goal of this chapter is to develop the two principal notions of logic, namely propositions and proofs There is no universal agreement about the proper foundations

More information

First-Order Theorem Proving and Vampire

First-Order Theorem Proving and Vampire First-Order Theorem Proving and Vampire Laura Kovács 1,2 and Martin Suda 2 1 TU Wien 2 Chalmers Outline Introduction First-Order Logic and TPTP Inference Systems Saturation Algorithms Redundancy Elimination

More information

Program verification. Hoare triples. Assertional semantics (cont) Example: Semantics of assignment. Assertional semantics of a program

Program verification. Hoare triples. Assertional semantics (cont) Example: Semantics of assignment. Assertional semantics of a program Program verification Assertional semantics of a program Meaning of a program: relation between its inputs and outputs; specified by input assertions (pre-conditions) and output assertions (post-conditions)

More information

Element x is R-minimal in X if y X. R(y, x).

Element x is R-minimal in X if y X. R(y, x). CMSC 22100/32100: Programming Languages Final Exam M. Blume December 11, 2008 1. (Well-founded sets and induction principles) (a) State the mathematical induction principle and justify it informally. 1

More information

Type Systems Winter Semester 2006

Type Systems Winter Semester 2006 Type Systems Winter Semester 2006 Week 7 November 29 November 29, 2006 - version 1.0 Plan PREVIOUSLY: 1. type safety as progress and preservation 2. typed arithmetic expressions 3. simply typed lambda

More information

3 Propositional Logic

3 Propositional Logic 3 Propositional Logic 3.1 Syntax 3.2 Semantics 3.3 Equivalence and Normal Forms 3.4 Proof Procedures 3.5 Properties Propositional Logic (25th October 2007) 1 3.1 Syntax Definition 3.0 An alphabet Σ consists

More information

THE UNIVERSITY OF CALGARY FACULTY OF SCIENCE FINAL EXAMINATION COMPUTER SCIENCE 521

THE UNIVERSITY OF CALGARY FACULTY OF SCIENCE FINAL EXAMINATION COMPUTER SCIENCE 521 P. 1 of 7 THE UNIVERSITY OF CALGARY FACULTY OF SCIENCE FINAL EXAMINATION COMPUTER SCIENCE 521 December, 2014 Time: 2 hrs. Instructions The exam contains questions totaling 100 points. Answer all questions.

More information

Computational Soundness of a Call by Name Calculus of Recursively-scoped Records. UMM Working Papers Series, Volume 2, Num. 3.

Computational Soundness of a Call by Name Calculus of Recursively-scoped Records. UMM Working Papers Series, Volume 2, Num. 3. Computational Soundness of a Call by Name Calculus of Recursively-scoped Records. UMM Working Papers Series, Volume 2, Num. 3. Elena Machkasova Contents 1 Introduction and Related Work 1 1.1 Introduction..............................

More information

A call-by-name lambda-calculus machine

A call-by-name lambda-calculus machine A call-by-name lambda-calculus machine Jean-Louis Krivine University Paris VII, C.N.R.S. 2 place Jussieu 75251 Paris cedex 05 (krivine@pps.jussieu.fr) Introduction We present, in this paper, a particularly

More information

On the Correctness of the Krivine Machine

On the Correctness of the Krivine Machine On the Correctness of the Krivine Machine Mitchell Wand Northeastern University 2003-10-03 15:55:00 wand October 3, 2003 Abstract We provide a short proof of the correctness of the Krivine machine by showing

More information

Predicate Logic. Xinyu Feng 09/26/2011. University of Science and Technology of China (USTC)

Predicate Logic. Xinyu Feng 09/26/2011. University of Science and Technology of China (USTC) University of Science and Technology of China (USTC) 09/26/2011 Overview Predicate logic over integer expressions: a language of logical assertions, for example x. x + 0 = x Why discuss predicate logic?

More information

Lambda-Calculus (I) 2nd Asian-Pacific Summer School on Formal Methods Tsinghua University, August 23, 2010

Lambda-Calculus (I) 2nd Asian-Pacific Summer School on Formal Methods Tsinghua University, August 23, 2010 Lambda-Calculus (I) jean-jacques.levy@inria.fr 2nd Asian-Pacific Summer School on Formal Methods Tsinghua University, August 23, 2010 Plan computation models lambda-notation bound variables conversion

More information

Programming Languages Fall 2013

Programming Languages Fall 2013 Programming Languages Fall 2013 Lecture 11: Subtyping Prof Liang Huang huang@qccscunyedu Big Picture Part I: Fundamentals Functional Programming and Basic Haskell Proof by Induction and Structural Induction

More information

An Introduction to Logical Relations Proving Program Properties Using Logical Relations

An Introduction to Logical Relations Proving Program Properties Using Logical Relations An Introduction to Logical Relations Proving Program Properties Using Logical Relations Lau Skorstengaard lask@cs.au.dk July 27, 2018 Contents 1 Introduction 2 1.1 Simply Typed Lambda Calculus....................

More information