ltsmin: implement a two-step loading
* spot/ltsmin/ltsmin.cc, spot/ltsmin/ltsmin.hh: Split load_ltsmin() into ltsmin_model::load() and ltsmin_model::kripke(). Report errors using exceptions instead of on std::cerr. * python/spot/ltsmin.i: Deal with exceptions. * tests/ltsmin/modelcheck.cc, tests/python/ltsmin.ipynb: Adjust.
This commit is contained in:
parent
84031d2ae1
commit
907b72fbfb
6 changed files with 230 additions and 191 deletions
10
NEWS
10
NEWS
|
|
@ -5,6 +5,16 @@ New in spot 1.99.7a (not yet released)
|
||||||
* Building products with different dictionaries now raise an
|
* Building products with different dictionaries now raise an
|
||||||
exception instead of using an assertion that could be disabled.
|
exception instead of using an assertion that could be disabled.
|
||||||
|
|
||||||
|
* The load_ltsmin() function has been split in two. Now you should
|
||||||
|
first call ltsmin_model::load(filename) to create an ltlmin_model,
|
||||||
|
and then call the ltsmin_model::kripke(...) method to create an
|
||||||
|
automaton that can be iterated on the fly.
|
||||||
|
|
||||||
|
Python:
|
||||||
|
|
||||||
|
* The ltsmin interface has been binded in Python. See
|
||||||
|
https://spot.lrde.epita.fr/ipynb/ltsmin.html for a short example.
|
||||||
|
|
||||||
Documentation:
|
Documentation:
|
||||||
|
|
||||||
* There is a new page giving informal illustrations (and extra
|
* There is a new page giving informal illustrations (and extra
|
||||||
|
|
|
||||||
|
|
@ -47,20 +47,36 @@ using namespace spot;
|
||||||
%import(module="spot.impl") <spot/kripke/fairkripke.hh>
|
%import(module="spot.impl") <spot/kripke/fairkripke.hh>
|
||||||
%import(module="spot.impl") <spot/kripke/kripke.hh>
|
%import(module="spot.impl") <spot/kripke/kripke.hh>
|
||||||
|
|
||||||
|
%exception {
|
||||||
|
try {
|
||||||
|
$action
|
||||||
|
}
|
||||||
|
catch (const std::runtime_error& e)
|
||||||
|
{
|
||||||
|
SWIG_exception(SWIG_RuntimeError, e.what());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
namespace std {
|
namespace std {
|
||||||
%template(atomic_prop_set) set<spot::formula>;
|
%template(atomic_prop_set) set<spot::formula>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
%rename(model) spot::ltsmin_model;
|
||||||
|
%rename(kripke_raw) spot::ltsmin_model::kripke;
|
||||||
%include <spot/ltsmin/ltsmin.hh>
|
%include <spot/ltsmin/ltsmin.hh>
|
||||||
|
|
||||||
%pythoncode %{
|
%pythoncode %{
|
||||||
import spot
|
import spot
|
||||||
|
|
||||||
def load(filename, ap_set, dict=spot._bdd_dict,
|
def load(filename):
|
||||||
dead=spot.formula_ap('dead'),
|
return model.load(filename)
|
||||||
compress=2, debug=False):
|
|
||||||
|
def _kripke(self, ap_set, dict=spot._bdd_dict,
|
||||||
|
dead=spot.formula_ap('dead'),
|
||||||
|
compress=2):
|
||||||
s = spot.atomic_prop_set()
|
s = spot.atomic_prop_set()
|
||||||
for ap in ap_set:
|
for ap in ap_set:
|
||||||
s.insert(spot.formula_ap(ap))
|
s.insert(spot.formula_ap(ap))
|
||||||
return load_ltsmin(filename, dict, s, dead, compress, debug)
|
return self.kripke_raw(s, dict, dead, compress)
|
||||||
|
model.kripke = _kripke
|
||||||
%}
|
%}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
// -*- coding: utf-8 -*-
|
// -*- coding: utf-8 -*-
|
||||||
// Copyright (C) 2011, 2012, 2014, 2015 Laboratoire de Recherche et
|
// Copyright (C) 2011, 2012, 2014, 2015, 2016 Laboratoire de Recherche et
|
||||||
// Développement de l'Epita (LRDE)
|
// Développement de l'Epita (LRDE)
|
||||||
//
|
//
|
||||||
// This file is part of Spot, a model checking library.
|
// This file is part of Spot, a model checking library.
|
||||||
|
|
@ -53,21 +53,33 @@ namespace spot
|
||||||
typedef void (*TransitionCB)(void *ctx,
|
typedef void (*TransitionCB)(void *ctx,
|
||||||
transition_info_t *transition_info,
|
transition_info_t *transition_info,
|
||||||
int *dst);
|
int *dst);
|
||||||
|
}
|
||||||
|
|
||||||
struct spins_interface
|
struct spins_interface
|
||||||
|
{
|
||||||
|
lt_dlhandle handle; // handle to the dynamic library
|
||||||
|
void (*get_initial_state)(void *to);
|
||||||
|
int (*have_property)();
|
||||||
|
int (*get_successors)(void* m, int *in, TransitionCB, void *arg);
|
||||||
|
int (*get_state_size)();
|
||||||
|
const char* (*get_state_variable_name)(int var);
|
||||||
|
int (*get_state_variable_type)(int var);
|
||||||
|
int (*get_type_count)();
|
||||||
|
const char* (*get_type_name)(int type);
|
||||||
|
int (*get_type_value_count)(int type);
|
||||||
|
const char* (*get_type_value_name)(int type, int value);
|
||||||
|
|
||||||
|
~spins_interface()
|
||||||
{
|
{
|
||||||
lt_dlhandle handle; // handle to the dynamic library
|
if (handle)
|
||||||
void (*get_initial_state)(void *to);
|
lt_dlclose(handle);
|
||||||
int (*have_property)();
|
lt_dlexit();
|
||||||
int (*get_successors)(void* m, int *in, TransitionCB, void *arg);
|
}
|
||||||
int (*get_state_size)();
|
};
|
||||||
const char* (*get_state_variable_name)(int var);
|
|
||||||
int (*get_state_variable_type)(int var);
|
namespace
|
||||||
int (*get_type_count)();
|
{
|
||||||
const char* (*get_type_name)(int type);
|
typedef std::shared_ptr<const spins_interface> spins_interface_ptr;
|
||||||
int (*get_type_value_count)(int type);
|
|
||||||
const char* (*get_type_value_name)(int type, int value);
|
|
||||||
};
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
// STATE
|
// STATE
|
||||||
|
|
@ -322,14 +334,15 @@ namespace spot
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
int
|
void
|
||||||
convert_aps(const atomic_prop_set* aps,
|
convert_aps(const atomic_prop_set* aps,
|
||||||
const spins_interface* d,
|
spins_interface_ptr d,
|
||||||
bdd_dict_ptr dict,
|
bdd_dict_ptr dict,
|
||||||
formula dead,
|
formula dead,
|
||||||
prop_set& out)
|
prop_set& out)
|
||||||
{
|
{
|
||||||
int errors = 0;
|
int errors = 0;
|
||||||
|
std::ostringstream err;
|
||||||
|
|
||||||
int state_size = d->get_state_size();
|
int state_size = d->get_state_size();
|
||||||
typedef std::map<std::string, var_info> val_map_t;
|
typedef std::map<std::string, var_info> val_map_t;
|
||||||
|
|
@ -367,8 +380,7 @@ namespace spot
|
||||||
++s;
|
++s;
|
||||||
if (!*s)
|
if (!*s)
|
||||||
{
|
{
|
||||||
std::cerr << "Proposition `" << str
|
err << "Proposition `" << str << "' cannot be parsed.\n";
|
||||||
<< "' cannot be parsed." << std::endl;
|
|
||||||
++errors;
|
++errors;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
@ -393,8 +405,7 @@ namespace spot
|
||||||
|
|
||||||
if (name == name_p)
|
if (name == name_p)
|
||||||
{
|
{
|
||||||
std::cerr << "Proposition `" << str
|
err << "Proposition `" << str << "' cannot be parsed.\n";
|
||||||
<< "' cannot be parsed." << std::endl;
|
|
||||||
free(name);
|
free(name);
|
||||||
++errors;
|
++errors;
|
||||||
continue;
|
continue;
|
||||||
|
|
@ -415,9 +426,9 @@ namespace spot
|
||||||
|
|
||||||
if (ni == val_map.end())
|
if (ni == val_map.end())
|
||||||
{
|
{
|
||||||
std::cerr << "No variable `" << name
|
err << "No variable `" << name
|
||||||
<< "' found in model (for proposition `"
|
<< "' found in model (for proposition `"
|
||||||
<< str << "')." << std::endl;
|
<< str << "').\n";
|
||||||
free(name);
|
free(name);
|
||||||
++errors;
|
++errors;
|
||||||
continue;
|
continue;
|
||||||
|
|
@ -429,14 +440,12 @@ namespace spot
|
||||||
enum_map_t::const_iterator ei = enum_map[type_num].find(lastdot);
|
enum_map_t::const_iterator ei = enum_map[type_num].find(lastdot);
|
||||||
if (ei == enum_map[type_num].end())
|
if (ei == enum_map[type_num].end())
|
||||||
{
|
{
|
||||||
std::cerr << "No state `" << lastdot
|
err << "No state `" << lastdot << "' known for variable `"
|
||||||
<< "' known for variable `"
|
<< name << "'.\n";
|
||||||
<< name << "'." << std::endl;
|
err << "Possible states are:";
|
||||||
std::cerr << "Possible states are:";
|
for (auto& ej: enum_map[type_num])
|
||||||
for (ei = enum_map[type_num].begin();
|
err << ' ' << ej.first;
|
||||||
ei != enum_map[type_num].end(); ++ei)
|
err << '\n';
|
||||||
std::cerr << ' ' << ei->first;
|
|
||||||
std::cerr << '\n';
|
|
||||||
|
|
||||||
free(name);
|
free(name);
|
||||||
++errors;
|
++errors;
|
||||||
|
|
@ -446,16 +455,16 @@ namespace spot
|
||||||
// At this point, *s should be 0.
|
// At this point, *s should be 0.
|
||||||
if (*s)
|
if (*s)
|
||||||
{
|
{
|
||||||
std::cerr << "Trailing garbage `" << s
|
err << "Trailing garbage `" << s
|
||||||
<< "' at end of proposition `"
|
<< "' at end of proposition `"
|
||||||
<< str << "'." << std::endl;
|
<< str << "'.\n";
|
||||||
free(name);
|
free(name);
|
||||||
++errors;
|
++errors;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Record that X.Y must be equal to Z.
|
// Record that X.Y must be equal to Z.
|
||||||
int v = dict->register_proposition(*ap, d);
|
int v = dict->register_proposition(*ap, d.get());
|
||||||
one_prop p = { ni->second.num, OP_EQ, ei->second, v };
|
one_prop p = { ni->second.num, OP_EQ, ei->second, v };
|
||||||
out.push_back(p);
|
out.push_back(p);
|
||||||
free(name);
|
free(name);
|
||||||
|
|
@ -515,9 +524,9 @@ namespace spot
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
report_error:
|
report_error:
|
||||||
std::cerr << "Unexpected `" << s
|
err << "Unexpected `" << s
|
||||||
<< "' while parsing atomic proposition `" << str
|
<< "' while parsing atomic proposition `" << str
|
||||||
<< "'." << std::endl;
|
<< "'.\n";
|
||||||
++errors;
|
++errors;
|
||||||
free(name);
|
free(name);
|
||||||
continue;
|
continue;
|
||||||
|
|
@ -534,8 +543,7 @@ namespace spot
|
||||||
val = strtol(s, &s_end, 10);
|
val = strtol(s, &s_end, 10);
|
||||||
if (s == s_end)
|
if (s == s_end)
|
||||||
{
|
{
|
||||||
std::cerr << "Failed to parse `" << s
|
err << "Failed to parse `" << s << "' as an integer.\n";
|
||||||
<< "' as an integer." << std::endl;
|
|
||||||
++errors;
|
++errors;
|
||||||
free(name);
|
free(name);
|
||||||
continue;
|
continue;
|
||||||
|
|
@ -555,14 +563,13 @@ namespace spot
|
||||||
enum_map_t::const_iterator ei = enum_map[type_num].find(st);
|
enum_map_t::const_iterator ei = enum_map[type_num].find(st);
|
||||||
if (ei == enum_map[type_num].end())
|
if (ei == enum_map[type_num].end())
|
||||||
{
|
{
|
||||||
std::cerr << "No state `" << st
|
err << "No state `" << st << "' known for variable `"
|
||||||
<< "' known for variable `"
|
<< name << "'.\n";
|
||||||
<< name << "'." << std::endl;
|
err << "Possible states are:";
|
||||||
std::cerr << "Possible states are:";
|
|
||||||
for (ei = enum_map[type_num].begin();
|
for (ei = enum_map[type_num].begin();
|
||||||
ei != enum_map[type_num].end(); ++ei)
|
ei != enum_map[type_num].end(); ++ei)
|
||||||
std::cerr << ' ' << ei->first;
|
err << ' ' << ei->first;
|
||||||
std::cerr << '\n';
|
err << '\n';
|
||||||
|
|
||||||
free(name);
|
free(name);
|
||||||
++errors;
|
++errors;
|
||||||
|
|
@ -578,11 +585,11 @@ namespace spot
|
||||||
++s;
|
++s;
|
||||||
if (*s)
|
if (*s)
|
||||||
{
|
{
|
||||||
std::cerr << "Unexpected `" << s
|
err << "Unexpected `" << s
|
||||||
<< "' while parsing atomic proposition `" << str
|
<< "' while parsing atomic proposition `" << str
|
||||||
<< "'." << std::endl;
|
<< "'.\n";
|
||||||
++errors;
|
++errors;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -591,7 +598,8 @@ namespace spot
|
||||||
out.push_back(p);
|
out.push_back(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
return errors;
|
if (errors)
|
||||||
|
throw std::runtime_error(err.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
|
|
@ -601,7 +609,7 @@ namespace spot
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
spins_kripke(const spins_interface* d, const bdd_dict_ptr& dict,
|
spins_kripke(spins_interface_ptr d, const bdd_dict_ptr& dict,
|
||||||
const spot::prop_set* ps, formula dead,
|
const spot::prop_set* ps, formula dead,
|
||||||
int compress)
|
int compress)
|
||||||
: kripke(dict),
|
: kripke(dict),
|
||||||
|
|
@ -679,13 +687,9 @@ namespace spot
|
||||||
delete[] uncompressed_;
|
delete[] uncompressed_;
|
||||||
delete[] compressed_;
|
delete[] compressed_;
|
||||||
}
|
}
|
||||||
lt_dlclose(d_->handle);
|
dict_->unregister_all_my_variables(d_.get());
|
||||||
|
|
||||||
dict_->unregister_all_my_variables(d_);
|
|
||||||
|
|
||||||
delete d_;
|
|
||||||
delete ps_;
|
delete ps_;
|
||||||
lt_dlexit();
|
|
||||||
|
|
||||||
if (state_condition_last_state_)
|
if (state_condition_last_state_)
|
||||||
state_condition_last_state_->destroy();
|
state_condition_last_state_->destroy();
|
||||||
|
|
@ -918,7 +922,7 @@ namespace spot
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const spins_interface* d_;
|
spins_interface_ptr d_;
|
||||||
int state_size_;
|
int state_size_;
|
||||||
bdd_dict_ptr dict_;
|
bdd_dict_ptr dict_;
|
||||||
const char** vname_;
|
const char** vname_;
|
||||||
|
|
@ -950,8 +954,8 @@ namespace spot
|
||||||
|
|
||||||
// Call spins to compile "foo.prom" as "foo.prom.spins" if the latter
|
// Call spins to compile "foo.prom" as "foo.prom.spins" if the latter
|
||||||
// does not exist already or is older.
|
// does not exist already or is older.
|
||||||
static bool
|
static void
|
||||||
compile_model(std::string& filename, std::string& ext, bool verbose)
|
compile_model(std::string& filename, std::string& ext)
|
||||||
{
|
{
|
||||||
std::string command;
|
std::string command;
|
||||||
std::string compiled_ext;
|
std::string compiled_ext;
|
||||||
|
|
@ -968,22 +972,14 @@ namespace spot
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (verbose)
|
throw std::runtime_error(std::string("Unknown extension '")
|
||||||
std::cerr << "Unknown extension `" << ext
|
+ ext + "'. Use '.prom', '.pm', '.pml', "
|
||||||
<< ("'. Use `.prom', `.pm', `.pml', `.dve', `.dve2C' or"
|
"'.dve', '.dve2C', or '.prom.spins'.");
|
||||||
"`.prom.spins'.") << std::endl;
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct stat s;
|
struct stat s;
|
||||||
if (stat(filename.c_str(), &s) != 0)
|
if (stat(filename.c_str(), &s) != 0)
|
||||||
{
|
throw std::runtime_error(std::string("Cannot open ") + filename);
|
||||||
if (verbose)
|
|
||||||
{
|
|
||||||
std::cerr << "Cannot open " << filename << std::endl;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string old = filename;
|
std::string old = filename;
|
||||||
filename += compiled_ext;
|
filename += compiled_ext;
|
||||||
|
|
@ -998,26 +994,19 @@ namespace spot
|
||||||
if (stat(filename.c_str(), &d) == 0)
|
if (stat(filename.c_str(), &d) == 0)
|
||||||
if (s.st_mtime < d.st_mtime)
|
if (s.st_mtime < d.st_mtime)
|
||||||
// The .spins or .dve2C is up-to-date, no need to recompile it.
|
// The .spins or .dve2C is up-to-date, no need to recompile it.
|
||||||
return false;
|
return;
|
||||||
|
|
||||||
int res = system(command.c_str());
|
int res = system(command.c_str());
|
||||||
if (res)
|
if (res)
|
||||||
{
|
throw std::runtime_error(std::string("Execution of '")
|
||||||
if (verbose)
|
+ command.c_str() + "' returned exit code "
|
||||||
std::cerr << "Execution of `" << command.c_str()
|
+ std::to_string(WEXITSTATUS(res)));
|
||||||
<< "' returned exit code " << WEXITSTATUS(res)
|
|
||||||
<< ".\n";
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
kripke_ptr
|
ltsmin_model
|
||||||
load_ltsmin(const std::string& file_arg, const bdd_dict_ptr& dict,
|
ltsmin_model::load(const std::string& file_arg)
|
||||||
const atomic_prop_set* to_observe,
|
|
||||||
const formula dead, int compress, bool verbose)
|
|
||||||
{
|
{
|
||||||
std::string file;
|
std::string file;
|
||||||
if (file_arg.find_first_of("/\\") != std::string::npos)
|
if (file_arg.find_first_of("/\\") != std::string::npos)
|
||||||
|
|
@ -1027,33 +1016,20 @@ namespace spot
|
||||||
|
|
||||||
std::string ext = file.substr(file.find_last_of("."));
|
std::string ext = file.substr(file.find_last_of("."));
|
||||||
if (ext != ".spins" && ext != ".dve2C")
|
if (ext != ".spins" && ext != ".dve2C")
|
||||||
{
|
compile_model(file, ext);
|
||||||
if (compile_model(file, ext, verbose))
|
|
||||||
{
|
|
||||||
if (verbose)
|
|
||||||
std::cerr << "Failed to compile `" << file_arg
|
|
||||||
<< "'." << std::endl;
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (lt_dlinit())
|
if (lt_dlinit())
|
||||||
{
|
throw std::runtime_error("Failed to initialize libltldl.");
|
||||||
if (verbose)
|
|
||||||
std::cerr << "Failed to initialize libltdl." << std::endl;
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
lt_dlhandle h = lt_dlopen(file.c_str());
|
lt_dlhandle h = lt_dlopen(file.c_str());
|
||||||
if (!h)
|
if (!h)
|
||||||
{
|
{
|
||||||
if (verbose)
|
|
||||||
std::cerr << "Failed to load `" << file << "'." << std::endl;
|
|
||||||
lt_dlexit();
|
lt_dlexit();
|
||||||
return nullptr;
|
throw std::runtime_error(std::string("Failed to load '")
|
||||||
|
+ file + "'.");
|
||||||
}
|
}
|
||||||
|
|
||||||
spins_interface* d = new spins_interface;
|
auto d = std::make_shared<spins_interface>();
|
||||||
d->handle = h;
|
d->handle = h;
|
||||||
|
|
||||||
// SpinS interface.
|
// SpinS interface.
|
||||||
|
|
@ -1112,36 +1088,38 @@ namespace spot
|
||||||
&& d->get_type_name
|
&& d->get_type_name
|
||||||
&& d->get_type_value_count
|
&& d->get_type_value_count
|
||||||
&& d->get_type_value_name))
|
&& d->get_type_value_name))
|
||||||
{
|
throw std::runtime_error(std::string("Failed resolve some symbol"
|
||||||
if (verbose)
|
"while loading '") + file + "'.");
|
||||||
std::cerr << "Failed to resolve some symbol while loading `"
|
|
||||||
<< file << "'\n";
|
|
||||||
delete d;
|
|
||||||
lt_dlexit();
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (d->have_property && d->have_property())
|
if (d->have_property && d->have_property())
|
||||||
{
|
throw std::runtime_error("Models with embedded properties "
|
||||||
if (verbose)
|
"are not supported.");
|
||||||
std::cerr << "Model with an embedded property are not supported."
|
|
||||||
<< std::endl;
|
|
||||||
delete d;
|
|
||||||
lt_dlexit();
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
return { d };
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
kripke_ptr
|
||||||
|
ltsmin_model::kripke(const atomic_prop_set* to_observe,
|
||||||
|
bdd_dict_ptr dict,
|
||||||
|
const formula dead, int compress) const
|
||||||
|
{
|
||||||
spot::prop_set* ps = new spot::prop_set;
|
spot::prop_set* ps = new spot::prop_set;
|
||||||
int errors = convert_aps(to_observe, d, dict, dead, *ps);
|
try
|
||||||
if (errors)
|
{
|
||||||
|
convert_aps(to_observe, iface, dict, dead, *ps);
|
||||||
|
}
|
||||||
|
catch (std::runtime_error)
|
||||||
{
|
{
|
||||||
delete ps;
|
delete ps;
|
||||||
dict->unregister_all_my_variables(d);
|
dict->unregister_all_my_variables(iface.get());
|
||||||
delete d;
|
throw;
|
||||||
lt_dlexit();
|
|
||||||
return nullptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return std::make_shared<spins_kripke>(d, dict, ps, dead, compress);
|
return std::make_shared<spins_kripke>(iface, dict, ps, dead, compress);
|
||||||
|
}
|
||||||
|
|
||||||
|
ltsmin_model::~ltsmin_model()
|
||||||
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
// -*- coding: utf-8 -*-
|
// -*- coding: utf-8 -*-
|
||||||
// Copyright (C) 2011, 2013, 2014, 2015 Laboratoire de Recherche et
|
// Copyright (C) 2011, 2013, 2014, 2015, 2016 Laboratoire de Recherche et
|
||||||
// Developpement de l'Epita (LRDE)
|
// Developpement de l'Epita (LRDE)
|
||||||
//
|
//
|
||||||
// This file is part of Spot, a model checking library.
|
// This file is part of Spot, a model checking library.
|
||||||
|
|
@ -24,40 +24,56 @@
|
||||||
|
|
||||||
namespace spot
|
namespace spot
|
||||||
{
|
{
|
||||||
|
struct spins_interface;
|
||||||
|
|
||||||
// \brief Load an ltsmin model, either from divine or promela.
|
class SPOT_API ltsmin_model final
|
||||||
//
|
{
|
||||||
// The filename given can be either a *.pm/*.pml/*.prom promela
|
public:
|
||||||
// source or a *.spins dynamic library compiled with "spins file".
|
~ltsmin_model();
|
||||||
// If a promela source is supplied, this function will call spins to
|
|
||||||
// update the *.spins library only if it is not newer.
|
// \brief Load an ltsmin model, either from divine or promela.
|
||||||
//
|
//
|
||||||
// Similarly the divine models can be specified as *.dve source or
|
// The filename given can be either a *.pm/*.pml/*.prom promela
|
||||||
// *.dve or *.dve2C libraries.
|
// source or a *.spins dynamic library compiled with "spins file".
|
||||||
//
|
// If a promela source is supplied, this function will call spins to
|
||||||
// The dead parameter is used to control the behavior of the model
|
// update the *.spins library only if it is not newer.
|
||||||
// on dead states (i.e. the final states of finite sequences).
|
//
|
||||||
// If DEAD is "false", it means we are not
|
// Similarly the divine models can be specified as *.dve source or
|
||||||
// interested in finite sequences of the system, and dead state
|
// *.dve or *.dve2C libraries.
|
||||||
// will have no successor. If DEAD is
|
//
|
||||||
// "true", we want to check finite sequences as well as infinite
|
static ltsmin_model load(const std::string& file);
|
||||||
// sequences, but do not need to distinguish them. In that case
|
|
||||||
// dead state will have a loop labeled by true. If DEAD is any
|
// \brief Generate a Kripke structure on-the-fly
|
||||||
// other string, this is the name a property that should be true
|
//
|
||||||
// when looping on a dead state, and false otherwise.
|
// The dead parameter is used to control the behavior of the model
|
||||||
//
|
// on dead states (i.e. the final states of finite sequences).
|
||||||
// This function returns 0 on error.
|
// If DEAD is "false", it means we are not
|
||||||
//
|
// interested in finite sequences of the system, and dead state
|
||||||
// \a file the name of the *.prom source file or the dynamic library
|
// will have no successor. If DEAD is
|
||||||
// \a to_observe the list of atomic propositions that should be observed
|
// "true", we want to check finite sequences as well as infinite
|
||||||
// in the model
|
// sequences, but do not need to distinguish them. In that case
|
||||||
// \a dict the BDD dictionary to use
|
// dead state will have a loop labeled by true. If DEAD is any
|
||||||
// \a dead an atomic proposition or constant to use for looping on
|
// other string, this is the name a property that should be true
|
||||||
// dead states
|
// when looping on a dead state, and false otherwise.
|
||||||
// \a verbose whether to output verbose messages
|
//
|
||||||
SPOT_API kripke_ptr
|
// This function returns 0 on error.
|
||||||
load_ltsmin(const std::string& file, const bdd_dict_ptr& dict,
|
//
|
||||||
const atomic_prop_set* to_observe,
|
// \a to_observe the list of atomic propositions that should be observed
|
||||||
formula dead = formula::tt(),
|
// in the model
|
||||||
int compress = 0, bool verbose = true);
|
// \a dict the BDD dictionary to use
|
||||||
|
// \a dead an atomic proposition or constant to use for looping on
|
||||||
|
// dead states
|
||||||
|
// \a compress whether to compress the states. Use 0 to disable, 1
|
||||||
|
// to enable compression, 2 to enable a faster compression that only
|
||||||
|
// work if all variables are smaller than 2^28.
|
||||||
|
kripke_ptr kripke(const atomic_prop_set* to_observe,
|
||||||
|
bdd_dict_ptr dict,
|
||||||
|
formula dead = formula::tt(),
|
||||||
|
int compress = 0) const;
|
||||||
|
private:
|
||||||
|
ltsmin_model(std::shared_ptr<const spins_interface> iface) : iface(iface)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
std::shared_ptr<const spins_interface> iface;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
// -*- coding: utf-8 -*-
|
// -*- coding: utf-8 -*-
|
||||||
// Copyright (C) 2011, 2012, 2013, 2014, 2015 Laboratoire de Recherche
|
// Copyright (C) 2011, 2012, 2013, 2014, 2015, 2016 Laboratoire de
|
||||||
// et Developpement de l'Epita (LRDE)
|
// Recherche et Developpement de l'Epita (LRDE)
|
||||||
//
|
//
|
||||||
// This file is part of Spot, a model checking library.
|
// This file is part of Spot, a model checking library.
|
||||||
//
|
//
|
||||||
|
|
@ -216,8 +216,15 @@ checked_main(int argc, char **argv)
|
||||||
if (output != DotFormula)
|
if (output != DotFormula)
|
||||||
{
|
{
|
||||||
tm.start("loading ltsmin model");
|
tm.start("loading ltsmin model");
|
||||||
model = spot::load_ltsmin(argv[1], dict, &ap, deadf,
|
try
|
||||||
compress_states, true);
|
{
|
||||||
|
model = spot::ltsmin_model::load(argv[1]).kripke(&ap, dict, deadf,
|
||||||
|
compress_states);
|
||||||
|
}
|
||||||
|
catch (std::runtime_error& e)
|
||||||
|
{
|
||||||
|
std::cerr << e.what() << '\n';
|
||||||
|
}
|
||||||
tm.stop("loading ltsmin model");
|
tm.stop("loading ltsmin model");
|
||||||
|
|
||||||
if (!model)
|
if (!model)
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"name": "",
|
"name": "",
|
||||||
"signature": "sha256:d5994cc04991eaf218539c16319f17128cf42be5d813785fd977ee3d991a5c00"
|
"signature": "sha256:eba4457368b676284d4696dd7afe5596d865c6f9f6f44b5fd5dc7c6585757c89"
|
||||||
},
|
},
|
||||||
"nbformat": 3,
|
"nbformat": 3,
|
||||||
"nbformat_minor": 0,
|
"nbformat_minor": 0,
|
||||||
|
|
@ -59,7 +59,7 @@
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"collapsed": false,
|
"collapsed": false,
|
||||||
"input": [
|
"input": [
|
||||||
"m = spot.ltsmin.load(srcdir + '/../ltsmin/finite.dve', ['P.a<1', 'P.b>2'])\n",
|
"m = spot.ltsmin.load(srcdir + '/../ltsmin/finite.dve')\n",
|
||||||
"m"
|
"m"
|
||||||
],
|
],
|
||||||
"language": "python",
|
"language": "python",
|
||||||
|
|
@ -69,6 +69,27 @@
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"output_type": "pyout",
|
"output_type": "pyout",
|
||||||
"prompt_number": 3,
|
"prompt_number": 3,
|
||||||
|
"text": [
|
||||||
|
"<spot.ltsmin.model; proxy of <Swig Object of type 'spot::ltsmin_model *' at 0x7f6990bd44e0> >"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"prompt_number": 3
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"collapsed": false,
|
||||||
|
"input": [
|
||||||
|
"k = m.kripke([\"P.a<1\", \"P.b>2\"])\n",
|
||||||
|
"k"
|
||||||
|
],
|
||||||
|
"language": "python",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"metadata": {},
|
||||||
|
"output_type": "pyout",
|
||||||
|
"prompt_number": 4,
|
||||||
"svg": [
|
"svg": [
|
||||||
"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n",
|
"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n",
|
||||||
"<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n",
|
"<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n",
|
||||||
|
|
@ -310,11 +331,11 @@
|
||||||
"</svg>\n"
|
"</svg>\n"
|
||||||
],
|
],
|
||||||
"text": [
|
"text": [
|
||||||
"<spot.impl.kripke; proxy of <Swig Object of type 'std::shared_ptr< spot::kripke > *' at 0x7f40740974e0> >"
|
"<spot.impl.kripke; proxy of <Swig Object of type 'std::shared_ptr< spot::kripke > *' at 0x7f6990bd4600> >"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"prompt_number": 3
|
"prompt_number": 4
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
|
|
@ -328,7 +349,7 @@
|
||||||
{
|
{
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"output_type": "pyout",
|
"output_type": "pyout",
|
||||||
"prompt_number": 4,
|
"prompt_number": 5,
|
||||||
"svg": [
|
"svg": [
|
||||||
"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n",
|
"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n",
|
||||||
"<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n",
|
"<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n",
|
||||||
|
|
@ -380,17 +401,17 @@
|
||||||
"</svg>\n"
|
"</svg>\n"
|
||||||
],
|
],
|
||||||
"text": [
|
"text": [
|
||||||
"<spot.impl.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7f40740977e0> >"
|
"<spot.impl.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7f6990bd4c90> >"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"prompt_number": 4
|
"prompt_number": 5
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"collapsed": false,
|
"collapsed": false,
|
||||||
"input": [
|
"input": [
|
||||||
"spot.otf_product(m, a)"
|
"spot.otf_product(k, a)"
|
||||||
],
|
],
|
||||||
"language": "python",
|
"language": "python",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
|
|
@ -398,7 +419,7 @@
|
||||||
{
|
{
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"output_type": "pyout",
|
"output_type": "pyout",
|
||||||
"prompt_number": 5,
|
"prompt_number": 6,
|
||||||
"svg": [
|
"svg": [
|
||||||
"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n",
|
"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n",
|
||||||
"<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n",
|
"<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n",
|
||||||
|
|
@ -510,20 +531,11 @@
|
||||||
"</svg>\n"
|
"</svg>\n"
|
||||||
],
|
],
|
||||||
"text": [
|
"text": [
|
||||||
"<spot.impl.twa_product; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_product > *' at 0x7f4074097720> >"
|
"<spot.impl.twa_product; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_product > *' at 0x7f6990bd49c0> >"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"prompt_number": 5
|
"prompt_number": 6
|
||||||
},
|
|
||||||
{
|
|
||||||
"cell_type": "code",
|
|
||||||
"collapsed": false,
|
|
||||||
"input": [],
|
|
||||||
"language": "python",
|
|
||||||
"metadata": {},
|
|
||||||
"outputs": [],
|
|
||||||
"prompt_number": 5
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"metadata": {}
|
"metadata": {}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue