What does my program mean?
|
|
- Conrad Osborne
- 5 years ago
- Views:
Transcription
1 September 16, 2015 L02-1 What does my program mean? Armando Solar Lezama Computer Science and Artificial Intelligence Laboratory M.I.T. Adapted from Arvind Used with permission. September 16, 2015
2 Meaning of a term The semantics must distinguish between terms that should not be equal, i.e., if September 16, x. y. y; 1 x. y. x y; 2 x. y. x (x y) Then x. y. y x. y. x y x. y. x (x y) The semantics must equate terms that should be equal, i.e., the terms corresponding to (plus 0 1) and 1 must have the same meaning A semantics is said to be fully abstract if two terms have different meaning according to the semantics then there exists a term that can tell them apart In the -calculus it is possible to define the meaning of a term almost syntactically L02-2
3 Information content of a term Instantaneous information: A term obtained by replacing each redex in a term by where stands for no information Term ( q. p.p (q a)) ( z.z) p.p (( z.z) a)) p.p a Instantaneous information p.p p.p a b-reductions monotonically increase information The meaning of a term is the maximum information that can be obtained by b-reductions September 16, 2015 L02-3
4 Is the meaning of a term simply its normal form? Yes, but... What if a term doesn t have a normal form? Is the meaning of such terms always? Consider = ( x.x x) ( x.x x) It doesn t have a normal form, and its meaning is What about x.x? It doesn t have a normal form, but its meaning is x.x What if a term has more than one normal form? It would have two meanings. BAD Not possible in the -calculus because of Confluence... September 16, 2015 L02-4
5 Can the choice of redexes lead to different meaning? A term may have multiple redexes 1. (( x.m) A) (( x.n) B) (( x.m) (( y.n)b)) followed by does not necessary produce the same term as followed by Notice in the second example can destroy or duplicate Can our choice of redexes lead us to produce terms that are clearly different (e.g., x versus y.y)? September 16, 2015 L02-5
6 Church-Rosser Property A reduction system is said to have the Church-Rosser property, if E E 1 and E E 2 then there exits a E 3 such that E E and E E 3. E E 1 E 2 E 3 also known as CR or Confluence If a system has the CR property then the divergence in terms due to the choice of redexes can be corrected September 16, 2015 L02-6
7 Church-Rosser Theorem Theorem: The -calculus is CR. (Martin-Lof & Tate) No satisfactory proof of this theorem was given until 1970 (30 years later!) The proof is elegant Requires showing how two divergent terms can be brought together in finite number of steps strategy for choosing reductions CR implies that if NF exists it is unique September 16, 2015 L02-7
8 Interpreters An interpreter for the -calculus is a program to reduce -expressions to answers. Requires: the definition of an answer - e.g., normal form? a reduction strategy - a method to choose redexes in an expression September 16, 2015 L02-8
9 September 16, 2015 L02-9 Definitions of Answers Normal form (NF): an expression without redexes Head normal form (HNF): x is HNF ( x.e) is in HNF if E is in HNF (x E 1... E n ) is in HNF Semantically most interesting- represents the information content of an expression Weak head normal form (WHNF): An expression in which the left most application is not a redex. x is in WHNF ( x.e) is in WHNF (x E 1... E n ) is in WHNF Practically most interesting Printable Answers
10 Two Common Reduction Strategies applicative order: right-most innermost redex aka call by value evaluation normal order: left-most (outermost) redex aka call by name evaluation ( x.y) (( x.x x) ( x.x x)) 1 2 applicative order normal order September 16, 2015 L02-10
11 September 16, 2015 L02-11 Computing a normal form 1. Every -expression does not have an answer i.e., a NF or HNF or WHNF ( x.x x) ( x.x x) = 3. Even if an expression has an answer, not all reduction strategies may produce it ( x. y.y) leftmost redex: ( x. y.y) y.y innermost redex: ( x. y.y) ( x. y. y)...
12 September 16, 2015 L02-12 Normalizing Strategy A reduction strategy is said to be normalizing if it terminates and produces an answer of an expression whenever the expression has an answer. aka the standard reduction Theorem: Normal order (left-most) reduction strategy is normalizing for the -calculus.
13 September 16, 2015 L02-13 A Call-by-name Interpreter Answers: Strategy: WHNF leftmost redex Apply the function before evaluating the arguments cn(e): Definition by cases on E E = x x.e E E [...] represents syntax [[...]] is my ppt approx cn([[x]]) = x cn([[ x.e]]) = x.e cn([[e 1 E 2 ]]) = let f = cn(e 1 ) in case f of x.e 3 = _ = Meta syntax cn(e 3 [E 2 /x]) f E 2
14 September 16, 2015 L02-14 A Call-by-value Interpreter Answers: Strategy: cv(e): WHNF rightmost-innermost redex but not inside a -abstraction Evaluate the argument before applying the function Definition by cases on E E = x x.e E E cv([[x]]) = x cv([[ x.e]]) = x.e cv([[e 1 E 2 ]]) = let f = cv(e 1 ) a = cv(e 2 ) in case f of x.e 3 = _ = cv(e 3 [a/x]) f a
15 Coding this in Haskell with Algebraic Data Types September 16, 2015 L02-15
16 September 20, 2011 L02-16 Algebraic types Algebraic types are tagged unions of products Example keyword data Shape = Line Pnt Pnt Triangle Pnt Pnt Pnt Quad Pnt Pnt Pnt Pnt "union" new type "products (fields) - new "constructors" (a.k.a. "tags", "disjuncts", "summands") - a k-ary constructor is applied to k type expressions
17 September 20, 2011 L02-17 Examples of Algebraic types data Bool = False True data Day = Sun Mon Tue Wed Thu Fri Sat data Maybe a = Nothing Just a data List a = Nil Cons a (List a) data Tree a = Leaf a Node (Tree a) (Tree a) data Tree a b = Leaf a Nonleaf b (Tree a b) (Tree a b) data Course = Course String Int String (List Course) name number description pre-reqs
18 September 20, 2011 L02-18 Constructors are functions Constructors can be used as functions to create values of the type let in l1 :: Shape l1 = Line e1 e2 t1 :: Shape = Triangle e3 e4 e5 q1 :: Shape = Quad e6 e7 e8 e9... where each "ej" is an expression of type "Pnt"
19 September 20, 2011 L02-19 Pattern-matching on algebraic types Pattern-matching is used to examine values of an algebraic type anchorpnt :: Shape -> Pnt anchorpnt s = case s of Line p1 p2 -> p1 Triangle p3 p4 p5 -> p3 Quad p6 p7 p8 p9 -> p6 A pattern-match has two roles: A test: "does the given value match this pattern?" Binding ("if the given value matches the pattern, bind the variables in the pattern to the corresponding parts of the value") Clauses are examined top-to-bottom and left-to-right for pattern matching
20 September 16, 2015 L02-20 Big Step Semantics
21 Big Step Operational Semantics Model the execution in an abstract machine Basic Notation: Judgments Some alternative notations: describe how a program configuration is evaluated into a result the configuration is usually a program fragment together with any state. Basic Notation: Inference rules define how to derive judgments for an arbitrary program also called derivation rules or evaluation rules usually defined recursively L02-21
22 What evaluation order is this? Call by Name cn([[x]]) = x cn([[ x.e]]) = x.e cn([[e 1 E 2 ]])= let f = cn(e 1 ) in case f of x.e 3 = cn(e 3 [E 2 /x]) _ = f E 2 Do these semantics coincide? L02-22
23 What evaluation order is this? Call by Value cv([[x]]) = x cv([[ x.e]]) = x.e cv([[e 1 E 2 ]])= let f = cv(e 1 ) a = cv(e 2 ) in case f of x.e 3 = cv(e 3 [a/x]) _ = f a L02-23
24 Recursion and the Y Combinator L02-24
25 September 16, 2015 L02-25 Recursion and Fixed Point Equations Recursive functions can be thought of as solutions of fixed point equations: fact = n. Cond (Zero? n) 1 (Mul n (fact (Sub n 1))) Suppose then H = f. n.cond (Zero? n) 1 (Mul n (f (Sub n 1))) fact = H fact fact is a fixed point of function H!
26 September 16, 2015 L02-26 Fixed Point Equations f : D D A fixed point equation has the form f(x) = x Its solutions are called the fixed points of f because if x p is a solution then x p = f(x p ) = f(f(x p )) = f(f(f(x p ))) =... We want to consider fixed-point equations whose solutions are functions, i.e., sets that contain their function spaces domain theory, Scottary,...
27 September 16, 2015 L02-27 An example Consider f n = if n=0 then 1 else (if n=1 then f 3 else f (n-2)) H = f. n.cond(n=0, 1, Cond(n=1, f 3, f (n-2)) Is there an f p such that f p = H f p? f1 n = 1 if n is even = otherwise f2 n = 1 if n is even = 5 otherwise f1 contains no arbitrary information and is said to be the least fixed point (lfp) Under the assumption of monotonicity and continuity least fixed points are unique and computable
28 September 16, 2015 L02-28 Computing a Fixed Point Recursion requires repeated application of a function Self application allows us to recreate the original term Consider: = ( x. x x) ( x. x x) Notice b-reduction of leaves : Now to get F (F (F (F...))) we insert F in : F = ( x.f (x x)) ( x.f (x x)) which b-reduces to: F F( x. F(x x))( x. F(x x)) F F F(F F ) F(F(F F ))... Now -abstract F to get a Fix-Point Combinator: Y f.( x. (f (x x))) ( x.(f (x x)))
29 September 16, 2015 L02-29 Y : A Fixed Point Operator Y f.( x. (f (x x))) ( x.(f (x x))) Notice Y F ( x.f (x x)) ( x.f (x x)) F ( x.f (x x)) ( x.f (x x)) F (Y F) F (Y F) = Y F (Y F) is a fixed point of F Y computes the least fixed point of any function! There are many different fixed point operators.
30 September 16, 2015 L02-30 Mutual Recursion odd n = if n==0 then False else even (n-1) even n = if n==0 then True else odd (n-1) odd = H 1 even even = H 2 odd where H 1 = f. n.cond(n=0, False, f(n-1)) H 2 = f. n.cond(n=0, True, f(n-1)) substituting H 2 odd for even odd = H 1 (H 2 odd) = H odd where H = odd = Y H Can we express odd using Y? f. H 1 (H 2 f)
31 September 16, 2015 L02-31 Self-application and Paradoxes Self application, i.e., (x x) is dangerous. Suppose: u y. if (y y) = a then b else a What is (u u)? (u u) if (u u) = a then b else a Contradiction!!! Any semantics of -calculus has to make sure that functions such as u have the meaning, i.e. totally undefined or no information. Self application also violates every type discipline.
32 September 16, 2015 L calculus with Combinator Y Recursive programs can be translated into the -calculus with constants and combinator Y. However, Y violates every type discipline translation is messy in case of mutually recursive functions extend the -calculus with recursive let blocks. The let Calculus
33 MIT OpenCourseWare Fundamentals of Program Analysis Fall 2015 For information about citing these materials or our Terms of Use, visit:
Overloading, Type Classes, and Algebraic Datatypes
Overloading, Type Classes, and Algebraic Datatypes Delivered by Michael Pellauer Arvind Computer Science and Artificial Intelligence Laboratory M.I.T. September 28, 2006 September 28, 2006 http://www.csg.csail.mit.edu/6.827
More informationn n Try tutorial on front page to get started! n spring13/ n Stack Overflow!
Announcements n Rainbow grades: HW1-6, Quiz1-5, Exam1 n Still grading: HW7, Quiz6, Exam2 Intro to Haskell n HW8 due today n HW9, Haskell, out tonight, due Nov. 16 th n Individual assignment n Start early!
More informationCSE 3302 Programming Languages Lecture 8: Functional Programming
CSE 3302 Programming Languages Lecture 8: Functional Programming (based on the slides by Tim Sheard) Leonidas Fegaras University of Texas at Arlington CSE 3302 L8 Spring 2011 1 Functional Programming Languages
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/ October 13, 2004 Lambda Calculus and Type
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 informationGetting Started with Haskell (10 points)
Massachusetts Institute of Technology Department of Electrical Engineering and Computer Science 6.820 Foundations of Program Analysis Problem Set 1 Out: September 9, 2015 Due: September 22, 2015 at 5 PM
More information(Refer Slide Time: 4:00)
Principles of Programming Languages Dr. S. Arun Kumar Department of Computer Science & Engineering Indian Institute of Technology, Delhi Lecture - 38 Meanings Let us look at abstracts namely functional
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 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 informationCOMP80 Lambda Calculus Programming Languages Slides Courtesy of Prof. Sam Guyer Tufts University Computer Science History Big ideas Examples:
COMP80 Programming Languages Slides Courtesy of Prof. Sam Guyer Lambda Calculus Formal system with three parts Notation for functions Proof system for equations Calculation rules called reduction Idea:
More informationProgramming Language Concepts: Lecture 19
Programming Language Concepts: Lecture 19 Madhavan Mukund Chennai Mathematical Institute madhavan@cmi.ac.in http://www.cmi.ac.in/~madhavan/courses/pl2009 PLC 2009, Lecture 19, 01 April 2009 Adding types
More informationFunctional Programming. Overview. Topics. Recall λ-terms. Examples
Topics Functional Programming Christian Sternagel Harald Zankl Evgeny Zuenko Department of Computer Science University of Innsbruck WS 2017/2018 abstract data types, algebraic data types, binary search
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 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 informationCITS3211 FUNCTIONAL PROGRAMMING. 14. Graph reduction
CITS3211 FUNCTIONAL PROGRAMMING 14. Graph reduction Summary: This lecture discusses graph reduction, which is the basis of the most common compilation technique for lazy functional languages. CITS3211
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 informationGetting Started with Haskell (10 points)
Massachusetts Institute of Technology Department of Electrical Engineering and Computer Science 6.827 Multithreaded Parallelism: Languages and Compilers Problem Set 1 Out: September 19, 2006 Due: October
More informationFunctional Programming
Functional Programming COMS W4115 Prof. Stephen A. Edwards Spring 2003 Columbia University Department of Computer Science Original version by Prof. Simon Parsons Functional vs. Imperative Imperative programming
More informationCS 457/557: Functional Languages
CS 457/557: Functional Languages Lists and Algebraic Datatypes Mark P Jones Portland State University 1 Why Lists? Lists are a heavily used data structure in many functional programs Special syntax is
More informationFrom the λ-calculus to Functional Programming Drew McDermott Posted
From the λ-calculus to Functional Programming Drew McDermott drew.mcdermott@yale.edu 2015-09-28 Posted 2015-10-24 The λ-calculus was intended from its inception as a model of computation. It was used by
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 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 informationType Inference Systems. Type Judgments. Deriving a Type Judgment. Deriving a Judgment. Hypothetical Type Judgments CS412/CS413
Type Inference Systems CS412/CS413 Introduction to Compilers Tim Teitelbaum Type inference systems define types for all legal programs in a language Type inference systems are to type-checking: As regular
More informationUrmas Tamm Tartu 2013
The implementation and optimization of functional languages Urmas Tamm Tartu 2013 Intro The implementation of functional programming languages, Simon L. Peyton Jones, 1987 Miranda fully lazy strict a predecessor
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 informationTypes. Type checking. Why Do We Need Type Systems? Types and Operations. What is a type? Consensus
Types Type checking What is a type? The notion varies from language to language Consensus A set of values A set of operations on those values Classes are one instantiation of the modern notion of type
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 information1.3. Conditional expressions To express case distinctions like
Introduction Much of the theory developed in the underlying course Logic II can be implemented in a proof assistant. In the present setting this is interesting, since we can then machine extract from a
More informationCSCI-GA Scripting Languages
CSCI-GA.3033.003 Scripting Languages 12/02/2013 OCaml 1 Acknowledgement The material on these slides is based on notes provided by Dexter Kozen. 2 About OCaml A functional programming language All computation
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
Resources: The slides of this lecture were derived from [Järvi], with permission of the original author, by copy & x = 1 let x = 1 in... paste or by selection, annotation, or rewording. [Järvi] is in turn
More informationIntroduction to Functional Programming in Haskell 1 / 56
Introduction to Functional Programming in Haskell 1 / 56 Outline Why learn functional programming? The essence of functional programming What is a function? Equational reasoning First-order vs. higher-order
More informationProgramming Languages Lecture 14: Sum, Product, Recursive Types
CSE 230: Winter 200 Principles of Programming Languages Lecture 4: Sum, Product, Recursive Types The end is nigh HW 3 No HW 4 (= Final) Project (Meeting + Talk) Ranjit Jhala UC San Diego Recap Goal: Relate
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 informationFundamental Concepts. Chapter 1
Chapter 1 Fundamental Concepts This book is about the mathematical foundations of programming, with a special attention on computing with infinite objects. How can mathematics help in programming? There
More informationJ. Barkley Rosser, 81, a professor emeritus of mathematics and computer science at the University of Wisconsin who had served in government, died
Church-Rosser J. Barkley Rosser, 81, a professor emeritus of mathematics and computer science at the University of Wisconsin who had served in government, died Sept. 5, 1989. Along with Alan Turing and
More informationQIR Specification. Romain Vernoux. January 6, Notations 2
QIR Specification Romain Vernoux January 6, 2017 Contents 1 Notations 2 2 Architecture 3 3 QIR data model, expressions and operators 4 3.1 QIR data model.................................... 4 3.2 QIR operators.....................................
More informationReview. CS152: Programming Languages. Lecture 11 STLC Extensions and Related Topics. Let bindings (CBV) Adding Stuff. Booleans and Conditionals
Review CS152: Programming Languages Lecture 11 STLC Extensions and Related Topics e ::= λx. e x ee c v ::= λx. e c (λx. e) v e[v/x] e 1 e 2 e 1 e 2 τ ::= int τ τ Γ ::= Γ,x : τ e 2 e 2 ve 2 ve 2 e[e /x]:
More informationHomework 3 COSE212, Fall 2018
Homework 3 COSE212, Fall 2018 Hakjoo Oh Due: 10/28, 24:00 Problem 1 (100pts) Let us design and implement a programming language called ML. ML is a small yet Turing-complete functional language that supports
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 informationCOSE212: Programming Languages. Lecture 3 Functional Programming in OCaml
COSE212: Programming Languages Lecture 3 Functional Programming in OCaml Hakjoo Oh 2017 Fall Hakjoo Oh COSE212 2017 Fall, Lecture 3 September 18, 2017 1 / 44 Why learn ML? Learning ML is a good way of
More informationThe Substitution Model
The Substitution Model Prof. Clarkson Fall 2017 Today s music: Substitute by The Who Review Previously in 3110: simple interpreter for expression language abstract syntax tree (AST) evaluation based on
More informationThe Untyped Lambda Calculus
Resources: The slides of this lecture were derived from x = 1 [Järvi], with permission of the original author, by copy & let x = 1 in... paste or by selection, annotation, or rewording. [Järvi] is in turn
More informationCMSC 330: Organization of Programming Languages
CMSC 330: Organization of Programming Languages Operational Semantics CMSC 330 Summer 2018 1 Formal Semantics of a Prog. Lang. Mathematical description of the meaning of programs written in that language
More informationPropositional Logic. Part I
Part I Propositional Logic 1 Classical Logic and the Material Conditional 1.1 Introduction 1.1.1 The first purpose of this chapter is to review classical propositional logic, including semantic tableaux.
More informationExercise 1 ( = 24 points)
1 Exercise 1 (4 + 5 + 4 + 6 + 5 = 24 points) The following data structure represents polymorphic binary trees that contain values only in special Value nodes that have a single successor: data Tree a =
More informationCS558 Programming Languages
CS558 Programming Languages Winter 2017 Lecture 7b Andrew Tolmach Portland State University 1994-2017 Values and Types We divide the universe of values according to types A type is a set of values and
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 informationLecture #13: Type Inference and Unification. Typing In the Language ML. Type Inference. Doing Type Inference
Lecture #13: Type Inference and Unification Typing In the Language ML Examples from the language ML: fun map f [] = [] map f (a :: y) = (f a) :: (map f y) fun reduce f init [] = init reduce f init (a ::
More informationFunctional Programming. Big Picture. Design of Programming Languages
Functional Programming Big Picture What we ve learned so far: Imperative Programming Languages Variables, binding, scoping, reference environment, etc What s next: Functional Programming Languages Semantics
More informationThe type checker will complain that the two branches have different types, one is string and the other is int
1 Intro to ML 1.1 Basic types Need ; after expression - 42 = ; val it = 42 : int - 7+1; val it = 8 : int Can reference it - it+2; val it = 10 : int - if it > 100 then "big" else "small"; val it = "small"
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 informationFundamentals 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 informationIntroduction to OCaml
Fall 2018 Introduction to OCaml Yu Zhang Course web site: http://staff.ustc.edu.cn/~yuzhang/tpl References Learn X in Y Minutes Ocaml Real World OCaml Cornell CS 3110 Spring 2018 Data Structures and Functional
More informationData Types. Prof. Clarkson Fall Today s music: Pokémon Theme by Jason Paige
Data Types Prof. Clarkson Fall 2016 Today s music: Pokémon Theme by Jason Paige Review Previously in 3110: Functions Lists Today: Let expressions Ways to define your own data types: variants, records,
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 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 informationCourse Notes Equational Programming: Lambda Calculus. Femke van Raamsdonk
Course Notes Equational Programming: Lambda Calculus Femke van Raamsdonk November 8, 2018 2 Contents 1 Introduction 5 2 Terms and Reduction 7 2.1 Lambda terms............................ 7 2.2 Beta reduction............................
More informationCS 320 Midterm Exam. Fall 2018
Name: BU ID: CS 320 Midterm Exam Fall 2018 Write here the number of the problem you are skipping: You must complete 5 of the 6 problems on this exam for full credit. Each problem is of equal weight. Please
More informationA Small Interpreted Language
A Small Interpreted Language What would you need to build a small computing language based on mathematical principles? The language should be simple, Turing equivalent (i.e.: it can compute anything that
More informationConstraint-based Analysis. Harry Xu CS 253/INF 212 Spring 2013
Constraint-based Analysis Harry Xu CS 253/INF 212 Spring 2013 Acknowledgements Many slides in this file were taken from Prof. Crista Lope s slides on functional programming as well as slides provided by
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 informationResources: The slides of this lecture were derived from [Järvi], with permission of the original author, by copy & x = 1 let x = 1 in...
Resources: The slides of this lecture were derived from [Järvi], with permission of the original author, by copy & x = 1 let x = 1 in... paste or by selection, annotation, or rewording. [Järvi] is in turn
More informationRecursive Types and Subtyping
Recursive Types and Subtyping #1 One-Slide Summary Recursive types (e.g., list) make the typed lambda calculus as powerful as the untyped lambda calculus. If is a subtype of then any expression of type
More informationMeta-programming with Names and Necessity p.1
Meta-programming with Names and Necessity Aleksandar Nanevski Carnegie Mellon University ICFP, Pittsburgh, 05 October 2002 Meta-programming with Names and Necessity p.1 Meta-programming Manipulation of
More informationProgramming Languages Third Edition
Programming Languages Third Edition Chapter 12 Formal Semantics Objectives Become familiar with a sample small language for the purpose of semantic specification Understand operational semantics Understand
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 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 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 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 informationModule 6. Knowledge Representation and Logic (First Order Logic) Version 2 CSE IIT, Kharagpur
Module 6 Knowledge Representation and Logic (First Order Logic) 6.1 Instructional Objective Students should understand the advantages of first order logic as a knowledge representation language Students
More informationThe Untyped Lambda Calculus
Resources: The slides of this lecture were derived from [Järvi], with permission of the original author, by copy & x = 1 let x = 1 in... paste or by selection, annotation, or rewording. [Järvi] is in turn
More informationExercise 1 ( = 18 points)
1 Exercise 1 (4 + 5 + 4 + 5 = 18 points) The following data structure represents polymorphic binary trees that contain values only in special Value nodes that have a single successor: data Tree a = Leaf
More informationCSE 505: Concepts of Programming Languages
CSE 505: Concepts of Programming Languages Dan Grossman Fall 2009 Lecture 4 Proofs about Operational Semantics; Pseudo-Denotational Semantics Dan Grossman CSE505 Fall 2009, Lecture 4 1 This lecture Continue
More informationData Types. Guest Lecture: Andrew Myers Spring 2018
Data Types Guest Lecture: Andrew Myers Spring 2018 Review Previously in 3110: Functions Lists Today: Let expressions Ways to define your own data types: variants, records, tuples LET EXPRESSIONS Let expressions
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 informationGraphical Untyped Lambda Calculus Interactive Interpreter
Graphical Untyped Lambda Calculus Interactive Interpreter (GULCII) Claude Heiland-Allen https://mathr.co.uk mailto:claude@mathr.co.uk Edinburgh, 2017 Outline Lambda calculus encodings How to perform lambda
More informationCMSC 330: Organization of Programming Languages. OCaml Expressions and Functions
CMSC 330: Organization of Programming Languages OCaml Expressions and Functions CMSC330 Spring 2018 1 Lecture Presentation Style Our focus: semantics and idioms for OCaml Semantics is what the language
More informationFunctional Programming
Functional Programming Overview! Functional vs. imperative programming! Fundamental concepts! Evaluation strategies! Pattern matching! Higher order functions! Lazy lists References! Richard Bird, Introduction
More informationCMSC 330: Organization of Programming Languages. Formal Semantics of a Prog. Lang. Specifying Syntax, Semantics
Recall Architecture of Compilers, Interpreters CMSC 330: Organization of Programming Languages Source Scanner Parser Static Analyzer Operational Semantics Intermediate Representation Front End Back End
More informationProving the Genericity Lemma by Leftmost Reduction is Simple
Proving the Genericity Lemma by Leftmost Reduction is Simple Jan Kuper University of Twente, Department of Computer Science P.O.Box 217, 7500 AE Enschede, The Netherlands e-mail: jankuper~cs.utwente.ul
More informationDenotational semantics
1 Denotational semantics 2 What we're doing today We're looking at how to reason about the effect of a program by mapping it into mathematical objects Specifically, answering the question which function
More informationData Types The ML Type System
7 Data Types 7.2.4 The ML Type System The following is an ML version of the tail-recursive Fibonacci function introduced Fibonacci function in ML in Section 6.6.1: EXAMPLE 7.96 1. fun fib (n) = 2. let
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 informationLecture Notes on Aggregate Data Structures
Lecture Notes on Aggregate Data Structures 15-312: Foundations of Programming Languages Frank Pfenning Lecture 8 September 23, 2004 In this lecture we discuss various language extensions which make MinML
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 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 informationCSCE 314 Programming Languages
CSCE 314 Programming Languages Haskell: Declaring Types and Classes Dr. Hyunyoung Lee 1 Outline Declaring Data Types Class and Instance Declarations 2 Defining New Types Three constructs for defining types:
More informationLambda Calculus LC-1
Lambda Calculus LC-1 λ- Calculus History-1 Developed by Alonzo Church during 1930 s-40 s One fundamental goal was to describe what can be computed. Full definition of λ-calculus is equivalent in power
More information3.4 Deduction and Evaluation: Tools Conditional-Equational Logic
3.4 Deduction and Evaluation: Tools 3.4.1 Conditional-Equational Logic The general definition of a formal specification from above was based on the existence of a precisely defined semantics for the syntax
More informationLists. Michael P. Fourman. February 2, 2010
Lists Michael P. Fourman February 2, 2010 1 Introduction The list is a fundamental datatype in most functional languages. ML is no exception; list is a built-in ML type constructor. However, to introduce
More informationProject 2: Scheme Interpreter
Project 2: Scheme Interpreter CSC 4101, Fall 2017 Due: 12 November 2017 For this project, you will implement a simple Scheme interpreter in C++ or Java. Your interpreter should be able to handle the same
More informationTyped Lambda Calculus
Department of Linguistics Ohio State University Sept. 8, 2016 The Two Sides of A typed lambda calculus (TLC) can be viewed in two complementary ways: model-theoretically, as a system of notation for functions
More informationOn Meaning Preservation of a Calculus of Records
On Meaning Preservation of a Calculus of Records Emily Christiansen and Elena Machkasova Computer Science Discipline University of Minnesota, Morris Morris, MN 56267 chri1101, elenam@morris.umn.edu Abstract
More informationScheme. Functional Programming. Lambda Calculus. CSC 4101: Programming Languages 1. Textbook, Sections , 13.7
Scheme Textbook, Sections 13.1 13.3, 13.7 1 Functional Programming Based on mathematical functions Take argument, return value Only function call, no assignment Functions are first-class values E.g., functions
More information9/23/2014. Why study? Lambda calculus. Church Rosser theorem Completeness of Lambda Calculus: Turing Complete
Dr A Sahu Dept of Computer Science & Engineering IIT Guwahati Why study? Lambda calculus Syntax Evaluation Relationship to programming languages Church Rosser theorem Completeness of Lambda Calculus: Turing
More informationChapter 2 The Language PCF
Chapter 2 The Language PCF We will illustrate the various styles of semantics of programming languages with an example: the language PCF Programming language for computable functions, also called Mini-ML.
More informationTo figure this out we need a more precise understanding of how ML works
Announcements: What are the following numbers: 74/2/70/17 (2:30,2:30,3:35,7:30) PS2 due Thursday 9/20 11:59PM Guest lecture on Tuesday 9/25 o No RDZ office hours next Friday, I am on travel A brief comment
More information