forked from hklarner/NuSMV-a
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmc.h
515 lines (374 loc) · 14.6 KB
/
mc.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
/* ---------------------------------------------------------------------------
This file is part of the ``mc'' package of NuSMV version 2.
Copyright (C) 1998-2001 by CMU and FBK-irst.
NuSMV version 2 is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
NuSMV version 2 is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
For more information on NuSMV see <http://nusmv.fbk.eu>
or email to <[email protected]>.
Please report bugs to <[email protected]>.
To contact the NuSMV development board, email to <[email protected]>.
-----------------------------------------------------------------------------*/
/*!
\author Marco Roveri, Roberto Cavada
\brief Fair CTL model checking algorithms. External header file.
Fair CTL model checking algorithms. External header file.
*/
#ifndef __NUSMV_CORE_MC_MC_H__
#define __NUSMV_CORE_MC_MC_H__
#include "nusmv/core/utils/utils.h"
#include "nusmv/core/dd/dd.h"
#include "nusmv/core/prop/Prop.h"
#include "nusmv/core/fsm/bdd/BddFsm.h"
#include "nusmv/core/trace/Trace.h"
#include "nusmv/core/opt/opt.h"
/*!
\brief Options for top level function of check_invar command
\sa See the documentation of the single types
*/
typedef struct McCheckInvarOpts_TAG {
Check_Strategy strategy;
FB_Heuristic fb_heuristic;
Bdd2bmc_Heuristic bdd2bmc_heuristic;
int threshold;
int bmc_length;
} McCheckInvarOpts;
void McCheckInvarOpts_init(McCheckInvarOpts* options,
NuSMVEnv_ptr env);
void McCheckInvarOpts_init_invalid(McCheckInvarOpts* options);
boolean McCheckInvarOpts_is_valid(McCheckInvarOpts* options);
/*!
\brief \todo Missing synopsis
\todo Missing description
*/
#define MC_CHECK_INVAR_OPTS_INVALID -1
/*---------------------------------------------------------------------------*/
/* Function prototypes */
/*---------------------------------------------------------------------------*/
/*!
\brief Verifies that M,s0 |= alpha
Verifies that M,s0 |= alpha using the fair CTL model checking.
*/
void Mc_CheckCTLSpec(NuSMVEnv_ptr env, Prop_ptr prop);
/*!
\brief This function checks for SPEC of the form AG
alpha in "context".
The implicit assumption is that "spec" must be an AG
formula (i.e. it must contain only conjunctions and AG's). No attempt
is done to normalize the formula (e.g. push negations). The AG mode
relies on the previous computation and storage of the reachable
state space (<tt>reachable_states_layers</tt>), they are used in
counterexample computation.
\sa check_ctlspec
*/
void Mc_CheckAGOnlySpec(NuSMVEnv_ptr env, Prop_ptr prop);
/*!
\brief Verifies that M,s0 |= AG alpha
Verifies that M,s0 |= AG alpha, with alpha propositional.
Uses strategy read from the option variable.
\sa check_ctlspec check_ltlspec Mc_CheckInvar_With_Strategy
*/
void Mc_CheckInvar(NuSMVEnv_ptr env, Prop_ptr prop);
/*!
\brief Verifies that M,s0 |= AG alpha WITHOUT print results or
counterexamples
Verifies that M,s0 |= AG alpha, with alpha propositional.
Uses strategy read from the option variable.
If opt_counter_examples is setted and trace is not null, then a
trace is stored (and must be released by caller) in trace
parameter location.
The result of model checking is stored in the given property.
\sa check_ctlspec check_ltlspec Mc_CheckInvar_With_Strategy
*/
void Mc_CheckInvarSilently(NuSMVEnv_ptr env,
Prop_ptr prop,
Trace_ptr* trace);
/*!
\brief Verifies that M,s0 |= AG alpha with the specified strategy
Verifies that M,s0 |= AG alpha, with alpha propositional.
Uses strategy given in input
If opt_counter_examples is setted and trace is not null, then a
trace is stored (and must be released by caller) in trace
parameter location.
The result of model checking is stored in the given property.
\sa check_ctlspec check_ltlspec Mc_CheckInvar
*/
void
Mc_CheckInvar_With_Strategy(NuSMVEnv_ptr env,
Prop_ptr prop,
Check_Strategy strategy,
Trace_ptr* trace,
boolean silent);
/*!
\brief Verifies that M,s0 |= AG alpha with the specified strategy
Verifies that M,s0 |= AG alpha, with alpha propositional.
Uses strategy given in input.
If opt_counter_examples is setted and trace is not null, then a
trace is stored (and must be released by caller) in trace
parameter location. A trace is created for variables and defines in 'symbols'.
If trace is not required 'symbols' can be NULL.
The result of model checking is stored in the given property.
\sa check_ctlspec check_ltlspec Mc_CheckInvar
*/
void
Mc_CheckInvar_With_Strategy_And_Symbols(NuSMVEnv_ptr env,
Prop_ptr prop,
Check_Strategy strategy,
Trace_ptr* trace,
boolean silent,
NodeList_ptr symbols);
/*!
\brief Compute quantitative characteristics on the model.
Compute the given quantitative characteristics on the model.
*/
void Mc_CheckCompute(NuSMVEnv_ptr env, Prop_ptr prop);
/*!
\brief Top-level function for mc of PSL properties
The parameters are:
- prop is the PSL property to be checked
\se None
*/
int Mc_check_psl_property(NuSMVEnv_ptr env, Prop_ptr prop);
/*!
\brief Checks whether the language is empty
Checks whether the language is empty. Basically just a
wrapper function that calls the language emptiness algorithm given
by the value of the oreg_justice_emptiness_bdd_algorithm option.
If <tt>allinit</tt> is <tt>true</tt> the check is performed by
verifying whether all initial states are included in the set of fair
states. If it is the case from all initial states there exists a
fair path and thus the language is not empty. On the other hand, if
<tt>allinit</tt> is false, the check is performed by verifying
whether there exists at least one initial state that is also a fair
state. In this case there is an initial state from which it starts a
fair path and thus the lnaguage is not empty. <tt>allinit</tt> is
not supported for forward Emerson-Lei.
Depending on the global option use_reachable_states the set of fair
states computed can be restricted to reachable states only. In this
latter case the check can be further simplified. Forward Emerson-Lei
requires forward_search and use_reachable_states to be enabled.
If <tt>verbose</tt> is true, then some information on the set of
initial states is printed out too. <tt> verbose</tt> is ignored for
forward Emerson-Lei.
\se None
\sa mc_check_language_emptiness_el_bwd,
mc_check_language_emptiness_el_fwd
*/
void Mc_CheckLanguageEmptiness(NuSMVEnv_ptr env,
const BddFsm_ptr fsm,
boolean allinit,
boolean verbose);
/* mcTrace.c */
/*!
\brief Creates a trace out of a < S (i, S)* > bdd list
Creates a trace out of a < S (i, S)* > bdd list.
The built trace is non-volatile. For more control over
the built trace, please see
Mc_fill_trace_from_bdd_state_input_list
\se none
\sa Trace_create, Bmc_create_trace_from_cnf_model,
Mc_fill_trace_from_bdd_state_input_list
*/
Trace_ptr
Mc_create_trace_from_bdd_state_input_list(const BddEnc_ptr bdd_enc,
const NodeList_ptr symbols,
const char* desc,
const TraceType type,
node_ptr path);
/*!
\brief Fills the given trace out of a < S (i, S)* > bdd list
Fills the given trace out of a < S (i, S)* > bdd list.
The returned trace is the given one, filled with all
steps. The given trace MUST be empty. Path must be non-Nil
\se none
\sa Trace_create, Bmc_fill_trace_from_cnf_model
*/
Trace_ptr
Mc_fill_trace_from_bdd_state_input_list(const BddEnc_ptr bdd_enc,
Trace_ptr trace,
node_ptr path);
/*!
\brief Populates a trace step with state assignments
\se none
*/
void
Mc_trace_step_put_state_from_bdd(Trace_ptr trace, TraceIter step,
BddEnc_ptr bdd_enc, bdd_ptr bdd);
/*!
\brief Populates a trace step with input assignments
\se none
*/
void
Mc_trace_step_put_input_from_bdd(Trace_ptr trace, TraceIter step,
BddEnc_ptr bdd_enc, bdd_ptr bdd);
/*!
\brief Prints out a CTL specification
Prints out a CTL specification
*/
void print_spec(OStream_ptr file, Prop_ptr prop, Prop_PrintFmt fmt);
/*!
\brief Print an invariant specification
Print an invariant specification
*/
void print_invar(OStream_ptr file, Prop_ptr n, Prop_PrintFmt fmt);
/*!
\brief Prints out a COMPUTE specification
Prints out a COMPUTE specification
*/
void print_compute(OStream_ptr file, Prop_ptr, Prop_PrintFmt fmt);
/*!
\brief Set of states satisfying <i>EX(g)</i>.
Computes the set of states satisfying <i>EX(g)</i>.
\sa eu ef eg
*/
BddStates ex(BddFsm_ptr, BddStates);
/*!
\brief Set of states satisfying <i>EF(g)</i>.
Computes the set of states satisfying <i>EF(g)</i>.
\sa eu ex
*/
BddStates ef(BddFsm_ptr, BddStates);
/*!
\brief Set of states satisfying <i>EF(g)</i>.
Computes the set of states satisfying <i>EG(g)</i>.
\sa eu ex
*/
BddStates eg(BddFsm_ptr, BddStates);
/*!
\brief Set of states satisfying <i>E\[ f U g \]</i>.
Computes the set of states satisfying <i>E\[ f U g \]</i>.
\sa ebu
*/
BddStates eu(BddFsm_ptr, BddStates, BddStates);
/*!
\brief Set of states satisfying <i>A\[f U g\]</i>.
Computes the set of states satisfying <i>A\[f U g\]</i>.
\sa ax af ex ef
*/
BddStates au(BddFsm_ptr, BddStates, BddStates);
/*!
\brief Set of states satisfying <i>E\[f U^{inf..sup} g\]</i>.
Computes the set of states satisfying
<i>E\[f U^{inf..sup} g\]</i></i>.
\sa eu
*/
BddStates ebu(BddFsm_ptr, BddStates, BddStates, int, int);
/*!
\brief Set of states satisfying <i>EF^{inf..sup}(g)</i>.
Computes the set of states satisfying
<i>EF^{inf..sup}(g)</i>.
\sa ef
*/
BddStates ebf(BddFsm_ptr, BddStates, int, int);
/*!
\brief Set of states satisfying <i>EG^{inf..sup}(g)</i>.
Computes the set of states satisfying
<i>EG^{inf..sup}(g)</i>.
\sa eg
*/
BddStates ebg(BddFsm_ptr, BddStates, int, int);
/*!
\brief Set of states satisfying <i>A\[f U^{inf..sup} g\]</i>.
Computes the set of states satisfying
<i>A\[f U^{inf..sup} g\]</i>.
\sa au
*/
BddStates abu(BddFsm_ptr, BddStates, BddStates, int, int);
/*!
\brief Computes the minimum length of the shortest path
from <i>f</i> to <i>g</i>.
This function computes the minimum length of the
shortest path from <i>f</i> to <i>g</i>.<br>
Starts from <i>f</i> and proceeds forward until finds a state in <i>g</i>.
Notice that this function works correctly only if <code>-f</code>
option is used.
\sa maxu
*/
int minu(BddFsm_ptr, bdd_ptr, bdd_ptr);
/*!
\brief This function computes the maximum length of the
shortest path from <i>f</i> to <i>g</i>.
This function computes the maximum length of the
shortest path from <i>f</i> to <i>g</i>. It starts from !g and
proceeds backward until no states in <i>f</i> can be found. In other
words, it looks for the maximum length of <i>f->AG!g</i>.
Notice that this function works correctly only if <code>-f</code>
option is used.
Returns -1 if infinity, -2 if undefined
\sa minu
*/
int maxu(BddFsm_ptr, bdd_ptr, bdd_ptr);
/*!
\brief Counterexamples and witnesses generator.
This function takes as input a CTL formula and
returns a witness showing how the given formula does not hold. The
result consists of a list of states (i.e. an execution trace) that
leads to a state in which the given formula does not hold.
\sa explain_recur ex_explain eu_explain eg_explain
ebg_explain ebu_explain
*/
node_ptr explain(BddFsm_ptr, BddEnc_ptr, node_ptr,
node_ptr, node_ptr);
/*!
\brief Compile a CTL formula into BDD and performs
Model Checking.
Compile a CTL formula into BDD and performs
Model Checking.
\sa eval_compute
*/
bdd_ptr
eval_ctl_spec(BddFsm_ptr, BddEnc_ptr enc, node_ptr, node_ptr);
/*!
\brief This function takes a list of formulas, and
returns the list of their BDDs.
This function takes as input a list of formulae,
and return as output the list of the corresponding BDDs, obtained by
evaluating each formula in the given context.
*/
node_ptr
eval_formula_list(BddFsm_ptr, BddEnc_ptr enc, node_ptr, node_ptr);
/*!
\brief Computes shortest and longest length of the path
between two set of states.
This function performs the invocation of the
routines to compute the length of the shortest and longest execution
path between two set of states s_1 and s_2.
\sa eval_ctl_spec
*/
int
eval_compute(BddFsm_ptr, BddEnc_ptr enc, node_ptr, node_ptr);
/*!
\brief Frees a list of BDD as generated by eval_formula_list
Frees a list of BDD as generated by eval_formula_list
\sa eval_formula_list
*/
void free_formula_list(DDMgr_ptr , node_ptr);
/* directly called by commands */
/*!
\brief Performs fair bdd-based PSL model checking.
Performs fair bdd-based PSL model checking.
*/
int Mc_check_psl_spec(const NuSMVEnv_ptr env, const int prop_no);
/*!
\brief Performs model checking of invariants
*/
int Mc_check_invar(NuSMVEnv_ptr env,
Prop_ptr prop,
McCheckInvarOpts* options);
/* Called by SA */
/*!
\brief This function constructs a counterexample
starting from state target_state
Compute a counterexample starting from a given state.
Returned counterexample is a sequence of "state (input, state)*"
*/
node_ptr make_AG_counterexample(BddFsm_ptr, BddStates);
#endif /* __NUSMV_CORE_MC_MC_H__ */