1 SML fn x => e e 1 e 2 0, 1, 2,..., +, -,... true, false, if e then e else e patterns datatypes exceptions structures functors fun f x = e variables.

Slides:



Advertisements
Similar presentations
Types and Programming Languages Lecture 7 Simon Gay Department of Computing Science University of Glasgow 2006/07.
Advertisements

The lambda calculus David Walker CS 441. the lambda calculus Originally, the lambda calculus was developed as a logic by Alonzo Church in 1932 –Church.
Tim Sheard Oregon Graduate Institute Lecture 8: Operational Semantics of MetaML CSE 510 Section FSC Winter 2005 Winter 2005.
8. Introduction to Denotational Semantics. © O. Nierstrasz PS — Denotational Semantics 8.2 Roadmap Overview:  Syntax and Semantics  Semantics of Expressions.
CSE-321 Programming Languages Predicative Polymorphic -Calculus POSTECH May 23, 2007 박성우.
Pascal Programming Today Chapter 4 1 »Conditional statements allow the execution of one of a number of possible operations. »Conditional statements include:
Introduction to ML – Part 1 Frances Spalding. Assignment 1 chive/fall05/cos441/assignments/a1.ht m
CSE 425: Semantic Analysis Semantic Analysis Allows rigorous specification of a program’s meaning –Lets (parts of) programming languages be proven correct.
Fall Semantics Juan Carlos Guzmán CS 3123 Programming Languages Concepts Southern Polytechnic State University.
CSE-321 Programming Languages Polymorphism POSTECH May 15, 2006 박성우.
Comp 205: Comparative Programming Languages Semantics of Imperative Programming Languages denotational semantics operational semantics logical semantics.
Foundations of Programming Languages: Introduction to Lambda Calculus
C. Varela; Adapted w/permission from S. Haridi and P. Van Roy1 Declarative Computation Model Defining practical programming languages Carlos Varela RPI.
8. Introduction to Denotational Semantics. © O. Nierstrasz PS — Denotational Semantics 8.2 Roadmap  Syntax and Semantics  Semantics of Expressions 
6. Introduction to the Lambda Calculus. © O. Nierstrasz PS — Introduction to the Lambda Calculus 6.2 Roadmap  What is Computability? — Church’s Thesis.
Cse321, Programming Languages and Compilers 1 6/12/2015 Lecture #10, Feb. 14, 2007 Modified sets of item construction Rules for building LR parse tables.
CS 330 Programming Languages 09 / 18 / 2007 Instructor: Michael Eckmann.
Introduction to ML - Part 2 Kenny Zhu. What is next? ML has a rich set of structured values Tuples: (17, true, “stuff”) Records: {name = “george”, age.
The lambda calculus David Walker CS 441. the lambda calculus Originally, the lambda calculus was developed as a logic by Alonzo Church in 1932 –Church.
Introduction to ML Last time: Basics: integers, Booleans, tuples,... simple functions introduction to data types This time, we continue writing an evaluator.
Copyright © 2006 The McGraw-Hill Companies, Inc. Programming Languages 2nd edition Tucker and Noonan Chapter 14 Functional Programming It is better to.
PSUCS322 HM 1 Languages and Compiler Design II Formal Semantics Material provided by Prof. Jingke Li Stolen with pride and modified by Herb Mayer PSU Spring.
COS 320 Compilers David Walker. Outline Last Week –Introduction to ML Today: –Lexical Analysis –Reading: Chapter 2 of Appel.
Dec Formal Semantics1 Programming Language Theory Formal Semantics Leif Grönqvist The national Graduate School of Language Technology (GSLT) MSI.
Comp 205: Comparative Programming Languages Imperative Programming Languages Functional Programming Languages Semantics Other Paradigms Lecture notes,
Tim Sheard Oregon Graduate Institute Lecture 11: A Reduction Semantics for MetaML CS510 Section FSC Winter 2005 Winter 2005.
Imperative Programming
CSE-321 Programming Languages Overview POSTECH March 4, 2014 박성우.
10/12/20151 GC16/3C11 Functional Programming Lecture 3 The Lambda Calculus A (slightly) deeper look.
CSE S. Tanimoto Lambda Calculus 1 Lambda Calculus What is the simplest functional language that is still Turing complete? Where do functional languages.
© Kenneth C. Louden, Chapter 11 - Functional Programming, Part III: Theory Programming Languages: Principles and Practice, 2nd Ed. Kenneth C. Louden.
CSE-321 Programming Languages Introduction to Functional Programming (Part II) POSTECH March 13, 2006 박성우.
Chapter Twenty-ThreeModern Programming Languages1 Formal Semantics.
Formal Semantics Chapter Twenty-ThreeModern Programming Languages, 2nd ed.1.
1 ML fun x -> e e 1 e 2 0, 1, 2,..., +, -,... true, false, if e then e else e patterns datatypes exceptions structures functors let f x = e variables These.
Introduction to Programming Languages S1.3.1Bina © 1998 Liran & Ofir Introduction to Programming Languages Programming in C.
© Kenneth C. Louden, Chapter 11 - Functional Programming, Part III: Theory Programming Languages: Principles and Practice, 2nd Ed. Kenneth C. Louden.
CSE 230 The -Calculus. Background Developed in 1930’s by Alonzo Church Studied in logic and computer science Test bed for procedural and functional PLs.
Semantics In Text: Chapter 3.
1 Formal Semantics. 2 Why formalize? ML is tricky, particularly in corner cases generalizable type variables? polymorphic references? exceptions? Some.
Languages and Compilers
CSE-321 Programming Languages -Calculus (II) POSTECH March 27, 2006 박성우.
CS 2104 – Prog. Lang. Concepts Functional Programming II Lecturer : Dr. Abhik Roychoudhury School of Computing From Dr. Khoo Siau Cheng’s lecture notes.
8-1 Compilers Compiler A program that translates a high-level language program into machine code High-level languages provide a richer set of instructions.
-Calculus Kangwon National University 임현승 Programming Languages These slides are based on the slides by Prof. Sungwoo Park at POSTECH.
CMSC 330: Organization of Programming Languages Operational Semantics a.k.a. “WTF is Project 4, Part 3?”
CS April 2002 Lazy Evaluation, Thunks, and Streams.
CSE-321 Programming Languages (So Many Topics) POSTECH May 29, 2006 박성우.
CMSC 330: Organization of Programming Languages Operational Semantics.
CSE-321 Programming Languages -Calculus (II) POSTECH March 26, 2007 박성우.
CSE-321 Programming Languages Abstract Machine E POSTECH May 1, 2006 박성우.
CSE-321 Programming Languages Introduction to Functional Programming POSTECH March 8, 2006 박성우.
CSE 311 Foundations of Computing I Lecture 18 Recursive Definitions: Context-Free Grammars and Languages Autumn 2011 CSE 3111.
6/21/20161 Programming Languages and Compilers (CS 421) Reza Zamani Based in part on slides by Mattox Beckman,
Arvind Computer Science and Artificial Intelligence Laboratory M.I.T. L03-1 September 14, 2006http:// -calculus: A Basis for.
CSE-321 Programming Languages Simply Typed -Calculus
More on Lambda Calculus
Comp 205: Comparative Programming Languages
CS 611: Lecture 9 More Lambda Calculus: Recursion, Scope, and Substitution September 17, 1999 Cornell University Computer Science Department Andrew Myers.
Programming Languages and Compilers (CS 421)
FP Foundations, Scheme In Text: Chapter 14.
CSE 341 Section 5 Winter 2018.
Announcements Quiz 6 HW7 due Tuesday, October 30
CSE-321 Programming Languages Introduction to Functional Programming
Announcements Exam 2 on Friday, November 2nd Topics
CSE-321 Programming Languages Introduction to Functional Programming
CSE-321 Programming Languages Overview
Programming Languages and Compilers (CS 421)
Assignments and Procs w/Params
CSE S. Tanimoto Lambda Calculus
Presentation transcript:

1 SML fn x => e e 1 e 2 0, 1, 2,..., +, -,... true, false, if e then e else e patterns datatypes exceptions structures functors fun f x = e variables

2 What lies in the core of SML? fn x => e e 1 e 2 0, 1, 2,..., +, -,... true, false, if e then e else e patterns datatypes exceptions structures functors fun f x = e variables ?

3 Candidates? booleans and if/then/else integers lists variables functions and function applications datatypes patterns structures functors...

4 Core of SML fn x => e e 1 e 2 x

5  calculus

6  calculus is Turing-complete fn x => e e 1 e 2 x Turing machine  calculus =

CSE-321 Programming Languages -Calculus POSTECH March 21, 2007 박성우

8 Outline Abstract syntax of the -calculus Operational semantics of the -calculus Substitutions Programming in the -calculus

9 Syntax for a Programming Language Concrete syntax program = string of characters specifies rules for parsing. –operator precedence –associativity –keywords, * (2 * 3) 1 + (2 * (3)) Abstract syntax abstracts away from details of parsing. focuses on the high-level structure of programs. suitable for studying the semantics

10 x –variable –z, s, t, f, arg, accum,... x. e – -abstraction – x = formal argument, e = body – ¼ fn x => e e 1 e 2 –application –left-associative (as in SML): e 1 e 2 e 3 = (e 1 e 2 ) e 3 e 1 e 2 e 3  e 1 (e 2 e 3 ) Abstract Syntax of the -Calculus

11 Examples

12 Outline Abstract syntax of the -calculus V Operational semantics of the -calculus Substitutions Programming in the -calculus

13 Semantics of Languages Answers "what is the meaning of a given program?" –SML has a formal semantics. –What about C? Three styles –denotational semantics –axiomatic semantics –operational semantics The 1990s saw the renaissance of operational semantics.

14 Operational Semantics Specifies how to transform a program into a value via a sequence of operations Program Value P2P2 operation PnPn... let fun fac 1 = 1 | fac n = n * fac (n - 1) in fac 4 end 24

15 Operational Semantics of -Calculus Specifies how to transform an expression into a value via a sequence of reductions Expr Value E2E2 reduction EnEn...

16 Values and Reductions

17 Reductions redex = reducible expression :  -reduction

18 _____ = Redex

19 _____ = Redex

20  Reduction Not Unique So we need a reduction strategy.

21  Reduction Not Unique So we need a reduction strategy.

22 Call-by-name Call-by-value

23 Call-by-name Call-by-value

24

25

26 Call-by-name Call-by-value Used in Haskell Lazy or non-strict functional languages The implementation uses call-by-need. Superb! Used in SML Eager or strict functional languages Superb! (fn x => 0)

27 Assignments Assignment 2 –average –Be sure to take a look at the sample solution. Assignment 3 –to be out by midnight tonight. ??? –due on April 2 –Start early! (  Start coding early!)

28 Quiz 1 Next Monday Read Chapter 2 of Course Notes. –'fill in the blank' problems (i.e., easy) 15 minutes –Please show up on time. Otherwise you might miss the quiz!

29 Anonymous Feedback To be set up sometime today (hopefully) – I will appreciate your feedback on this course. –lectures –assignments –schedule –topics It is you who will improve this course!