mCRL2
Loading...
Searching...
No Matches
enumerate_quantifiers_rewriter.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/rewriters/enumerate_quantifiers_rewriter.h
10/// \brief add your file description here.
11
12#ifndef MCRL2_PBES_REWRITERS_ENUMERATE_QUANTIFIERS_REWRITER_H
13#define MCRL2_PBES_REWRITERS_ENUMERATE_QUANTIFIERS_REWRITER_H
14
15#include <numeric>
16#include "mcrl2/atermpp/standard_containers/vector.h"
17#include "mcrl2/data/detail/split_finite_variables.h"
18#include "mcrl2/data/rewriters/enumerate_quantifiers_rewriter.h"
19#include "mcrl2/pbes/enumerator.h"
20#include "mcrl2/pbes/pbes.h"
21#include "mcrl2/pbes/rewriters/quantifier_expansion_mode.h"
22#include "mcrl2/pbes/rewriters/simplify_rewriter.h"
23#include "mcrl2/pbes/substitutions.h"
24
25namespace mcrl2::pbes_system
26{
27
28namespace detail {
29
30// Simplifying PBES rewriter that eliminates quantifiers using enumeration.
31/// \param MutableSubstitution This must be a MapSubstitution.
32template <typename Derived, typename DataRewriter, typename MutableSubstitution, typename PbesSubstitution>
33struct enumerate_quantifiers_builder: public simplify_data_rewriter_builder<Derived, DataRewriter, MutableSubstitution, PbesSubstitution>
34{
35 using super = simplify_data_rewriter_builder<Derived, DataRewriter, MutableSubstitution, PbesSubstitution>;
36 using self = enumerate_quantifiers_builder<Derived, DataRewriter, MutableSubstitution, PbesSubstitution>;
37 using enumerator_element = data::enumerator_list_element<pbes_expression>;
38 using super::enter;
39 using super::leave;
40 using super::update;
41 using super::apply;
42 using super::sigma;
43 using super::R;
44
45/* MutableSubstitution& m_sigma;
46 const DataRewriter& m_R;
47 const PbesSubstitution& m_sigma_pbes; */
49
50 /// If false, only quantifier variables over finite sorts are enumerated.
51 enumerate_quantifiers_mode m_enum_mode;
52
53 /// identifier generator
55
56 /// The enumerator
58
59 /// \brief Constructor.
60 /// \param R A data rewriter.
61 /// \param sigma A mutable substitution.
62 /// \param sigma_pbes A substitution for pbes variables.
63 /// \param dataspec A data specification.
64 /// \param id_generator A generator to generate fresh variable names.
65 /// \param enumerate_infinite_sorts If true, quantifier variables of infinite sort are enumerated as well.
66 enumerate_quantifiers_builder(const DataRewriter& R,
67 MutableSubstitution& sigma,
68 const PbesSubstitution& sigma_pbes,
69 const data::data_specification& dataspec,
71 enumerate_quantifiers_mode enum_mode = enumerate_quantifiers_mode::expand_infinite_sorts_and_use_data_rewriter )
72 : super(R, sigma, sigma_pbes),
73 // m_R(R),
74 // m_sigma(sigma),
75 // m_sigma_pbes(sigma_pbes),
76 m_dataspec(dataspec),
77 m_enum_mode(enum_mode),
78 m_id_generator(id_generator),
80
81 { }
82
83 Derived& derived()
84 {
85 return static_cast<Derived&>(*this);
86 }
87
89 {
90 atermpp::vector<data::data_expression> result;
91 for (const data::variable& v : variables)
92 {
93 result.push_back(sigma(v));
94 sigma[v] = v;
95 }
96 return result;
97 }
98
99 void redo_substitution(const data::variable_list& v, const atermpp::vector<data::data_expression>& undo)
100 {
101 assert(v.size() == undo.size());
102 auto i = v.begin();
103 auto j = undo.begin();
104 while (i != v.end())
105 {
106 sigma[*i++] = *j++;
107 }
108 }
109
110 // We assume that phi is already rewritten.
111 void enumerate_forall(pbes_expression& result, const data::variable_list& v, const pbes_expression& phi)
112 {
113 assert(!v.empty());
114 assert(&result!=&phi);
115 atermpp::vector<data::data_expression> undo = undo_substitution(v);
116 result = true_();
117 E.enumerate(enumerator_element(v, phi),
118 sigma,
119 [&](const enumerator_element& p)
120 {
121 pbes_system::make_optimized_and(result, result, p.expression());
122 return is_false(result);
123 },
124 is_true,
125 is_false
126 );
127
128 redo_substitution(v, undo);
129 }
130
131 void enumerate_exists(pbes_expression& result, const data::variable_list& v, const pbes_expression& phi)
132 {
133 assert(!v.empty());
134 assert(&result!=&phi);
135 atermpp::vector<data::data_expression> undo = undo_substitution(v);
136 result = false_();
137 E.enumerate(enumerator_element(v, phi),
138 sigma,
139 [&](const enumerator_element& p)
140 {
141 pbes_system::make_optimized_or(result, result, p.expression());
142 return is_false(result);
143 },
144 is_false,
145 is_true
146 );
147
148 redo_substitution(v, undo);
149 }
150
151 template <class T>
152 void apply(T& result, const forall& x)
153 {
154 const bool remove_unused_variables=true;
155 atermpp::vector<data::data_expression> undo = undo_substitution(x.variables());
156 derived().apply(result, x.body());
157 std::set<data::variable> free_variables = find_free_variables(result);
158 data::variable_list enumerable;
159 data::variable_list non_enumerable;
160 data::variable_list unused;
161
162 if (m_enum_mode==enumerate_quantifiers_mode::expand_finite_sorts)
163 {
164 data::detail::split_finite_variables(x.variables(), m_dataspec,
165 enumerable, non_enumerable, unused,
166 [&free_variables](const data::variable& v){ return free_variables.count(v)>0; });
167 }
168 else
169 {
170 data::detail::split_enumerable_variables(x.variables(), m_dataspec, R,
171 enumerable, non_enumerable, unused,
172 [&free_variables](const data::variable& v){ return free_variables.count(v)>0; });
173 }
174 if (enumerable.empty())
175 {
176 pbes_system::make_optimized_forall(result, non_enumerable, result, remove_unused_variables);
177 }
178 else
179 {
180 pbes_expression phi_;
181 enumerate_forall(phi_, enumerable, result);
182 if constexpr (!std::is_same_v<PbesSubstitution, no_substitution>)
183 {
184 // we need to rewrite the new body again to deal properly with PBES substitutions
185 // TODO: update enumerate_forall such that it uses the rewriter in derived() during enumeration
186 derived().apply(result, phi_);
187 }
188 else
189 {
190 result = phi_;
191 }
192 pbes_system::make_optimized_forall(result, non_enumerable, result, remove_unused_variables);
193 }
194 redo_substitution(x.variables(), undo);
195 }
196
197 template <class T>
198 void apply(T& result, const exists& x)
199 {
200 const bool remove_unused_variables=true;
201 atermpp::vector<data::data_expression> undo = undo_substitution(x.variables());
202 derived().apply(result, x.body());
203 std::set<data::variable> free_variables = find_free_variables(result);
204 data::variable_list enumerable;
205 data::variable_list non_enumerable;
206 data::variable_list unused;
207
208 if (m_enum_mode==enumerate_quantifiers_mode::expand_finite_sorts)
209 {
210 data::detail::split_finite_variables(x.variables(), m_dataspec,
211 enumerable, non_enumerable, unused,
212 [&free_variables](const data::variable& v){ return free_variables.count(v)>0; });
213 }
214 else
215 {
216 data::detail::split_enumerable_variables(x.variables(), m_dataspec, R,
217 enumerable, non_enumerable, unused,
218 [&free_variables](const data::variable& v){ return free_variables.count(v)>0; });
219 }
220 if (enumerable.empty())
221 {
222 pbes_system::make_optimized_exists(result, non_enumerable, result, remove_unused_variables);
223 }
224 else
225 {
226 pbes_expression phi_;
227 enumerate_exists(phi_, enumerable, result);
228 if constexpr (!std::is_same_v<PbesSubstitution, no_substitution>)
229 {
230 // we need to rewrite the new body again to deal properly with PBES substitutions
231 // TODO: update enumerate_exists such that it uses the rewriter in derived() during enumeration
232 derived().apply(result, phi_);
233 }
234 else
235 {
236 result = phi_;
237 }
238 pbes_system::make_optimized_exists(result, non_enumerable, phi_, remove_unused_variables);
239 }
240 redo_substitution(x.variables(), undo);
241 }
242
243 template <atermpp::IsATerm T>
244 void apply(T& result, const data::data_expression& x)
245 {
246 if (m_enum_mode==enumerate_quantifiers_mode::expand_infinite_sorts_and_use_data_rewriter)
247 {
248 R(atermpp::assign_cast<data::data_expression>(result),x,sigma);
249 }
250 else
251 {
252 data::data_expression temporary_result;
253 data::enumerate_quantifiers_rewriter(R,m_dataspec,m_id_generator,m_enum_mode==enumerate_quantifiers_mode::expand_infinite_sorts)(temporary_result, x, sigma);
254 R(atermpp::assign_cast<data::data_expression>(result),temporary_result,sigma);
255 }
256 }
257
258
259 // N.B. This function has been added to make this class operate well with the enumerator.
260 pbes_expression operator()(const pbes_expression& x, MutableSubstitution&)
261 {
262 pbes_expression result;
263 derived().apply(result, x);
264 return result;
265 }
266
267 // N.B. This function has been added to make this class operate well with the enumerator.
268 // that employs the "make_rewrite" variant with an explicit result.
269 void operator()(pbes_expression& result, const pbes_expression& x, MutableSubstitution&)
270 {
271 derived().apply(result, x);
272 }
273};
274
275template <template <class, class, class, class> class Builder, class DataRewriter, class MutableSubstitution, class PbesSubstitution = no_substitution>
277{
282 using super::enter;
283 using super::leave;
284
285 apply_enumerate_builder(const DataRewriter& R,
286 MutableSubstitution& sigma,
287 const PbesSubstitution& sigma_pbes,
288 const data::data_specification& dataspec,
290 const enumerate_quantifiers_mode enum_mode)
292 {}
293};
294
295template<template<class, class, class, class> class Builder,
296 class DataRewriter,
297 class MutableSubstitution,
298 class PbesSubstitution>
300 const DataRewriter& R,
306{
307 return apply_enumerate_builder<Builder, DataRewriter, MutableSubstitution, PbesSubstitution>(R,
308 sigma,
309 sigma_pbes,
310 dataspec,
311 id_generator,
312 enumerate_infinite_sorts);
313}
314
315template<template<class, class, class, class> class Builder,
316 class DataRewriter,
317 class MutableSubstitution>
319 const DataRewriter& R,
324{
325 return apply_enumerate_builder<Builder, DataRewriter, MutableSubstitution, no_substitution>(R,
326 sigma,
327 no_substitution(),
328 dataspec,
329 id_generator,
330 enumerate_infinite_sorts);
331}
332
333} // namespace detail
334
335/// \brief An attempt for improving the efficiency.
337{
338 protected:
339 /// \brief A data rewriter
341
342 /// \brief A data specification
344
345 /// \brief If true, quantifier variables of infinite sort are enumerated.
346 enumerate_quantifiers_mode m_enum_mode;
347
349
350 public:
351 using term_type = pbes_expression;
352 using variable_type = data::variable;
353
355 const data::data_specification& dataspec,
356 const enumerate_quantifiers_mode enum_mode = enumerate_quantifiers_mode::expand_infinite_sorts_and_use_data_rewriter)
357 : m_rewriter(R),
359 m_enum_mode(enum_mode)
360 {}
361
363 {
364 data::rewriter::substitution_type sigma;
365 pbes_expression result;
366 detail::apply_enumerate_builder<detail::enumerate_quantifiers_builder, data::rewriter, data::rewriter::substitution_type>(m_rewriter, sigma, no_substitution(), m_dataspec, m_id_generator, m_enum_mode).apply(result, x);
367 return result;
368 }
369
370 template <typename MutableSubstitution>
371 pbes_expression operator()(const pbes_expression& x, MutableSubstitution& sigma) const
372 {
373 pbes_expression result;
374 detail::apply_enumerate_builder<detail::enumerate_quantifiers_builder, data::rewriter, MutableSubstitution>(m_rewriter, sigma, no_substitution(), m_dataspec, m_id_generator, m_enum_mode).apply(result, x);
375 return result;
376 }
377
378 template <typename MutableSubstitution>
379 void operator()(pbes_expression& result, const pbes_expression& x, MutableSubstitution& sigma) const
380 {
381 detail::apply_enumerate_builder<detail::enumerate_quantifiers_builder, data::rewriter, MutableSubstitution>(m_rewriter, sigma, no_substitution(), m_dataspec, m_id_generator, m_enum_mode).apply(result, x);
382 }
383
384 template<typename MutableSubstitution, typename PbesSubstitution>
385 pbes_expression operator()(const pbes_expression& x, MutableSubstitution& sigma, const PbesSubstitution& sigma_pbes) const
386 {
387 pbes_expression result;
388 detail::apply_enumerate_builder<detail::enumerate_quantifiers_builder,
389 data::rewriter,
390 MutableSubstitution,
391 PbesSubstitution>(m_rewriter,
392 sigma,
393 sigma_pbes,
394 m_dataspec,
395 m_id_generator,
396 m_enum_mode)
397 .apply(result, x);
398 return result;
399 }
400
401 template<typename MutableSubstitution, typename PbesSubstitution>
402 void operator()(pbes_expression& result, const pbes_expression& x, MutableSubstitution& sigma, const PbesSubstitution& sigma_pbes) const
403 {
404 detail::apply_enumerate_builder<detail::enumerate_quantifiers_builder, data::rewriter, MutableSubstitution, PbesSubstitution>(
405 m_rewriter,
406 sigma,
407 sigma_pbes,
408 m_dataspec,
409 m_id_generator,
410 m_enum_mode)
411 .apply(result, x);
412 }
413
415 {
416 m_id_generator.clear();
417 }
418
419 /// \brief Create a clone of the rewriter in which the underlying rewriter is copied, and not passed as a shared pointer.
420 /// \details This is useful when the rewriter is used in different parallel processes. One rewriter can only be used sequentially.
421 /// \return A rewriter, with a copy of the underlying jitty, jittyc or jittyp rewriting engine.
423 {
424 return enumerate_quantifiers_rewriter(m_rewriter.clone(), m_dataspec, m_enum_mode);
425 }
426
427 /// \brief Initialises this rewriter with thread dependent information.
428 /// \details This function sets a pointer to the m_busy_flag and m_forbidden_flag of this.
429 /// process, such that rewriter can access these faster than via the general thread.
430 /// local mechanism. It is expected that this is not needed when compilers become.
431 /// faster, and should be removed in due time.
433 {
434 m_rewriter.thread_initialise();
435 }
436};
437
438} // namespace mcrl2::pbes_system
439
440#endif // MCRL2_PBES_REWRITERS_ENUMERATE_QUANTIFIERS_REWRITER_H
A unordered_map class in which aterms can be stored.
The default element for the todo list of the enumerator.
Definition enumerator.h:229
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:84
\brief A data variable
Definition variable.h:25
\brief The and operator for pbes expressions
and_(const pbes_expression &left, const pbes_expression &right)
\brief Constructor Z14.
const pbes_expression & left() const
const pbes_expression & right() const
std::set< pbes_expression > get_successors(const pbes_expression &phi)
Returns the successors of a state, which is a instantiated propositional variable....
pbes_greybox_interface(pbes &p, bool true_false_dependencies=false, bool is_min_parity=true, data::rewriter::strategy rewrite_strategy=data::rewrite_strategy::jitty)
Constructor.
propositional_variable_instantiation get_initial_state() override
Returns the initial state, rewritten and simplified.
virtual std::string print_successors(const std::set< pbes_expression > &successors)
Prints the set of successors states.
pbes_system::enumerate_quantifiers_rewriter pbes_rewriter
pbes_equation get_pbes_equation(const core::identifier_string &s)
Returns the equation for variable s.
pbes_expression rewrite_and_simplify_expression(const pbes_expression &e, const bool=true)
Rewrites and simplifies an expression.
std::set< pbes_expression > get_successors(const pbes_expression &phi, const std::string &var, const pbes_expression &expr)
Returns the successors of a state, which is a instantiated propositional variable,...
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:88
virtual ~ppg_visitor()=default
Destructor.
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:38
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:56
virtual bool visit_inner_and(const pbes_expression &e)
Visits a conjunctive expression within an inner existential quantifier expression.
Definition ppg_visitor.h:68
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:47
\brief The existential quantification operator for pbes expressions
const data::variable_list & variables() const
const pbes_expression & body() const
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...
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.
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
const pbes_expression & body() const
const data::variable_list & variables() const
\brief The implication operator for pbes expressions
const pbes_expression & left() const
const pbes_expression & right() const
bool is_write_dependent_propvar(int group)
Determines if group is write dependent on the propositional variable. Returns true if propositional v...
std::map< std::string, int > variable_priority
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, 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...
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::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::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 &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::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
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.
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.
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 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.
\brief The not operator for pbes expressions
const pbes_expression & operand() const
\brief The or operator for pbes expressions
const pbes_expression & left() const
or_(const pbes_expression &left, const pbes_expression &right)
\brief Constructor Z14.
const pbes_expression & right() const
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.
virtual operation_type get_expression_operation(const pbes_expression &phi)
Returns the vertex type.
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)
parity_game_generator(pbes &p, bool true_false_dependencies=false, bool is_min_parity=true, data::rewriter::strategy rewrite_strategy=data::rewrite_strategy::jitty)
Constructor.
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< 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.
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:54
propositional_variable_instantiation & initial_state()
Returns the initial state.
Definition pbes.h:194
\brief A propositional variable instantiation
const data::data_expression_list & parameters() const
\brief A propositional variable declaration
const core::identifier_string & name() const
propositional_variable(const core::identifier_string &name, const data::variable_list &parameters)
\brief Constructor Z12.
#define mCRL2log(LEVEL)
mCRL2log(LEVEL) provides the stream used to log.
Definition logger.h:435
atermpp::aterm remove_index(const atermpp::aterm &x)
Definition io.h:50
bool is_data_expression(const atermpp::aterm &x)
Test for a data_expression expression.
std::ostream & operator<<(std::ostream &out, const no_substitution &)
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.
std::set< data::variable > significant_variables(const pbes_expression &x)
Returns the significant variables of a pbes expression.
void remove_parameters(pbes &x, const std::set< data::variable > &to_be_removed)
Removes parameters from propositional variable instantiations in a pbes expression.
void remove_parameters(pbes &x, const std::map< core::identifier_string, std::vector< std::size_t > > &to_be_removed)
Removes parameters from propositional variable instantiations in a pbes expression.
void pbesinst_finite(pbes &p, data::rewrite_strategy rewrite_strategy, const std::string &finite_parameter_selection)
Apply finite instantiation to the given PBES.
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:64
bool is_normalized(const pbes &x)
Checks if a PBEs is normalized.
std::vector< propositional_variable > remove_unreachable_variables(pbes &p)
Removes equations that are not (syntactically) reachable from the initial state of a PBES.
bool is_bes(const pbes &x)
Returns true if a PBES is in BES form.
Definition pbes.cpp:69
std::string print_removed_equations(const std::vector< propositional_variable > &removed)
Print removed equations.
void normalize(pbes &x)
The function normalize brings (embedded) pbes expressions into positive normal form,...
apply_enumerate_builder< Builder, DataRewriter, MutableSubstitution, no_substitution > make_apply_enumerate_builder(const DataRewriter &R, MutableSubstitution &sigma, const data::data_specification &dataspec, data::enumerator_identifier_generator &id_generator, bool enumerate_infinite_sorts)
static void inc_indent()
Increases the current indent level.
bool is_counter_example_equation(const pbes_equation &equation)
Guesses if the PBES equation is a counter example equation.
bool is_counter_example_positive(const core::identifier_string &name)
Returns true iff the name is Zpos, name must be a counter example name.
apply_data_rewriter_with_pbes_substitution_builder< Builder, DataRewriter, MutableSubstitution, PbesSubstitution > make_apply_data_rewriter_with_pbes_substitution_builder(const DataRewriter &R, MutableSubstitution &sigma, const PbesSubstitution &sigma_pbes)
mcrl2::pbes_system::pbes remove_counterexample_info(const pbes_system::pbes &pbes, bool remove_Lplus=true, bool remove_Lminus=true, bool remove_Lequations=true)
Removes all equations and expressions related to counter examples from the input PBES.
void data_rewrite(data::data_expression &result, const data::data_expression &x, const DataRewriter &R, SubstitutionFunction &sigma)
bool is_counter_example_instantiation(const propositional_variable_instantiation &inst)
Guesses if the PBES variable instantiation is for counter example equation.
void data_rewrite(data::data_expression &result, const data::data_expression &x, const DataRewriter &R, data::no_substitution &)
bool has_counter_example_information(const pbes &pbesspec)
Guesses if a pbes has counter example information.
bool counter_example_index(const core::identifier_string &name, std::size_t &index)
Extracts the index embedded in a Zpos_<index>_.../Zneg_<index>_... counter example name.
static void indent()
Indents according to the current indent level.
static void dec_indent()
Decreases the current indent level.
bool is_counter_example_variable(const propositional_variable &X)
static int indent_count
The current indent level. Used for debug output.
apply_rewriter_builder< Builder, DataRewriter, SubstitutionFunction > make_apply_rewriter_builder(const DataRewriter &datar, SubstitutionFunction &sigma)
bool is_counter_example_name(const core::identifier_string &name)
apply_data_rewriter_with_pbes_substitution_builder< Builder, DataRewriter, MutableSubstitution, no_substitution > make_apply_data_rewriter_with_pbes_substitution_builder(const DataRewriter &R, MutableSubstitution &sigma)
MapContainer::mapped_type map_at(const MapContainer &m, typename MapContainer::key_type key)
apply_enumerate_builder< Builder, DataRewriter, MutableSubstitution, PbesSubstitution > make_apply_enumerate_builder(const DataRewriter &R, MutableSubstitution &sigma, const PbesSubstitution &sigma_pbes, const data::data_specification &dataspec, data::enumerator_identifier_generator &id_generator, bool enumerate_infinite_sorts)
The main namespace for the PBES library.
bool is_pbes_file_format(const utilities::file_format &format)
Definition io.h:26
pbes_expression join_or(FwdIt first, FwdIt last)
Returns or applied to the sequence of pbes expressions [first, last)
Definition join.h:24
bool is_data(const pbes_expression &t)
Returns true if the term t is a data expression.
pbes_expression optimized_or(const pbes_expression &p, const pbes_expression &q)
Make a disjunction.
void load_pbes(pbes &pbes, std::istream &stream, utilities::file_format format, const std::string &)
Load a PBES from file.
Definition io.cpp:83
std::set< pbes_expression > split_and(const pbes_expression &expr, bool split_data_expressions=false)
Splits a conjunction into a sequence of operands Given a pbes expression of the form p1 && p2 && ....
Definition join.h:74
void save_pbes(const pbes &pbes, const std::string &filename, utilities::file_format format, bool welltypedness_check)
save_pbes Saves a PBES to a file.
Definition io.cpp:114
const pbes_expression & true_()
bool is_not(const atermpp::aterm &x)
const utilities::file_format & pbes_format_internal_bes()
Definition io.h:43
pbes_expression optimized_join_and(FwdIt first, FwdIt last)
Returns and applied to the sequence of pbes expressions [first, last)
Definition join.h:112
pbes_expression optimized_join_or(FwdIt first, FwdIt last)
Returns or applied to the sequence of pbes expressions [first, last)
Definition join.h:96
pbes_expression join_and(FwdIt first, FwdIt last)
Returns and applied to the sequence of pbes expressions [first, last)
Definition join.h:34
void load_pbes(pbes &pbes, const std::string &filename, utilities::file_format format)
Load pbes from file.
Definition io.cpp:149
const utilities::file_format & pbes_format_pgsolver()
Definition io.h:45
bool is_exists(const atermpp::aterm &x)
utilities::file_format guess_format(const std::string &filename)
Definition io.h:47
bool is_or(const atermpp::aterm &x)
void make_optimized_forall(pbes_expression &result, const data::variable_list &l, const pbes_expression &p, bool remove_variables=false)
Make a universal quantification If l is empty, p is returned.
bool is_non_simple_conjunct(const pbes_expression &t)
Test for a conjunction.
bool is_simple_expression(const T &x, bool allow_counter_example_propvar)
Determines if an expression is a simple expression. An expression is simple if it is free of proposit...
bool is_forall(const atermpp::aterm &x)
pbes_expression optimized_and(const pbes_expression &p, const pbes_expression &q)
Make a conjunction.
const std::vector< utilities::file_format > & pbes_file_formats()
Definition io.cpp:27
void save_bes_pgsolver(const pbes &bes, std::ostream &stream, bool maxpg)
Definition pgsolver.cpp:141
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.
void save_pbes(const pbes &pbes, std::ostream &stream, utilities::file_format format)
Save a PBES in the format specified.
Definition io.cpp:50
void make_optimized_exists(pbes_expression &result, const data::variable_list &l, const pbes_expression &p, bool remove_variables=false)
Make an optimized existential quantification. If l is empty, p is returned.
bool is_simple_expression_with_cache(const T &x, bool allow_counter_example_propvar, std::map< pbes_expression, bool > &cache_true, std::map< pbes_expression, bool > &cache_false)
Determines if an expression is a simple expression using a cache. An expression is simple if it is fr...
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 && ....
const utilities::file_format & pbes_format_internal()
Definition io.h:39
bool is_propositional_variable_instantiation(const atermpp::aterm &x)
const utilities::file_format & pbes_format_text()
Definition io.h:41
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.
std::set< pbes_expression > split_or(const pbes_expression &expr, bool split_data_expressions=false)
Splits a disjunction into a sequence of operands Given a pbes expression of the form p1 || p2 || ....
Definition join.h:48
bool is_non_simple_disjunct(const pbes_expression &t)
Test for a disjunction.
bool is_imp(const atermpp::aterm &x)
bool is_true(const pbes_expression &t)
Test for the value true.
const pbes_expression & false_()
An empty struct that is used to denote the absence of a substitution. Used for rewriters.
const variable & operator()(const variable &v) const
static constexpr bool is_identity_substitution
A rewriter that applies a data rewriter to data expressions in a term.
pbes_expression operator()(const pbes_expression &x, SubstitutionFunction &sigma) const
pbes_expression operator()(const pbes_expression &x) const
data_rewriter(const DataRewriter &R_)
void apply(T &result, const data::data_expression &x)
add_data_rewriter(const DataRewriter &R_, SubstitutionFunction &sigma_)
void apply(T &result, const propositional_variable_instantiation &x)
void apply(T &result, const forall &x)
void apply(T &result, const exists &x)
void apply(T &result, const or_ &x)
void apply(T &result, const not_ &x)
void apply(T &result, const and_ &x)
apply_data_rewriter_with_pbes_substitution_builder(const DataRewriter &R, MutableSubstitution &sigma)
apply_data_rewriter_with_pbes_substitution_builder(const DataRewriter &R, MutableSubstitution &sigma, const PbesSubstitution &sigma_pbes)
apply_enumerate_builder(const DataRewriter &R, MutableSubstitution &sigma, const PbesSubstitution &sigma_pbes, const data::data_specification &dataspec, data::enumerator_identifier_generator &id_generator, const enumerate_quantifiers_mode enum_mode)
apply_rewriter_builder(const DataRewriter &datar, SubstitutionFunction &sigma)
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 ~bqnf_visitor()=default
Destructor.
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.
data_rewriter_builder(const DataRewriter &R, SubstitutionFunction &sigma)
enumerate_quantifiers_mode m_enum_mode
If false, only quantifier variables over finite sorts are enumerated.
void operator()(pbes_expression &result, const pbes_expression &x, MutableSubstitution &)
void enumerate_exists(pbes_expression &result, const data::variable_list &v, const pbes_expression &phi)
data::enumerator_identifier_generator & m_id_generator
identifier generator
void redo_substitution(const data::variable_list &v, const atermpp::vector< data::data_expression > &undo)
pbes_expression operator()(const pbes_expression &x, MutableSubstitution &)
void enumerate_forall(pbes_expression &result, const data::variable_list &v, const pbes_expression &phi)
atermpp::vector< data::data_expression > undo_substitution(const data::variable_list &variables)
enumerate_quantifiers_builder(const DataRewriter &R, MutableSubstitution &sigma, const PbesSubstitution &sigma_pbes, const data::data_specification &dataspec, data::enumerator_identifier_generator &id_generator, enumerate_quantifiers_mode enum_mode=enumerate_quantifiers_mode::expand_infinite_sorts_and_use_data_rewriter)
Constructor.
void apply_substitution(T &result, const propositional_variable_instantiation &x, const SubstitutionType &sigma)
simplify_data_rewriter_builder(const DataRewriter &R, MutableSubstitution &sigma)
void apply_substitution(T &, const propositional_variable_instantiation &, const no_substitution &)
Overload to have a trivial function in case the substitution is no_substitution.
simplify_data_rewriter_builder(const DataRewriter &R, MutableSubstitution &sigma, const PbesSubstitution &sigma_pbes)
void apply(T &result, const propositional_variable_instantiation &x)
void apply(T &result, const propositional_variable_instantiation &x)
void operator()(pbes_expression &result, const pbes_expression &x, MutableSubstitution &sigma) const
void thread_initialise()
Initialises this rewriter with thread dependent information.
pbes_expression operator()(const pbes_expression &x, MutableSubstitution &sigma, const PbesSubstitution &sigma_pbes) const
enumerate_quantifiers_mode m_enum_mode
If true, quantifier variables of infinite sort are enumerated.
enumerate_quantifiers_rewriter clone()
Create a clone of the rewriter in which the underlying rewriter is copied, and not passed as a shared...
data::data_specification m_dataspec
A data specification.
void operator()(pbes_expression &result, const pbes_expression &x, MutableSubstitution &sigma, const PbesSubstitution &sigma_pbes) const
pbes_expression operator()(const pbes_expression &x) const
enumerate_quantifiers_rewriter(const data::rewriter &R, const data::data_specification &dataspec, const enumerate_quantifiers_mode enum_mode=enumerate_quantifiers_mode::expand_infinite_sorts_and_use_data_rewriter)
pbes_expression operator()(const pbes_expression &x, MutableSubstitution &sigma) const
An empty struct that can be used to indicate that there is no substitution that should be applied to ...
Visitor for printing the root node of a PBES.
void apply(const pbes_equation &x)
void apply(const propositional_variable_instantiation &x)
A rewriter that simplifies boolean expressions in a term, and rewrites data expressions using DataRew...
pbes_expression operator()(const pbes_expression &x) const
pbes_expression operator()(const pbes_expression &x, Substitution &sigma, const PbesSubstitution &sigma_pbes) const
void operator()(pbes_expression &result, const pbes_expression &x, Substitution &sigma, const PbesSubstitution &sigma_pbes) const
void operator()(pbes_expression &result, const pbes_expression &x, Substitution &sigma) const
pbes_expression operator()(const pbes_expression &x, Substitution &sigma) const
A rewriter that simplifies boolean expressions in a term.
void operator()(pbes_expression &result, const pbes_expression &x) const
pbes_expression operator()(const pbes_expression &x, const PbesSubstitution &sigma) const
pbes_expression operator()(const pbes_expression &x) const
void operator()(pbes_expression &result, const pbes_expression &x, const PbesSubstitution &sigma) const