Relating Static and Dynamic Semantics

Slides:



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

Some important properties Lectures of Prof. Doron Peled, Bar Ilan University.
Substitution & Evaluation Order cos 441 David Walker.
- Vasvi Kakkad.  Formal -  Tool for mathematical analysis of language  Method for precisely designing language  Well formed model for describing and.
Formal Semantics of Programming Languages 虞慧群 Topic 5: Axiomatic Semantics.
Tangent lines Recall: tangent line is the limit of secant line The tangent line to the curve y=f(x) at the point P(a,f(a)) is the line through P with slope.
Formalizing Alpha: Soundness and Completeness Bram van Heuveln Dept. of Cognitive Science RPI.
Parametric Polymorphism COS 441 Princeton University Fall 2004.
CS5371 Theory of Computation Lecture 5: Automata Theory III (Non-regular Language, Pumping Lemma, Regular Expression)
Syntax With Binders COS 441 Princeton University Fall 2004.
Foundations of (Theoretical) Computer Science Chapter 2 Lecture Notes (Section 2.2: Pushdown Automata) Prof. Karen Daniels, Fall 2009 with acknowledgement.
Dynamic Semantics COS 441 Princeton University Fall 2004.
Type Inference David Walker CS 510, Fall Criticisms of Typed Languages Types overly constrain functions & data polymorphism makes typed constructs.
Semantics for MinML COS 441 Princeton University Fall 2004.
Mechanized Metatheory for User- Defined Type Extensions Dan Marino, Brian Chin, Todd Millstein UCLA Gang Tan Boston College Robert J. Simmons, David Walker.
3.2/3.4 Postulates, Properties, Definitions and Proofs Warm-up (IN) Learning Objective: to justify statements about geometric figures in 2-column proofs.
1.3 – AXIOMS FOR THE REAL NUMBERS. Goals  SWBAT apply basic properties of real numbers  SWBAT simplify algebraic expressions.
Mathematical Induction Assume that we are given an infinite supply of stamps of two different denominations, 3 cents and and 5 cents. Prove using mathematical.
WARM UP EXERCSE Consider the right triangle below with M the midpoint of the hypotenuse. Is MA = MC? Why or why not? MC B A 1.
Sequences and Series (T) Students will know the form of an Arithmetic sequence.  Arithmetic Sequence: There exists a common difference (d) between each.
ISBN Chapter 3 Describing Semantics -Attribute Grammars -Dynamic Semantics.
Lesson 4 Typed Arithmetic Typed Lambda Calculus 1/21/02 Chapters 8, 9, 10.
Type Safety Kangwon National University 임현승 Programming Languages.
Types and Programming Languages Lecture 12 Simon Gay Department of Computing Science University of Glasgow 2006/07.
1 Finite Model Theory Lecture 1: Overview and Background.
Lesson 2.7 Transitive and Substitution Properties Objective: After studying this lesson you will be able to apply the transitive properties of segments.
1 CMSC 341 Math Review. 2 Exponents Identities (X A ) B = X AB X A * X B = X A+B X A / X B = X A-B X A + X B  X A+B.
Type soundness In a more formal way. Proving Soundness of Type Systems Goal of a sound type system: –if the program type checks, then it never “crashes”
Types and Programming Languages Lecture 3 Simon Gay Department of Computing Science University of Glasgow 2006/07.
Bellwork Write if-then form, converse, inverse, and contrapositive of given statement. 3x - 8 = 22 because x = 10.
Section 1.7. Section Summary Mathematical Proofs Forms of Theorems Direct Proofs Indirect Proofs Proof of the Contrapositive Proof by Contradiction.
CS 344 Artificial Intelligence By Prof: Pushpak Bhattacharya Class on 12/Feb/2007.
1 Proving Properties of Recursive List Functions CS 270 Math Foundations of CS Jeremy Johnson.
Generic Programming and Proving for Programming Language Metatheory
Context-Free Languages & Grammars (CFLs & CFGs) (part 2)
CSE-321 Programming Languages Simply Typed -Calculus
Standard Representations of Regular Languages
CSE322 PUMPING LEMMA FOR REGULAR SETS AND ITS APPLICATIONS
September 4, 1997 Programming Languages (CS 550) Lecture 6 Summary Operational Semantics of Scheme using Substitution Jeremy R. Johnson TexPoint fonts.
6-4 Day 1 Fundamental Theorem of Calculus
Lesson 4 Typed Arithmetic Typed Lambda Calculus
Proving Properties of Recursive List Functions
Use Part 1 of the Fundamental Theorem of Calculus to find the derivative of the function. {image}
Fall Break Chain Rule Review
Typed Arithmetic Expressions
Lesson 2-8 Proof Review.
Engineering Aspects of Formal Metatheory
CSE 311: Foundations of Computing
CSE 311: Foundations of Computing
CSE 20: Discrete Mathematics for Computer Science Prof. Shachar Lovett
EVALUATING EXPRESSIONS
Propositional Logic.
Evaluating Expressions
Simplification of Boolean Expressions
Organization of Programming Languages
Computer Security: Art and Science, 2nd Edition
CMSC 341 Math Review.
3.3 Proofs with parallel lines
1.3 – AXIOMS FOR THE REAL NUMBERS
Problems of the Day Express the relation {(–3, 4), (–1, 2), (–3, 3), (2, 4) (4, 3)} as a table, as a graph, and as a mapping diagram. State the Domain.
Search techniques.
LECTURE 2-7 Complete Problems in PH
Have homework out to be checked!!
2-6 Proving Angles Congruent
Chapter 5 Parallel Lines and Related Figures
Tutorial 2 - Daniel Razavi
From the last time: gcd(a, b) can be characterized in two different ways: It is the least positive value of ax + by where x and y range over integers.
11.4 Mathematical Induction
Proving Statements about Segments
Presentation transcript:

Relating Static and Dynamic Semantics COS 441 Princeton University Fall 2004

Motivations We want to know that when evaluating certain well-formed programs certain errors never occur Example Transition semantics for -calculus is “stuck” when applied to expressions with free variables in it So if {} ` E ok then E should never be “stuck”

Formal Statement isFinal(e) = e 2 F steps(e) = 9 e’. e  e’ stuck(e) = :(steps(e) or isFinal(e)) Soundness Theorem: If {} ` E ok and E * E’ then :stuck(E’)

Formal Statement isFinal(e) = e 2 F steps(e) = 9 e’. e  e’ stuck(e) = :(steps(e) or isFinal(e)) Soundness Theorem: If {} ` E ok and E * E’ then (steps(E’) or isFinal(E’))

Proof: Soundness Theorem By induction on derivations of * with Preservation and Progress Lemmas Preservation Lemma: If {} ` E ok and E  E’ then {} ` E’ ok Progress Lemma: If {} ` E ok then (steps(E) or isFinal(E))

Warning!! The remainder of the lecture consists of a series of tedious proofs Take that swig of coffee now Slides will be on web-site Last set of tedious proofs in lecture I’ll assign them as homework from now on! ;) What we discuss today is a template for Assignment 3

Proof by Induction over * S * S Z* S * S’’ S  S’ S’ * S’’ S* To show 8 e,e’ P(e,e’) we must show case Z*: IH(E,E) case S*: If E  E’ and IH(E’,E’’) then IH(E,E’’) IH(e,e’) = If {} ` e ok and e * e’ then (steps(e’) or isFinal(e’))

Proof: Soundness Theorem case Z*: IH(E,E)

Proof: Soundness Theorem case Z*: If {} ` E ok and E * E then (steps(E) or isFinal(E))

Proof: Soundness Theorem case Z*: (steps(E) or isFinal(E)) {} ` E ok and E * E by assumption

Proof: Soundness Theorem case Z*: {} ` E ok and E * E by assumption 2. (steps(E) or isFinal(E)) by ??

Proof: Soundness Theorem case Z*: {} ` E ok and E * E by assumption 2. (steps(E) or isFinal(E)) by Progress Lemma with (1)

Proof: Soundness Theorem case S*: If E  E’ and IH(E’,E’’) then IH(E,E’’)

Proof: Soundness Theorem case S*: IH(E,E’’) 1. E  E’ and IH(E’,E’’) by assumption

Proof: Soundness Theorem case S*: If {} ` E ok and E * E’’ then (steps(E’’) or isFinal(E’’)) E  E’ and IH(E’,E’’) by assumption

Proof: Soundness Theorem case S*: (steps(E’’) or isFinal(E’’)) E  E’ and IH(E’,E’’) by assumption {} ` E ok and E * E’’ by assumption ` E’ ok by Preservation with (2,1) E’ * E’’ by inversion of S* and (2) (steps(E) or isFinal(E’’)) by IH with (3, 4)

Proof: Soundness Theorem case S*: (steps(E’’) or isFinal(E’’)) E  E’ and IH(E’,E’’) by assumption {} ` E ok and E * E’’ by assumption {} ` E’ ok by ?? E’ * E’’ by inversion of S* and (2) (steps(E) or isFinal(E’’)) by IH with (3, 4)

Proof: Soundness Theorem case S*: (steps(E’’) or isFinal(E’’)) E  E’ and IH(E’,E’’) by assumption {} ` E ok and E * E’’ by assumption {} ` E’ ok by Preservation with (2,1) E’ * E’’ by inversion of S* and (2) (steps(E) or isFinal(E’’)) by IH with (3, 4)

Proof: Soundness Theorem case S*: (steps(E’’) or isFinal(E’’)) E  E’ and IH(E’,E’’) by assumption {} ` E ok and E * E’’ by assumption {} ` E’ ok by Preservation with (2,1) E’ * E’’ by ?? (steps(E’’) or isFinal(E’’)) by IH with (3, 4)

Proof: Soundness Theorem case S*: (steps(E’’) or isFinal(E’’)) E  E’ and IH(E’,E’’) by assumption {} ` E ok and E * E’’ by assumption {} ` E’ ok by Preservation with (2,1) E’ * E’’ by inversion of S* and (2) (steps(E’’) or isFinal(E’’)) by IH with (3, 4)

Proof: Soundness Theorem case S*: E  E’ and IH(E’,E’’) by assumption {} ` E ok and E * E’’ by assumption {} ` E’ ok by Preservation with (2,1) E’ * E’’ by inversion of S* and (2) (steps(E’’) or isFinal(E’’)) by ??

Proof: Soundness Theorem case S*: E  E’ and IH(E’,E’’) by assumption {} ` E ok and E * E’’ by assumption {} ` E’ ok by Preservation with (2,1) E’ * E’’ by inversion of S* and (2) (steps(E’’) or isFinal(E’’)) by IH(E’,E’’) with (3, 4)

Notes About our Proof Note our Proof works for any single step relation () Specific details of step function factored into Progress and Preservation lemmas Need to refer to the static and dynamic semantics of the step relation to prove Progress and Preservation Lemmas

Static Semantics for -calculus Names x 2 … Expressions e ::= lam(x.e) | apply(e1,e2)| x  ` apply(E1,E2)ok  ` E1 ok  ` E2 ok ok-A  ` lam(X.E)ok  [ {X} ` E ok X   ok-L  ` X ok X 2  ok-V

Dynamic Semantics for -calculus = { E | 9.  ` E ok } I = { E | {} ` E ok } F = { x.e | {} ` x.e ok } ((x.e1) (y.e2))  [xÃ(y.e2)] e1 A1 ((x.e1) e2)  ((x.e1) e’2) e2  e’2 A2 (e1 e2)  (e’1 e2) e1  e’1 A3

Proof: Preservation Lemma Proof by induction on the derivations of E  E’ case A1: IH(((X.E1) (Y.E2)),[X Ã (Y.E2)] E1) case A2: If IH(E2,E’2) then IH(((X.E1) E2)),((X.E1) E’2)) case A3: If IH(E1,E’1) then IH((E1 E2)),(E’1 E2)) IH(e,e’) = If {} ` e ok and e  e’ then {} ` e’ ok

Proof: Preservation Lemma case A1: If {} ` ((X.E1) (Y.E1)) ok and ((X.E1) (Y.E1))  [X Ã (Y.E2)] E1 then {} ` [X Ã (Y.E2)] E1 ok

Proof: Preservation Lemma case A1: {} ` [X Ã (Y.E2)] E1 ok {} ` ((X.E1) (Y.E2)) ok and ((X.E1) (Y.E2))  [X Ã (Y.E2)] E1 by assumption {} ` (X.E1) ok and {} ` (Y.E2) ok by inversion of ok-A and (1) {} [ {X} ` E1 ok by inversion of ok-L and (2) {} ` [X Ã (Y.E2)] E1 ok by Substitution Lemma with (3) and (2)

Proof: Preservation Lemma case A1: {} ` [X Ã (Y.E2)] E1 ok {} ` ((X.E1) (Y.E2)) ok and ((X.E1) (Y.E2))  [X Ã (Y.E2)] E1 by assumption {} ` (X.E1) ok and {} ` (Y.E2) ok by ?? {} [ {X} ` E1 ok by inversion of ok-L and (2) {} ` [X Ã (Y.E2)] E1 ok by Substitution Lemma with (3) and (2)

Proof: Preservation Lemma case A1: {} ` [X Ã (Y.E2)] E1 ok {} ` ((X.E1) (Y.E2)) ok and ((X.E1) (Y.E2))  [X Ã (Y.E2)] E1 by assumption {} ` (X.E1) ok and {} ` (Y.E2) ok by inversion of ok-A and (1) {} [ {X} ` E1 ok by inversion of ok-L and (2) {} ` [X Ã (Y.E2)] E1 ok by Substitution Lemma with (3) and (2)

Proof: Preservation Lemma case A1: {} ` [X Ã (Y.E2)] E1 ok {} ` ((X.E1) (Y.E2)) ok and ((X.E1) (Y.E2))  [X Ã (Y.E2)] E1 by assumption {} ` (X.E1) ok and {} ` (Y.E2) ok by inversion of ok-A and (1) {} [ {X} ` E1 ok by ?? {} ` [X Ã (Y.E2)] E1 ok by Substitution Lemma with (3) and (2)

Proof: Preservation Lemma case A1: {} ` [X Ã (Y.E2)] E1 ok {} ` ((X.E1) (Y.E2)) ok and ((X.E1) (Y.E2))  [X Ã (Y.E2)] E1 by assumption {} ` (X.E1) ok and {} ` (Y.E2) ok by inversion of ok-A and (1) {} [ {X} ` E1 ok by inversion of ok-L and (2) {} ` [X Ã (Y.E2)] E1 ok by Substitution Lemma with (3) and (2)

Proof: Preservation Lemma case A1: {} ` [X Ã (Y.E2)] E1 ok {} ` ((X.E1) (Y.E2)) ok and ((X.E1) (Y.E2))  [X Ã (Y.E2)] E1 by assumption {} ` (X.E1) ok and {} ` (Y.E2) ok by inversion of ok-A and (1) {} [ {X} ` E1 ok by inversion of ok-L and (2) {} ` [X Ã (Y.E2)] E1 ok by ??

Proof: Preservation Lemma case A1: {} ` [X Ã (Y.E2)] E1 ok {} ` ((X.E1) (Y.E2)) ok and ((X.E1) (Y.E2))  [X Ã (Y.E2)] E1 by assumption {} ` (X.E1) ok and {} ` (Y.E2) ok by inversion of ok-A and (1) {} [ {X} ` E1 ok by inversion of ok-L and (2) {} ` [X Ã (Y.E2)] E1 ok by Substitution Lemma with (3) and (2)

Substitution Lemma Proof by induction on the derivations of  ` E ok If  [ {X} ` E ok and {} ` E’ ok then  ` [XÃE’]E ok case ok-V: … case ok-L: … case ok-A: … IH(env,e) = If env [ {X} ` e ok and {} ` E’ ok then env ` [XÃE’]e ok

Substitution Proof by induction on the derivations of  ` E ok If  [ {X} ` E ok and {} ` E’ ok then  ` [XÃE’]E ok case ok-V: If X 2  then IH(,X) case ok-L: If IH( [ {X}, E) and X   then IH(,(X.E)) case ok-A: If IH(,E1) and IH(,E2) then IH(,(E1 E2)) IH(env,e) = If env [ {X} ` e ok and {} ` E’ ok then env ` [XÃE’]e ok

Proof: Substitution case ok-V: 1. X 2  by assumption 2.  [ {Y} ` X ok and {} ` E’ ok by assumption 3.  ` [YÃE’]X ok by cases case X = Y: 3.1. [YÃE’]X = E’ by def of subst. 3.2.  ` E’ ok by (2) 3.3.  ` [YÃE’]X ok by (3.1) and (3.2) case X  Y: 3.1. [YÃE’]X = X by def of subst. 3.2.  ` X ok by ok-V and (1) 3.3.  ` [YÃE’]X ok by (3.1) and (3.2)

Proof: Substitution case ok-L: If IH( [ {X}, E) and X   then IH(,(X.E)) …

Proof: Substitution case ok-A: If IH(,E1) and IH(,E2) then IH(,(E1 E2)) …

Proof: Preservation Lemma case A2: If IH(E2,E’2) then IH(((X.E1) E2)),((X.E1) E’2))

Proof: Preservation Lemma case A2: IH(((X.E1) E2)),((X.E1) E’2)) IH(E2,E’2) by assumption

Proof: Preservation Lemma case A2: If {} ` ((X.E1) E2)) ok and ((X.E1) E2))  ((X.E1) E’2) then {} ` ((X.E1) E’2) ok IH(E2,E’2) by assumption

Proof: Preservation Lemma case A2: {} ` ((X.E1) E’2) ok IH(E2,E’2) by assumption {} ` ((X.E1) E2)) ok and ((X.E1) E2))  ((X.E1) E’2) by assumption {} ` (X.E1) ok and {} ` E2 ok by inversion of ok-A and (2) E2  E’2 by inversion of A2 {} ` E’2 ok by IH(E2,E’2) with (3) and (4) {} ` ((X.E1) E’2) ok by ok-A with (3) and (5)

Proof: Preservation Lemma case A2: {} ` ((X.E1) E’2) ok IH(E2,E’2) by assumption {} ` ((X.E1) E2)) ok and ((X.E1) E2))  ((X.E1) E’2) by assumption {} ` (X.E1) ok and {} ` E2 ok by ?? E2  E’2 by inversion of A2 {} ` E’2 ok by IH(E2,E’2) with (3) and (4) {} ` ((X.E1) E’2) ok by ok-A with (3) and (5)

Proof: Preservation Lemma case A2: {} ` ((X.E1) E’2) ok IH(E2,E’2) by assumption {} ` ((X.E1) E2)) ok and ((X.E1) E2))  ((X.E1) E’2) by assumption {} ` (X.E1) ok and {} ` E2 ok by inversion of ok-A and (2) E2  E’2 by inversion of A2 {} ` E’2 ok by IH(E2,E’2) with (3) and (4) {} ` ((X.E1) E’2) ok by ok-A with (3) and (5)

Proof: Preservation Lemma case A2: {} ` ((X.E1) E’2) ok IH(E2,E’2) by assumption {} ` ((X.E1) E2)) ok and ((X.E1) E2))  ((X.E1) E’2) by assumption {} ` (X.E1) ok and {} ` E2 ok by inversion of ok-A and (2) E2  E’2 by ?? {} ` E’2 ok by IH(E2,E’2) with (3) and (4) {} ` ((X.E1) E’2) ok by ok-A with (3) and (5)

Proof: Preservation Lemma case A2: {} ` ((X.E1) E’2) ok IH(E2,E’2) by assumption {} ` ((X.E1) E2)) ok and ((X.E1) E2))  ((X.E1) E’2) by assumption {} ` (X.E1) ok and {} ` E2 ok by inversion of ok-A and (2) E2  E’2 by inversion of A2 and (2) {} ` E’2 ok by IH(E2,E’2) with (3) and (4) {} ` ((X.E1) E’2) ok by ok-A with (3) and (5)

Proof: Preservation Lemma case A2: {} ` ((X.E1) E’2) ok IH(E2,E’2) by assumption {} ` ((X.E1) E2)) ok and ((X.E1) E2))  ((X.E1) E’2) by assumption {} ` (X.E1) ok and {} ` E2 ok by inversion of ok-A and (2) E2  E’2 by inversion of A2 and (2) {} ` E’2 ok by ?? {} ` ((X.E1) E’2) ok by ok-A with (3) and (5)

Proof: Preservation Lemma case A2: {} ` ((X.E1) E’2) ok IH(E2,E’2) by assumption {} ` ((X.E1) E2)) ok and ((X.E1) E2))  ((X.E1) E’2) by assumption {} ` (X.E1) ok and {} ` E2 ok by inversion of ok-A and (2) E2  E’2 by inversion of A2 and (2) {} ` E’2 ok by IH(E2,E’2) with (3) and (4) {} ` ((X.E1) E’2) ok by ok-A with (3) and (5)

Proof: Preservation Lemma case A2: {} ` ((X.E1) E’2) ok IH(E2,E’2) by assumption {} ` ((X.E1) E2)) ok and ((X.E1) E2))  ((X.E1) E’2) by assumption {} ` (X.E1) ok and {} ` E2 ok by inversion of ok-A and (2) E2  E’2 by inversion of A2 and (2) {} ` E’2 ok by IH(E2,E’2) with (3) and (4) {} ` ((X.E1) E’2) ok by ??

Proof: Preservation Lemma case A2: {} ` ((X.E1) E’2) ok IH(E2,E’2) by assumption {} ` ((X.E1) E2)) ok and ((X.E1) E2))  ((X.E1) E’2) by assumption {} ` (X.E1) ok and {} ` E2 ok by inversion of ok-A and (2) E2  E’2 by inversion of A2 and (2) {} ` E’2 ok by IH(E2,E’2) with (3) and (4) {} ` ((X.E1) E’2) ok by ok-A with (3) and (5)

Proof: Preservation Lemma case A3: If IH(E1,E’1) then IH(E1 E2)),(E’1 E2))

Proof: Preservation Lemma case A3: IH((E1 E2)),((E’1 E2)) IH(E1,E’1) by assumption

Proof: Preservation Lemma case A3: If {} ` (E1 E2) ok and (E1 E2)  (E’1 E2) then {} ` (E’1 E2) ok IH(E1,E’1) by assumption

Proof: Preservation Lemma case A3: {} ` (E’1 E2) ok IH(E1,E’1) by assumption {} ` (E1 E2) ok and (E1 E2)  (E’1 E’2) by assumption {} ` E1 ok and {} ` E2 ok by inversion of ok-A and (2) E1  E’1 by inversion of A3 and (2) {} ` E’1 ok by IH(E1,E’1) with (3) and (4) {} ` (E’1 E2) ok by ok-A with (5) and (3)

Proof: Preservation Lemma case A3: {} ` (E’1 E2) ok IH(E1,E’1) by assumption {} ` (E1 E2) ok and (E1 E2)  (E’1 E’2) by assumption {} ` E1 ok and {} ` E2 ok by inversion of ok-A and (2) E1  E’1 by inversion of A3 and (2) {} ` E’1 ok by IH(E1,E’1) with (3) and (4) {} ` (E’1 E2) ok by ok-A with (5) and (3)

Proof: Preservation Lemma case A3: {} ` (E’1 E2) ok IH(E1,E’1) by assumption {} ` (E1 E2) ok and (E1 E2)  (E’1 E’2) by assumption {} ` E1 ok and {} ` E2 ok by inversion of ok-A and (2) E1  E’1 by inversion of A3 and (2) {} ` E’1 ok by IH(E1,E’1) with (3) and (4) {} ` (E’1 E2) ok by ok-A with (5) and (3)

Proof: Preservation Lemma case A3: {} ` (E’1 E2) ok IH(E1,E’1) by assumption {} ` (E1 E2) ok and (E1 E2)  (E’1 E’2) by assumption {} ` E1 ok and {} ` E2 ok by inversion of ok-A and (2) E1  E’1 by inversion of A3 and (2) {} ` E’1 ok by IH(E1,E’1) with (3) and (4) {} ` (E’1 E2) ok by ok-A with (5) and (3)

Proof: Preservation Lemma case A3: {} ` (E’1 E2) ok IH(E1,E’1) by assumption {} ` (E1 E2) ok and (E1 E2)  (E’1 E’2) by assumption {} ` E1 ok and {} ` E2 ok by inversion of ok-A and (2) E1  E’1 by inversion of A3 and (2) {} ` E’1 ok by IH(E1,E’1) with (3) and (4) {} ` (E’1 E2) ok by ok-A with (5) and (3)

Progress Lemma Proof by induction on the derivations of  ` E ok case ok-V: If X 2  then IH(,X) case ok-L: If IH( [ {X}, E) and X   then IH(,(X.E)) case ok-A: If IH(,E1) and IH(,E2) then IH(,(E1 E2)) IH(env,e) = If env = {} and env ` e ok then (steps(e) or isFinal(e))

Proof: Progress Lemma case ok-V: If X 2  then IH(,X)

Proof: Progress Lemma case ok-V: IH(,X) X 2  by assumption

Proof: Progress Lemma case ok-V: If = {} and ` X ok then (steps(X) or isFinal(X)) X 2  by assumption

Proof: Progress Lemma case ok-V: If = {} and {} ` X ok then (steps(X) or isFinal(X)) X 2  by assumption

Proof: Progress Lemma case ok-V: steps(X) or isFinal(X) X 2  by assumption = {} and {} ` X ok by assumption X 2 {} by (1) and (2) (steps(X) or isFinal(X)) by contradiction implied by (3)

Proof: Progress Lemma case ok-V: steps(X) or isFinal(X) X 2  by assumption = {} and {} ` X ok by assumption X 2 {} by ?? (steps(X) or isFinal(X)) by contradiction implied by (3)

Proof: Progress Lemma case ok-V: steps(X) or isFinal(X) X 2  by assumption = {} and {} ` X ok by assumption X 2 {} by (1) and (2) (steps(X) or isFinal(X)) by contradiction implied by (3)

Proof: Progress Lemma case ok-V: (steps(X) or isFinal(X)) X 2  by assumption = {} and {} ` X ok by assumption X 2 {} by (2) and invert-ok-V steps(X) or isFinal(X) by ??

Proof: Progress Lemma case ok-V: (steps(X) or isFinal(X)) X 2  by assumption = {} and {} ` X ok by assumption X 2 {} by (2) and invert-ok-V steps(X) or isFinal(X) by contradiction implied by (3)

Proof: Progress Lemma case ok-L: If IH( [ {X}, E) and X   then IH(,(X.E))

Proof: Progress Lemma case ok-L: IH(,(X.E)) IH( [ {X}, E) and X   by assumption

Proof: Progress Lemma case ok-L: If  = {} and  ` (X.E) ok then (steps((X.E)) or isFinal((X.E))) IH( [ {X}, E) and X   by assumption

Proof: Progress Lemma case ok-L: steps((X.E)) or isFinal((X.E)) IH( [ {X}, E) and X   by assumption  = {} and  ` (X.E) ok by assumption {} ` (X.E) ok by (2) (X.E) 2 F by definition of F and (3) isFinal((X.E)) by definition of isFinal and (4) steps((X.E)) or isFinal((X.E)) by (5)

Proof: Progress Lemma case ok-L: steps((X.E)) or isFinal((X.E)) IH( [ {X}, E) and X   by assumption  = {} and  ` (X.E) ok by assumption {} ` (X.E) ok by ?? (X.E) 2 F by definition of F and (3) isFinal((X.E)) by definition of isFinal and (4) steps((X.E)) or isFinal((X.E)) by (5)

Proof: Progress Lemma case ok-L: steps((X.E)) or isFinal((X.E)) IH( [ {X}, E) and X   by assumption  = {} and  ` (X.E) ok by assumption {} ` (X.E) ok by (2) (X.E) 2 F by definition of F and (3) isFinal((X.E)) by definition of isFinal and (4) steps((X.E)) or isFinal((X.E)) by (5)

Proof: Progress Lemma case ok-L: steps((X.E)) or isFinal((X.E)) IH( [ {X}, E) and X   by assumption  = {} and  ` (X.E) ok by assumption {} ` (X.E) ok by (2) (X.E) 2 F by ?? isFinal((X.E)) by definition of isFinal and (4) steps((X.E)) or isFinal((X.E)) by (5)

Proof: Progress Lemma case ok-L: steps((X.E)) or isFinal((X.E)) IH( [ {X}, E) and X   by assumption  = {} and  ` (X.E) ok by assumption {} ` (X.E) ok by (2) (X.E) 2 F by definition of F and (3) isFinal((X.E)) by definition of isFinal and (4) steps((X.E)) or isFinal((X.E)) by (5)

Proof: Progress Lemma case ok-L: steps((X.E)) or isFinal((X.E)) IH( [ {X}, E) and X   by assumption  = {} and  ` (X.E) ok by assumption {} ` (X.E) ok by (2) (X.E) 2 F by definition of F and (3) isFinal((X.E)) by ?? steps((X.E)) or isFinal((X.E)) by (5)

Proof: Progress Lemma case ok-L: steps((X.E)) or isFinal((X.E)) IH( [ {X}, E) and X   by assumption  = {} and  ` (X.E) ok by assumption {} ` (X.E) ok by (2) (X.E) 2 F by definition of F and (3) isFinal((X.E)) by definition of isFinal and (4) steps((X.E)) or isFinal((X.E)) by (5)

Proof: Progress Lemma case ok-L: steps((X.E)) or isFinal((X.E)) IH( [ {X}, E) and X   by assumption  = {} and  ` (X.E) ok by assumption {} ` (X.E) ok by (2) (X.E) 2 F by definition of F and (3) isFinal((X.E)) by definition of isFinal and (4) steps((X.E)) or isFinal((X.E)) by ??

Proof: Progress Lemma case ok-L: steps((X.E)) or isFinal((X.E)) IH( [ {X}, E) and X   by assumption  = {} and  ` (X.E) ok by assumption {} ` (X.E) ok by (2) (X.E) 2 F by definition of F and (3) isFinal((X.E)) by definition of isFinal and (4) steps((X.E)) or isFinal((X.E)) by (5)

Proof: Progress Lemma case ok-A: If IH(,E1) and IH(,E2) then IH(,(E1 E2))

Proof: Progress Lemma case ok-A: IH(,(E1 E2)) IH(,E1) and IH(,E2)

Proof: Progress Lemma case ok-A: If  = {} and ` (E1 E2) ok then (steps((E1 E2)) or isFinal((E1 E2))) IH(,E1) and IH(,E2) by assumption

Proof: Progress Lemma case ok-A: steps((E1 E2)) or isFinal((E1 E2)) IH(,E1) and IH(,E2) by assumption  = {} and ` (E1 E2) ok by assumption {} ` (E1 E2) ok by (2) {} ` E1 ok and {} ` E2 ok by inversion of ok-A 9 e. (E1 E2)  e by induction on (E1 E2)  e … steps((E1 E2)) by definition of steps and (5) 7. steps((E1 E2)) or isFinal((E1 E2)) by (6)

Proof: Progress Lemma case ok-A: steps((E1 E2)) or isFinal((E1 E2)) IH(,E1) and IH(,E2) by assumption  = {} and ` (E1 E2) ok by assumption {} ` (E1 E2) ok by (2) {} ` E1 ok and {} ` E2 ok by inversion of ok-A 9 e. (E1 E2)  e by induction on (E1 E2)  e … steps((E1 E2)) by definition of steps and (5) 7. steps((E1 E2)) or isFinal((E1 E2)) by (6)

Proof: Progress Lemma case ok-A: steps((E1 E2)) or isFinal((E1 E2)) IH(,E1) and IH(,E2) by assumption  = {} and ` (E1 E2) ok by assumption {} ` (E1 E2) ok by (2) {} ` E1 ok and {} ` E2 ok by inversion of ok-A 9 e. (E1 E2)  e by induction on (E1 E2)  e … steps((E1 E2)) by definition of steps and (5) 7. steps((E1 E2)) or isFinal((E1 E2)) by (6)

Proof: Progress Lemma case ok-A: steps((E1 E2)) or isFinal((E1 E2)) IH(,E1) and IH(,E2) by assumption  = {} and ` (E1 E2) ok by assumption {} ` (E1 E2) ok by (2) {} ` E1 ok and {} ` E2 ok by inversion of ok-A 9 e. (E1 E2)  e by cases … steps((E1 E2)) by definition of steps and (5) 7. steps((E1 E2)) or isFinal((E1 E2)) by (6)

Proof: Progress Lemma case ok-A: steps((E1 E2)) or isFinal((E1 E2)) IH(,E1) and IH(,E2) by assumption  = {} and ` (E1 E2) ok by assumption {} ` (E1 E2) ok by (2) {} ` E1 ok and {} ` E2 ok by inversion of ok-A 9 e. (E1 E2)  e by cases … steps((E1 E2)) by definition of steps and (5) 7. steps((E1 E2)) or isFinal((E1 E2)) by (6)

Proof: Progress Lemma case ok-A: steps((E1 E2)) or isFinal((E1 E2)) IH(,E1) and IH(,E2) by assumption  = {} and ` (E1 E2) ok by assumption {} ` (E1 E2) ok by (2) {} ` E1 ok and {} ` E2 ok by inversion of ok-A 9 e. (E1 E2)  e by cases … steps((E1 E2)) by definition of steps and (5) 7. steps((E1 E2)) or isFinal((E1 E2)) by (6)

Proof: Progress Lemma 5. 9 e. (E1 E2)  e by cases (E1 E2) case E1 = (X’.E’) and E2 = (X’’.E’’): 5.1. (E1 E2)  [X’ Ã(X’’.E’’) ] E’ by A1 case E1 = (X’.E’) and E2  F: 5.1. E2  E’2 by IH({},E2) with (4) and E2  F 5.2. (E1 E2)  (E1 E’2) by A2 with (5.1) case E1  F : 5.1. E1  E’1 by IH({},E1) with (4) and E1  F 5.2. (E’1 E2)  (E’1 E2) by A3 with (5.1)

Proof: Progress Lemma 5. 9 e. (E1 E2)  e by cases (E1 E2) case E1 = (X’.E’) and E2 = (X’’.E’’): 5.1. (E1 E2)  [X’ Ã(X’’.E’’) ] E’ by ?? case E1 = (X’.E’) and E2  F: 5.1. E2  E’2 by IH({},E2) with (4) and E2  F 5.2. (E1 E2)  (E1 E’2) by A2 with (5.1) case E1  F : 5.1. E1  E’1 by IH({},E1) with (4) and E1  F 5.2. (E’1 E2)  (E’1 E2) by A3 with (5.1)

Proof: Progress Lemma 5. 9 e. (E1 E2)  e by cases (E1 E2) case E1 = (X’.E’) and E2 = (X’’.E’’): 5.1. (E1 E2)  [X’ Ã(X’’.E’’) ] E’ by A1 case E1 = (X’.E’) and E2  F: 5.1. E2  E’2 by IH({},E2) with (4) and E2  F 5.2. (E1 E2)  (E1 E’2) by A2 with (5.1) case E1  F : 5.1. E1  E’1 by IH({},E1) with (4) and E1  F 5.2. (E’1 E2)  (E’1 E2) by A3 with (5.1)

Proof: Progress Lemma 5. 9 e. (E1 E2)  e by cases (E1 E2) case E1 = (X’.E’) and E2 = (X’’.E’’): 5.1. (E1 E2)  [X’ Ã(X’’.E’’) ] E’ by A1 case E1 = (X’.E’) and E2  F: 5.1. E2  E’2 by ?? 5.2. (E1 E2)  (E1 E’2) case E1  F : 5.1. E1  E’1 by IH({},E1) with (4) and E1  F 5.2. (E’1 E2)  (E’1 E2) by A3 with (5.1)

Proof: Progress Lemma 5. 9 e. (E1 E2)  e by cases (E1 E2) case E1 = (X’.E’) and E2 = (X’’.E’’): 5.1. (E1 E2)  [X’ Ã(X’’.E’’) ] E’ by A1 case E1 = (X’.E’) and E2  F: 5.1. E2  E’2 by IH({},E2) with (4) and E2  F 5.2. (E1 E2)  (E1 E’2) by ?? case E1  F : 5.1. E1  E’1 by IH({},E1) with (4) and E1  F 5.2. (E’1 E2)  (E’1 E2) by A3 with (5.1)

Proof: Progress Lemma 5. 9 e. (E1 E2)  e by cases (E1 E2) case E1 = (X’.E’) and E2 = (X’’.E’’): 5.1. (E1 E2)  [X’ Ã(X’’.E’’) ] E’ by A1 case E1 = (X’.E’) and E2  F: 5.1. E2  E’2 by IH({},E2) with (4) and E2  F 5.2. (E1 E2)  (E1 E’2) by A2 with (5.1) case E1  F : 5.1. E1  E’1 by IH({},E1) with (4) and E1  F 5.2. (E’1 E2)  (E’1 E2) by A3 with (5.1)

Proof: Progress Lemma 5. 9 e. (E1 E2)  e by cases (E1 E2) case E1 = (X’.E’) and E2 = (X’’.E’’): 5.1. (E1 E2)  [X’ Ã(X’’.E’’) ] E’ by A1 case E1 = (X’.E’) and E2  F: 5.1. E2  E’2 by IH({},E2) with (4) and E2  F 5.2. (E1 E2)  (E1 E’2) by A2 with (5.1) case E1  F : 5.1. E1  E’1 by ?? 5.2. (E’1 E2)  (E’1 E2)

Proof: Progress Lemma 5. 9 e. (E1 E2)  e by cases (E1 E2) case E1 = (X’.E’) and E2 = (X’’.E’’): 5.1. (E1 E2)  [X’ Ã(X’’.E’’) ] E’ by A1 case E1 = (X’.E’) and E2  F: 5.1. E2  E’2 by IH({},E2) with (4) and E2  F 5.2. (E1 E2)  (E1 E’2) by A2 with (5.1) case E1  F : 5.1. E1  E’1 by IH({},E1) with (4) and E1  F 5.2. (E’1 E2)  (E’1 E2) by ??

Proof: Progress Lemma 5. 9 e. (E1 E2)  e by cases (E1 E2) case E1 = (X’.E’) and E2 = (X’’.E’’): 5.1. (E1 E2)  [X’ Ã(X’’.E’’) ] E’ by A1 case E1 = (X’.E’) and E2  F: 5.1. E2  E’2 by IH({},E2) with (4) and E2  F 5.2. (E1 E2)  (E1 E’2) by A2 with (5.1) case E1  F : 5.1. E1  E’1 by IH({},E1) with (4) and E1  F 5.2. (E’1 E2)  (E’1 E2) by A3 with (5.1)

Summary Soundness Theorem: If {} ` E ok and E * E’ then :stuck(E’) Preservation Lemma: If {} ` E ok and E  E’ then {} ` E’ ok Progress Lemma: If {} ` E ok then (steps(E) or isFinal(E)) Substitution Lemma: If  [ {X} ` E ok and {} ` E’ ok then  ` [XÃE’]E ok

Summary Soundness follows from Preservation and Progress by induction on the ?? relation Soundness means well formed programs don’t get “stuck”

Summary Soundness follows from Preservation and Progress by induction on the * relation Soundness means well formed programs don’t get “stuck”

Summary Soundness follows from Preservation and Progress by induction on the * relation Soundness means well formed programs don’t get “stuck” Preservation follows by induction on the ?? relation

Summary Soundness follows from Preservation and Progress by induction on the * relation Soundness means well formed programs don’t get “stuck” Preservation follows by induction on the  relation

Summary Soundness follows from Preservation and Progress by induction on the * relation Soundness means well formed programs don’t get “stuck” Preservation follows by induction on the  relation Progress follows by induction on the wellformedness relation ??

Summary Soundness follows from Preservation and Progress by induction on the * relation Soundness means well formed programs don’t get “stuck” Preservation follows by induction on the  relation Progress follows by induction on the wellformedness relation ( ` E ok)

Lesson Learned High-level structure of soundness proof All soundness for SOS semantics proofs are basically the same The details vary in small but important ways Proofs are straightforward but tedious Details easy to get confused if not organized Someone ought to automate these proofs or at least their checking See Twelf, Coq, Isabella/HOL … etc.