Programming Language Semantics Inductive Definitions Mooly SagivEran Yahav Schrirber 317Open space 03-640-760603-640-5358.

Slides:



Advertisements
Similar presentations
Substitution & Evaluation Order cos 441 David Walker.
Advertisements

Rigorous Software Development CSCI-GA Instructor: Thomas Wies Spring 2012 Lecture 11.
Formal Semantics of Programming Languages 虞慧群 Topic 5: Axiomatic Semantics.
1/22 Programs : Semantics and Verification Charngki PSWLAB Programs: Semantics and Verification Mordechai Ben-Ari Mathematical Logic for Computer.
CS 355 – Programming Languages
Lecture 02 – Structural Operational Semantics (SOS) Eran Yahav 1.
Programming Language Semantics Denotational Semantics Chapter 5.
Programming Language Semantics Axiomatic Semantics Chapter 6.
Programming Language Semantics Denotational Semantics Chapter 5 Based on a lecture by Martin Abadi.
1 Operational Semantics Mooly Sagiv Tel Aviv University Textbook: Semantics with Applications.
Programming Language Semantics Mooly SagivEran Yahav Schrirber 317Open space html://
Denotational Semantics Syntax-directed approach, generalization of attribute grammars: –Define context-free abstract syntax –Specify syntactic categories.
Programming Language Semantics Denotational Semantics Chapter 5 Part II.
Discrete Mathematics Lecture 2 Alexander Bukharovich New York University.
Programming Language Semantics Mooly SagivEran Yahav Schrirber 317Open space html://
1 Program Analysis Mooly Sagiv Tel Aviv University Textbook: Principles of Program Analysis.
Semantics with Applications Mooly Sagiv Schrirber html:// Textbooks:Winskel The.
Operational Semantics Semantics with Applications Chapter 2 H. Nielson and F. Nielson
Program Analysis Mooly Sagiv Tel Aviv University Sunday Scrieber 8 Monday Schrieber.
1 Section 3.3 Mathematical Induction. 2 Technique used extensively to prove results about large variety of discrete objects Can only be used to prove.
1 Propositional calculus versions. 2 3-value (Lukasziewicz) logic Truth values T,F,N(unknown)
Section Section Summary Introduction to Boolean Algebra Boolean Expressions and Boolean Functions Identities of Boolean Algebra Duality The Abstract.
 2004 SDU Introduction to the Theory of Computation My name: 冯好娣 My office: 计算中心 430
Discrete Mathematics, Part II CSE 2353 Fall 2007 Margaret H. Dunham Department of Computer Science and Engineering Southern Methodist University Some slides.
CSE 311 Foundations of Computing I Lecture 8 Proofs and Set Theory Spring
Formal Semantics of Programming Languages 虞慧群 Topic 3: Principles of Induction.
Principles of programming languages 5: An operational semantics of a small subset of C Department of Information Science and Engineering Isao Sasano.
CS 611: Lecture 6 Rule Induction September 8, 1999 Cornell University Computer Science Department Andrew Myers.
Language: Set of Strings
Logical Agents Chapter 7. Outline Knowledge-based agents Logic in general Propositional (Boolean) logic Equivalence, validity, satisfiability.
Section 3.3: Mathematical Induction Mathematical induction is a proof technique that can be used to prove theorems of the form:  n  Z +,P(n) We have.
CSE 311 Foundations of Computing I Lecture 9 Proofs and Set Theory Autumn 2012 CSE
(CSC 102) Lecture 23 Discrete Structures. Previous Lecture Summery  Sequences  Alternating Sequence  Summation Notation  Product Notation  Properties.
1 Georgia Tech, IIC, GVU, 2006 MAGIC Lab Rossignac Lecture 02: QUANTIFIERS Sections 1.3 and 1.4 Jarek Rossignac CS1050:
LDK R Logics for Data and Knowledge Representation First Order Logics (FOL) Originally by Alessandro Agostini and Fausto Giunchiglia Modified by Fausto.
Boolean Algebra M. AL- Towaileb1. Boolean Functions In Boolean algebra we work with the set {0,1}, where: 0 ≡ F (False) & 1 ≡ T (True). The 3 Operations.
Classifications LanguageGrammarAutomaton Regular, right- linear Right-linear, left-linear DFA, NFA Context-free PDA Context- sensitive LBA Recursively.
Compiler Principles Fall Compiler Principles Lecture 7: Lowering Correctness Roman Manevich Ben-Gurion University of the Negev.
Operational Semantics Mooly Sagiv Tel Aviv University Textbook: Semantics with Applications Chapter.
Program Analysis and Verification
Copyright © Cengage Learning. All rights reserved. CHAPTER 8 RELATIONS.
CSE 311: Foundations of Computing Fall 2013 Lecture 8: Proofs and Set theory.
Types and Programming Languages Lecture 3 Simon Gay Department of Computing Science University of Glasgow 2006/07.
Induction Practice CS1050. Prove that whenever n is a positive integer. Proof: Basis Case: Let n = 1, then.
Formal Semantics of Programming Languages 虞慧群 Topic 2: Operational Semantics.
Lecture 041 Predicate Calculus Learning outcomes Students are able to: 1. Evaluate predicate 2. Translate predicate into human language and vice versa.
Operational Semantics Mooly Sagiv Tel Aviv University Sunday Scrieber 8 Monday Schrieber.
Operational Semantics Mooly Sagiv Reference: Semantics with Applications Chapter 2 H. Nielson and F. Nielson
1 Section 7.1 First-Order Predicate Calculus Predicate calculus studies the internal structure of sentences where subjects are applied to predicates existentially.
Operational Semantics Mooly Sagiv Reference: Semantics with Applications Chapter 2 H. Nielson and F. Nielson
Program Analysis and Verification Noam Rinetzky Lecture 2: Operational Semantics 1 Slides credit: Tom Ball, Dawson Engler, Roman Manevich, Erik.
CS.462 Artificial Intelligence SOMCHAI THANGSATHITYANGKUL Lecture 04 : Logic.
1 Section 4.4 Inductive Proof What do we believe about nonempty subsets of N? Since  N, <  is well-founded, and in fact it is linear, it follows that.
CENG 424-Logic for CS Introduction Based on the Lecture Notes of Konstantin Korovin, Valentin Goranko, Russel and Norvig, and Michael Genesereth.
The Relation Induced by a Partition
3. The Logic of Quantified Statements Summary
Advanced Algorithms Analysis and Design
ARTIFICIAL INTELLIGENCE
Mathematical Induction Recursion
BaSIC Math Reviews.
CSE 311: Foundations of Computing
MA/CSSE 474 More Math Review Theory of Computation
Applied Discrete Mathematics Week 9: Integer Properties
The Data Element.
Formal Methods in software development
Predicates and Quantifiers
Advanced Analysis of Algorithms
Logic Logic is a discipline that studies the principles and methods used to construct valid arguments. An argument is a related sequence of statements.
The Data Element.
Agenda Proofs (Konsep Pembuktian) Direct Proofs & Counterexamples
Presentation transcript:

Programming Language Semantics Inductive Definitions Mooly SagivEran Yahav Schrirber 317Open space html:// Textbook:Winskel The Formal Semantics of Programming Languages CS

Outline Rule induction Special rule induction Proof rules of the operational semantics Least fixed points

Derivations A set of rule instances R consists pairs X/y where X is a finite set and y is an element –X/y – rule instance –X – premises –y – conclusion d  R y – d is an R-derivation of y –(  /y)  R y if (  /y)  R –({d 1, …, d n }/y)  R y if ({x 1, …, x n }/y)  R and d 1  R x 1 & … & d n  R x n

Derivations Expressions R= {(  /  n) | n  N,    }  {(  /   (X)) : X  Loc,    }  {({  n 0,  n 1 }/  m) | n 0, n 1, m  N, m= n 0 +n 1,    }  {({  n 0,  n 1 }/  m) | n 0, n 1, m  N, m= n 0 -n 1,    }  {({  n 0,  n 1 }/  m) | n 0, n 1, m  N, m= n 0  n 1,    } (  /  5)  R  5 (  / <X, [ X  8, Y  7]  8)  R X, [ X  8, Y  7]  8 ({  /  5), (  / <X, [ X  8, Y  7]  8)})  R (5+X), [ X  8, Y  7]  13 ({(  /  5)})  R (5+5), [ X  8, Y  7]  10

Rule induction A special induction Define a set by rules I R ={x |  R x} Examples – of Aexp    N such that  n – of Bexp    T such that  t – of Com     such that   ’ Show that the property is true for all elements by induction on the rule application

The general principle of rule induction Let I R ={x |  R x} Let P be a property  x  I R P(X)  for all the rule instances (X/y) in R for which X  I R  z  X. P(z)  P(y)

Justifying the principle of induction A set Q is closed under rule instances or simply R-closed if for all rule instances X/y X  Q  y  Q Proposition 4.1: –I R is closed and –If Q is an R-closed set then I R  Q Application –Q = { x  I R | P(x) } Examples –R = {(  /0)}  {{n}/{n+1) | n   } –Referential transparency for expressions

Expressing Syntax using Rules a ::= … | a 0 + a 1 | … a 0 : Aexp a 1 : Aexp a 0 +a 1 : Aexp

Special Rule Induction Handles rules of different types BNF –c ::= … | X := a | …| if b then c 0 else c 1 | … Rules –X : Loc a : Exp X:=a: Com –b : Bexp c 0 : Com c 1 : Com if b then c 0 else c 1 : Com

The special principle of rule induction Let I R ={x |  R x} A  I R Let Q be a property  a  A. Q(a)  for all the rule instances (X/y) in R for which X  I R and y  A  x  X  A.Q(x)  Q(y)

Proof rule for operational semantics Arithmetic Expressions P(a, , n) is true of all evaluations  n if it is preserved by the expression rules

Proof rule for operational semantics Arithmetic Expressions P(a, , n) is true of all evaluations  n if it is preserved by the expression rules

Rule Induction for Arithmetic Expressions  a  Aexp, , n  N.  n  P(a, , n) iff  n  N, . P(n, , n) &  X  Loc, . P(X, ,  (X)) &  a 0, a 1  Aexp, , n 0, n 1  N.  n 0 & P(a0, , n0) &  n 1 & P(a 1, , n 1 )  P(a0+a1, , n 0 +n 1 ) & …

Proof rule for operational semantics Boolean Expressions P(b, , t) is true of all evaluations  t if it is preserved by the Boolean expression rules Define a subset of –(Aexp  N)  (Bexp  T) Obtained from the special principle of induction for properties P(b, , t) on the subset Bexp  T

Rule Induction for Booleans  b  Bexp, , t  T.  t  P(b, , t) iff . P(false, , false) & . P(true, , true) &  a 0, a 1  Aexp, , n 0, n 1  N.  m&  n & m=n  P(a 0 =a 1, , true) &  a 0, a 1  Aexp, , n 0, n 1  N.  m&  n & m  n  P(a 0 =a 1, ,false) … &  b  Bexp,  , t  T.  t & P(b, , t)  P(  b, ,  t) &…

Proof rule for operational semantics Commands P(c, ,  ’) is true of all evaluations  ’ if it is preserved by the command rules Define a subset of –(Aexp  N)  (Bexp  T)  (Com  ) Obtained from the special principle of induction for properties P(c, ,  ’) on the subset Com 

Rule Induction for Commands  c  Com, ,  ’ .   ’  P(c, ,  ’) iff . P(skip, ,  ) &  X  Loc, a  Bexp, .  m  P(X:=a, ,  [m/X]) &  c 0, c 1  Com, ,  ’,  ’’ .   ’’& P(c 0, ,  ’) &   ’ &P(c 1,  ’’,  ’)  P(c 0 ;c 1, ,  ’) & …

Proposition 4.7 Define Loc L (c) to be the variables which appear on the left side of some assignment in c Let y  Loc For all commands c and states ,  ’ Y  Loc L (c).   ’   (Y) =  ’(Y)

Operators and their least fixed points For a set of rule instances R –R(B)={y |  X  B, X/y  R} Proposition 4.11 A set B is closed under R if R(B)  B R is monotonic –A  B  R(A)  R(B) Define the sequence of sets –A 0 = R 0 (  ) =  –A 1 = R 1 (  ) =R(  ) –A 2 = R 2 (  ) =R(R(  )) –…–… –A n = R n (  ) Define A =  n  A n

Proposition 4.12 (i)A is R-closed (ii)R(A) = A (iii)A is the least R-closed set Let fix(R) denote the least fixed point of R fix(R)=  n  R n (  )

Summary Induction allows to prove properties of the programming language Example properties –Deterministic –Referential transparency –Equivalent of small step and natural semantics