Ichiro Hasuo University of Tokyo Kohei Suenaga JSPS Research Fellow (PD) Kyoto University Programming with Infinitesimals A WHILE-Language for Hybrid System.

Slides:



Advertisements
Similar presentations
Automated Theorem Proving Lecture 1. Program verification is undecidable! Given program P and specification S, does P satisfy S?
Advertisements

In this episode of The Verification Corner, Rustan Leino talks about Loop Invariants. He gives a brief summary of the theoretical foundations and shows.
Semantics Static semantics Dynamic semantics attribute grammars
ICE1341 Programming Languages Spring 2005 Lecture #6 Lecture #6 In-Young Ko iko.AT. icu.ac.kr iko.AT. icu.ac.kr Information and Communications University.
Verification of Evolving Software Natasha Sharygina Joint work with Sagar Chaki and Nishant Sinha Carnegie Mellon University.
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.
Timed Automata.
A survey of techniques for precise program slicing Komondoor V. Raghavan Indian Institute of Science, Bangalore.
David Evans CS655: Programming Languages University of Virginia Computer Science Lecture 19: Minding Ps & Qs: Axiomatic.
Partial correctness © Marcelo d’Amorim 2010.
ISBN Chapter 3 Describing Syntax and Semantics.
Predicate Transformers
Program Proving Notes Ellen L. Walker.
1 Semantic Description of Programming languages. 2 Static versus Dynamic Semantics n Static Semantics represents legal forms of programs that cannot be.
1/22 Programs : Semantics and Verification Charngki PSWLAB Programs: Semantics and Verification Mordechai Ben-Ari Mathematical Logic for Computer.
CS 355 – Programming Languages
Comp 205: Comparative Programming Languages Semantics of Imperative Programming Languages denotational semantics operational semantics logical semantics.
What is an Algorithm? (And how do we analyze one?)
A Semantic Characterization of Unbounded-Nondeterministic Abstract State Machines Andreas Glausch and Wolfgang Reisig 1.
1 Basic abstract interpretation theory. 2 The general idea §a semantics l any definition style, from a denotational definition to a detailed interpreter.
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.
Hoare-style program verification K. Rustan M. Leino Guest lecturer Rob DeLine’s CSE 503, Software Engineering University of Washington 26 Apr 2004.
Programming Language Semantics Mooly SagivEran Yahav Schrirber 317Open space html://
Copyright © 2006 The McGraw-Hill Companies, Inc. Programming Languages 2nd edition Tucker and Noonan Chapter 18 Program Correctness To treat programming.
PSUCS322 HM 1 Languages and Compiler Design II Formal Semantics Material provided by Prof. Jingke Li Stolen with pride and modified by Herb Mayer PSU Spring.
Semantics with Applications Mooly Sagiv Schrirber html:// Textbooks:Winskel The.
Software Verification Bertrand Meyer Chair of Software Engineering Lecture 2: Axiomatic semantics.
Operational Semantics Semantics with Applications Chapter 2 H. Nielson and F. Nielson
Describing Syntax and Semantics
Chapter 3 (Part 3): Mathematical Reasoning, Induction & Recursion  Recursive Algorithms (3.5)  Program Correctness (3.6)
1 Inference Rules and Proofs (Z); Program Specification and Verification Inference Rules and Proofs (Z); Program Specification and Verification.
ISBN Chapter 3 Describing Semantics -Attribute Grammars -Dynamic Semantics.
Program Analysis and Verification Spring 2014 Program Analysis and Verification Lecture 4: Axiomatic Semantics I Roman Manevich Ben-Gurion University.
Semantics In Text: Chapter 3.
Languages and Compilers
COP4020 Programming Languages Introduction to Axiomatic Semantics Prof. Robert van Engelen.
From Hoare Logic to Matching Logic Reachability Grigore Rosu and Andrei Stefanescu University of Illinois, USA.
13 Aug 2013 Program Verification. Proofs about Programs Why make you study logic? Why make you do proofs? Because we want to prove properties of programs.
Program Analysis and Verification Spring 2015 Program Analysis and Verification Lecture 4: Axiomatic Semantics I Roman Manevich Ben-Gurion University.
Principle of Programming Lanugages 3: Compilation of statements Statements in C Assertion Hoare logic Department of Information Science and Engineering.
This Week Lecture on relational semantics Exercises on logic and relations Labs on using Isabelle to do proofs.
Cs7100(Prasad)L18-9WP1 Axiomatic Semantics Predicate Transformers.
Program Analysis and Verification
Operational Semantics Mooly Sagiv Tel Aviv University Sunday Scrieber 8 Monday Schrieber.
Spring 2017 Program Analysis and Verification
Chapter 3 of Programming Languages by Ravi Sethi
(One-Path) Reachability Logic
Formal Methods in Software Engineering 1
Stateful Manifest Contracts
Mathematical Structures for Computer Science Chapter 1
Lecture 5 Floyd-Hoare Style Verification
Lecture 2: Axiomatic semantics
Programming Languages and Compilers (CS 421)
Programming Languages 2nd edition Tucker and Noonan
Over-Approximating Boolean Programs with Unbounded Thread Creation
Logic for Computer Security Protocols
Formal Methods in software development
Predicate Transformers
Formal Methods in software development
The Zoo of Software Security Techniques
Program correctness Axiomatic semantics
Program Verification with Hoare Logic
Lecture 2: Axiomatic semantics
Programming Languages 2nd edition Tucker and Noonan
COP4020 Programming Languages
Program Correctness an introduction.
Presentation transcript:

Ichiro Hasuo University of Tokyo Kohei Suenaga JSPS Research Fellow (PD) Kyoto University Programming with Infinitesimals A WHILE-Language for Hybrid System Modeling Infinitely small values

Hybrid systems  Flow + Jump  Jump is familiar  Flow is not Accel. rate Veloc. flow jump flow t t x

Hybrid System Verification  Existing work  Hybrid automata [Alur et al.]  Differential dynamic logic [Platzer et al.]  Flow by differential equations

This work  Turns flow into jump

This work  Turns flow into jump  With infinitesimals Infinitely small values

This work  Turns flow into jump  With infinitesimals Accel. rate Veloc. flow jump flow jump t t x Infinitely small values Infinitely-many infinitesimal jumps

Concretely  Modeling language WHILE dt  WHILE + dt  Hoare-style program logic (HOARE dt ) for WHILE dt  Sound and (relatively) complete t := 0; while (t < 1) t := t + dt infinitesimal constant (“infinitely small”)

Modeling in WHILE dt t := 0; x := 0; v := 0; a := 1; while (t < 4) { v’ := v + a * dt; x’ := x + v * dt; v := v’; x := x’; t := t + dt; a := (t < 2) ? 1 : -1; }

Verification in Hoare dt A {} B { } c

true {} x < 4.01 {} t := 0; x := 0; v := 0; a := 1; while (t < 4) { v’ := v + a * dt; x’ := x + v * dt; v := v’; x := x’; t := t + dt; a := (t < 2) ? 1 : -1; }

Challenges  Mathematically rigorous basis t := 0; while (t < 1) t := t + dt dt: denotation? infinite iteration? Non-standard analysis [Robinson’60] Section-wise approximation of while-loops

Outline  WHILE dt  Syntax and example  Brief introduction of non-standard analysis  Semantics  HOARE dt  Related work  Conclusion

WHILE dt  WHILE + reals + dt c (commands) ::= skip | x := a | c1;c2 | if (b) then c1 else c2 | while (b) do c (inaction) (assignment) (sequential) (conditional) (loop) b ::= true | false | b1 and b2 | b1 or b2 | not b a ::= x | r | dt | a1+a2 | … real infinitesimal

Example 1 : Differential equation t := 0; x := 1; while (t < 1) { t := t + dt; x := x + x * dt }  Computes x(1) of dx dt = x, x(0) = 1 x(t+dt) – x(t) dt = x(t) x(t + dt) = x(t) + x(t) * dt x = exp(1) at the end

Example: Bus t := 0; x := 0; v := 0; a := 1; while (t < 4) { v := v + a * dt; x := x + v * dt; if (t < 2) then a := 1 else a:= -1; t := t + dt; } dv/dt = a dx/dt = v Gas pedal if t < 2. Brake otherwise. Infinitesimal clock tick

Challenges  Mathematically rigorous basis t := 0; while (t < 1) t := t + dt dt: denotation? “infinite”-time iterations? Non-standard analysis [Robinson’60] Section-wise approximation of while-loops

Outline  WHILE dt  Syntax and sample programs  Brief introduction of non-standard analysis  Semantics  HOARE dt  Answer to FAQs  Conclusion

() () + =  Hyperreal ≒ sequence of reals  Operations: Pointwise  Predicates: Pointwise “almost everywhere” Non-standard analysis in nutshell Reals + dt ()

Hyperreal ≒ sequence of reals (1, 1, 1, 1,…) ( (1, 2, 3, 4,…)  A component of a sequence is called a section (1, 2, 3, 4,…) 0th section 2nd section NB. Precisely, Hyperreal = (sequence of reals) / ultrafilter )

Real as hyperreal  Reals are naturally embedded to hyperreals 1 Real (1, 1, 1, 1,…) Hyperreal 2 (2, 2, 2, 2,…)  ( , , , ,…)

Operations: Sectionwise ( ) ( ) + =

Predicates: Sectionwise “almost everywhere”  Predicate holds if it holds except for finitely-many sections (0, 0, 0, 0, …) (1, 2, 3, 4, …) <<<< < ? ✓ …

? ✓ Predicates: Sectionwise “almost everywhere”  Predicate holds if it holds except for finitely-many sections (1, 1, 1, 1, …) (1, 2, 3, 4, …) <<< < < …

< Predicates: Sectionwise “almost everywhere” (NB “almost every section” is defined with an ultrafilter in the paper)  Predicate holds if it holds except for finitely-many sections (1, 2, 3, 4, …) (0, 1, 2, 3, …) <<<< ? …

dt = ( ) is an infinitesimal () …… () <<<<<<< < ? ✓  Infinitesimal = Smaller than any positive real

Outline  WHILE dt  Syntax and sample programs  Brief introduction of non-standard analysis  Semantics  HOARE dt  Answer to FAQs  Conclusion

Idea of the semantics  Section-wise execution  Execute a program on each section and merge the result t := 0; while (t < 1) t := t + dt;

Idea of the semantics  Section-wise execution  Execute a program on each section and merge the result t := 0; while (t < 1) t := t + dt;

Idea of the semantics  Section-wise execution  Execute a program on each section and merge the result t := (0, 0, 0, …); while (t < (1, 1, 1, …)) t := t + (1, 1/2, 1/3, …);

Idea of the semantics  Section-wise execution  Execute a program on each section and merge the result t := 0; while (t < 1) t := t + 1; t := 0; while (t < 1) t := t + 1/2; t := 0; while (t < 1) t := t + 1/3; … 0th section1st section2nd section

Idea of the semantics  Section-wise execution  Execute a program on each section and merge the result t := 0; while (t < 1) t := t + 1; t := 0; while (t < 1) t := t + 1/2; t := 0; while (t < 1) t := t + 1/3; … 0th section1st section2nd section t = 1

Idea of the semantics  Section-wise execution  Execute a program on each section and merge the result t := (0, 0, 0, …); while (t < (1, 1, 1, …)) t := t + (1, 1/2, 1/3, …); t = (1, 1, 1, …)

Idea of the semantics  Section-wise execution  Execute a program on each section and merge the result t := 0; while (t < 1) t := t + dt; t = 1

Idea of the semantics  Section-wise execution  Execute a program on each section and merge the result t := 0; while (t <= 1) t := t + dt;

Idea of the semantics  Section-wise execution  Execute a program on each section and merge the result t := 0; while (t <= 1) t := t + dt;

Idea of the semantics  Section-wise execution  Execute a program on each section and merge the result t := (0, 0, 0, …); while (t <= (1, 1, 1, …)) t := t + (1, 1/2, 1/3, …);

Idea of the semantics  Section-wise execution  Execute a program on each section and merge the result t := 0; while (t <= 1) t := t + 1; t := 0; while (t <= 1) t := t + 1/2; t := 0; while (t <= 1) t := t + 1/3; … 0th section1st section2nd section

Idea of the semantics  Section-wise execution  Execute a program on each section and merge the result t := 0; while (t <= 1) t := t + 1; t := 0; while (t <= 1) t := t + 1/2; t := 0; while (t <= 1) t := t + 1/3; … 0th section1st section2nd section t = t = 1 + 1/2t = 1 + 1/3

Idea of the semantics  Section-wise execution  Execute a program on each section and merge the result t := (0, 0, 0, …); while (t <= (1, 1, 1, …)) t := t + (1, 1/2, 1/3, …); t = (1, 1, 1, …) + (1, 1/2, 1/3, …)

Idea of the semantics  Section-wise execution  Execute a program on each section and merge the result t := 0; while (t <= 1) t := t + dt; t = 1 + dt

Sectionwise Execution Lemma  Def. (Section) The i-th section e| i of a WHILE dt expression e is obtained by replacing dt with  Lem. (Sectionwise Execution) For each program c and a memory state , Usual program, usual semantics stores reals stores hyperreals

Q: Is WHILE dt program executable?  A: No  WHILE dt is for modeling and verification of hybrid systems

Outline  WHILE dt  HOARE dt  Related work  Conclusion

Assertion language A (assertion) ::= true | false | A 1 and A 2 | not A | a 1 < a 2 | ∀ x ∈ *N. A | ∀ x ∈ *R. A  Almost the same as the standard Hoare logic Set of hypernaturals Set of hyperreals  Cf. Transfer Principle in Non-Standard Analysis

Hoare triples and inference rules {A}skip{A}  Exactly the same as the standard Hoare logic {[a/x]A}x := a{A} {A 1 }c 1 ;c 2 {A 3 } {A 1 }c 1 {A 2 }{A 2 }c 1 {A 3 } {A 1 }if b then c 1 else c 2 {A 2 } {A 1 and b}c 1 {A 2 } {A 2 and not b}c 2 {A 2 } {A}while b do c{A and not b} {A and b}c{A}

Verification example t := 0; x := 0; v := 0; a := 1; while (t < 4) { v’ := v + a * dt; x’ := x + v * dt; v := v’; x := x’; if (t < 2) then a := 1 else a:= -1; t := t + dt; } Loop invariant: ∃ n ∈ *N. t = n * dt & t = 2 + dt  v = (2n – n) * dt & a = -1 & x = x 0 + (3n – n)(n – n 0 - 2)*dt 2 / 2

Verification example t := 0; x := 0; v := 0; a := 1; while (t < 4) { v’ := v + a * dt; x’ := x + v * dt; v := v’; x := x’; if (t < 2) then a := 1 else a:= -1; t := t + dt; } Loop invariant: ∃ n ∈ *N. t = n * dt & t = 2 + dt  v = (2n – n) * dt & a = -1 & x = x 0 + (3n – n)(n – n 0 - 2)*dt 2 / 2

Verification example t := 0; x := 0; v := 0; a := 1; while (t < 4) { v’ := v + a * dt; x’ := x + v * dt; v := v’; x := x’; if (t < 2) then a := 1 else a:= -1; t := t + dt; } Loop invariant: ∃ n ∈ *N. t = n * dt & t = 2 + dt  v = (2n – n) * dt & a = -1 & x = x 0 + (3n – n)(n – n 0 - 2)*dt 2 / 2

Verification example true {} x < 4.01 {} t := 0; x := 0; v := 0; a := 1; while (t < 4) { v’ := v + a * dt; x’ := x + v * dt; v := v’; x := x’; t := t + dt; a := (t < 2) ? 1 : -1; } …… Using the loop invariant

Properties Thm. HOARE dt is sound Thm. HOARE dt is relatively complete

Related work Features Hybrid automata [Alur et al.] Differential dynamic logic [Platzer et al.] WHILE dt + HOARE dt  Diff. eqns. for flow  dt for flow  Diff. eqns. for flow  Auto. verif.  Sound  Rel. Compl.  Concurrency

Related work  Hybrid automata [Alur et al.]  Extension of automata with diff. eqn.  Supports concurrency  Automated verification  Differential dynamic logic [Platzer et al.]  Extension of dynamic logic with diff. eqn.  Sound & relatively complete  Automated verification

Conclusion t := 0; x := 0; v := 0; a := 1; while (t < 4) { v’ := v + a * dt; x’ := x + v * dt; v := v’; x := x’; t := t + dt; a := (t < 2) ? 1 : -1; } ModelingVerification WHILE dt HOARE dt Semantics by > Non-Standard Analysis > Sectionwise exec. > Sound > Relatively complete

Future direction  Verifier based on this approach  Current prototype: WHILE dt w/ invariants  Verif. cond.  Coq  Automated verification?  MetiTarski  Invariant generators  Application of other software verification methods  Extension of the language  Feasibility study with more examples

Does the choice of dt matter?  A: Yes t := 0; while (t = 1) t := t + dt; Terminates with dt = (1, 1/2, 1/3, …) Doesn’t with dt = (1/ , 1/2 , 1/3 , …)

 forall x in R. A is prohibited  Excludes, e.g., x is infinitely close to 1 forall r in R. r > 0  |x – 1| < r

Zeno behavior  Problematic?  No  There is no special notion of “time”  Variable “t” in the examples is just a variable  Progression of t is not required by the framework  Proving “progress” of a variable is an interesting future direction

Verification example true {} x < 4 + 6dt – dt 2 {} t := 0; x := 0; v := 0; a := 1; while (t < 4) { v’ := v + a * dt; x’ := x + v * dt; v := v’; x := x’; t := t + dt; a := (t < 2) ? 1 : -1; } …… Using the loop invariant