CSE-321 Programming Languages Simply Typed -Calculus

Slides:



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

Types and Programming Languages Lecture 7 Simon Gay Department of Computing Science University of Glasgow 2006/07.
Type Inference David Walker COS 320. Criticisms of Typed Languages Types overly constrain functions & data polymorphism makes typed constructs useful.
4.5 Inherently Ambiguous Context-free Language For some context-free languages, such as arithmetic expressions, may have many different CFG’s to generate.
Certified Typechecking in Foundational Certified Code Systems Susmit Sarkar Carnegie Mellon University.
- Vasvi Kakkad.  Formal -  Tool for mathematical analysis of language  Method for precisely designing language  Well formed model for describing and.
Foundational Certified Code in a Metalogical Framework Karl Crary and Susmit Sarkar Carnegie Mellon University.
Current Techniques in Language-based Security David Walker COS 597B With slides stolen from: Steve Zdancewic University of Pennsylvania.
Translator Architecture Code Generator ParserTokenizer string of characters (source code) string of tokens abstract program string of integers (object.
1 Dependent Types for Termination Verification Hongwei Xi University of Cincinnati.
Formal Semantics of Programming Languages 虞慧群 Topic 5: Axiomatic Semantics.
CSE-321 Programming Languages Predicative Polymorphic -Calculus POSTECH May 23, 2007 박성우.
CSE-321 Programming Languages Polymorphism POSTECH May 15, 2006 박성우.
CPSC 411, Fall 2008: Set 12 1 CPSC 411 Design and Analysis of Algorithms Set 12: Undecidability Prof. Jennifer Welch Fall 2008.
Pointer. Warning! Dangerous Curves C (and C++) have just about the most powerful, flexible and dangerous pointers in the world. –Most other languages.
Programming Language Semantics Mooly SagivEran Yahav Schrirber 317Open space html://
Catriel Beeri Pls/Winter 2004/05 types 65  A type-checking algorithm The task: (since we start with empty H, why is the goal not just E?) The rule set.
Type Systems and Object- Oriented Programming John C. Mitchell Stanford University.
CS 454 Theory of Computation Sonoma State University, Fall 2011 Instructor: B. (Ravi) Ravikumar Office: 116 I Darwin Hall Original slides by Vahid and.
Semantics for MinML COS 441 Princeton University Fall 2004.
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.
Introduction to Java University of Sunderland CSE301 Harry R. Erwin, PhD.
CSE S. Tanimoto Lambda Calculus 1 Lambda Calculus What is the simplest functional language that is still Turing complete? Where do functional languages.
Typed Lambda Calculus Chapter 9 Benjamin Pierce Types and Programming Languages.
Lesson 4 Typed Arithmetic Typed Lambda Calculus 1/21/02 Chapters 8, 9, 10.
Type Safety Kangwon National University 임현승 Programming Languages.
CSE-321 Programming Languages Inductive Definitions POSTECH March 14, 2007 박성우.
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.
Solving a system of equations by adding or subtracting.
Types and Programming Languages Lecture 6 Simon Gay Department of Computing Science University of Glasgow 2006/07.
CSE-321 Programming Languages -Calculus (II) POSTECH March 27, 2006 박성우.
Types and Programming Languages Lecture 12 Simon Gay Department of Computing Science University of Glasgow 2006/07.
-Calculus Kangwon National University 임현승 Programming Languages These slides are based on the slides by Prof. Sungwoo Park at POSTECH.
Advanced Formal Methods Lecture 3: Simply Typed Lambda calculus Mads Dam KTH/CSC Course 2D1453, Some material from B. Pierce: TAPL + some from.
Advanced Formal Methods Lecture 4: Isabelle – Types and Terms Mads Dam KTH/CSC Course 2D1453, Some material from Paulson.
Types and Programming Languages
Types and Programming Languages Lecture 14 Simon Gay Department of Computing Science University of Glasgow 2006/07.
CS7120 (Prasad)L13-1-Lambda-Opt1 Typed Lambda Calculus Adapted from Lectures by Profs Aiken and Necula of Univ. of California at Berkeley.
Types and Programming Languages Lecture 3 Simon Gay Department of Computing Science University of Glasgow 2006/07.
CSE-321 Programming Languages -Calculus (II) POSTECH March 26, 2007 박성우.
CSE-321 Programming Languages Abstract Machine E POSTECH May 1, 2006 박성우.
6/21/20161 Programming Languages and Compilers (CS 421) Reza Zamani Based in part on slides by Mattox Beckman,
Language-Based Security: Overview of Types Deepak Garg Foundations of Security and Privacy October 27, 2009.
CSE 3302 Programming Languages
CS5205: Foundations in Programming Languages
Programming Languages and Compilers (CS 421)
COSC 5V90 Functional Programming and Interactive Theorem Proving
Lambda Calculus CSE 340 – Principles of Programming Languages
Compilers Principles, Techniques, & Tools Taught by Jing Zhang
CS 611: Lecture 9 More Lambda Calculus: Recursion, Scope, and Substitution September 17, 1999 Cornell University Computer Science Department Andrew Myers.
September 4, 1997 Programming Languages (CS 550) Lecture 6 Summary Operational Semantics of Scheme using Substitution Jeremy R. Johnson TexPoint fonts.
Simplifications of Context-Free Grammars
Pointers and References
CSE 3302 Programming Languages
Lesson 4 Typed Arithmetic Typed Lambda Calculus
Syntax-Directed Translation
Typed Arithmetic Expressions
Programming Languages and Compilers (CS 421)
Lecture 7: Introduction to Parsing (Syntax Analysis)
CSE-321 Programming Languages Introduction to Functional Programming
Organization of Programming Languages
Language-based Security
Class 33: Making Recursion M.C. Escher, Ascending and Descending
CSE-321 Programming Languages Introduction to Functional Programming
Programming Languages and Compilers (CS 421)
Programming Languages and Compilers (CS 421)
Subject Name: FORMAL LANGUAGES AND AUTOMATA THEORY
CSE S. Tanimoto Lambda Calculus
Decidability continued….
Relating Static and Dynamic Semantics
Presentation transcript:

CSE-321 Programming Languages Simply Typed -Calculus 박성우 POSTECH April 3, 2006

-Calculus Abstract syntax Operational semantics (call-by-value)

Simulating Base Types Booleans Natural numbers Fixed point combinator

Motivation The -calculus is equally expressive as Turing machines. booleans, integers, lists, recursive functions, ... But it is highly inefficient to program in the -calculus. Why not just use instead of ? So we introduce a type system!

Simply Typed -Calculus An extension of the untyped -calculus with types Assumes a fixed set of base types E.g. base type primitive constructs A subset of Standard ML

Outline Introduction V The simply typed -calculus Abstract syntax Operational semantics Type system Type safety

Abstract Syntax

What if there is no base type? No interesting expression!

Outline Introduction V The simply typed -calculus Abstract syntax V Operational semantics Type system Type safety

Simply Untyped -Calculus

Reduction Rules for Booleans

Capture-Avoiding Substitutions Completely analogous

Free Variables Completely analogous

Outline Introduction V The simply typed -calculus Abstract syntax V Operational semantics V Type system Type safety

What is the type of ? Answer:

How to find the type of Assume that the type of x is A. okay Find the type of x. A Build a function type A ! A Need to make assumptions on types of variables!

Type System Typing context Typing judgment

Typing Rules --- Top-down

Typing Rules --- Bottom-up

Typing Rules for Booleans

Typing Derivation

Typing Derivation

Outline Introduction V The simply typed -calculus V Abstract syntax V Operational semantics V Type system V Type safety

Unsafe Operations in C Adding two pointers Subtracting an integer from a string which is okay, but likely to be unintended Null-pointer dereferencing Argh... segmentation fault! Using an integer as a destination address in a function call ...

Huffman Coding in SML Suppose that you spent 10 hours before getting your program to typecheck. 0am: You start. 10am: Your program compiles with no type errors. How many more hours did you spend after that?

Type Safety Slogan "well-typed expressions never go wrong" Two theorems Type preservation: "A well-typed expression reduces to another expression of the same type." Progress: "A well-typed expression is not stuck: either it is a value or reduces to another expression."

Type Preservation + Progress A well-typed expression e: If it is a value, we are finished. If it is not, It reduces to another e' [Progress] e' has the same type as e. [Type preservation]

Type Safety Type preservation Progress

Proof of Type Safety Use the rule induction. In the next lecture!