CBV and CBN. Eduardo Bonelli. TP para LP 2012C1 1/55
|
|
- Lillian McCormick
- 6 years ago
- Views:
Transcription
1 CBV and CBN Eduardo Bonelli TP para LP 2012C1 1/55
2 Reduction Strategies Call-By-Value Call-by-Name Relating CBN and CBV λ-calculus Continuation Passing Style Bibliography 2/55
3 Reduction Strategies Reduction in λ-calculus is non-deterministic A term may have more than one redex Reduction-as-computation requires fixing a reduction strategy Criterion for selecting a redex Example strategies Call-by-value (CBV) Call-by-name (CBN) Call-by-need 3/55
4 Origins of CBV/CBN Plotkin [Plo75] introduced CBV/CBN in an effort to study correct program equivalences Programming language theory Calculus: determines notions of equality between expressions Computation (abstract machine/operational semantics): determines how programs are executed Computational soundness (of the calculus): expressions identified by the calculus behave the same computationally Plotkin departed from an abstract machine (Peter Landin s ISWIM [Lan64] 1 and proposed a calculus (the CBV lambda calculus) that is computationally sound for the SECD abstract machine (which implements ISWIM). 1 If You See What I Mean 4/55
5 Origins of CBV/CBN Programming language theory Calculus: determines notions of equality between expressions Usually specified in terms of equations or rewrite rules Computation (abstract machine/operational semantics): determines how programs are executed Usually specified via small-step operational semantics Abstract machines are instance Computational soundness (of the calculus): expressions identified by the calculus behave the same computationally behave the same computationally usually taken to be Morris-style contextual equivalence We ll take a closer look at CBV lambda calculus Note: We work in an untyped setting 5/55
6 Computation - The SECD Machine 2 Due to Peter Landin [Lan64] Carries out CBV evaluation of closed λ-terms Simple enough that its basic instructions can be easily implemented Machine configuration (Stack,Environment,Code,Dump) Dynamics described in terms of transitions over configurations All transitions are at the root which is characteristic of abstract machine reduction 2 We follow presentation of [Gun93] 6/55
7 The SECD Machine Machine Configuration Machine configuration (Stack,Environment,Code,Dump) Code: List of instructions (instruction is λ-term or constant ap) Environment: partial function that assigns closures to identifiers Closure: pair (M, E) where M is a λ-term; and E is an environment that is defined on all free identifiers of M Stack: stack of closures Dump: empty or (S, E, C, D ) Initial mach. config. for M closed (denoted Load(M)): Final mach. config-: (nil,, M, empty) (Cl :: S, E, nil, empty) 7/55
8 The SECD Machine Transitions for CBV pure lambda calculus M ::= x M M λx.m (Cl :: S, E, nil, (S, E, C, D )) (Cl :: S, E, C, D ) (S, E, x :: C, D) (E(x) :: S, E, C, D) (S, E, (λx.m) :: C, D) ((λx.m, E) :: S, E, C, D) ((λx.m, E ) :: Cl :: S, E, ap :: C, D) (nil, E [x Cl], M, (S, E, C, D)) (S, E, (M N) :: C, D) (S, E, N :: M :: ap :: C, D) 8/55
9 The SECD Machine Transitions Extension to defined constants (applicative style) M ::= zero succ x M M λx.m (S, E, n :: C, D) ((n, ) :: S, E, C, D) (S, E, succ :: C, D) ((succ, ) :: S, E, C, D) ((succ, E 1 ) :: (n, E 2 ) :: S, E, ap :: C, D) ((n + 1, ) :: S, E, C, D) 9/55
10 The SECD Machine Transitions Example nil (λx. mul x ((λy.dbl y) 5)) 3 empty 10/55
11 The SECD Machine Environments Required for Static Scoping Let M be the λ-term: let x = 5 in let f = λy. (add x y) in let x = 3 in f x nil M empty 11/55
12 Other abstract machines SMC [Plo81] CEK [FF86] Cardelli AM (CAM) Chemical AM (CHAM) Krivine AM (KAM) [Kri07] Zinc (Xavier Leroy) Survey: [DHS00] 12/55
13 Computation - Big-Step Semantics Switching from closures to substitution Higher-level description Yields what is presently called big-step semantics Notation: a value (V ) is an abstraction λx.m V λx.m M V λx.m N V N M {x := N } V P M N V P Note: M V N implies N is unique and is a value 13/55
14 Computation - Equivalence with SECD Machine Eval V (M) def = V iff Load(M) reduces to a final configuration that has (V, E ) as topmost closure in the stack, for some E eval V (M) def = V iff M V V for some V λx.m V λx.m M V λx.m N V N M {x := N } V P Theorem Eval V (M) = α eval V (M). M N V P 14/55
15 Calculus Reasoning about Computation The λ V -calculus Since the calculus deals with equality of program fragments we extend values with variables: V ::= λx.m x λ V -calculus: The reflexive, symmetric, transitive closure of (λx.p) V. = P{x := V } M =. N C any λ-context Cong C[M] =. C[N] λ V -equality: We write λv M =. N if the judgement M =. N is derivable in λ V λ V -reduction: λ V -equality without symmetry and denoted λv β V 15/55
16 Contextual equivalence In what sense is λv M. = N true with regards to program computation? Contextual equivalence: M V N iff for every context C s.t. C[M] and C[N] are closed, eval V (C[M]) and eval V (C[N]) are either both undefined or else both defined. Note that M and N are program fragments Two phrases of a programming language are contextually equivalent if any occurrences of the first phrase in a complete program can be replaced by the second phrase without affecting the observable results of executing the program (Andrew Pitts, notes) 16/55
17 Contextual equivalence Contextual equivalence: M V N iff for every context C s.t. C[M] and C[N] are closed, eval V (C[M]) and eval V (C[N]) are either both undefined or else both defined. Examples: Note that requiring that both closed terms evaluate to the same value is too simplistic Take 2 and succ 1 as Church Numerals as an example 2 V succ 1 (λx.p) V V P{x := V } 1 V 2 17/55
18 Contextual equivalence Coinductive techinques for contextual equivalence See slides of the course Fundamentos de concurrencia y movilidad Available here 18/55
19 Computational soundness - Proof idea Corollary (Cor.2.1(1) in [Plo75]) For any closed term M: V s.t. λv M =. V iff eval V (M) defined Theorem (Computational soundness) λv M =. N implies M V N Proof: 1. Take any C s.t. C[M] and C[N] closed 2. Suppose eval V (C[M]) defined and equal to V 3. Then λv C[N] =. C[M] =. V 4. Then by the above cor., eval V (C[N]) is defined 19/55
20 Computational soundness - Proof idea Corollary (Cor.2.1(1) in [Plo75]) For any closed term M: V s.t. λv M. = V iff eval V (M) defined Proof relies on a number of results: 1. CR( λv ) 2. Standardization of λv 3. Fact that a standard reduction to a value consists of head steps ( λ h V ) 4. M λ h V V iff eval V (M) defined (for closed M and value V ) 20/55
21 λ h V CBV reduction (as a computation rule) is the following system: (λx.p) V V h P{x := V } β V M V h M µ M N V h M N N V h N V N V h V N ν V Pick leftmost redex, not under a constructor λ is a constructor Thus, no reduction under λ Would be considered code optimization rather than computation We speak of weak reduction 21/55
22 λ h V Examples Examples: 1. (λx.x x) (I I ) V h (λx.x x) I V h I I V h I 2. λx.i I is in normal form 3. x (I I ) V h x I 4. x I (I I ) is in normal form 5. x I is in normal form 6. Ω V h Ω V h Ω V h... 22/55
23 Failure of Computational Completeness Example: ω = λx.x x ω y = λx.(x x) y ω ω V ω y ω y (trivially). λv ω ω = ω y ω y Example: λx.x (λy.x y) V ω. λv λx.x (λy.x y) = ω 23/55
24 Reduction Strategies Call-By-Value Call-by-Name Relating CBN and CBV λ-calculus Continuation Passing Style Bibliography 24/55
25 Computation - Big-Step Semantics Notation: a value (V ) is an abstraction. λx.m N λx.m M N λx.m M {x := N} N P Note: M N N P M N N implies N is unique and is a value eval N (M) def = V iff M N V for some V 25/55
26 Calculus Reasoning about Computation The λ N -calculus Since the calculus deals with equality of program fragments we extend values with variables: V ::= λx.m x λ N -calculus: The reflexive, symmetric, transitive closure of (λx.p) Q. = P{x := Q} M =. N C any λ-context Cong C[M] =. C[N] λ N -equality: We write λn M =. N if the judgement M =. N is derivable in λ N λ N -reduction: λ N -equality without symmetry and denoted λn β N 26/55
27 Contextual equivalence In what sense is λn M. = N true with regards to program computation? Contextual equivalence: M N N iff for every context C s.t. C[M] and C[N] are closed, eval N (C[M]) and eval N (C[N]) are either both undefined or else both defined. Note that M and N are program fragments Theorem (Computational soundness) λn M. = N implies M N N 27/55
28 CBN λ h N -calculus Values V ::= λx.m Reduction (λx.p) Q N h P{x := Q} β N h M N h M µ M N N h M N 28/55
29 CBN λ-calculus - Sample reduction sequence 1. (λx.x x) (I I ) N (I I ) (I I ) N I (I I ) N I I N I 2. λx.i I is in normal form 3. x (I I ) is in normal form 4. (λx.i ) Ω N I 5. Ω N Ω N Ω N... 29/55
30 Reduction Strategies Call-By-Value Call-by-Name Relating CBN and CBV λ-calculus Continuation Passing Style Bibliography 30/55
31 Reduction Strategies Call-By-Value Call-by-Name Relating CBN and CBV λ-calculus Continuation Passing Style Bibliography 31/55
32 Relating CBN and CBV λ-calculus Reduction in the CBN λ-calculus can be simulated in the CBV λ-calculus and viceversa Essentially they differ in how they deal with arguments CBV in CBN: must force eval. of arguments CBN in CBV: freeze arguments into values Can be achieved in two ways Using continuations [Plo75] Using thunks [HD97] We develop the first 32/55
33 Introduction fact 4 = 4 * (fact 3) = 4 * (3 * (fact 2)) = 4 * (3 * (2 * (fact 1))) = 4 * (3 * (2 * (1 * (fact 0)))) = 4 * (3 * (2 * (1 * 1))) = 4 * (3 * (2 * 1)) = 4 * (3 * 2) = 4 * 6 = 24 Control context increments with each call This context may be seen as a continuation of the computation: it is left pending for the recursive call to return 33/55
34 Introduction In CPS programming style continuations become first class citizens (just like data) a function never returns: it passes its result to its continuation can achieve fast, iterative behaviour any function can be converted to CPS Example - Factorial in CPS fact 0 c = c 1 fact (n+1) c = fact n (\x-> c ((n+1)*x)) 34/55
35 Introduction prod [] = 1 prod (x:xs) = x * prod xs Fast prod in CPS prod [3,2,0,7] = 3 * prod [2,0,7] = 3 * (2 * prod [0,7]) = 3 * (2 * (0 * prod[7])) = 3 * (2 * (0 * (7 * prod[]))) = 3 * (2 * (0 * (7 * 1))) = 3 * (2 * (0 * 7)) = 3 * (2 * 0) = 3 * 0 = 0 fastprod [] c = c 1 fastprod (x:xs) c = if x==0 then 0 else fastprod xs (\y -> c (x*y)) 35/55
36 Example - Simple Interpreter in CPS type Cont = Int -> Int eval1 :: Exp -> Env String Int -> Cont -> Int eval1 (LitExp n) env c = c n eval1 (VarExp id) env c = c (lookupenv env id) eval1 (DobleExp e1) env c = eval1 e1 env (\x -> c (2*x)) eval1 (DivExp e1 e2) env c = eval1 e1 env (\x -> eval1 e2 env (\y -> c (x div y))) eval1 (IfExp testexp trueexp falseexp) env c = eval1 testexp env (\x -> if istruevalue x then eval1 trueexp env c else eval1 falseexp env c) eval1 (LetExp id e1 body) env c = eval1 e1 env (\v -> eval1 body (extendenv id v env) c) eval1 (AbortExp e) env c = eval1 e env (\x -> x) 36/55
37 Example Simple Interpreter in CPS data Exp =... Try e1 e2 Raise eval2 :: Exp -> Env String Int -> Cont -> Cont -> Int eval2 (LitExp n) env c cerr = c n eval2 (VarExp id) env c cerr = c (lookupenv env id)... eval2 (AbortExp e) env c cerr = eval2 e env (\x -> x) cerr eval2 (TryExp a b) env c cerr = eval2 b env c (\x -> eval2 a env c cerr) eval2 (RaiseExp) env c cerr = cerr (-1) 37/55
38 Example Simple Interpreter in CPS data Exp =... TryR e RaiseR e eval3 :: Exp -> Env String Int -> Cont -> Cont -> Int eval3 (LitExp n) env c ctry = c n eval3 (VarExp id) env c ctry = c (lookupenv env id)... eval3 (AbortExp e) env c ctry = eval3 e env (\x -> x) ctry eval3 (TryRExp a) env c ctry = eval3 a env c c eval3 (RaiseRExp a) env c ctry = eval3 a env ctry ctry 38/55
39 Relating CBN and CBV CBN and CBV are equivalent in a precise sense We introduce two translations due to Plotkin [Plo75] 1. CBN CPS transform [ ] NinV Evaluation of terms in CBN, can be correctly simulated in CBV 2. CBV CPS transform [ ] VinN Evaluation of terms in CBV, can be correctly simulated in CBN Notation: e 1 e 2 for meta-language expressions e 1, e 2 means either both are undefined or else both are defined and denote α-equivalent terms 39/55
40 Simulating CBN in CBV - Plotkin s CBN CPS transformation [ ] NinV : T λ T λ [x] NinV = λk.x k [λx.m] NinV = λk.k (λx.[m] NinV ) [M N] NinV = λk.[m] NinV (λv.v [N] NinV k) An abstraction is already a value, so just pass it on to topmost continuation (k) In an application M N first compute M, then pass-on the result (as v) to the continuation (λv.v [N] NinV k), then apply x to [N]NinV (note [N] NinV is a value), then pass final result to topmost continuation (k) 40/55
41 Simulating β N in CBV (λx.m) N N M{x := N} (λk 1.[λx.M] NinV (λv.v [N] NinV k 1 )) k V [λx.m] NinV (λv.v [N] NinV k) = (λk 2.k 2 (λx.[m] NinV )) (λv.v [N] NinV k) V (λv.v [N] NinV k) (λx.[m] NinV ) V (λx.[m] NinV ) [N] NinV k [M] NinV {x := [N] NinV } k V Does [ ] NinV commute with substitution? I.e. [M{x := N}] NinV k = [M] NinV {x := [N] NinV } k? No (e.g. take M = x and N = y) However, [M] NinV {x := [N] NinV } k V [M{x := N}] NinV k 41/55
42 Theorem - Simulation of CBN in CBV For all closed terms M T λ, where Note: [eval N (M)] NVal I V eval V ([M] NinV I ) [ ] NVal : Values N T λ [λx.m] NVal = λx.[m] NinV I plays role of topmost continuation 42/55
43 CPS Terms and Indifference CPS terms: set of terms in the range of [ ] NinV, closed under β reduction CBN and CBV coincide on CPS terms (Indifference) CPS terms are tail-recursive: no argument is an application. Therefore there is at most one redex which is not inside the scope of an abstraction and thus CBV evaluation coincides with outermost or CBN evaluation [MW85] [ ] NinV : T λ T λ [x] NinV = λk.x k [λx.m] NinV = λk.k (λx.[m] NinV ) [M N] NinV = λk.[m] NinV (λv.v [N] NinV k) 43/55
44 Theorem - Indifference For all closed terms M T λ, eval N ([M] NinV I ) eval V ([M] NinV I ) I plays role of topmost continuation 44/55
45 Simulating CBV in CBN - Plotkin s CBV CPS transformation [ ] VinN : T λ T λ [x] VinN = λk.k x [λx.m] VinN = λk.k (λx.[m] VinN ) [M N] VinN = λk.[m] VinN (λv.[n] VinN (λw.v w k)) Variables and abstractions are values, so just pass them on to topmost continuation (k) In an application M N first compute M (call the result v), then compute N (call the result w), then apply v to w, then pass final result to topmost continuation (k) 45/55
46 Notational Variation [ ] VinN : T λ T λ [x] VinN = λk.k x [λx.m] VinN = λk.k (λx.[m] VinN ) [M N] VinN = λk.[m] VinN (λv.[n] VinN (λw.v w k)) Notationally more convenient [ ] VinN : T λ T λ [V ] VinN = λk.k [V ] VVal [M N] VinN = λk.[m] VinN (λv.[n] VinN (λw.v w k)) [ ] VVal : Values V T λ [x] VVal = x [λx.m] VVal = λx.[m] VinN 46/55
47 Simulating β V in CBN (λx.m) V V M{x := V } (λk 1.[λx.M] VinN (λv.[v ] VinN (λw.v w k 1 ))) k N [λx.m] VinN (λv.[v ] VinN (λw.v w k)) = (λk 2.k 2 (λx.[m] VinN )) (λv.[v ] VinN (λw.v w k)) N (λv.[v ] VinN (λw.v w k)) (λx.[m] VinN ) N [V ] VinN (λw.(λx.[m] VinN ) w k) = (λh.h [V ] VVal ) (λw.(λx.[m] VinN ) w k) N (λw.(λx.[m] VinN ) w k) [V ] VVal N (λx.[m] VinN ) [V ] VVal k N [M] VinN {x := [V ] VVal } k = [M{x := V }] VinN k All but last step regarded as administrative: does not correspond to reduction of source terms 47/55
48 Theorem - Simulation of CBV in CBN For all closed terms M T λ : [eval V (M) I ] VVal eval N ([M] VinN I ) Note: I plays role of topmost continuation, as before 48/55
49 Theorem - Indifference CPS terms: set of terms which is in the range of [ ] VinN, closed under β reduction CBN and CBV coincide on CPS terms (Indifference) For all closed terms M T λ eval N ([M] VinN I ) eval V ([M] VinN I ) 49/55
50 Further Reading History behind discovery of continuations: [Rey93] Applications of continuations: [Fri88, FS99] Introduction to continuations and CPS: [FWH01] In-depth analysis of CPS: [DF92] 50/55
51 Reduction Strategies Call-By-Value Call-by-Name Relating CBN and CBV λ-calculus Continuation Passing Style Bibliography 51/55
52 Bibliography I Olivier Danvy and Andrzej Filinski. Representing control: A study of the cps transformation. MSCS, 2: , Stephan Diehl, Pieter H. Hartel, and Peter Sestoft. Abstract machines for programming language implementation. Future Generation Comp. Syst., 16(7): , M. Felleisen and D. P. Friedman. Control operators, the secd machine, and the λ-calculus. Formal Description of Programming Concepts III, Daniel Friedman. Applications of continuations. Invited Tutorial to POPL 88, Available from /55
53 Bibliography II Matthias Felleisen and Amr Sabry. Continuations in programming practice: Introduction and survey. Available from Daniel P. Friedman, Mitchell Wand, and Christopher T. Haynes. Essentials of Programming Languages. MIT Press, Carl A. Gunter. Semantics of programming languages - structures and techniques. Foundations of computing. MIT Press, /55
54 Bibliography III John Hatcliff and Olivier Danvy. Thunks and the lambda-calculus. Journal of Functional Programming, 7(3): , Jean-Louis Krivine. A call-by-name lambda-calculus machine. Higher-Order and Symbolic Computation, 20(3): , Peter J. Landin. The mechanical evaluation of expressions. Computer Journal, 6(4), Albert R. Meyer and Mitchell Wand. Continuation semantics in typed lambda-calculi. In Rohit Parikh, editor, Proc. of Logic of Programs, volume 193 of LNCS, pages Springer Verlag, /55
55 Bibliography IV Gordon Plotkin. Call-by-name, call-by-value and the λ-calculus. Theoretical Computer Science, 1: , Gordon Plotkin. A structural approach to operational semantics. Technical Report DAIMI FN-19, Aarhus University, John Reynolds. The discoveries of continuations. LISP and Symbolic Computation, 6(3-4): , /55
On 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 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 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 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 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 informationOn 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 informationContinuations, Processes, and Sharing. Paul Downen, Luke Maurer, Zena M. Ariola, Daniele Varacca. September 8, 2014
Continuations, Processes, and Sharing Paul Downen, Luke Maurer, Zena M. Ariola, Daniele Varacca University of Oregon, Université Paris Diderot September 8, 2014 The plethora of semantic artifacts Many
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 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 informationEquivalence of Algebraic λ -calculi extended abstract
Equivalence of Algebraic λ -calculi extended abstract Alejandro Díaz-Caro LIG, Université de Grenoble, France Alejandro.Diaz-Caro@imag.fr Christine Tasson CEA-LIST, MeASI, France Christine.Tasson@cea.fr
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 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 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 informationBRICS. Thunks and the λ-calculus. (Extended Version) Basic Research in Computer Science BRICS RS-97-7 Hatcliff & Danvy: Thunks and the λ-calculus
BRICS Basic Research in Computer Science BRICS RS-97-7 Hatcliff & Danvy: Thunks and the λ-calculus Thunks and the λ-calculus (Extended Version) John Hatcliff Olivier Danvy BRICS Report Series RS-97-7 ISSN
More informationOn 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 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 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 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 informationProbabilistic Applicative Bisimulation and Call-by-Value Lam
Probabilistic Applicative and Call-by-Value Lambda Calculi Joint work with Ugo Dal Lago ENS Lyon February 9, 2014 Probabilistic Applicative and Call-by-Value Lam Introduction Fundamental question: when
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 informationA probabilistic lambda calculus - Some preliminary investigations
A probabilistic lambda calculus - Some preliminary investigations Ugo Dal Lago, Margherita Zorzi Università di Bologna, Università di Verona June, 9-11, 2010, Torino Introduction: Λ P We present some results
More informationA Formulae-as-Types Notion of Control
A Formulae-as-Types Notion of Control Timothy G. Griffin Department of Computer Science Rice University Houston, TX 77251-1892 Abstract The programming language Scheme contains the control construct call/cc
More informationFrom Operational Semantics to Abstract Machines
From Operational Semantics to Abstract Machines John Hannan Department of Computer Science, University of Copenhagen, Universitetsparken 1, DK-2100 Copenhagen East, Denmark. hannan@diku.dk Dale Miller
More informationIntroduction 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 informationCongruence of Bisimulation in a Non-Deterministic Call-By-Need Lambda Calculus
Congruence of Bisimulation in a Non-Deterministic Call-By-Need Lambda Calculus Matthias Mann Johann Wolfgang Goethe-Universität, Frankfurt, Germany Congruence of Bisimulation p. 1/21 Lambda Calculi and
More informationBRICS. A First-Order One-Pass CPS Transformation
BRICS Basic Research in Computer Science BRICS RS-01-49 Danvy & Nielsen: A First-Order One-Pass CPS Transformation A First-Order One-Pass CPS Transformation Olivier Danvy Lasse R. Nielsen BRICS Report
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 informationBisimulation and coinduction in higher-order languages
Bisimulation and coinduction in higher-order languages Davide Sangiorgi Focus Team, University of Bologna/INRIA ICE, Florence, June 2013 Bisimulation Behavioural equality One of the most important contributions
More informationCOMP6463: λ-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 informationProperties of Terms in Continuation-Passing Style in an Ordered Logical Framework
Properties of Terms in Continuation-Passing yle in an Ordered Logical Framework Jeff Polakow and Frank Pfenning Department of Computer Science Carnegie Mellon University jpolakow@cs.cmu.edu and fp@cs.cmu.edu
More informationDiagrams for Meaning Preservation
Diagrams for Meaning Preservation 2003-06-13 Joe Wells Detlef Plump Fairouz Kamareddine Heriot-Watt University University of York www.cee.hw.ac.uk/ultra www.cs.york.ac.uk/ det Diagrams for Meaning Preservation
More informationLazy Functions as Processes
Lazy Functions as Processes Luke Maurer University of Oregon maurerl@cs.uoregon.edu Abstract CPS transforms have long been important tools in the study of programming languages, especially those related
More informationsummer school Logic and Computation Goettingen, July 24-30, 2016
Università degli Studi di Torino summer school Logic and Computation Goettingen, July 24-30, 2016 A bit of history Alonzo Church (1936) The as formal account of computation. Proof of the undecidability
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 informationCall-by-value non-determinism in a linear logic type discipline
Call-by-value non-determinism in a linear logic type discipline Alejandro Díaz-Caro? Giulio Manzonetto Université Paris-Ouest & INRIA LIPN, Université Paris 13 Michele Pagani LIPN, Université Paris 13
More informationOperational Semantics Using the Partiality Monad
page.1 Operational Semantics Using the Partiality Monad Nils Anders Danielsson (Göteborg) Shonan Meeting 026: Coinduction for computation structures and programming languages The research leading to these
More informationVariations on a theme: call-by-value and factorization
Variations on a theme: call-by-value and factorization Beniamino Accattoli INRIA & LIX, Ecole Polytechnique Accattoli (INRIA Parsifal) Variations on a theme: call-by-value and factorization 1 / 31 Outline
More informationA Call-by-Name CPS Hierarchy
A Call-by-Name CPS Hierarchy Asami Tanaka and Yukiyoshi Kameyama University of Tsukuba, Japan asami@logic.cs.tsukuba.ac.jp,kameyama@acm.org Abstract. The Continuation-Passing-Style (CPS) translation gives
More information«Specification and Abstraction of Semantics» 1. Souvenir, Souvenir. Neil D. Jones. Contents. A Tribute Workshop and Festival to Honor Neil D.
«Specification and Abstraction of Semantics» Patrick Cousot Radhia Cousot École normale supérieure CNRS & École polytechnique 45 rue d Ulm Route de Saclay 7530 Paris cedex 05, France 9118 Palaiseau Cedex,
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 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 informationKleene realizability and negative translations
Q E I U G I C Kleene realizability and negative translations Alexandre Miquel O P. D E. L Ō A U D E L A R April 21th, IMERL Plan 1 Kleene realizability 2 Gödel-Gentzen negative translation 3 Lafont-Reus-Streicher
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 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 informationExtending 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 informationLecture 13: Turing Machine
Lecture 13: Turing Machine Instructor: Ketan Mulmuley Scriber: Yuan Li February 19, 2015 Turing machine is an abstract machine which in principle can simulate any computation in nature. Church-Turing Thesis:
More informationLogical specification and coinduction
Logical specification and coinduction Robert J. Simmons Carnegie Mellon University, Pittsburgh PA 15213, USA, rjsimmon@cs.cmu.edu, WWW home page: http://www.cs.cmu.edu/ rjsimmon Abstract. The notion of
More informationCS154, Lecture 10: Rice s Theorem, Oracle Machines
CS154, Lecture 10: Rice s Theorem, Oracle Machines Moral: Analyzing Programs is Really, Really Hard But can we more easily tell when some program analysis problem is undecidable? Problem 1 Undecidable
More informationOperational reasoning for functions with local state
Operational reasoning for functions with local state Andrew Pitts and Ian Stark Abstract Languages such as ML or Lisp permit the use of recursively defined function expressions with locally declared storage
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 Kleene Algebras
Introduction to Kleene Algebras Riccardo Pucella Basic Notions Seminar December 1, 2005 Introduction to Kleene Algebras p.1 Idempotent Semirings An idempotent semiring is a structure S = (S, +,, 1, 0)
More informationStrong Normalization for Guarded Types
Strong Normalization for Guarded Types Andreas Abel Andrea Vezzosi Department of Computer Science and Engineering Chalmers and Gothenburg University, Sweden PLS Seminar ITU, Copenhagen, Denmark 20 August
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 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 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 informationThe L Machines are very high-level, in two senses:
What is a Computer? State of the machine. CMPSCI 630: Programming Languages An Abstract Machine for Control Spring 2009 (with thanks to Robert Harper) Internal registers, memory, etc. Initial and final
More informationReasoning about Programs in Continuation-Passing. for the same programs in continuation-passing style (CPS). To identify the callby-value
LISP AND SYMBOLIC COMPUTATION: An International Journal,?,??{??, 1993 c 1993 Kluwer Academic Publishers { Manufactured in The Netherlands Reasoning about Programs in Continuation-Passing Style AMR SABRY
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 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 informationSafety Analysis versus Type Inference for Partial Types
Safety Analysis versus Type Inference for Partial Types Jens Palsberg palsberg@daimi.aau.dk Michael I. Schwartzbach mis@daimi.aau.dk Computer Science Department, Aarhus University Ny Munkegade, DK-8000
More informationCPS Transformation of Flow Information
Under consideration for publication in J. Functional Programming 1 CPS Transformation of Flow Information Jens Palsberg Purdue University Mitchell Wand Northeastern University Abstract We consider the
More informationA Differential Model Theory for Resource Lambda Calculi - Part II
A Differential Model Theory for Resource Lambda Calculi - Part II Giulio Manzonetto (joint work with Bucciarelli, Ehrhard, Laird, McCusker) g.manzonetto@cs.ru.nl Intelligent Systems Radboud University
More informationMinimal logic for computable functionals
Minimal logic for computable functionals Helmut Schwichtenberg Mathematisches Institut der Universität München Contents 1. Partial continuous functionals 2. Total and structure-total functionals 3. Terms;
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 informationAn Implicit Characterization of PSPACE
An Implicit Characterization of PSPACE Marco Gaboardi Dipartimento di Scienze dell Informazione, Università degli Studi di Bologna - Mura Anteo Zamboni 7, 40127 Bologna, Italy, gaboardi@cs.unibo.it and
More informationNormalisation by evaluation
Normalisation by evaluation Sam Lindley Laboratory for Foundations of Computer Science The University of Edinburgh Sam.Lindley@ed.ac.uk August 11th, 2016 Normalisation and embedded domain specific languages
More informationType 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 informationSafety 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 informationMFPS LICS Special Session Honouring Dana Scott. Symmetric Scott. Andrew Pitts. Computer Laboratory MFPS/LICS /14
MFPS/LICS 2013 1/14 MFPS LICS Special Session Honouring Dana Scott Symmetric Scott Andrew Pitts Computer Laboratory 80 years of Dana Scott MFPS/LICS 2013 2/14 automata theory set theory sheaves & logic
More informationOn the Value of Variables
On the Value of Variables Beniamino Accattoli a, Claudio Sacerdoti Coen b a INRIA, UMR 7161, LIX, École Polytechnique b Department of Computer Science and Engineering, University of Bologna Abstract Call-by-value
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 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 informationRealizing the axiom of dependent choice
Realizing the axiom of dependent choice Jean-Louis Krivine PPS Group, University Paris 7, CNRS krivine@pps.jussieu.fr Edinburgh, March 26, 2003 1 The extended Curry-Howard correspondence We want to get
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 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 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 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 informationContextual equivalence
Techniques 16/22 ACS L16, lecture 2 4/10 Contextual equivalence Two phrases of a programming language are ( Morris style ) contextually equivalent ( = ctx ) if occurrences of the first phrase in any program
More informationRealizability Semantics of Parametric Polymorphism, General References, and Recursive Types
Realizability Semantics of Parametric Polymorphism, General References, and Recursive Types Lars Birkedal IT University of Copenhagen Joint work with Kristian Støvring and Jacob Thamsborg Oct, 2008 Lars
More informationTechniques. Contextual equivalence
Techniques 16/22 Contextual equivalence Two phrases of a programming language are ( Morris style ) contextually equivalent ( = ctx )if occurrences of the first phrase in any program can be replaced by
More informationBRICS. A Computational Formalization for Partial Evaluation. (Extended Version) Basic Research in Computer Science
BRICS RS-96-34 Hatcliff & Danvy: A Computational Formalization for Partial Evaluation BRICS Basic Research in Computer Science A Computational Formalization for Partial Evaluation (Extended Version) John
More informationNon deterministic classical logic: the λµ ++ -calculus
Paru dans : Mathematical Logic Quarterly, 48, pp. 357-366, 2002 Non deterministic classical logic: the λµ ++ -calculus Karim NOUR LAMA - Equipe de Logique, Université de Savoie 73376 Le Bourget du Lac
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 informationThe duality of computation
The duality of computation (notes for the 3rd International Workshop on Higher-Order Rewriting) Hugo Herbelin LIX - INRIA-Futurs - PCRI Abstract. The work presented here is an extension of a previous work
More informationPrinciples of Program Analysis: Control Flow Analysis
Principles of Program Analysis: Control Flow Analysis Transparencies based on Chapter 3 of the book: Flemming Nielson, Hanne Riis Nielson and Chris Hankin: Principles of Program Analysis. Springer Verlag
More informationHORSes: format, termination and confluence
HORSes: format, termination and confluence Jean-Pierre Jouannaud INRIA-LIAMA and singhua Software Chair Joint on-going work with Jianqi Li School of Software, singhua University Project CoqLF NList Cross-discipline
More informationElaborating evaluation-order polymorphism
Elaborating evaluation-order polymorphism Joshua Dunfield University of British Columbia ICFP 2015 1 (prologue) ICFP in Canada for the first time since 2008 2 (prologue) ICFP in Canada for the first time
More informationDomain theory and denotational semantics of functional programming
Domain theory and denotational semantics of functional programming Martín Escardó School of Computer Science, Birmingham University MGS 2007, Nottingham, version of April 20, 2007 17:26 What is denotational
More informationOperationally-Based Theories of Program Equivalence
Operationally-Based Theories of Program Equivalence Andrew Pitts Contents 1 Introduction : : : : : : : : : : : : : : : : : : : : : : : : : : : : 241 2 Contextual Equivalence : : : : : : : : : : : : : :
More informationTHE 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, 2016 Time: 2 hrs. Instructions The exam contains questions totaling 100 points. Answer all questions.
More informationInformation and Computation
Information and Computation 211 2012) 49 76 Contents lists available at SciVerse ScienceDirect Information and Computation www.elsevier.com/locate/yinco Control-flow analysis of function calls and returns
More informationCoinductive big-step operational semantics
Coinductive big-step operational semantics Xavier Leroy a, Hervé Grall b a INRIA Paris-Rocquencourt Domaine de Voluceau, B.P. 105, 78153 Le Chesnay, France b École des Mines de Nantes La Chantrerie, 4,
More informationLecture 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 informationMeta-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 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 informationComputational 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 informationSimply Typed Lambda-Calculi (II)
THEORY AND PRACTICE OF FUNCTIONAL PROGRAMMING Simply Typed Lambda-Calculi (II) Dr. ZHANG Yu Institute of Software, Chinese Academy of Sciences Fall term, 2011 GUCAS, Beijing Introduction PCF Programming
More informationNames and Symmetry in Computer Science
1/27 Names and Symmetry in Computer Science Andrew Pitts Computer Laboratory LICS 2015 Tutorial 2/27 An introduction to nominal techniques motivated by Programming language semantics Automata theory Constructive
More informationClassical Combinatory Logic
Computational Logic and Applications, CLA 05 DMTCS proc. AF, 2006, 87 96 Classical Combinatory Logic Karim Nour 1 1 LAMA - Equipe de logique, Université de Savoie, F-73376 Le Bourget du Lac, France Combinatory
More informationarxiv: v3 [cs.pl] 15 May 2011
A Step-indexed Semantic Model of Types for the Call-by-Name Lambda Calculus arxiv:1105.1985v3 [cs.pl] 15 May 2011 Abstract Step-indexed semantic models of types were proposed as an alternative to purely
More information