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//
11#ifndef MCRL2_PBES_PBES_EXPLORER_H
12#define MCRL2_PBES_PBES_EXPLORER_H
13
14#define PBES_EXPLORER_VERSION 1
15
19
22
23namespace mcrl2
24{
25
26namespace pbes_system
27{
28
29namespace detail
30{
31 template <typename MapContainer>
32 typename MapContainer::mapped_type map_at(const MapContainer& m, typename MapContainer::key_type key);
33} // namespace detail
34
35
36
38class lts_type {
40 std::vector<std::string> state_names;
41 std::vector<std::string> state_types;
42 std::vector<std::string> state_type_list;
43 std::map<std::string,int> state_type_index;
44 std::vector<int> state_type_no;
45 std::vector<std::string> state_label_names;
46 std::vector<std::string> state_label_types;
47 std::vector<std::string> edge_label_names;
48 std::vector<std::string> edge_label_types;
49
50public:
54
56 ~lts_type();
57
59 int get_state_length() const;
60
62 std::size_t get_number_of_state_types() const;
63
65 const std::vector<std::string>& get_state_names() const;
66
68 const std::vector<std::string>& get_state_types() const;
69
72 int get_state_type_no(int part) const;
73
76 std::string get_state_type_name(int type_no) const;
77
79 std::size_t get_number_of_state_labels() const;
80
82 const std::vector<std::string>& get_state_labels() const;
83
85 const std::vector<std::string>& get_state_label_types() const;
86
88 std::size_t get_number_of_edge_labels() const;
89
91 const std::vector<std::string>& get_edge_labels() const;
92
94 const std::vector<std::string>& get_edge_label_types() const;
95
99 void add_state(const std::string& name, const std::string& type);
100
104 void add_state_label(const std::string& name, const std::string& type);
105
109 void add_edge_label(const std::string& name, const std::string& type);
110};
111
112
113
114
117
118friend class lts_info;
119friend class explorer;
120
121public:
123
124private:
125 int priority; // Priority (depends on fixpoint operator and equation order)
126 std::string var; // Propositional variable name
127 operation_type type; // player or type (And/Or, Abelard/Eloise, Odd/Even)
128 std::vector<data_expression> param_values; // List of parameter values
129
130protected:
134 ltsmin_state(const std::string& varname, const pbes_expression& e);
135
137 const std::vector<data_expression>& get_parameter_values() const;
138
141
144
145public:
148 ltsmin_state(const std::string& varname);
149
154 bool operator<( const ltsmin_state& other ) const;
155
160 bool operator==( const ltsmin_state& other ) const;
161
164 //int get_priority() const;
165
167 std::string get_variable() const;
168
170 //operation_type get_type() const;
171
173 std::string state_to_string() const;
174};
175
176
177
178
180class lts_info {
181
182friend class ltsmin_state;
183friend class explorer;
184
185public:
188private:
194 std::map<int,std::vector<bool> > read_matrix;
195 std::map<int,std::vector<bool> > write_matrix;
196 std::map<int,std::vector<bool> > matrix;
197 std::map<std::string,int> param_index;
198 std::vector<data_expression> param_default_values;
200 std::vector<pbes_expression> transition_expression;
201 std::vector<pbes_expression> transition_expression_plain;
202 std::vector<std::string> transition_variable_name;
203 std::vector<operation_type> transition_type;
204 std::map<std::string, propositional_variable> variables;
205 std::map<std::string, operation_type> variable_type;
206 std::map<std::string, fixpoint_symbol> variable_symbol;
207 std::map<std::string, int> variable_priority;
208 std::map<std::string, pbes_expression> variable_expression;
209 std::map<std::string, data::variable_list> variable_parameters;
210 std::map<std::string, std::vector<std::string> > variable_parameter_signatures;
211 std::map<std::string, std::vector<int> > variable_parameter_indices;
212 std::map<std::string, std::map<int,int> > variable_parameter_index_positions;
213
214 static std::map<variable,std::string> variable_signatures;
215
219 int count_variables(const pbes_expression& e);
220
224
232 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);
233
235 void compute_lts_type();
236
239
242
243protected:
244
246 const std::vector<pbes_expression>& get_transition_expressions() const;
247
249 const std::map<std::string, propositional_variable>& get_variables() const;
250
252 const std::map<std::string, fixpoint_symbol>& get_variable_symbols() const;
253
255 const std::map<std::string, data::variable_list>& get_variable_parameters() const;
256
260 static bool tf(const pbes_expression& phi);
261
264 static std::set<std::string> occ(const pbes_expression& expr);
265
268 static std::set<std::string> free(const pbes_expression& expr);
269
272 std::set<std::string> used(const pbes_expression& expr);
273
277 std::set<std::string> used(const pbes_expression& expr, const std::set<std::string>& L);
278
281 std::set<std::string> copied(const pbes_expression& expr);
282
286 std::set<std::string> copied(const pbes_expression& expr, const std::set<std::string>& L);
287
290 std::set<std::string> changed(const pbes_expression& phi);
291
295 std::set<std::string> changed(const pbes_expression& phi, const std::set<std::string>& L);
296
300 std::set<std::string> reset(const pbes_expression& phi, const std::set<std::string>& d);
301
304 static std::set<std::string> get_param_set(const data::variable_list& params);
305
308 static std::vector<std::string> get_param_sequence(const data::variable_list& params);
309
313 std::vector<int> get_param_indices(const data::variable_list& params);
314
319 std::map<int,int> get_param_index_positions(const data::variable_list& params);
320
323 static inline std::string get_param_signature(const variable& param);
324
328 const data_expression& get_default_value(int index);
329
335 lts_info(pbes& p, detail::pbes_greybox_interface* pgg, bool reset, bool always_split);
336
337public:
338
340 bool get_reset_option() const;
341
343 int get_number_of_groups() const;
344
347 const std::vector<std::string>& get_transition_variable_names() const;
348
351 const std::vector<operation_type>& get_transition_types() const;
352
355 const std::map<std::string, operation_type>& get_variable_types() const;
356
358 const std::map<std::string, int>& get_variable_priorities() const;
359
361 const std::map<std::string, std::vector<std::string> >& get_variable_parameter_signatures() const;
362
365 const std::map<std::string, std::vector<int> >& get_variable_parameter_indices() const;
366
370 const std::map<std::string, std::map<int,int> >& get_variable_parameter_index_positions() const;
371
373 const lts_type& get_lts_type() const;
374
376 const std::map<int,std::vector<bool> >& get_dependency_matrix() const;
377
379 const std::map<int,std::vector<bool> >& get_read_matrix() const;
380
382 const std::map<int,std::vector<bool> >& get_write_matrix() const;
383
387 int get_index(const std::string& signature);
388
394 bool is_read_dependent_propvar(int group);
395
402 bool is_read_dependent_parameter(int group, int part);
403
409 bool is_write_dependent_propvar(int group);
410
417 bool is_write_dependent_parameter(int group, int part);
418
421 std::string state_to_string(const ltsmin_state& state);
422
426 static inline std::string get_param_signature(const std::string& paramname, const std::string& paramtype);
427};
428
429
430
431
433class explorer {
434
435public:
438
439private:
442 std::map<std::string,int> localmap_string2int;
443 std::vector<std::string> localmap_int2string;
444 std::vector<std::map<data_expression,int> > localmaps_data2int;
445 std::vector<std::vector<data_expression> > localmaps_int2data;
446
447protected:
451
456
460 data::data_expression string_to_data(const std::string& s);
461
468 int get_value_index(int type_no, const data_expression& value);
469
476 const data_expression& get_data_value(int type_no, int index);
477
480
481public:
488 explorer(const std::string& filename, const std::string& rewrite_strategy, bool reset_flag, bool always_split_flag);
489
496 explorer(const pbes& p_, const std::string& rewrite_strategy, bool reset_flag, bool always_split_flag);
497
499 ~explorer();
500
502 lts_info* get_info() const;
503
506
507 void initial_state(int* state);
508
510 static inline ltsmin_state true_state();
511
513 static inline ltsmin_state false_state();
514
522 int get_index(int type_no, const std::string& s);
523
529 int get_string_index(const std::string& s);
530
537 void to_state_vector(const ltsmin_state& dst_state, int* dst, const ltsmin_state& src_state, int* const& src);
538
546 std::string get_value(int type_no, int index);
547
552 const std::string& get_string_value(int index);
553
560 ltsmin_state from_state_vector(int* const& src);
561
566 std::vector<ltsmin_state> get_successors(const ltsmin_state& state);
567
579 template <typename callback>
580 void next_state_all(int* const& src, callback& cb)
581 {
582 int state_length = this->info->get_lts_type().get_state_length();
583 ltsmin_state state = this->from_state_vector(src);
584 //std::clog << "next_state_all: " << state->to_string() << std::endl;
585 std::vector<ltsmin_state> successors = this->get_successors(state);
586 // int dst[state_length]; N.B. This is not portable C++
587 int* dst = MCRL2_SPECIFIC_STACK_ALLOCATOR(int, state_length);
588 for (auto & successor : successors) {
589
590 this->to_state_vector(successor, dst, state, src);
591 cb(dst);
592 //std::clog << " succ: " << (*succ)->to_string() << std::endl;
593 }
594 }
595
601 std::vector<ltsmin_state> get_successors(const ltsmin_state& state, int group);
602
615 template <typename callback>
616 void next_state_long(int* const& src, int group, callback& cb)
617 {
618 int state_length = this->info->get_lts_type().get_state_length();
619 std::string group_varname = info->get_transition_variable_names()[group];
620 std::string varname = this->get_string_value(src[0]);
621 if (varname==group_varname)
622 {
623 ltsmin_state state = this->from_state_vector(src);
624 std::vector<ltsmin_state> successors = this->get_successors(state, group);
625 // int dst[state_length]; N.B. This is not portable C++
626 int* dst = MCRL2_SPECIFIC_STACK_ALLOCATOR(int, state_length);
627 for (auto & successor : successors) {
628 this->to_state_vector(successor, dst, state, src);
629 cb(dst, group);
630 }
631 }
632 }
633
634};
635
636} // namespace pbes_system
637
638} // namespace mcrl2
639
640#endif // MCRL2_PBES_PBES_EXPLORER_H
\brief A data variable
Definition variable.h:28
static ltsmin_state false_state()
Returns the state representing false.
ltsmin_state get_state(const propositional_variable_instantiation &expr) const
Returns a PBES_State object for expr.
std::vector< std::vector< data_expression > > localmaps_int2data
std::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....
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...
parity_game_generator::operation_type operation_type
The expression type of the equation.
std::vector< std::map< data_expression, int > > localmaps_data2int
ltsmin_state from_state_vector(int *const &src)
Transforms a state vector src into a PBES_State object object containing the variable and parameter v...
int get_string_index(const std::string &s)
Returns the index of s in the local store for string values. This store is reserved for the string re...
const std::string & get_string_value(int index)
Returns the string at position index in the local store for string values. An exception is thrown if ...
std::vector< ltsmin_state > get_successors(const ltsmin_state &state)
Computes successor states for a state. Serves as a wrapper around the get_successors function of the ...
data::data_expression string_to_data(const std::string &s)
Returns a data expression for the string representation s.
lts_info * get_info() const
Returns the PBES_Info object.
const data_expression & get_data_value(int type_no, int index)
Returns the value at position index in the local store for the data type with number type_no....
void next_state_all(int *const &src, callback &cb)
Iterates over the successors of a state and invokes a callback function for each successor state.
detail::pbes_greybox_interface * pgg
the PBES greybox interface
bool is_write_dependent_propvar(int group)
Determines if group is write dependent on the propositional variable. Returns true if propositional v...
const std::map< std::string, std::map< int, int > > & get_variable_parameter_index_positions() const
Returns the map from variable names to the map from indices of parameter signatures for the variable ...
std::map< std::string, int > variable_priority
const std::map< int, std::vector< bool > > & get_read_matrix() const
Returns the read dependency matrix.
const std::map< int, std::vector< bool > > & get_write_matrix() const
Returns the write dependency matrix.
static std::vector< std::string > get_param_sequence(const data::variable_list &params)
Converts a variable_sequence_type into a sequence of parameter signatures.
bool is_read_dependent_parameter(int group, int part)
Determines if group is read dependent on part part of the state vector. Returns true if the parameter...
std::vector< int > get_param_indices(const data::variable_list &params)
Converts a variable_sequence_type into a sequence of indices of parameter signatures in the list of p...
std::vector< std::string > transition_variable_name
bool is_pass_through_state(const propositional_variable_instantiation &propvar)
Determines if the propositional variable instantiation is one that only copies parameters from the cu...
const std::map< std::string, fixpoint_symbol > & get_variable_symbols() const
Returns the map from variable names to the fixpoint operator of the equation for the variable.
static std::map< variable, std::string > variable_signatures
std::map< std::string, fixpoint_symbol > variable_symbol
const std::map< std::string, data::variable_list > & get_variable_parameters() const
Returns the map from variable names to the sequence of parameters for the variable.
const std::map< std::string, std::vector< std::string > > & get_variable_parameter_signatures() const
Returns the map from variable names to the list of parameters signatures for the variable.
const std::map< std::string, propositional_variable > & get_variables() const
Returns the map from variable names to the variable object for the variable.
int get_index(const std::string &signature)
Returns the index for a parameter signature in the list of parameter signatures for the system.
const lts_type & get_lts_type() const
Returns the LTS Type.
std::map< std::string, int > param_index
bool get_reset_option() const
Returns if the reset option is set.
std::map< std::string, std::vector< std::string > > variable_parameter_signatures
const std::vector< pbes_expression > & get_transition_expressions() const
Returns the map from transition group number to the expression of the transition group.
std::set< std::string > copied(const pbes_expression &expr)
Computes the free variables which are copied/passed through (to a recursive variable) in an expressio...
std::map< int, std::vector< bool > > read_matrix
std::vector< data_expression > param_default_values
detail::pbes_greybox_interface * pgg
bool is_read_dependent_propvar(int group)
Determines if group is read dependent on the propositional variable. Returns true,...
std::vector< pbes_expression > transition_expression
const std::map< int, std::vector< bool > > & get_dependency_matrix() const
Returns the dependency matrix.
const std::vector< operation_type > & get_transition_types() const
Returns the map from transition group number to the type of the right hand side of the equation to wh...
std::set< std::string > used(const pbes_expression &expr)
Computes the free variables actually used, not only passed through, in an expression.
std::map< std::string, std::map< int, int > > variable_parameter_index_positions
static std::string get_param_signature(const variable &param)
Returns a signature for parameter param.
const std::map< std::string, operation_type > & get_variable_types() const
Returns the map from variable names to the type of the right hand side of the equation for the variab...
void compute_dependency_matrix()
Computes dependency matrix from PBES.
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::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.
parity_game_generator::operation_type operation_type
The variable sequence type.
std::map< std::string, data::variable_list > variable_parameters
const data_expression & get_default_value(int index)
Returns a default value for the sort of a parameter signature.
const std::vector< std::string > & get_transition_variable_names() const
Returns the map from transition group number to the variable name of the equation to which the transi...
std::map< int, std::vector< bool > > matrix
std::set< std::string > reset(const pbes_expression &phi, const std::set< std::string > &d)
Computes the set of parameters reset in the expression.
static std::set< std::string > free(const pbes_expression &expr)
Computes the free variables read in an expression.
std::vector< pbes_expression > transition_expression_plain
std::map< int, std::vector< bool > > write_matrix
bool is_write_dependent_parameter(int group, int part)
Determines if group is read dependent on part part of the state vector. Returns true if the parameter...
std::map< std::string, pbes_expression > variable_expression
std::set< std::string > changed(const pbes_expression &phi)
Computes the set of parameters changed in the expression.
std::map< std::string, std::vector< int > > variable_parameter_indices
void compute_transition_groups()
Computes transition groups from PBES.
const std::map< std::string, std::vector< int > > & get_variable_parameter_indices() const
Returns the map from variable names to the list of indices of the parameters signatures for the varia...
const std::vector< std::string > & get_edge_label_types() const
Returns the sequence of edge label types.
std::size_t get_number_of_state_types() const
Returns the number of state types.
const std::vector< std::string > & get_edge_labels() const
Returns the sequence of edge labels.
int get_state_type_no(int part) const
Returns the state type index for the state part part.
std::vector< std::string > state_type_list
std::vector< std::string > state_label_types
std::vector< std::string > state_names
std::vector< int > state_type_no
void add_state(const std::string &name, const std::string &type)
Adds a state part of type type with name name.
void add_state_label(const std::string &name, const std::string &type)
Adds a state label of type type with name name.
std::string get_state_type_name(int type_no) const
Returns the name of the state type with number type_no.
int get_state_length() const
Returns the state length.
std::map< std::string, int > state_type_index
std::vector< std::string > edge_label_names
const std::vector< std::string > & get_state_label_types() const
Returns the sequence of state label types.
std::vector< std::string > edge_label_types
std::vector< std::string > state_types
std::size_t get_number_of_edge_labels() const
Returns the number of edge labels.
std::vector< std::string > state_label_names
const std::vector< std::string > & get_state_types() const
Returns the sequence of state part types.
void add_edge_label(const std::string &name, const std::string &type)
Adds an edge label of type type with name name.
const std::vector< std::string > & get_state_labels() const
Returns the sequence of state labels.
const std::vector< std::string > & get_state_names() const
Returns the sequence of state part names.
std::size_t get_number_of_state_labels() const
Returns the number of state labels.
void add_parameter_value(const data_expression &)
Adds a parameter value to the list of parameter values.
pbes_expression to_pbes_expression() const
Returns a PBES expression representing the state.
std::vector< data_expression > param_values
std::string state_to_string() const
Returns the player or type of the state (And/Or, Abelard/Eloise, Odd/Even).
bool operator<(const ltsmin_state &other) const
Compares two PBES_State objects. Uses lexicographical ordering on priority, type, variable and parame...
parity_game_generator::operation_type operation_type
bool operator==(const ltsmin_state &other) const
Checks if two PBES_State objects are equal.
std::string get_variable() const
Returns the priority for the state, which depends on the fixpoint operator of the equation of the pro...
const std::vector< data_expression > & get_parameter_values() const
Returns the list of parameter values.
operation_type
The operation type of the vertices.
parameterized boolean equation system
Definition pbes.h:58
\brief A propositional variable instantiation
MapContainer::mapped_type map_at(const MapContainer &m, typename MapContainer::key_type key)
A class that takes a linear process specification and checks all tau-summands of that LPS for conflue...
Definition indexed_set.h:72
The pbes_greybox_interface class provides a wrapper for the parity_game_generator classes,...
Traverser class for Parameterised Parity Games (PPG), PBES expressions of the form: PPG :== /_{i: I} ...