mCRL2
Loading...
Searching...
No Matches
parity_game_generator.h
Go to the documentation of this file.
1// Author(s): Wieger Wesselink
2// Copyright: see the accompanying file COPYING or copy at
3// https://github.com/mCRL2org/mCRL2/blob/master/COPYING
4//
5// Distributed under the Boost Software License, Version 1.0.
6// (See accompanying file LICENSE_1_0.txt or copy at
7// http://www.boost.org/LICENSE_1_0.txt)
8//
9/// \file mcrl2/pbes/parity_game_generator.h
10/// \brief A class for generating a parity game from a pbes.
11
12#ifndef MCRL2_PBES_PARITY_GAME_GENERATOR_H
13#define MCRL2_PBES_PARITY_GAME_GENERATOR_H
14
15#include "mcrl2/pbes/algorithms.h"
16#include "mcrl2/pbes/detail/bes_equation_limit.h"
17#include "mcrl2/pbes/join.h"
18#include "mcrl2/pbes/rewriters/enumerate_quantifiers_rewriter.h"
19#include <iomanip>
20
21namespace mcrl2
22{
23
24namespace pbes_system
25{
26
27/// \brief Class for generating a BES from a PBES. This BES can be interpreted as
28/// a graph corresponding to a parity game problem. The proposition variables
29/// of the BES correspond to the vertices of the graph.
30/// An interface to the graph is provided in which the vertices correspond to
31/// integer values. The values are in the range [0, 1, ..., n], i.e. there are
32/// no holes in the sequence.
33/// Each vertex is labeled with a priority value, which is the
34/// block nesting depth of the proposition variable in the BES.
36{
37 protected:
38 /// \brief Substitution function type used by the PBES rewriter.
40
41 /// \brief Mark whether initialization has been initialized.
42 /// Needed to properly cope with virtual inheritance!
44
45 /// \brief The PBES that is being solved.
47
48 /// \brief Data rewriter.
50
51 /// \brief PBES rewriter.
53
54 /// \brief Maps propositional variables to corresponding PBES equations.
56
57 /// \brief Maps propositional variables to corresponding priorities.
59
60 /// \brief Maps PBES closed expressions to corresponding BES variables.
62
63 /// \brief Contains intermediate results of the BES that is being generated.
64 /// m_bes[i] represents a BES equation corresponding to BES variable i.
65 /// m_bes[i].first is the right hand side of the BES equation
66 /// m_bes[i].second is the block nesting depth of the corresponding PBES variable
68
69 /// \brief Determines what kind of BES equations are generated for true and false.
71
72 /// \brief True if it is a min-parity game.
74
75 /// \brief The maximum priority value of the game.
76 std::size_t m_max_priority = 0;
77
78 /// \brief Adds a BES equation for a given PBES expression, if it not already exists.
79 /// \param t A PBES expression
80 /// \param priority A positive integer
81 /// \return The index of a BES equation corresponding to the given PBES expression.
82 /// If no equation exists for the expression, a new one is added.
83 std::size_t add_bes_equation(pbes_expression t, std::size_t priority)
84 {
85 std::size_t result;
86
87 mCRL2log(log::trace) << "Adding equation for " << t << std::endl;
88
89 // TODO: can this insertion be done more efficiently?
90 auto i = m_pbes_expression_index.find(t);
91 if (i != m_pbes_expression_index.end())
92 {
93 result = i->second;
94 }
95 else
96 {
97 std::size_t p = m_pbes_expression_index.size();
98 m_pbes_expression_index[t] = p;
100 {
101 priority = m_priorities[atermpp::down_cast<propositional_variable_instantiation>(t).name()];
102 }
103 m_bes.emplace_back(t, priority);
104 detail::check_bes_equation_limit(m_bes.size());
105 mCRL2log(log::status) << print_equation_count(m_bes.size());
106 result = p;
107 }
108
109 return result;
110 }
111
112 /// \brief Generates a substitution function for the pbesinst rewriter.
113 /// \param v A sequence of data variables
114 /// \param e A sequence of data expressions
115 /// \param sigma The result.
117 {
118 assert(v.size() == e.size());
119 data::variable_list::iterator i = v.begin();
120 data::data_expression_list::iterator j = e.begin();
121 for (; i != v.end(); ++i, ++j)
122 {
123 sigma[*i] = *j;
124 }
125 }
126
128 {
129 // expand the right hand side if needed
131 {
132 const auto& psi1 = atermpp::down_cast<propositional_variable_instantiation>(psi);
133 const pbes_equation& pbes_eqn = *m_pbes_equation_index[psi1.name()];
135 make_substitution(pbes_eqn.variable().parameters(), psi1.parameters(), sigma);
136 mCRL2log(log::trace) << "Expanding right hand side " << pbes_eqn.formula() << " into " << std::flush;
137 pbes_expression result = R(pbes_eqn.formula(), sigma);
138 R.clear_identifier_generator();
139 mCRL2log(log::trace) << result << std::endl;
140 return result;
141 }
142 return psi;
143 }
144
145 /// \brief Compute equation index map.
147 {
148
149 for (std::vector<pbes_equation>::const_iterator i = m_pbes.equations().begin(); i != m_pbes.equations().end(); ++i)
150 {
151 m_pbes_equation_index[i->variable().name()] = i;
152 }
153 }
154
155 /// \brief Compute priorities of PBES propositional variables.
156 void compute_priorities(const std::vector<pbes_equation>& equations)
157 {
159 std::size_t priority = 0;
160 for (const auto& equation: equations)
161 {
162 if (equation.symbol() == sigma)
163 {
164 m_priorities[equation.variable().name()] = priority;
165 }
166 else
167 {
168 sigma = equation.symbol();
169 m_priorities[equation.variable().name()] = ++priority;
170 }
171 }
172
173 m_max_priority = (priority % 2 == 0 ? priority : priority + 1);
174
175 // If it is a max-priority game, adjust the priorities
177 {
178 // Choose an even upperbound max_priority
179 if (m_max_priority == 0)
180 {
181 m_max_priority = 2;
182 }
183 for (auto& i: m_priorities)
184 {
185 i.second = m_max_priority - i.second;
186 }
187 // Add BES equations for true and false with priorities 0 and 1.
190 }
191 else
192 {
193 // Add BES equations for true and false with priorities 0 and 1.
196 }
197 }
198
199 // prints the BES equation with left hand side 'index' and right hand side 'rhs'
200 virtual
201 std::string print_bes_equation(std::size_t index, const std::set<std::size_t>& rhs)
202 {
203 std::ostringstream out;
204 const std::pair<pbes_expression, std::size_t>& eqn = m_bes[index];
205 const std::size_t priority = eqn.second;
206 out << (priority % 2 == 1 ? "mu Y" : "nu Y") << index << " = ";
207 std::string op = (get_operation(index) == PGAME_AND ? " && " : " || ");
208 for (auto i = rhs.begin(); i != rhs.end(); ++i)
209 {
210 out << (i == rhs.begin() ? "" : op) << "Y" << *i;
211 }
212 out << " (priority = " << priority << ")" << std::endl;
213 return out.str();
214 }
215
216 /// \brief Prints a log message for every step-th equation
217 std::string print_equation_count(std::size_t size, std::size_t step = 1000) const
218 {
219 if (size > 0 && (size % step == 0 || (size < 1000 && size % 100 == 0)))
220 {
221 std::ostringstream out;
222 out << "Generated " << size << " BES equations" << std::endl;
223 return out.str();
224 }
225 return "";
226 }
227
228 virtual
230 {
231 if (m_initialized)
232 {
233 return;
234 }
235 else
236 {
237 // Nothing to be done for an empty PBES.
238 if (m_pbes.equations().empty())
239 {
240 return;
241 }
242
243 // Normalize the pbes, since the parity game generator currently doesn't handle negation and implication.
245
247 compute_priorities(m_pbes.equations());
248
249 // Add a BES equation for the initial state.
251 add_bes_equation(phi, m_priorities[phi.name()]);
252
253 m_initialized = true;
254 }
255 }
256
257 public:
258 /// \brief The operation type of the vertices.
260
261 /// \brief Constructor.
262 /// \param p A PBES
263 /// \param true_false_dependencies If true, nodes are generated for the values <tt>true</tt> and <tt>false</tt>.
264 /// \param is_min_parity If true a min-parity game is produced, otherwise a max-parity game
265 /// \param rewrite_strategy Strategy to use for the data rewriter
266 explicit parity_game_generator(pbes& p, bool true_false_dependencies = false, bool is_min_parity = true, data::rewriter::strategy rewrite_strategy = data::jitty)
267 :
268 m_initialized(false),
269 m_pbes(p),
271 R(datar, p.data()),
272 m_true_false_dependencies(true_false_dependencies),
273 m_is_min_parity_game(is_min_parity)
274 {
276 }
277
278 virtual ~parity_game_generator() = default;
279
280 /// \brief Returns the (rewritten) initial state.
281 /// \return the initial state rewritten by R
283 {
284 return atermpp::down_cast<propositional_variable_instantiation>(R(m_pbes.initial_state()));
285 }
286
287 /// \brief Returns the vertex type.
288 /// \param index A positive integer
289 /// \return PGAME_AND if the corresponding BES equation is a conjunction,
290 /// PGAME_OR if it is a disjunction.
291 virtual
293 {
295
296 assert(index < m_bes.size());
297 const pbes_expression& phi = m_bes[index].first;
299 }
300
301 /// \brief Returns the vertex type.
302 /// \param phi A PBES expression
303 /// \return PGAME_AND if the expression is a conjunction,
304 /// PGAME_OR if it is a disjunction.
305 virtual
307 {
308 if (is_and(phi))
309 {
310 return PGAME_AND;
311 }
312 else if (is_or(phi))
313 {
314 return PGAME_OR;
315 }
317 {
318 return PGAME_OR;
319 }
320 else if (is_true(phi))
321 {
322 return PGAME_AND;
323 }
324 else if (is_false(phi))
325 {
326 return PGAME_OR;
327 }
328 else if (is_forall(phi))
329 {
330 return PGAME_AND;
331 }
332 else if (is_exists(phi))
333 {
334 return PGAME_OR;
335 }
336 else if (is_data(phi))
337 {
338 return PGAME_OR;
339 }
340 throw(std::runtime_error("Error in parity_game_generator: unexpected operation " + pbes_system::pp(phi)));
341 }
342
343 /// \brief Returns the priority of a vertex.
344 /// The priority of the first equation is 0 if it is a maximal fixpoint,
345 /// and 1 if it is a minimal fixpoint.
346 /// \param index A positive integer
347 /// \return The block nesting depth of the variable in the BES.
348 virtual
349 std::size_t get_priority(std::size_t index)
350 {
352
353 assert(index < m_bes.size());
354 return m_bes[index].second;
355 }
356
357 /// \brief Returns the vertices for which a solution is requested.
358 /// By default a set containing the values 0, 1 and 2 is returned, corresponding
359 /// to the expressions true, false and the initial state of the PBES.
360 /// \return A set of indices corresponding to proposition variables of the generated BES.
361 virtual
363 {
365
366 std::set<std::size_t> result;
367 if (!m_pbes.equations().empty())
368 {
369 result.insert(0); // equation 0 corresponds with the value true
370 result.insert(1); // equation 1 corresponds with the value false
371 result.insert(2); // equation 2 corresponds with the initial state
372 }
373 return result;
374 }
375
376 /// \brief Returns the successors of a vertex in the graph.
377 /// \param index A positive integer
378 /// \return The indices of the proposition variables that appear in the
379 /// right hand side of the BES equation of the given index.
380 virtual
382 {
384
385 assert(index < m_bes.size());
386
387 std::set<std::size_t> result;
388
389 std::pair<pbes_expression, std::size_t>& eqn = m_bes[index];
390 pbes_expression& psi = eqn.first;
391 const std::size_t priority = eqn.second;
392
393 mCRL2log(log::debug) << std::endl << "Generating equation for expression " << psi << std::endl;
394
395 // expand the right hand side if needed
396 psi = expand_rhs(psi);
397
398 // top_flatten
400 {
401 result.insert(add_bes_equation(psi, m_priorities[atermpp::down_cast<propositional_variable_instantiation>(psi).name()]));
402 }
403 else if (is_and(psi))
404 {
405 for (const pbes_expression& term: split_and(psi))
406 {
407 auto prio = is_or(term) ? (m_is_min_parity_game ? m_max_priority : 0) : priority;
408 result.insert(add_bes_equation(term, prio));
409 }
410 }
411 else if (is_or(psi))
412 {
413 for (const pbes_expression& term: split_or(psi))
414 {
415 auto prio = is_and(term) ? (m_is_min_parity_game ? m_max_priority : 0) : priority;
416 result.insert(add_bes_equation(term, prio));
417 }
418 }
419 else if (is_true(psi))
420 {
422 {
423 auto i = m_pbes_expression_index.find(true_());
424 assert(i != m_pbes_expression_index.end());
425 result.insert(i->second);
426 }
427 }
428 else if (is_false(psi))
429 {
431 {
432 auto i = m_pbes_expression_index.find(false_());
433 assert(i != m_pbes_expression_index.end());
434 result.insert(i->second);
435 }
436 }
437 else
438 {
439 std::ostringstream out;
440 out << "Error in parity_game_generator: unexpected expression " << psi << "\n" << atermpp::aterm(psi);
441 throw(std::runtime_error(out.str()));
442 }
443 mCRL2log(log::debug) << print_bes_equation(index, result);
444 return result;
445 }
446
447 /// \brief Prints the mapping from BES variables to the corresponding PBES expressions.
448 virtual
450 {
451 mCRL2log(log::info) << "--- variable mapping ---" << std::endl;
452 std::map<std::size_t, pbes_expression> m;
453 for (auto& i: m_pbes_expression_index)
454 {
455 m[i.second] = i.first;
456 }
457 for (auto& i: m)
458 {
459 mCRL2log(log::info) << std::setw(4) << i.first << " " << i.second << std::endl;
460 }
461 mCRL2log(log::info) << "--- priorities ---" << std::endl;
462 for (auto& i: m_priorities)
463 {
464 mCRL2log(log::info) << core::pp(i.first) << " " << i.second << std::endl;
465 }
466 }
467};
468
469} // namespace pbes_system
470
471} // namespace mcrl2
472
473#endif // MCRL2_PBES_PARITY_GAME_GENERATOR_H
aterm_string(const std::string &s)
Constructor that allows construction from a string.
aterm(const aterm &other) noexcept=default
This class has user-declared copy constructor so declare default copy and move operators.
bool operator!=(const unprotected_aterm_core &t) const
Inequality operator on two unprotected aterms.
Definition aterm_core.h:92
Components for generating an arbitrary element of a sort.
representative_generator(const data_specification &specification)
Constructor with data specification as context.
Rewriter that operates on data expressions.
Definition rewriter.h:81
basic_rewriter< data_expression >::substitution_type substitution_type
Definition rewriter.h:114
\brief A data variable
Definition variable.h:28
const core::identifier_string & name() const
Definition variable.h:38
const sort_expression & sort() const
Definition variable.h:43
logger(const log_level_t l)
Default constructor.
Definition logger.h:164
std::set< pbes_expression > get_successors(const pbes_expression &phi)
Returns the successors of a state, which is a instantiated propositional variable....
virtual std::string print_successors(const std::set< pbes_expression > &successors)
Prints the set of successors states.
pbes_greybox_interface(pbes &p, bool true_false_dependencies=false, bool is_min_parity=true, data::rewriter::strategy rewrite_strategy=data::jitty)
Constructor.
pbes_system::enumerate_quantifiers_rewriter pbes_rewriter
pbes_equation get_pbes_equation(const core::identifier_string &s)
Returns the equation for variable s.
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.
virtual pbes_expression expand_group(const pbes_expression &psi, const pbes_expression &expr)
Expands a formula expr for a instantiated state variable psi, which means substituting the variables ...
virtual bool visit_inner_bounded_exists(const pbes_expression &e)
Visits a bounded existential quantifier expression within a disjunctive expression.
Definition ppg_visitor.h:97
virtual bool visit_inner_implies(const pbes_expression &e)
Visits a disjunctive expression within an inner universal quantifier expression.
virtual bool visit_or(const pbes_expression &e)
Visits a disjunctive expression.
static std::string print_brief(const pbes_expression &e)
Returns a string representation of the type of the root node of the expression.
Definition ppg_visitor.h:43
virtual bool visit_and(const pbes_expression &e)
Visits a conjunctive expression.
virtual bool visit_propositional_variable(const pbes_expression &e)
Visits a propositional variable expression.
Definition ppg_visitor.h:62
bqnf_visitor bqnf
The BQNF visitor type.
Definition ppg_visitor.h:30
virtual bool visit_inner_and(const pbes_expression &e)
Visits a conjunctive expression within an inner existential quantifier expression.
Definition ppg_visitor.h:76
virtual bool visit_ppg_expression(const pbes_expression &e)
Visits a PPG expression.
virtual bool visit_inner_bounded_forall(const pbes_expression &e)
Visits a bounded universal quantifier expression within a conjunctive expression.
virtual bool visit_simple_expression(const pbes_expression &e)
Visits a simple expression. An expression is simple if it does not contain propositional variables.
Definition ppg_visitor.h:52
\brief The existential quantification operator for pbes expressions
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< std::vector< data_expression > > localmaps_int2data
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...
std::string data_to_string(const data::data_expression &e)
Returns a string representation for the data expression e.
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....
std::vector< std::string > localmap_int2string
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.
std::map< std::string, int > localmap_string2int
void next_state_long(int *const &src, int group, callback &cb)
Iterates over the successors of a state for a certain transition group and invokes a callback functio...
explorer(const pbes &p_, const std::string &rewrite_strategy, bool reset_flag, bool always_split_flag)
Constructor.
std::vector< std::map< data_expression, int > > localmaps_data2int
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....
void next_state_all(int *const &src, callback &cb)
Iterates over the successors of a state and invokes a callback function for each successor state.
detail::pbes_greybox_interface * pgg
the PBES greybox interface
static fixpoint_symbol nu()
Returns the nu symbol.
fixpoint_symbol & operator=(fixpoint_symbol &&) noexcept=default
static fixpoint_symbol mu()
Returns the mu symbol.
\brief The universal quantification operator for pbes expressions
\brief The implication operator for pbes expressions
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 ...
std::map< std::string, int > variable_priority
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.
static std::vector< std::string > get_param_sequence(const data::variable_list &params)
Converts a variable_sequence_type into a sequence of parameter signatures.
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 &params)
Converts a variable_sequence_type into a sequence of indices of parameter signatures in the list of p...
std::vector< std::string > transition_variable_name
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
std::map< std::string, fixpoint_symbol > variable_symbol
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.
std::map< std::string, int > param_index
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...
std::map< std::string, std::vector< std::string > > variable_parameter_signatures
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...
std::map< int, std::vector< bool > > read_matrix
std::vector< data_expression > param_default_values
detail::pbes_greybox_interface * pgg
bool is_read_dependent_propvar(int group)
Determines if group is read dependent on the propositional variable. Returns true,...
std::vector< pbes_expression > transition_expression
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.
std::map< std::string, std::map< int, int > > variable_parameter_index_positions
static std::string get_param_signature(const variable &param)
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...
std::map< std::string, propositional_variable > variables
int get_number_of_groups() const
Returns the number of transition groups.
static std::set< std::string > get_param_set(const data::variable_list &params)
Converts a variable_sequence_type into a set of parameter signatures.
std::map< int, int > get_param_index_positions(const data::variable_list &params)
Converts a variable_sequence_type into a map from indices of parameter signatures (in the list of par...
static std::set< std::string > occ(const pbes_expression &expr)
Computes the propositional variables used in an expression.
std::map< std::string, operation_type > variable_type
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::vector< operation_type > transition_type
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.
std::map< std::string, data::variable_list > variable_parameters
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::map< int, std::vector< bool > > matrix
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 &paramname, const std::string &paramtype)
Returns a signature using name and type of a parameter.
static std::set< std::string > free(const pbes_expression &expr)
Computes the free variables read in an expression.
std::vector< pbes_expression > transition_expression_plain
std::map< int, std::vector< bool > > write_matrix
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::map< std::string, pbes_expression > variable_expression
std::set< std::string > changed(const pbes_expression &phi)
Computes the set of parameters changed in the expression.
std::map< std::string, std::vector< int > > variable_parameter_indices
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.
std::vector< std::string > state_type_list
std::vector< std::string > state_label_types
std::vector< std::string > state_names
std::vector< int > state_type_no
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.
std::map< std::string, int > state_type_index
std::vector< std::string > edge_label_names
const std::vector< std::string > & get_state_label_types() const
Returns the sequence of state label types.
std::vector< std::string > edge_label_types
std::vector< std::string > state_types
std::size_t get_number_of_edge_labels() const
Returns the number of edge labels.
std::vector< std::string > state_label_names
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::vector< data_expression > param_values
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.
\brief The not operator for pbes expressions
Class for generating a BES from a PBES. This BES can be interpreted as a graph corresponding to a par...
void compute_priorities(const std::vector< pbes_equation > &equations)
Compute priorities of PBES propositional variables.
std::vector< std::pair< pbes_expression, std::size_t > > m_bes
Contains intermediate results of the BES that is being generated. m_bes[i] represents a BES equation ...
virtual operation_type get_expression_operation(const pbes_expression &phi)
Returns the vertex type.
parity_game_generator(pbes &p, bool true_false_dependencies=false, bool is_min_parity=true, data::rewriter::strategy rewrite_strategy=data::jitty)
Constructor.
virtual void print_variable_mapping()
Prints the mapping from BES variables to the corresponding PBES expressions.
std::map< core::identifier_string, std::size_t > m_priorities
Maps propositional variables to corresponding priorities.
void compute_equation_index_map()
Compute equation index map.
pbes_expression expand_rhs(const pbes_expression &psi)
virtual operation_type get_operation(std::size_t index)
Returns the vertex type.
bool m_true_false_dependencies
Determines what kind of BES equations are generated for true and false.
virtual propositional_variable_instantiation get_initial_state()
Returns the (rewritten) initial state.
std::string print_equation_count(std::size_t size, std::size_t step=1000) const
Prints a log message for every step-th equation.
std::map< core::identifier_string, std::vector< pbes_equation >::const_iterator > m_pbes_equation_index
Maps propositional variables to corresponding PBES equations.
std::map< pbes_expression, std::size_t > m_pbes_expression_index
Maps PBES closed expressions to corresponding BES variables.
std::size_t m_max_priority
The maximum priority value of the game.
pbes_system::enumerate_quantifiers_rewriter R
PBES rewriter.
void make_substitution(const data::variable_list &v, const data::data_expression_list &e, substitution_function &sigma) const
Generates a substitution function for the pbesinst rewriter.
pbes & m_pbes
The PBES that is being solved.
virtual std::size_t get_priority(std::size_t index)
Returns the priority of a vertex. The priority of the first equation is 0 if it is a maximal fixpoint...
virtual std::set< std::size_t > get_initial_values()
Returns the vertices for which a solution is requested. By default a set containing the values 0,...
virtual std::string print_bes_equation(std::size_t index, const std::set< std::size_t > &rhs)
operation_type
The operation type of the vertices.
data::rewriter::substitution_type substitution_function
Substitution function type used by the PBES rewriter.
bool m_is_min_parity_game
True if it is a min-parity game.
std::size_t add_bes_equation(pbes_expression t, std::size_t priority)
Adds a BES equation for a given PBES expression, if it not already exists.
bool m_initialized
Mark whether initialization has been initialized. Needed to properly cope with virtual inheritance!
virtual std::set< std::size_t > get_dependencies(std::size_t index)
Returns the successors of a vertex in the graph.
const pbes_expression & formula() const
Returns the predicate formula on the right hand side of the equation.
const fixpoint_symbol & symbol() const
Returns the fixpoint symbol of the equation.
const propositional_variable & variable() const
Returns the pbes variable of the equation.
pbes_expression & operator=(pbes_expression &&) noexcept=default
pbes_expression & operator=(const pbes_expression &) noexcept=default
parameterized boolean equation system
Definition pbes.h:58
propositional_variable_instantiation & initial_state()
Returns the initial state.
Definition pbes.h:199
\brief A propositional variable instantiation
const data::data_expression_list & parameters() const
\brief A propositional variable declaration
const data::variable_list & parameters() const
const core::identifier_string & name() const
propositional_variable(const core::identifier_string &name, const data::variable_list &parameters)
\brief Constructor Z12.
Standard exception class for reporting runtime errors.
Definition exception.h:27
#define mCRL2log(LEVEL)
mCRL2log(LEVEL) provides the stream used to log.
Definition logger.h:391
The main namespace for the aterm++ library.
Definition algorithm.h:21
std::string pp(const atermpp::aterm &t)
Transform an aterm to an ascii string.
Definition aterm.h:440
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)
Definition io.h:55
atermpp::aterm remove_index(const atermpp::aterm &x)
Definition io.h:61
Namespace for all data library functionality.
Definition data.cpp:22
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
@ verbose
Definition logger.h:37
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.
void instantiate_global_variables(pbes &p)
Attempts to eliminate the free variables of a PBES, by substituting a constant value for them....
Definition pbes.cpp:65
void normalize(pbes &x)
The function normalize brings (embedded) pbes expressions into positive normal form,...
static void inc_indent()
Increases the current indent level.
static void indent()
Indents according to the current indent level.
static void dec_indent()
Decreases the current indent level.
static int indent_count
The current indent level. Used for debug output.
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_non_simple_conjunct(const pbes_expression &t)
Test for a conjunction.
bool is_forall(const atermpp::aterm &x)
std::string pp(const pbes_system::pbes_expression &x)
Definition pbes.cpp:44
bool is_pbes_or(const pbes_expression &t)
Returns true if the term t is an or expression.
bool is_false(const pbes_expression &t)
Test for the value false.
std::vector< pbes_expression > split_disjuncts(const pbes_expression &expr, bool split_simple_expr=false)
Splits a disjunction into a sequence of operands. Given a pbes expression of the form p1 || p2 || ....
bool is_pbes_and(const pbes_expression &t)
Returns true if the term t is an and expression.
std::vector< pbes_expression > split_conjuncts(const pbes_expression &expr, bool split_simple_expr=false)
Splits a conjunction into a sequence of operands Given a pbes expression of the form p1 && p2 && ....
bool is_propositional_variable_instantiation(const atermpp::aterm &x)
bool is_and(const atermpp::aterm &x)
std::string print_brief(const T &x)
Returns a string representation of the root node of a PBES.
bool is_non_simple_disjunct(const pbes_expression &t)
Test for a disjunction.
bool is_imp(const atermpp::aterm &x)
bool is_simple_expression(const T &x)
Determines if an expression is a simple expression. An expression is simple if it is free of proposit...
bool is_true(const pbes_expression &t)
Test for the value true.
const pbes_expression & false_()
A visitor class for PBES equations in BQNF. There is a visit_<node> function for each type of node....
bool debug
flag that indicates if debug output should be printed.
virtual bool visit_bqnf_equation(const pbes_equation &eqn)
Visits a BQNF equation.
virtual bool visit_inner_bounded_exists(const fixpoint_symbol &sigma, const propositional_variable &var, const pbes_expression &e)
Visits a bounded existential quantifier expression within a disjunctive expression.
static std::string print_brief(const pbes_expression &e)
Returns a string representation of the type of the root node of the expression.
virtual bool visit_bounded_forall(const fixpoint_symbol &sigma, const propositional_variable &var, const pbes_expression &e)
Visits a bounded universal quantifier expression.
virtual bool visit_bounded_quantifier(const fixpoint_symbol &sigma, const propositional_variable &var, const pbes_expression &e)
Visits a bounded quantifier expression.
virtual bool visit_inner_and(const fixpoint_symbol &sigma, const propositional_variable &var, const pbes_expression &e)
Visits a conjunctive expression within an inner existential quantifier expression.
virtual bool visit_propositional_variable(const fixpoint_symbol &, const propositional_variable &, const pbes_expression &e)
Visits a propositional variable expression.
static bool is_inner_implies(const pbes_expression &e)
Determines if an expression if of the form phi => psi or of the form phi \/ psi where phi is a simple...
virtual bool visit_simple_expression(const fixpoint_symbol &sigma, const propositional_variable &var, const pbes_expression &e)
Visits a simple expression. An expression is simple if it does not contain propositional variables.
virtual bool visit_bqnf_expression(const pbes_expression &e)
Visits a BQNF expression. In the current BQNF visitor sigma and var parameters are added for use in b...
virtual bool visit_and(const fixpoint_symbol &sigma, const propositional_variable &var, const pbes_expression &e)
Visits a conjunctive expression.
virtual bool visit_bqnf_expression(const fixpoint_symbol &sigma, const propositional_variable &var, const pbes_expression &e)
Visits a BQNF expression.
static bool is_inner_and(const pbes_expression &e)
Determines if an expression if of the form phi /\ psi where phi is a simple expression and psi is an ...
virtual bool visit_or(const fixpoint_symbol &sigma, const propositional_variable &var, const pbes_expression &e)
Visits a disjunctive expression.
virtual bool visit_bqnf_equation_debug(const pbes_equation &eqn)
Visits a BQNF equation in debug mode.
virtual bool visit_bounded_exists(const fixpoint_symbol &sigma, const propositional_variable &var, const pbes_expression &e)
Visits a bounded existential quantifier expression.
virtual bool visit_inner_bounded_forall(const fixpoint_symbol &sigma, const propositional_variable &var, const pbes_expression &e)
Visits a bounded universal quantifier expression within a conjunctive expression.
Visitor for printing the root node of a PBES.
void apply(const pbes_equation &x)
void apply(const propositional_variable_instantiation &x)
pbes_expression_traverser< print_brief_traverser > super
std::size_t operator()(const atermpp::detail::reference_aterm< T > &t) const