14#include "mcrl2/data/detail/io.h"
15#include "mcrl2/data/representative_generator.h"
16#include "mcrl2/pbes/detail/ppg_visitor.h"
17#include "mcrl2/pbes/io.h"
18#include "mcrl2/pbes/pbes_explorer.h"
29 template <
typename MapContainer>
30 typename MapContainer::
mapped_type map_at(
const MapContainer& m,
typename MapContainer::key_type key)
32 typename MapContainer::const_iterator i = m.find(key);
35 throw mcrl2::
runtime_error(
"map_at: key is not present in the map: " + key);
61 return this->state_type_list.size();
67 return this->state_type_no.at(part);
72 return this->state_type_list.at(type_no);
89 return this->state_label_names.size();
95 return state_label_names;
101 return state_label_types;
107 return this->edge_label_names.size();
113 return edge_label_names;
119 return edge_label_types;
128 this->state_names.push_back(name);
129 this->state_types.push_back(type);
130 std::size_t type_index;
131 std::map<std::string,
int>::iterator type_index_it =
this->state_type_index.find(type);
132 if (type_index_it !=
this->state_type_index.end()) {
133 type_index = type_index_it->second;
135 this->state_type_list.push_back(type);
136 type_index =
this->state_type_list.size() - 1;
137 this->state_type_index[type] = type_index;
139 this->state_type_no.push_back(type_index);
145 const std::string& type)
147 this->state_label_names.push_back(name);
148 this->state_label_types.push_back(type);
153 const std::string& type)
155 this->edge_label_names.push_back(name);
156 this->edge_label_types.push_back(type);
173 throw std::runtime_error(
"PBES is not a PPG! Please rewrite with pbesrewr -pppg.");
186 std::vector<std::string> params;
187 std::map<std::string,std::string> paramtypes;
190 for (
const auto& eqn : p.equations())
195 propositional_variable var = eqn.variable();
196 for (
const variable& varparam: var.parameters())
198 std::string signature = get_param_signature(varparam);
199 bool new_param =
true;
200 for (
auto & param : params) {
201 if (signature == param) new_param =
false;
204 params.push_back(signature);
205 paramtypes[signature] = core::pp(varparam.sort());
207 data_expression e(default_expression_generator(varparam.sort()));
208 pbes_expression e1 = pgg->rewrite_and_simplify_expression(e,
false);
209 this->param_default_values.push_back(atermpp::down_cast<
const data::data_expression>(e1));
214 this->type = lts_type(1 + params.size());
215 this->type.add_state(
"var",
"string");
218 for (
const std::string& signature: params) {
219 this->type.add_state(signature, paramtypes[signature]);
220 this->param_index[signature] = i;
224 this->type.add_state_label(
"priority",
"int");
225 this->type.add_state_label(
"type",
"int");
238 if (params.size() != values.size())
244 data::variable_list::const_iterator param_it = params.begin();
245 for(
const auto & value : values)
247 if (!data::is_variable(value))
253 data::variable param(*param_it);
254 data::variable param_expr(value);
255 if (param != param_expr)
260 if (param_it != params.end())
268 throw mcrl2::runtime_error(
"is_pass_through_state check failed on " + data::pp(params) +
" " + data::pp(values));
285 if (a < INT_MAX && b < INT_MAX)
321 std::vector<pbes_expression> result;
322 std::vector<pbes_expression> parts;
323 if (is_simple_expression(e))
332 parts = split_conjuncts(e,
true);
334 parts = split_disjuncts(e,
true);
339 bool pass_through =
true;
341 for(std::vector<pbes_expression>::iterator p_it = parts.begin(); pass_through && p_it != parts.end(); ++p_it)
343 pbes_expression part = *p_it;
344 if (is_propositional_variable_instantiation(part))
348 propositional_variable_instantiation propvar = (propositional_variable_instantiation)part;
349 if (is_pass_through_state(propvar))
354 std::string varname = std::string(propvar.name());
355 int priority =
this->variable_priority[varname];
356 operation_type type =
this->variable_type[varname];
357 pbes_expression expr =
this->variable_expression[varname];
359 if ((priority == current_priority) &&
360 (current_type == type || is_simple_expression(expr) || count_variables(expr) <= 1) &&
361 vars_stack.find(varname) == vars_stack.end())
371 std::set<std::string> new_vars_stack(vars_stack.begin(), vars_stack.end());
372 new_vars_stack.insert(varname);
373 std::vector<pbes_expression> part_result = split_expression_and_substitute_variables(expr, current_priority, current_type, new_vars_stack);
374 result.insert(result.end(), part_result.begin(), part_result.end());
378 result.push_back(part);
383 pass_through =
false;
388 pass_through =
false;
393 if (always_split_option && !parts.empty())
421 std::string name =
"true";
423 this->variables[name] = t;
424 this->variable_type[name] = type;
425 this->variable_symbol[name] = symbol;
426 this->variable_priority[name] = priority;
428 this->variable_parameter_signatures[name] = get_param_sequence(t.parameters());
429 this->variable_parameter_indices[name] =
this->get_param_indices(t
.parameters());
430 this->variable_parameter_index_positions[name] =
this->get_param_index_positions(t
.parameters());
431 this->transition_expression_plain.push_back(
true_());
433 this->transition_variable_name.push_back(name);
434 this->transition_type.push_back(type);
442 this->variables[name] = f;
443 this->variable_type[name] = type;
444 this->variable_symbol[name] = symbol;
445 this->variable_priority[name] = priority;
447 this->variable_parameter_signatures[name] = get_param_sequence(f.parameters());
448 this->variable_parameter_indices[name] =
this->get_param_indices(f
.parameters());
449 this->variable_parameter_index_positions[name] =
this->get_param_index_positions(f
.parameters());
450 this->transition_expression_plain.push_back(
false_());
452 this->transition_variable_name.push_back(name);
453 this->transition_type.push_back(type);
459 for (
auto & eqn : p.equations()) {
460 pbes_expression expr = pgg->get_pbes_equation(eqn.variable().name()).formula();
461 std::string variable_name = eqn.variable().name();
462 this->variables[variable_name] = eqn.variable();
463 type = pgg->get_expression_operation(expr);
464 this->variable_type[variable_name] = type;
465 this->variable_symbol[variable_name] = eqn.symbol();
466 if (eqn.symbol() != symbol) {
468 symbol = eqn.symbol();
470 mCRL2log(log::debug) <<
"Adding var " << variable_name <<
", priority=" << priority <<
", symbol=" << symbol << std::endl;
471 this->variable_priority[variable_name] = priority;
472 this->variable_parameters[variable_name] = eqn.variable().parameters();
473 this->variable_parameter_signatures[variable_name] = get_param_sequence(eqn.variable().parameters());
474 this->variable_parameter_indices[variable_name] =
this->get_param_indices(eqn.variable().parameters());
475 this->variable_parameter_index_positions[variable_name] =
this->get_param_index_positions(eqn.variable().parameters());
476 this->variable_expression[variable_name] = expr;
480 std::set<std::string> variable_set;
483 std::queue<std::string> variable_queue;
484 variable_queue.push(init.name());
485 variable_set.insert(init.name());
486 while (!variable_queue.empty())
488 std::string var = variable_queue.front();
489 variable_queue.pop();
490 type =
this->variable_type[var];
491 priority =
this->variable_priority[var];
492 pbes_expression expr =
this->variable_expression[var];
493 std::set<std::string> vars_stack;
494 std::vector<pbes_expression> expression_parts = split_expression_and_substitute_variables(expr, priority, type, vars_stack);
495 for (std::vector<pbes_expression>::const_iterator e =
496 expression_parts.begin(); e != expression_parts.end(); ++e) {
497 std::set<std::string> occ_vars = lts_info::occ(*e);
498 for (
const auto & var_str : variable_set)
500 occ_vars.erase(var_str);
502 for(
const auto & occ_var : occ_vars)
504 variable_queue.push(occ_var);
506 variable_set.insert(occ_vars.begin(), occ_vars.end());
510 for (
const auto & var_str : variable_set)
512 mCRL2log(log::debug) <<
" " << var_str << std::endl;
517 for (
auto & eqn : p.equations()) {
518 std::string variable_name = eqn.variable().name();
519 if (variable_set.find(variable_name) != variable_set.end())
521 type =
this->variable_type[variable_name];
522 priority =
this->variable_priority[variable_name];
523 pbes_expression expr =
this->variable_expression[variable_name];
524 std::set<std::string> vars_stack;
525 mCRL2log(log::debug) << std::endl <<
"Generating groups for equation " << variable_name << std::endl;
526 std::vector<pbes_expression> expression_parts = split_expression_and_substitute_variables(expr, priority, type, vars_stack);
527 for (std::vector<pbes_expression>::const_iterator e =
528 expression_parts.begin(); e != expression_parts.end(); ++e) {
529 this->transition_expression_plain.push_back(*e);
530 this->transition_expression.push_back(pgg->rewrite_and_simplify_expression(*e));
531 this->transition_variable_name.push_back(variable_name);
532 this->transition_type.push_back(type);
533 mCRL2log(log::debug) <<
"Add transition group " << group <<
": "
534 << (type==parity_game_generator::PGAME_AND ?
"AND" :
"OR") <<
" " << variable_name <<
" "
535 << pbes_system::pp(*e) << std::endl;
551 std::vector<
bool> dep_row;
552 std::vector<
bool> read_row;
553 std::vector<
bool> write_row;
557 dep_row.push_back(d);
558 read_row.push_back(r);
559 write_row.push_back(w);
560 for (
int part = 1; part < type.get_state_length(); part++)
562 r = is_read_dependent_parameter(group, part);
563 w = is_write_dependent_parameter(group, part);
565 dep_row.push_back(d);
566 read_row.push_back(r);
567 write_row.push_back(w);
569 matrix[group] = dep_row;
570 read_matrix[group] = read_row;
571 write_matrix[group] = write_row;
591 return transition_expression;
597 return transition_variable_name;
603 return transition_type;
615 return variable_type;
620 return variable_symbol;
626 return variable_priority;
632 return variable_parameters;
638 return variable_parameter_signatures;
644 return variable_parameter_indices;
650 return variable_parameter_index_positions;
680 return param_index[signature];
686 return param_default_values.at(index);
698 if (group==0 || group==1)
return false;
699 std::string p = type.get_state_names()[part];
700 mCRL2log(log::debug) <<
"is_read_dependent_parameter (group=" << group <<
", part=" << part <<
" [" << p <<
"]" <<
std::endl;
702 std::string X = transition_variable_name[group];
703 std::set<std::string> params = lts_info::get_param_set(variable_parameters[X]);
704 if (params.find(p) == params.end())
710 std::set<std::string> usedSet = used(phi);
711 std::set<std::string> changedSet = changed(phi);
712 std::set<std::string> copySet = copied(phi);
713 std::set<std::string> changedAndCopied;
714 std::set_intersection(changedSet.begin(), changedSet.end(), copySet.begin(), copySet.end(),
715 std::inserter(changedAndCopied, changedAndCopied.end()));
717 if (usedSet.find(p) == usedSet.end() && changedAndCopied.find(p) == changedAndCopied.end())
733 if (group==0 || group==1)
return false;
735 std::string X = transition_variable_name[group];
740 std::set<std::string> occ = lts_info::occ(phi);
745 else if (occ.size() == 1)
747 bool containsX = occ.find(X) != occ.end();
759 if (group==0 || group==1)
return false;
760 std::string p = type.get_state_names().at(part);
762 std::string X = transition_variable_name[group];
769 std::set<std::string> params = lts_info::get_param_set(variable_parameters[X]);
770 std::set<std::string> resetSet = reset(phi, params);
771 if (resetSet.find(p) != resetSet.end())
776 std::set<std::string> changedSet = changed(phi);
777 bool changedSetContainsP = (changedSet.find(p) != changedSet.end());
778 return changedSetContainsP;
784 std::set<std::string> empty;
785 return changed(phi, empty);
791 std::set<std::string> result;
794 result = changed(pbes_system::accessors::arg(phi), L);
798 std::set<std::string> l = changed(pbes_system::accessors::left(phi), L);
799 result.insert(l.begin(), l.end());
800 std::set<std::string> r = changed(pbes_system::accessors::right(phi), L);
801 result.insert(r.begin(), r.end());
805 std::set<std::string> LL;
806 LL.insert(L.begin(), L.end());
808 for (
auto variable : vars)
810 LL.insert(get_param_signature(variable));
812 result = changed(pbes_system::accessors::arg(phi), LL);
816 std::vector<std::string> var_param_signatures =
817 variable_parameter_signatures[atermpp::down_cast<propositional_variable_instantiation>(phi).name()];
819 assert(var_param_signatures.size() == values.size());
820 data::data_expression_list::const_iterator val = values.begin();
821 for (std::vector<std::string>::const_iterator param =
822 var_param_signatures.begin(); param != var_param_signatures.end(); ++param) {
823 std::string param_signature = *param;
824 if (data::is_variable(*val))
826 const variable& value = atermpp::down_cast<variable>(*val);
827 std::string value_signature = get_param_signature(value);
828 if (param_signature != value_signature || L.find(value_signature) != L.end())
830 result.insert(param_signature);
835 result.insert(param_signature);
837 if (val != values.end()) {
848 std::set<std::string> result;
851 result = reset(pbes_system::accessors::arg(phi), d);
855 std::set<std::string> l = reset(pbes_system::accessors::left(phi), d);
856 result.insert(l.begin(), l.end());
857 std::set<std::string> r = reset(pbes_system::accessors::right(phi), d);
858 result.insert(r.begin(), r.end());
862 result = reset(pbes_system::accessors::arg(phi), d);
866 std::set<std::string> params;
867 std::vector<std::string> var_params =
868 variable_parameter_signatures[atermpp::down_cast<propositional_variable_instantiation>(phi).name()];
869 for (std::vector<std::string>::const_iterator param =
870 var_params.begin(); param != var_params.end(); ++param) {
871 std::string signature = *param;
872 params.insert(signature);
874 for (
auto signature : d) {
875 if (params.find(signature) == params.end())
877 result.insert(signature);
907std::set<std::string>
lts_info::occ(
const pbes_expression& expr)
909 std::set<std::string> result;
912 result.insert(atermpp::down_cast<propositional_variable_instantiation>(expr).name());
916 std::set<std::string> l = occ(pbes_system::accessors::left(expr));
917 result.insert(l.begin(), l.end());
918 std::set<std::string> r = occ(pbes_system::accessors::right(expr));
919 result.insert(r.begin(), r.end());
923 result = occ(pbes_system::accessors::arg(expr));
929std::set<std::string>
lts_info::free(
const pbes_expression& expr)
931 std::set<std::string> result;
932 for (
const data::variable& var: pbes_system::find_free_variables(expr))
934 result.insert(get_param_signature(var));
942 std::set<std::string> emptySet;
943 return used(expr, emptySet);
950 std::set<std::string> result;
953 std::set<std::string> fv = free(expr);
954 result.insert(fv.begin(), fv.end());
959 variable_parameters[atermpp::down_cast<propositional_variable_instantiation>(expr).name()];
961 assert(var_params.size() == values.size());
962 data::data_expression_list::const_iterator val = values.begin();
963 for (
auto parameter : var_params) {
964 std::string param_signature = get_param_signature(parameter);
965 if (data::is_variable(*val))
967 const variable& value = atermpp::down_cast<variable>(*val);
968 std::string value_signature = get_param_signature(value);
969 if (param_signature != value_signature || L.find(value_signature) != L.end())
971 result.insert(value_signature);
977 std::set<std::string> l = used(*val, L);
978 result.insert(l.begin(), l.end());
980 if (val != values.end()) {
987 std::set<std::string> l = used(pbes_system::accessors::left(expr), L);
988 result.insert(l.begin(), l.end());
989 std::set<std::string> r = used(pbes_system::accessors::right(expr), L);
990 result.insert(r.begin(), r.end());
994 result = used(pbes_system::accessors::arg(expr), L);
998 std::set<std::string> LL;
999 LL.insert(L.begin(), L.end());
1001 for (
auto variable : vars)
1003 LL.insert(get_param_signature(variable));
1005 result = used(pbes_system::accessors::arg(expr), LL);
1013 std::set<std::string> emptySet;
1014 return copied(expr, emptySet);
1021 std::set<std::string> result;
1029 variable_parameters[atermpp::down_cast<propositional_variable_instantiation>(expr).name()];
1031 assert(var_params.size() == values.size());
1032 data::data_expression_list::const_iterator val = values.begin();
1033 for (
auto parameter : var_params) {
1034 std::string param_signature = get_param_signature(parameter);
1035 if (data::is_variable(*val))
1037 const variable& value = atermpp::down_cast<variable>(*val);
1038 std::string value_signature = get_param_signature(value);
1039 if (param_signature == value_signature && L.find(value_signature) == L.end())
1041 result.insert(value_signature);
1044 if (val != values.end()) {
1051 std::set<std::string> l = copied(pbes_system::accessors::left(expr), L);
1052 result.insert(l.begin(), l.end());
1053 std::set<std::string> r = copied(pbes_system::accessors::right(expr), L);
1054 result.insert(r.begin(), r.end());
1058 result = copied(pbes_system::accessors::arg(expr), L);
1062 std::set<std::string> LL;
1063 LL.insert(L.begin(), L.end());
1065 for (
auto variable : vars)
1067 LL.insert(get_param_signature(variable));
1069 result = copied(pbes_system::accessors::arg(expr), LL);
1079 std::stringstream ss;
1080 operation_type type = detail::map_at(get_variable_types(), state.get_variable());
1084 const std::vector<data_expression>& param_values = state.get_parameter_values();
1085 std::vector<std::string> param_signatures =
1086 this->variable_parameter_signatures[state.get_variable()];
1087 std::vector<std::string>::const_iterator param_signature =
1088 param_signatures.begin();
1089 for (std::vector<data_expression>::const_iterator param_value =
1090 param_values.begin(); param_value != param_values.end(); ++param_value) {
1091 if (param_value != param_values.begin())
1093 ss << *param_signature <<
" = ";
1095 if (param_signature != param_signatures.end())
1106std::set<std::string>
lts_info::get_param_set(
const data::variable_list& params)
1108 std::set<std::string> result;
1109 for (
auto parameter : params) {
1110 result.insert(get_param_signature(parameter));
1116std::vector<std::string>
lts_info::get_param_sequence(
const data::variable_list& params)
1118 std::vector<std::string> result;
1119 for (
auto parameter : params) {
1120 result.push_back(get_param_signature(parameter));
1128 std::vector<
int> result;
1129 for (
auto parameter : params) {
1130 int index =
this->get_index(get_param_signature(parameter));
1131 result.push_back(index);
1139 std::map<
int,
int> result;
1141 for (
auto parameter : params) {
1142 int index =
this->get_index(get_param_signature(parameter));
1143 result.insert(std::make_pair(index,i));
1155 std::map<variable,std::string>::const_iterator i = variable_signatures.find(param);
1156 if (i == variable_signatures.end())
1161 variable_signatures[param] = signature;
1169 const std::string& paramtype)
1171 return paramname +
":" + paramtype;
1181 this->var = varname;
1190 this->var = varname;
1195 for (
const auto & value : values)
1197 if (value == novalue)
1199 throw(std::runtime_error(
"Error in ltsmin_state: state expression contains NoValue: "
1202 this->add_parameter_value(value);
1207 throw(
std::runtime_error(
"Not a valid state expression! " +
pp(e
)));
1216 if (param_values.size() < other.param_values.size())
return true;
1217 else if (param_values.size() == other.param_values.size())
1219 if (param_values < other.param_values)
return true;
1228 return this->var==other.var
1229 && param_values.size()==other.param_values.size()
1230 && param_values == other.param_values;
1242 return param_values;
1248 param_values.push_back(value);
1255 for (
const auto & param_value : param_values) {
1256 parameter_values.push_back(param_value);
1261 propositional_variable_instantiation(core::identifier_string(var), parameter_values_list);
1269 std::stringstream ss;
1272 ss <<
"[" <<
std::endl;
1273 for (std::vector<data_expression>::const_iterator entry =
1274 param_values.begin(); entry != param_values.end(); ++entry) {
1275 if (entry != param_values.begin())
1276 ss << std::endl <<
" value = ";
1289explorer::
explorer(
const std::string& filename,
const std::string& rewrite_strategy =
"jittyc",
bool reset_flag =
false,
bool always_split_flag =
false)
1291 load_pbes(p, filename);
1292 for (
auto & eqn : p.equations()) {
1293 std::string variable_name = eqn.variable().name();
1296 pbes_system::algorithms::normalize(p);
1297 if (!detail::is_ppg(p))
1300 p = detail::to_ppg(p);
1303 this->pgg =
new detail::pbes_greybox_interface(p,
true,
true, data::parse_rewrite_strategy(rewrite_strategy));
1304 this->info =
new lts_info(p, pgg, reset_flag, always_split_flag);
1307 std::map<data_expression,
int> data2int_map;
1308 this->localmaps_data2int.push_back(data2int_map);
1309 std::vector<data_expression> int2data_map;
1310 this->localmaps_int2data.push_back(int2data_map);
1316explorer::
explorer(
const pbes& p_,
const std::string& rewrite_strategy =
"jittyc",
bool reset_flag =
false,
bool always_split_flag =
false)
1319 this->pgg =
new detail::pbes_greybox_interface(p,
true,
true, data::parse_rewrite_strategy(rewrite_strategy));
1320 this->info =
new lts_info(p, pgg, reset_flag, always_split_flag);
1323 std::map<data_expression,
int> data2int_map;
1324 this->localmaps_data2int.push_back(data2int_map);
1325 std::vector<data_expression> int2data_map;
1326 this->localmaps_int2data.push_back(int2data_map);
1375 return ltsmin_state(
"true");
1381 return ltsmin_state(
"false");
1408 std::map<std::string,
int>::iterator it =
this->localmap_string2int.find(s);
1410 if (it !=
this->localmap_string2int.end()) {
1413 this->localmap_int2string.push_back(s);
1414 index =
this->localmap_int2string.size() - 1;
1416 this->localmap_string2int.insert(std::make_pair(s,index));
1428 std::map<data_expression,
int>& data2int_map =
this->localmaps_data2int.at(type_no);
1429 std::map<data_expression,
int>::iterator it = data2int_map.find(value);
1431 if (it != data2int_map.end()) {
1434 this->localmaps_int2data.at(type_no).push_back(value);
1435 index =
this->localmaps_int2data.at(type_no).size() - 1;
1436 data2int_map.insert(std::make_pair(value,index));
1451 std::string src_varname;
1452 bool same_var =
false;
1453 if (!(src==
nullptr)) {
1455 same_var = (varname==src_varname);
1468 std::vector < data_expression > values(state_length);
1472 for (
int i = 1; i < state_length; i++) {
1474 values[i] = default_value;
1476 dst[i] =
this->get_value_index(type_no, values[i]);
1479 for (
int i = 1; i < state_length; i++) {
1484 const std::vector<data_expression>& parameter_values = dst_state.get_parameter_values();
1485 std::vector<
int> parameter_indices =
1486 detail::map_at(info->get_variable_parameter_indices(), varname);
1487 std::vector<std::string> parameter_signatures =
1488 detail::map_at(info->get_variable_parameter_signatures(), varname);
1489 std::vector<std::string>::iterator param_signature = parameter_signatures.begin();
1490 int value_index = 0;
1491 for(
int & parameter_indice : parameter_indices)
1493 int i = parameter_indice + 1;
1494 int type_no = info->get_lts_type().get_state_type_no(i);
1495 values[i] = parameter_values[value_index];
1496 if (values[i]==novalue)
1502 dst[i] =
this->get_value_index(type_no, values[i]);
1508 std::map<
int,
int> src_param_index_positions = detail::map_at(info->get_variable_parameter_index_positions(), src_state.get_variable());
1509 std::map<
int,
int>::iterator src_param_index_position_it = src_param_index_positions.find(parameter_indice);
1510 if ( src_param_index_position_it != src_param_index_positions.end()
1511 && src_state.get_parameter_values()[src_param_index_position_it->second] == values[i])
1518 dst[i] =
this->get_value_index(type_no, values[i]);
1522 if (param_signature != parameter_signatures.end())
1530 throw(
std::runtime_error(
"Error in to_state_vector: NoValue in parameters of dst_state: "
1559 if (index >= (
int)(localmap_int2string.size()))
1561 throw(
std::runtime_error(
"Error in get_string_value: Value not found for index " +
std::to_string(index) +
"."));
1563 return localmap_int2string.at(index);
1569 std::vector<data_expression>& int2data_map =
this->localmaps_int2data.at(type_no);
1570 if (index >= (
int)(int2data_map.size()))
1572 throw(
std::runtime_error(
"Error in get_data_value: Value not found for type_no "
1573 +
std::to_string(type_no) +
" at index " +
std::to_string(index) +
"."));
1575 return int2data_map.at(index);
1591 std::vector <data_expression> values(state_length);
1594 for (
int i = 1; i < state_length; i++) {
1597 values[i] =
this->get_data_value(type_no, src[i]);
1602 std::vector<
int> parameter_indices =
1603 detail::map_at(info->get_variable_parameter_indices(), varname);
1604 for (
int & parameter_indice : parameter_indices) {
1605 if (values[parameter_indice+1]==novalue)
1610 parameters.push_back(values[parameter_indice+1]);
1614 throw(
std::runtime_error(
"Error in from_state_vector: NoValue in parameters."));
1628 std::vector<ltsmin_state> result;
1631 assert(
core::
detail::check_term_PropVarInst(e));
1635 result.push_back(state);
1640 result.push_back(state);
1644 std::set<pbes_expression> successors
1645 = pgg->get_successors(e);
1647 for (
const auto & successor : successors) {
1648 if (is_propositional_variable_instantiation(successor)) {
1649 result.push_back(get_state(atermpp::down_cast<propositional_variable_instantiation>(successor)));
1650 }
else if (is_true(successor)) {
1651 if (type != parity_game_generator::PGAME_AND)
1653 result.push_back(true_state());
1655 }
else if (is_false(successor)) {
1656 if (type != parity_game_generator::PGAME_OR)
1658 result.push_back(false_state());
1661 throw(std::runtime_error(
"!! Successor is NOT a propvar: " + pbes_system::pp(successor)));
1673 std::vector<ltsmin_state> result;
1678 result.push_back(state);
1683 result.push_back(state);
1688 std::string group_varname =
info->get_transition_variable_names()[group];
1689 if (varname==group_varname)
1692 std::set<pbes_expression> successors
1693 = pgg->get_successors(e, group_varname,
1694 info->get_transition_expressions()[group]);
1696 for (
const auto & successor : successors) {
1698 if (is_propositional_variable_instantiation(successor)) {
1699 result.push_back(get_state(atermpp::down_cast<propositional_variable_instantiation>(successor)));
1700 }
else if (is_true(successor)) {
1701 if (type != parity_game_generator::PGAME_AND)
1703 result.push_back(true_state());
1705 }
else if (is_false(successor)) {
1706 if (type != parity_game_generator::PGAME_OR)
1708 result.push_back(false_state());
1711 throw(std::runtime_error(
"!! Successor is NOT a propvar: " + pbes_system::pp(successor)));
aterm_string(const std::string &s)
Constructor that allows construction from a string.
bool operator!=(const unprotected_aterm_core &t) const
Inequality operator on two unprotected aterms.
Components for generating an arbitrary element of a sort.
representative_generator(const data_specification &specification)
Constructor with data specification as context.
const core::identifier_string & name() const
const sort_expression & sort() const
logger(const log_level_t l)
Default constructor.
propositional_variable_instantiation get_initial_state()
Returns the initial state, rewritten and simplified.
pbes_expression rewrite_and_simplify_expression(const pbes_expression &e, const bool=true)
Rewrites and simplifies an expression.
static ltsmin_state false_state()
Returns the state representing false.
ltsmin_state get_state(const propositional_variable_instantiation &expr) const
Returns a PBES_State object for expr.
std::vector< ltsmin_state > get_successors(const ltsmin_state &state, int group)
Computes successor states for a state as defined in transition group group. Serves as a wrapper aroun...
int get_index(int type_no, const std::string &s)
Returns the index of value in the local store for the data type with number type_no....
ltsmin_state get_initial_state() const
Returns the initial state.
static ltsmin_state true_state()
Returns the state representing true.
void to_state_vector(const ltsmin_state &dst_state, int *dst, const ltsmin_state &src_state, int *const &src)
Transforms a PBES state to a state vector, represented by an array of integers.
std::string get_value(int type_no, int index)
Returns the value at position index in the local store for the data type with number type_no....
int get_value_index(int type_no, const data_expression &value)
Returns the index of value in the local store for the data type with number type_no....
explorer(const std::string &filename, const std::string &rewrite_strategy, bool reset_flag, bool always_split_flag)
Constructor.
explorer(const pbes &p_, const std::string &rewrite_strategy, bool reset_flag, bool always_split_flag)
Constructor.
ltsmin_state from_state_vector(int *const &src)
Transforms a state vector src into a PBES_State object object containing the variable and parameter v...
int get_string_index(const std::string &s)
Returns the index of s in the local store for string values. This store is reserved for the string re...
const std::string & get_string_value(int index)
Returns the string at position index in the local store for string values. An exception is thrown if ...
std::vector< ltsmin_state > get_successors(const ltsmin_state &state)
Computes successor states for a state. Serves as a wrapper around the get_successors function of the ...
data::data_expression string_to_data(const std::string &s)
Returns a data expression for the string representation s.
lts_info * get_info() const
Returns the PBES_Info object.
const data_expression & get_data_value(int type_no, int index)
Returns the value at position index in the local store for the data type with number type_no....
detail::pbes_greybox_interface * pgg
the PBES greybox interface
void initial_state(int *state)
static fixpoint_symbol nu()
Returns the nu symbol.
fixpoint_symbol & operator=(fixpoint_symbol &&) noexcept=default
static fixpoint_symbol mu()
Returns the mu symbol.
bool is_write_dependent_propvar(int group)
Determines if group is write dependent on the propositional variable. Returns true if propositional v...
const std::map< std::string, std::map< int, int > > & get_variable_parameter_index_positions() const
Returns the map from variable names to the map from indices of parameter signatures for the variable ...
const std::map< int, std::vector< bool > > & get_read_matrix() const
Returns the read dependency matrix.
const std::map< int, std::vector< bool > > & get_write_matrix() const
Returns the write dependency matrix.
bool is_read_dependent_parameter(int group, int part)
Determines if group is read dependent on part part of the state vector. Returns true if the parameter...
std::vector< int > get_param_indices(const data::variable_list ¶ms)
Converts a variable_sequence_type into a sequence of indices of parameter signatures in the list of p...
bool is_pass_through_state(const propositional_variable_instantiation &propvar)
Determines if the propositional variable instantiation is one that only copies parameters from the cu...
const std::map< std::string, fixpoint_symbol > & get_variable_symbols() const
Returns the map from variable names to the fixpoint operator of the equation for the variable.
static std::map< variable, std::string > variable_signatures
const std::map< std::string, data::variable_list > & get_variable_parameters() const
Returns the map from variable names to the sequence of parameters for the variable.
const std::map< std::string, std::vector< std::string > > & get_variable_parameter_signatures() const
Returns the map from variable names to the list of parameters signatures for the variable.
const std::map< std::string, propositional_variable > & get_variables() const
Returns the map from variable names to the variable object for the variable.
int get_index(const std::string &signature)
Returns the index for a parameter signature in the list of parameter signatures for the system.
const lts_type & get_lts_type() const
Returns the LTS Type.
bool get_reset_option() const
Returns if the reset option is set.
std::set< std::string > copied(const pbes_expression &expr, const std::set< std::string > &L)
Computes the free variables which are copied/passed through (to a recursive variable) in an expressio...
const std::vector< pbes_expression > & get_transition_expressions() const
Returns the map from transition group number to the expression of the transition group.
std::set< std::string > copied(const pbes_expression &expr)
Computes the free variables which are copied/passed through (to a recursive variable) in an expressio...
detail::pbes_greybox_interface * pgg
bool is_read_dependent_propvar(int group)
Determines if group is read dependent on the propositional variable. Returns true,...
const std::map< int, std::vector< bool > > & get_dependency_matrix() const
Returns the dependency matrix.
const std::vector< operation_type > & get_transition_types() const
Returns the map from transition group number to the type of the right hand side of the equation to wh...
std::set< std::string > used(const pbes_expression &expr, const std::set< std::string > &L)
Computes the free variables actually used, not only passed through, in an expression.
std::set< std::string > used(const pbes_expression &expr)
Computes the free variables actually used, not only passed through, in an expression.
static std::string get_param_signature(const variable ¶m)
Returns a signature for parameter param.
const std::map< std::string, operation_type > & get_variable_types() const
Returns the map from variable names to the type of the right hand side of the equation for the variab...
void compute_dependency_matrix()
Computes dependency matrix from PBES.
lts_info(pbes &p, detail::pbes_greybox_interface *pgg, bool reset, bool always_split)
Constructor.
static bool tf(const pbes_expression &phi)
Determines if the term phi contains a branch that directly results in true or false (not a variable).
std::vector< pbes_expression > split_expression_and_substitute_variables(const pbes_expression &e, int current_priority, operation_type current_type, std::set< std::string > vars_stack)
Splits the expression into parts (disjuncts or conjuncts) and recursively tries to substitute the pro...
int get_number_of_groups() const
Returns the number of transition groups.
std::map< int, int > get_param_index_positions(const data::variable_list ¶ms)
Converts a variable_sequence_type into a map from indices of parameter signatures (in the list of par...
int count_variables(const pbes_expression &e)
Counts the number of propositional variables in an expression.
void compute_lts_type()
Computes LTS Type from PBES.
std::set< std::string > changed(const pbes_expression &phi, const std::set< std::string > &L)
Computes the set of parameters changed in the expression.
std::string state_to_string(const ltsmin_state &state)
Returns a string representation for state state.
const std::map< std::string, int > & get_variable_priorities() const
Returns the map from variable names to the priority of the equation for the variable.
const data_expression & get_default_value(int index)
Returns a default value for the sort of a parameter signature.
const std::vector< std::string > & get_transition_variable_names() const
Returns the map from transition group number to the variable name of the equation to which the transi...
std::set< std::string > reset(const pbes_expression &phi, const std::set< std::string > &d)
Computes the set of parameters reset in the expression.
static std::string get_param_signature(const std::string ¶mname, const std::string ¶mtype)
Returns a signature using name and type of a parameter.
bool is_write_dependent_parameter(int group, int part)
Determines if group is read dependent on part part of the state vector. Returns true if the parameter...
std::set< std::string > changed(const pbes_expression &phi)
Computes the set of parameters changed in the expression.
void compute_transition_groups()
Computes transition groups from PBES.
const std::map< std::string, std::vector< int > > & get_variable_parameter_indices() const
Returns the map from variable names to the list of indices of the parameters signatures for the varia...
const std::vector< std::string > & get_edge_label_types() const
Returns the sequence of edge label types.
std::size_t get_number_of_state_types() const
Returns the number of state types.
const std::vector< std::string > & get_edge_labels() const
Returns the sequence of edge labels.
int get_state_type_no(int part) const
Returns the state type index for the state part part.
void add_state(const std::string &name, const std::string &type)
Adds a state part of type type with name name.
void add_state_label(const std::string &name, const std::string &type)
Adds a state label of type type with name name.
lts_type(int state_length)
Contructor.
std::string get_state_type_name(int type_no) const
Returns the name of the state type with number type_no.
int get_state_length() const
Returns the state length.
const std::vector< std::string > & get_state_label_types() const
Returns the sequence of state label types.
std::size_t get_number_of_edge_labels() const
Returns the number of edge labels.
const std::vector< std::string > & get_state_types() const
Returns the sequence of state part types.
void add_edge_label(const std::string &name, const std::string &type)
Adds an edge label of type type with name name.
const std::vector< std::string > & get_state_labels() const
Returns the sequence of state labels.
const std::vector< std::string > & get_state_names() const
Returns the sequence of state part names.
std::size_t get_number_of_state_labels() const
Returns the number of state labels.
void add_parameter_value(const data_expression &)
Adds a parameter value to the list of parameter values.
pbes_expression to_pbes_expression() const
Returns a PBES expression representing the state.
std::string state_to_string() const
Returns the player or type of the state (And/Or, Abelard/Eloise, Odd/Even).
bool operator<(const ltsmin_state &other) const
Compares two PBES_State objects. Uses lexicographical ordering on priority, type, variable and parame...
ltsmin_state(const std::string &varname)
Constructor.
bool operator==(const ltsmin_state &other) const
Checks if two PBES_State objects are equal.
ltsmin_state(const std::string &varname, const pbes_expression &e)
Constructor.
std::string get_variable() const
Returns the priority for the state, which depends on the fixpoint operator of the equation of the pro...
const std::vector< data_expression > & get_parameter_values() const
Returns the list of parameter values.
Class for generating a BES from a PBES. This BES can be interpreted as a graph corresponding to a par...
parameterized boolean equation system
propositional_variable_instantiation & initial_state()
Returns the initial state.
\brief A propositional variable instantiation
const data::data_expression_list & parameters() const
const core::identifier_string & name() const
\brief A propositional variable declaration
const data::variable_list & parameters() const
propositional_variable(const core::identifier_string &name, const data::variable_list ¶meters)
\brief Constructor Z12.
Standard exception class for reporting runtime errors.
#define mCRL2log(LEVEL)
mCRL2log(LEVEL) provides the stream used to log.
The main namespace for the aterm++ library.
std::string pp(const atermpp::aterm &t)
Transform an aterm to an ascii string.
aterm read_term_from_string(const std::string &s)
Reads an aterm from a string. The string can be in either binary or text format.
atermpp::aterm_string identifier_string
String type of the LPS library. Identifier strings are represented internally as ATerms.
atermpp::aterm add_index(const atermpp::aterm &x)
atermpp::aterm remove_index(const atermpp::aterm &x)
Namespace for all data library functionality.
std::vector< data_expression > data_expression_vector
\brief vector of data_expressions
atermpp::term_list< data_expression > data_expression_list
\brief list of data_expressions
atermpp::term_list< variable > variable_list
\brief list of variables
The namespace for accessor functions on pbes expressions.
const pbes_expression & arg(const pbes_expression &t)
Returns the pbes expression argument of expressions of type not, exists and forall.
const pbes_expression & left(const pbes_expression &t)
Returns the left hand side of an expression of type and, or or imp.
const pbes_expression & right(const pbes_expression &t)
Returns the right hand side of an expression of type and, or or imp.
MapContainer::mapped_type map_at(const MapContainer &m, typename MapContainer::key_type key)
The main namespace for the PBES library.
bool is_data(const pbes_expression &t)
Returns true if the term t is a data expression.
const pbes_expression & true_()
bool is_not(const atermpp::aterm &x)
bool is_exists(const atermpp::aterm &x)
bool is_or(const atermpp::aterm &x)
bool is_forall(const atermpp::aterm &x)
std::string pp(const pbes_system::pbes_expression &x)
bool is_propositional_variable_instantiation(const atermpp::aterm &x)
bool is_and(const atermpp::aterm &x)
bool is_imp(const atermpp::aterm &x)
const pbes_expression & false_()
std::size_t operator()(const atermpp::detail::reference_aterm< T > &t) const