Verifying the Lustre modular reset
Timothy Bourke1,2 Lélio Brun1,2 Marc Pouzet 3,2,1
1Inria Paris 2DI ENS 3UPMC
Verifying the Lustre modular reset Timothy Bourke 1,2 Llio Brun 1,2 - - PowerPoint PPT Presentation
Verifying the Lustre modular reset Timothy Bourke 1,2 Llio Brun 1,2 Marc Pouzet 3,2,1 1 Inria Paris 2 DI ENS 3 UPMC SYNCHRON18 November 29, 2018 The problem Adding the modular reset to Vlus 1 / 22 The problem Adding the modular
1Inria Paris 2DI ENS 3UPMC
1 / 22
1 / 22
1 / 22
1 / 22
1 / 22
1Caspi, Halbwachs, Pilaud, and Plaice (1987): “LUSTRE: A declarative language for
2 / 22
1Caspi, Halbwachs, Pilaud, and Plaice (1987): “LUSTRE: A declarative language for
2 / 22
3 / 22
3 / 22
3 / 22
4 / 22
4 / 22
4 / 22
4 / 22
5 / 22
5 / 22
5 / 22
5 / 22
5 / 22
5 / 22
5 / 22
5 / 22
5 / 22
5 / 22
5 / 22
2Hamon and Pouzet (2000): “Modular Resetting of Synchronous Data-flow
6 / 22
7 / 22
7 / 22
7 / 22
7 / 22
7 / 22
7 / 22
7 / 22
7 / 22
7 / 22
7 / 22
7 / 22
eqn ⇀
8 / 22
exp ⇀
eqn ⇀
8 / 22
exp ⇀
node f (⇀
eqn ⇀
8 / 22
exp ⇀
node f (⇀
var ⇀
eqn ⇀
8 / 22
exp ⇀
node f (⇀
var ⇀
eqn ⇀
eqn ⇀
8 / 22
exp ⇀
node f (⇀
var ⇀
eqn ⇀
exp ⇀
var ⇀
eqn ⇀
8 / 22
exp ⇀
node f (⇀
var ⇀
eqn ⇀
var r ⇓ rs
exp ⇀
var ⇀
eqn ⇀
8 / 22
exp ⇀
node f (⇀
var ⇀
eqn ⇀
var r ⇓ rs
exp ⇀
var ⇀
eqn ⇀
8 / 22
exp ⇀
node f (⇀
var ⇀
eqn ⇀
var r ⇓ rs
exp ⇀
reset f (⇀
var ⇀
eqn ⇀
8 / 22
exp ⇀
node f (⇀
var ⇀
eqn ⇀
var r ⇓ rs
exp ⇀
reset f (⇀
var ⇀
eqn ⇀
reset f (⇀
8 / 22
exp ⇀
node f (⇀
var ⇀
eqn ⇀
var r ⇓ rs
exp ⇀
reset f (⇀
var ⇀
eqn ⇀
node f (mask k rk ⇀
reset f (⇀
8 / 22
Unannotated Lustre parsing Lustre elaboration N-Lustre normalization SN-Lustre scheduling Obc translation Clight generation Assembly compilation printing fusion optimization
CompCert
3Bourke, Brun, Dagand, Leroy, Pouzet, and Rieg (2017): “A Formally Verified
9 / 22
Unannotated Lustre parsing Lustre elaboration N-Lustre normalization SN-Lustre scheduling Obc translation Clight generation Assembly compilation printing fusion optimization
CompCert
aJourdan, Pottier, and Leroy (2012): “Validating LR(1) parsers” 9 / 22
Unannotated Lustre parsing Lustre elaboration N-Lustre normalization SN-Lustre scheduling Obc translation Clight generation Assembly compilation printing fusion optimization
CompCert
9 / 22
Unannotated Lustre parsing Lustre elaboration N-Lustre normalization SN-Lustre scheduling Obc translation Clight generation Assembly compilation printing fusion optimization
CompCert
aAuger (2013): “Compilation certifiée de SCADE/LUSTRE” 9 / 22
Unannotated Lustre parsing Lustre elaboration N-Lustre normalization SN-Lustre scheduling Obc translation Clight generation Assembly compilation printing fusion optimization
CompCert
9 / 22
Unannotated Lustre parsing Lustre elaboration N-Lustre normalization SN-Lustre scheduling Obc translation Clight generation Assembly compilation printing fusion optimization
CompCert
9 / 22
Unannotated Lustre parsing Lustre elaboration N-Lustre normalization SN-Lustre scheduling Obc translation Clight generation Assembly compilation printing fusion optimization
CompCert
node e u l e r ( y0 , y ’ : r e a l ) r e t u r n s ( y : r e a l ) var h , y1 : r e a l ; i n i t : bool ; l e t h = 2; y = i f i n i t then y0 e l s e y1 ; i n i t = t r u e fby f a l s e ; y1 = 0 fby ( y + y ’ ∗ h ) ; t e l c l a s s e u l e r { memory i n i t : bool ; memory y1 : r e a l ; step ( y0 , y ’ : r e a l ) r e t u r n s ( y : r e a l ) var h : r e a l { h := 2; i f ( s t a t e ( i n i t ) ) { y := y0 } e l s e { y := s t a t e ( y1 ) }; s t a t e ( i n i t ) := f a l s e ; s t a t e ( y1 ) := y + y ’ ∗ h } r e s e t ( ) { s t a t e ( i n i t ) := t r u e ; s t a t e ( y1 ) := 0 } }
9 / 22
Unannotated Lustre parsing Lustre elaboration N-Lustre normalization SN-Lustre scheduling Obc translation Clight generation Assembly compilation printing fusion optimization
CompCert
node e u l e r ( y0 , y ’ : r e a l ) r e t u r n s ( y : r e a l ) var h , y1 : r e a l ; i n i t : bool ; l e t h = 2; y = i f i n i t then y0 e l s e y1 ; i n i t = t r u e fby f a l s e ; y1 = 0 fby ( y + y ’ ∗ h ) ; t e l c l a s s e u l e r { memory i n i t : bool ; memory y1 : r e a l ; step ( y0 , y ’ : r e a l ) r e t u r n s ( y : r e a l ) var h : r e a l { h := 2; i f ( s t a t e ( i n i t ) ) { y := y0 } e l s e { y := s t a t e ( y1 ) }; s t a t e ( i n i t ) := f a l s e ; s t a t e ( y1 ) := y + y ’ ∗ h } r e s e t ( ) { s t a t e ( i n i t ) := t r u e ; s t a t e ( y1 ) := 0 } }
9 / 22
Unannotated Lustre parsing Lustre elaboration N-Lustre normalization SN-Lustre scheduling Obc translation Clight generation Assembly compilation printing fusion optimization
CompCert
node e u l e r ( y0 , y ’ : r e a l ) r e t u r n s ( y : r e a l ) var h , y1 : r e a l ; i n i t : bool ; l e t h = 2; y = i f i n i t then y0 e l s e y1 ; i n i t = t r u e fby f a l s e ; y1 = 0 fby ( y + y ’ ∗ h ) ; t e l c l a s s e u l e r { memory i n i t : bool ; memory y1 : r e a l ; step ( y0 , y ’ : r e a l ) r e t u r n s ( y : r e a l ) var h : r e a l { h := 2; i f ( s t a t e ( i n i t ) ) { y := y0 } e l s e { y := s t a t e ( y1 ) }; s t a t e ( i n i t ) := f a l s e ; s t a t e ( y1 ) := y + y ’ ∗ h } r e s e t ( ) { s t a t e ( i n i t ) := t r u e ; s t a t e ( y1 ) := 0 } }
9 / 22
Unannotated Lustre parsing Lustre elaboration N-Lustre normalization SN-Lustre scheduling Obc translation Clight generation Assembly compilation printing fusion optimization
CompCert
node main ( x0 , x ’ : r e a l ) r e t u r n s ( x : r e a l ) l e t x = e u l e r ( x0 , x ’ ) ; t e l c l a s s main { i n s t a n c e i : e u l e r ; step ( x0 , x ’ : r e a l ) r e t u r n s ( x : r e a l ) { x := e u l e r ( i ) . step ( x0 , x ’ ) } r e s e t ( ) { e u l e r ( i ) . r e s e t () } }
9 / 22
Unannotated Lustre parsing Lustre elaboration N-Lustre normalization SN-Lustre scheduling Obc translation Clight generation Assembly compilation printing fusion optimization
CompCert
node main ( x0 , x ’ : r e a l ) r e t u r n s ( x : r e a l ) l e t x = e u l e r ( x0 , x ’ ) ; t e l c l a s s main { i n s t a n c e i : e u l e r ; step ( x0 , x ’ : r e a l ) r e t u r n s ( x : r e a l ) { x := e u l e r ( i ) . step ( x0 , x ’ ) } r e s e t ( ) { e u l e r ( i ) . r e s e t () } }
9 / 22
Unannotated Lustre parsing Lustre elaboration N-Lustre normalization SN-Lustre scheduling Obc translation Clight generation Assembly compilation printing fusion optimization
CompCert
9 / 22
Unannotated Lustre parsing Lustre elaboration N-Lustre normalization SN-Lustre scheduling Obc translation Clight generation Assembly compilation printing fusion optimization
CompCert node main ( x0 , x ’ : r e a l ; ck : bool ) r e t u r n s ( x : r e a l ) var v , w: r e a l when ck ; l e t v = f i l t e r ( x ’ when ck ) ; w = e u l e r ( x0 when ck , v ) ; x = merge ck w ( −1); t e l step ( x0 , x ’ : r e a l ; ck : bool ) r e t u r n s ( x : r e a l ) var v , w: r e a l { i f ( ck ) { v := f i l t e r ( i ) . step ( x ’ ) }; i f ( ck ) { w := e u l e r ( j ) . step ( x0 , v ) } ; i f ( ck ) { x := w } e l s e { x := −1 } } 9 / 22
Unannotated Lustre parsing Lustre elaboration N-Lustre normalization SN-Lustre scheduling Obc translation Clight generation Assembly compilation printing fusion optimization
CompCert step ( x0 , x ’ : r e a l ; ck : bool ) r e t u r n s ( x : r e a l ) var v , w: r e a l { i f ( ck ) { v := f i l t e r ( i ) . step ( x ’ ) }; i f ( ck ) { w := e u l e r ( j ) . step ( x0 , v ) }; i f ( ck ) { x := w } e l s e { x := −1 } } step ( x0 , x ’ : r e a l ; ck : bool ) r e t u r n s ( x : r e a l ) var v , w: r e a l { i f ( ck ) { v := f i l t e r ( i ) . step ( x ’ ) ; w := e u l e r ( j ) . step ( x0 , v ) ; x := w } e l s e { x := −1 } } 9 / 22
Unannotated Lustre parsing Lustre elaboration N-Lustre normalization SN-Lustre scheduling Obc translation Clight generation Assembly compilation printing fusion optimization
CompCert
9 / 22
Unannotated Lustre parsing Lustre elaboration N-Lustre normalization SN-Lustre scheduling Obc translation Clight generation Assembly compilation printing fusion optimization
CompCert
aBlazy, Dargaye, and Leroy (2006): “Formal verification of a C compiler
9 / 22
10 / 22
node main ( x0 , x ’ : r e a l ; ck , r : bool ) r e t u r n s ( x : r e a l ) var v , w: r e a l when ck ; l e t v = f i l t e r ( x ’ when ck ) ; w = e u l e r (( x0 , v ) when ck ) ev er y r ; x = merge ck w 0; t e l
10 / 22
node main ( x0 , x ’ : r e a l ; ck , r : bool ) r e t u r n s ( x : r e a l ) var v , w: r e a l when ck ; l e t v = f i l t e r ( x ’ when ck ) ; w = e u l e r (( x0 , v ) when ck ) ev er y r ; x = merge ck w 0; t e l step ( x0 , x ’ : r e a l ; ck , r : bool ) r e t u r n s ( x : r e a l ) var v , w : r e a l { i f ( ck ) { v := f i l t e r ( i ) . step ( x ’ ) }; i f ( r ) { e u l e r ( j ) . r e s e t () }; i f ( ck ) { w := e u l e r ( j ) . step ( x0 , v ) }; i f ( ck ) { x := w } e l s e { x := 0 } }
10 / 22
node main ( x0 , x ’ : r e a l ; ck , r : bool ) r e t u r n s ( x : r e a l ) var v , w: r e a l when ck ; l e t v = f i l t e r ( x ’ when ck ) ; w = e u l e r (( x0 , v ) when ck ) ev er y r ; x = merge ck w 0; t e l step ( x0 , x ’ : r e a l ; ck , r : bool ) r e t u r n s ( x : r e a l ) var v , w : r e a l { i f ( r ) { e u l e r ( j ) . r e s e t () }; i f ( ck ) { v := f i l t e r ( i ) . step ( x ’ ) ; w := e u l e r ( j ) . step ( x0 , v ) ; x := w } e l s e { x := 0 } }
10 / 22
M i M’ x v0 · · · vω
11 / 22
M i M’ x v0 · · · vω
11 / 22
M i M’ x v0 · · · vω
11 / 22
M i M’ x v0 · · · vω
11 / 22
11 / 22
11 / 22
11 / 22
11 / 22
11 / 22
11 / 22
12 / 22
12 / 22
12 / 22
12 / 22
N-Lustre SyBloc translation Obc translation fusion optimization scheduling 12 / 22
13 / 22
13 / 22
13 / 22
13 / 22
14 / 22
eqn x = c0 fby e
15 / 22
const c0 ⇓ v0
eqn x = c0 fby e
15 / 22
const c0 ⇓ v0
exp e ⇓ vs
eqn x = c0 fby e
15 / 22
const c0 ⇓ v0
exp e ⇓ vs
var x ⇓ xs
eqn x = c0 fby e
15 / 22
const c0 ⇓ v0
exp e ⇓ vs
var x ⇓ xs
eqn x = c0 fby e
15 / 22
const c0 ⇓ v0
exp e ⇓ vs
var x ⇓ xs
eqn x = c0 fby e
15 / 22
const c0 ⇓ v0
exp e ⇓ vs
var x ⇓ xs
eqn x = c0 fby e
15 / 22
const c0 ⇓ v0
exp e ⇓ vs
var x ⇓ xs
eqn x = c0 fby e
15 / 22
const c0 ⇓ v0
exp e ⇓ vs
var x ⇓ xs
eqn x = c0 fby e
15 / 22
const c0 ⇓ v0
exp e ⇓ vs
var x ⇓ xs
eqn x = c0 fby e
15 / 22
const c0 ⇓ v0
exp e ⇓ vs
var x ⇓ xs
eqn x = c0 fby e
15 / 22
const c0 ⇓ v0
exp e ⇓ vs
var x ⇓ xs
eqn x = c0 fby e
15 / 22
const c0 ⇓ v0
exp e ⇓ vs
var x ⇓ xs
eqn x = c0 fby e
15 / 22
eqn() = i.reset_on r
16 / 22
eqn() = i.reset_on r
16 / 22
var r ⇓ rs
eqn() = i.reset_on r
16 / 22
var r ⇓ rs
eqn() = i.reset_on r
16 / 22
var r ⇓ rs
eqn() = i.reset_on r
16 / 22
var r ⇓ rs
eqn() = i.reset_on r
16 / 22
var r ⇓ rs
eqn() = i.reset_on r
16 / 22
17 / 22
18 / 22
r
r
r
r
18 / 22
r
r
r
r
18 / 22
18 / 22
19 / 22
19 / 22
19 / 22
19 / 22
r
r
r
r
20 / 22
r
r
r
r
20 / 22
a · · · vk b · · ·
a · · · r k b · · ·
b+1 · · · vk+1 c
b+1 · · · r k+1 c
20 / 22
a · · · vk b · · ·
a · · · r k b · · ·
b+1 · · · vk+1 c
b+1 · · · r k+1 c
20 / 22
a · · · vk b · · ·
a · · · r k b · · ·
b+1 · · · vk+1 c
b+1 · · · r k+1 c
n ||r n
20 / 22
a · · · vk b · · ·
a · · · r k b · · ·
b+1 · · · vk+1 c
b+1 · · · r k+1 c
n
20 / 22
21 / 22
21 / 22
21 / 22
22 / 22
22 / 22
1 / 6
I n d u c t i v e sem_cexp : h i s t o r y → c l o c k → cexp → vstream → Prop := | Smerge : ∀ H b x t f xs t s f s
sem_var H x xs → sem_cexp H b t t s → sem_cexp H b f f s → merge xs t s f s
sem_cexp H b ( Emerge x t f )
| S i t e : ∀ H b e t f es t s f s
sem_lexp H b e es → sem_cexp H b t t s → sem_cexp H b f f s → i t e es t s f s
sem_cexp H b ( E i t e e t f )
| Sexp : ∀ H b e es , sem_lexp H b e es → sem_cexp H b ( Eexp e ) es .
2 / 6
le := expression | k (constant) | x (variable) | le when x (when) | ⋄ e (unary operator) | e ⊕ e (binary operator) ce := control expression | merge x ce ce (merge) | if x then ce else ce (if) | le (expression) eq := equation | x :: c = ce (def) | x :: c = k fby le (fby) |
⇀
x :: c = x(⇀ le ) (app) |
⇀
x :: c = x(⇀ le ) every x (reset) n := node | node x(⇀ xty::c ) returns (⇀ xty::c ) [var ⇀ xty::c ] let
⇀
eq; tel
3 / 6
⇀
4 / 6
5 / 6
5 / 6
5 / 6
6 / 6
6 / 6
6 / 6
6 / 6
6 / 6
6 / 6
6 / 6