15#include "mcrl2/data/detail/io.h"
16#include "mcrl2/data/representative_generator.h"
17#include "mcrl2/pbes/detail/ppg_visitor.h"
18#include "mcrl2/pbes/io.h"
19#include "mcrl2/pbes/pbes_explorer.h"
28 template <
typename MapContainer>
29 typename MapContainer::
mapped_type map_at(
const MapContainer& m,
typename MapContainer::key_type key)
31 typename MapContainer::const_iterator i = m.find(key);
34 throw mcrl2::runtime_error(
"map_at: key is not present in the map: " + key);
57 return this->state_type_list.size();
63 return this->state_type_no.at(part);
68 return this->state_type_list.at(type_no);
85 return this->state_label_names.size();
91 return state_label_names;
97 return state_label_types;
103 return this->edge_label_names.size();
109 return edge_label_names;
115 return edge_label_types;
124 this->state_names.push_back(name);
125 this->state_types.push_back(type);
127 std::map<std::string,
int>::iterator type_index_it =
this->state_type_index.find(type);
128 if (type_index_it !=
this->state_type_index.end()) {
129 type_index = type_index_it->second;
131 this->state_type_list.push_back(type);
132 type_index =
static_cast<
int>(
this->state_type_list.size() - 1);
133 this->state_type_index[type] = type_index;
135 this->state_type_no.push_back(type_index);
140 const std::string& type)
142 this->state_label_names.push_back(name);
143 this->state_label_types.push_back(type);
148 const std::string& type)
150 this->edge_label_names.push_back(name);
151 this->edge_label_types.push_back(type);
168 throw std::runtime_error(
"PBES is not a PPG! Please rewrite with pbesrewr -pppg.");
178 mCRL2log(log::log_level_t::verbose) <<
"Compute LTS type." << std::endl;
179 std::vector<std::string> params;
180 std::map<std::string,std::string> paramtypes;
183 for (
const auto& eqn : p.equations())
188 propositional_variable var = eqn.variable();
189 for (
const variable& varparam: var.parameters())
191 std::string signature = get_param_signature(varparam);
192 bool new_param =
true;
193 for (
const std::string& param: params)
195 if (signature == param)
202 params.push_back(signature);
203 paramtypes[signature] = core::pp(varparam.sort());
204 data_expression e(default_expression_generator(varparam.sort()));
205 pbes_expression e1 = pgg->rewrite_and_simplify_expression(atermpp::down_cast<pbes_expression>(e),
false);
206 this->param_default_values.push_back(atermpp::down_cast<
const data::data_expression>(e1));
210 this->type = lts_type(
static_cast<
int>(1 + params.size()));
211 this->type.add_state(
"var",
"string");
214 for (
const std::string& signature: params) {
215 this->type.add_state(signature, paramtypes[signature]);
216 this->param_index[signature] = i;
220 this->type.add_state_label(
"priority",
"int");
221 this->type.add_state_label(
"type",
"int");
223 mCRL2log(log::log_level_t::verbose) <<
"end of compute_lts_type." << std::endl;
229 std::string varname = std::string(propvar.name());
230 data::variable_list params =
this->variable_parameters[varname];
232 if (params.size() != values.size())
238 data::variable_list::const_iterator param_it = params.begin();
239 for(
const auto & value : values)
241 if (!data::is_variable(value))
247 data::variable param(*param_it);
248 data::variable param_expr(value);
249 if (param != param_expr)
254 if (param_it != params.end())
262 throw mcrl2::runtime_error(
"is_pass_through_state check failed on " + data::pp(params) +
" " + data::pp(values));
279 if (a < INT_MAX && b < INT_MAX)
309 throw(std::runtime_error(
"Unexpected expression: " + pbes_system::pp(e)));
315 std::vector<pbes_expression> result;
316 std::vector<pbes_expression> parts;
317 if (is_simple_expression(e,
false))
326 parts = split_conjuncts(e,
true);
328 parts = split_disjuncts(e,
true);
333 bool pass_through =
true;
335 for(std::vector<pbes_expression>::iterator p_it = parts.begin(); pass_through && p_it != parts.end(); ++p_it)
337 pbes_expression part = *p_it;
338 if (is_propositional_variable_instantiation(part))
342 propositional_variable_instantiation propvar = (propositional_variable_instantiation)part;
343 if (is_pass_through_state(propvar))
348 std::string varname = std::string(propvar.name());
349 int priority =
this->variable_priority[varname];
350 operation_type type =
this->variable_type[varname];
351 pbes_expression expr =
this->variable_expression[varname];
353 if ((priority == current_priority) &&
354 (current_type == type || is_simple_expression(expr,
false) || count_variables(expr) <= 1) &&
355 vars_stack.find(varname) == vars_stack.end())
365 std::set<std::string> new_vars_stack(vars_stack.begin(), vars_stack.end());
366 new_vars_stack.insert(varname);
367 std::vector<pbes_expression> part_result = split_expression_and_substitute_variables(expr, current_priority, current_type, new_vars_stack);
368 result.insert(result.end(), part_result.begin(), part_result.end());
372 result.push_back(part);
377 pass_through =
false;
382 pass_through =
false;
387 if (always_split_option && !parts.empty())
407 mCRL2log(log::log_level_t::verbose) <<
"Compute transition groups." << std::endl;
415 std::string name =
"true";
417 this->variables[name] = t;
418 this->variable_type[name] = type;
419 this->variable_symbol[name] = symbol;
420 this->variable_priority[name] = priority;
421 this->variable_parameters[name] = t.parameters();
422 this->variable_parameter_signatures[name] = get_param_sequence(t.parameters());
423 this->variable_parameter_indices[name] =
this->get_param_indices(t.parameters());
424 this->variable_parameter_index_positions[name] =
this->get_param_index_positions(t.parameters());
425 this->transition_expression_plain.push_back(
true_());
427 this->transition_variable_name.push_back(name);
428 this->transition_type.push_back(type);
436 this->variables[name] = f;
437 this->variable_type[name] = type;
438 this->variable_symbol[name] = symbol;
439 this->variable_priority[name] = priority;
440 this->variable_parameters[name] = f.parameters();
441 this->variable_parameter_signatures[name] = get_param_sequence(f.parameters());
442 this->variable_parameter_indices[name] =
this->get_param_indices(f.parameters());
443 this->variable_parameter_index_positions[name] =
this->get_param_index_positions(f.parameters());
444 this->transition_expression_plain.push_back(
false_());
446 this->transition_variable_name.push_back(name);
447 this->transition_type.push_back(type);
453 for (
auto & eqn : p.equations()) {
454 pbes_expression expr = pgg->get_pbes_equation(eqn.variable().name()).formula();
455 std::string variable_name = eqn.variable().name();
456 this->variables[variable_name] = eqn.variable();
457 type = pgg->get_expression_operation(expr);
458 this->variable_type[variable_name] = type;
459 this->variable_symbol[variable_name] = eqn.symbol();
460 if (eqn.symbol() != symbol) {
462 symbol = eqn.symbol();
464 mCRL2log(log::log_level_t::debug) <<
"Adding var " << variable_name <<
", priority=" << priority <<
", symbol=" << symbol << std::endl;
465 this->variable_priority[variable_name] = priority;
466 this->variable_parameters[variable_name] = eqn.variable().parameters();
467 this->variable_parameter_signatures[variable_name] = get_param_sequence(eqn.variable().parameters());
468 this->variable_parameter_indices[variable_name] =
this->get_param_indices(eqn.variable().parameters());
469 this->variable_parameter_index_positions[variable_name] =
this->get_param_index_positions(eqn.variable().parameters());
470 this->variable_expression[variable_name] = expr;
474 std::set<std::string> variable_set;
477 std::queue<std::string> variable_queue;
478 variable_queue.push(init.name());
479 variable_set.insert(init.name());
480 while (!variable_queue.empty())
482 std::string var = variable_queue.front();
483 variable_queue.pop();
484 type =
this->variable_type[var];
485 priority =
this->variable_priority[var];
486 pbes_expression expr =
this->variable_expression[var];
487 std::set<std::string> vars_stack;
488 std::vector<pbes_expression> expression_parts = split_expression_and_substitute_variables(expr, priority, type, vars_stack);
489 for (
const auto & expression_part : expression_parts) {
490 std::set<std::string> occ_vars = lts_info::occ(expression_part);
491 for (
const auto & var_str : variable_set)
493 occ_vars.erase(var_str);
495 for(
const auto & occ_var : occ_vars)
497 variable_queue.push(occ_var);
499 variable_set.insert(occ_vars.begin(), occ_vars.end());
502 mCRL2log(log::log_level_t::debug) <<
"Set of 'used' variables: " << std::endl;
503 for (
const auto & var_str : variable_set)
505 mCRL2log(log::log_level_t::debug) <<
" " << var_str << std::endl;
507 mCRL2log(log::log_level_t::debug) << std::endl;
510 for (
auto & eqn : p.equations()) {
511 std::string variable_name = eqn.variable().name();
512 if (variable_set.find(variable_name) != variable_set.end())
514 type =
this->variable_type[variable_name];
515 priority =
this->variable_priority[variable_name];
516 pbes_expression expr =
this->variable_expression[variable_name];
517 std::set<std::string> vars_stack;
518 mCRL2log(log::log_level_t::debug) << std::endl <<
"Generating groups for equation " << variable_name << std::endl;
519 std::vector<pbes_expression> expression_parts = split_expression_and_substitute_variables(expr, priority, type, vars_stack);
520 for (
const auto & expression_part : expression_parts) {
521 this->transition_expression_plain.push_back(expression_part);
522 this->transition_expression.push_back(pgg->rewrite_and_simplify_expression(expression_part));
523 this->transition_variable_name.push_back(variable_name);
524 this->transition_type.push_back(type);
525 mCRL2log(log::log_level_t::debug) <<
"Add transition group " << group <<
": "
526 << (type==parity_game_generator::operation_type::PGAME_AND ?
"AND" :
"OR") <<
" " << variable_name <<
" "
527 << pbes_system::pp(expression_part) << std::endl;
533 mCRL2log(log::log_level_t::debug) <<
"end of compute_transition_groups." << std::endl;
539 mCRL2log(log::log_level_t::verbose) <<
"Compute dependency matrix." << std::endl;
542 std::vector<
bool> dep_row;
543 std::vector<
bool> read_row;
544 std::vector<
bool> write_row;
548 dep_row.push_back(d);
549 read_row.push_back(r);
550 write_row.push_back(w);
551 for (
int part = 1; part < type.get_state_length(); part++)
553 r = is_read_dependent_parameter(group, part);
554 w = is_write_dependent_parameter(group, part);
556 dep_row.push_back(d);
557 read_row.push_back(r);
558 write_row.push_back(w);
560 matrix[group] = dep_row;
561 read_matrix[group] = read_row;
562 write_matrix[group] = write_row;
564 mCRL2log(log::log_level_t::verbose) <<
"end of compute_dependency_matrix." << std::endl;
582 return transition_expression;
588 return transition_variable_name;
594 return transition_type;
606 return variable_type;
611 return variable_symbol;
617 return variable_priority;
623 return variable_parameters;
671 return param_index[signature];
677 return param_default_values.at(index);
689 if (group == 0 || group == 1)
693 std::string p = type.get_state_names()[part];
694 mCRL2log(log::log_level_t::debug) <<
"is_read_dependent_parameter (group=" << group <<
", part=" << part <<
" [" << p <<
"]" << std::endl;
696 std::string X = transition_variable_name[group];
697 std::set<std::string> params = lts_info::get_param_set(variable_parameters[X]);
698 if (params.find(p) == params.end())
704 std::set<std::string> usedSet = used(phi);
705 std::set<std::string> changedSet = changed(phi);
706 std::set<std::string> copySet = copied(phi);
707 std::set<std::string> changedAndCopied;
708 std::set_intersection(changedSet.begin(), changedSet.end(), copySet.begin(), copySet.end(),
709 std::inserter(changedAndCopied, changedAndCopied.end()));
711 if (usedSet.find(p) == usedSet.end() && changedAndCopied.find(p) == changedAndCopied.end())
727 if (group == 0 || group == 1)
732 std::string X = transition_variable_name[group];
737 std::set<std::string> occ = lts_info::occ(phi);
742 else if (occ.size() == 1)
744 bool containsX = occ.find(X) != occ.end();
756 if (group == 0 || group == 1)
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());
807 data::variable_list vars = quantifier_variables(phi);
808 for (
const 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()];
818 data::data_expression_list values = atermpp::down_cast<propositional_variable_instantiation>(phi).parameters();
819 assert(var_param_signatures.size() == values.size());
820 data::data_expression_list::const_iterator val = values.begin();
821 for (
auto param_signature : var_param_signatures) {
822 if (data::is_variable(*val))
824 const variable& value = atermpp::down_cast<variable>(*val);
825 std::string value_signature = get_param_signature(value);
826 if (param_signature != value_signature || L.find(value_signature) != L.end())
828 result.insert(param_signature);
833 result.insert(param_signature);
835 if (val != values.end()) {
846 std::set<std::string> result;
849 result = reset(pbes_system::accessors::arg(phi), d);
853 std::set<std::string> l = reset(pbes_system::accessors::left(phi), d);
854 result.insert(l.begin(), l.end());
855 std::set<std::string> r = reset(pbes_system::accessors::right(phi), d);
856 result.insert(r.begin(), r.end());
860 result = reset(pbes_system::accessors::arg(phi), d);
864 std::set<std::string> params;
865 std::vector<std::string> var_params =
866 variable_parameter_signatures[atermpp::down_cast<propositional_variable_instantiation>(phi).name()];
867 for (
auto signature : var_params) {
868 params.insert(signature);
870 for (
const auto& signature: d)
872 if (params.find(signature) == params.end())
874 result.insert(signature);
904std::set<std::string>
lts_info::occ(
const pbes_expression& expr)
906 std::set<std::string> result;
909 result.insert(atermpp::down_cast<propositional_variable_instantiation>(expr).name());
913 std::set<std::string> l = occ(pbes_system::accessors::left(expr));
914 result.insert(l.begin(), l.end());
915 std::set<std::string> r = occ(pbes_system::accessors::right(expr));
916 result.insert(r.begin(), r.end());
920 result = occ(pbes_system::accessors::arg(expr));
926std::set<std::string>
lts_info::free(
const pbes_expression& expr)
928 std::set<std::string> result;
929 for (
const data::variable& var: pbes_system::find_free_variables(expr))
931 result.insert(get_param_signature(var));
939 std::set<std::string> emptySet;
940 return used(expr, emptySet);
946 std::set<std::string> result;
949 std::set<std::string> fv = free(expr);
950 result.insert(fv.begin(), fv.end());
954 data::variable_list var_params =
955 variable_parameters[atermpp::down_cast<propositional_variable_instantiation>(expr).name()];
956 data::data_expression_list values = atermpp::down_cast<propositional_variable_instantiation>(expr).parameters();
957 assert(var_params.size() == values.size());
958 data::data_expression_list::const_iterator val = values.begin();
959 for (
const auto& parameter: var_params)
961 std::string param_signature = get_param_signature(parameter);
962 if (data::is_variable(*val))
964 const variable& value = atermpp::down_cast<variable>(*val);
965 std::string value_signature = get_param_signature(value);
966 if (param_signature != value_signature || L.find(value_signature) != L.end())
968 result.insert(value_signature);
974 std::set<std::string> l = used(atermpp::down_cast<pbes_expression>(*val), L);
975 result.insert(l.begin(), l.end());
977 if (val != values.end())
985 std::set<std::string> l = used(pbes_system::accessors::left(expr), L);
986 result.insert(l.begin(), l.end());
987 std::set<std::string> r = used(pbes_system::accessors::right(expr), L);
988 result.insert(r.begin(), r.end());
992 result = used(pbes_system::accessors::arg(expr), L);
996 std::set<std::string> LL;
997 LL.insert(L.begin(), L.end());
998 data::variable_list vars = quantifier_variables(expr);
999 for (
const auto& variable: vars)
1001 LL.insert(get_param_signature(variable));
1003 result = used(pbes_system::accessors::arg(expr), LL);
1011 std::set<std::string> emptySet;
1012 return copied(expr, emptySet);
1018 std::set<std::string> result;
1025 data::variable_list var_params =
1026 variable_parameters[atermpp::down_cast<propositional_variable_instantiation>(expr).name()];
1027 data::data_expression_list values = atermpp::down_cast<propositional_variable_instantiation>(expr).parameters();
1028 assert(var_params.size() == values.size());
1029 data::data_expression_list::const_iterator val = values.begin();
1030 for (
const auto& parameter: var_params)
1032 std::string param_signature = get_param_signature(parameter);
1033 if (data::is_variable(*val))
1035 const variable& value = atermpp::down_cast<variable>(*val);
1036 std::string value_signature = get_param_signature(value);
1037 if (param_signature == value_signature && L.find(value_signature) == L.end())
1039 result.insert(value_signature);
1042 if (val != values.end())
1050 std::set<std::string> l = copied(pbes_system::accessors::left(expr), L);
1051 result.insert(l.begin(), l.end());
1052 std::set<std::string> r = copied(pbes_system::accessors::right(expr), L);
1053 result.insert(r.begin(), r.end());
1057 result = copied(pbes_system::accessors::arg(expr), L);
1061 std::set<std::string> LL;
1062 LL.insert(L.begin(), L.end());
1063 data::variable_list vars = quantifier_variables(expr);
1064 for (
const auto& variable: vars)
1066 LL.insert(get_param_signature(variable));
1068 result = copied(pbes_system::accessors::arg(expr), LL);
1077 std::stringstream ss;
1078 operation_type type = detail::map_at(get_variable_types(), state.get_variable());
1079 ss << (type==parity_game_generator::operation_type::PGAME_AND ?
"AND" :
"OR");
1080 ss <<
":" << state.get_variable();
1082 const std::vector<data_expression>& param_values = state.get_parameter_values();
1083 std::vector<std::string> param_signatures =
1084 this->variable_parameter_signatures[state.get_variable()];
1085 std::vector<std::string>::const_iterator param_signature =
1086 param_signatures.begin();
1087 for (std::vector<data_expression>::const_iterator param_value =
1088 param_values.begin(); param_value != param_values.end(); ++param_value) {
1089 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 (
const auto& parameter: params)
1111 result.insert(get_param_signature(parameter));
1117std::vector<std::string>
lts_info::get_param_sequence(
const data::variable_list& params)
1119 std::vector<std::string> result;
1120 for (
const auto& parameter: params)
1122 result.push_back(get_param_signature(parameter));
1130 std::vector<
int> result;
1131 for (
const auto& parameter: params)
1133 int index =
this->get_index(get_param_signature(parameter));
1134 result.push_back(index);
1142 std::map<
int,
int> result;
1144 for (
const auto& parameter: params)
1146 int index =
this->get_index(get_param_signature(parameter));
1147 result.insert(std::make_pair(index, i));
1157std::string
lts_info::get_param_signature(
const variable& param)
1159 std::map<variable,std::string>::const_iterator i = variable_signatures.find(param);
1160 if (i == variable_signatures.end())
1162 std::string paramname = param.name();
1163 std::string paramtype = core::pp(param.sort());
1164 std::string signature = get_param_signature(paramname, paramtype);
1165 variable_signatures[param] = signature;
1172std::string
lts_info::get_param_signature(
const std::string& paramname,
1173 const std::string& paramtype)
1175 return paramname +
":" + paramtype;
1185 this->var = varname;
1193 this->var = varname;
1195 assert(std::string(atermpp::down_cast<propositional_variable_instantiation>(e).name()) == varname);
1196 const data::data_expression_list& values = atermpp::down_cast<propositional_variable_instantiation>(e).parameters();
1197 for (
const auto & value : values)
1199 if (value == novalue)
1201 throw(std::runtime_error(
"Error in ltsmin_state: state expression contains NoValue: "
1204 this->add_parameter_value(value);
1207 throw(std::runtime_error(
"Not a valid state expression! " + pp(e)));
1213 if (
this->var < other.var)
1217 else if (
this->var == other.var)
1219 if (param_values.size() < other.param_values.size())
1223 else if (param_values.size() == other.param_values.size())
1225 if (param_values < other.param_values)
1237 return this->var==other.var
1238 && param_values.size()==other.param_values.size()
1239 && param_values == other.param_values;
1251 return param_values;
1257 param_values.push_back(value);
1263 data::data_expression_vector parameter_values;
1264 for (
const auto & param_value : param_values) {
1265 parameter_values.push_back(param_value);
1267 data::data_expression_list parameter_values_list(parameter_values.begin(), parameter_values.end());
1270 propositional_variable_instantiation(core::identifier_string(var), parameter_values_list);
1278 std::stringstream ss;
1279 ss << (type==parity_game_generator::operation_type::PGAME_AND ?
"AND" :
"OR");
1281 ss <<
"[" << std::endl;
1282 for (std::vector<data_expression>::const_iterator entry =
1283 param_values.begin(); entry != param_values.end(); ++entry) {
1284 if (entry != param_values.begin())
1286 ss << std::endl <<
" value = ";
1300explorer::
explorer(
const std::string& filename,
const std::string& rewrite_strategy =
"jittyc",
bool reset_flag =
false,
bool always_split_flag =
false)
1302 load_pbes(p, filename);
1303 pbes_system::algorithms::normalize(p);
1304 if (!detail::is_ppg(p))
1306 mCRL2log(log::log_level_t::info) <<
"Rewriting to PPG..." << std::endl;
1307 p = detail::to_ppg(p);
1308 mCRL2log(log::log_level_t::info) <<
"Rewriting done." << std::endl;
1310 this->pgg =
new detail::pbes_greybox_interface(p,
true,
true, data::parse_rewrite_strategy(rewrite_strategy));
1311 this->info =
new lts_info(p, pgg, reset_flag, always_split_flag);
1312 for (std::size_t i = 0; i < info->get_lts_type().get_number_of_state_types(); ++i) {
1313 std::map<data_expression,
int> data2int_map;
1314 this->localmaps_data2int.push_back(data2int_map);
1315 std::vector<data_expression> int2data_map;
1316 this->localmaps_int2data.push_back(int2data_map);
1321explorer::
explorer(
const pbes& p_,
const std::string& rewrite_strategy =
"jittyc",
bool reset_flag =
false,
bool always_split_flag =
false)
1324 this->pgg =
new detail::pbes_greybox_interface(p,
true,
true, data::parse_rewrite_strategy(rewrite_strategy));
1325 this->info =
new lts_info(p, pgg, reset_flag, always_split_flag);
1326 for (std::size_t i = 0; i < info->get_lts_type().get_number_of_state_types(); i++) {
1327 std::map<data_expression,
int> data2int_map;
1328 this->localmaps_data2int.push_back(data2int_map);
1329 std::vector<data_expression> int2data_map;
1330 this->localmaps_int2data.push_back(int2data_map);
1367 std::string varname = expr.name();
1375 return ltsmin_state(
"true");
1381 return ltsmin_state(
"false");
1388 return atermpp::down_cast<data::data_expression>(data::detail::add_index(
static_cast<
const atermpp::aterm&>(t)));
1396 return get_string_index(s);
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;
1415 this->localmap_string2int.insert(std::make_pair(s,index));
1417 return static_cast<
int>(index);
1423 std::map<data_expression,
int>& data2int_map =
this->localmaps_data2int.at(type_no);
1424 std::map<data_expression,
int>::iterator it = data2int_map.find(value);
1426 if (it != data2int_map.end()) {
1429 this->localmaps_int2data.at(type_no).push_back(value);
1430 index =
this->localmaps_int2data.at(type_no).size() - 1;
1431 data2int_map.insert(std::make_pair(value,index));
1433 return static_cast<
int>(index);
1443 std::string varname = dst_state.get_variable();
1444 std::string src_varname;
1445 bool same_var =
false;
1446 if (!(src==
nullptr)) {
1447 src_varname = src_state.get_variable();
1448 same_var = (varname==src_varname);
1454 varindex =
this->get_string_index(varname);
1460 std::vector < data_expression > values(state_length);
1464 for (
int i = 1; i < state_length; i++) {
1466 values[i] = default_value;
1468 dst[i] =
this->get_value_index(type_no, values[i]);
1471 for (
int i = 1; i < state_length; i++) {
1476 const std::vector<data_expression>& parameter_values = dst_state.get_parameter_values();
1477 std::vector<
int> parameter_indices =
1478 detail::map_at(info->get_variable_parameter_indices(), varname);
1479 std::vector<std::string> parameter_signatures =
1480 detail::map_at(info->get_variable_parameter_signatures(), varname);
1481 std::vector<std::string>::iterator param_signature = parameter_signatures.begin();
1482 int value_index = 0;
1483 for(
int & parameter_indice : parameter_indices)
1485 int i = parameter_indice + 1;
1486 int type_no = info->get_lts_type().get_state_type_no(i);
1487 values[i] = parameter_values[value_index];
1488 if (values[i]==novalue)
1494 dst[i] =
this->get_value_index(type_no, values[i]);
1500 std::map<
int,
int> src_param_index_positions = detail::map_at(info->get_variable_parameter_index_positions(), src_state.get_variable());
1501 std::map<
int,
int>::iterator src_param_index_position_it = src_param_index_positions.find(parameter_indice);
1502 if ( src_param_index_position_it != src_param_index_positions.end()
1503 && src_state.get_parameter_values()[src_param_index_position_it->second] == values[i])
1510 dst[i] =
this->get_value_index(type_no, values[i]);
1514 if (param_signature != parameter_signatures.end())
1522 throw(std::runtime_error(
"Error in to_state_vector: NoValue in parameters of dst_state: "
1523 + info->state_to_string(dst_state) +
"."));
1532 return this->get_string_value(index);
1545 if (std::cmp_greater_equal(index ,(localmap_int2string.size())))
1547 throw(std::runtime_error(
"Error in get_string_value: Value not found for index " + std::to_string(index) +
"."));
1549 return localmap_int2string.at(index);
1555 std::vector<data_expression>& int2data_map =
this->localmaps_int2data.at(type_no);
1556 if (std::cmp_greater_equal(index ,(int2data_map.size())))
1558 throw(std::runtime_error(
"Error in get_data_value: Value not found for type_no "
1559 + std::to_string(type_no) +
" at index " + std::to_string(index) +
"."));
1561 return int2data_map.at(index);
1570 std::string varname =
this->get_string_value(src[0]);
1575 std::vector <data_expression> values(state_length);
1578 for (
int i = 1; i < state_length; i++) {
1580 values[i] =
this->get_data_value(type_no, src[i]);
1582 data::data_expression_vector parameters;
1583 std::vector<
int> parameter_indices =
1584 detail::map_at(info->get_variable_parameter_indices(), varname);
1585 for (
int & parameter_indice : parameter_indices) {
1586 if (values[parameter_indice+1]==novalue)
1590 parameters.push_back(values[parameter_indice+1]);
1594 throw(std::runtime_error(
"Error in from_state_vector: NoValue in parameters."));
1596 data::data_expression_list paramlist(parameters.begin(), parameters.end());
1605 std::vector<ltsmin_state> result;
1608 assert(
core::
detail::check_term_PropVarInst(e));
1609 if (state.get_variable()==
"true")
1612 result.push_back(state);
1614 else if (state.get_variable()==
"false")
1617 result.push_back(state);
1621 std::set<pbes_expression> successors
1622 = pgg->get_successors(e);
1623 operation_type type =
detail::map_at(
info->get_variable_types(), state.get_variable());
1624 for (
const auto & successor : successors) {
1625 if (is_propositional_variable_instantiation(successor)) {
1626 result.push_back(get_state(atermpp::down_cast<propositional_variable_instantiation>(successor)));
1627 }
else if (is_true(successor)) {
1628 if (type != parity_game_generator::operation_type::PGAME_AND)
1630 result.push_back(true_state());
1632 }
else if (is_false(successor)) {
1633 if (type != parity_game_generator::operation_type::PGAME_OR)
1635 result.push_back(false_state());
1638 throw(std::runtime_error(
"!! Successor is NOT a propvar: " + pbes_system::pp(successor)));
1649 std::vector<ltsmin_state> result;
1651 if (group == 0 && state.get_variable()==
"true")
1654 result.push_back(state);
1656 else if (group == 1 && state.get_variable()==
"false")
1659 result.push_back(state);
1663 std::string varname = state.get_variable();
1664 std::string group_varname = info->get_transition_variable_names()[group];
1665 if (varname==group_varname)
1668 std::set<pbes_expression> successors
1669 = pgg->get_successors(e, group_varname,
1670 info->get_transition_expressions()[group]);
1671 operation_type type =
detail::map_at(
info->get_variable_types(), state.get_variable());
1672 for (
const auto & successor : successors) {
1673 if (is_propositional_variable_instantiation(successor)) {
1674 result.push_back(get_state(atermpp::down_cast<propositional_variable_instantiation>(successor)));
1675 }
else if (is_true(successor)) {
1676 if (type != parity_game_generator::operation_type::PGAME_AND)
1678 result.push_back(true_state());
1680 }
else if (is_false(successor)) {
1681 if (type != parity_game_generator::operation_type::PGAME_OR)
1683 result.push_back(false_state());
1686 throw(std::runtime_error(
"!! Successor is NOT a propvar: " + pbes_system::pp(successor)));
A unordered_map class in which aterms can be stored.
Components for generating an arbitrary element of a sort.
representative_generator(const data_specification &specification)
Constructor with data specification as context.
propositional_variable_instantiation get_initial_state() override
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...
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, 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::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.
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.
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::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 a string representation of the state.
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 a string representation of the propositional variable of the state.
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...
operation_type
The operation type of the vertices.
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
\brief A propositional variable declaration
#define mCRL2log(LEVEL)
mCRL2log(LEVEL) provides the stream used to log.
atermpp::aterm remove_index(const atermpp::aterm &x)
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)
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)
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_()