A Usable Reachability Analyser Victor Khomenko Newcastle University
A Usable Reachability Analyser Victor Khomenko Newcastle University
Reachability analysis • Problem statement: check if there is a reachable state s satisfying a given predicate R(s) • Usually R specifies some undesirable situation, e. g. a deadlock, violation of mutual exclusion, violation of an assertion • If the system is a safe Petri net then R is a Boolean expression over the elementary predicates corresponding to the places, e. g. : p 1 p 2 + p 1 p 3 + p 2 p 3 2
How to specify properties? • Manual specification is tedious and errorprone • Automatic generation of formulae can be done only for a fixed set of standard properties; hence custom properties cannot be checked, even if they are just minor variations of standard properties • Users are often forced to implement generators for their custom properties (simple in theory, hard work in practice) 3
Example: Dining Philosophers T 2 P 4 T 7 P 12 P 10 P 7 T 1 P 1 T 5 P 3 P 6 T 3 P 5 T 4 P 8 T 9 P 14 P 9 T 10 T 8 P 13 T 11 T 12 P 15 P 16 T 6 P 11 p 1 (p 2 + p 7)(p 3 + p 8)(p 4 + p 5) p 6 p 9 (p 7 + p 10)(p 8 + p 9)(p 12 + p 13) p 14 p 1 p 9 (p 15 + p 16) 4
How to specify properties? • In this case can reduce to standard deadlock P checking: P • In general, such reductions may be difficult or not possible • It is a bad idea to make the user to modify the model or invent tricks 15 16 5
Proposed solution Language Reach for specifying reachability properties: • custom properties can be easily and concisely specified • the model does not have to be modified in any way, in particular the model does not have to be translated into an input language of some model checker • almost any reachability analyser can be used as the back-end 6
Example: deadlock property Mathematical definition: Reach specification: forall t in TRANSITIONS { exists p in pre t { ~$p } } or simply forall t in TRANSITIONS { ~@t } taking care of proper termination: forall t in TRANSITIONS { ~@t } & (~$P"p 15" | ~$P"p 16") 7
Reachability analysis flow 8
Case studies: asynchronous circuits Asynchronous circuits are circuits without clocks • Very attractive: the traditional synchronous (clocked) designs lack flexibility to cope with contemporary microelectronics challenges • Notoriously difficult to design correctly • Often specified using Signal Transition Graphs (STGs) – a class of labelled Petri nets 9
Example: VME Bus Controller Data Transceiver Bus dsr dtack VME Bus Controller lds ldtack dsr+ lds+ dtackd- ldsdsr- ldtack+ Device d ldtack+ d+ 10
Case studies: Consistency In each possible execution, the transitions representing the rising and falling edges of each signal must be correctly alternated between, always starting from the same edge (either rising or falling) exists s in SIGNALS { let Ts = tran s { $s & exists t in Ts s. t. is_plus t { @t } | ~$s & exists t in Ts s. t. is_minus t { @t } } } 11
Case studies: Output persistency A local signal (output or internal) should not be disabled by any other transition a+ x+ x+ OP violation a+ ok ok x+ y+ OP violation a+ b+ ok a+ x+ ok 12
Case studies: Output persistency exists t 1 in TRANSITIONS s. t. sig(t 1) in LOCAL { @t 1 & exists t 2 in TRANSITIONS s. t. sig(t 2)!=sig(t 1) & |pre(t 1)*(pre(t 2)post(t 2))|!=0 { @t 2 & forall t 3 in tran(sig(t 1)){t 1} s. t. |pre(t 3)*(pre(t 2)post(t 2))|=0 { exists p in pre(t 3)post(t 2) { ~$p } } Intuitively, we are looking for a marking where t 1 is disabled by t 2, and after t 2 fires, no transition with the same signal as t 1 is enabled 13
Case studies: CSC 00100 ldtack 01100 lds 01110 States with the same encoding should enable the same local signals dtackldtack- 10000 dsr+ 00000 lds+ ldtack- dtack 01000 dsr+ 10010 11000 ldsldsdtackdsr+ 01010 11010 M’’ ldtack+ M’ 11010 d+ d- dsr 01111 dtack+ 11111 11011 14
Case studies: CSC • Generalised reachability property: check if there are reachable states s 1, …, sk satisfying a given predicate R(s 1, …, sk) forall s in SIGNALS { $s <-> $$s } & exists s in LOCAL { @s^@@s } 15
Case studies: arbiters r 1 + g 1+ r 1 - g 1 - rn + g n+ rn - g n- r 1 + g 1+ r 1 - g 1 - g n+ rn - g n- … Traditional protocol g 1 … gn … rn Arbiter … r 1 Early protocol rn + 16
Case studies: deadlock in arbiters • The rising request transitions are not weakly fair, i. e. any state (except the initial one) enabling only such transitions is a deadlock • The initial state has to be treated in a special way • A minor variation of a standard property that renders standard deadlock checkers almost useless {T"ra+", T"rb+", T"rc+"} { let requests = TT "r[a-z]\++\(/[0 -9]\+\)\? " { forall t in TRANSITIONSrequests { ~@t } } & exists p in PLACES { $p ^ is_init p } 17
Case studies: mutual exclusion • Mutual exclusion of signals rather than places let a = $S"ga", b = $S"gb", c = $S"gc" { a & b | b & c | a & c } • Alternatively: threshold[2]($S"ga", $S"gb", $S"gc") • With a regular expression: let grants = SS "g[a-z]\+" { threshold[2] g in grants { $g } } 18
Case studies: mutual exclusion • Traditional mutual exclusion does not hold for the early protocol threshold[2]($S"ra" & $S"ga", $S"rb" & $S"gb", $S"rc"&$S"gc") • With a regular expression: let req = SS "r[a-z]\+" { threshold[2] r in req { $r & $S("g" + (name r)[1. . ]) } } 19
Conclusion • A solution to the problem of generating formulae expressing custom reachability properties has been proposed • The usefulness of this method is demonstrated on several case studies • The developed MPSAT tool is currently being used as the reachability analysis engine within the Desi. J and Workcraft tools 20
Future work • Extension to other formalisms is straightforward (general Petri nets, coloured Petri nets, products of automata, digital circuits, etc. ) • Extension to other property classes is straightforward (e. g. add LTL or CTL modalities) • Share common subterms during expansion • Add more powerful constructs, such as recursive definitions and rewriting rules 21
- Slides: 21