Flow Analysis, Linearity and PTIME. David Van Horn and Harry Mairson
|
|
- Dwain Price
- 5 years ago
- Views:
Transcription
1 Flow Analysis, Linearity and PTIME David Van Horn and Harry Mairson
2 What is a lower bound? Higher-order control-flow analysis in retrospect: Lessons learned, lessons abandoned. Shivers, Best of PLDI retrospective: In the ensuing years, researchers have expended a great deal of effort deriving clever ways to tame the cost of the analysis. But a fundamental questions remains: To what extent is this possible? Flow Analysis, Linearity and PTIME p.1/5
3 Lower bounds on AI Observation. For any (useful) abstract interpretation, there exists a class of programs on which AI corresponds with concrete interpretation. Programming within this class may lead to interesting lower bounds. Flow Analysis, Linearity and PTIME p.2/5
4 Goal Give a transparent proof of the correspondence between evaluation and flow analysis for linear programs. Outline: Inspirations Flow analysis and linearity onsequences Flow Analysis, Linearity and PTIME p.3/5
5 Inspirations Flow Analysis, Linearity and PTIME p.4/5
6 Inspiration Linear lambda calculus and PTIME-completeness, Mairson, JFP Special Issue on Functional Pearls. The normal form of a linear λ-term is isomorphic to its most general type. Simple typing: surely a kind of static analysis. What happens with other kinds? Flow Analysis, Linearity and PTIME p.5/5
7 Linearity and simple types When a program is linear, there is no approximation. approximation: λx : σ.... x... x... both occurrences of x must be of type σ linearity avoids the approximation T : α β α F : α β β ( Not T ) : α β β F The same is true for flow analyses (roughly). Flow Analysis, Linearity and PTIME p.6/5
8 Inspiration, II ontrol-flow Analysis of Functional Programs, Midtgaard, AM omputing Surveys. (To appear. BRIS tech. report RS ) Flow analysis abound. (170+ citations and growing). Flow analysis: surely a kind of static analysis. What happens in face of linearity? Flow Analysis, Linearity and PTIME p.7/5
9 Outline Inspirations X Flow analysis and linearity onsequences Flow Analysis, Linearity and PTIME p.8/5
10 Flow analysis and linearity Flow Analysis, Linearity and PTIME p.9/5
11 What is flow analysis? An approximation to operational behavior of programs. let f = λx.x in ( f f )(λy.y) f may be bound to λx.x. x may be bound to λy.y or λx.x. ( f f ) may eval to λy.y or λx.x.... program may eval to λy.y or λx.x. A typical example showing the imprecision of analysis. Flow Analysis, Linearity and PTIME p.10/5
12 Abstract cache We have a simple language with labelled syntax: e ::= tℓ expressions (or labeled terms) t ::= x ee λx.e terms (or unlabeled expressions) b (ℓ) = {λx, λy,...} b (ℓ) = {λx,...} subexpression ℓ may eval to λx,... b (y) = {λx,...} variable y may be bound to λx,... Flow Analysis, Linearity and PTIME p.11/5
13 Abstraction of evaluation E J x Kρ = ρ( x ) E Jλx.eKρ = hλx.e, ρ fv(e)i E Je1 e2 Kρ = let hλx.e0, ρ i = E Je1 K in let c = E Je2 K in E J e0 K ρ [ x 7 c ] b (ℓ) E JPℓ K = hλx.e, ρi = λx.e Flow Analysis, Linearity and PTIME p.12/5
14 A typical specification b = P b = b = b = xℓ (λx.e)ℓ ( t ℓ1 t ℓ2 ) ℓ b is a valid analysis of P b(x) b (ℓ) b (ℓ) λx.e b = tℓ1 b = tℓ2 b (ℓ1 ) : λx.tℓ0 b = tℓ0 b (ℓ2 ) b ( x ) b (ℓ0 ) b (ℓ) Flow Analysis, Linearity and PTIME p.13/5
15 Single and loving it Jagannathan, et al. POPL 98 b (ℓ) = {λx } Subexpression ℓ may must eval to λx. (An idea also used by Might and Shivers, IFP 06, abstract counting.) Flow Analysis, Linearity and PTIME p.14/5
16 Staying single Key to staying single: linearity (1 is the loneliest number). Each variable occurs at most once, so each abstraction λx.e can be applied to at most one argument, and the abstracted value can be bound to at most one argument. b = e and e is linear, b is a complete description of Theorem. If running the program. let f 1 = λx1.x1 in let f 2 = λx2.x2 in ( f 1 f 2 )(λy.y) Flow Analysis, Linearity and PTIME p.15/5
17 0FA E J K? b = x ℓ b = (λx.e)ℓ b = (tℓ1 tℓ2 )ℓ 1 2 b (x) b (ℓ) b (ℓ) λx.e b = tℓ2 b = tℓ1 2 1 ℓ b (ℓ1 ) : λx.t 0 0 b = tℓ0 0 b (ℓ2 ) b ( x ) How can we reconcile superficial distinctions between these two? b (ℓ0 ) b (ℓ) E JxKρ = ρ( x ) E Jλx.eKρ = hλx.e, ρ fv(e)i E Je1 e2 Kρ = let hλx.e0, ρ i let c = E Je1 K in = E Je2 K in E Je0 Kρ [ x 7 c] Flow Analysis, Linearity and PTIME p.16/5
18 The path ahead 1. Specialize the 0FA algorithm for linear terms. 2. Derive an evaluator for linear terms. 3. Un-specialize to reveal typical evaluator. Flow Analysis, Linearity and PTIME p.17/5
19 The path ahead 1. Specialize the 0FA algorithm for linear terms. 2. Derive an evaluator for linear terms. 3. Un-specialize to reveal typical evaluator. Keep in mind: 1. Single and loving it 2. Every subterm is evaluated just once. 3. Every variable is bound just once. Flow Analysis, Linearity and PTIME p.17/5
20 An algorithm for 0FA General 0FA algorithm: mutates (initially empty) cache. b ( x )] b [ℓ 7 + AJ x ℓ K = b [ℓ 7 {λx.e}] AJ(λx.e)ℓ K = AJ(tℓ1 tℓ2 )ℓ K = AJtℓ1 K; AJtℓ2 K; b (ℓ1 ) do for each λx.tℓ0 in b [ x 7 + b (ℓ2 )]; AJtℓ0 K; b [ℓ 7 + b (ℓ0 )] b [ℓ 7 v ] means update b so b (ℓ) = v b [ℓ 7 + v ] means update b so b (ℓ) = v b (ℓ) Flow Analysis, Linearity and PTIME p.18/5
21 An algorithm for linear 0FA b ( x )] b [ℓ 7 + AJ x ℓ K = b [ℓ 7 {λx.e}] AJ(λx.e)ℓ K = AJ(tℓ1 tℓ2 )ℓ K = AJtℓ1 K; AJtℓ2 K; b (ℓ1 ) do for each λx.tℓ0 in b (ℓ0 )] b (ℓ2 )]; AJtℓ0 K; b [ℓ 7 + b [ x 7 + Observation: By singularity, the for each is unneeded. Flow Analysis, Linearity and PTIME p.19/5
22 An algorithm for linear 0FA b ( x )] b [ℓ 7 + AJ x ℓ K = b [ℓ 7 {λx.e}] AJ(λx.e)ℓ K = AJ(tℓ1 tℓ2 )ℓ K = AJtℓ1 K; AJtℓ2 K; b (ℓ1 ) in let { λx.tℓ0 } = b (ℓ0 )] b (ℓ2 )]; AJtℓ0 K; b [ℓ 7 + b [ x 7 + Observation: By singularity, the for each is unneeded. Again by singularity, the 7 + can be replaced with 7. Flow Analysis, Linearity and PTIME p.20/5
23 An algorithm for linear 0FA b [ℓ 7 b ( x )] AJ x ℓ K = b [ℓ 7 {λx.e}] AJ(λx.e)ℓ K = AJ(tℓ1 tℓ2 )ℓ K = AJtℓ1 K; AJtℓ2 K; b (ℓ1 ) in let { λx.tℓ0 } = b [ x 7 b (ℓ2 )]; AJtℓ0 K; b [ℓ 7 b (ℓ0 )] Observation: By singularity, the for each is unneeded. Again by singularity, the 7 + can be replaced with 7. Flow Analysis, Linearity and PTIME p.21/5
24 The path ahead 1. Specialize the 0FA algorithm for linear terms. X 2. Derive an evaluator for linear terms. 3. Un-specialize to reveal typical evaluator. Flow Analysis, Linearity and PTIME p.22/5
25 An algorithm for linear 0FA b [ℓ 7 b ( x )] AJ x ℓ K = b [ℓ 7 {λx.e}] AJ(λx.e)ℓ K = AJ(tℓ1 tℓ2 )ℓ K = AJtℓ1 K; AJtℓ2 K; b (ℓ1 ) in let { λx.tℓ0 } = b [ x 7 b (ℓ2 )]; AJtℓ0 K; b [ℓ 7 b (ℓ0 )] Observation: Values aren t returned; they re written into the cache. The cache is playing the role of the environment. Flow Analysis, Linearity and PTIME p.23/5
26 An algorithm for linear 0FA b [ℓ 7 ρb( x )] AJ x ℓ K = b [ℓ 7 {λx.e}] AJ(λx.e)ℓ K = AJ(tℓ1 tℓ2 )ℓ K = AJtℓ1 K; AJtℓ2 K; b (ℓ1 ) in let { λx.tℓ0 } = b (ℓ2 )]; AJtℓ0 K; b [ℓ 7 b (ℓ0 )] ρb[ x 7 Observation: Values aren t returned; they re written into the cache. The cache is playing the role of the environment. Flow Analysis, Linearity and PTIME p.24/5
27 An algorithm for linear 0FA AJ x ℓ K = ρb( x ) AJ(λx.e)ℓ K = λx.e AJ(tℓ1 tℓ2 )ℓ K = let λx.tℓ0 = AJtℓ1 K in let v = AJtℓ2 K in ρb[ x 7 v]; A J t ℓ0 K Observation: Each variable is bound just once. The cache is playing the role of a global environment Flow Analysis, Linearity and PTIME p.25/5
28 An algorithm for linear 0FA AJ x ℓ Kρ = ρ( x ) AJ(λx.e)ℓ Kρ = hλx.e, ρi AJ(tℓ1 tℓ2 )ℓ Kρ = let hλx.tℓ0, ρ i = AJtℓ1 Kρ1 in let c = AJtℓ2 Kρ2 in A J t ℓ0 K ρ [ x 7 c ] where ρi = ρ fv(tℓi ) and ρ1 ρ2 = Each variable is bound just once. The cache is playing the role of a global environment. Flow Analysis, Linearity and PTIME p.26/5
29 A linear evaluator AJ x ℓ Kρ = ρ( x ) AJ(λx.e)ℓ Kρ = hλx.e, ρi AJ(tℓ1 tℓ2 )ℓ Kρ = let hλx.tℓ0, ρ i = AJtℓ1 Kρ1 in let c = AJtℓ2 Kρ2 in A J t ℓ0 K ρ [ x 7 c ] where ρi = ρ fv(tℓi ) and ρ1 ρ2 = Observation: This is just an evaluator for linear programs. Flow Analysis, Linearity and PTIME p.27/5
30 The path ahead 1. Specialize the 0FA algorithm for linear terms. X 2. Derive an evaluator for linear terms. X 3. Un-specialize to reveal typical evaluator. Flow Analysis, Linearity and PTIME p.28/5
31 A linear evaluator E J x ℓ Kρ = ρ( x ) E J(λx.e)ℓ Kρ = hλx.e, ρi E J(tℓ1 tℓ2 )ℓ Kρ = let hλx.tℓ0, ρ i = E Jtℓ1 Kρ1 in let c = E Jtℓ2 Kρ2 in E J t ℓ0 K ρ [ x 7 c ] where ρi = ρ fv(tℓi ) and ρ1 ρ2 = Observation: This is just an evaluator for linear programs. Flow Analysis, Linearity and PTIME p.29/5
32 A linear evaluator E J x ℓ Kρ = ρ( x ) E J(λx.e)ℓ Kρ = hλx.e, ρi E J(tℓ1 tℓ2 )ℓ Kρ = let hλx.tℓ0, ρ i = E Jtℓ1 Kρ1 in let c = E Jtℓ2 Kρ2 in E J t ℓ0 K ρ [ x 7 c ] where ρi = ρ fv(tℓi ) and ρ1 ρ2 = Observation: This is just an evaluator. Flow Analysis, Linearity and PTIME p.30/5
33 A linear evaluator E J x ℓ Kρ = ρ( x ) E J(λx.e)ℓ Kρ = hλx.e, ρ i where ρ = ρ fv(e) E J(tℓ1 tℓ2 )ℓ Kρ = let hλx.tℓ0, ρ i = E Jtℓ1 Kρ in let c = E Jtℓ2 Kρ in E J t ℓ0 K ρ [ x 7 c ] where ρi = ρ fv(tℓi ) and ρ1 ρ2 = Observation: This is just an evaluator. Flow Analysis, Linearity and PTIME p.31/5
34 A typical evaluator E J x ℓ Kρ = ρ( x ) E J(λx.e)ℓ Kρ = hλx.e, ρ i where ρ = ρ fv(e) E J(tℓ1 tℓ2 )ℓ Kρ = let hλx.tℓ0, ρ i = E Jtℓ1 Kρ in let c = E Jtℓ2 Kρ in E J t ℓ0 K ρ [ x 7 c ] Flow Analysis, Linearity and PTIME p.32/5
35 Outline Inspirations X Flow analysis and linearity X onsequences Flow Analysis, Linearity and PTIME p.33/5
36 onsequences Flow Analysis, Linearity and PTIME p.34/5
37 PTIME Because evaluation of linear terms is complete for PTIME, so is 0FA. - fun - fun - fun - fun Andgate p q k= Orgate p q k= Notgate p k= opygate p k= linear ML terms Difficult to parallelize effectively. Difficult to solve in limited space. Flow Analysis, Linearity and PTIME p.35/5
38 Further approximations The best 0FA algorithm is cubic (and unlikely to be improved: Heintze and McAllester, LIS 97). Several further approximations to 0FA have been developed: Henglein s simple closure analysis Ashley and Dybvig s Sub-0FA Heintze and McAllester subtransitive flow analysis Mossin flow graphs But... on linear programs they are all equivalent to each other and to evaluation. They are all complete for PTIME. Flow Analysis, Linearity and PTIME p.36/5
39 Henglein s simple flow analysis Idea: replace with =. But: Makes no difference for a linear program! Flow Analysis, Linearity and PTIME p.37/5
40 Ashley and Dybvig s Sub-0FA Idea: limit the number of passes over the program. But: Just 1 will do for a linear program! Flow Analysis, Linearity and PTIME p.38/5
41 Beyond 0FA kfa (k > 0) is complete for EXPTIME (IFP 2008). There is no tractable algorithm for kfa. Theory and practice meet. But the exact subset of kfa is only complete for PTIME, i.e. today s technique does not lead to interesting lower bounds. Flow Analysis, Linearity and PTIME p.39/5
42 What has been done? Given a transparent proof of the correspondence between evaluation and flow analysis for linear programs. Identified a core language on which several variants of flow analysis (and evaluation) coincide. Shown all of these variants are PTIME complete. Sketched some ideas for abstract interpretation in general. Flow Analysis, Linearity and PTIME p.40/5
43 What has been done? Given a transparent proof of the correspondence between evaluation and flow analysis for linear programs. Identified a core language on which several variants of flow analysis (and evaluation) coincide. Shown all of these variants are PTIME complete. Sketched some ideas for abstract interpretation in general. Moltes Gràcies Flow Analysis, Linearity and PTIME p.40/5
Fundamentals and lambda calculus. Deian Stefan (adopted from my & Edward Yang s CSE242 slides)
Fundamentals and lambda calculus Deian Stefan (adopted from my & Edward Yang s CSE242 slides) Logistics Assignments: Programming assignment 1 is out Homework 1 will be released tomorrow night Podcasting:
More informationFundamentals and lambda calculus
Fundamentals and lambda calculus Again: JavaScript functions JavaScript functions are first-class Syntax is a bit ugly/terse when you want to use functions as values; recall block scoping: (function ()
More informationRelating Complexity and Precision in Control Flow Analysis
Relating Complexity and Precision in Control Flow Analysis David Van Horn Harry G. Mairson Brandeis University {dvanhorn,mairson}cs.brandeis.edu Abstract We analyze the computational complexity of kcfa,
More informationLinear lambda calculus and PTIME-completeness
Under consideration for publication in J. Functional Programming 1 Linear lambda calculus and PTIME-completeness HARRY G. MAIRSON Computer Science Department Volen Center for Complex Numbers Brandeis University
More informationLambda Calculus and Extensions as Foundation of Functional Programming
Lambda Calculus and Extensions as Foundation of Functional Programming David Sabel and Manfred Schmidt-Schauß 29. September 2015 Lehrerbildungsforum Informatik Last update: 30. September 2015 Overview
More informationLambda Calculus-2. Church Rosser Property
Lambda Calculus-2 Church-Rosser theorem Supports referential transparency of function application Says if it exists, normal form of a term is UNIQUE 1 Church Rosser Property Fundamental result of λ-calculus:
More informationCMSC 330: Organization of Programming Languages
CMSC 330: Organization of Programming Languages Lambda Calculus CMSC 330 Summer 2017 1 100 years ago Albert Einstein proposed special theory of relativity in 1905 In the paper On the Electrodynamics of
More informationIntroduction to Lambda Calculus. Lecture 7 CS /08/09
Introduction to Lambda Calculus Lecture 7 CS 565 02/08/09 Lambda Calculus So far, we ve explored some simple but non-interesting languages language of arithmetic expressions IMP (arithmetic + while loops)
More informationCMSC 330: Organization of Programming Languages. Lambda Calculus
CMSC 330: Organization of Programming Languages Lambda Calculus 1 100 years ago Albert Einstein proposed special theory of relativity in 1905 In the paper On the Electrodynamics of Moving Bodies 2 Prioritätsstreit,
More informationLambda Calculus alpha-renaming, beta reduction, applicative and normal evaluation orders, Church-Rosser theorem, combinators
Lambda Calculus alpha-renaming, beta reduction, applicative and normal evaluation orders, Church-Rosser theorem, combinators Carlos Varela Rennselaer Polytechnic Institute February 11, 2010 C. Varela 1
More informationPure (Untyped) λ-calculus. Andrey Kruglyak, 2010
Pure (Untyped) λ-calculus Andrey Kruglyak, 2010 1 Pure (untyped) λ-calculus An example of a simple formal language Invented by Alonzo Church (1936) Used as a core language (a calculus capturing the essential
More informationCMSC 330: Organization of Programming Languages. Lambda Calculus
CMSC 330: Organization of Programming Languages Lambda Calculus 1 Turing Completeness Turing machines are the most powerful description of computation possible They define the Turing-computable functions
More informationLambda Calculus and Type Inference
Lambda Calculus and Type Inference Björn Lisper Dept. of Computer Science and Engineering Mälardalen University bjorn.lisper@mdh.se http://www.idt.mdh.se/ blr/ August 17, 2007 Lambda Calculus and Type
More informationCITS3211 FUNCTIONAL PROGRAMMING
CITS3211 FUNCTIONAL PROGRAMMING 9. The λ calculus Summary: This lecture introduces the λ calculus. The λ calculus is the theoretical model underlying the semantics and implementation of functional programming
More informationControl Flow Analysis with SAT Solvers
Control Flow Analysis with SAT Solvers Steven Lyde, Matthew Might University of Utah, Salt Lake City, Utah, USA Abstract. Control flow analyses statically determine the control flow of programs. This is
More informationCOMP 1130 Lambda Calculus. based on slides by Jeff Foster, U Maryland
COMP 1130 Lambda Calculus based on slides by Jeff Foster, U Maryland Motivation Commonly-used programming languages are large and complex ANSI C99 standard: 538 pages ANSI C++ standard: 714 pages Java
More informationLecture 5: The Untyped λ-calculus
Lecture 5: The Untyped λ-calculus Syntax and basic examples Polyvios Pratikakis Computer Science Department, University of Crete Type Systems and Static Analysis Pratikakis (CSD) Untyped λ-calculus I CS49040,
More informationActivity. CSCI 334: Principles of Programming Languages. Lecture 4: Fundamentals II. What is computable? What is computable?
Activity CSCI 334: Principles of Programming Languages Lecture 4: Fundamentals II Write a function firsts that, when given a list of cons cells, returns a list of the left element of each cons. ( (a. b)
More informationCSCI B522 Lecture 11 Naming and Scope 8 Oct, 2009
CSCI B522 Lecture 11 Naming and Scope 8 Oct, 2009 Lecture notes for CS 6110 (Spring 09) taught by Andrew Myers at Cornell; edited by Amal Ahmed, Fall 09. 1 Static vs. dynamic scoping The scope of a variable
More informationOne of a number of approaches to a mathematical challenge at the time (1930): Constructibility
λ Calculus Church s λ Calculus: Brief History One of a number of approaches to a mathematical challenge at the time (1930): Constructibility (What does it mean for an object, e.g. a natural number, to
More informationLecture Notes: Control Flow Analysis for Functional Languages
Lecture Notes: Control Flow Analysis for Functional Languages 17-355/17-665: Program Analysis (Spring 2017) Jonathan Aldrich aldrich@cs.cmu.edu 1 Analysis of Functional Programs Analyzing functional programs
More informationSharing in the weak lambda-calculus
Sharing in the weak lambda-calculus Tomasz Blanc Jean-Jacques Lévy Luc Maranget INRIA Rocquencourt Dec 19, 2005 Sharing in the weak lambda-calculus Tomasz Blanc Jean-Jacques Lévy Luc Maranget INRIA Rocquencourt
More informationIntroduction to Lambda Calculus. Lecture 5 CS 565 1/24/08
Introduction to Lambda Calculus Lecture 5 CS 565 1/24/08 Lambda Calculus So far, we ve explored some simple but non-interesting languages language of arithmetic expressions IMP (arithmetic + while loops)
More informationdynamically typed dynamically scoped
Reference Dynamically Typed Programming Languages Part 1: The Untyped λ-calculus Jim Royer CIS 352 April 19, 2018 Practical Foundations for Programming Languages, 2/e, Part VI: Dynamic Types, by Robert
More information11/6/17. Outline. FP Foundations, Scheme. Imperative Languages. Functional Programming. Mathematical Foundations. Mathematical Foundations
Outline FP Foundations, Scheme In Text: Chapter 15 Mathematical foundations Functional programming λ-calculus LISP Scheme 2 Imperative Languages We have been discussing imperative languages C/C++, Java,
More informationCS-XXX: Graduate Programming Languages. Lecture 9 Simply Typed Lambda Calculus. Dan Grossman 2012
CS-XXX: Graduate Programming Languages Lecture 9 Simply Typed Lambda Calculus Dan Grossman 2012 Types Major new topic worthy of several lectures: Type systems Continue to use (CBV) Lambda Caluclus as our
More informationLambda Calculus. Variables and Functions. cs3723 1
Lambda Calculus Variables and Functions cs3723 1 Lambda Calculus Mathematical system for functions Computation with functions Captures essence of variable binding Function parameters and substitution Can
More informationIntroduction to the λ-calculus
Announcements Prelim #2 issues: o Problem 5 grading guide out shortly o Problem 3 (hashing) issues Will be on final! Friday RDZ office hours are 11-12 not 1:30-2:30 1 Introduction to the λ-calculus Today
More informationFormal Semantics. Aspects to formalize. Lambda calculus. Approach
Formal Semantics Aspects to formalize Why formalize? some language features are tricky, e.g. generalizable type variables, nested functions some features have subtle interactions, e.g. polymorphism and
More informationFlow-Sensitive Type Recovery in Linear-Log Time
Flow-Sensitive Type Recovery in Linear-Log Time Michael D Adams Indiana University Andrew W Keep Indiana University Jan Midtgaard Aarhus University Matthew Might University of Utah Arun Chauhan Indiana
More informationlambda calculus History 11/28/13 Jianguo Lu A formal system designed to inves:gate func:on defini:on, func:on applica:on, and recursion.
lambda calculus Jianguo Lu 1 History Lambda calculus A formal system designed to inves:gate func:on defini:on, func:on applica:on, and recursion. Introduced by Alonzo Church in 1930s. The calculus can
More informationProgramming Language Features. CMSC 330: Organization of Programming Languages. Turing Completeness. Turing Machine.
CMSC 330: Organization of Programming Languages Lambda Calculus Programming Language Features Many features exist simply for convenience Multi-argument functions foo ( a, b, c ) Ø Use currying or tuples
More informationCMSC 330: Organization of Programming Languages
CMSC 330: Organization of Programming Languages Lambda Calculus CMSC 330 1 Programming Language Features Many features exist simply for convenience Multi-argument functions foo ( a, b, c ) Ø Use currying
More informationChapter 5: The Untyped Lambda Calculus
Chapter 5: The Untyped Lambda Calculus What is lambda calculus for? Basics: syntax and operational semantics Programming in the Lambda Calculus Formalities (formal definitions) What is Lambda calculus
More informationINF 212 ANALYSIS OF PROG. LANGS LAMBDA CALCULUS. Instructors: Crista Lopes Copyright Instructors.
INF 212 ANALYSIS OF PROG. LANGS LAMBDA CALCULUS Instructors: Crista Lopes Copyright Instructors. History Formal mathematical system Simplest programming language Intended for studying functions, recursion
More informationLambda Calculus. Adrian Groza. Department of Computer Science Technical University of Cluj-Napoca
Lambda Calculus Adrian Groza Department of Computer Science Technical University of Cluj-Napoca Outline 1 λ-calculus 2 Operational Semantics Syntax Conversions Normal Form 3 Lambda Calculus as a Functional
More informationCMSC 330: Organization of Programming Languages. Operational Semantics
CMSC 330: Organization of Programming Languages Operational Semantics Notes about Project 4, Parts 1 & 2 Still due today (7/2) Will not be graded until 7/11 (along with Part 3) You are strongly encouraged
More informationHarvard School of Engineering and Applied Sciences CS 152: Programming Languages. Lambda calculus
Harvard School of Engineering and Applied Sciences CS 152: Programming Languages Tuesday, February 19, 2013 The lambda calculus (or λ-calculus) was introduced by Alonzo Church and Stephen Cole Kleene in
More informationCIS 500 Software Foundations Fall October 2
CIS 500 Software Foundations Fall 2006 October 2 Preliminaries Homework Results of my email survey: There was one badly misdesigned (PhD) problem and a couple of others that were less well thought through
More informationLecture Notes on Data Representation
Lecture Notes on Data Representation 15-814: Types and Programming Languages Frank Pfenning Lecture 9 Tuesday, October 2, 2018 1 Introduction In this lecture we ll see our type system in action. In particular
More informationMore Lambda Calculus and Intro to Type Systems
More Lambda Calculus and Intro to Type Systems Plan Heavy Class Participation Thus, wake up! Lambda Calculus How is it related to real life? Encodings Fixed points Type Systems Overview Static, Dyamic
More informationLazy Modules. Keiko Nakata Institute of Cybernetics at Tallinn University of Technology
Lazy Modules Keiko Nakata Institute of Cybernetics at Tallinn University of Technology Constrained lazy initialization for modules Plan of my talk Lazy initialization in practice Constrained laziness Or,
More informationHarvard School of Engineering and Applied Sciences Computer Science 152
Harvard School of Engineering and Applied Sciences Computer Science 152 Lecture 17 Tuesday, March 30, 2010 1 Polymorph means many forms. Polymorphism is the ability of code to be used on values of different
More informationLexicografie computationala Feb., 2012
Lexicografie computationala Feb., 2012 Anca Dinu University of Bucharest Introduction When we construct meaning representations systematically, we integrate information from two different sources: 1. The
More informationLambda Calculus. Lecture 4 CS /26/10
Lambda Calculus Lecture 4 CS 565 10/26/10 Pure (Untyped) Lambda Calculus The only value is a function Variables denote functions Functions always take functions as arguments Functions always return functions
More informationThe Untyped Lambda Calculus
CS738: Advanced Compiler Optimizations The Untyped Lambda Calculus Amey Karkare karkare@cse.iitk.ac.in http://www.cse.iitk.ac.in/~karkare/cs738 Department of CSE, IIT Kanpur Reference Book Types and Programming
More informationCompilers: The goal. Safe. e : ASM
Compilers: The goal What s our goal with compilers? Take a high level language, turn it into a low level language In a semantics preserving way. e : ML Safe e : ASM 1 Compilers: The goal What s our goal
More informationλ calculus is inconsistent
Content Rough timeline COMP 4161 NICTA Advanced Course Advanced Topics in Software Verification Gerwin Klein, June Andronick, Toby Murray λ Intro & motivation, getting started [1] Foundations & Principles
More informationVU Semantik von Programmiersprachen
VU Semantik von Programmiersprachen Agata Ciabattoni Institute für Computersprachen, Theory and Logic group (agata@logic.at) (A gentle) Introduction to λ calculus p. 1 Why shoud I studyλcalculus? p. 2
More informationCS 6110 S11 Lecture 12 Naming and Scope 21 February 2011
CS 6110 S11 Lecture 12 Naming and Scope 21 February 2011 In this lecture we introduce the topic of scope in the context of the λ-calculus and define translations from λ-cbv to FL for the two most common
More informationComputer Science 203 Programming Languages Fall Lecture 10. Bindings, Procedures, Functions, Functional Programming, and the Lambda Calculus
1 Computer Science 203 Programming Languages Fall 2004 Lecture 10 Bindings, Procedures, Functions, Functional Programming, and the Lambda Calculus Plan Informal discussion of procedures and bindings Introduction
More informationCSCI.4430/6969 Programming Languages Lecture Notes
CSCI.4430/6969 Programming Languages Lecture Notes August 28, 2006 1 Brief History of Programming Languages Ada Augusta, the Countess of Lovelace, the daughter of the poet Lord Byron, is attributed as
More informationλ calculus Function application Untyped λ-calculus - Basic Idea Terms, Variables, Syntax β reduction Advanced Formal Methods
Course 2D1453, 2006-07 Advanced Formal Methods Lecture 2: Lambda calculus Mads Dam KTH/CSC Some material from B. Pierce: TAPL + some from G. Klein, NICTA Alonzo Church, 1903-1995 Church-Turing thesis First
More informationaxiomatic semantics involving logical rules for deriving relations between preconditions and postconditions.
CS 6110 S18 Lecture 18 Denotational Semantics 1 What is Denotational Semantics? So far we have looked at operational semantics involving rules for state transitions, definitional semantics involving translations
More informationCMPUT 325 : Lambda Calculus Basics. Lambda Calculus. Dr. B. Price and Dr. R. Greiner. 13th October 2004
CMPUT 325 : Lambda Calculus Basics Dr. B. Price and Dr. R. Greiner 13th October 2004 Dr. B. Price and Dr. R. Greiner CMPUT 325 : Lambda Calculus Basics 1 Lambda Calculus Lambda calculus serves as a formal
More informationLast class. CS Principles of Programming Languages. Introduction. Outline
Last class CS6848 - Principles of Programming Languages Principles of Programming Languages V. Krishna Nandivada IIT Madras Interpreters A Environment B Cells C Closures D Recursive environments E Interpreting
More informationCS152: Programming Languages. Lecture 7 Lambda Calculus. Dan Grossman Spring 2011
CS152: Programming Languages Lecture 7 Lambda Calculus Dan Grossman Spring 2011 Where we are Done: Syntax, semantics, and equivalence For a language with little more than loops and global variables Now:
More informationIntroduction to lambda calculus Part 3
Introduction to lambda calculus Part 3 Antti-Juhani Kaijanaho 2017-01-27... 1 Untyped lambda calculus... 2 Typed lambda calculi In an untyped lambda calculus extended with integers, it is required that
More informationIf a program is well-typed, then a type can be inferred. For example, consider the program
CS 6110 S18 Lecture 24 Type Inference and Unification 1 Type Inference Type inference refers to the process of determining the appropriate types for expressions based on how they are used. For example,
More informationRecursive Definitions, Fixed Points and the Combinator
Recursive Definitions, Fixed Points and the Combinator Dr. Greg Lavender Department of Computer Sciences University of Texas at Austin Recursive Self-Reference Recursive self-reference occurs regularly
More informationAbstract register machines Lecture 23 Tuesday, April 19, 2016
Harvard School of Engineering and Applied Sciences CS 152: Programming Languages Lecture 23 Tuesday, April 19, 2016 1 Why abstract machines? So far in the class, we have seen a variety of language features.
More information5. Introduction to the Lambda Calculus. Oscar Nierstrasz
5. Introduction to the Lambda Calculus Oscar Nierstrasz Roadmap > What is Computability? Church s Thesis > Lambda Calculus operational semantics > The Church-Rosser Property > Modelling basic programming
More informationCS 565: Programming Languages. Spring 2008 Tu, Th: 16:30-17:45 Room LWSN 1106
CS 565: Programming Languages Spring 2008 Tu, Th: 16:30-17:45 Room LWSN 1106 Administrivia Who am I? Course web page http://www.cs.purdue.edu/homes/peugster/cs565spring08/ Office hours By appointment Main
More informationCMSC330. Objects, Functional Programming, and lambda calculus
CMSC330 Objects, Functional Programming, and lambda calculus 1 OOP vs. FP Object-oriented programming (OOP) Computation as interactions between objects Objects encapsulate mutable data (state) Accessed
More informationLambda Calculus. Lambda Calculus
Lambda Calculus Formalism to describe semantics of operations in functional PLs Variables are free or bound Function definition vs function abstraction Substitution rules for evaluating functions Normal
More informationPolymorphism and Type Inference
Polymorphism and Type Inference Volker Stolz stolz@ifi.uio.no INF 3110-2008 Department of Informatics University of Oslo Initially by Gerardo Schneider. Based on John C. Mitchell s slides (Stanford U.)
More informationCMSC 330: Organization of Programming Languages
CMSC 330: Organization of Programming Languages Lambda Calculus Encodings CMSC 330 Spring 2017 1 Review A lambda calculus expression is defined as e ::= x variable λx.e abstraction (fun def) e e application
More informationCMSC 330: Organization of Programming Languages
CMSC 330: Organization of Programming Languages Lambda Calculus CMSC 330 1 Programming Language Features Many features exist simply for convenience Multi-argument functions foo ( a, b, c ) Use currying
More informationCS 6110 S11 Lecture 25 Typed λ-calculus 6 April 2011
CS 6110 S11 Lecture 25 Typed λ-calculus 6 April 2011 1 Introduction Type checking is a lightweight technique for proving simple properties of programs. Unlike theorem-proving techniques based on axiomatic
More information1 Introduction. 3 Syntax
CS 6110 S18 Lecture 19 Typed λ-calculus 1 Introduction Type checking is a lightweight technique for proving simple properties of programs. Unlike theorem-proving techniques based on axiomatic semantics,
More informationInternational School on Rewriting (ISR 2015) Rewriting Techniques for Correctness of Program Transformations
International School on Rewriting (ISR 2015) Rewriting Techniques for Correctness of Program Transformations David Sabel and Manfred Schmidt-Schauß Computer Science Institute Goethe-University Frankfurt
More informationDATABASE THEORY. Lecture 11: Introduction to Datalog. TU Dresden, 12th June Markus Krötzsch Knowledge-Based Systems
DATABASE THEORY Lecture 11: Introduction to Datalog Markus Krötzsch Knowledge-Based Systems TU Dresden, 12th June 2018 Announcement All lectures and the exercise on 19 June 2018 will be in room APB 1004
More informationCS-XXX: Graduate Programming Languages. Lecture 17 Recursive Types. Dan Grossman 2012
CS-XXX: Graduate Programming Languages Lecture 17 Recursive Types Dan Grossman 2012 Where are we System F gave us type abstraction code reuse strong abstractions different from real languages (like ML),
More informationThe Polymorphic Blame Calculus and Parametricity
1 / 31 The Polymorphic Blame Calculus and Parametricity Jeremy G. Siek Indiana University, Bloomington University of Strathclyde August 2015 2 / 31 Integrating static and dynamic typing Static Dynamic
More informationThe University of Nottingham SCHOOL OF COMPUTER SCIENCE A LEVEL 4 MODULE, SPRING SEMESTER MATHEMATICAL FOUNDATIONS OF PROGRAMMING ANSWERS
The University of Nottingham SCHOOL OF COMPUTER SCIENCE A LEVEL 4 MODULE, SPRING SEMESTER 2012 2013 MATHEMATICAL FOUNDATIONS OF PROGRAMMING ANSWERS Time allowed TWO hours Candidates may complete the front
More informationNumerical Optimization
Convex Sets Computer Science and Automation Indian Institute of Science Bangalore 560 012, India. NPTEL Course on Let x 1, x 2 R n, x 1 x 2. Line and line segment Line passing through x 1 and x 2 : {y
More informationType Systems Winter Semester 2006
Type Systems Winter Semester 2006 Week 4 November 8 November 15, 2006 - version 1.1 The Lambda Calculus The lambda-calculus If our previous language of arithmetic expressions was the simplest nontrivial
More informationCOMP 4161 NICTA Advanced Course. Advanced Topics in Software Verification. Toby Murray, June Andronick, Gerwin Klein
COMP 4161 NICTA Advanced Course Advanced Topics in Software Verification Toby Murray, June Andronick, Gerwin Klein λ 1 Last time... λ calculus syntax free variables, substitution β reduction α and η conversion
More informationWhereweare. CS-XXX: Graduate Programming Languages. Lecture 7 Lambda Calculus. Adding data structures. Data + Code. What about functions
Whereweare CS-XXX: Graduate Programming Languages Lecture 7 Lambda Calculus Done: Syntax, semantics, and equivalence For a language with little more than loops and global variables Now: Didn t IMP leave
More informationConcepts of programming languages
Concepts of programming languages Lecture 5 Wouter Swierstra 1 Announcements Submit your project proposal to me by email on Friday; The presentation schedule in now online Exercise session after the lecture.
More informationFunctional Programming Languages (FPL)
Functional Programming Languages (FPL) 1. Definitions... 2 2. Applications... 2 3. Examples... 3 4. FPL Characteristics:... 3 5. Lambda calculus (LC)... 4 6. Functions in FPLs... 7 7. Modern functional
More informationFlow Analysis. Data-flow analysis, Control-flow analysis, Abstract interpretation, AAM
Flow Analysis Data-flow analysis, Control-flow analysis, Abstract interpretation, AAM Helpful Reading: Sections 1.1-1.5, 2.1 Data-flow analysis (DFA) A framework for statically proving facts about program
More informationDenotational Semantics; Lambda Calculus Basics Section and Practice Problems Week 4: Tue Feb 13 Fri Feb 16, 2018
Harvard School of Engineering and Applied Sciences CS 152: Programming Languages Denotational Semantics; Lambda Calculus Basics Week 4: Tue Feb 13 Fri Feb 16, 2018 1 Denotational Semantics (a) Give the
More informationIntroductory Example
CSc 520 Principles of Programming Languages 21: Lambda Calculus Introduction Christian Collberg Department of Computer Science University of Arizona collberg@cs.arizona.edu Copyright c 2005 Christian Collberg
More informationFunctional Programming and λ Calculus. Amey Karkare Dept of CSE, IIT Kanpur
Functional Programming and λ Calculus Amey Karkare Dept of CSE, IIT Kanpur 0 Software Development Challenges Growing size and complexity of modern computer programs Complicated architectures Massively
More informationChapter 11 :: Functional Languages
Chapter 11 :: Functional Languages Programming Language Pragmatics Michael L. Scott Copyright 2016 Elsevier 1 Chapter11_Functional_Languages_4e - Tue November 21, 2017 Historical Origins The imperative
More informationLambda Calculus. Type Systems, Lectures 3. Jevgeni Kabanov Tartu,
Lambda Calculus Type Systems, Lectures 3 Jevgeni Kabanov Tartu, 13.02.2006 PREVIOUSLY ON TYPE SYSTEMS Arithmetical expressions and Booleans Evaluation semantics Normal forms & Values Getting stuck Safety
More informationCSE413: Programming Languages and Implementation Racket structs Implementing languages with interpreters Implementing closures
CSE413: Programming Languages and Implementation Racket structs Implementing languages with interpreters Implementing closures Dan Grossman Fall 2014 Hi! I m not Hal J I love this stuff and have taught
More informationFunctional programming languages
Functional programming languages Part I: interpreters and operational semantics Xavier Leroy INRIA Paris-Rocquencourt MPRI 2-4, 2016 2017 X. Leroy (INRIA) Functional programming languages MPRI 2-4, 2016
More informationCSE 505: Concepts of Programming Languages
CSE 505: Concepts of Programming Languages Dan Grossman Fall 2003 Lecture 6 Lambda Calculus Dan Grossman CSE505 Fall 2003, Lecture 6 1 Where we are Done: Modeling mutation and local control-flow Proving
More informationIntroduction to the Lambda Calculus
Introduction to the Lambda Calculus Overview: What is Computability? Church s Thesis The Lambda Calculus Scope and lexical address The Church-Rosser Property Recursion References: Daniel P. Friedman et
More informationCMSC 336: Type Systems for Programming Languages Lecture 5: Simply Typed Lambda Calculus Acar & Ahmed January 24, 2008
CMSC 336: Type Systems for Programming Languages Lecture 5: Simply Typed Lambda Calculus Acar & Ahmed January 24, 2008 Contents 1 Solution to the Exercise 1 1.1 Semantics for lambda calculus.......................
More informationThe Typed λ Calculus and Type Inferencing in ML
Notes on Types S. Arun-Kumar Department of Computer Science and Engineering Indian Institute of Technology New Delhi, 110016 email: sak@cse.iitd.ernet.in April 14, 2002 2 Chapter 1 The Typed λ Calculus
More informationCSE341: Programming Languages Lecture 17 Implementing Languages Including Closures. Dan Grossman Autumn 2018
CSE341: Programming Languages Lecture 17 Implementing Languages Including Closures Dan Grossman Autumn 2018 Typical workflow concrete syntax (string) "(fn x => x + x) 4" Parsing Possible errors / warnings
More informationMore Lambda Calculus and Intro to Type Systems
#1 More Lambda Calculus and Intro to Type Systems #2 Plan Heavy Class Participation Thus, wake up! (not actually kidding) Lambda Calculus How is it related to real life? Encodings Fixed points Type Systems
More informationCSE-505: Programming Languages. Lecture 20.5 Recursive Types. Zach Tatlock 2016
CSE-505: Programming Languages Lecture 20.5 Recursive Types Zach Tatlock 2016 Where are we System F gave us type abstraction code reuse strong abstractions different from real languages (like ML), but
More informationHiding local state in direct style: a higher-order anti-frame rule
1 / 65 Hiding local state in direct style: a higher-order anti-frame rule François Pottier January 28th, 2008 2 / 65 Contents Introduction Basics of the type system A higher-order anti-frame rule Applications
More informationFormal Systems and their Applications
Formal Systems and their Applications Dave Clarke (Dave.Clarke@cs.kuleuven.be) Acknowledgment: these slides are based in part on slides from Benjamin Pierce and Frank Piessens 1 Course Overview Introduction
More informationBRICS. Control-Flow Analysis of Functional Programs. BRICS RS J. Midtgaard: Control-Flow Analysis of Functional Programs
BRICS RS-07-18 J. Midtgaard: Control-Flow Analysis of Functional Programs BRICS Basic Research in Computer Science Control-Flow Analysis of Functional Programs Jan Midtgaard BRICS Report Series RS-07-18
More informationIn class 75min: 2:55-4:10 Thu 9/30.
MATH 4530 Topology. In class 75min: 2:55-4:10 Thu 9/30. Prelim I Solutions Problem 1: Consider the following topological spaces: (1) Z as a subspace of R with the finite complement topology (2) [0, π]
More information