System Level Formal Verification via Distributed Multi-core Hardware in the Loop Simulation
System Level Formal Verification via Distributed Multi-core Hardware in the Loop Simulation
System Level Formal Verification via Distributed Multi-Core Hardware in the Loop
Simulation
Toni Mancini, Federico Mari, Annalisa Massini, Igor Melatti, Enrico Tronci
Computer Science Department, Sapienza University of Rome
Via Salaria 113, I-00198 Roma, Italy
Email: {tmancini,mari,massini,melatti,tronci}@di.uniroma1.it
735
Authorized licensed use limited to: Univ of Calif Santa Cruz. Downloaded on October 15,2024 at 21:08:15 UTC from IEEE Xplore. Restrictions apply.
the above ones focus on parallelising the state space explo- • s0 ∈ S is the initial state.
ration engine by devising techniques to minimise locking of • d ∈ N+ defines the input space as Ud (the set of discrete
the visited state hash table whereas we leave unchanged the event sequences over [0, d]).
state space exploration engine (the simulator in our context) • O is the set of output values (finite, countable, contin-
and use a Map-Reduce like strategy that splits (Map step) uous, or any combination thereof).
≥0
the set of simulation scenarios into equal sized subsets to be • flow : S × R → S. For all s ∈ S, t ∈ R≥0 , flow(s, t)
simulated on different cores and stops verification as soon defines the state reached by H from state s after time t when
as one of such cores finds an error (Reduce step). Note that no event occurs. Accordingly, we stipulate that for all s ∈ S,
we propose an embarrassingly parallel algorithm for (black flow(s, 0) = s.
box) formal verification of hybrid systems. Embarrassingly • jump : S × [0, d] → S. For all s ∈ S, e ∈ [0, d]
parallel verification algorithms have also been investigated in jump(s, e) defines the state reached by H from state s upon
[22], as for finite state system verification, and in [23], as for occurrence of event e (no time flows). Accordingly, we
symbolic testing of programs. Such approaches are close in stipulate that for all s ∈ S, jump(s, 0) = s.
spirit to ours, although they differ from ours as for the class • output : S → O. The value output(s) defines the output
of systems considered (we focus on hybrid systems whereas of H in state s.
the above papers focus on discrete systems) as well as for The state, respectively output, reached after time t by a
the modelling approach (our black box algorithm rests on DES with a given input can be computed with the DES state,
the disturbance model whereas the above papers both present respectively output, function (Definition 3).
white box algorithms resting on the system model). Definition 3 (DES state and output functions): The state
function of DES H is a function φ : Ud × R≥0 → S, where
II. BACKGROUND φ(u, t) is the state reached at time t by H with input the
In this section we give some background notions. Unless discrete event sequence u. Function φ is defined inductively
otherwise stated, all definitions are based on [24], [1]. as follows:
Throughout the paper, we use R≥0 for the set of non- • φ(u, 0) = jump(s0 , u(0)), where s0 is the initial state
negative reals, R+ for the set of strictly positive reals, and of H;
Bool = {0, 1} for the set of Boolean values (0 for false and • For each t > 0, φ(u, t) = jump(flow(φ(u, t ), t −
∗
736
Authorized licensed use limited to: Univ of Calif Santa Cruz. Downloaded on October 15,2024 at 21:08:15 UTC from IEEE Xplore. Restrictions apply.
u(t) = δ0 , . . . , δn−1 is an (h, d) sequence of disturbance traces,
u(t) and H = (S, s0 , d, flow, jump, output) is an MDES.
The answer to SLFV problem P is FAIL if there exists a
t t disturbance trace δ in Δ such that ψ(uτδ , τ h) = 1 (in such a
(a) (b) (c)
case also the counterexample δ is returned), PASS otherwise.
Figure 1: (a) a discrete event sequence (d = 3); (b) our SUV Note that, notwithstanding the fact that the number of
with an embedded monitor; (c) the SUV monitor output. states of our SUV is infinite and we are in a continuous
time setting, to answer a SLFV problem we only need to
check a finite number of disturbance traces. This is because
we are bounding: (a) our time horizon to T = hτ (i.e.,
whose set of output values is Bool. We call such a DES a
h multiplied by τ ), and (b) the set of time points at which
Monitored Discrete Event System (Definition 4 and Fig. 1b).
disturbances can take place, by taking τ as the time quantum
Definition 4 (Monitored Discrete Event System): A
among disturbance events.
Monitored Discrete Event System (MDES) is a tuple
Thus, by taking h large enough (as in BMC) and τ
H = (S, s0 , d, flow, jump, output) such that (S, s0 , d,
small enough (to faithfully model our SUV operational
Bool, flow, jump, output) is a DES whose output function
scenarios), we can achieve any desired precision. On such
ψ(u, t) is non-decreasing with respect to t. That is, for any
considerations rests the effectiveness of the approach.
input sequence u ∈ Ud , for all t, t ∈ R≥0 , if t ≤ t then
ψ(u, t) ≤ ψ(u, t ). In other words, an MDES is a DES with F. HILS-based System Level Formal Verification
non-decreasing boolean outputs.
We use a black-box approach where the MDES H defin-
D. Modelling SUV operational scenarios ing our SUV and property to be verified is defined using the
System level verification follows an Assume-Guarantee modelling language of a suitable simulator (e.g., MatLab and
approach aimed at showing that the SUV meets its specifi- Stateflow for Simulink).
cation (Guarantee) as long as the SUV operational environ- We compute the answer to an SLFV problem (h, d,
ment behaves as expected (Assume). As in Bounded Model τ , Δ, H) by simulating each operational scenario δ in
Checking (BMC), we model (Definition 5) scenarios in the the operational environment Δ. In other words, we are
SUV operational environment as sequences of disturbances performing an exhaustive (with respect to Δ) HILS.
(disturbance traces) our SUV is expected to withstand. Each We drive a simulator for H (that is, a simulator running a
disturbance is an integer in [0, d] and disturbance traces are model for H) using four basic commands: store, load, free,
of finite length h. Given a time quantum τ ∈ R+ , a distur- run. Command store(l) stores in memory the current state
bance trace can be associated to a discrete event sequence of the simulator and labels with l such a state. Command
where all disturbances occur at time points multiple of τ . load(l) loads into the simulator the stored state labelled
Definition 5 (Disturbance trace): Let h, d ∈ N+ . An with l. Command free(l) removes from the memory the
(h, d) disturbance trace δ is a finite sequence δ : [0, h−1] → state labelled with l. Command run(e, t) (with e ∈ [0, d]
[0, d]. Given τ ∈ R+ (time quantum), to an (h, d) disturbance and t ∈ R+ ) injects disturbance e and then advances the
trace δ we can univocally associate a discrete event sequence simulation of time t. A simulation campaign is a sequence
uτδ , defined as follows (see also Fig. 2d, ignoring the letters of simulator commands.
in the disturbance traces). For all t ∈ R≥0 , if there exists Using the commands store and load we can avoid revisit-
k ∈ [0, h − 1] such that t = τ k then uτδ (t) = δ(k), else uτδ (t) ing simulation states (much as in explicit model checking).
= 0 (no disturbance). Using command free we can remove from the memory
Thus a disturbance trace δ defines an operational scenario states that will never be needed in the remaining part of
(namely, uτδ ) for our SUV. the simulation campaign. This is needed since each state
An (h, d) sequence of disturbance traces is a finite may require many KB of memory (150 KB in the case
sequence Δ = δ0 , . . . , δn−1 of (h, d) disturbance traces. study presented in this paper). We will show how optimised
Given τ ∈ R+ , to each sequence of disturbance traces Δ simulation campaigns enable HILS-based distributed multi-
= δ0 , . . . , δn−1 is associated a sequence of discrete event core SLFV.
τ
sequences UΔ = uτδ0 , . . . , uτδn−1 . Accordingly, we model our
III. OVERALL APPROACH
SUV operational environment as a sequence of disturbance
traces Δ since UΔ τ
defines the operational scenarios our SUV Our overall approach is shown in Fig. 3. To define an
should withstand. SLFV problem (h, d, τ , Δ, H), we need to build the
sequence of admissible disturbance traces Δ (operational
E. The System Level Formal Verification problem environment).
A System Level Formal Verification (SLFV) problem is a Of course, it is typically infeasible to define operational
tuple P = (h, d, τ , Δ, H) where: h, d ∈ N+ , τ ∈ R+ , Δ environments by listing all their disturbance traces. In [1]
737
Authorized licensed use limited to: Univ of Calif Santa Cruz. Downloaded on October 15,2024 at 21:08:15 UTC from IEEE Xplore. Restrictions apply.
τ
$%&'%()* +
! !
(a) (b) (c) (d) t
#
"
Figure 2: (a) disturbance model; (b) CMurphi-based distur-
bance generator; (c) generated labelled admissible sequence
of disturbance traces (d = 3, h = 6, integers from 0 to d ,*
denote disturbances, letters denote labels); (d) the discrete
event sequence associated to the trace in the black rectangle
738
Authorized licensed use limited to: Univ of Calif Santa Cruz. Downloaded on October 15,2024 at 21:08:15 UTC from IEEE Xplore. Restrictions apply.
Input: Δλ , a labelled lex-ordered sequence of disturbance traces A. LBT construction
Output: χ , the computed simulation campaign, initially empty
1 LBT ← buildLBT(Δλ ); The LBT is a tree of labels rooted at l0 , the first label of all
2 let l0 be the first label common to all traces in Δλ ; traces (e.g., l0 = a in Fig. 2c and Fig. 4). The LBT collects
3 stored ← empty set of labels; /* inv: stored⊆LBT and |stored|≤h */ branching labels, i.e., labels li for which there exist at least
4 append store(l0 ) to χ and add l0 to stored;
5 i ← 0; two labelled disturbance traces δ λ = l0 , d0 , . . . , li , di , . . . , lh
6 foreach δ λ = l0 , d0 , . . . , lh−1 , dh−1 , lh in Δλ do and δ λ = l0 , d0 , . . . , li , di , . . . , lh in Δλ which are identical
7 i++; /* δ λ is the i-the trace in Δλ */ up to li and such that di = di . Branching labels represent
8 t load ← max t s.t. lt ∈ stored;
9 append load(lt load ) to χ;
simulator states whose storing may save simulation time (by
10 foreach label l ∈ stored s.t. LBT[l].lastTrace ≤ i do loading them back later).
11 append free(l) to χ; Label lj is a child of li in the LBT iff, for all δ λ = l0 , d0 ,
12 remove l from stored;
13 dˆ ← dt load ; steps ← 1;
. . . , li , . . . , lj , . . . , lh ∈ Δλ , no lk in δ λ with i < k < j is
14 for t ← t load + 1 to h − 1 do in the LBT (note: all such δ λ are identical at least up to lj ).
15 toBeStored ← (lt ∈ LBT − stored and LBT[lt ].lastTrace > i); For each label l in the LBT, the number of the last trace in
if toBeStored or dt = 0 then
16
ˆ steps) to χ; dˆ ← dt ; steps ← 1;
Δλ where it occurs is kept.
17 append run(d,
18 if toBeStored then The construction of the LBT is shown as function
19 append store(lt ) to χ and add lt to stored; buildLBT() in Algorithm 1 (from line 22). The function
20 else steps++; scans the input slice in order to recognise branching labels,
21 return χ;
keeping in array watched the labels of the last processed
22 function buildLBT(Δλ ) trace. In fact, as the traces in Δλ are lexicographically
23 LBT ← empty tree of labels;
/* for each l ∈ LBT, LBT[l].lastTrace stores the index of last trace
ordered, these are the only labels that may become branching
where it is known to occur */ when processing a new trace. To see why, assume that the
24 watched ← empty array [0..h − 1] of labels; optimiser is processing, e.g., trace 2 in Fig. 4a (left). As this
25 let l0 be the first label common to all traces in Δλ ; trace starts to be different with respect to the previous trace
26 set l0 as the root of LBT with LBT[l0 ].lastTrace ← |Δλ |;
27 watched[0] ← l0 ; (trace 1) from the disturbance at step 2 (i.e., disturbance 2
28 i ← 0; right after label c), the optimiser infers that labels d, e, f, g
29 foreach δ λ = l0 , d0 , . . . , lh−1 , dh−1 , lh in Δλ do of trace 1 will never occur in later traces of Δλ , and will
30 i++; /* δ λ is the i-th trace in Δλ */
31 for t ← 0 to h − 1 s.t. lt ∈ LBT do LBT[lt ].lastTrace ← i;
never become branching.
32 t lbt ← max t s.t. lt ∈ LBT; As for the actual recognition of a new branching la-
33 t w ← max t s.t. lt ∈ watched; bel and its addition to the LBT, assume that function
34 if t lbt = t w then
/* label lt w ∈ LBT: add it */ buildLBT() is processing the i-th disturbance trace δ =
35 t child ← min t > t w s.t. watched[t child] ∈ LBT (if any); l0 , d0 , . . . , lt lbt , dt lbt , . . . , lt w , dt wW , . . . , lh (line 29). Vari-
36 add lt w to LBT as child of lt lbt with LBT[lt w ].lastTrace = i; able t lbt is set to the max index of a label in δ λ already
37 move lt child (if any) as to be child of lt w in LBT;
38 foreach t ← t w + 1 to h − 1 do watched[t] ← lt ; in the LBT, and t w is the max index of a label in δ which
/* watched now contains labels of the last trace */ belongs also to array watched. As l0 is put both in the
39 return LBT; LBT and in watched[0] at the beginning, both values are
Algorithm 1: DFS-Optimiser pseudo-code
always defined. The algorithm infers that the current trace
is identical to the previously processed one up to t w, but
differs from it starting from the disturbance to be injected at
step t w + 1. If t w = t lbt, label lt w is already branching,
and nothing has to be done. Otherwise, the new label lt w is
campaign is abstract in that, for all commands of the form
recognised as branching, and is added to the LBT as a child
run(e, t), t is a natural number and not an actual time
of lt lbt (as, given that the input traces are in lexicographic
duration. By providing a time step τ ∈ R+ , χ can be
order, t w = t lbt implies t w > t lbt). As lt lbt could
instantiated into a concrete simulation campaign χτ , by
already have children in the LBT, the tree may need to be
replacing all run(e, t) commands by run(e, tτ ).
rearranged to accommodate the new label lt w . Given that the
The algorithm of our optimiser is shown as Algorithm 1. input traces are in lexicographic order, the last task is very
As the input sequence Δλ of labelled disturbance traces can simple, as at most one child of lt lbt must be moved. This
be too big to be kept in main memory, the optimiser reads child, if exists, must be a label that occurred in the previous
the input file sequentially twice. In the first scan of Δλ , the trace, i.e., it belongs to the watched array (line 35).
optimiser builds a data structure called Labels Branching Fig. 4a shows an example of LBT construction starting
Tree (LBT) as completely as possible within the available from a labelled lexicographically ordered sequence of dis-
RAM. Afterwards, it reads Δλ again to produce the abstract turbance traces Δλ consisting of 6 traces. Note that, out of
simulation campaign from the LBT. 25 labels in Δλ , only 5 of them belong to the LBT. When
739
Authorized licensed use limited to: Univ of Calif Santa Cruz. Downloaded on October 15,2024 at 21:08:15 UTC from IEEE Xplore. Restrictions apply.
be safely freed (line 12).
Fig. 4(b) shows the simulation campaign computed by
the optimiser on the slice in Fig. 4(a). Except for the first
command which stores a (the label common to all traces and
representing the simulator initial state), each line represents
(a)
the portion of the simulation campaign stemming from each
store(a) trace. Note that only the first trace is simulated entirely,
load (a) run(0,1) store(b) run(2,1) store(c) run(1,3) run(1,1)
load (c) run(2,2) store(i) run(0,2) while all the others are simulated starting from intermediate,
load (i) free(i) run(3,2) previously stored, states.
load (c) run(3,1) store(p) run(1,1) run(1,2)
load (p) free(p) free(c) run(2,1) run(2,2) C. Optimiser soundness and completeness
load (b) free(b) free(a) run(3,3) run(1,2)
740
Authorized licensed use limited to: Univ of Calif Santa Cruz. Downloaded on October 15,2024 at 21:08:15 UTC from IEEE Xplore. Restrictions apply.
#traces scSLFV mcSLFV time scSLFV mcSLFV
#slices per slice optimiser optimiser saving %
#machines #slices time #slices time time saving %
1 4,023,955 20:27:26 0:7:16 99.41%
2 2,011,977 3:47:57 0:9:43 95.74% 8 8 711:3:33 64 205:49:20 71.05%
4 1,005,988 1:45:4 0:9:0 91.43% 16 16 343:24:27 128 100:47:4 70.65%
8 502,994 0:44:27 0:5:27 87.74% 32 32 167:6:9 256 58:26:29 65.03%
16 251,497 0:16:24 0:2:8 86.99% 64 64 81:49:3 512 27:18:2 66.63%
32 125,748 0:4:50 0:0:57 80.34%
64 62,874 0:0:51 0:0:29 43.14% Table III: Completion time of the parallel simulation (i.e.,
128 31,437 0:0:35 0:0:17 51.43% completion time of the longest campaign) with respect to
256 15,718 0:0:10 0:0:8 20.00% the approach of [1] (time in h:m:s).
512 7,859 0:0:5 0:0:4 20.00%
741
Authorized licensed use limited to: Univ of Calif Santa Cruz. Downloaded on October 15,2024 at 21:08:15 UTC from IEEE Xplore. Restrictions apply.
ing % is defined as (tsc − tmc )/tsc , where tsc and tmc [9] S. Tripakis, C. Sofronis, P. Caspi, and A. Curic, “Translating
are, respectively, the entries in columns scSLFV time and discrete-time simulink to lustre,” ACM Trans. Emb. Comp.
mcSLFV time. Table III shows that, when using the same Syst., vol. 4, no. 4, pp. 779–818, 2005.
hardware, our distributed multi-core approach saves at least [10] B. Meenakshi, A. Bhatnagar, and S. Roy, “Tool for translating
65% of verification time. For example, using 64 machines, simulink models into input language of a model checker,” in
the verification task using the single-core approach of [1] Proc. ICFEM 2006, 2006, pp. 606–620.
would need 81 hours, while ours needs less than 27 hours.
[11] M. Whalen, D. Cofer, S. Miller, B. Krogh, and W. Storm,
Note that a serial approach to verification would need more “Integration of formal analysis into a model-based software
than 200 days. development process,” in Proc. FMICS 2007, 2007.
VI. C ONCLUSIONS [12] C. Yang and D. Dill, “Validation with guided search of the
We have presented a distributed multi-core approach to state space,” in Proc. DAC 1998. ACM, 1998, pp. 599–604.
HILS-based SLFV. We have implemented our algorithms
[13] P. Ho, T. Shiple, K. Harer, J. Kukula, R. Damiano,
and run experiments on a large control system case study V. Bertacco, J. Taylor, and J. Long, “Smart simulation
in the Simulink distribution, whose operational environment using collaborative formal and simulation engines,” in Proc.
consists of more than 4 million simulation scenarios. Our ICCAD 2000. IEEE, 2000, pp. 120–126.
distributed multi-core approach allows us to complete the
verification of such a system in about 27 hours using 64 [14] K. Nanshi and F. Somenzi, “Guiding simulation with
increasingly refined abstract traces,” in Proc. DAC 2006.
8-core machines, whereas a sequential computation would ACM, 2006, pp. 737–742.
require more than 200 days.
To the best of our knowledge, this is the first time that [15] F. De Paula and A. Hu, “An effective guidance strategy for
a distributed multi-core algorithm for HILS-based SLFV is abstraction-guided simulation,” in Proc. DAC 2007. ACM,
2007, pp. 63–68.
presented.
Acknowledgements: Work partially supported by FP7 [16] U. Stern and D. Dill, “Parallelizing the Murphi Verifier,”
Form. Methods Syst. Des., vol. 18, no. 2, pp. 117–129, 2001.
projects SmartHG (317761) and PAEON (600773). We
thank our reviewers for their valuable comments. [17] J. Barnat, L. Brim, I. Černá, P. Moravec, P. Ročkai, and
P. Šimeček, “Divine: a tool for distributed verification,” in
R EFERENCES Proc. CAV 2006. Springer, 2006, pp. 278–281.
[1] T. Mancini, F. Mari, A. Massini, I. Melatti, F. Merli, and
E. Tronci, “System level formal verification via model check- [18] I. Melatti, R. Palmer, G. Sawaya, Y. Yang, R. Kirby, and
ing driven simulation,” in Proc. CAV 2013, ser. LNCS, vol. G. Gopalakrishnan, “Parallel and distributed model checking
8044. Springer, 2013, pp. 296–312. in eddy,” Int. J. Softw. Tools Technol. Transf., vol. 11, no. 1,
pp. 13–25, 2009.
[2] R. Alur, “Formal verification of hybrid systems,” in Proc.
EMSOFT 2011. ACM, 2011, pp. 273–278. [19] B. Bingham, J. Bingham, F. De Paula, J. Erickson, G. Singh,
and M. Reitblatt, “Industrial strength distributed explicit
[3] F. Cavaliere, F. Mari, I. Melatti, G. Minei, I. Salvo, E. Tronci, state model checking,” in Proc. PDMC-HIBI 2010. IEEE,
G. Verzino, and Y. Yushtein, “Model checking satellite oper- 2010, pp. 28–36.
ational procedures,” in Proc. DASIA 2011, 2011.
[20] G. Holzmann, “Parallelizing the SPIN model checker,” in
[4] G. Della Penna, B. Intrigila, I. Melatti, E. Tronci, and Proc. SPIN 2012. Springer, 2012, pp. 155–171.
M. Venturini Zilli, “Exploiting transition locality in automatic
verification of finite state concurrent systems,” STTT, vol. 6, [21] A. Laarman, J. van de Pol, and M. Weber, “Boosting multi-
no. 4, pp. 320–341, 2004. core reachability performance with shared hash tables,” in
Proc. FMCAD 2010. IEEE, 2010, pp. 247–255.
[5] P. Zuliani, A. Platzer, and E. Clarke, “Bayesian statistical
model checking with application to simulink/stateflow verifi- [22] A. Wijs, “Towards informed swarm verification,” in Proc.
cation,” in Proc. HSCC 2010, 2010, pp. 243–252. NFM 2011, ser. LNCS, vol. 6617. Springer, 2011.
[6] K. Sen, M. Viswanathan, and G. Agha, “On statistical model [23] M. Staats and C. S. Pasareanu, “Parallel symbolic execution
checking of stochastic systems,” in Proc. CAV 2005, ser. for structural test generation,” in Proc. ISSTA 2010. ACM,
LNCS, vol. 3576. Springer, 2005, pp. 266–280. 2010, pp. 183–194.
[7] E. Tronci, G. Della Penna, B. Intrigila, and M. Venturini Zilli, [24] E. Sontag, Mathematical Control Theory: Deterministic
“A probabilistic approach to automatic verification of concur- Finite Dimensional Systems. Springer, 1998.
rent systems,” in Proc. APSEC 2001. IEEE, 2001.
[25] O. Maler and D. Nickovic, “Monitoring temporal proper-
[8] R. Grosu and S. Smolka, “Monte carlo model checking,” in ties of continuous signals,” in Proc. FORMATS 2004 and
Proc. TACAS 2005, ser. LNCS, vol. 3440. Springer, 2005. FTRTFT 2004, ser. LNCS, vol. 3253, 2004, pp. 152–166.
742
Authorized licensed use limited to: Univ of Calif Santa Cruz. Downloaded on October 15,2024 at 21:08:15 UTC from IEEE Xplore. Restrictions apply.