12#include "mcrl2/pbes/io.h"
13#include "mcrl2/pbes/join.h"
14#include "mcrl2/pbes/normal_forms.h"
27template <
typename Iter>
30 std::set<std::size_t> variables_int;
31 for (Iter i = first; i != last; ++i)
34 variable_map::const_iterator j = variables.find(b.name());
35 if (j == variables.end())
39 variables_int.insert(j->second);
41 return utilities::string_join(variables_int,
", ");
52 std::set<pbes_expression> expressions = split_and(p);
53 result = boolean_variables2pgsolver(expressions.begin(), expressions.end(), variables);
57 std::set<pbes_expression> expressions = split_or(p);
58 result = boolean_variables2pgsolver(expressions.begin(), expressions.end(), variables);
63 variable_map::const_iterator i = variables.find(b.name());
64 if (i == variables.end())
66 throw mcrl2::runtime_error(
"Found undeclared variable in bes_expression2cwi: " +
pbes_system::pp(p
));
68 std::stringstream out;
74 throw mcrl2::runtime_error(
"Unknown or unsupported expression encountered in bes_expression2cwi: " +
pbes_system::pp(p
));
82template <
typename Iter>
89 std::size_t index = 0;
90 std::map<
int,
int> block_to_player;
92 bool and_in_block =
false;
95 for (Iter i = first; i != last; ++i)
97 if(i->symbol() != sigma)
99 block_to_player[block++] = (and_in_block)?1:0;
100 and_in_block =
false;
103 variables[i->variable().name()] = index++;
104 and_in_block = and_in_block || is_and(i->formula());
106 block_to_player[block] = (and_in_block)?1:0;
108 if(maxpg && block % 2 == 1)
113 out <<
"parity " << index -1 <<
";\n";
117 for (Iter i = first; i != last; ++i)
119 if(i->symbol() != sigma)
125 out << variables[i->variable().name()]
127 << (maxpg?(block-priority):priority)
129 << (is_and(i->formula()) ? 1 : (is_or(i->formula())?0:block_to_player[priority]))
131 << bes_expression2pgsolver(i->formula(), variables)
132#ifdef MCRL2_BES2PGSOLVER_PRINT_VARIABLE_NAMES
135 << pbes_systembes::pp(i->variable())
144 pbes bes_standard_form(bes);
148 std::stringstream ss;
149 ss <<
"The initial state " << bes_standard_form
.initial_state() <<
" and the left hand side "
150 "of the first equation (" << bes_standard_form.equations().front().variable() <<
") do "
151 "not correspond. Cannot save BES to PGSolver format.";
154 bes2pgsolver(bes_standard_form.equations().begin(), bes_standard_form.equations().end(), stream, maxpg);
static fixpoint_symbol nu()
Returns the nu symbol.
fixpoint_symbol & operator=(fixpoint_symbol &&) noexcept=default
parameterized boolean equation system
const propositional_variable_instantiation & initial_state() const
Returns the initial state.
propositional_variable_instantiation & initial_state()
Returns the initial state.
\brief A propositional variable instantiation
const core::identifier_string & name() const
Standard exception class for reporting runtime errors.
The main namespace for the aterm++ library.
The main namespace for the PBES library.
std::map< core::identifier_string, std::size_t > variable_map
std::string boolean_variables2pgsolver(Iter first, Iter last, const variable_map &variables)
Convert a sequence of Boolean variables to PGSolver format.
std::string pp(const pbes_system::propositional_variable_instantiation &x)
bool is_or(const atermpp::aterm &x)
void bes2pgsolver(Iter first, Iter last, std::ostream &out, bool maxpg)
Save a sequence of BES equations in to a stream in PGSolver format.
std::string pp(const pbes_system::pbes_expression &x)
void save_bes_pgsolver(const pbes &bes, std::ostream &stream, bool maxpg)
static std::string bes_expression2pgsolver(const pbes_expression &p, const variable_map &variables)
Convert a BES expression to PGSolver format.
bool is_propositional_variable_instantiation(const atermpp::aterm &x)
bool is_and(const atermpp::aterm &x)
void make_standard_form(pbes &eqn, bool recursive_form=false)
Transforms a PBES into standard form.
std::size_t operator()(const atermpp::detail::reference_aterm< T > &t) const