Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Spot
Spot
Commits
49048600
Commit
49048600
authored
Apr 21, 2016
by
Etienne Renault
Browse files
modelcheck: support for twacube
* spot/ltsmin/ltsmin.cc, spot/ltsmin/ltsmin.hh, tests/ltsmin/modelcheck.cc: here.
parent
5003d8d2
Changes
3
Hide whitespace changes
Inline
Side-by-side
spot/ltsmin/ltsmin.cc
View file @
49048600
...
...
@@ -42,6 +42,7 @@
#include
<string.h>
#include
<spot/twacube/cube.hh>
#include
<spot/mc/utils.hh>
#include
<spot/mc/ec.hh>
#include
<bricks/brick-hashset.h>
#include
<bricks/brick-hash.h>
...
...
@@ -2010,6 +2011,20 @@ namespace spot
{
}
std
::
tuple
<
bool
,
std
::
string
,
istats
>
ltsmin_model
::
modelcheck
(
spot
::
kripkecube
<
spot
::
cspins_state
,
spot
::
cspins_iterator
>*
sys
,
spot
::
twacube
*
twa
,
bool
compute_ctrx
)
{
ec_renault13lpar
<
cspins_state
,
cspins_iterator
,
cspins_state_hash
,
cspins_state_equal
>
ec
(
*
sys
,
twa
);
bool
has_ctrx
=
ec
.
run
();
std
::
string
trace
=
""
;
if
(
has_ctrx
&&
compute_ctrx
)
trace
=
ec
.
trace
();
return
std
::
make_tuple
(
has_ctrx
,
trace
,
ec
.
stats
());
}
int
ltsmin_model
::
state_size
()
const
{
return
iface
->
get_state_size
();
...
...
spot/ltsmin/ltsmin.hh
View file @
49048600
...
...
@@ -20,7 +20,10 @@
#pragma once
#include
<spot/kripke/kripke.hh>
#include
<spot/twacube/twacube.hh>
#include
<spot/tl/apcollect.hh>
#include
<tuple>
#include
<spot/mc/intersect.hh>
namespace
spot
{
...
...
@@ -81,6 +84,14 @@ namespace spot
formula
dead
=
formula
::
tt
(),
int
compress
=
0
)
const
;
/// \brief Check for the emptiness between a system and a twa.
/// Return a pair containing a boolean indicating wether a counterexample
/// has been found and a string representing the counterexample if the
/// computation have been required
static
std
::
tuple
<
bool
,
std
::
string
,
istats
>
modelcheck
(
spot
::
kripkecube
<
spot
::
cspins_state
,
spot
::
cspins_iterator
>*
sys
,
spot
::
twacube
*
twa
,
bool
compute_ctrx
=
false
);
/// Number of variables in a state
int
state_size
()
const
;
/// Name of each variable
...
...
tests/ltsmin/modelcheck.cc
View file @
49048600
...
...
@@ -36,6 +36,11 @@
#include
<spot/kripke/kripkegraph.hh>
#include
<spot/twaalgos/hoa.hh>
#include
<thread>
#include
<spot/twacube/twacube.hh>
#include
<spot/twacube_algos/convert.hh>
#include
<spot/mc/ec.hh>
const
char
argp_program_doc
[]
=
"Process model and formula to check wether a "
"model meets a specification.
\v
\
...
...
@@ -61,6 +66,7 @@ struct mc_options_
bool
use_timer
=
false
;
unsigned
compress
=
0
;
bool
kripke_output
=
false
;
unsigned
nb_threads
=
1
;
}
mc_options
;
...
...
@@ -99,6 +105,9 @@ parse_opt_finput(int key, char* arg, struct argp_state*)
case
'm'
:
mc_options
.
model
=
arg
;
break
;
case
'p'
:
mc_options
.
nb_threads
=
to_unsigned
(
arg
);
break
;
case
's'
:
mc_options
.
dead_ap
=
arg
;
break
;
...
...
@@ -127,11 +136,10 @@ static const argp_option options[] =
{
"counterexample"
,
'c'
,
nullptr
,
0
,
"compute an accepting counterexample (if it exists)"
,
0
},
{
"is-empty"
,
'e'
,
nullptr
,
0
,
"check if the model meets its specification using "
"the (sequential) algorithm as described "
"in [Renault et al, LPAR'13]. Return 1 if a counterexample "
"is found."
"check if the model meets its specification. "
"Return 1 if a counterexample is found."
,
0
},
{
"parallel"
,
'p'
,
"INT"
,
0
,
"use INT threads (when possible)"
,
0
},
{
"selfloopize"
,
's'
,
"STRING"
,
0
,
"use STRING as property for marking deadlock "
"states (by default selfloopize is activated with STRING='true')"
,
0
},
...
...
@@ -172,7 +180,7 @@ static int checked_main()
spot
::
atomic_prop_set
ap
;
auto
dict
=
spot
::
make_bdd_dict
();
spot
::
const_kripke_ptr
model
=
nullptr
;
spot
::
const_twa_ptr
prop
=
nullptr
;
spot
::
const_twa_
graph_
ptr
prop
=
nullptr
;
spot
::
const_twa_ptr
product
=
nullptr
;
spot
::
emptiness_check_instantiator_ptr
echeck_inst
=
nullptr
;
int
exit_code
=
0
;
...
...
@@ -256,7 +264,9 @@ static int checked_main()
}
}
if
(
mc_options
.
formula
!=
nullptr
&&
if
(
mc_options
.
nb_threads
==
1
&&
mc_options
.
formula
!=
nullptr
&&
mc_options
.
model
!=
nullptr
)
{
product
=
spot
::
otf_product
(
model
,
prop
);
...
...
@@ -350,6 +360,73 @@ static int checked_main()
}
}
if
(
mc_options
.
nb_threads
!=
1
&&
mc_options
.
formula
!=
nullptr
&&
mc_options
.
model
!=
nullptr
)
{
unsigned
int
hc
=
std
::
thread
::
hardware_concurrency
();
if
(
mc_options
.
nb_threads
>
hc
)
std
::
cerr
<<
"Warning: you require "
<<
mc_options
.
nb_threads
<<
" threads, but your computer only support "
<<
hc
<<
". This could slow down parallel algorithms.
\n
"
;
tm
.
start
(
"twa to twacube"
);
auto
*
propcube
=
spot
::
twa_to_twacube
(
prop
);
tm
.
stop
(
"twa to twacube"
);
tm
.
start
(
"load kripkecube"
);
spot
::
kripkecube
<
spot
::
cspins_state
,
spot
::
cspins_iterator
>*
modelcube
=
nullptr
;
try
{
modelcube
=
spot
::
ltsmin_model
::
load
(
mc_options
.
model
)
.
kripkecube
(
&
ap
,
deadf
,
mc_options
.
compress
);
}
catch
(
std
::
runtime_error
&
e
)
{
std
::
cerr
<<
e
.
what
()
<<
'\n'
;
}
tm
.
stop
(
"load kripkecube"
);
int
memused
=
spot
::
memusage
();
tm
.
start
(
"emptiness check"
);
auto
res
=
spot
::
ltsmin_model
::
modelcheck
(
modelcube
,
propcube
,
mc_options
.
compute_counterexample
);
tm
.
stop
(
"emptiness check"
);
memused
=
spot
::
memusage
()
-
memused
;
if
(
!
modelcube
)
{
delete
propcube
;
exit_code
=
2
;
goto
safe_exit
;
}
// Display statistics
std
::
cout
<<
std
::
get
<
2
>
(
res
).
states
<<
" unique states visited
\n
"
;
std
::
cout
<<
std
::
get
<
2
>
(
res
).
instack_sccs
<<
" strongly connected components in search stack
\n
"
;
std
::
cout
<<
std
::
get
<
2
>
(
res
).
transitions
<<
" transitions explored
\n
"
;
std
::
cout
<<
std
::
get
<
2
>
(
res
).
instack_item
<<
" items max in DFS search stack
\n
"
;
std
::
cout
<<
memused
<<
" pages allocated for emptiness check
\n
"
;
if
(
!
std
::
get
<
0
>
(
res
))
std
::
cout
<<
"no accepting run found"
;
else
if
(
!
mc_options
.
compute_counterexample
)
{
std
::
cout
<<
"an accepting run exists "
<<
"(use -c to print it)"
<<
std
::
endl
;
exit_code
=
1
;
}
else
std
::
cout
<<
"an accepting run exists!
\n
"
<<
std
::
get
<
1
>
(
res
)
<<
std
::
endl
;
delete
modelcube
;
delete
propcube
;
}
safe_exit:
if
(
mc_options
.
use_timer
)
tm
.
print
(
std
::
cout
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment