Winter 2004/5Pls – expresssion-lang – Catriel Beeri22 Informal Analysis Goal: prove the semantics is deterministic Stages: Values --- we know they have.

Slides:



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

Substitution & Evaluation Order cos 441 David Walker.
Circuit and Communication Complexity. Karchmer – Wigderson Games Given The communication game G f : Alice getss.t. f(x)=1 Bob getss.t. f(y)=0 Goal: Find.
Data-Flow Analysis II CS 671 March 13, CS 671 – Spring Data-Flow Analysis Gather conservative, approximate information about what a program.
Possible World Semantics for Modal Logic
- Vasvi Kakkad.  Formal -  Tool for mathematical analysis of language  Method for precisely designing language  Well formed model for describing and.
Primitive Recursive Functions (Chapter 3)
Vered Gafni – Formal Development of Real Time Systems 1 Statecharts Semantics.
SECURITY AND VERIFICATION Lecture 4: Cryptography proofs in context Tamara Rezk INDES TEAM, INRIA January 24 th, 2012.
Hoare’s Correctness Triplets Dijkstra’s Predicate Transformers
Elements of Lambda Calculus Functional Programming Academic Year Alessandro Cimatti
Expressions and Statements. 2 Contents Side effects: expressions and statements Expression notations Expression evaluation orders Conditional statements.
Getting started with ML ML is a functional programming language. ML is statically typed: The types of literals, values, expressions and functions in a.
Congestion Games with Player- Specific Payoff Functions Igal Milchtaich, Department of Mathematics, The Hebrew University of Jerusalem, 1993 Presentation.
Distributed Computing 5. Snapshot Shmuel Zaks ©
Catriel Beeri Pls/Winter 2004/5 last 55 Two comments on let polymorphism I. What is the (time, space) complexity of type reconstruction? In practice –
Catriel Beeri Pls/Winter 2004/5 functional-language 1 Substitution Semantics of FL – a simple functional language FL is EL + (non-recursive) function creation.
Complexity 11-1 Complexity Andrei Bulatov Space Complexity.
1 Introduction to Computability Theory Lecture12: Reductions Prof. Amos Israeli.
Introduction to Computability Theory
1 Operational Semantics Mooly Sagiv Tel Aviv University Textbook: Semantics with Applications.
Katz Formal Specifications Larch 1 Algebraic Specification and Larch Formal Specifications of Complex Systems Shmuel Katz The Technion.
Catriel Beeri Pls/Winter 2004/5 types 1 Types Three chapters:  General introduction to types  A simple static monomorphic type system (with type checking.
Catriel Beeri Pls/Winter 2004/5 type reconstruction 1 Type Reconstruction & Parametric Polymorphism  Introduction  Unification and type reconstruction.
Winter 2004/5Pls – inductive – Catriel Beeri1 Inductive Definitions (our meta-language for specifications)  Examples  Syntax  Semantics  Proof Trees.
Catriel Beeri Pls/Winter 2004/5 inductive-revisited 1 Inductive definitions revisited  Generated and Freely generated sets oPattern match, unification.
Catriel Beeri Pls/Winter 2004/5 interpreters 1 Language processors for EL  An interpreter transEval from  An interpreter natEval from An important theme:
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.
Sparkle A theorem prover for the functional language Clean Maarten de Mol University of Nijmegen February 2002.
1 Semantics Q S EMANTICS (Q1,’07) Week 4 Jacob Andersen PhD student
Winter 2004/5Pls – analysis – Catriel Beeri1 A precise analysis  Determinism, soundness, completeness for  Determinism for  Additional properties of.
Operational Semantics Semantics with Applications Chapter 2 H. Nielson and F. Nielson
Tim Sheard Oregon Graduate Institute Lecture 11: A Reduction Semantics for MetaML CS510 Section FSC Winter 2005 Winter 2005.
Winter 2003/4Pls – syntax – Catriel Beeri1 SYNTAX Syntax: form, structure The syntax of a pl: The set of its well-formed programs The rules that define.
Programming Language Semantics Denotational Semantics Chapter 5 Part III Based on a lecture by Martin Abadi.
©Silberschatz, Korth and Sudarshan7.1Database System Concepts Chapter 7: Relational Database Design First Normal Form Pitfalls in Relational Database Design.
Lesson 4 Typed Arithmetic Typed Lambda Calculus 1/21/02 Chapters 8, 9, 10.
Theory of Computing Lecture 21 MAS 714 Hartmut Klauck.
Formal Specification of Intrusion Signatures and Detection Rules By Jean-Philippe Pouzol and Mireille Ducassé 15 th IEEE Computer Security Foundations.
Recursive Data Structures and Grammars  Themes  Recursive Description of Data Structures  Recursive Definitions of Properties of Data Structures  Recursive.
Program Analysis and Verification Spring 2014 Program Analysis and Verification Lecture 4: Axiomatic Semantics I Roman Manevich Ben-Gurion University.
CSE Winter 2008 Introduction to Program Verification January 31 proofs through simplification.
CSE Winter 2008 Introduction to Program Verification January 15 tautology checking.
Recursive Data Structures and Grammars  Themes  Recursive Description of Data Structures  Recursive Definitions of Properties of Data Structures  Recursive.
Advanced Formal Methods Lecture 3: Simply Typed Lambda calculus Mads Dam KTH/CSC Course 2D1453, Some material from B. Pierce: TAPL + some from.
Types and Programming Languages
Operational Semantics Mooly Sagiv Tel Aviv University Textbook: Semantics with Applications Chapter.
COMP 412, FALL Type Systems II C OMP 412 Rice University Houston, Texas Fall 2000 Copyright 2000, Robert Cartwright, all rights reserved. Students.
Types and Programming Languages Lecture 3 Simon Gay Department of Computing Science University of Glasgow 2006/07.
Operational Semantics Mooly Sagiv Tel Aviv University Sunday Scrieber 8 Monday Schrieber.
Process Algebra (2IF45) Basic Process Algebra Dr. Suzana Andova.
CSE Winter 2008 Introduction to Program Verification February 5 calculating with simplify.
Chapter 8 Relational Database Design. 2 Relational Database Design: Goals n Reduce data redundancy (undesirable replication of data values) n Minimize.
Operational Semantics Mooly Sagiv Reference: Semantics with Applications Chapter 2 H. Nielson and F. Nielson
Operational Semantics Mooly Sagiv Reference: Semantics with Applications Chapter 2 H. Nielson and F. Nielson
1 Proving Properties of Recursive List Functions CS 270 Math Foundations of CS Jeremy Johnson.
Chapter 3 of Programming Languages by Ravi Sethi
Graph-Based Operational Semantics
Basic Block Optimizations
Lesson 4 Typed Arithmetic Typed Lambda Calculus
Axiomatic semantics Points to discuss: The assignment statement
Logics for Data and Knowledge Representation
MA/CSSE 474 More Math Review Theory of Computation
CS 611: Lecture 10 More Lambda Calculus September 20, 1999
This Lecture Substitution model
CS 611: Lecture 10 More Lambda Calculus September 20, 1999
Switching Lemmas and Proof Complexity
Live Variables – Basic Block
Basic Block Optimizations
Presentation transcript:

Winter 2004/5Pls – expresssion-lang – Catriel Beeri22 Informal Analysis Goal: prove the semantics is deterministic Stages: Values --- we know they have no transitions Minimal non-values --- consider the axioms General composite expressions --- consider the propagation rules

Winter 2004/5Pls – expresssion-lang – Catriel Beeri23 “Minimal” non-value expressions Reducible expression (redex): provided it has a transition (condition?) (always has a transition) by (op-apply): 3+4  7 by (if_) : if true 3 4  3 Both are reductions Claim: there is a a unique transition from a redex. (both ) Q: Why “minimal”?

Winter 2004/5Pls – expresssion-lang – Catriel Beeri24 Intuition: The rules of  define paths in a composite expression E; each descends to a “minimal” non- value sub-expression F A path defined by the rules: a selection path The sub-expression at its end: a selected sub-expression If F is a redex, has a transition F  F’,  E has a transition E  {F’/F}E (replacement) Arbitrary composite expressions

Winter 2004/5Pls – expresssion-lang – Catriel Beeri25 Examples applic tuple applic +tuple 3545 (eval-rand) (eval-tuple) (2,1) (op-apply)

Winter 2004/5Pls – expresssion-lang – Catriel Beeri26 applic tuple applic +tuple 3545 (eval-rand) (eval-tuple) (2,2) (op-apply)

Winter 2004/5Pls – expresssion-lang – Catriel Beeri27 For , an expression may have several selected sub- expressions, several transitions But, for  d, there is a unique selected sub- expression, hence at most one transition How do argue this is the case?

Winter 2004/5Pls – expresssion-lang – Catriel Beeri28 Consider application E1 E2 E1 is not a value: – (op-apply), (eval-rand) cannot be used. – (eval-rator) can be used, if E1 has a transition E1 is a value, E2 is not: –(op-apply), (eval-rator) cannot be used (why?) –(eval-rand) can be used, if E2 has a transition Both E1 E2 are values: –(eval-rator),(eval-rand) cannot be used, –Possibly (op-apply) can be used

Winter 2004/5Pls – expresssion-lang – Catriel Beeri29 This “shows” that for  d : For each composite expression E, there is at most one transition The binary relation  d is functional (a partial function) This transition semantics is deterministic

Winter 2004/5Pls – expresssion-lang – Catriel Beeri30 Natural (evaluation) Semantics Transition semantics deals with one step Natural semantics deals with a complete computation EV transition Natural:

Winter 2004/5Pls – expresssion-lang – Catriel Beeri31 Natural semantics rules (nat-int)(nat-bool) (nat-op) (nat-applic-op)(nat-tuple)(nat-if-true)(nat-if-false) if defined

Winter 2004/5Pls – expresssion-lang – Catriel Beeri32 A proof tree in natural semantics Q: What is the difference in shape of trees between transition and natural?

Winter 2004/5Pls – expresssion-lang – Catriel Beeri33 A (faulty) proof tree in natural semantics: (what is missing?)

Winter 2004/5Pls – expresssion-lang – Catriel Beeri34 Properties of natural semantics For each value V, For each E, if then E’ is a value (The value variables in the rules are not needed!) For each E, there is at most one proof tree, hence at most one value (main idea of proof: For each expression category, except if, a unique rule.) Natural semantics is a functional relation --- it defines a partial function

Winter 2004/5Pls – expresssion-lang – Catriel Beeri35  On run-time errors High level pl’s do not allow run-time errors to occur w/o taking notice: prevent, detect and treat A semantics should specify explicitly both what are errors, error handling

Winter 2004/5Pls – expresssion-lang – Catriel Beeri36 A computation from E may get stuck in a non-value final expression 3/0, true + 2, if 3 4 5, 2 3 We shall: Determine the forms of error expressions Introduce terminology Add rules that specify error treatment to all specs

Winter 2004/5Pls – expresssion-lang – Catriel Beeri37 Candidate for a reduction: a expression of the forms For both, proper rules certainly do not apply If there is no transition: a run-time error 4/0, 4 2, false + 3, + (2, 3, 4) (All, except the first, are run-time type errors) Candidate for a reduction: either a redex or a run-time error Claim: there is a at most one transition from a candidate for a reduction (for both ,  d).

Winter 2004/5Pls – expresssion-lang – Catriel Beeri38 The run-time errors: 3/0, 2+false, + (2,3,4) 2 4 if 5 4 6

Winter 2004/5Pls – expresssion-lang – Catriel Beeri39 For each composite expression: each selected sub-expression is a candidate for a reduction Def: E contains an error: a selected sub-expression is a run-time error E is an error: ( a stuck expression) all its selected sub-expressions are run-time errors Discuss differences between ,  d on these concepts

Winter 2004/5Pls – expresssion-lang – Catriel Beeri40 Error treatment --- error rules We add a special “constant” ER (not a regular expression/value) We add error rules to specify error handling An expression may transform in one step to ER iff It is a run-time error (error axioms) It contains an error (error propagation rules) Def: Exval - extended values: Val {ER} extended expressions: Exp {ER}

Winter 2004/5Pls – expresssion-lang – Catriel Beeri41 Need to change assumption about built-in: For each built-in operation o, is a total function from Val to Exval (returns a value or ER) Takes care of

Winter 2004/5Pls – expresssion-lang – Catriel Beeri42 Some error rules: For other constructs –left to you For  d -- left for you The new set of rules Is there a change in selected sub-expressions? Can rules be improved upon by using v instead of e?

Winter 2004/5Pls – expresssion-lang – Catriel Beeri43 Example:  ER applic tuple applic seq (error-rand) (error-tuple) (2,1) (apply- error)

Winter 2004/5Pls – expresssion-lang – Catriel Beeri44 Rules for natural semantics: The other constructs – left to you The new set:

Winter 2004/5Pls – expresssion-lang – Catriel Beeri45 Additional properties for semantics with error rules: Soundness: an expression cannot evaluate to both a value and ER Completeness/Progress: If E is not in Exval, then E evaluates to some XV in Exval (progress --- evaluation does not get stuck) Determinism implies soundness (we argue that is deterministic, as before) Completeness: Argue that a candidate for a reduction is never stuck, extend to all expressions