Translation Validation A.PnueliM.SiegelE.Singerman.

Slides:



Advertisements
Similar presentations
Technologies for finding errors in object-oriented software K. Rustan M. Leino Microsoft Research, Redmond, WA Lecture 1 Summer school on Formal Models.
Advertisements

Automated Theorem Proving Lecture 1. Program verification is undecidable! Given program P and specification S, does P satisfy S?
Copyright , Doron Peled and Cesare Tinelli. These notes are based on a set of lecture notes originally developed by Doron Peled at the University.
Functional Verification III Prepared by Stephen M. Thebaut, Ph.D. University of Florida Software Testing and Verification Lecture Notes 23.
Introducing Formal Methods, Module 1, Version 1.1, Oct., Formal Specification and Analytical Verification L 5.
Control-Flow Graphs & Dataflow Analysis CS153: Compilers Greg Morrisett.
1 1 Regression Verification for Multi-Threaded Programs Sagar Chaki, SEI-Pittsburgh Arie Gurfinkel, SEI-Pittsburgh Ofer Strichman, Technion-Haifa Originally.
Hoare’s Correctness Triplets Dijkstra’s Predicate Transformers
Rigorous Software Development CSCI-GA Instructor: Thomas Wies Spring 2012 Lecture 11.
Formal Semantics of Programming Languages 虞慧群 Topic 5: Axiomatic Semantics.
1 Translation Validation: From Simulink to C Michael RyabtsevOfer Strichman Technion, Haifa, Israel Acknowledgement: sponsored by a grant from General.
This Week Finish relational semantics Hoare logic Interlude on one-point rule Building formulas from programs.
David Evans CS655: Programming Languages University of Virginia Computer Science Lecture 19: Minding Ps & Qs: Axiomatic.
Copyright © 2006 Addison-Wesley. All rights reserved.1-1 ICS 410: Programming Languages Chapter 3 : Describing Syntax and Semantics Axiomatic Semantics.
ISBN Chapter 3 Describing Syntax and Semantics.
Copyright © 2006 Addison-Wesley. All rights reserved. 3.5 Dynamic Semantics Meanings of expressions, statements, and program units Static semantics – type.
Fall Semantics Juan Carlos Guzmán CS 3123 Programming Languages Concepts Southern Polytechnic State University.
1/22 Programs : Semantics and Verification Charngki PSWLAB Programs: Semantics and Verification Mordechai Ben-Ari Mathematical Logic for Computer.
CS 355 – Programming Languages
Formal Methods of Systems Specification Logical Specification of Hard- and Software Prof. Dr. Holger Schlingloff Institut für Informatik der.
Reading, Writing and Relations Towards Extensional Semantics for Effect Analyses Andrew Kennedy Microsoft Research Cambridge (joint work with Nick Benton,
Self-Reference - Induction Cmput Lecture 7 Department of Computing Science University of Alberta ©Duane Szafron 1999 Some code in this lecture is.
The Programming Discipline Professor Stephen K. Kwan 2010 Things you need to know (learn) for developing large computer programs.
Dr. Muhammed Al-Mulhem 1ICS ICS 535 Design and Implementation of Programming Languages Part 1 Fundamentals (Chapter 4) Axiomatic Semantics ICS 535.
On the Correctness of Model Transformations Gabor Karsai ISIS/Vanderbilt University.
Describing Syntax and Semantics
Proving Program Correctness The Axiomatic Approach.
Using Mathematica for modeling, simulation and property checking of hardware systems Ghiath AL SAMMANE VDS group : Verification & Modeling of Digital systems.
Introduction to Proofs
Reading and Writing Mathematical Proofs
Runtime Refinement Checking of Concurrent Data Structures (the VYRD project) Serdar Tasiran Koç University, Istanbul, Turkey Shaz Qadeer Microsoft Research,
CSI 3125, Axiomatic Semantics, page 1 Axiomatic semantics The assignment statement Statement composition The "if-then-else" statement The "while" statement.
ISBN Chapter 3 Describing Semantics -Attribute Grammars -Dynamic Semantics.
Development of Symbolic Debuggers Based on Refinement Calculus RK Shyamasundar Rohit Kundaji Tata Institute of Fundamental Research Mumbai India.
CS 363 Comparative Programming Languages Semantics.
Mr. Dave Clausen1 La Cañada High School Chapter 6: Repetition Statements.
Computer Science School of Computing Clemson University Discrete Math and Reasoning about Software Correctness Joseph E. Hollingsworth
9.4 Mathematical Induction
Reading and Writing Mathematical Proofs Spring 2015 Lecture 4: Beyond Basic Induction.
Arvind Computer Science and Artificial Intelligence Laboratory M.I.T. L06-1 September 26, 2006http:// Type Inference September.
Semantics In Text: Chapter 3.
Languages and Compilers
Hwajung Lee. The State-transition model The set of global states = s 0 x s 1 x … x s m {s k is the set of local states of process k} S0  S1  S2  Each.
Lecture 5 1 CSP tools for verification of Sec Prot Overview of the lecture The Casper interface Refinement checking and FDR Model checking Theorem proving.
Hwajung Lee. The State-transition model The set of global states = s 0 x s 1 x … x s m {s k is the set of local states of process k} S0  S1  S2  Each.
Principle of Programming Lanugages 3: Compilation of statements Statements in C Assertion Hoare logic Department of Information Science and Engineering.
Static Techniques for V&V. Hierarchy of V&V techniques Static Analysis V&V Dynamic Techniques Model Checking Simulation Symbolic Execution Testing Informal.
From Natural Language to LTL: Difficulties Capturing Natural Language Specification in Formal Languages for Automatic Analysis Elsa L Gunter NJIT.
R-customizers Goal: define relation between graph and its customizers, study domains of adaptive programs, merging of interface class graphs.
CSC3315 (Spring 2009)1 CSC 3315 Languages & Compilers Hamid Harroud School of Science and Engineering, Akhawayn University
C HAPTER 3 Describing Syntax and Semantics. D YNAMIC S EMANTICS Describing syntax is relatively simple There is no single widely acceptable notation or.
Verifying Component Substitutability Nishant Sinha Sagar Chaki Edmund Clarke Natasha Sharygina Carnegie Mellon University.
© Bertrand Meyer and Yishai Feldman Notice Some of the material is taken from Object-Oriented Software Construction, 2nd edition, by Bertrand Meyer (Prentice.
Credible Compilation With Pointers Martin Rinard and Darko Marinov Laboratory for Computer Science Massachusetts Institute of Technology.
CS 550 Programming Languages Jeremy Johnson
Formal methods: Lecture
Sparkle a functional theorem prover
Formal Methods in Software Engineering 1
Lecture 5 Floyd-Hoare Style Verification
Axiomatic semantics Points to discuss: The assignment statement
IS 2935: Developing Secure Systems
ITEC452 Distributed Computing Lecture 5 Program Correctness
ECE-C662 Introduction to Behavioral Synthesis Knapp Text Ch
Predicate Transformers
Formal Methods in software development
Program correctness Axiomatic semantics
Programming Languages and Compilers (CS 421)
COP4020 Programming Languages
Program Correctness an introduction.
Presentation transcript:

Translation Validation A.PnueliM.SiegelE.Singerman

Motivation Prove that high level specification is correctly implemented in low level code. –Verifying compiler is not feasible. –Development freezing. Solution: Translation Validation

Translation Validation After each compiler run verify that the target code produced on this run correctly implements the source code.

A common semantic framework. Notion of “correct implementation”. A proof method. Automation of the proof method. Necessary Ingredients

Example process DEC = ( ? integer FB ! integer N ) ( | N := FB default (ZN-1) | ZN := N $ init 1 | FB ^= when (ZN <= 1) |) where integer ZN init 1 ; end logical DEC_iterate() { l0:h1 C = TRUE; l1:h2 C = ZN C <= 1; l2:if (h2 C ) l2.1: read(FB C ); l3:if (h2 C ) l3.1: N C = FB C ; else l3.2: N C = ZN C - 1; l4:write(N C ); l5:ZN C = N C ; return TRUE; }

FB : 3 N : 3 ZN : 1 FB :  N : 2 ZN : 3 FB :  N : 1 ZN : 2 FB : 5 N : 5 ZN : 1 FB :  N : 4 ZN : 5 … FB : * N : * ZN : 1 h1 : * h2 : * pc : l0 FB : * N : * ZN : 1 h1 : t h2 : t pc : l2 FB : 3 N : * ZN : 1 h1 : t h2 : t pc : l3 FB : 3 N : * ZN : 1 h1 : t h2 : t pc : l3.1 FB : 3 N : 3 ZN : 1 h1 : t h2 : t pc : l5 FB : 3 N : 3 ZN : 3 h1 : t h2 : t pc : l0 … FB : 3 N : 3 ZN : 3 h1 : t h2 : f pc : l2 FB : 3 N : 3 ZN : 3 h1 : t h2 : f pc : l3 FB : 3 N : 3 ZN : 3 h1 : t h2 : f pc : l3.2 FB : 3 N : 2 ZN : 3 h1 : t h2 : f pc : l5 FB :  N :  ZN : 1 …

Common Semantic Framework Synchronous Transition System S = (V,O,Θ, ρ) –V a set of state variables –O  V a set of observable variables –Θ an initial condition characterizing the initial states of the system –ρ a transition relation, relating a state to its possible successors

process DEC = ( ? integer FB ! integer N ) ( | N := FB default (ZN-1) | ZN := N $ 1 | FB ^= when (ZN <= 1) |) where integer ZN init 1 ; end V = {FB,N,ZN,m.ZN} Θ = (FB =   N =   ZN =   m.ZN = 1) N’ = if FB’   then FB’ else ZN’ -1  m.ZN’ = if N’   then N’ else m.ZN  ZN’ = if N’   then m.ZN else   ZN’  1  FB’     =

logical DEC_iterate() { l0:h1 = TRUE; l1:h2 = ZN <= 1; l2:if (h2) l2.1: read(FB); l3:if (h2) l3.1: N = FB; else l3.2: N = ZN - 1; l4:write(N); l5:ZN = N; return TRUE; } V = {FB C,N C,ZN C,h1 C,h2 C } Θ = (ZN C = 1  pc = l 0 ) (pc=l 0  h1 ’ C =T  pc ’ =l 1  pres_but(pc.h1 c ))  (pc=l 1  h2’ C =(ZN C  1)  pc’=l 2  pres_but(pc,h2 C ))  (pc=l 2  h2 C  pc’=l 2.1  pres_but(pc))  (pc=l 2   h2 C  pc’=l 3  pres_but(pc))  (pc=l 2.1  pc’=l 3  pres_but(pc,FB C ))  (pc=l 3  h2 C  pc’=l 3.1  pres_but(pc))  (pc=l 3   h2 C  pc’=l 3.2  pres_but(pc))  (pc=l 3.1  N’ C =FB C  pc’=l 4  pres_but(pc,N C ))  (pc=l 3.2  N’ C =ZN C –1  pc’=l 4  pres_but(pc,N C ))  (pc=l 4  pc’=l 5  pres_but(pc))  (pc=l 5  ZN’ C =N C  pc’=l 0  pres_but(pc,ZN C )) C=C=

Let A = (V,O,Θ, ρ) s[v] – a value state s assigns to each variable v  V. σ: s 0,s 1 … - A computation s 0 |= Θ (s i,s i+1 ) |= ρ  i  N ||A|| - the set of computations of A. STS computation

A = (V A,O A,Θ A, ρ A ) C = (V C,O C,Θ C, ρ C ) Clocked interface mapping: I:  C   O A  x  O A, s  C. I(s)[x]=s[x] or I(s)[x]=  Definition: C refines A if there exists a clocked interface mapping I from C to A such that I(||C||)  ||A|| O. Defining Refinement OAOCOAOC

Proving Refinement Clocked refinement mapping from C to A: f:  C   A  x  O A, s  C. f(s)[x]=s[x] or f(s)[x]=  Theorem: C refines A if there exists a clocked refinement mapping f:  C   A such that  s  C. s|= Θ C  f(s) |= Θ A  s,s’  C r. (s,s’)|= ρ C  (f(s),f(s’))|= ρ A Such f called inductive.

Proof Rule  : V A   (V C )s A  ā(s C ) For  - state formula over V A : ā(s C )|=  iff s C |=  [  ] For assertion inv and substitution  : V A  E(V C ) R1. Θ C  invinv holds initially R2. inv  ρ C  inv`inv is propagated R3. Θ C  Θ A [  ]Initiation R4. inv  ρ C  ρ A [  ]Propagation R5. inv  (v[  ] = v  v[  ] =  )  v  O A C refines A

Translation Validation: from Signal to C A.PnueliO.ShtrichmanM.Siegel

Observation Functions and Correct Implementation A = (V A,Θ A,  A,O A )C = (V C,Θ C,  C,O C ) O A, O C – observation functions Given  : s 0, s 1, …, - O(s 0 ),O(s 1 ), …, is observation of STS. Obs(A) is the set of A observations. Definition: C refines A if Obs(C)  Obs(A)

Adaptation to Signal compilation

process MUX = ( ? integer FB ! integer N ) ( | N := FB default (ZN- 1) | ZN := N $ init 1 | FB ^= when (ZN <= 1) |) where integer ZN init 1 ; end Choosing Observation O A = (FB,N) O C = (O C FB,O C N ) logical MUX_iterate() { l0:h1 C = TRUE; l1:h2 C = ZN C <= 1; l2:if (h2 C ) l2.1: read(FB C ); l3:if (h2 C ) l3.1: N C = FB C ; else l3.2: N C = ZN C - 1; l4:write(N C ); l5:ZN C = N C ; return TRUE; } logical MUX_iterate() { rd.FB C =F; wr.N C =F; l0:h1 C = TRUE; l1:h2 C = ZN C <= 1; l2:if (h2 C ){ l2.1: read(FB C ); rd>FB C =T; } l3:if (h2 C ) l3.1: N C = FB C ; else l3.2: N C = ZN C - 1; l4:write(N C ); wr.N C =T; l5:ZN C = N C ; return TRUE; } O C FB : if rd.FB C then FB C else  O C N : if wr.N C then N C else 

FB : 3 N : 3 ZN : 1 FB :  N : 2 ZN : 3 FB :  N : 1 ZN : 2 FB : 5 N : 5 ZN : 1 FB :  N : 4 ZN : 5 … FB : * N : * ZN : 1 h1 : * h2 : * pc : l0 FB : * N : * ZN : 1 h1 : t h2 : t pc : l2 FB : 3 N : * ZN : 1 h1 : t h2 : t pc : l3 FB : 3 N : * ZN : 1 h1 : t h2 : t pc : l3.1 FB : 3 N : 3 ZN : 1 h1 : t h2 : t pc : l5 FB : 3 N : 3 ZN : 3 h1 : t h2 : t pc : l0 … FB : 3 N : 3 ZN : 3 h1 : t h2 : f pc : l2 FB : 3 N : 3 ZN : 3 h1 : t h2 : f pc : l3 FB : 3 N : 3 ZN : 3 h1 : t h2 : f pc : l3.2 FB : 3 N : 2 ZN : 3 h1 : t h2 : f pc : l5 FB :  N :  ZN : 1

Composite STS Compose the transition relations of the individual statements inside the loop’s body. –no nested loops V : {FB C,N C,ZN C,h1 C,h2 C,rd.FB C,wr.N C } Θ : ZN C = 1  pc = l 0  (h1 ’ C =T)  (h2’ C =(ZN C  1))  (h2’ C  (N’ C =FB C )  (  h2’ C  (FB’ C =FB C  N’ C =ZN C –1))  (ZN’ C =N’ C )  (rd.FB’ C =h2’ C )  (wr.N’ C =T) O C FB : if rd.FB C then FB C else  O C N : if wr.N C then N C else   C :

Composite STS V : {FB C,N C,ZN C,h1 C,h2 C } Θ : ZN C = 1  pc = l 0  (h1 ’ C =T)  (h2’ C =(ZN C  1))  (h2’ C  (N’ C =FB C )  (  h2’ C  (FB’ C =FB C  N’ C =ZN C –1))  (ZN’ C =N’ C ) O C FB : if h2 C then FB C else  O C N : N C  C :

For an abstraction mapping V A =  (V C ) R1. Θ C  V A =  (V C )  Θ A Initiation R2. V A =  (V C )   C  V’ A =  (V’ C )   A Propagation R3. V A =  (V C )  O A =O C Compatibility with observations C refines A Rule Ref. Establish by induction that, for every  C :s 0 C,s 1 C,… there exists  A :s 0 A,s 1 A,… such that s j A =  (s j C ) and their observations are equal.

Construction of the Mapping  For v  V A,  v (V c ) – the value of v in s A related to s C. For v  IO,  v (V c ) = O C v (V C ) For each register flow  m.r = r C  ’ m.r = r’ C For each Register or Local variable v’ = eq v   ’ v = eq v (determinate programs) W1. Θ C   r  R (m.r = r C )   v  IORL (v =  )  Θ A W2.  r  R (m.r = r C  m.r’ = r’ C )   C   v  IO ( v’ = (O C v )’ )   v  RL (v’ = eq v ) AA

Theorem: If verification conditions W1 and W2 are valid, then C refines A.

Example U1. ZN C = 1  m.ZN = ZNc   FB =   N =   ZN =  FB =   N =   ZN =   m.ZN= 1 U2.  C    A m.ZN = ZN C  FB’ = if h2’ C then FB’ else   N’ = N’ C  m.ZN’ = ZN’ C  ZN’ = if N’   then m.ZN else 

Example U2.  C    A m.ZN = ZN C  FB’ = if h2’ C then FB’ else   N’ = N’ C  m.ZN’ = ZN’ C  ZN’ = if N’   then m.ZN else  U2.  C    A m.ZN = ZN C  FB’ = if h2’ C then FB’ else   N’ = N’ C  m.ZN’ = ZN’ C  ZN’ = ZN C

The End