Introduction to lambda calculus Part 2
|
|
- Alfred Rice
- 6 years ago
- Views:
Transcription
1 Introduction to lambda calculus Part 2 Antti-Juhani Kaijanaho 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 concrete phrase-structure syntax for the pure lambda calculus: <term> ::= <term1> λ <variables>. <term> <term1> ::= <term2> <term1> <term2> <term2> ::= <variable> ( <term> ) <variables> ::= <variable> <variables> <variable> As to the lexical syntax, in this document variables are single letters possibly with subscripts or primes added (so x, x 1, and x are distinct variables); all Minor changes made afterward. Last changed :15:48+02:00. 1
2 other lexemes are λ, the period (which I usually write on the centerline, not at the bottom of the line), and the parentheses Denotational semantics E: Term (Var D) D E x σ = σ ( x ) (1) E tu σ = E t σ (E u σ) (2) E λx t σ = f, where f : D D (3) f(z) = E t (σ[x := z]) 1.3 Basic conversions The trouble with the denotational semantics of lambda calculus is that while it specifies what kind of objects lambda calculus term denote, it does not give us any clue as to how to manipulate them and compute with them. In fact, while the lambda calculus was always intended to describe mathematical functions, the original description of it was based on mechanical calculation rules, called conversions (in Finnish muunnos), and calculating with lambdas is still based on them. Informally specified, the two most important conversions are (Barendregt 1984; Church 1985): 1 α conversion It is permissible to change the name of the function parameter in an abstraction, so long as all references to the parameter inside the abstraction are similarly changed. β reduction It is permissible to perform a function call, that is, to replace any term of the form (λx t)u with a version of t where each reference to the function parameter x is replaced by the argument u. In formulas, we write the use of α conversion or β reduction as α or β, respectively. The reverse direction of β reduction is called β expansion (sometimes also β abstraction), and when the direction is not important, we may talk of β conversion. 2 1 Note that these informal descriptions leave out important qualifications and limitations, as discussed below. Precise definitions of these conversions will be given later. 2 In Finnish, reduction is sievennys and expansion is lavennus. 2
3 The claim is that both rules preserve the term s denotation and may therefore be used to simplify terms to be more easily understood. Example 4 Let us compute (λxy x) a b, which is the same as ((λx (λy x)) a) b: ((λx (λy x)) a) b β (λy a) b β a To see that this is correct, let us compute the denotation of the original term: E ((λx (λy x)) a) b σ = E (λx (λy x)) a σ(e b σ) by 2 = (E (λx (λy x)) σ(e a σ))(e b σ) by 2 = (E (λx (λy x)) σ(σ a ))(σ b ) by 1 = (f(σ a ))(σ b ) where f : D D f(z) = E λy x (σ[x := z]) by 3 = (E λy x (σ[x := σ a ])) (σ b ) call f = f(σ b ) where f : D D = f(σ b ) where f : D D = f(σ b ) where f : D D f(z) = E x ((σ[x := σ a ]) [y := z]) f(z) = ((σ[x := σ a ]) [y := z]) x f(z) = σ a by 3 by 1 simplify = σ a call f Then let us compute the denotation of the resulting term: E a σ = σ a by 1 They are, indeed, identical. Exercise 2 Show that λx x and λy y denote the same function. There are subtleties in these conversion rules, however. Let us first look at an example: 3
4 Example 5 Let us compute ((λx (λy x)) y) z: But is this correct? Let us compute: E ((λx (λy x)) y) z σ ((λx (λy x)) y) z β (λy y) z β z = E (λx (λy x)) y σ(e z σ) by 2 = E (λx (λy x)) y σ(σ z ) by 1 = (E λx (λy x) σ(e y σ))(σ z ) by 2 = (E λx (λy x) σ(σ y ))(σ z ) by 1 = (f(σ y ))(σ z ), where f : D D f(z) = E λy x (σ[x := z]) by 3 = (E λy x (σ[x := σ y ]))(σ z ) call f = f(σ z ), where f : D D = f(σ z ), where f : D D f(z) = E x (σ[x := σ y ][y := z]) f(z) = σ y by 3 by 1 = σ y call f But the result of our conversion denotes trivially σ z ; since σ may assign different values for y and z, these are not equivalent results. Clearly the conversion is incorrect. What is happening in the above example is called variable capture (in Finnish muuttujankaappaus). The same issue exists in ordinary programming languages; consider the following Java fragment: class A { public int a ; public int foo ( ) { return a ; } } class B { public A oa ; public int a ; public int bar ( ) { 4
5 return oa. foo ( ) ; } } public class Capture { public static void main ( S t r i n g [ ] args ) { B ob = new B ( ) ; ob. oa = new A( ) ; ob. a = 2 ; ob. oa. a = 4 ; System. out. p r i n t l n (ob. bar ( ) ) ; } } How is the call from B.bar to A.foo performed? A naive idea is to just copy the text of A.foo in place of the call: Thus, return oa.foo(); becomes return a;. Thus, the program would print 2. But let us try it in Java: ajk@kukkaistutus:~/opetus/okp-2017/matksut$ javac Capture.java ajk@kukkaistutus:~/opetus/okp-2017/matksut$ java Capture 4 Java does not do the call naively, instead it knows that the a in B.bar is a different a than in A.foo. 3 Getting back to lambda calculus, we can avoid variable capture by applying α conversion to rename a parameter variable whenever capture would otherwise result. Example 6 Let us compute ((λx (λy x)) y) z: The result is correct. ((λx (λy x)) y) z α ((λx (λy x)) y) z β (λy y) z β y We need somehow to correct the β reduction rule so that it disallows variable capture and forces the computor 4 to apply the α conversion where 3 We say that Java implements lexical scoping or static scoping (in Finnish leksikaalinen / staattinen näkyvyysalue). The naive method of just replacing the call with the text of the callee (with parameters substituted as appropriate) results in what is called dynamic scoping (in Finnish dynaaminen näkyvyysalue); it is rarely seen outside Lisp, where it has some popularity. 4 I use the word computor to refer to a human or machine who computes using formal rules. Thus, a computor may be a computer, but it is not always the case. 5
6 necessary. One key insight is that capture happens in a situation like this: (λx... (λy... x...))(... y...) In other words, the parameter variable occurs inside an abstraction that names its parameter the same as some variable that occurs in the argument term. But there is a complication: there is no variable capture in (λx... (λy... x...))(... (λy... y...)...) so long as y does not occur in the argument outside the inner abstraction. 1.4 Free variables Somehow, therefore, there is a distinction between variable occurrences that are inside an abstraction naming that variable and other occurrences. This distinction is conventionally made by talking about variable binding (in Finnish muuttujan sidonta), bound (in Finnish sidottu) occurrences of a variable, and free (in Finnish vapaa) occurrences of a variable. Informally we may state that an abstraction binds its parameter variable; all occurrences of that variable inside that abstraction are bound, while an occurrence of a variable that is not bound is a free occurrence. Further, a variable that has at least one free occurrence in a term is called a free variable of that term. Formally, it is customary to define a function F V : Term P (Var) that gives for each term a set of its free variables. We may define it for the pure untyped lambda calculus as follows: F V : Term P (Var) F V x = { x } (4) F V tu = F V t F V u (5) F V λx t = F V t \ { x } (6) Example 7 Let us compute the set of free variables of ((λx (λy x)) y) z: F V ((λx (λy x)) y) z = F V (λx (λy x)) y F V z by 5 = (F V λx (λy x) F V y ) F V z by 5 = ((F V λy x \ { x }) F V y ) F V z by 6 = (((F V x \ { y }) \ { x }) F V y ) F V z by 6 = ((({ x } \ { y }) \ { x }) { y }) { z } by 4 = (({ x } \ { x }) { y }) { z } simplify 6
7 = ( { y }) { z } simplify = { y } { z } simplify = { y, z } simplify Exercise 3 Extend the definition of F V to the untyped lambda calculus extended with nonnegative integer constants, additions, and multiplications. 5 It is possible to prove (but we will not prove) the following theorem: Theorem 1 The value of a variable that is not a free variable of a term has no effect on the denotation of that term. In other words, for all terms t, variables x, environments σ, and values v D: x F V t E t σ = E t (σ[x := v]) 1.5 Variable substitution and conversions formally To avoid variable capture, we should define precisely what it means to replace all references to a variable with some term. The key insight is that all (and only the) references to a variable bound by an abstraction are free occurrences of that variable in the body of the abstraction. 6 Further, the only thing that can prevent an occurrence from being free is that there is some binding of that variable between the abstraction and the occurrence on the path connecting them in the AST. Thus, we will replace a variable recursively until another binding for it is found. However, that is not enough. A variable y is captured if and only if we replace another variable x with a term that contains y as a free variable inside an abstraction that binds y. Thus, we must forbid such a replacement. Formally, we may now define variable substitution (in Finnish muuttujan korvaus). There are multiple traditional notations for this operation, but I will adopt here t[x := u] for the subsitution of u for x in t. 7 Although this is a meta-level operation, it is usually written without semantic brackets as if it were an object language operation, with higher precedence than both application and abstraction. Thus we define (supposing that x and y are different variables): x[x := u] = u (7) y[x := u] = x (8) 5 See 6 We call the t of an abstraction λx t its body (in Finnish runko). 7 Other notations seen in the literature for the same substitution include t[u/x] and S x ut. 7
8 (t 1 t 2 )[x := u] = t 1 [x := u] t 2 [x := u] (9) (λx t)[x := u] = λx t (10) (λy t)[x := u] = λy t[x := u] if y F V u (11) Note that variable substitution is not always defined. In practice, this just means that we need to perform α conversion in an appropriate subterm. 8 Now we are in position to define formally what α conversion and β reduction are: λx t α λy t[x := y] (12) (λx t)u β t[x := u] (13) Further, the following rules apply equally to both α conversion and β reduction. Let v {α, β}: x v x (14) tu v t u if t v t (15) tu v tu if u v u (16) λx t v λx t if t v t (17) In other words, both α conversion and β reduction may be employed in any subterm of a term. Example 8 With this formal definition of variable substitution and beta reduction, it is revealed why the computation in Example 5 is fallacious. To perform the β reduction (λx (λy x)) y? β λy y, one must compute (λy x)[x := y] but this cannot be done, because the side condition of (11), that is y F V y, is trivially false, and no other equation defining substitution is applicable. It is possible to prove (but we will not prove) the following theorems: Theorem 2 For any terms t and u and any environment σ, the following two formulas hold: t α u = E t σ = E u σ (18) t β u = E t σ = E u σ (19) 8 A term u is a subterm of a term t if the AST of u is a subtree of the AST of t. 8
9 1.6 Normal forms and evaluation orders The goal of computing using α conversions and β-reductions is to reach a (β) normal form (in Finnish (β-)normaalimuoto): a term on which no more β reductions can be performed even after any number of α conversions. After defining a (β) redex (in Finnish (β-)redeksi) as a term of the form (λx t)u that is, an application whose left subterm is an abstraction it is a fairly simple thing to prove the following theorem: Theorem 3 A term is in β normal form if and only if it contains no subterm that is a β redex. A far more complex but also more interesting result was proven by Church and Rosser (1936). This result and its analogues is usually called Church Rosser or CR, and it is said that a formal system possessing a similar theorem is Church Rosser. Before I can state this theorem, I must define two new notations: I will write t β u (and say that t β-reduces to u) as an abbreviation for the statement that there is a sequence of α conversions and β reductions leading from t to u; and I will write t = α u (and say that t and u are α-equivalent) as an abbreviation for the statement that there is a sequence of α conversions leading from t to u. In both cases a sequence may be empty, so t β t and t = α t are both vacuously true. Theorem 4 (Church Rosser) Let t be a term and u 1 and u 2 be terms in β normal form. If t β u 1 and t β u 2, then u 1 = α u 2. In other words, if a term has a β normal form (that is, there is at least one sequence of α conversions and β reductions from that term to a β normal form), then that β normal form is unique (up to α equivalence). There are two important qualifications. First, some sequences of α conversions and β reductions can be extended indefinitely without reaching a β normal form. Second, there are terms that have no β normal form. Example 9 Let us consider the term (λx xx)(λx xx). It is not in β normal form since it contains a β redex. But the only possible β reduction on it makes no changes to that term, and α conversions never remove β redexes from a term. Thus, this term cannot have a β normal form. Example 10 Let us consider the term (λx y)((λx xx)(λx xx)). This term has two β redexes: the whole term itself and the subterm that was considered 9
10 above. We can choose which redex to apply β reduction to. If we choose the former, we reach a β normal form immediately: (λx y)((λx xx)(λx xx)) β y But if we choose the latter, the term is not changed, and we have to make the choice again. If we stubbornly always choose the latter, we will never learn the β normal form. There are two important reduction strategies, that is, systematic rules for choosing which β redex to apply β reduction to. Normal order reduction always chooses the leftmost of those β redexes that are not subterms of any other β-redex. Applicative order reduction always chooses the leftmost of those β redexes that have no other β redexes as subterm. It is sometimes said that the normal order (in Finnish normaalijärjestys) chooses the leftmost outermost redex, while the applicative order (in Finnish applikatiivinen järjestys) chooses the leftmost innermost redex. The following theorem can be proven: Theorem 5 If a term has a β normal form, then a normal order reduction will eventually find it. No such theorem is true of the applicative order, as Example 10 showed. Exercise 4 Let us make the following shorthard definitions: IF = (λx x) TRUE = (λxy x) FALSE = (λxy y) Now determine the β normal forms of the following terms. 1. IF TRUE a b 2. IF FALSE a b Exercise 5 It is possible to encode nonnegative integers in pure untyped lambda calculus using what are known as Church encodings. In this system, we model a nonnegative integer n as a function of two parameters f and x that returns f(f(f... (fx)...)) 10
11 where the number of times f is repeated is n. Thus 0 (λfx x) 1 (λfx fx) 2 (λfx f(fx)) We can further define add (λnmfx.nf(mfx)) Using these definitions, show that one plus one is indeed two. 1.7 Important variations If we delete rule (17) from β reduction, we end up with weak β reduction. The corresponding normal form concept is weak normal form; a term is in weak normal form if and only if the only β redexes it contains are subterms of abstractions. In essence, we decline to reduce inside abstractions. The call semantics of mainstream programming languages like C and Java is best modeled using weak β reduction using the applicative order. This corresponds roughly to how these languages treat function and method calls. If we delete rule (16) from β reduction, we end up with head β reduction. The corresponding normal form concept is head normal form; a term is in head normal form if and only if the only β redexes it contains are in argument positions (that is, inside the second subterm of an argument). In essence, we decline to reduce function arguments. If we delete both rules from β reduction, we end up with weak head β reduction. The corresponding normal form concept is weak head normal form or WHNF ; a term is in weak head normal form if it is of the form tu 1... u n for some n {0, 1, 2... }, and t is not an abstraction if n 1 and in any case not an application. This is a particularly important concept as it is the semantics of function evaluation in Haskell (so long as one ignores evaluation efficiency): expressions are reduced to WHNF, at which point the computation is considered finished. 9 All these variations can be further modified by introducing graph reduction (in Finnish verkonsievennys), invented by Wadsworth (1971). The idea 9 It is often said that Haskell uses the normal order, but that is misleading. In weak head reduction, there is never a question of which redex to reduce, as there can be only one candidate. 11
12 is to regard the original term as an AST, and when, in the process of reduction, a variable occurrence is substituted by a term, instead of making a copy of the term we simply move all edges leading to the variable occurrence to lead instead to the root vertex of the substitute term. The result is often that the term no longer is a tree but a graph; and the graph itself may contain loops. This is the essence of lazy evaluation as it occurs in Haskell; Haskell s model is essentially weak head graph reduction. 10 References Barendregt, H. P. (1984). The Lambda Calculus. Its Syntax and Semantics. Revised. Studies in logic and the foundation of mathematics 103. Amsterdam: Elsevier. Church, Alonzo (1985). The Calculi of Lambda Conversion. Princeton University Press. Church, Alonzo and J. B. Rosser (1936). Some properties of conversion. In: Transactions of the American Mathematical Society 39, pp doi: /S Wadsworth, Christopher Peter (1971). Semantics and Pragmatics of the Lambda Calculus. PhD thesis. Oxford University. 10 For a more extensive tutorial on graph reduction, see ~antkaij/opetus/okp/2010/luennot/laziness.pdf. 12
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 informationThe 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 informationIntroduction to lambda calculus Part 6
Introduction to lambda calculus Part 6 Antti-Juhani Kaijanaho 2017-02-16 1 Untyped lambda calculus 2 Typed lambda calculi 2.1 Dynamically typed lambda calculus with integers 2.2 A model of Lisp 2.3 Simply
More informationLambda-Calculus (cont): Fixpoints, Naming. Lecture 10 CS 565 2/10/08
Lambda-Calculus (cont): Fixpoints, Naming Lecture 10 CS 565 2/10/08 Recursion and Divergence Consider the application: Ω ((λ x. (x x)) (λ x. (x x))) Ω evaluates to itself in one step. It has no normal
More informationModels 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 informationType Systems. Lecture 2 Oct. 27th, 2004 Sebastian Maneth.
Type Systems Lecture 2 Oct. 27th, 2004 Sebastian Maneth http://lampwww.epfl.ch/teaching/typesystems/2004 Today 1. What is the Lambda Calculus? 2. Its Syntax and Semantics 3. Church Booleans and Church
More informationType Systems. Today. 1. What is the Lambda Calculus. 1. What is the Lambda Calculus. Lecture 2 Oct. 27th, 2004 Sebastian Maneth
Today 1. What is the Lambda Calculus? Type Systems 2. Its Syntax and Semantics 3. Church Booleans and Church Numerals 4. Lazy vs. Eager Evaluation (call-by-name vs. call-by-value) Lecture 2 Oct. 27th,
More information3.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 informationProgramming 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 informationThe λ-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λ Slide 1 Content Exercises from last time λ-calculus COMP 4161 NICTA Advanced Course Advanced Topics in Software Verification
Content COMP 4161 NICTA Advanced Course Advanced Topics in Software Verification Toby Murray, June Andronick, Gerwin Klein λ Slide 1 Intro & motivation, getting started [1] Foundations & Principles Lambda
More informationReview. 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 informationPredicate Logic. x. x + 0 = x. Predicate logic over integer expressions: a language of logical assertions, for example. Why discuss predicate logic?
Predicate Logic Predicate logic over integer expressions: a language of logical assertions, for example x. x + 0 = x Why discuss predicate logic? It is an example of a simple language It has simple denotational
More informationConsequence 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 informationLambda-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 informationMathematical Foundations of Programming. Nicolai Kraus. Draft of February 15, 2018
Very short lecture notes: Mathematical Foundations of Programming University of Nottingham, Computer Science, module code G54FOP, Spring 2018 Nicolai Kraus Draft of February 15, 2018 What is this? This
More informationModels of Computation,
Models of Computation, 2010 1 The Lambda Calculus A brief history of mathematical notation. Our notation for numbers was introduced in the Western World in the Renaissance (around 1200) by people like
More informationNon-Idempotent Typing Operators, beyond the λ-calculus
Non-Idempotent Typing Operators, beyond the λ-calculus Soutenance de thèse Pierre VIAL IRIF (Univ. Paris Diderot and CNRS) December 7, 2017 Non-idempotent typing operators P. Vial 0 1 /46 Certification
More informationLambda Calculus! Gunnar Gotshalks! LC-1
Lambda Calculus! LC-1 λ Calculus History! Developed by Alonzo Church during mid 1930 s! One fundamental goal was to describe what can be computed.! Full definition of λ-calculus is equivalent in power
More informationPredicate 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 informationPredicate Logic. Xinyu Feng 11/20/2013. University of Science and Technology of China (USTC)
University of Science and Technology of China (USTC) 11/20/2013 Overview Predicate logic over integer expressions: a language of logical assertions, for example x. x + 0 = x Why discuss predicate logic?
More informationLambda Calculus. Andrés Sicard-Ramírez. Semester Universidad EAFIT
Lambda Calculus Andrés Sicard-Ramírez Universidad EAFIT Semester 2010-2 Bibliography Textbook: Hindley, J. R. and Seldin, J. (2008). Lambda-Calculus and Combinators. An Introduction. Cambridge University
More informationCS 4110 Programming Languages & Logics. Lecture 16 Programming in the λ-calculus
CS 4110 Programming Languages & Logics Lecture 16 Programming in the λ-calculus 30 September 2016 Review: Church Booleans 2 We can encode TRUE, FALSE, and IF, as: TRUE λx. λy. x FALSE λx. λy. y IF λb.
More informationStatic 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 informationLazy Strong Normalization
Lazy Strong Normalization Luca Paolini 1,2 Dipartimento di Informatica Università di Torino (ITALIA) Elaine Pimentel 1,2 Departamento de Matemática Universidade Federal de Minas Gerais (BRASIL) Dipartimento
More information3 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 informationCSE 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 informationFunctional Database Query Languages as. Typed Lambda Calculi of Fixed Order. Gerd G. Hillebrand and Paris C. Kanellakis
Functional Database Query Languages as Typed Lambda Calculi of Fixed Order Gerd G. Hillebrand and Paris C. Kanellakis Department of Computer Science Brown University Providence, Rhode Island 02912 CS-94-26
More informationConsequence 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 informationPart 2: First-Order Logic
Part 2: First-Order Logic First-order logic formalizes fundamental mathematical concepts is expressive (Turing-complete) is not too expressive (e. g. not axiomatizable: natural numbers, uncountable sets)
More informationTyping λ-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 informationBeyond First-Order Logic
Beyond First-Order Logic Software Formal Verification Maria João Frade Departmento de Informática Universidade do Minho 2008/2009 Maria João Frade (DI-UM) Beyond First-Order Logic MFES 2008/09 1 / 37 FOL
More informationPropositional Logic: Syntax
Logic Logic is a tool for formalizing reasoning. There are lots of different logics: probabilistic logic: for reasoning about probability temporal logic: for reasoning about time (and programs) epistemic
More informationChapter 1. Logic and Proof
Chapter 1. Logic and Proof 1.1 Remark: A little over 100 years ago, it was found that some mathematical proofs contained paradoxes, and these paradoxes could be used to prove statements that were known
More informationExamples: P: it is not the case that P. P Q: P or Q P Q: P implies Q (if P then Q) Typical formula:
Logic: The Big Picture Logic is a tool for formalizing reasoning. There are lots of different logics: probabilistic logic: for reasoning about probability temporal logic: for reasoning about time (and
More informationPropositional logic (revision) & semantic entailment. p. 1/34
Propositional logic (revision) & semantic entailment p. 1/34 Reading The background reading for propositional logic is Chapter 1 of Huth/Ryan. (This will cover approximately the first three lectures.)
More informationEDA045F: 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 informationCharles Wells 1. February 25, 1999
NOTES ON THE λ-calculus Charles Wells 1 February 25, 1999 Department of Mathematics Case Western Reserve University 10900 Euclid Ave. Cleveland, OH 44106-7058 USA charles@freude.com http://www.cwru.edu/artsci/math/wells/home.html
More informationTutorial on Semantics Part I
Tutorial on Semantics Part I Basic Concepts Prakash Panangaden 1 1 School of Computer Science McGill University on sabbatical leave at Department of Computer Science Oxford University Fields Institute,
More informationLecture 3. Lambda calculus. Iztok Savnik, FAMNIT. October, 2015.
Lecture 3 Lambda calculus Iztok Savnik, FAMNIT October, 2015. 1 Literature Henk Barendregt, Erik Barendsen, Introduction to Lambda Calculus, March 2000. Lambda calculus Leibniz had as ideal the following
More information1. Object Calculus. Object calculus is to OO languages what lambda calculus is to functional languages
1. Object Calculus In this section we will introduce a calculus of objects that gives a simple but powerful mathematical model to study object based languages. Object calculus is to OO languages what lambda
More information3. The λ-calculus and Implication
3. The λ-calculus and Implication (a) (b) (c) (d) (e) (f) The untyped λ-calculus. The typed λ-calculus. The λ-calculus in Agda. Logic with Implication Implicational Logic in Agda. More on the typed λ-calculus.
More informationSharing in the weak lambda-calculus (2)
Sharing in the weak lambda-calculus (2) Jean-Jacques Lévy INRIA Joint work with Tomasz Blanc and Luc aranget Happy birthday Henk! Happy birthday Henk! Happy birthday Henk! History Sharing in the lambda-calculus
More informationHenk Barendregt and Freek Wiedijk assisted by Andrew Polonsky. Radboud University Nijmegen. March 5, 2012
1 λ Henk Barendregt and Freek Wiedijk assisted by Andrew Polonsky Radboud University Nijmegen March 5, 2012 2 reading Femke van Raamsdonk Logical Verification Course Notes Herman Geuvers Introduction to
More informationHoare Logic: Reasoning About Imperative Programs
Hoare Logic: Reasoning About Imperative Programs COMP1600 / COMP6260 Dirk Pattinson Australian National University Semester 2, 2018 Programming Paradigms Functional. (Haskell, SML, OCaml,... ) main paradigm:
More informationLocal computation of β-reduction A concrete presentation of Game Semantics
1 2 3 4 Local computation of β-reduction A concrete presentation of Game Semantics William Blum and C.H. Luke Ong Oxford University Computing Laboratory 5 6 Abstract We show that... Key words: Lambda calculus,
More informationFormal Methods Lecture 6. (B. Pierce's slides for the book Types and Programming Languages )
Formal Methods Lecture 6 (B. Pierce's slides for the book Types and Programming Languages ) This Saturday, 10 November 2018, room 335 (FSEGA), we will recover the following activities: 1 Formal Methods
More informationLecture 2. Lambda calculus. Iztok Savnik, FAMNIT. March, 2018.
Lecture 2 Lambda calculus Iztok Savnik, FAMNIT March, 2018. 1 Literature Henk Barendregt, Erik Barendsen, Introduction to Lambda Calculus, March 2000. Lambda calculus Leibniz had as ideal the following
More informationTraditional and Non Traditional lambda calculi
Strategies July 2009 Strategies Syntax Semantics Manipulating Expressions Variables and substitutions Free and bound variables Subterms and substitution Grafting and substitution Ordered list of variables
More informationTyped Arithmetic Expressions
Typed Arithmetic Expressions CS 550 Programming Languages Jeremy Johnson TAPL Chapters 3 and 5 1 Types and Safety Evaluation rules provide operational semantics for programming languages. The rules provide
More informationImplementing -Reduction by. Hypergraph Rewriting. Sabine Kuske 1. Fachbereich Mathematik und Informatik. Universitat Bremen. D{28334 Bremen, Germany
URL: http://www.elsevier.nl/locate/entcs/volume2.html 8 pages Implementing -Reduction by Hypergraph Rewriting abine Fachbereich Mathematik und Informatik Universitat Bremen D{28334 Bremen, Germany email:
More informationSimply 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 informationThe Greek Alphabet. (a) The Untyped λ-calculus
3. The λ-calculus and Implication Greek Letters (a) The untyped λ-calculus. (b) The typed λ-calculus. (c) The λ-calculus in Agda. (d) Logic with Implication (e) Implicational Logic in Agda. (f) More on
More informationLogic. Propositional Logic: Syntax
Logic Propositional Logic: Syntax Logic is a tool for formalizing reasoning. There are lots of different logics: probabilistic logic: for reasoning about probability temporal logic: for reasoning about
More informationTyped Lambda Calculi. Nikos Tzeveλekos Queen Mary, University of London 1 / 23
Typed Lambda Calculi Nikos Tzeveλekos Queen Mary, University of London 1 / 23 What is the Lambda Calculus A minimal formalism expressing computation with functionals s ::= x λx.s ss All you need is lambda.
More informationAxiomatic Semantics. Stansifer Ch 2.4, Ch. 9 Winskel Ch.6 Slonneger and Kurtz Ch. 11 CSE
Axiomatic Semantics Stansifer Ch 2.4, Ch. 9 Winskel Ch.6 Slonneger and Kurtz Ch. 11 CSE 6341 1 Outline Introduction What are axiomatic semantics? First-order logic & assertions about states Results (triples)
More informationIntroduction 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 information3.2 Equivalence, Evaluation and Reduction Strategies
3.2 Equivalence, Evaluation and Reduction Strategies The λ-calculus can be seen as an equational theory. More precisely, we have rules i.e., α and reductions, for proving that two terms are intensionally
More informationEquivalent Computers. Lecture 39: Lambda Calculus. Lambda Calculus. What is Calculus? Real Definition. Why?
#,, - Lecture 39: Lambda Calculus Equivalent Computers z z z... term = variable term term (term) λ variable. term λy. M α λv. (M [y α v]) where v does not occur in M. (λx. M)N β M [ x α N ] Turing Machine
More informationPredicate Logic: Syntax
Predicate Logic: Syntax Alice Gao Lecture 12 Based on work by J. Buss, L. Kari, A. Lubiw, B. Bonakdarpour, D. Maftuleac, C. Roberts, R. Trefler, and P. Van Beek 1/31 Outline Syntax of Predicate Logic Learning
More informationSimply 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 informationOn the Correctness and Efficiency of the Krivine Machine
On the Correctness and Efficiency of the Krivine Machine Mitchell Wand Northeastern University Daniel P. Friedman Indiana University February 12, 2003 Abstract We provide a short derivation of the Krivine
More informationThe Lambda-Calculus Reduction System
2 The Lambda-Calculus Reduction System 2.1 Reduction Systems In this section we present basic notions on reduction systems. For a more detailed study see [Klop, 1992, Dershowitz and Jouannaud, 1990]. Definition
More informationChiastic Lambda-Calculi
Chiastic Lambda-Calculi wren ng thornton Cognitive Science & Computational Linguistics Indiana University, Bloomington NLCS, 28 June 2013 wren ng thornton (Indiana University) Chiastic Lambda-Calculi NLCS,
More informationProgramming Language Concepts, CS2104 Lecture 3
Programming Language Concepts, CS2104 Lecture 3 Statements, Kernel Language, Abstract Machine 31 Aug 2007 CS2104, Lecture 3 1 Reminder of last lecture Programming language definition: syntax, semantics
More informationLambda Calculus. Syntax. i ::= a b c d e... etc L ::= i i L L L ( L ) A Few Examples. x x y a x a (b a) c d (c e (d e)) (x (x x)) (y (y a))
Syntax Lambda Calculus A Few Examples i ::= a b c d e... etc L ::= i i L L L ( L ) x x y a x a (b a) c d (c e (d e)) (x (x x)) (y (y a)) Semantics With Examples α β Anywhere that something of the form
More informationIntroduction to Turing Machines
Introduction to Turing Machines Deepak D Souza Department of Computer Science and Automation Indian Institute of Science, Bangalore. 12 November 2015 Outline 1 Turing Machines 2 Formal definitions 3 Computability
More informationThe lambda calculus with constructors
The lambda calculus with constructors Categorical semantic and Continuations Barbara Petit Focus - Univ. Bologna CaCos 2012 Barbara Petit (Focus - Univ. Bologna) The lambda calculus with constructors 1
More informationFormal Methods Lecture 6. (B. Pierce's slides for the book Types and Programming Languages )
Formal Methods Lecture 6 (B. Pierce's slides for the book Types and Programming Languages ) Programming in the Lambda-Calculus, Continued Testing booleans Recall: tru = λt. λf. t fls = λt. λf. f We showed
More informationIntroduction to λ-calculus
p.1/65 Introduction to λ-calculus Ken-etsu FUJITA fujita@cs.gunma-u.ac.jp http://www.comp.cs.gunma-u.ac.jp/ fujita/ Department of Computer Science Gunma University :Church 32, 36, 40; Curry 34 1. Universal
More informationIntroduction to Turing Machines. Reading: Chapters 8 & 9
Introduction to Turing Machines Reading: Chapters 8 & 9 1 Turing Machines (TM) Generalize the class of CFLs: Recursively Enumerable Languages Recursive Languages Context-Free Languages Regular Languages
More informationSHARING IN THE WEAK LAMBDA-CALCULUS REVISITED
SHARING IN THE WEAK LAMBDA-CALCULUS REVISITED TOMASZ BLANC, JEAN-JACQUES LÉVY, AND LUC MARANGET INRIA e-mail address: tomasz.blanc@inria.fr INRIA, Microsoft Research-INRIA Joint Centre e-mail address:
More information3. Only sequences that were formed by using finitely many applications of rules 1 and 2, are propositional formulas.
1 Chapter 1 Propositional Logic Mathematical logic studies correct thinking, correct deductions of statements from other statements. Let us make it more precise. A fundamental property of a statement is
More informationCSC 7101: Programming Language Structures 1. Axiomatic Semantics. Stansifer Ch 2.4, Ch. 9 Winskel Ch.6 Slonneger and Kurtz Ch. 11.
Axiomatic Semantics Stansifer Ch 2.4, Ch. 9 Winskel Ch.6 Slonneger and Kurtz Ch. 11 1 Overview We ll develop proof rules, such as: { I b } S { I } { I } while b do S end { I b } That allow us to verify
More informationFunctional Programming with Coq. Yuxin Deng East China Normal University
Functional Programming with Coq Yuxin Deng East China Normal University http://basics.sjtu.edu.cn/ yuxin/ September 10, 2017 Functional Programming Y. Deng@ECNU 1 Reading materials 1. The Coq proof assistant.
More informationNormalization 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 informationProgramming Language Concepts: Lecture 18
Programming Language Concepts: Lecture 18 Madhavan Mukund Chennai Mathematical Institute madhavan@cmi.ac.in http://www.cmi.ac.in/~madhavan/courses/pl2009 PLC 2009, Lecture 18, 30 March 2009 One step reduction
More informationAdvanced Lambda Calculus Lecture 5
Advanced Lambda Calculus Lecture 5 The fathers Alonzo Church (1903-1995) as mathematics student at Princeton University (1922 or 1924) Haskell B. Curry (1900-1982) as BA in mathematics at Harvard (1920)
More informationUniform Schemata for Proof Rules
Uniform Schemata for Proof Rules Ulrich Berger and Tie Hou Department of omputer Science, Swansea University, UK {u.berger,cshou}@swansea.ac.uk Abstract. Motivated by the desire to facilitate the implementation
More informationLecture Notes on Compositional Reasoning
15-414: Bug Catching: Automated Program Verification Lecture Notes on Compositional Reasoning Matt Fredrikson Ruben Martins Carnegie Mellon University Lecture 4 1 Introduction This lecture will focus on
More information2 Results I: Lifting Computer Science
Ben Greenman December 12, 2015 Call-By-Name, Call-By-Value, and the λ Calculus Abstract Plotkin s 1975 paper is strictly business. There are many theorems packed in the space of 35 pages, with little room
More informationNICTA 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 informationEXTENDED ABSTRACT. 2;4 fax: , 3;5 fax: Abstract
1 Syntactic denitions of undened: EXTENDED ABSTRACT on dening the undened Zena Ariola 1, Richard Kennaway 2, Jan Willem Klop 3, Ronan Sleep 4 and Fer-Jan de Vries 5 1 Computer and Information Science Department,
More informationOperational Semantics
Operational Semantics Semantics and applications to verification Xavier Rival École Normale Supérieure Xavier Rival Operational Semantics 1 / 50 Program of this first lecture Operational semantics Mathematical
More informationStaged Notational Definitions
Staged Notational Definitions Walid Taha 1 and Patricia Johann 2 1 Department of Computer Science, Rice University, taha@cs.rice.edu 2 Department of Computer Science, Rutgers University, pjohann@crab.rutgers.edu
More informationAdvanced Lambda Calculus. Henk Barendregt & Giulio Manzonetto ICIS Faculty of Science Radboud University Nijmegen, The Netherlands
Advanced Lambda Calculus Henk Barendregt & Giulio Manzonetto ICIS Faculty of Science Radboud University Nijmegen, The Netherlands Form of the course Ordinary lecture Seminar form Exam: working out an exercise
More informationContext Free Grammars
Automata and Formal Languages Context Free Grammars Sipser pages 101-111 Lecture 11 Tim Sheard 1 Formal Languages 1. Context free languages provide a convenient notation for recursive description of languages.
More informationPropositional Logic Arguments (5A) Young W. Lim 11/8/16
Propositional Logic (5A) Young W. Lim Copyright (c) 2016 Young W. Lim. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version
More informationChurch s undecidability result
Church s undecidability result Alan Turing Birth Centennial Talk at IIT Bombay, Mumbai Joachim Breitner April 21, 2011 Welcome, and thank you for the invitation to speak about Church s lambda calculus
More informationTaylor and Maclaurin Series. Copyright Cengage Learning. All rights reserved.
11.10 Taylor and Maclaurin Series Copyright Cengage Learning. All rights reserved. We start by supposing that f is any function that can be represented by a power series f(x)= c 0 +c 1 (x a)+c 2 (x a)
More informationEvery 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 informationLectures on The Lambda Calculus (I)
Lectures on The Lambda Calculus (I) Masahiko Sato Graduate School of Informatics, Kyoto University Autumn school Proof and Computation Fischbachau, Germany October 4, 2016 Overview In these lectures, I
More informationA 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 informationPropositional and Predicate Logic. jean/gbooks/logic.html
CMSC 630 February 10, 2009 1 Propositional and Predicate Logic Sources J. Gallier. Logic for Computer Science, John Wiley and Sons, Hoboken NJ, 1986. 2003 revised edition available on line at http://www.cis.upenn.edu/
More informationAutomated 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 informationA Little Deductive Logic
A Little Deductive Logic In propositional or sentential deductive logic, we begin by specifying that we will use capital letters (like A, B, C, D, and so on) to stand in for sentences, and we assume that
More informationA Stochastic l-calculus
A Stochastic l-calculus Content Areas: probabilistic reasoning, knowledge representation, causality Tracking Number: 775 Abstract There is an increasing interest within the research community in the design
More informationOrigin in Mathematical Logic
Lambda Calculus Origin in Mathematical Logic Foundation of mathematics was very much an issue in the early decades of 20th century. Cantor, Frege, Russel s Paradox, Principia Mathematica, NBG/ZF Origin
More informationLogic. Propositional Logic: Syntax. Wffs
Logic Propositional Logic: Syntax Logic is a tool for formalizing reasoning. There are lots of different logics: probabilistic logic: for reasoning about probability temporal logic: for reasoning about
More informationProof Techniques (Review of Math 271)
Chapter 2 Proof Techniques (Review of Math 271) 2.1 Overview This chapter reviews proof techniques that were probably introduced in Math 271 and that may also have been used in a different way in Phil
More information