Typed Arithmetic Expressions
|
|
- Dale Newman
- 6 years ago
- Views:
Transcription
1 Typed Arithmetic Expressions CS 550 Programming Languages Jeremy Johnson TAPL Chapters 3 and 5 1
2 Types and Safety Evaluation rules provide operational semantics for programming languages. The rules provide state transitions for an abstract machine that evaluates terms in the language. Evaluating a term can result in a value or get stuck in an erroneous state. We would like to be able to tell, without actually evaluating the term, whether or not it will get stuck. Type rules are introduced to associate types with terms. A term t is well-typed if there is some type T such that t has type T. The safety property says that well-typed terms do not lead to erroneous states, i.e. do not go wrong Safety is progress plus preservation. A well-typed term is either a value or it transitions to another well-typed term. 2
3 Outline Arithmetic Expressions Syntax and evaluation rules Untyped arithmetic expressions Typed arithmetic expressions Safety well typed terms do not get stuck 3
4 Boolean Expressions Syntax t ::= true false if t then t else t v ::= true false Evaluation if true then t 2 else t3 t 2 (E-IfTrue) if false then t 2 else t 3 t 3 (E-IfFalse) t 1 t 1 (E-If) if t 1 then t 2 else t 3 if t 1 then t 2 else t 3
5 Derivation s = if true then false else false t = if s then true else true u = if false then true else true E-IfTrue s false E-If t u E-If if t then false else false if u then false else false
6 Determinacy Theorem [Determinacy of one-step evaluation]. If t t and t t, then t = t. Proof. By induction on a derivation of t t.
7 Determinacy Proof. By induction on a derivation of t t. Three cases: E-IfTrue, E-IfFalse and E-If. The first two are base cases. 1) E-IfTrue. t = if true then t 2 else t 3 and t = t 2 E-IfFalse and E-If are not applicable, so t = t = t 2
8 Determinacy Proof. By induction on a derivation of t t. Three cases: E-IfTrue, E-IfFalse and E-If. 2) E-IfFalse. t = if false then t 2 else t 3 and t = t 3 E-IfTrue and E-If are not applicable, so t = t = t 3
9 Determinacy Proof. By induction on a derivation of t t. Three cases: E-IfTrue, E-IfFalse and E-If. 3) E-If. t = if t 1 then t 2 else t 3 and t = if t 1 then t 2 else t 3 and t 1 t 1 E-IfTrue and E-IfFalse are not applicable since t 1 is not a normal form.
10 Determinacy Proof. By induction on a derivation of t t. 3) E-If. t = if t 1 then t 2 else t 3 and t = if t 1 then t 2 else t 3 with t 1 t 1 E-IfTrue and E-IfFalse are not applicable since t 1 is not a normal form, so t = if t 1 then t 2 else t 3 with t 1 t 1. By induction t 1 = t 1 and t = t.
11 Normal Forms Definition. A term t is in normal form if no evaluation rule applies to it. Theorem. Every value is in a normal form and every term t that is in normal form is a value. Proof. Immediate from rules. Show contrapositive by induction on t.
12 Normal Forms Theorem. Every value is in a normal form and every term t that is in normal form is a value. Show contrapositive by induction on t. If t is not a value then it is not a normal form t = if t 1 then t 2 else t 3 1. t 1 = true E-IfTrue applicable 2. t 1 = false E-IfFalse applicable 3. else by induction t 1 t 1 and E-If is applicable
13 Multi-step Evaluation Definition. Multistep evaluation * is the reflexive, transitive closure of one step evaluation.
14 Uniqueness of Normal Forms Theorem [Uniqueness of normal forms]. If t * u and t * v, where u and v are normal forms, then u = v. Proof. Corollary of determinacy.
15 Termination of Evaluation Theorem [Termination of evaluation]. For every term t, there is a normal form t such that t * t. Proof. Each evaluation step decreases the size and since size is natural number and the natural numbers are well founded the size must reach 1.
16 Arithmetic Expressions Syntax t ::= 0 succ t pred t iszero t nv ::= 0 succ nv Evaluation t 1 t 1 (E-Succ) succ t 1 succ t 1 pred 0 0 (E-PredZero) pred (succ nv 1 ) nv 1 (E-PredSucc) t 1 t 1 (E-Pred) pred t 1 pred t 1 iszero 0 true (E-IsZeroZero) iszero (succ nv 1 ) false (E-IsZeroSucc) t 1 t 1 (E-IsZero) iszero t 1 iszero t 1
17 Derivation pred (succ (pred 0)) * 0 pred (succ (pred 0)) pred (succ 0) 0 E-PredZero pred 0 0 E-Succ succ (pred 0) succ 0 E-Pred pred (succ (pred 0)) pred (succ 0)
18 Stuck Terms Definition. A stuck term is a term that is in normal form but is not a value. E.G. pred false if 0 then true else false
19 Typing Relation Definition. A typing relation, t : T, is defined by a set of inference rules assigning types to terms. A term is well-typed if there is some T such that t : T. For arithmetic expressions there are two types: Bool and Nat Insisting that evaluation rules are only applied to proper types prevents things from going wrong (getting stuck).
20 Typing Relation Syntax T ::= Bool Typing Rules true : Bool false : Bool (T-True) (T-False) t 1 : Bool, t 2 : T, t 3 : T if t 1 then t 2 else t 3 : T (T-If)
21 Typing Relation Syntax T ::= Nat *The typing relation is conservative. I.E. some terms that do not get stuck are not well-typed. Typing Rules 0 : Nat (T-Zero) t 1 : Nat (T-Succ) succ t 1 : Nat t 1 : Nat (T-Pred) pred t 1 : Nat if (iszero 0) then 0 else false Want type checking to be easy t 1 : Nat iszero t 1 : Bool (T-IsZero)
22 Inversion Lemma 1. If true : R, then R = Bool. 2. If false : R, then R = Bool. 3. If if t 1 then t 2 else t 3 : R, then t 1 : Bool and t 2 : R and t 3 : R. 4. If 0 : R, then R = Nat. 5. If succ t 1 : R, then R = Nat and t 1 : Nat 6. If pred t 1 : R, then R = Nat and t 1 : Nat 7. If iszero t 1 : R, then R = Bool and t 1 : Nat
23 Uniqueness of Types Theorem. Each term t has at most one type. Proof. By induction on t using the inversion lemma. The inversion lemma provides a recursive algorithm for computing types.
24 Safety = Progress + Preservation Progress. A well-typed term is not stuck (either it is a value or it can take a step according to the evaluation rules). Preservation. If a well-typed term takes a step of evaluation, then the resulting term is well-typed.
25 Progress Theorem. If t : T, then t is a value or there is a t such that t t. Proof. By induction on the derivation of t : T.
26 Progress Theorem. If t : T, then t is a value or there is a t such that t t. Proof. By induction on the derivation of t : T. Base Cases: T-True, T-False, T-Zero, then t is a value.
27 Progress Theorem. If t : T, then t is a value or there is a t such that t t. Proof. By induction on the derivation of t : T. Case: T-If t = if t 1 then t 2 else t 3, t 1 : Bool, t 2, t 3 : T By induction either t 1 has a value E-IfTrue or E-IfFalse is applicable. Else t 1 t 1 and E-If is applicable
28 Progress Theorem. If t : T, then t is a value or there is a t such that t t. Proof. By induction on the derivation of t : T. Case: T-Succ t = succ t 1 and t 1 : Nat By induction either t 1 has a value t is a value else t 1 t 1 and E-Succ is applicable
29 Progress Theorem. If t : T, then t is a value or there is a t such that t t. Proof. By induction on the derivation of t : T. Case: T-Pred t = pred t 1 and t 1 : Nat By induction either t 1 has a value E-PredZero or E-PredSucc is applicable else t 1 t 1 and E- Pred is applicable
30 Progress Theorem. If t : T, then t is a value or there is a t such that t t. Proof. By induction on the derivation of t : T. Case: T-IsZero t = iszero t 1 and t 1 : Nat By induction either t 1 is a value either E- IsZeroZero or E-IsZeroSucc is applicable else t 1 t 1 and E-IsZero is applicable
31 Preservation Theorem. If t : T and t t, then t : T. Proof. By induction on t : T.
32 Preservation Theorem. If t : T and t t, then t : T. Proof. By induction on t : T. Case T-True, T-False, and T-Zero. t = true and T = Bool. t = false and T = Bool. t = 0 and T = Nat In all of these cases, t is a value and there is no t t and theorem is vacuously true.
33 Preservation Theorem. If t : T and t t, then t : T. Proof. By induction on t : T. Case T-If t = if t 1 then t 2 else t 3, t 1 : Bool, t 2, t 3 : T E-IfTrue E-IfFalse t 1 = true t = t 2 : T t 1 = false t = t 3 : T E-If t 1 t 1 and by induction t 1 : Bool t = if t 1 then t 2 else t 3 : T (by T-If)
34 Preservation Theorem. If t : T and t t, then t : T. Proof. By induction on t : T. Case T-Succ t = succ t 1 T = Nat t 1 : Nat E-Succ t 1 t 1 and by induction t 1 : Nat t = succ t 1 : Nat (by T-Succ)
35 Preservation Theorem. If t : T and t t, then t : T. Proof. By induction on t : T. Case T-Pred t = pred t 1 T = Nat t 1 : Nat E-PredZero t 1 = 0 and t = 0 : Nat (by T-Zero) E-PredSucc t 1 = succ nv 1 and t = nv 1 : Nat (by T- Zero or T-Succ) E-Pred t 1 t 1 and by induction t 1 : Nat t = pred t 1 : Nat (by T-Pred)
36 Preservation Theorem. If t : T and t t, then t : T. Proof. By induction on t : T. Case T-IsZero t = iszero t 1 T = Bool t 1 : Nat E-ZeroZero t 1 = 0 and t = true : Bool (by T-True) E-IsZeroSucc t 1 = succ nv 1 and t = false : Bool (by T-False) E-IsZero t 1 t 1 and by induction t 1 : Nat t = iszero t 1 : Bool (by T-IsZero)
37 Untyped Lambda Calculus Syntax Evaluation t ::= terms: x variable t 1 t 1 (E-App1) λx.t abstraction t 1 t 2 t 1 t 2 t t application t 2 t 2 (E-App2) v ::= values v 1 t 2 v 1 t 2 λx.t abstraction value (λx.t 12 )v 2 [x v 2 ] t 12 (E-AppAbs) Call by value
38 Substitution Definition. [x s] x = s [x s] y = y if y x [x s] (λy.t 1 ) = λy. [x s] t 1 if y x & y FV(s) [x s] (t 1 t 2 ) = [x s] t 1 [x s] t 2
39 Function Types Extend types to include functions λx:true [returns Bool] λx. λy.y [returns function] λx.if x then 0 else 1 [returns Nat, expects Bool] T T Definition. T ::= T T Bool Bool Bool, (Bool Bool) (Bool Bool) T 1 T 2 T 3 T 1 (T 2 T 3 )
40 Typing Relation Type rules for functions x : T 1 t 2 : T 2 λx:t 1.t 2 : T 1 T 2 Need three term relation, Γ t : T, that includes typing context Γ (set of assumptions on free variables) Γ, x : T 1 t 2 : T 2 Γ λx:t 1.t 2 : T 1 T 2
41 Simply Typed Lambda Calculus Syntax Evaluation t ::= terms: x variable t 1 t 1 (E-App1) λx:t.t abstraction t 1 t 2 t 1 t 2 t t application t 2 t 2 (E-App2) v ::= values v 1 t 2 v 1 t 2 λx:t.t abstraction value (λx:t 11.t 12 )v 2 [x v 2 ] t 12 (E-AppAbs)
42 Lambda Calculus Typing Syntax T ::= types: T T function types Γ ::= contexts empty context Γ, x:t term variable binding Type Rules x : T (T-Var) Γ x : T Γ, x : T 1 t 2 : T 2 (T-Abs) Γ λx:t 1.t 2 : T 1 T 2 Γ t 1 : T 1 T 2 Γ t 2 : T 1 (T-App) Γ t 1 t 2 : T 2
43 Substitution Lemma Theorem. If Γ, x : S t : T and Γ s : S, then Γ [x s]t : T.
44 Safety Theorem [Progress]. Suppose t is a closed (no free variables), well-typed term (i.e. t : T). Then either t is a value or else there is some t with t t. Theorem [Preservation]. If Γ t : T and t t, then Γ t : T.
45 Erasure Definition. The erasure of a simply typed term t is defined by erase(x) = x erase(λx:t 1.t 2 ) = λx.erase(t 2 ) erase(t 1 t 2 ) = erase(t 1 ) erase(t 2 ) Theorem. If t t, then erase(t) erase(t ). If erase(t) m, then there is a simply typed term t such that t t and erase(t ) = m.
46 Curry-Howard Correspondence Logic 1. Propositions 2. P Q 3. P Q 4. Proof of P 5. Prop P is provable Programming Languages 1. Types 2. Type P Q 3. Type P Q 4. Term t of type P 5. Type P is inhabited by some term A term of λ- is a proof of a logical proposition corresponding to its type.
CIS 500 Software Foundations Midterm II Answer key November 17, 2004
CIS 500 Software Foundations Midterm II Answer key November 17, 2004 Simply typed lambda-calculus The following questions refer to the simply typed lambda-calculus with booleans and error. The syntax,
More informationCIS 500 Software Foundations Final Exam Answer key December 20, 2004
CIS 500 Software Foundations Final Exam Answer key December 20, 2004 True/False questions For each of the following statements, circle T if the sentence is true or F otherwise. 1. (10 points) (a) T F The
More informationSimply Typed Lambda Calculus
Simply Typed Lambda Calculus Language (ver1) Lambda calculus with boolean values t ::= x variable x : T.t abstraction tt application true false boolean values if ttt conditional expression Values v ::=
More informationProgramming Languages and Types
Programming Languages and Types Klaus Ostermann based on slides by Benjamin C. Pierce Where we re going Type Systems... Type systems are one of the most fascinating and powerful aspects of programming
More informationType Systems Winter Semester 2006
Type Systems Winter Semester 2006 Week 7 November 29 November 29, 2006 - version 1.0 Plan PREVIOUSLY: 1. type safety as progress and preservation 2. typed arithmetic expressions 3. simply typed lambda
More informationCIS 500 Software Foundations Final Exam Answer key December 14, 2005
CIS 500 Software Foundations Final Exam Answer key December 14, 2005 True/False questions For each of the following statements, circle T if the sentence is true or F otherwise. 1. (9 points) (a) T F The
More informationInduction; Operational Semantics. Fall Software Foundations CIS 500
CIS 500 Software Foundations Fall 2005 Induction; Operational Semantics CIS 500, Induction; Operational Semantics 1 Announcements Review recitations start this week. You may go to any recitation section
More informationFormal Methods Lecture 8. (B. Pierce's slides for the book Types and Programming Languages )
Formal Methods Lecture 8 (B. Pierce's slides for the book Types and Programming Languages ) Erasure and Typability Erasure We can transform terms in λ to terms of the untyped lambda-calculus simply by
More informationCS 4110 Programming Languages & Logics. Lecture 16 Programming in the λ-calculus
CS 4110 Programming Languages & Logics Lecture 16 Programming in the λ-calculus 30 September 2016 Review: Church Booleans 2 We can encode TRUE, FALSE, and IF, as: TRUE λx. λy. x FALSE λx. λy. y IF λb.
More informationTyping λ-terms. Types. Typed λ-terms. Base Types. The Typing Relation. Advanced Formal Methods. Lecture 3: Simply Typed Lambda calculus
Course 2D1453, 200607 Advanced Formal Methods Lecture 3: Simply Typed Lambda calculus Mads Dam KTH/CSC Some material from B. Pierce: TAPL + some from G. Klein, NICTA Typing λterms The uptyped λcalculus
More informationSeptember 14. Fall Software Foundations CIS 500
CIS 500 Software Foundations Fall 2005 September 14 CIS 500, September 14 1 Announcements I will be away September 19-October 5. I will be reachable by email. Fastest response cis500@cis.upenn.edu No office
More informationλ Slide 1 Content Exercises from last time λ-calculus COMP 4161 NICTA Advanced Course Advanced Topics in Software Verification
Content COMP 4161 NICTA Advanced Course Advanced Topics in Software Verification Toby Murray, June Andronick, Gerwin Klein λ Slide 1 Intro & motivation, getting started [1] Foundations & Principles Lambda
More informationCIS 500 Software Foundations Final Exam. Answer key. December 20, 2006
CIS 500 Software Foundations Final Exam Answer key December 20, 2006 Instructions This is a closed-book exam. You have 120 minutes to answer all of the questions. The entire exam is worth 120 points. Questions
More informationFormal Methods Lecture 6. (B. Pierce's slides for the book Types and Programming Languages )
Formal Methods Lecture 6 (B. Pierce's slides for the book Types and Programming Languages ) This Saturday, 10 November 2018, room 335 (FSEGA), we will recover the following activities: 1 Formal Methods
More informationFormal Methods Lecture 6. (B. Pierce's slides for the book Types and Programming Languages )
Formal Methods Lecture 6 (B. Pierce's slides for the book Types and Programming Languages ) Programming in the Lambda-Calculus, Continued Testing booleans Recall: tru = λt. λf. t fls = λt. λf. f We showed
More informationReview. Principles of Programming Languages. Equality. The Diamond Property. The Church-Rosser Theorem. Corollaries. CSE 230: Winter 2007
CSE 230: Winter 2007 Principles of Programming Languages Lecture 12: The λ-calculus Ranjit Jhala UC San Diego Review The lambda calculus is a calculus of functions: e := x λx. e e 1 e 2 Several evaluation
More informationCMSC 336: Type Systems for Programming Languages Lecture 10: Polymorphism Acar & Ahmed 19 February 2008
CMSC 336: Type Systems for Programming Languages Lecture 10: Polymorphism Acar & Ahmed 19 February 2008 Contents 1 Polymorphism 1 2 Polymorphic λ-calculus: Syntax 1 3 Static Semantics 2 4 Dynamic Semantics
More informationSimple Type Extensions
Simple Type Extensions Type Systems, Lecture 4 Jevgeni Kabanov Tartu, 14.02.2006 PREVIOUSLY ON TYPE SYSTEMS Lambda Calculus Embedded Booleans and Arithmetical expressions Fixpoints and Recursion Simple
More information(2) (15pts) Using Prolog, implement a type-checker for the following small subset of System F:
CS 6371 Advanced Programming Languages Sample Spring 2018 Final Exam This sample final exam is LONGER than a real final exam (to give you more practice problems) and has a medium difficulty level. You
More informationFully-Abstract Compilation by Approximate Back-Translation Technical Appendix
Fully-Abstract Compilation by Approximate Back-Translation Technical Appendix Abstract This technical appendix provides the full formalisation and proofs for its paper 1 Contents 1 The Source Language
More informationModels of computation
Lambda-Calculus (I) jean-jacques.levy@inria.fr 2nd Asian-Pacific Summer School on Formal ethods Tsinghua University, August 23, 2010 Plan computation models lambda-notation bound variables odels of computation
More informationThe Lambda Calculus. Stephen A. Edwards. Fall Columbia University
The Lambda Calculus Stephen A. Edwards Columbia University Fall 2014 Lambda Expressions Function application written in prefix form. Add four and five is (+ 4 5) Evaluation: select a redex and evaluate
More information1. Object Calculus. Object calculus is to OO languages what lambda calculus is to functional languages
1. Object Calculus In this section we will introduce a calculus of objects that gives a simple but powerful mathematical model to study object based languages. Object calculus is to OO languages what lambda
More informationReferences. 7 November. Fall Software Foundations CIS 500. Another example. Announcements. Homework 7 out today, due November 14.
CIS 500 Software Foundations Fall 2005 7 November CIS 500, 7 November 1 References CIS 500, 7 November 3 Announcements Midterm II is one week from Wednesday (November 16). It will cover TAPL chapters 8-14
More informationUNTYPED LAMBDA CALCULUS (II)
1 UNTYPED LAMBDA CALCULUS (II) RECALL: CALL-BY-VALUE O.S. Basic rul Sarch ruls: (\x.) v [v/x] 1 1 1 1 v v CALL-BY-VALUE EVALUATION EXAMPLE (\x. x x) (\y. y) x x [\y. y / x] = (\y. y) (\y. y) y [\y. y /
More informationConsistency of a Programming Logic for a Version of PCF Using Domain Theory
Consistency of a Programming Logic for a Version of PCF Using Domain Theory Andrés Sicard-Ramírez EAFIT University Logic and Computation Seminar EAFIT University 5 April, 3 May 2013 A Core Functional Programming
More informationProgramming Languages
CSE 230: Winter 2010 Principles of Programming Languages Lecture 10: Programming in λ-calculusc l l Ranjit Jhala UC San Diego Review The lambda calculus is a calculus of functions: e := x λx. e e 1 e 2
More informationLambda-Calculus (I) 2nd Asian-Pacific Summer School on Formal Methods Tsinghua University, August 23, 2010
Lambda-Calculus (I) jean-jacques.levy@inria.fr 2nd Asian-Pacific Summer School on Formal Methods Tsinghua University, August 23, 2010 Plan computation models lambda-notation bound variables conversion
More informationλ-calculus and types
λ-calculus and types Lecture notes Midland Graduate School / APPSEM Spring School 2004 Thorsten Altenkirch School of Computer Science and Information Technology, Nottingham University txa@cs.nott.ac.uk
More informationType Systems Winter Semester 2006
Type Systems Winter Semester 2006 Week 5 November 15 November 15, 2006 - version 1.0 Programming in the Lambda-Calculus, Continued Testing booleans Recall: tru = λt. λf. t fls = λt. λf. f We showed last
More informationThe Curry-Howard Isomorphism
The Curry-Howard Isomorphism Software Formal Verification Maria João Frade Departmento de Informática Universidade do Minho 2008/2009 Maria João Frade (DI-UM) The Curry-Howard Isomorphism MFES 2008/09
More informationSafety Analysis versus Type Inference
Information and Computation, 118(1):128 141, 1995. Safety Analysis versus Type Inference Jens Palsberg palsberg@daimi.aau.dk Michael I. Schwartzbach mis@daimi.aau.dk Computer Science Department, Aarhus
More informationCSE 505, Fall 2009, Midterm Examination 5 November Please do not turn the page until everyone is ready.
CSE 505, Fall 2009, Midterm Examination 5 November 2009 Please do not turn the page until everyone is ready Rules: The exam is closed-book, closed-note, except for one side of one 85x11in piece of paper
More informationCSCI 490 problem set 6
CSCI 490 problem set 6 Due Tuesday, March 1 Revision 1: compiled Tuesday 23 rd February, 2016 at 21:21 Rubric For full credit, your solutions should demonstrate a proficient understanding of the following
More informationNormalization by Evaluation
Normalization by Evaluation Andreas Abel Department of Computer Science and Engineering Chalmers and Gothenburg University PhD Seminar in Mathematical Engineering EAFIT University, Medellin, Colombia 9
More informationIntroduction to λ-calculus
p.1/65 Introduction to λ-calculus Ken-etsu FUJITA fujita@cs.gunma-u.ac.jp http://www.comp.cs.gunma-u.ac.jp/ fujita/ Department of Computer Science Gunma University :Church 32, 36, 40; Curry 34 1. Universal
More informationSimply Typed λ-calculus
Simply Typed λ-calculus Lecture 1 Jeremy Dawson The Australian National University Semester 2, 2017 Jeremy Dawson (ANU) COMP4630,Lecture 1 Semester 2, 2017 1 / 23 A Brief History of Type Theory First developed
More informationCS522 - Programming Language Semantics
1 CS522 - Programming Language Semantics Simply Typed Lambda Calculus Grigore Roşu Department of Computer Science University of Illinois at Urbana-Champaign 2 We now discuss a non-trivial extension of
More informationCIS 500: Software Foundations
CIS 500: Software Foundations Solutions Final Exam December 15, 2017 1. Inductive relations (11 points) Complete the definition at the bottom of the page of an Inductive relation count that relates a list
More informationStatic Program Analysis
Static Program Analysis Xiangyu Zhang The slides are compiled from Alex Aiken s Michael D. Ernst s Sorin Lerner s A Scary Outline Type-based analysis Data-flow analysis Abstract interpretation Theorem
More informationAbout Typed Algebraic Lambda-calculi
About Typed Algebraic Lambda-calculi Benoît Valiron INRIA Saclay/LIX Palaiseau, France valiron@lix.polytechnique.fr Abstract Arrighi and Dowek (2008) introduce an untyped lambdacalculus together with a
More informationNotes from Yesterday s Discussion. Big Picture. CIS 500 Software Foundations Fall November 1. Some lessons.
CIS 500 Software Foundations Fall 2006 Notes from Yesterday s Email Discussion November 1 Some lessons This is generally a crunch-time in the semester Slow down a little and give people a chance to catch
More informationAn Introduction to Modal Logic III
An Introduction to Modal Logic III Soundness of Normal Modal Logics Marco Cerami Palacký University in Olomouc Department of Computer Science Olomouc, Czech Republic Olomouc, October 24 th 2013 Marco Cerami
More informationSimply Typed Lambda Calculus
Simply Typed Lambda Calculus Mathias Vorreiter Pedersen November 13, 2015 1 Recalling the untyped lambda calculus 1.1 Syntax t ::= x λ x. t t t 1.2 Evaluation x x t t λx.t λx.t t 1 t 1 t 2 t 2 t 1 t 2
More informationHarvard School of Engineering and Applied Sciences CS 152: Programming Languages
Harvard School of Engineering and Applied Sciences CS 152: Programming Languages Lecture 17 Tuesday, April 2, 2013 1 There is a strong connection between types in programming languages and propositions
More informationElement x is R-minimal in X if y X. R(y, x).
CMSC 22100/32100: Programming Languages Final Exam M. Blume December 11, 2008 1. (Well-founded sets and induction principles) (a) State the mathematical induction principle and justify it informally. 1
More informationDynamic Semantics. Dynamic Semantics. Operational Semantics Axiomatic Semantics Denotational Semantic. Operational Semantics
Dynamic Semantics Operational Semantics Denotational Semantic Dynamic Semantics Operational Semantics Operational Semantics Describe meaning by executing program on machine Machine can be actual or simulated
More informationType Systems. Lecture 2 Oct. 27th, 2004 Sebastian Maneth.
Type Systems Lecture 2 Oct. 27th, 2004 Sebastian Maneth http://lampwww.epfl.ch/teaching/typesystems/2004 Today 1. What is the Lambda Calculus? 2. Its Syntax and Semantics 3. Church Booleans and Church
More informationSemantics of Higher-Order Functional Programming
Semantics of Higher-Order Functional Programming Petros Barbagiannis µ λ July 14, 2014 Petros Barbagiannis Semantics of Higher-Order Functional Programming July 14, 2014 1 / 18 Introduction Higher-order
More informationLectures Notes on Progress
Lectures Notes on Progress 15-312: Foundations of Programming Languages Frank Pfenning Lecture 7 September 21, 2004 In this lecture we prove the progress property for MinML, discuss type safety, and consider
More information1 Problem 1. (20 pts)
CS 336 Programming Languages Homework Solution 4 Winter 2005 Due 2/24/05 1 Problem 1. (20 pts) Do Exercise 18.6.2. We define a meta-operation + on types as follows: If R is a record type with labels given
More informationPropositional Dynamic Logic
Propositional Dynamic Logic Contents 1 Introduction 1 2 Syntax and Semantics 2 2.1 Syntax................................. 2 2.2 Semantics............................... 2 3 Hilbert-style axiom system
More informationRules and derivations in an elementary logic course arxiv: v1 [cs.lo] 7 Jan 2016
Rules and derivations in an elementary logic course arxiv:160101483v1 [cslo] 7 Jan 2016 Gilles Dowek Inria, 23 avenue d Italie, CS 81321, 75214 Paris Cedex 13, France gillesdowek@inriafr When teaching
More informationCSE 311 Lecture 28: Undecidability of the Halting Problem. Emina Torlak and Kevin Zatloukal
CSE 311 Lecture 28: Undecidability of the Halting Problem Emina Torlak and Kevin Zatloukal 1 Topics Final exam Logistics, format, and topics. Countability and uncomputability A quick recap of Lecture 27.
More informationTutorial on Semantics Part I
Tutorial on Semantics Part I Basic Concepts Prakash Panangaden 1 1 School of Computer Science McGill University on sabbatical leave at Department of Computer Science Oxford University Fields Institute,
More informationA Monadic Analysis of Information Flow Security with Mutable State
A Monadic Analysis of Information Flow Security with Mutable State Karl Crary Aleksey Kliger Frank Pfenning July 2003 CMU-CS-03-164 School of Computer Science Carnegie Mellon University Pittsburgh, PA
More informationTyped Lambda Calculi. Nikos Tzeveλekos Queen Mary, University of London 1 / 23
Typed Lambda Calculi Nikos Tzeveλekos Queen Mary, University of London 1 / 23 What is the Lambda Calculus A minimal formalism expressing computation with functionals s ::= x λx.s ss All you need is lambda.
More informationIntroduction to Type Theory
Introduction to Type Theory Herman Geuvers Radboud University Nijmegen & Technical University Eindhoven, The Netherlands July 8, 2008 1 Overview These notes comprise the lecture Introduction to Type Theory
More informationFinite Automata Theory and Formal Languages TMV027/DIT321 LP Recap: Logic, Sets, Relations, Functions
Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2017 Formal proofs; Simple/strong induction; Mutual induction; Inductively defined sets; Recursively defined functions. Lecture 3 Ana Bove
More informationBeyond First-Order Logic
Beyond First-Order Logic Software Formal Verification Maria João Frade Departmento de Informática Universidade do Minho 2008/2009 Maria João Frade (DI-UM) Beyond First-Order Logic MFES 2008/09 1 / 37 FOL
More informationProgramming Languages Fall 2013
Programming Languages Fall 2013 Lecture 11: Subtyping Prof Liang Huang huang@qccscunyedu Big Picture Part I: Fundamentals Functional Programming and Basic Haskell Proof by Induction and Structural Induction
More informationThe lambda calculus with constructors
The lambda calculus with constructors Categorical semantic and Continuations Barbara Petit Focus - Univ. Bologna CaCos 2012 Barbara Petit (Focus - Univ. Bologna) The lambda calculus with constructors 1
More informationSimply Typed Lambda-Calculi (II)
THEORY AND PRACTICE OF FUNCTIONAL PROGRAMMING Simply Typed Lambda-Calculi (II) Dr. ZHANG Yu Institute of Software, Chinese Academy of Sciences Fall term, 2011 GUCAS, Beijing Introduction PCF Programming
More informationSafety Analysis versus Type Inference for Partial Types
Safety Analysis versus Type Inference for Partial Types Jens Palsberg palsberg@daimi.aau.dk Michael I. Schwartzbach mis@daimi.aau.dk Computer Science Department, Aarhus University Ny Munkegade, DK-8000
More informationThe Lifting Lemma. Ralf Hinze
The Lifting Lemma Ralf Hinze Computing Laboratory, University of Oxford Wolfson Building, Parks Road, Oxford, OX1 3QD, England ralf.hinze@comlab.ox.ac.uk http://www.comlab.ox.ac.uk/ralf.hinze/ June 2009
More informationFormalising the Completeness Theorem of Classical Propositional Logic in Agda (Proof Pearl)
Formalising the Completeness Theorem of Classical Propositional Logic in Agda (Proof Pearl) Leran Cai, Ambrus Kaposi, and Thorsten Altenkirch University of Nottingham {psylc5, psxak8, psztxa}@nottingham.ac.uk
More informationNICTA Advanced Course. Theorem Proving Principles, Techniques, Applications
NICTA Advanced Course Theorem Proving Principles, Techniques, Applications λ 1 CONTENT Intro & motivation, getting started with Isabelle Foundations & Principles Lambda Calculus Higher Order Logic, natural
More informationTruth-Functional Logic
Truth-Functional Logic Syntax Every atomic sentence (A, B, C, ) is a sentence and are sentences With ϕ a sentence, the negation ϕ is a sentence With ϕ and ψ sentences, the conjunction ϕ ψ is a sentence
More informationFoundations of Programming Languages. Paul Downen
Foundations of Programming Languages Paul Downen July 3 8, 2018 2 Contents 1 Static and Dynamic Semantics of a Little Language 7 1.1 Syntax................................. 7 1.2 Static Scope..............................
More informationAlonzo Church ( ) Lambda Calculus. λ-calculus : syntax. Grammar for terms : Inductive denition for λ-terms
Alonzo Church (1903-1995) Lambda Calculus 2 λ-calculus : syntax Grammar for terms : t, u ::= x (variable) t u (application) λx.t (abstraction) Notation : Application is left-associative so that t 1 t 2...
More informationType Soundness for Path Polymorphism
Type Soundness for Path Polymorphism Andrés Ezequiel Viso 1,2 joint work with Eduardo Bonelli 1,3 and Mauricio Ayala-Rincón 4 1 CONICET, Argentina 2 Departamento de Computación, FCEyN, UBA, Argentina 3
More informationProgramming Language Concepts: Lecture 16
Programming Language Concepts: Lecture 16 Madhavan Mukund Chennai Mathematical Institute madhavan@cmi.ac.in http://www.cmi.ac.in/~madhavan/courses/pl2009 PLC 2009, Lecture 16, 23 March 2009 λ-calculus:
More informationCS611 Lecture 25 Solving Domain Equations 22 October 2007 Lecturer: Andrew Myers
CS611 Lecture 25 Solving Domain Equations 22 October 2007 Lecturer: Andrew Myers To develop a denotational semantics for a language with recursive types, or to give a denotational semantics for the untyped
More informationRoy L. Crole. Operational Semantics Abstract Machines and Correctness. University of Leicester, UK
Midlands Graduate School, University of Birmingham, April 2008 1 Operational Semantics Abstract Machines and Correctness Roy L. Crole University of Leicester, UK Midlands Graduate School, University of
More informationOn the Correctness and Efficiency of the Krivine Machine
On the Correctness and Efficiency of the Krivine Machine Mitchell Wand Northeastern University Daniel P. Friedman Indiana University February 12, 2003 Abstract We provide a short derivation of the Krivine
More informationAn Introduction to Logical Relations Proving Program Properties Using Logical Relations
An Introduction to Logical Relations Proving Program Properties Using Logical Relations Lau Skorstengaard lask@cs.au.dk July 27, 2018 Contents 1 Introduction 2 1.1 Simply Typed Lambda Calculus....................
More informationOn Modal Logics of Partial Recursive Functions
arxiv:cs/0407031v1 [cs.lo] 12 Jul 2004 On Modal Logics of Partial Recursive Functions Pavel Naumov Computer Science Pennsylvania State University Middletown, PA 17057 naumov@psu.edu June 14, 2018 Abstract
More informationHandbook of Logic and Proof Techniques for Computer Science
Steven G. Krantz Handbook of Logic and Proof Techniques for Computer Science With 16 Figures BIRKHAUSER SPRINGER BOSTON * NEW YORK Preface xvii 1 Notation and First-Order Logic 1 1.1 The Use of Connectives
More informationHenk Barendregt and Freek Wiedijk assisted by Andrew Polonsky. Radboud University Nijmegen. March 5, 2012
1 λ Henk Barendregt and Freek Wiedijk assisted by Andrew Polonsky Radboud University Nijmegen March 5, 2012 2 reading Femke van Raamsdonk Logical Verification Course Notes Herman Geuvers Introduction to
More information1. Propositional Calculus
1. Propositional Calculus Some notes for Math 601, Fall 2010 based on Elliott Mendelson, Introduction to Mathematical Logic, Fifth edition, 2010, Chapman & Hall. 2. Syntax ( grammar ). 1.1, p. 1. Given:
More informationHigher Order Containers
Higher Order Containers Thorsten Altenkirch 1, Paul Levy 2, and Sam Staton 3 1 University of Nottingham 2 University of Birmingham 3 University of Cambridge Abstract. Containers are a semantic way to talk
More informationBlame for All. Amal Ahmed, Robert Bruce Findler, Jeremy Siek, Philip Wadler
Blame for All Amal Ahmed, Robert Bruce Findler, Jeremy Siek, Philip Wadler Vs. Part I The bit you know from before with a twist A simple untyped program let inc = λx. x + 1 in let app = λf. λx. f x in
More informationFocusing on Binding and Computation
Focusing on Binding and Computation Dan Licata Joint work with Noam Zeilberger and Robert Harper Carnegie Mellon University 1 Programming with Proofs Represent syntax, judgements, and proofs Reason about
More informationType Systems. Today. 1. What is the Lambda Calculus. 1. What is the Lambda Calculus. Lecture 2 Oct. 27th, 2004 Sebastian Maneth
Today 1. What is the Lambda Calculus? Type Systems 2. Its Syntax and Semantics 3. Church Booleans and Church Numerals 4. Lazy vs. Eager Evaluation (call-by-name vs. call-by-value) Lecture 2 Oct. 27th,
More informationType Systems. Lecture 9: Classical Logic. Neel Krishnaswami University of Cambridge
Type Systems Lecture 9: Classical Logic Neel Krishnaswami University of Cambridge Where We Are We have seen the Curry Howard correspondence: Intuitionistic propositional logic Simply-typed lambda calculus
More informationA Lambda Calculus for Quantum Computation
arxiv:quant-ph/0307150v5 3 Apr 004 A Lambda Calculus for Quantum Computation André van Tonder Department of Physics, Brown University Box 1843, Providence, RI 0906 andre@het.brown.edu July 15, 003 Revised
More informationProofs Propositions and Calculuses
Lecture 2 CS 1813 Discrete Mathematics Proofs Propositions and Calculuses 1 City of Königsberg (Kaliningrad) 2 Bridges of Königsberg Problem Find a route that crosses each bridge exactly once Must the
More informationFIXED POINTS AND EXTENSIONALITY IN TYPED FUNCTIONAL PROGRAMMING LANGUAGES
FIXED POINTS AND EXTENSIONALITY IN TYPED FUNCTIONAL PROGRAMMING LANGUAGES a dissertation submitted to the department of computer science and the committee on graduate studies of stanford university in
More informationRecitation 2: Binding, Semantics, and Safety : Foundations of Programming Languages
Recitation 2: Binding, Semantics, and Safety 15-312: Foundations of Programming Languages Charles Yuan, Jeanne Luning Prak September 5, 2018 1 Abstract Binding Trees The abstract syntax trees we saw previously
More informationOperational Semantics Using the Partiality Monad
page.1 Operational Semantics Using the Partiality Monad Nils Anders Danielsson (Göteborg) Shonan Meeting 026: Coinduction for computation structures and programming languages The research leading to these
More informationLocal Representations of Binding
Local Representations of Binding Randy Pollack LFCS, University of Edinburgh Joint work with James McKinna, Christian Urban, Arthur Charguéraud, Brian Aydemir, Benjamin Pierce, Stephanie Weirich Version
More informationMidterm Exam Types and Programming Languages Frank Pfenning. October 18, 2018
Midterm Exam 15-814 Types and Programming Languages Frank Pfenning October 18, 2018 Name: Andrew ID: Instructions This exam is closed-book, closed-notes. You have 80 minutes to complete the exam. There
More informationKleene realizability and negative translations
Q E I U G I C Kleene realizability and negative translations Alexandre Miquel O P. D E. L Ō A U D E L A R April 21th, IMERL Plan 1 Kleene realizability 2 Gödel-Gentzen negative translation 3 Lafont-Reus-Streicher
More informationApplied Logic for Computer Scientists. Answers to Some Exercises
Applied Logic for Computer Scientists Computational Deduction and Formal Proofs Springer, 2017 doi: http://link.springer.com/book/10.1007%2f978-3-319-51653-0 Answers to Some Exercises Mauricio Ayala-Rincón
More informationOn a computational interpretation of sequent calculus for modal logic S4
On a computational interpretation of sequent calculus for modal logic S4 Yosuke Fukuda Graduate School of Informatics, Kyoto University Second Workshop on Mathematical Logic and Its Applications March
More informationCIS 500 Software Foundations. Final Exam. May 9, Answer key. Hoare Logic
CIS 500 Software Foundations Final Exam May 9, 2011 Answer key Hoare Logic 1. (7 points) What does it mean to say that the Hoare triple {{P}} c {{Q}} is valid? Answer: {{P}} c {{Q}} means that, for any
More informationPropositional Language - Semantics
Propositional Language - Semantics Lila Kari University of Waterloo Propositional Language - Semantics CS245, Logic and Computation 1 / 41 Syntax and semantics Syntax Semantics analyzes Form analyzes Meaning
More informationVariations on a theme: call-by-value and factorization
Variations on a theme: call-by-value and factorization Beniamino Accattoli INRIA & LIX, Ecole Polytechnique Accattoli (INRIA Parsifal) Variations on a theme: call-by-value and factorization 1 / 31 Outline
More informationA REWRITING VIEW OF SIMPLE TYPING
A REWRITING VIEW OF SIMPLE TYPING AARON STUMP, GARRIN KIMMELL, HANS ZANTEMA, AND RUBA EL HAJ OMAR Computer Science, The University of Iowa e-mail address: astump@acm.org Computer Science, The University
More informationReasoning with Higher-Order Abstract Syntax and Contexts: A Comparison
1 Reasoning with Higher-Order Abstract Syntax and Contexts: A Comparison Amy Felty University of Ottawa July 13, 2010 Joint work with Brigitte Pientka, McGill University 2 Comparing Systems We focus on
More information