Functional Concepts in C++
|
|
- Sydney Atkins
- 5 years ago
- Views:
Transcription
1 Trends in Functional Programming 2006 Nottingham Functional Concepts in C++ Rose H. Abdul Rauf, Anton Setzer, Ulrich Berger Swansea 1
2 Goal: Integrating Functional and Object-Oriented Programming A first step: Implementing the simply typed λ-calculus in C++. Novelty: Formal correctness proof. Extensions - recursion, - Lazy evaluation - λ-terms with side effects. 2
3 The simply typed λ-calculus with arithmetic functions Γ, x : A x : A Γ n : nat Γ, x : A r : B Γ λx A r : A B Γ r : A B Γ s : A Γ r s : B Γ r 1 : nat... Γ r k : nat Γ f[r 1,..., r k ] : nat (f a name for k-ary arithmetic function [f ]) 3
4 Implementing types The base type nat is implemented by the native C++ type int. If the types A, B are implemented by C++ types A, B, then the type A B is implemented by the C++ type CA_BD defined as follows: class CA_BD_aux { public : virtual B operator() (A x) = 0; }; typedef CA_BD_aux* CA_BD; 4
5 Implementing λ-terms Example: λx nat.f (f x) with free variable f nat nat. class lambda1 : public Cint_intD_aux{ public :Cint_intD f; lambda1( Cint_intD f) { this-> f = f;}; virtual int operator () (int x) { return (*(f))((*(f))(x)); }; }; Abstracting f: λf nat nat λx nat.f(fx) class lambda0 : public CCint_intD_Cint_intDD_aux{ public : lambda0( ) { }; virtual Cint_intD operator () (Cint_intD f) { return new lambda1( f); } }; 5
6 Implementing λ-terms (ctd.) λx nat.2 + x class lambda2 : public Cint_intD_aux{ public : lambda2( ) { }; virtual int operator () (int x) { return x + 2; }; }; t = (λf nat nat λx nat.f (f x)) (λx nat. x + 2) 3 int t = (*((*( new lambda0( )))( new lambda2( ))))(3); 6
7 Proof of Correctness Our goal is to formally prove: If a closed term t nat has value n, then our implementation evaluates t to n. This requires: - A formal definition of the value of a term. - A formal model of our C++ implementation. 7
8 What is the value of a λ-term? Operational semantics: Normal form w.r.t. β-reduction: (λx.r)s r[s/x] f-reduction: f[n 1,..., n k ] [f ](n 1,..., n k ) Denotational semantics: [r ] D where D is a domain of higher type functionals. Luckily, at base type the two semantics coincide. We will use the denotational semantics and logical relations to prove correctness. 8
9 Naïve denotational semantics N = {0, 1, 2,...}, X Y = {f f : X Y } D(nat) = N, D(A B) = D(A) D(B), D = Functional environment: ξ : Var D, ξ : Γ means x dom(γ).ξ(x) D(Γ(x)). A Type D(A) For Γ r : A and ξ : Γ, we define [r ]ξ D(A): [x]ξ = ξ(x), [n]ξ = n [r s]ξ = [r ]ξ([s]ξ) [λx A.r ]ξ(a) = [r ]ξ[x a] [f[ r]] = [f ]([ r ]ξ) 9
10 The state monad M X (Y ) := X Y X do{y 1 e 1 ; y 2 e 2 (y 1 ) ; e 3 (y 1, y 2 )} x =g let {(y 1, x 1 ) = e 1 x, (y 2, x 2 ) = e 2 (y 1 ) x 1 } in e 3 (y 1, y 2 ) x 2 return : Y M X (Y ), return y x = (y, x) mapm : (Z M X (Y )) Z M X (Y ) mapm f a = do{y 1 f a 1 ;... ; return (y 1,...)} get : M X (X), get x = (x, x) put : X M X ({ }), put x x = (, x) 10
11 Modelling the implementation Addr = a set addresses of classes on the heap Constr = a set of constructors, i.e. class names Val = N + Addr F = a set of names for arithmetic C++ functions App = N + Var + F App + App App + Constr App Class = Context Var Type App VEnv = Var fin Val Heap = Addr fin Constr Val CEnv = Constr fin Class 11
12 Parsing (Implementing λ-terms) P : Context Term M CEnv (App) Evaluating λ-terms eval : apply : CEnv VEnv App M Heap (Val) CEnv Val Val M Heap (Val) 12
13 P : Context Term M CEnv (App) P Γ u = return u, if u is a numeral or a variable P Γ f[ r] = do{ a mapm (P Γ) r ; return f[ a]} P Γ (r s) = do{(a, b) mapm (P Γ) (r, s) ; return (a b)} P Γ (λx A.r) = do{a P Γ[x A] r ; C get ; let c = fresh(c) ; put(c[c (Γ; x : A; a)]) ; return(c[dom(γ)])} 13
14 eval : CEnv VEnv App M Heap (Val) eval C η n = return n eval C η x = return (η x) eval C η f[ a] = do{ n mapm (eval C η) a ; return [f ]( n)} eval C η (a b) = do{(v, w) mapm(eval C η) (a, b) ; apply C v w} eval C η c[ a] = do{ v mapm (eval C η) a ; H get ; let h = fresh(h) ; put(h[h (c, v)]) ; return(h)} 14
15 apply : CEnv Val Val M Heap (Val) apply C h v = do{h get ; let (c, w) = H h ; let ( y : B; x : A; a) = C c ; eval C [ y, x w, v] a} 15
16 Linking C++ with higher type functionals The Kripke logical relation C A (Val Heap) D(A), is defined by recursion on A as follows: (v, H) C nat n : v = n (v, H) C A B f : C C, H H, (w, d) Val D(A) : (w, H ) C A d apply C v w H C B f(d) (η, H) C Γ ξ : x dom(γ)(η(x), H) C Γ(x) ξ(x) 16
17 Adequacy Theorem Assume η : VEnv, ξ : FEnv, Γ r : A. Assume ξ : Γ, P Γ r C = (a, C ), C C, (η, H) C Γ ξ, and H H. Then eval C η a H C A [r ]ξ. Proof. Induction on the typing judgement Γ r : A. Correctness of the implementation Assume r : nat, P r C = (a, C ) and C C. Then for any heap H and environment η we have eval C η a H = ([r ], H ) for some H H. 17
18 Further work Study the C++ implementation of recursion, lazy evaluation, and λ-terms with side effects more systematically and prove correctness. Construct a less ad-hoc model of a suitable fragment of C++ (similar to Featherweight Java [IPW99]). Give a monadic proof of the Adequacy Theorem. Study related work, e.g.: Läufer [Läu95] (1995) Kiselyov [Kis98] (1998) B. McNamara and Y. Smaragdakis [MS00] (2000) Schupp [Sch00] (2000) 18
19 Conclusion The implementation of functional concepts in object-oriented (imperative) languages is feasible. Denotational semantics and logical relations are very useful tools for proving correctness of the implementation. 19
20 References [ASS85] H. Abelson, G. J. Sussman, and J. Sussman. Structure and interpretation of computer programs. MIT Press, [IPW99] Atshushi Igarashi, Benjamin Pierce, and Philip Wadler. Featherweight Java: A minimal core calculus for Java and GJ. In Loren Meissner, editor, Proceedings of the 1999 ACM SIGPLAN Conference on Object-Oriented Programming, Systems, Languages & Applications (OOPSLA 99), volume 34(10), pages , N. Y., [Kel97] R. M. Keller. The Polya C++ Library. Version
21 [Kis98] Available via keller/polya/, O. Kiselyov. Functional style in C++: Closures, late binding, and lambda abstractions. In ICFP 98: Proceedings of the third ACM SIGPLAN International conference on Functional programming, page 337, New York, NY, USA, ACM Press. [Läu95] K. Läufer. A framework for higher-order functions in C++. In COOTS, [Mog91] E. Moggi. Notions of computation and monads. Information and Computation, 93(3):55 2,
22 [MS00] [Plo77] [Plo80] B. McNamara and Y. Smaragdakis. Functional programming in C++. In ICFP 00: Proceedings of the fifth ACM SIGPLAN international conference on Functional programming, pages , New York, NY, USA, ACM Press. G. D. Plotkin. LCF considered as a programming language. Theoretical Computer Science, 5: , G. D. Plotkin. Lambda definability in the full type hierarchy. In R. Hindley and J. Seldin, editors, To H.B. Curry: Essays in Combinatory Logic, lambda calculus and Formalisms, pages Academic Press,
23 [Pol81] W. Polak. Program verification based on denotation semantics. In POPL 81: Proceedings of the 8th ACM SIGPLAN-SIGACT symposium on Principles of programming languages, pages , New York, NY, USA, ACM Press. [Sch00] S. Schupp. Lazy lists in C++. SIGPLAN Not., 35(6):47 54, [Set03] A. Setzer. Java as a functional programming language. In Herman Geuvers and Freek Wiedijk, editors, Types for Proofs and Programs: International Workshop, TYPES 2002, Berg en Dal, The Netherlands, April 24-28, Selected Papers., pages LNCS 2646,
A Provably Correct Translation of the λ-calculus into a Mathematical Model of C++
A Provably Correct Translation of the λ-calculus into a Mathematical Model of C++ Rose H. Abdul Rauf, Ulrich Berger, Anton Setzer November 9, 2006 Abstract We introduce a translation of the simply typed
More informationFunctional Concepts in C++
Chapter 1 Functional Concepts in C++ Rose H. Abdul Rauf 1, Ulrich Berger 2, Anton Setzer 2 3 Abstract: We describe a parser-translator program that translates typed λ-terms into C++ classes so as to integrate
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 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 informationMPRI course 2-4 Functional programming languages Exercises
MPRI course 2-4 Functional programming languages Exercises Xavier Leroy October 13, 2016 Part I: Interpreters and operational semantics Exercise I.1 (**) Prove theorem 2 (the unique decomposition theorem).
More informationThe Arrow Calculus (Functional Pearl)
The Arrow Calculus (Functional Pearl) Sam Lindley Philip Wadler Jeremy Yallop University of Edinburgh Abstract We introduce the arrow calculus, a metalanguage for manipulating Hughes s arrows with close
More informationBeluga: A Framework for Programming and Reasoning with Deductive Systems (System Description)
Beluga: A Framework for Programming and Reasoning with Deductive Systems (System Description) Brigitte Pientka and Joshua Dunfield McGill University, Montréal, Canada {bpientka,joshua}@cs.mcgill.ca Abstract.
More informationType Systems. Today. 1. Organizational Matters. 1. Organizational Matters. Lecture 1 Oct. 20th, 2004 Sebastian Maneth. 1. Organizational Matters
Today Type Systems 1. Organizational Matters 2. What is this course about? 3. Where do types come from? 4. Def. of the small language Expr. Its syntax and semantics. Lecture 1 Oct. 20th, 2004 Sebastian
More informationUniqueness Typing Redefined
Uniqueness Typing Redefined Edsko de Vries 1, Rinus Plasmeijer 2, and David Abrahamson 1 1 Trinity College Dublin, Ireland, {devriese,david}@cs.tcd.ie 2 Radboud Universiteit Nijmegen, Netherlands, rinus@cs.ru.nl
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 informationA Type System for Functional Traversal-Based Aspects
A Type System for Functional Traversal-Based Aspects Bryan Chadwick College of Computer & Information Science Northeastern University, 360 Huntington Avenue Boston, Massachusetts 02115 USA chadwick@ccs.neu.edu
More informationConclusions and further reading
Chapter 18 Conclusions and further reading We have not been exhaustive in the description of the Caml Light features. We only introduced general concepts in functional programming, and we have insisted
More informationDerivation of an Abstract Machine for λ-calculus with Delimited Continuation Constructs
Derivation of an Abstract Machine for λ-calculus with Delimited Continuation Constructs Arisa Kitani Kenich Asai Ochanomizu University 2-1-1 Otsuka, Bunkyo-ku, Tokyo 112-8610, Japan Abstract The goal of
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 informationExploring the Design Space of Higher-Order Casts ; CU-CS
University of Colorado, Boulder CU Scholar Computer Science Technical Reports Computer Science Fall 10-1-2008 Exploring the Design Space of Higher-Order Casts ; CU-CS-1047-08 Jeremy Siek University of
More informationType raising, continuations, and classical logic
Type raising, continuations, and classical logic Philippe de Groote Inria-Lorraine Abstract. There is a striking analogy between type raising, as introduced by Montague (973), and the notion of continuation
More informationCSE505, Fall 2012, Midterm Examination October 30, 2012
CSE505, Fall 2012, Midterm Examination October 30, 2012 Rules: The exam is closed-book, closed-notes, except for one side of one 8.5x11in piece of paper. Please stop promptly at Noon. You can rip apart
More informationA Type System for Functional Traversal-Based Aspects
A Type System for Functional Traversal-Based Aspects Bryan Chadwick and Karl Lieberherr March 2 nd 2009 1 / 30 Outline Introduction Example (Pure) Semantics Example (Full Dispatch) Type System Soundness
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 informationAccurate Step Counting
Accurate Step Counting Catherine Hope and Graham Hutton School of Computer Science and IT University of Nottingham, UK {cvh,gmh}@cs.nott.ac.uk Abstract Starting with an evaluator for a language, an abstract
More informationFUNCTIONAL PEARLS The countdown problem
To appear in the Journal of Functional Programming 1 FUNCTIONAL PEARLS The countdown problem GRAHAM HUTTON School of Computer Science and IT University of Nottingham, Nottingham, UK www.cs.nott.ac.uk/
More informationThe Worker/Wrapper Transformation
The Worker/Wrapper Transformation Andy Gill 1 Graham Hutton 2 1 Galois, Inc. 2 University of Nottingham February 6, 2008 Andy Gill, Graham Hutton The Worker/Wrapper Transformation February 6, 2008 1 /
More informationSémantique des Langages de Programmation (SemLP) DM : Region Types
Sémantique des Langages de Programmation (SemLP) DM : Region Types I) Submission Submission Date : 21/05/2017 Submission Format : Submit a virtual machine (.ova) 1 with 1. an executable of the interpreter,
More information4.8 Dependent Types 97
4.8 Dependent Types 97 4.8 Dependent Types We have encountered a number of constructors for propositions and types. Generally, propositions are constructed from simpler propositions, and types are constructed
More informationPolynomial Size Analysis for an Imperative Language
Polynomial Size Analysis for an Imperative Language Master Thesis Research Plan Rody Kersten Supervised by Marko van Eekelen February 16, 2009 Abstract Analysis of heap space consumption is a valuable
More informationRuntime Behavior of Conversion Interpretation of Subtyping
Runtime Behavior of Conversion Interpretation of Subtyping Yasuhiko Minamide Institute of Information Sciences and Electronics University of Tsukuba and PRESTO, JST minamide@is.tsukuba.ac.jp Abstract.
More informationPolymorphism and System-F (OV)
Polymorphism and System-F (OV) Theorie der Programmierung SoSe 2014 FAU the occurrence of something in several different forms Polymorphism? Polymorphic systems Type systems that allow a single piece of
More informationHutton, Graham and Bahr, Patrick (2016) Cutting out continuations. In: WadlerFest, April 2016, Edinburgh, Scotland.
Hutton, Graham and Bahr, Patrick (2016) Cutting out continuations. In: WadlerFest, 11-12 April 2016, Edinburgh, Scotland. Access from the University of Nottingham repository: http://eprints.nottingham.ac.uk/32703/1/cutting.pdf
More informationExtracting the Range of cps from Affine Typing
Extracting the Range of cps from Affine Typing Extended Abstract Josh Berdine, Peter W. O Hearn Queen Mary, University of London {berdine, ohearn}@dcs.qmul.ac.uk Hayo Thielecke The University of Birmingham
More informationDenotational Semantics. Domain Theory
Denotational Semantics and Domain Theory 1 / 51 Outline Denotational Semantics Basic Domain Theory Introduction and history Primitive and lifted domains Sum and product domains Function domains Meaning
More information1 Scope, Bound and Free Occurrences, Closed Terms
CS 6110 S18 Lecture 2 The λ-calculus Last time we introduced the λ-calculus, a mathematical system for studying the interaction of functional abstraction and functional application. We discussed the syntax
More informationOverview. A normal-order language. Strictness. Recursion. Infinite data structures. Direct denotational semantics. Transition semantics
Overview A normal-order language Strictness Recursion Infinite data structures Direct denotational semantics Transition semantics Lazy (call-by-need) evaluation and its semantics A Normal-Order Language
More informationProofs-Programs correspondance and Security
Proofs-Programs correspondance and Security Jean-Baptiste Joinet Université de Lyon & Centre Cavaillès, École Normale Supérieure, Paris Third Cybersecurity Japanese-French meeting Formal methods session
More informationLecture slides & distribution files:
Type Theory Lecture slides & distribution files: http://www.cs.rhul.ac.uk/home/zhaohui/ttlectures.html Zhaohui Luo Department of Computer Science Royal Holloway, University of London April 2011 2 Type
More informationOn Compilation and Call-by-Value Games. Ulrich Schöpp LMU Munich
On Compilation and Call-by-Value Games Ulrich Schöpp LMU Munich Motivation Understand low-level decompositions of high-level languages. let rec fib x = if x < 1 then 1 else (fib (x - 1)) + (fib (x - 2))...
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 informationCoinductive big-step operational semantics for type soundness of Java-like languages
Coinductive big-step operational semantics for type soundness of Java-like languages Davide Ancona DISI, University of Genova, Italy davide@disi.unige.it ABSTRACT We define a coinductive semantics for
More informationM. Snyder, George Mason University LAMBDA CALCULUS. (untyped)
1 LAMBDA CALCULUS (untyped) 2 The Untyped Lambda Calculus (λ) Designed by Alonzo Church (1930s) Turing Complete (Turing was his doctoral student!) Models functions, always as 1-input Definition: terms,
More informationThe Formal Semantics of Programming Languages An Introduction. Glynn Winskel. The MIT Press Cambridge, Massachusetts London, England
The Formal Semantics of Programming Languages An Introduction Glynn Winskel The MIT Press Cambridge, Massachusetts London, England Series foreword Preface xiii xv 1 Basic set theory 1 1.1 Logical notation
More informationCS 4110 Programming Languages & Logics. Lecture 28 Recursive Types
CS 4110 Programming Languages & Logics Lecture 28 Recursive Types 7 November 2014 Announcements 2 Foster office hours 11-12pm Guest lecture by Fran on Monday Recursive Types 3 Many languages support recursive
More informationTowards a Safe Partial Evaluation of Lazy Functional Logic Programs
WFLP 2007 Towards a Safe Partial Evaluation of Lazy Functional Logic Programs Sebastian Fischer 1 Department of Computer Science, University of Kiel Olshausenstr. 40, D-24098, Kiel, Germany Josep Silva
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 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 informationSemantics of Imperative Objects
Semantics of Imperative Objects Catalin Hritcu Supervisor: Jan Schwinghammer Responsible: Prof. Gert Smolka Programming Systems Lab Saarland University, Saarbrücken November 2006 1 Overview Imperative
More informationMore Untyped Lambda Calculus & Simply Typed Lambda Calculus
Concepts in Programming Languages Recitation 6: More Untyped Lambda Calculus & Simply Typed Lambda Calculus Oded Padon & Mooly Sagiv (original slides by Kathleen Fisher, John Mitchell, Shachar Itzhaky,
More informationCompiling Exceptions Correctly
Compiling Exceptions Correctly Graham Hutton and Joel Wright School of Computer Science and IT University of Nottingham, United Kingdom Abstract. Exceptions are an important feature of modern programming
More informationProgramming Languages Lecture 15: Recursive Types & Subtyping
CSE 230: Winter 2008 Principles of Programming Languages Lecture 15: Recursive Types & Subtyping Ranjit Jhala UC San Diego News? Formalize first-order type systems Simple types (integers and booleans)
More informationTyped Lambda Calculus for Syntacticians
Department of Linguistics Ohio State University January 12, 2012 The Two Sides of Typed Lambda Calculus A typed lambda calculus (TLC) can be viewed in two complementary ways: model-theoretically, as a
More informationn λxy.x n y, [inc] [add] [mul] [exp] λn.λxy.x(nxy) λmn.m[inc]0 λmn.m([add]n)0 λmn.n([mul]m)1
LAMBDA CALCULUS 1. Background λ-calculus is a formal system with a variety of applications in mathematics, logic, and computer science. It examines the concept of functions as processes, rather than the
More informationFaith, Evolution, and Programming Languages. Philip Wadler University of Edinburgh
Faith, Evolution, and Programming Languages Philip Wadler University of Edinburgh Evolution Multiculturalism Part I Church: The origins of faith Gerhard Gentzen (1909 1945) Gerhard Gentzen (1935) Natural
More informationLambda Calculus. Concepts in Programming Languages Recitation 6:
Concepts in Programming Languages Recitation 6: Lambda Calculus Oded Padon & Mooly Sagiv (original slides by Kathleen Fisher, John Mitchell, Shachar Itzhaky, S. Tanimoto ) Reference: Types and Programming
More informationCSE-321 Programming Languages 2014 Final
Name: Hemos ID: CSE-321 Programming Languages 2014 Final Problem 1 Problem 2 Problem 3 Problem 4 Problem 5 Problem 6 Total Score Max 15 12 14 14 30 15 100 There are six problems on 12 pages in this exam.
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 informationDerivation for the Necessity of Recursive Types and its Basic Usage
Derivation for the Necessity of Recursive Types and its Basic Usage Philipp Koster Supervised by Prof. Dr. Farhad D. Mehta Seminar AT 2016 1 Abstract This paper derives the need for recursive types by
More informationIdris, a language with dependent types Extended Abstract
Idris, a language with dependent types Extended Abstract Edwin Brady School of Computer Science, University of St Andrews, St Andrews, Scotland. Email: eb@cs.st-andrews.ac.uk. Tel: +44-1334-463253, Fax:
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 informationLecture Notes on Computational Interpretations of Modalities
Lecture Notes on Computational Interpretations of Modalities 15-816: Modal Logic Frank Pfenning Lecture 4 January 21, 2010 1 Introduction In this lecture we present the first two of many possible computational
More informationA Typed Calculus Supporting Shallow Embeddings of Abstract Machines
A Typed Calculus Supporting Shallow Embeddings of Abstract Machines Aaron Bohannon Zena M. Ariola Amr Sabry April 23, 2005 1 Overview The goal of this work is to draw a formal connection between steps
More informationAccurate Step Counting
Accurate Step Counting Catherine Hope and Graham Hutton University of Nottingham Abstract Starting with an evaluator for a language, an abstract machine for the same language can be mechanically derived
More informationProgramming with Dependent Types Interactive programs and Coalgebras
Programming with Dependent Types Interactive programs and Coalgebras Anton Setzer Swansea University, Swansea, UK 14 August 2012 1/ 50 A Brief Introduction into ML Type Theory Interactive Programs in Dependent
More informationCalculus INT. Value Types A, B ::= types of the low-level language Interactive Types X, Y ::= [A] A X X Y A X
Calculus INT Calculus INT Value Types A, B ::= types of the low-level language Interactive Types X, Y ::= [A] A X X Y A X X Y α A. X α A. X Related: Call-by-Push-Value [Levy 2004] Enrichted Effect Calculus
More informationBidirectional Certified Programming
Bidirectional Certified Programming Daisuke Kinoshita University of Electro-Communications kinoshita@ipl.cs.uec.ac.jp Keisuke Nakano University of Electro-Communications ksk@cs.uec.ac.jp Abstract Certified
More informationProgramming language design and analysis
Programming language design and analysis Introduction Marius Minea 25 September 2017 Why this course? Programming languages are fundamental and one of the oldest CS fields Language design is an important
More informationEta-equivalence in Core Dependent Haskell
Eta-equivalence in Core Dependent Haskell You should machine-check your proofs Stephanie Weirich University of Pennsylvania Core Dependent Haskell A Specification for Dependent Types in Haskell Stephanie
More informationTrees. Solution: type TreeF a t = BinF t a t LeafF 1 point for the right kind; 1 point per constructor.
Trees 1. Consider the following data type Tree and consider an example inhabitant tree: data Tree a = Bin (Tree a) a (Tree a) Leaf deriving Show tree :: Tree Int tree = Bin (Bin (Bin Leaf 1 Leaf ) 2 (Bin
More informationThunks (continued) Olivier Danvy, John Hatcli. Department of Computing and Information Sciences. Kansas State University. Manhattan, Kansas 66506, USA
Thunks (continued) Olivier Danvy, John Hatcli Department of Computing and Information Sciences Kansas State University Manhattan, Kansas 66506, USA e-mail: (danvy, hatcli)@cis.ksu.edu Abstract: Call-by-name
More informationVerified Characteristic Formulae for CakeML. Armaël Guéneau, Magnus O. Myreen, Ramana Kumar, Michael Norrish April 27, 2017
Verified Characteristic Formulae for CakeML Armaël Guéneau, Magnus O. Myreen, Ramana Kumar, Michael Norrish April 27, 2017 Goal: write programs in a high-level (ML-style) language, prove them correct interactively,
More informationImperative Functional Programming
Imperative Functional Programming Uday S. Reddy Department of Computer Science The University of Illinois at Urbana-Champaign Urbana, Illinois 61801 reddy@cs.uiuc.edu Our intuitive idea of a function is
More informationLecture 14: Recursive Types
Lecture 14: Recursive Types Polyvios Pratikakis Computer Science Department, University of Crete Type Systems and Programming Languages Pratikakis (CSD) Recursive Types CS546, 2018-2019 1 / 11 Motivation
More informationExercise 1 (2+2+2 points)
1 Exercise 1 (2+2+2 points) The following data structure represents binary trees only containing values in the inner nodes: data Tree a = Leaf Node (Tree a) a (Tree a) 1 Consider the tree t of integers
More informationFeatherweight Java (FJ)
x = 1 let x = 1 in... x(1).!x(1) x.set(1) Programming Language Theory Featherweight Java (FJ) Ralf Lämmel This lecture is based on David Walker s lecture: Computer Science 441, Programming Languages, Princeton
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 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 informationAutomata and Formal Languages - CM0081 Introduction to Agda
Automata and Formal Languages - CM0081 Introduction to Agda Andrés Sicard-Ramírez Universidad EAFIT Semester 2018-2 Introduction Curry-Howard correspondence Dependent types Constructivism Martin-Löf s
More informationPure Lambda Calculus. Lecture 17
Pure Lambda Calculus Lecture 17 Lambda Calculus Lambda Calculus (λ-calculus) is a functional notation introduced by Alonzo Church in the early 1930s to formalize the notion of computability. Pure λ-calculus
More informationLecture 9: More Lambda Calculus / Types
Lecture 9: More Lambda Calculus / Types CSC 131 Spring, 2019 Kim Bruce Pure Lambda Calculus Terms of pure lambda calculus - M ::= v (M M) λv. M - Impure versions add constants, but not necessary! - Turing-complete
More information- M ::= v (M M) λv. M - Impure versions add constants, but not necessary! - Turing-complete. - true = λ u. λ v. u. - false = λ u. λ v.
Pure Lambda Calculus Lecture 9: More Lambda Calculus / Types CSC 131 Spring, 2019 Kim Bruce Terms of pure lambda calculus - M ::= v (M M) λv. M - Impure versions add constants, but not necessary! - Turing-complete
More informationExample: A Compiler Fragment (1) Example: A Compiler Fragment (2) Example: A Compiler Fragment (3)
LiU-FP2016: Lecture 7 Monads Henrik Nilsson University of Nottingham, UK Example: A Compiler Fragment (1) Identification is the task of relating each applied identifier occurrence to its declaration or
More informationCS152: Programming Languages. Lecture 11 STLC Extensions and Related Topics. Dan Grossman Spring 2011
CS152: Programming Languages Lecture 11 STLC Extensions and Related Topics Dan Grossman Spring 2011 Review e ::= λx. e x e e c v ::= λx. e c τ ::= int τ τ Γ ::= Γ, x : τ (λx. e) v e[v/x] e 1 e 1 e 1 e
More informationMikiβ : A General GUI Library for Visualizing Proof Trees
Mikiβ : A General GUI Library for Visualizing Proof Trees System Description and Demonstration Kanako Sakurai and Kenichi Asai Ochanomizu University, Japan {sakurai.kanako,asai}@is.ocha.ac.jp Abstract.
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 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 informationFunctions as data. Massimo Merro. 9 November Massimo Merro The Lambda language 1 / 21
Functions as data Massimo Merro 9 November 2011 Massimo Merro The Lambda language 1 / 21 The core of sequential programming languages In the mid 1960s, Peter Landin observed that a complex programming
More 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 informationIntroduction to the Lambda Calculus. Chris Lomont
Introduction to the Lambda Calculus Chris Lomont 2010 2011 2012 www.lomont.org Leibniz (1646-1716) Create a universal language in which all possible problems can be stated Find a decision method to solve
More 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 information5. Semantic Analysis!
5. Semantic Analysis! Prof. O. Nierstrasz! Thanks to Jens Palsberg and Tony Hosking for their kind permission to reuse and adapt the CS132 and CS502 lecture notes.! http://www.cs.ucla.edu/~palsberg/! http://www.cs.purdue.edu/homes/hosking/!
More informationType Inference with Recursive Type Equations
Type Inference with Recursive Type Equations Mario Coppo Dipartimento di Informatica, Università di Torino, Corso Svizzera 185, 10149 Torino, Italy coppo@di.unito.it http://www.di.unito.it/ coppo Abstract.
More informationConstrained Types and their Expressiveness
Constrained Types and their Expressiveness JENS PALSBERG Massachusetts Institute of Technology and SCOTT SMITH Johns Hopkins University A constrained type consists of both a standard type and a constraint
More informationNote that in this definition, n + m denotes the syntactic expression with three symbols n, +, and m, not to the number that is the sum of n and m.
CS 6110 S18 Lecture 8 Structural Operational Semantics and IMP Today we introduce a very simple imperative language, IMP, along with two systems of rules for evaluation called small-step and big-step semantics.
More informationML Has Principal Typings
Electronic Notes in Theoretical Computer Science 38 (2005) URL: http://www.elsevier.nl/locate/entcs/volume38.html ML Has Principal Typings Carlos Camarão and Lucília Figueiredo Abstract Is there a type
More informationIdioms are oblivious, arrows are meticulous, monads are promiscuous
MSFP 2008 Idioms are oblivious, arrows are meticulous, monads are promiscuous Sam Lindley, Philip Wadler and Jeremy Yallop Laboratory for Foundations of Computer Science The University of Edinburgh Abstract
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 informationContinuation Passing Style. Continuation Passing Style
161 162 Agenda functional programming recap problem: regular expression matcher continuation passing style (CPS) movie regular expression matcher based on CPS correctness proof, verification change of
More informationNormalization by Evaluation in the Delay Monad A Case Study for Coinduction via Copatterns and Sized Types
Normalization by Evaluation in the Delay Monad A Case Study for Coinduction via Copatterns and Sized Types Andreas Abel Department of Computer Science and Engineering Chalmers University of Technology
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 informationFoundational Aspects of Syntax 1
Foundational Aspects of Syntax 1 Introduction Dale Miller and Catuscia Palamidessi Department of Computer Science and Engineering The Pennsylvania State University 220 Pond Laboratory University Park,
More informationA native compiler for Coq: current status, perspectives and discussion 1
A native compiler for Coq A native compiler for Coq: current status, perspectives and discussion 1 Maxime Dénès, jww M. Boespflug and B. Grégoire Marelle Team, INRIA Sophia-Antipolis February 19, 2013
More informationCS 6110 S14 Lecture 1 Introduction 24 January 2014
CS 6110 S14 Lecture 1 Introduction 24 January 2014 1 Introduction What is a program? Is it just something that tells the computer what to do? Yes, but there is much more to it than that. The basic expressions
More informationEXAMINATIONS 2007 END YEAR COMP471 COMPILER TECHNOLOGIES. Instructions: Read each question carefully before attempting it.
T E W H A R E W Ā N A N G A O T E Ū P O K O O T E I K A A M Ā U I VUW V I C T O R I A UNIVERSITY OF WELLINGTON EXAMINATIONS 2007 END YEAR COMP471 COMPILER TECHNOLOGIES Time Allowed: 3 Hours Instructions:
More information