ejcp 2016 model checking modulo theories with cubicle
play

EJCP 2016 Model Checking Modulo Theories with Cubicle Sylvain - PowerPoint PPT Presentation

EJCP 2016 Model Checking Modulo Theories with Cubicle Sylvain Conchon LRI (UMR 8623), Universit e Paris-Sud Equipe Toccata, INRIA Saclay Ile-de-France 1 Cubicle An SMT based model checker for parameterized systems 2 Contents


  1. Theoretical foundation : MCMT Cubicle implements the Model Checking Modulo Theories (MCMT) framework [Ghilardi, Ranise] where system states and transitions are defined as first-order formulas ◮ Initial states are defined by a universally quantified formula init (i) { A[i] = True && PC = L1 } ∀ i : proc . A [ i ] ∧ PC = L1 ◮ Bad states are defined by special existentially quantified formulas, called cubes unsafe (i j) { S[i] = Crit && S[j] = Crit } ∃ i, j : proc . i � = j ∧ S[i] = Crit ∧ S[j] = Crit ◮ Transitions correspond to existentially quantified formulas transition t(i) requires { S[i] = A && PC = L1 } { S[i] = B; X = X+1 } 19

  2. Theoretical foundation : MCMT Cubicle implements the Model Checking Modulo Theories (MCMT) framework [Ghilardi, Ranise] where system states and transitions are defined as first-order formulas ◮ Initial states are defined by a universally quantified formula init (i) { A[i] = True && PC = L1 } ∀ i : proc . A [ i ] ∧ PC = L1 ◮ Bad states are defined by special existentially quantified formulas, called cubes unsafe (i j) { S[i] = Crit && S[j] = Crit } ∃ i, j : proc . i � = j ∧ S[i] = Crit ∧ S[j] = Crit ◮ Transitions correspond to existentially quantified formulas transition t(i) requires { S[i] = A && PC = L1 } { S[i] = B; X = X+1 } ∃ i : proc . S[i] = A ∧ PC = L1 ∧ S’ = S[i <- B] ∧ X’ = X + 1 19

  3. Inductive invariants We are looking for a predicate Reach such that : Reach is an inductive invariant : ∀ � x. Init ( � x ) ⇒ Reach ( � x ) x ′ . Reach ( � x ′ ) ⇒ Reach ( � x ′ ) ∀ � x ) ∧ τ ( � x, � x, � The system is safe if there exists an interpretation of Reach such that : ∀ � x. Reach ( � x ) | = ¬ unsafe ( � x ) 20

  4. Example 7 : Back to Dekker-like algorithm type st = Idle | Want | Crit transition enter (i) var T : proc requires { S[i] = Want && array S[proc] : st T = i } { S[i] := Crit } init (z) { S[z] = Idle } unsafe (x y) { S[x] = Crit && S[y] = Crit } transition exit (i) requires { S[i] = Crit } transition req (i) { T := ? ; requires { S[i] = Idle } S[i] := Idle } { S[i] := Want } 21

  5. A pure SMT problem type st = Idle | Want | Crit type proc logic Reach : proc, (proc,st) farray -> prop axiom init : forall t:proc. forall s:(proc,st) farray. (forall z:proc. s[z]=Idle) -> Reach(t,s) axiom req : forall t,t’:proc. forall s,s’:(proc,st) farray. Reach(t,s) and ( exists i:proc. s[i]=Idle and s’=s[i<-Want] and t’=t) -> Reach(t’,s’) axiom enter : forall t,t’:proc. forall s,s’:(proc,st) farray. Reach(t,s) and (exists i:proc. s[i]=Want and t=i and s’= s[i<-Crit] and t’=t) -> Reach(t’,s’) axiom exit : forall t,t’:proc. forall s,s’:(proc,st) farray. Reach(t,s) and ( exists i:proc. s[i]=Crit and s’=s[i<-Idle]) -> Reach(t’,s’) goal unsafe : exists t:proc. exists s:(proc,st) farray. exists i,j:proc. i<>j and Reach(t,s) and s[i]=Crit and s[j]=Crit 22

  6. Inductive Invariants (1) var X : int axiom a1 : Reach(0) init () { X = 0 } axiom a2 : forall x:int. Reach(x)->Reach(x+2) unsafe () { X = 9 } goal unsafe : transition t () exists x. Reach(x) and x = 9 { X := X + 2 } 23

  7. Inductive Invariants (1) var X : int axiom a1 : Reach(0) init () { X = 0 } axiom a2 : forall x:int. Reach(x)->Reach(x+2) unsafe () { X = 9 } goal unsafe : transition t () exists x. Reach(x) and x = 9 { X := X + 2 } A possible interpretation for Reach could be { 0 , 2 , 4 , 6 , . . . } 23

  8. Inductive Invariants (1) var X : int axiom a1 : Reach(0) init () { X = 0 } axiom a2 : forall x:int. Reach(x)->Reach(x+2) unsafe () { X = 9 } goal unsafe : transition t () exists x. Reach(x) and x = 9 { X := X + 2 } A possible interpretation for Reach could be { 0 , 2 , 4 , 6 , . . . } or { 0 , 2 , 4 , 6 , 8 , 10 , 11 , 12 , 13 , . . . } 23

  9. Inductive Invariants (1) var X : int axiom a1 : Reach(0) init () { X = 0 } axiom a2 : forall x:int. Reach(x)->Reach(x+2) unsafe () { X = 9 } goal unsafe : transition t () exists x. Reach(x) and x = 9 { X := X + 2 } A possible interpretation for Reach could be { 0 , 2 , 4 , 6 , . . . } or { 0 , 2 , 4 , 6 , 8 , 10 , 11 , 12 , 13 , . . . } but not N nor { 0 , 2 , 4 , 5 , 6 , 7 , . . . } 23

  10. Inductive Invariants (1) var X : int axiom a1 : Reach(0) init () { X = 0 } axiom a2 : forall x:int. Reach(x)->Reach(x+2) unsafe () { X = 9 } goal unsafe : transition t () exists x. Reach(x) and x = 9 { X := X + 2 } A possible interpretation for Reach could be { 0 , 2 , 4 , 6 , . . . } or { 0 , 2 , 4 , 6 , 8 , 10 , 11 , 12 , 13 , . . . } but not N nor { 0 , 2 , 4 , 5 , 6 , 7 , . . . } How to find interpretations for inductive invariants ? 23

  11. Inductive invariants (2) U I Set of reachable states from Init = Strongest inductive invariant Post*(I) Strongest inductive invariant U I Set of states that cannot reach Unsafe = Weakest inductive invariant Pre*(U) Weakest inductive invariant 24

  12. Backward Reachability (BR) : How to compute Pre*(U) I : inital states U : unsafe states (cube) T : transitions BR (): V := ∅ ; push( Q , U ) ; while not empty(Q) do ϕ := pop(Q) if ϕ ∧ I sat then return unsafe if ¬ ( ϕ | = � ψ ∈ V ψ ) then V := V ∪ { ϕ } push(Q, pre T ( ϕ )) return safe 25

  13. Backward Reachability (BR) : How to compute Pre*(U) I : inital states U : unsafe states (cube) T : transitions BR (): V := ∅ ; push( Q , U ) ; while not empty(Q) do ϕ := pop(Q) if ϕ ∧ I sat then return unsafe (* SMT check *) if ¬ ( ϕ | = � ψ ∈ V ψ ) then (* SMT check *) V := V ∪ { ϕ } push(Q, pre T ( ϕ )) return safe 25

  14. Pre-images Given a transition t ∈ T , pre t ( ϕ ) is a formula that describes the set of states from which a ϕ -state is reachable in one t -step � pre T ( ϕ ) = pre t ( ϕ ) t ∈T If ϕ is a cube, then pre T ( ϕ ) can also be represented as a union of cubes 26

  15. Running BR I U 27

  16. Running BR I Q V U 27

  17. Running BR I Q V U 27

  18. Running BR I Q V U 27

  19. Running BR I Q V U 27

  20. Running BR I Q V U 27

  21. Running BR I Q V U 27

  22. Running BR I Q V U 27

  23. Running BR I V U 27

  24. BR : example S [ x ] = Crit ∧ S [ y ] = Crit pre enter ( y ) pre enter ( x ) pre enter ( z ) S [ x ] = Want ∧ S [ x ] = Crit ∧ S [ x ] = Crit ∧ S [ y ] = Crit ∧ S [ y ] = Want ∧ S [ y ] = Crit ∧ Turn = x Turn = y S [ z ] = Want ∧ Turn = z pre req ( x ) S [ x ] = Idle ∧ S [ y ] = Crit ∧ Turn = x pre exit ( x ) S [ x ] = Crit ∧ S [ y ] = Crit ∧ Turn = x ′ 28

  25. Implementation issues and optimizations 29

  26. Fixpoint computation V := ∅ push(Q, U) while not empty(Q) do ϕ := pop(Q) if ϕ ∧ I sat then return( unsafe ) if ¬ ( ϕ | = � ψ ∈ V ψ ) then V := V ∪ { ϕ } push(Q, pre T ( ϕ )) return( safe ) 30

  27. Fixpoint computation: a challenge � ϕ | = ψ ψ ∈ V 31

  28. Fixpoint computation: a challenge � ∃ ¯ x.F | = ∃ ¯ y.G ψ ψ ∈ V 31

  29. Fixpoint computation: a challenge � ∃ ¯ x.F ∧ ∀ ¯ y. ¬ G ψ satisfiable ? ψ ∈ V 31

  30. Fixpoint computation: a challenge � ∃ ¯ x.F ∧ ∀ ¯ y. ¬ G ψ satisfiable ? ψ ∈ V F and G ψ are conjunctions of literals involving several theories (uninterpreted function symbols, linear arithmetic, enumerations) 31

  31. Fixpoint computation: a challenge � � ∃ ¯ x.F ∧ ( ¬ G ψ ) σ satisfiable ? σ ∈ Σ ψ ∈ V 31

  32. Fixpoint computation: a challenge � � ∃ ¯ x.F ∧ ( ¬ G ψ ) σ satisfiable ? σ ∈ Σ ψ ∈ V Suppose | V | = 20000 and | Σ | = 120 (e.g. | ¯ x | = | ¯ y | = 5 ) then � � ( ¬ G ψ ) σ | ∼ 2 . 10 6 clauses | ψ ∈ V σ ∈ Σ 31

  33. Fixpoint computation: optimizations ◮ Fast checks: G ψ σ ⊆ F ◮ Irrelevant permutations: L ∈ G ψ σ and L ′ ∈ F and ¬ ( L ∧ L ′ ) is immediate ◮ A single SMT-context is used for each fixpoint check; it just gets incremented and repeatedly verified 32

  34. Node deletion V := ∅ push(Q, U) while not empty(Q) ϕ := pop(Q) if ϕ ∧ I sat then return(unsafe) if ¬ ( ϕ | = � ψ ∈ V ψ ) then V := V ∪ { ϕ } push(Q, pre( ϕ )) return(safe) 33

  35. Node deletion : backward simplification 34

  36. Node deletion : backward simplification 34

  37. Node deletion : backward simplification 34

  38. Node deletion : backward simplification 34

  39. Towards a concurrent implementation ◮ Based on the Functory Library [Filliˆ atre, Krishnamani] : master / worker architecture ◮ Search can be parallelized: • Expensive tasks = fixpoint checks • Synchronization to keep a precise guidance (BFS) • Deletion becomes dangerous 35

  40. Node deletion in parallel BFS 36

  41. Node deletion in parallel BFS 36

  42. Node deletion in parallel BFS 36

  43. Node deletion in parallel BFS 36

  44. Node deletion in parallel BFS 36

  45. Node deletion in parallel BFS 36

  46. Invariants 37

  47. How to scale? Cubicle’s benchmarks on academic problems are promising Cubicle CMurphi Szymanski at 0.30s 8.04s (8) 5m12s (10) 2h50m (12) German Baukus 7.03s 0.74s (4) 19m35s (8) 4h49m (10) German.CTC 3m23s 1.83s (4) 43m46s (8) 12h35m (10) German pfs 3m58s 0.99s (4) 22m56s (8) 5h30m (10) Chandra-Toueg 2h01m 5.68s (4) 2m58s (5) 1h36m (6) 38

  48. How to scale? But how to scale up on industrial-like problems? Cubicle CMurphi Szymanski at 0.30s 8.04s (8) 5m12s (10) 2h50m (12) German Baukus 7.03s 0.74s (4) 19m35s (8) 4h49m (10) German.CTC 3m23s 1.83s (4) 43m46s (8) 12h35m (10) German pfs 3m58s 0.99s (4) 22m56s (8) 5h30m (10) Chandra-Toueg 2h01m 5.68s (4) 2m58s (5) 1h36m (6) Szymanski na T.O. 0.88s (4) 8m25s (6) 7h08m (8) Flash nodata O.M. 4.86s (3) 3m33s (4) 2h46m (5) Flash O.M. 1m27s (3) 2h15m (4) O.M. (5) O.M. > 20 GB T.O. > 20 h 38

  49. What Industrial-Like Means (for us) A well-known candidate : the FLASH protocol (stanford multiprocessor architecture — 1994) ◮ Cache-coherence shared memory ◮ High-performance message passing ◮ 67 million states for 4 processes ( ∼ 40 variables, ∼ 75 transitions) 39

  50. Our Solution to Scale Up We designed a new core algorithm for Cubicle that ◮ infers invariants for parameterized case using finite instances ◮ inserts and checks them on the fly in a backward reachability loop ◮ backtracks if necessary BRAB (Backward Reachability Algorithm with Approximations) [FMCAD 2013] 40

  51. Example: German -ish cache coherence protocol Client i : E Cache [ i ] ∈ { E , S , I } Exg := true Exg := false Directory: Shr [ i ] := true Shr [ i ] := false Cmd ∈ { rs , re , ǫ } S Exg := true Exg := false Shr [ i ] := true Shr [ i ] := false Ptr ∈ proc Shr [ i ] ∈ { true , false } Exg ∈ { true , false } I Initial states: ∀ i. Cache [ i ] = I ∧ ¬ Shr [ i ] ∧ ¬ Exg ∧ Cmd = ǫ ∃ i, j. i � = j ∧ Cache [ i ] = E ∧ Cache [ j ] � = I ? Unsafe states: (cubes) 41

  52. Example: German -ish cache coherence protocol Client i : E Cache [ i ] ∈ { E , S , I } Exg := true Exg := false Directory: Shr [ i ] := false Cmd ∈ { rs , re , ǫ } Shr [ i ] := true S Exg := false Exg := true Shr [ i ] := true Shr [ i ] := false Ptr ∈ proc Shr [ i ] ∈ { true , false } Exg ∈ { true , false } I t 5 : ∃ i. Ptr = i ∧ Cmd = rs ∧ ¬ Exg ∧ Cmd ′ = ǫ ∧ Shr ′ [ i ] ∧ Cache ′ [ i ] = S 41

  53. Backward reachability algorithm I U 42

  54. Backward reachability algorithm I Q V U 42

  55. Backward reachability algorithm I Q V U 42

  56. Backward reachability algorithm I Q V U 42

  57. Backward reachability algorithm I Q V U 42

  58. Backward reachability algorithm I Q V U 42

  59. Backward reachability algorithm I Q V U 42

  60. Backward reachability algorithm I Q V U 42

  61. Backward reachability algorithm I V U 42

  62. BRAB: intuition I U 43

  63. BRAB: intuition I 2 U 43

  64. BRAB: intuition I 2 2 U 43

  65. BRAB: intuition I 2 2 Q V U 43

  66. BRAB: intuition I 2 2 ϕ Q V U 43

  67. BRAB: intuition I 2 2 candidate Q V U 43

  68. BRAB: intuition I 2 2 Q V U 43

  69. BRAB: intuition I 2 2 Q Q V V U 43

  70. BRAB: intuition I 2 2 ϕ Q Q V V U 43

  71. BRAB: intuition I 2 2 Q Q V V U 43

  72. BRAB: intuition I Q 2 2 V U 43

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend