Proving invariants: how many times a program should be unfolded ? - - PowerPoint PPT Presentation

proving invariants how many times a program should be
SMART_READER_LITE
LIVE PREVIEW

Proving invariants: how many times a program should be unfolded ? - - PowerPoint PPT Presentation

Proving invariants: how many times a program should be unfolded ? Paul Caspi, Jan Mik VERIMAG Grenoble Problem definition 1 A closed system state space S initial state I is a predicate on S transition relation T is a predicate on S


slide-1
SLIDE 1

Proving invariants: how many times a program should be unfolded ? Paul Caspi, Jan Miká

VERIMAG – Grenoble

slide-2
SLIDE 2

Problem definition 1

A closed system

state space S initial state I is a predicate on S transition relation T is a predicate on S x S sequence of states X0,X1,X2,...Xn,... such that I(X0) and T(Xn,Xn+1) hold

Properties

strongest invariant of the system X = I ∪ ∪ ∪ ∪ T[ X ] (fix) an invariant property P: X

  • P ?

Induction

I P P T[P] X

  • P
slide-3
SLIDE 3

Problem definition 2

Induction

I P P T[P] X

  • P

n unfoldings

I P, T[I] P, ..., Tn-1[I] P P∧ ∧ ∧ ∧T[P]∧ ∧ ∧ ∧...∧ ∧ ∧ ∧Tn-1[P] T[P]∧ ∧ ∧ ∧...∧ ∧ ∧ ∧Tn[P] (X

  • P)∧

∧ ∧ ∧...∧ ∧ ∧ ∧ (Tn[ X ]

  • P)

I P, T[I] P, ..., Tn-1[I] P P∧ ∧ ∧ ∧T[P]∧ ∧ ∧ ∧...∧ ∧ ∧ ∧Tn-1[P] T[P]∧ ∧ ∧ ∧...∧ ∧ ∧ ∧Tn[P] X

  • P

I P, T[I] P, ..., Tn-1[I] P P∧ ∧ ∧ ∧T[P]∧ ∧ ∧ ∧...∧ ∧ ∧ ∧Tn-1[P] T[P]∧ ∧ ∧ ∧...∧ ∧ ∧ ∧Tn[P] X

  • P

I P, T[I] P, ..., Tn-1[I] P P∧ ∧ ∧ ∧T[P]∧ ∧ ∧ ∧...∧ ∧ ∧ ∧Tn-1[P] Tn[P]∧ ∧ ∧ ∧...∧ ∧ ∧ ∧T[P] X

  • P

What is a ``good'' value for n ?

easy to find (by a machine) likely to work ``Good'' means number of variables of the system

slide-4
SLIDE 4

Problem definition 2

Induction

I P P T[P] X

  • P

n unfoldings

I P, T[I] P, ..., Tn-1[I] P P∧ ∧ ∧ ∧T[P]∧ ∧ ∧ ∧...∧ ∧ ∧ ∧Tn-1[P] T[P]∧ ∧ ∧ ∧...∧ ∧ ∧ ∧Tn[P] (X

  • P)∧

∧ ∧ ∧...∧ ∧ ∧ ∧ (Tn[ X ]

  • P)

I P, T[I] P, ..., Tn-1[I] P P∧ ∧ ∧ ∧T[P]∧ ∧ ∧ ∧...∧ ∧ ∧ ∧Tn-1[P] T[P]∧ ∧ ∧ ∧...∧ ∧ ∧ ∧Tn[P] X

  • P

I P, T[I] P, ..., Tn-1[I] P P∧ ∧ ∧ ∧T[P]∧ ∧ ∧ ∧...∧ ∧ ∧ ∧Tn-1[P] T[P]∧ ∧ ∧ ∧...∧ ∧ ∧ ∧Tn[P] X

  • P

I P, T[I] P P∧ ∧ ∧ ∧T[P] T2[P] X

  • P

proof

I P, T[I] P, T2[I] P P∧ ∧ ∧ ∧T[P]∧ ∧ ∧ ∧T2[P] T3[P] X

  • P

proof

I P, T[I] P, ..., Tn-1[I] P P∧ ∧ ∧ ∧T[P]∧ ∧ ∧ ∧...∧ ∧ ∧ ∧Tn-1[P] Tn[P]∧ ∧ ∧ ∧...∧ ∧ ∧ ∧T[P] X

  • P

proof proof

What is a ``good'' value for n ?

easy to find (by a machine) likely to work ``Good'' means number of variables of the system

slide-5
SLIDE 5

Small example 1

f = 1.(f + g) g = 0.(f – g) prove All f+g > 0 1 1 1 2 2 2 4 ... ... n = 1 f+g > 0 1.(f+g)+0.(f-g) > 0 impossible to prove g = 1.(f + g) f = 0.(f – g) 1 1

  • 1
  • 2
  • 2
  • 2
  • 4

... ... f =-1.(f + g) g = 2.(f – g)

  • 1

2 1

  • 3
  • 2

4 2

  • 6
  • 4

8 ... ... n = 2 f+g > 0 1.(2f) > 0 1.2.(2f + 2g)>0 provable

slide-6
SLIDE 6

Small examples 2

fibo = 1.(fibo + g) g = 0.fibo prove All fibo > 0 1 1 2 3 5 8 ... 0 1 1 2 3 5 ... n = 2 fibo > 0 1.(fibo + g) > 0 1.(1.(fibo+g) + 0.fibo)>0 provable fibo = 1.(fibo + 0.fibo) prove All fibo > 0 n = 1 fibo > 0 1.(fibo + 0.fibo) > 0 provable

slide-7
SLIDE 7

Small example 3

f = 1.(f + g) g = 0.(f + h) h = 1.g prove All f > 0 1 1 3 4 9 14 ... 0 2 1 5 5 14 ... 1 0 2 1 5 5 ... n = ? f > 0 1.(f + g) > 0 1.1.(2f+g+h) > 0 1.1.3.(3f+3g+h) > 0 1.1.3.4.(6f+4g+3h) > 0 1.1.3.4.9.(10f+9g+4h) > 0 ... ... ...

slide-8
SLIDE 8

Example conclusion

easy to find (by a machine) likely to work ``Good'' is number of variables of the system

What is a ``good'' value for n ?

In fact we want : dimension of the system. Number of variables mostly dimension Number of variables is easy to find Unfold < n times : can work (property holds

  • n a whole class)

Unfold n times : works because all information is used Unfold n times : if it doesn't work, we have no other limit

slide-9
SLIDE 9

Example of synchronizer

Paul Miner & Steven Johnson Verification of an Optimized Fault-Tolerant Clock Synchronization Circuit

/2 + rd f1 nf norm Normal circuit + rd f1 nf

  • pt

Optimized circuit

slide-10
SLIDE 10

assert R.true assert nf => f1 assert (not f1).true assert true.(tl(R) or (nf => tl(nf))) assert R => (not f1) rd=0.(if tl(R) then 0 else rd+1) nor=(t1 + tn) div 2 t1=0.(if tl(R) then 0 else (if tl(f1) then t1 else tl(rd))) tn=0.(if R then 0 else (if tl(nf) then tn else tl(rd))) h=false.((not tl(R)) and tl(f1) and (not h)) cin=false.(h and not tl(nf))

  • pt=0.(if tl(R) then 0 else (if tl(f1) then

(if tl(cin) then 1 else 0) + opt else tl(rd))) rd=0 -> if R then 0 else pre rd+1 ; nor=(t1 + tn) div 2 ; t1=0->if R then 0 else (if f1 then pre t1 else rd); tn=0->if R then 0 else (if nf then pre tn else rd); h =false -> (not R) and f1 and (not pre h) ; cin=false -> (pre h) and not nf ;

  • pt=0 -> if R then 0 else (if f1 then

(if cin then 1 else 0) + pre opt else rd); assert R -> true ; assert nf => f1 ; assert not f1 -> true ; assert true -> R or (pre nf => nf) ; assert R => (not f1) ;

Example of synchronizer

Paul Miner & Steven Johnson Verification of an Optimized Fault-Tolerant Clock Synchronization Circuit

slide-11
SLIDE 11

Example of synchronizer

Paul Miner & Steven Johnson Verification of an Optimized Fault-Tolerant Clock Synchronization Circuit

rd=0 -> if R then 0 else pre rd+1 ;

nor=(t1 + tn) div 2 ; t1=0->if R then 0 else (if f1 then pre t1 else rd); tn=0->if R then 0 else (if nf then pre tn else rd); h =false -> (not R) and f1 and (not pre h) ; cin=false -> (pre h) and not nf ;

  • pt=0 -> if R then 0 else (if f1 then

(if cin then 1 else 0) + pre opt else rd); assert R -> true ; assert nf => f1 ; assert not f1 -> true ; assert true -> R or (pre nf => nf) ; assert R => (not f1) ;

gloups nor = opt n unfoldings (infinite finite) list induction (finite scalar) proof obligations (scalar)

PVS

slide-12
SLIDE 12

Conclusion

Proving invariants: how many times a program should be unfolded ? What is a ``good'' value for n ?

easy to find (by a machine) likely to work ``Good'' means number of variables of the system I P, T[I] P, ..., Tn-1[I] P P∧ ∧ ∧ ∧T[P]∧ ∧ ∧ ∧...∧ ∧ ∧ ∧Tn-1[P] Tn[P]∧ ∧ ∧ ∧...∧ ∧ ∧ ∧T[P] X

  • P
slide-13
SLIDE 13

Perspectives

Prove Time-Trigered Protocole Membership Algorithm (Next-TTA) Difficult problem Space requirements Modular proofs Explore link refinement-unfolding Proving refinements (vertical modularity) Evolution of the number of unfoldings during the refinement

Questions ?