modelcheck: support for twacube
* spot/ltsmin/ltsmin.cc, spot/ltsmin/ltsmin.hh, tests/ltsmin/modelcheck.cc: here.
This commit is contained in:
parent
94f7c58f44
commit
9799f2884e
3 changed files with 109 additions and 6 deletions
|
|
@ -42,6 +42,7 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <spot/twacube/cube.hh>
|
#include <spot/twacube/cube.hh>
|
||||||
#include <spot/mc/utils.hh>
|
#include <spot/mc/utils.hh>
|
||||||
|
#include <spot/mc/ec.hh>
|
||||||
#include <bricks/brick-hashset.h>
|
#include <bricks/brick-hashset.h>
|
||||||
#include <bricks/brick-hash.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
|
int ltsmin_model::state_size() const
|
||||||
{
|
{
|
||||||
return iface->get_state_size();
|
return iface->get_state_size();
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,10 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <spot/kripke/kripke.hh>
|
#include <spot/kripke/kripke.hh>
|
||||||
|
#include <spot/twacube/twacube.hh>
|
||||||
#include <spot/tl/apcollect.hh>
|
#include <spot/tl/apcollect.hh>
|
||||||
|
#include <tuple>
|
||||||
|
#include <spot/mc/intersect.hh>
|
||||||
|
|
||||||
namespace spot
|
namespace spot
|
||||||
{
|
{
|
||||||
|
|
@ -81,6 +84,14 @@ namespace spot
|
||||||
formula dead = formula::tt(),
|
formula dead = formula::tt(),
|
||||||
int compress = 0) const;
|
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
|
/// Number of variables in a state
|
||||||
int state_size() const;
|
int state_size() const;
|
||||||
/// Name of each variable
|
/// Name of each variable
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,11 @@
|
||||||
#include <spot/kripke/kripkegraph.hh>
|
#include <spot/kripke/kripkegraph.hh>
|
||||||
#include <spot/twaalgos/hoa.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[] =
|
const char argp_program_doc[] =
|
||||||
"Process model and formula to check wether a "
|
"Process model and formula to check wether a "
|
||||||
"model meets a specification.\v\
|
"model meets a specification.\v\
|
||||||
|
|
@ -61,6 +66,7 @@ struct mc_options_
|
||||||
bool use_timer = false;
|
bool use_timer = false;
|
||||||
unsigned compress = 0;
|
unsigned compress = 0;
|
||||||
bool kripke_output = false;
|
bool kripke_output = false;
|
||||||
|
unsigned nb_threads = 1;
|
||||||
} mc_options;
|
} mc_options;
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -99,6 +105,9 @@ parse_opt_finput(int key, char* arg, struct argp_state*)
|
||||||
case 'm':
|
case 'm':
|
||||||
mc_options.model = arg;
|
mc_options.model = arg;
|
||||||
break;
|
break;
|
||||||
|
case 'p':
|
||||||
|
mc_options.nb_threads = to_unsigned(arg);
|
||||||
|
break;
|
||||||
case 's':
|
case 's':
|
||||||
mc_options.dead_ap = arg;
|
mc_options.dead_ap = arg;
|
||||||
break;
|
break;
|
||||||
|
|
@ -127,11 +136,10 @@ static const argp_option options[] =
|
||||||
{ "counterexample", 'c', nullptr, 0,
|
{ "counterexample", 'c', nullptr, 0,
|
||||||
"compute an accepting counterexample (if it exists)", 0 },
|
"compute an accepting counterexample (if it exists)", 0 },
|
||||||
{ "is-empty", 'e', nullptr, 0,
|
{ "is-empty", 'e', nullptr, 0,
|
||||||
"check if the model meets its specification using "
|
"check if the model meets its specification. "
|
||||||
"the (sequential) algorithm as described "
|
"Return 1 if a counterexample is found."
|
||||||
"in [Renault et al, LPAR'13]. Return 1 if a counterexample "
|
|
||||||
"is found."
|
|
||||||
, 0 },
|
, 0 },
|
||||||
|
{ "parallel", 'p', "INT", 0, "use INT threads (when possible)", 0 },
|
||||||
{ "selfloopize", 's', "STRING", 0,
|
{ "selfloopize", 's', "STRING", 0,
|
||||||
"use STRING as property for marking deadlock "
|
"use STRING as property for marking deadlock "
|
||||||
"states (by default selfloopize is activated with STRING='true')", 0 },
|
"states (by default selfloopize is activated with STRING='true')", 0 },
|
||||||
|
|
@ -172,7 +180,7 @@ static int checked_main()
|
||||||
spot::atomic_prop_set ap;
|
spot::atomic_prop_set ap;
|
||||||
auto dict = spot::make_bdd_dict();
|
auto dict = spot::make_bdd_dict();
|
||||||
spot::const_kripke_ptr model = nullptr;
|
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::const_twa_ptr product = nullptr;
|
||||||
spot::emptiness_check_instantiator_ptr echeck_inst = nullptr;
|
spot::emptiness_check_instantiator_ptr echeck_inst = nullptr;
|
||||||
int exit_code = 0;
|
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)
|
mc_options.model != nullptr)
|
||||||
{
|
{
|
||||||
product = spot::otf_product(model, prop);
|
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:
|
safe_exit:
|
||||||
if (mc_options.use_timer)
|
if (mc_options.use_timer)
|
||||||
tm.print(std::cout);
|
tm.print(std::cout);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue