mCRL2
Loading...
Searching...
No Matches
pbes_explorer.h
Go to the documentation of this file.
1// Author(s): Gijs Kant
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/pbes_explorer.h
10/// \brief
11#ifndef MCRL2_PBES_PBES_EXPLORER_H
12#define MCRL2_PBES_PBES_EXPLORER_H
13
14#include "mcrl2/pbes/detail/pbes_greybox_interface.h"
15#include "mcrl2/pbes/detail/ppg_rewriter.h"
16#include "mcrl2/pbes/detail/ppg_traverser.h"
17
18using mcrl2::data::data_expression;
19using mcrl2::data::variable;
20
21
22
23namespace mcrl2::pbes_system
24{
25
26namespace detail
27{
28 template <typename MapContainer>
29 typename MapContainer::mapped_type map_at(const MapContainer& m, typename MapContainer::key_type key);
30} // namespace detail
31
32
33
34/// \brief
35class lts_type {
46
47public:
48 /// \brief Contructor.
49 /// \param state_length
50 lts_type(int state_length);
51
52 /// \brief Destructor.
54
55 /// \brief Returns the state length.
56 int get_state_length() const;
57
58 /// \brief Returns the number of state types.
60
61 /// \brief Returns the sequence of state part names.
62 const std::vector<std::string>& get_state_names() const;
63
64 /// \brief Returns the sequence of state part types.
65 const std::vector<std::string>& get_state_types() const;
66
67 /// \brief Returns the state type index for the state part <tt>part</tt>.
68 /// \param part the state part number.
69 int get_state_type_no(int part) const;
70
71 /// \brief Returns the name of the state type with number <tt>type_no</tt>.
72 /// \param type_no the state type number.
74
75 /// \brief Returns the number of state labels.
77
78 /// \brief Returns the sequence of state labels.
79 const std::vector<std::string>& get_state_labels() const;
80
81 /// \brief Returns the sequence of state label types.
82 const std::vector<std::string>& get_state_label_types() const;
83
84 /// \brief Returns the number of edge labels.
86
87 /// \brief Returns the sequence of edge labels.
88 const std::vector<std::string>& get_edge_labels() const;
89
90 /// \brief Returns the sequence of edge label types.
91 const std::vector<std::string>& get_edge_label_types() const;
92
93 /// \brief Adds a state part of type <tt>type</tt> with name <tt>name</tt>.
94 /// \param name the name of the state part.
95 /// \param type the type of the state part.
96 void add_state(const std::string& name, const std::string& type);
97
98 /// \brief Adds a state label of type <tt>type</tt> with name <tt>name</tt>.
99 /// \param name the name of the state label.
100 /// \param type the type of the state label.
101 void add_state_label(const std::string& name, const std::string& type);
102
103 /// \brief Adds an edge label of type <tt>type</tt> with name <tt>name</tt>.
104 /// \param name the name of the edge label.
105 /// \param type the type of the edge label.
106 void add_edge_label(const std::string& name, const std::string& type);
107};
108
109
110
111
112/// \brief
114
115friend class lts_info;
116friend class explorer;
117
118public:
119 using operation_type = parity_game_generator::operation_type;
120
121private:
122 int priority = 0; // Priority (depends on fixpoint operator and equation order)
123 std::string var; // Propositional variable name
124 operation_type type; // player or type (And/Or, Abelard/Eloise, Odd/Even)
125 std::vector<data_expression> param_values; // List of parameter values
126
127protected:
128 /// \brief Constructor.
129 /// \param varname the propositional variable of the state.
130 /// \param e a propositional variable instantiation.
131 ltsmin_state(const std::string& varname, const pbes_expression& e);
132
133 /// \brief Returns the list of parameter values.
135
136 /// \brief Adds a parameter value to the list of parameter values.
138
139 /// \brief Returns a PBES expression representing the state.
141
142public:
143 /// \brief Constructor.
144 /// \param varname the name of the propositional variable of the state.
145 ltsmin_state(const std::string& varname);
146
147 /// \brief Compares two PBES_State objects. Uses lexicographical ordering on priority, type, variable and parameter values.
148 /// \param other an other PBES_State object.
149 /// \return true if this.priority < other.priority || (this.priority==other.priority && (this.type < other.type ||
150 /// (this.type==other.type && this.var < other.var || (this.var==other.var && this.param_values < other.param_values) ) ) ).
151 bool operator<( const ltsmin_state& other ) const;
152
153 /// \brief Checks if two PBES_State objects are equal.
154 /// \param other an other PBES_State object.
155 /// \return true if this.priority==other.priority && this.type==other.type && this.var==other.var
156 /// && param_values==param_values.
157 bool operator==( const ltsmin_state& other ) const;
158
159
160 /// \brief Returns a string representation of the propositional variable of the state.
161 std::string get_variable() const;
162
163 /// \brief Returns a string representation of the state.
164 std::string state_to_string() const;
165};
166
167
168
169
170/// \brief
171class lts_info {
172
173friend class ltsmin_state;
174friend class explorer;
175
176public:
177 /// \brief The variable sequence type
178 using operation_type = parity_game_generator::operation_type;
179private:
185 std::map<int,std::vector<bool> > read_matrix;
187 std::map<int,std::vector<bool> > matrix;
204
206
207 /// \brief Counts the number of propositional variables in an expression.
208 /// \returns the number of variable occurences or INT_MAX if a variable
209 /// occurs within the scope of a quantifier.
210 int count_variables(const pbes_expression& e);
211
212 /// \brief Determines if the propositional variable instantiation is one that
213 /// only copies parameters from the current state.
215
216 /// \brief Splits the expression into parts (disjuncts or conjuncts) and recursively tries to
217 /// substitute the propositional variables with the parts of the right hand side of the
218 /// equation for the variable.
219 /// \param e the expression
220 /// \param current_priority the priority of the current equation for which the parts are computed
221 /// \param current_type the operation type (AND/OR) of the current equation for which the parts are computed
222 /// \param vars_stack used for detection of infinite recursion. Please, initialise to the empty set.
224
225 /// \brief Computes LTS Type from PBES.
226 void compute_lts_type();
227
228 /// \brief Computes transition groups from PBES.
230
231 /// \brief Computes dependency matrix from PBES.
233
234protected:
235
236 /// \brief Returns the map from transition group number to the expression of the transition group.
238
239 /// \brief Returns the map from variable names to the variable object for the variable.
241
242 /// \brief Returns the map from variable names to the fixpoint operator of the equation for the variable.
244
245 /// \brief Returns the map from variable names to the sequence of parameters for the variable.
247
248 /// \brief Determines if the term phi contains a branch that directly results in
249 /// <tt>true</tt> or <tt>false</tt> (not a variable).
250 /// \param phi a PBES expression
251 static bool tf(const pbes_expression& phi);
252
253 /// \brief Computes the propositional variables used in an expression.
254 /// \param expr
255 static std::set<std::string> occ(const pbes_expression& expr);
256
257 /// \brief Computes the free variables read in an expression.
258 /// \param expr
259 static std::set<std::string> free(const pbes_expression& expr);
260
261 /// \brief Computes the free variables actually used, not only passed through, in an expression.
262 /// \param expr
264
265 /// \brief Computes the free variables actually used, not only passed through, in an expression.
266 /// \param expr
267 /// \param L
268 std::set<std::string> used(const pbes_expression& expr, const std::set<std::string>& L);
269
270 /// \brief Computes the free variables which are copied/passed through (to a recursive variable) in an expression.
271 /// \param expr
273
274 /// \brief Computes the free variables which are copied/passed through (to a recursive variable) in an expression.
275 /// \param expr
276 /// \param L
277 std::set<std::string> copied(const pbes_expression& expr, const std::set<std::string>& L);
278
279 /// \brief Computes the set of parameters changed in the expression.
280 /// \param phi
282
283 /// \brief Computes the set of parameters changed in the expression.
284 /// \param phi
285 /// \param L
286 std::set<std::string> changed(const pbes_expression& phi, const std::set<std::string>& L);
287
288 /// \brief Computes the set of parameters reset in the expression.
289 /// \param phi
290 /// \param d
291 std::set<std::string> reset(const pbes_expression& phi, const std::set<std::string>& d);
292
293 /// \brief Converts a variable_sequence_type into a set of parameter signatures.
294 /// \param params a sequence of variables.
296
297 /// \brief Converts a variable_sequence_type into a sequence of parameter signatures.
298 /// \param params a sequence of variables.
300
301 /// \brief Converts a variable_sequence_type into a sequence of indices of parameter signatures
302 /// in the list of parameter signatures for the system.
303 /// \param params a sequence of variables.
305
306 /// \brief Converts a variable_sequence_type into a map from indices of parameter signatures
307 /// (in the list of parameter signatures for the system) to the index of the type of the parameter
308 /// (in the list of types for the system).
309 /// \param params a sequence of variables.
311
312 /// \brief Returns a signature for parameter <tt>param</tt>.
313 /// \param param a parameter.
314 static inline std::string get_param_signature(const variable& param);
315
316 /// \brief Returns a default value for the sort of a parameter signature.
317 /// \param index the index of the parameter signature.
318 /// \return a default value for the sort of the parameter.
319 const data_expression& get_default_value(int index);
320
321 /// \brief Constructor
322 /// \param p
323 /// \param pgg
324 /// \param reset
325 /// \param always_split
326 lts_info(pbes& p, detail::pbes_greybox_interface* pgg, bool reset, bool always_split);
327
328public:
329
330 /// \brief Returns if the reset option is set.
331 bool get_reset_option() const;
332
333 /// \brief Returns the number of transition groups.
334 int get_number_of_groups() const;
335
336 /// \brief Returns the map from transition group number to the variable name of the equation to which
337 /// the transition group belongs.
339
340 /// \brief Returns the map from transition group number to the type of the right hand side of the
341 /// equation to which the transition group belongs.
343
344 /// \brief Returns the map from variable names to the type of the right hand side of the equation for
345 /// the variable.
347
348 /// \brief Returns the map from variable names to the priority of the equation for the variable.
349 const std::map<std::string, int>& get_variable_priorities() const;
350
351 /// \brief Returns the map from variable names to the list of parameters signatures for the variable.
353
354 /// \brief Returns the map from variable names to the list of indices of the parameters signatures for the variable
355 /// according the order in the list of parameter signatures for the system.
356 const std::map<std::string, std::vector<int> >& get_variable_parameter_indices() const;
357
358 /// \brief Returns the map from variable names to the map from indices of parameter signatures for the variable
359 /// (according to the list of parameter signatures for the system) to the index of the type of the parameter
360 /// (in the list of types for the system).
361 const std::map<std::string, std::map<int,int> >& get_variable_parameter_index_positions() const;
362
363 /// \brief Returns the LTS Type.
364 const lts_type& get_lts_type() const;
365
366 /// \brief Returns the dependency matrix.
367 const std::map<int,std::vector<bool> >& get_dependency_matrix() const;
368
369 /// \brief Returns the read dependency matrix.
370 const std::map<int,std::vector<bool> >& get_read_matrix() const;
371
372 /// \brief Returns the write dependency matrix.
373 const std::map<int,std::vector<bool> >& get_write_matrix() const;
374
375 /// \brief Returns the index for a parameter signature in the list of parameter signatures
376 /// for the system.
377 /// \param signature The parameter signature.
378 int get_index(const std::string& signature);
379
380 /// \brief Determines if <tt>group</tt> is read dependent on the propositional variable.
381 /// Returns true, because the propositional variable is needed to determine if the group belongs
382 /// to the variable.
383 /// \param group the number of the transition group.
384 /// \return true.
385 bool is_read_dependent_propvar(int group);
386
387 /// \brief Determines if <tt>group</tt> is read dependent on part <tt>part</tt> of the state vector.
388 /// Returns true if the parameter represented by <tt>part</tt> is in the set of parameters of the
389 /// state variable for the group or in the set of data variables used in the expression of for the group.
390 /// \param group the number of the transition group.
391 /// \param part the number of the state part.
392 /// \return true if param_part in ( params(var(group)) union used(expr(group)) ).
393 bool is_read_dependent_parameter(int group, int part);
394
395 /// \brief Determines if <tt>group</tt> is write dependent on the propositional variable.
396 /// Returns true if propositional variables other than the group variable occur in the group expression
397 /// or the group expression may directly evaluate to <tt>true</tt> or <tt>false</tt>.
398 /// \param group the number of the transition group.
399 /// \return true if ( occ(expr(group)) - {var(group)} ) is not empty or tf(expr(group)).
400 bool is_write_dependent_propvar(int group);
401
402 /// \brief Determines if <tt>group</tt> is read dependent on part <tt>part</tt> of the state vector.
403 /// Returns true if the parameter represented by <tt>part</tt> is in the set of data variables
404 /// changed by the expression for the group.
405 /// \param group the number of the transition group.
406 /// \param part the number of the state part.
407 /// \return true if param_part in changed(expr(group)).
408 bool is_write_dependent_parameter(int group, int part);
409
410 /// \brief Returns a string representation for state <tt>state</tt>.
411 /// \param state
413
414 /// \brief Returns a signature using name and type of a parameter.
415 /// \param paramname the parameter name.
416 /// \param paramtype the parameter type.
417 static inline std::string get_param_signature(const std::string& paramname, const std::string& paramtype);
418};
419
420
421
422
423/// \brief
424class explorer {
425
426public:
427 /// \brief The expression type of the equation.
428 using operation_type = parity_game_generator::operation_type;
429
430private:
437
438protected:
439 /// \brief Returns a PBES_State object for <tt>expr</tt>.
440 /// \param expr a propositional variable instantiation expression.
442
443 /// \brief Returns a string representation for the data expression <tt>e</tt>.
444 /// \param e a PBES expression that may be in internal format.
445 /// \return a string representation without internal rewriter quirks.
447
448 /// \brief Returns a data expression for the string representation <tt>s</tt>.
449 /// \param s a string representation of a data expression.
450 /// \return the data expression (possibly in internal format) that s represents.
451 data::data_expression string_to_data(const std::string& s);
452
453 /// \brief Returns the index of <tt>value</tt> in the local store for the data type
454 /// with number <tt>type_no</tt>.
455 /// The value is added to the store if it is not already present.
456 /// \param type_no the number of the value type.
457 /// \param value the data value.
458 /// \return the index of <tt>value</tt> in local store <tt>type_no</tt>.
459 int get_value_index(int type_no, const data_expression& value);
460
461 /// \brief Returns the value at position <tt>index</tt> in the local store for the data type
462 /// with number <tt>type_no</tt>.
463 /// An exception is thrown if the index does not exist in the store.
464 /// \param type_no the number of the value type.
465 /// \param index an index.
466 /// \return the value at position <tt>index</tt> in local store <tt>type_no</tt>.
467 const data_expression& get_data_value(int type_no, int index);
468
469 /// \brief the PBES greybox interface
471
472public:
473 /// \brief Constructor.
474 /// \param filename the name of a PBES file.
475 /// \param rewrite_strategy the name of the data rewrite strategy to use.
476 /// \param reset_flag if set, irrelevant parts of the state vector will be reset to a default value
477 /// \param always_split_flag if set, equations will always be split into conjuncts or disjuncts to form transition groups,
478 /// if not set (default) the explorer assumes the pbes to be generated with lps2pbes -p and splits accordingly.
479 explorer(const std::string& filename, const std::string& rewrite_strategy, bool reset_flag, bool always_split_flag);
480
481 /// \brief Constructor.
482 /// \param p_ a PBES.
483 /// \param rewrite_strategy String representing the rewrite strategy to use for the data rewriter.
484 /// \param reset_flag if set, irrelevant parts of the state vector will be reset to a default value
485 /// \param always_split_flag if set, equations will always be split into conjuncts or disjuncts to form transition groups,
486 /// if not set (default) the explorer assumes the pbes to be generated with lps2pbes -p and splits accordingly.
487 explorer(const pbes& p_, const std::string& rewrite_strategy, bool reset_flag, bool always_split_flag);
488
489 /// \brief Destructor.
490 ~explorer();
491
492 /// \brief Returns the PBES_Info object.
493 lts_info* get_info() const;
494
495 /// \brief Returns the initial state.
497
498 void initial_state(int* state);
499
500 /// \brief Returns the state representing <tt>true</tt>.
501 static inline ltsmin_state true_state();
502
503 /// \brief Returns the state representing <tt>false</tt>.
504 static inline ltsmin_state false_state();
505
506 /// \brief Returns the index of <tt>value</tt> in the local store for the data type
507 /// with number <tt>type_no</tt>. Type 0 is reserved for the string representations
508 /// of variable names.
509 /// The value is added to the store if it is not already present.
510 /// \param type_no The number of the value type.
511 /// \param s A string representation of the data value.
512 /// \return The index of <tt>value</tt> in local store <tt>type_no</tt>.
513 int get_index(int type_no, const std::string& s);
514
515 /// \brief Returns the index of <tt>s</tt> in the local store for string values.
516 /// This store is reserved for the string representations of variable names.
517 /// The value is added to the store if it is not already present.
518 /// \param s The string for which the index needs to be retrieved.
519 /// \return the index of <tt>s</tt> in the local store for string values.
520 int get_string_index(const std::string& s);
521
522 /// \brief Transforms a PBES state to a state vector, represented by an array of integers.
523 /// \param dst_state the new PBES state object
524 /// \param dst the int array to which the state vector is written
525 /// \param src_state the source PBES state object, used to check which fields have been changed.
526 /// \param src an array which is used for default values, to prevent unused variables for being reset.
527 /// the non-resetting behaviour can be turned off by the --reset option.
528 void to_state_vector(const ltsmin_state& dst_state, int* dst, const ltsmin_state& src_state, int* const& src);
529
530 /// \brief Returns the value at position <tt>index</tt> in the local store for the data type
531 /// with number <tt>type_no</tt>. Type 0 is reserved for the string representations
532 /// of variable names.
533 /// An exception is thrown if the index does not exist in the store.
534 /// \param type_no the number of the value type.
535 /// \param index an index.
536 /// \return a string representation of the value at position <tt>index</tt> in local store <tt>type_no</tt>.
537 std::string get_value(int type_no, int index);
538
539 /// \brief Returns the string at position <tt>index</tt> in the local store for string values.
540 /// An exception is thrown if the index does not exist in the store.
541 /// \param index an index.
542 /// \return the string value at position <tt>index</tt> in the local store for string values.
543 const std::string& get_string_value(int index);
544
545 /// \brief Transforms a state vector <tt>src</tt> into a PBES_State object
546 /// object containing the variable and parameter values that are represented
547 /// by the indices in <tt>src</tt>.
548 /// \param src an int array containg the indices of the state values.
549 /// \return a PBES_State object containing the variable and parameter values that are represented
550 /// by the indices in <tt>src</tt>.
551 ltsmin_state from_state_vector(int* const& src);
552
553 /// \brief Computes successor states for a state. Serves as a wrapper around the get_successors
554 /// function of the pbes_greybox_interface.
555 /// \param state the source state.
556 /// \return a list of successor states.
558
559 /// \brief Iterates over the successors of a state and invokes a callback
560 /// function for each successor state.
561 /// \param src an int array containg the indices of the state values.
562 /// \param cb a callback function that must provide the function operator() with the following interface:
563 ///
564 /// \code
565 /// void operator()(int* const& next_state, int group);
566 /// \endcode
567 /// where
568 /// - next_state is the target state of the transition
569 /// - group is the number of the transition group, or -1 if it is unknown which group
570 template <typename callback>
571 void next_state_all(int* const& src, callback& cb)
572 {
573 int state_length = this->info->get_lts_type().get_state_length();
574 ltsmin_state state = this->from_state_vector(src);
575 std::vector<ltsmin_state> successors = this->get_successors(state);
576 // int dst[state_length]; N.B. This is not portable C++
577 int* dst = MCRL2_SPECIFIC_STACK_ALLOCATOR(int, state_length);
578 for (auto & successor : successors) {
579
580 this->to_state_vector(successor, dst, state, src);
581 cb(dst);
582 }
583 }
584
585 /// \brief Computes successor states for a state as defined in transition group <tt>group</tt>.
586 /// Serves as a wrapper around the get_successors function of the pbes_greybox_interface.
587 /// \param state the source state.
588 /// \param group the group for which the successor states are computed.
589 /// \return a list of successor states.
591
592 /// \brief Iterates over the successors of a state for a certain transition group
593 /// and invokes a callback function for each successor state.
594 /// \param src an int array containg the indices of the state values.
595 /// \param group the transition group
596 /// \param cb a callback function that must provide the function operator() with the following interface:
597 ///
598 /// \code
599 /// void operator()(int* const& next_state, int group);
600 /// \endcode
601 /// where
602 /// - next_state is the target state of the transition
603 /// - group is the number of the transition group, or -1 if it is unknown which group
604 template <typename callback>
605 void next_state_long(int* const& src, int group, callback& cb)
606 {
607 int state_length = this->info->get_lts_type().get_state_length();
608 std::string group_varname = info->get_transition_variable_names()[group];
609 std::string varname = this->get_string_value(src[0]);
610 if (varname==group_varname)
611 {
612 ltsmin_state state = this->from_state_vector(src);
613 std::vector<ltsmin_state> successors = this->get_successors(state, group);
614 // int dst[state_length]; N.B. This is not portable C++
615 int* dst = MCRL2_SPECIFIC_STACK_ALLOCATOR(int, state_length);
616 for (auto & successor : successors) {
617 this->to_state_vector(successor, dst, state, src);
618 cb(dst, group);
619 }
620 }
621 }
622
623};
624
625} // namespace mcrl2::pbes_system
626
627
628
629#endif // MCRL2_PBES_PBES_EXPLORER_H
A unordered_map class in which aterms can be stored.
Components for generating an arbitrary element of a sort.
representative_generator(const data_specification &specification)
Constructor with data specification as context.
\brief A data variable
Definition variable.h:25
\brief The and operator for pbes expressions
const pbes_expression & left() const
const pbes_expression & right() const
propositional_variable_instantiation get_initial_state() override
Returns the initial state, rewritten and simplified.
pbes_expression rewrite_and_simplify_expression(const pbes_expression &e, const bool=true)
Rewrites and simplifies an expression.
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
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...
operation_type
The operation type of the vertices.
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=(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:195
\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:393
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.
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.
static std::regex negative("Zneg_(\\d+)_.*")
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.
static void indent()
Indents according to the current indent level.
static std::regex positive("Zpos_(\\d+)_.*")
static void dec_indent()
Decreases the current indent level.
bool is_counter_example_variable(const propositional_variable &X)
static std::regex positive_or_negative("Z(neg|pos)_(\\d+)_.*")
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)
bool is_pbes_file_format(const utilities::file_format &format)
Definition io.h:26
bool is_data(const pbes_expression &t)
Returns true if the term t is a data expression.
void load_pbes(pbes &pbes, std::istream &stream, utilities::file_format format, const std::string &)
Load a PBES from file.
Definition io.cpp:83
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
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)
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)
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
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.
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_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)
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)
subsitute_counterexample(bool replace_Lplus, bool replace_Lminus)
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