470 likes | 637 Views
Nantes, en Bretagne Nantes in Brittany. Spectacle de Royal de Luxe. La Cour des Comptes de Bretagne Le Château des ducs de Bretagne are situated in Nantes. 1. A bad solution, why?. Composition: to maintain properties. Proof and Model-checking, two Complementary Approaches. Henri Habrias
E N D
Nantes, en BretagneNantes in Brittany Spectacle de Royal de Luxe La Cour des Comptes de Bretagne Le Château des ducs de Bretagne are situated in Nantes 1
Proof and Model-checking, two Complementary Approaches Henri Habrias I.U.T. de Nantes LINA, Laboratoire de Nantes Atlantique
A black box in out We do not take into account the data going through this buffer
Two-places buffer Two accepted traces : [in, out, in, out] [in, in, out, in, out, out, in, out] The following traces are never accepted : [in, in, in] [out, in, out] [in, in, out, out, out] Using the notation for regular expressions : M = (in . (in . out)* out)*
Jackson trees CONS M PROD * * move out in out in move * in out
A white box move in out
Our presentation • Through an example : • proof and refinement with B • model-checking with FSP • To specify a two-places buffer • With two tools : Atelier B and LTSA
B • Classical B • Event B
Classical B vs Event B Classical B An abstract machine with an Invariant and Operations respecting the invariant. The execution system of these operations is not explicitely taken into account compte par la méthode. We prove that an operation called under its precondition respects the invariant..
Classical B vs Event B Event B, Keeps the concepts of classical B but use as fundamental concept, the concept of event.. An event is specified as a guarded operation. An operation is called.An event is not called.
A classical B Machine MACHINE classicalDoor SETS STATE = {open, closed} VARIABLES doorState INVARIANT doorState : STATE INITIALISATION doorState :: ETAT OPERATIONS open = doorState := open END; close = doorState := closed END; st <-- whatState =st := doorState END If doorState = open, doorState := open respects the invariant
A Event B Machine MACHINE EventBDoor SETS STATE = {open, closed} VARIABLES doorState INVARIANT doorState : STATE INITIALISATION doorState :: STATE OPERATIONS opening = SELECT doorState = closed THEN doorState := open END; closing = SELECT doorState = open THEN doorState := closed END; st <-- whatStates = st := doorState END
The door, classical B open close open close open closed open close
The door, Event B initialisation initialisation open closed open close
Classical operation vs Event - a classical operation is called • an event is NOT called. An event is trigged when its guard is • true
Refinement : guard vs precondition - in classical B, preconditions are weaked, - in Event B , Guards are strenghten . Parachute: more we are closed the ground more events we see.
Refinement in Event B • new variables • new constraints linking these new variables to the old variables • new events • And we refine the higher level events
The two places buffer in B (Architecture) M1 M1_I REFINES IMPORTS M2 INCLUDES CONS PROD
M1 (1) MACHINE M1 VARIABLES state INVARIANT state : 0..2 INITIALISATION state := 0
M1Machine (2) OPERATIONS in = SELECT state = 0 THEN state := 1 WHEN state = 1 THEN state := 2 END; out = SELECT state = 1 THEN state := 0 WHEN state = 2 THEN state := 1 END; move = skip END Necessary because we refine with constant signatures.
MACHINE PROD (1) MACHINE PROD VARIABLES pstate INVARIANT pstate : 0..1 INITIALISATION pstate := 0 PROD CONS
MACHINE PROD (1) OPERATIONS in = SELECT pstate = 0 THEN pstate := 1 END; pmove = SELECT pstate = 1 THEN pstate := 0 END END PROD CONS
La machine CONS MACHINE CONS VARIABLES cstate INVARIANT cstat : 0..1 INITIALISATION cstate := 0 OPERATIONS out = SELECT cstate = 1 THEN cstate := 0 END; cmove = SELECT cstate = 0 THEN cstate := 1 END END PROD CONS
M2 includes PROD and CONS MACHINE M2 INCLUDES PROD, CONS PROMOTES in, out OPERATIONS move = pmove || cmove END PROD CONS
M2 simulates M1 IMPLEMENTATION M1_I /* to prove that M2 simulates M1 */ REFINES M1 IMPORTS M2 PROMOTES in, out, move END
FSP • We specify a behaviour in FSP. • LTSA generate the automaton • and • Permits executions. • We can minimise the automaton. • We can verify properties : • no deadlock • progress property
FSP and LTSA Magee J., Kramer J., Concurrency, State Models & Java Programs, Wiley, 1999 Second edition, 2006
FSP and Regular Expressions P= ab*P= (a -> STATE),STATE =(b ->STOP | a -> STATE). P=aa* P= (a -> STOP | a -> STATE), STATE = (a -> STATE). P= (a, b, c)* P= (a -> P |b -> P | c -> P). P = (a (cd)*, b (cd)*)* P= (a -> STATE1 | b -> STATE1), STATE1 = (a -> STATE1 | b -> STATE1 | c -> STATE2), STATE2 = (d -> STATE1).
A limitation of FSP P = a* It impossible to translate into FSP In FSP, no empty sequence
From CCS to FSP C1 = in.m. C1 C2 = m'.out.C2 System = C1 | C2 Is written in LTSA : C1 =(in -> m -> C1). C2 =(m -> out -> C1). ||SYSTEM = (C1 || C2).
|| in B and the diamond in Process algebra P2 x=3 & y = 1 x=3 & y = 1 P1 x=3 & y = 1 P2 P1 x:= x+2 || y:= y+2 x:=x+2;x:=x+2 x:=x+2; y:=x+2 x=5 & y=5 x=5 & y = 5 x=5 & y=7 Diamond
High level spec in FSP BUFFER = STATE0, STATE0 = (in -> STATE1), STATE1 = (in -> STATE2 | out -> STATE0), STATE2 = (out -> STATE1). in out in out ou BUFFER(N=2) = STATE [0], STATE[i:0..N] = (when (i<N) in -> STATE [i+1] | when (i>0) out -> STATE [i-1]). When : guard in FSP
Low level spec in FSP PROD = (in -> move -> PROD). CONS = (move -> out -> CONS). ||BUFF_2 = (PROD || CONS). in out tau move move out in in out
Equivalent Specs ? If now we hide the silent action le move, it is replaced by a tau. If we ask the minimisation of the automation, we obtain the same automaton as the one of the high level spec Equivalence between the two behaviours
Two equivalences for the minimisation • In FSP, for minimisation, two équivalences are considered. • The strong equivalence considers that two systems are equal if they • Have the same behaviour when the occurrence of all their actions can • Be observed included the silent action. • Minimisation uses this equivalence when ther is no silent action.
Weak equivalence • The weak equivalence considers that two systems are equal if they • exhibit the same behaviour for an external observer who cannot detect • the occurrence of the tau actions. PROD = (in -> move -> PROD). CONS = (move -> out -> CONS). ||BUFF_2 = (PROD || CONS)\{move}.
Verification of properties with LTSA • Safety property) , as the absence of deadlock. • Defines a deterministic process asserting that this same process • accepts every trace including the actions of the alphabet of this process. • Liveness property • Asserts that something good will arrive eventually.
Progress property In FSP, the temporal logic is not used.. We are limited to a class of liveness property called progress, which is the opposite to the property of starvation. Such a property asserts that, whatever will be the state of the system, It is always the case where a specified action will eventually be executed.
A behaviour in FSP MEN(N=3) = BACHELOR[0] BACHELOR[spouses_nb : 0..N] = (marriage -> MARRIED[1]) MARRIED[spouses_nb :0..N]= (when (spouses_nb ==1) divorce -> MEN | when (spouses_nb >1) divorce -> MARRIED[spouses_nb –1] | when (spouses_nb == 3] it_is_enough_for_a_man -> divorce -> MARRIED[spouses_nb –1 ] | when (spouses_nb <3) marriage -> MARRIED[spouses_nb + 1]). Not considered: the death of a a man who was never married
4 Relational schemas (without null values) Schema 1 Marriages_in_course (id_married_men , id_married_women) Schema 2 Marriages_in_course (id_married_men , id_married_women) Schema 3 Marriages_in_course (id_married_men , id_married_women) Schema 4 Marriages_in_course (id_married_men , id_married_women)
B notation isToDayMarriedWith : id_married_women -->> id_married_men isToDayMarriedWith : id_married_men ->> id_married_women isToDayMarriedWith : id_married_women >->> id_married_men isToDayMarriedWith : id_married_women <--> id_married_men & dom (isToDayMarriedWith) = man
Polygamy without polyandry Marriage/N:=N+1 Marriage/ N:= N+1 Bachelor Married Divorce or death/ SELECT N=1 THEN N:=N-1 Divorce or death/ SELECT N>1 THEN N:=N-1 Harel Automata with guards
Conclusion • To specify, refine and verify : • the B approach permits to manipulate variables as it is done classically • in programming. • The approach by Process Algebras does not use variables. A state • is modelised by a behaviour. • With LTSA, we are obliged to modelise a variable by a behaviour and • It complicates the specification comparatively to what is done with B.
Conclusion • But otherwise with B the automaton is not explicit whereas LTSA • Products the automaton. • in B, we are guided by the proof, • in FSP we are guided by the execution and by the generated automaton • and his minimisation. Considering the automaton it is possible • to restructurate the specification
IN MEMORIAM Claude Piéplu (1923-2006)