|
mCRL2
|
data specification. More...
#include <data_specification.h>
Public Types | |
| using | implementation_map = std::map< function_symbol, std::pair< std::function< void(data_expression &, const data_expression &)>, std::string > > |
Public Member Functions | |
| data_specification ()=default | |
| Default constructor. Generate a data specification that contains only booleans and positive numbers. | |
| data_specification (const atermpp::aterm &t) | |
| Constructor from an aterm. | |
| data_specification (const basic_sort_vector &sorts, const alias_vector &aliases, const function_symbol_vector &constructors, const function_symbol_vector &user_defined_mappings, const data_equation_vector &user_defined_equations) | |
| Constructor from its members. | |
| const function_symbol_vector & | constructors () const |
| Gets all constructors including those that are system defined. | |
| const function_symbol_vector & | user_defined_constructors () const |
| Gets the constructors defined by the user, excluding those that are system defined. | |
| const function_symbol_vector & | constructors (const sort_expression &s, const bool do_not_normalize=false) const |
| Gets all constructors of a sort including those that are system defined. | |
| const function_symbol_vector & | mappings () const |
| Gets all mappings in this specification including those that are system defined. | |
| const function_symbol_vector & | user_defined_mappings () const |
| Gets all user defined mappings in this specification. | |
| const function_symbol_vector & | mappings (const sort_expression &s) const |
| Gets all mappings of a sort including those that are system defined. | |
| const std::set< data_equation > & | equations () const |
| Gets all equations in this specification including those that are system defined. | |
| const implementation_map & | cpp_implemented_functions () const |
| Gets all equations in this specification including those that are system defined. | |
| const data_equation_vector & | user_defined_equations () const |
| Gets all user defined equations. | |
| data_equation_vector & | user_defined_equations () |
| void | add_constructor (const function_symbol &f) |
| Adds a constructor to this specification. | |
| void | add_mapping (const function_symbol &f) |
| Adds a mapping to this specification. | |
| void | add_equation (const data_equation &e) |
| Adds an equation to this specification. | |
| void | translate_user_notation () |
| Translate user notation within the equations of the data specification. | |
| void | get_system_defined_sorts_constructors_and_mappings (std::set< sort_expression > &sorts, std::set< function_symbol > &constructors, std::set< function_symbol > &mappings) const |
| This function provides a sample of all system defined sorts, constructors and mappings that contains at least one specimen of each sort and function symbol. Because types can be parameterised not all function symbols for all types are provided. | |
| void | remove_constructor (const function_symbol &f) |
| Removes constructor from specification. | |
| void | remove_mapping (const function_symbol &f) |
| Removes mapping from specification. | |
| void | remove_equation (const data_equation &e) |
| Removes equation from specification. | |
| bool | equal_sorts (sort_expression const &s1, sort_expression const &s2) const |
| Checks whether two sort expressions represent the same sort. | |
| bool | is_certainly_finite (const sort_expression &s) const |
| Checks whether a sort is certainly finite. | |
| bool | is_certainly_finite (const sort_expression_list &l) const |
| Checks whether all sorts are certainly finite in a sort_expression_list. | |
| bool | is_constructor_sort (const sort_expression &s) const |
| Checks whether a sort is a constructor sort. | |
| bool | is_well_typed () const |
| Returns true if. | |
| bool | operator== (const data_specification &other) const |
Public Member Functions inherited from mcrl2::data::sort_specification | |
| sort_specification () | |
| Default constructor. | |
| sort_specification (const basic_sort_vector &sorts, const alias_vector &aliases) | |
| void | add_sort (const basic_sort &s) |
| Adds a sort to this specification. | |
| void | add_system_defined_sort (const sort_expression &s) |
| Adds a sort to this specification, and marks it as system defined. | |
| void | add_context_sort (const sort_expression &s) |
| Adds the sort s to the context sorts. | |
| template<typename Container > | |
| void | add_context_sorts (const Container &c, typename atermpp::enable_if_container< Container >::type *=nullptr) |
| Adds the sorts in c to the context sorts. | |
| void | remove_sort (const sort_expression &s) |
| Removes sort from the user defined sorts in the specification. Note that this does not remove aliases for the sort, and it does not remove constructors, mappings and equations, and also keeps the sort as defined in the context. | |
| const std::set< sort_expression > & | sorts () const |
| Gets the normalised sort declarations including those that are system defined. This is the set with all sorts that occur in a data_specification, or that have been registered as sorts used in the context. | |
| const std::set< sort_expression > & | context_sorts () const |
| Return the user defined context sorts of the current specification. | |
| const basic_sort_vector & | user_defined_sorts () const |
| Gets all sorts defined by a user (excluding the system defined sorts). | |
| void | add_alias (const alias &a) |
| Adds an alias (new name for a sort) to this specification. | |
| void | remove_alias (const alias &a) |
| Removes a user defined //alias from specification. | |
| const alias_vector & | user_defined_aliases () const |
| Gets the user defined aliases. | |
| const std::map< sort_expression, sort_expression > & | sort_alias_map () const |
| Gets a normalisation mapping that maps each sort to its unique normalised sort. | |
| bool | operator== (const sort_specification &other) const |
Protected Member Functions | |
| void | data_is_not_necessarily_normalised_anymore () const |
| void | add_normalised_constructor (const function_symbol &f) const |
| Adds a constructor to this specification, and marks it as system defined. | |
| void | add_normalised_mapping (const function_symbol &f) const |
| Adds a mapping to this specification, and marks it as system defined. | |
| void | add_normalised_equation (const data_equation &e) const |
| Adds an equation to this specification, and marks it as system defined. | |
| template<class Iterator > | |
| void | add_normalised_constructors (Iterator begin, Iterator end) const |
| template<class Iterator > | |
| void | add_normalised_mappings (Iterator begin, Iterator end) const |
| template<class Iterator > | |
| void | add_normalised_equations (Iterator begin, Iterator end) const |
| void | add_normalised_cpp_implemented_functions (const implementation_map &c) const |
| void | insert_mappings_constructors_for_structured_sort (const structured_sort &sort, std::set< function_symbol > &constructors, std::set< function_symbol > &mappings, std::set< data_equation > &equations, const bool skip_equations) const |
| Adds constructors, mappings and equations for a structured sort to this specification, and marks them as system defined. | |
| void | add_standard_mappings_and_equations (const sort_expression &sort, std::set< function_symbol > &mappings, std::set< data_equation > &equations, const bool skip_equations) const |
Protected Member Functions inherited from mcrl2::data::sort_specification | |
| void | sorts_are_not_necessarily_normalised_anymore () const |
| void | data_is_not_necessarily_normalised_anymore () const |
| void | normalise_sort_specification_if_required () const |
| void | add_predefined_basic_sorts () |
| template<class CONTAINER > | |
| void | import_system_defined_sorts (const CONTAINER &sorts) |
| void | import_system_defined_sort (const sort_expression &sort) |
| Adds the system defined sorts in a sequence. The second argument is used to check which sorts are added, to prevent useless repetitions of additions of sorts. | |
| void | reconstruct_m_normalised_aliases () const |
| void | check_for_alias_loop (const sort_expression &s, std::set< sort_expression > sorts_already_seen, bool toplevel=true) const |
Protected Attributes | |
| function_symbol_vector | m_user_defined_constructors |
| A mapping of sort expressions to the constructors corresponding to that sort. | |
| function_symbol_vector | m_user_defined_mappings |
| The mappings of the specification. | |
| data_equation_vector | m_user_defined_equations |
| The equations of the specification. | |
| function_symbol_vector | m_normalised_constructors |
| Set containing all constructors, including the system defined ones. The types in these constructors are normalised. | |
| target_sort_to_function_map | m_grouped_normalised_constructors |
| Cache normalised constructors grouped by target sort. | |
| function_symbol_vector | m_normalised_mappings |
| Set containing system defined all mappings, including the system defined ones. The types in these mappings are normalised. | |
| target_sort_to_function_map | m_grouped_normalised_mappings |
| Cache normalised mappings grouped by target sort. | |
| std::set< data_equation > | m_normalised_equations |
| Table containing all equations, including the system defined ones. The sorts in these equations are normalised. | |
| implementation_map | m_cpp_implemented_functions |
| A map that for function symbols gives how it can be implemented. | |
Protected Attributes inherited from mcrl2::data::sort_specification | |
| bool | m_normalised_sorts_are_up_to_date |
| This boolean indicates whether the variables m_normalised_constructors, m_mappings, m_equations, m_normalised_sorts, m_normalised_aliases are up to date with respect to changes of this sort specification. | |
| bool | m_normalised_data_is_up_to_date |
| The variable below indicates whether a surrounding data specification is up to data with respect to sort normalisation and available sorts. This is set to false if an alias or a new sort is added. | |
| basic_sort_vector | m_user_defined_sorts |
| The basic sorts and structured sorts in the specification. | |
| std::set< sort_expression > | m_normalised_sorts |
| Set containing all the sorts, including the system defined ones. | |
| std::set< sort_expression > | m_sorts_in_context |
| The sorts that occur are needed in this sort specification but are not explicitly defined as user defined sorts. An example is the sort Nat when declaring the use of a sort List(Nat). The normalised sorts, constructors, mappings and equations are complete with respect to these sorts. | |
| alias_vector | m_user_defined_aliases |
| The basic sorts and structured sorts in the specification. | |
| std::map< sort_expression, sort_expression > | m_normalised_aliases |
| Table containing how sorts should be mapped to normalised sorts. | |
Private Member Functions | |
| void | add_data_types_for_sorts () const |
| Puts the constructors, functions and equations in normalised form in de data type. | |
| void | normalise_data_specification_if_required () const |
| void | find_associated_system_defined_data_types_for_a_sort (const sort_expression &sort, std::set< function_symbol > &constructors, std::set< function_symbol > &mappings, std::set< data_equation > &equations, implementation_map &cpp_implemented_functions, bool skip_equations=false) const |
| Adds the system defined sorts to the sets with constructors, mappings, and equations for. | |
| void | import_data_type_for_system_defined_sort (const sort_expression &sort) const |
Adds the system defined sorts in a sequence. The second argument is used to check which sorts are added, to prevent useless repetitions of additions of sorts. The function normalise_sorts imports for the given sort_expression sort all sorts, constructors, mappings and equations that belong to this sort to the normalised sets in this data type. E.g. for the sort Nat of natural numbers, it is required that Pos (positive numbers) are defined. | |
data specification.
Definition at line 49 of file data_specification.h.
| using mcrl2::data::data_specification::implementation_map = std::map<function_symbol, std::pair<std::function<void(data_expression&, const data_expression&)>, std::string> > |
Definition at line 52 of file data_specification.h.
|
default |
Default constructor. Generate a data specification that contains only booleans and positive numbers.
|
inlineexplicit |
Constructor from an aterm.
| [in] | t | a term adhering to the internal format. |
Definition at line 316 of file data_specification.h.
| mcrl2::data::data_specification::data_specification | ( | const basic_sort_vector & | sorts, |
| const alias_vector & | aliases, | ||
| const function_symbol_vector & | constructors, | ||
| const function_symbol_vector & | user_defined_mappings, | ||
| const data_equation_vector & | user_defined_equations | ||
| ) |
Constructor from its members.
Definition at line 855 of file data_specification.cpp.
|
inline |
Adds a constructor to this specification.
| [in] | f | A function symbol. |
Definition at line 450 of file data_specification.h.
|
inlineprivate |
Puts the constructors, functions and equations in normalised form in de data type.
See the function normalise_sorts on arbitrary objects for a more detailed description. All sorts in the constructors, mappings and equations are normalised.
Definition at line 508 of file data_specification.h.
|
inline |
Adds an equation to this specification.
| [in] | e | An equation. |
Definition at line 480 of file data_specification.h.
|
inline |
Adds a mapping to this specification.
| [in] | f | A function symbol. |
Definition at line 465 of file data_specification.h.
|
inlineprotected |
Adds a constructor to this specification, and marks it as system defined.
| [in] | f | A function symbol. |
Definition at line 178 of file data_specification.h.
|
inlineprotected |
Definition at line 216 of file data_specification.h.
|
inlineprotected |
Definition at line 242 of file data_specification.h.
|
inlineprotected |
Adds an equation to this specification, and marks it as system defined.
| [in] | e | An equation. |
Definition at line 210 of file data_specification.h.
|
inlineprotected |
Definition at line 234 of file data_specification.h.
|
inlineprotected |
Adds a mapping to this specification, and marks it as system defined.
| [in] | f | A function symbol. |
Definition at line 194 of file data_specification.h.
|
inlineprotected |
Definition at line 225 of file data_specification.h.
|
inlineprotected |
Definition at line 292 of file data_specification.h.
|
inline |
Gets all constructors including those that are system defined.
The time complexity is the same as for sorts().
Definition at line 333 of file data_specification.h.
|
inline |
Gets all constructors of a sort including those that are system defined.
The time complexity is the same as for sorts().
| [in] | s | A sort expression. |
Definition at line 354 of file data_specification.h.
|
inline |
Gets all equations in this specification including those that are system defined.
The time complexity of this operation is the same as that for sort().
Definition at line 420 of file data_specification.h.
|
inlineprotected |
Definition at line 163 of file data_specification.h.
|
inline |
Checks whether two sort expressions represent the same sort.
| [in] | s1 | A sort expression |
| [in] | s2 | A sort expression |
Definition at line 648 of file data_specification.h.
|
inline |
Gets all equations in this specification including those that are system defined.
The time complexity of this operation is the same as that for sort().
Definition at line 408 of file data_specification.h.
|
private |
Adds the system defined sorts to the sets with constructors, mappings, and equations for.
Definition at line 529 of file data_specification.cpp.
| void mcrl2::data::data_specification::get_system_defined_sorts_constructors_and_mappings | ( | std::set< sort_expression > & | sorts, |
| std::set< function_symbol > & | constructors, | ||
| std::set< function_symbol > & | mappings | ||
| ) | const |
This function provides a sample of all system defined sorts, constructors and mappings that contains at least one specimen of each sort and function symbol. Because types can be parameterised not all function symbols for all types are provided.
The sorts, constructors and mappings for the following types are added: Bool, Pos, Int, Nat, Real, List(Pos), FSet(Pos), FBag(Pos), Set(Pos), Bag(Pos). How to deal with struct...
Definition at line 752 of file data_specification.cpp.
|
inlineprivate |
Adds the system defined sorts in a sequence. The second argument is used to check which sorts are added, to prevent useless repetitions of additions of sorts. The function normalise_sorts imports for the given sort_expression sort all sorts, constructors, mappings and equations that belong to this sort to the normalised sets in this data type. E.g. for the sort Nat of natural numbers, it is required that Pos (positive numbers) are defined.
Definition at line 575 of file data_specification.h.
|
inlineprotected |
Adds constructors, mappings and equations for a structured sort to this specification, and marks them as system defined.
| [in] | sort | A sort expression that is representing the structured sort. |
| [out] | constructors | To this set the new constructors are added. |
| [out] | mappings | New mappings are added to this set. |
| [out] | equations | New equations for the structured sort are added to this set. |
| [in] | skip_equations | This boolean indicates whether equations are added. |
Definition at line 262 of file data_specification.h.
| bool mcrl2::data::data_specification::is_certainly_finite | ( | const sort_expression & | s | ) | const |
Checks whether a sort is certainly finite.
| [in] | s | A sort expression |
| [in] | s | A sort expression |
Definition at line 137 of file data_specification.cpp.
|
inline |
Checks whether all sorts are certainly finite in a sort_expression_list.
| [in] | l | A sort expression list |
Definition at line 668 of file data_specification.h.
|
inline |
Checks whether a sort is a constructor sort.
| [in] | s | A sort expression |
Definition at line 684 of file data_specification.h.
| bool mcrl2::data::data_specification::is_well_typed | ( | ) | const |
Returns true if.
Definition at line 781 of file data_specification.cpp.
|
inline |
Gets all mappings in this specification including those that are system defined.
The time complexity is the same as for sorts().
Definition at line 372 of file data_specification.h.
|
inline |
Gets all mappings of a sort including those that are system defined.
| [in] | s | A sort expression. |
Definition at line 395 of file data_specification.h.
|
inlineprivate |
Definition at line 548 of file data_specification.h.
|
inline |
Definition at line 699 of file data_specification.h.
|
inline |
Removes constructor from specification.
Note that this does not remove equations containing the constructor.
| [in] | f | A constructor. |
Definition at line 611 of file data_specification.h.
|
inline |
Removes equation from specification.
| [in] | e | An equation. |
Definition at line 636 of file data_specification.h.
|
inline |
Removes mapping from specification.
Note that this does not remove equations in which the mapping occurs.
| [in] | f | A function. |
Definition at line 624 of file data_specification.h.
|
inline |
Translate user notation within the equations of the data specification.
This function replaces explicit numbers, lists, sets and bags by their counterpart in the data types. This function is to be invoked after type checking.
Definition at line 493 of file data_specification.h.
|
inline |
Gets the constructors defined by the user, excluding those that are system defined.
The time complexity for this operation is constant.
Definition at line 343 of file data_specification.h.
|
inline |
Definition at line 439 of file data_specification.h.
|
inline |
Gets all user defined equations.
The time complexity of this operation is constant.
Definition at line 432 of file data_specification.h.
|
inline |
Gets all user defined mappings in this specification.
The time complexity is constant.
Definition at line 384 of file data_specification.h.
|
mutableprotected |
A map that for function symbols gives how it can be implemented.
For each function symbol there is a function : application -> data_expression that when applied to a term in normal form with the function symbol as head symbol returns a function that can be applied to calculate this term. Furthermore, it provides the name of a function that when applied to the number of arguments that the function expects can be used to rewrite the term. This last string can be used for code generation.
Definition at line 159 of file data_specification.h.
|
mutableprotected |
Cache normalised constructors grouped by target sort.
Definition at line 136 of file data_specification.h.
|
mutableprotected |
Cache normalised mappings grouped by target sort.
Definition at line 143 of file data_specification.h.
|
mutableprotected |
Set containing all constructors, including the system defined ones. The types in these constructors are normalised.
Definition at line 133 of file data_specification.h.
|
mutableprotected |
Table containing all equations, including the system defined ones. The sorts in these equations are normalised.
The normalised equations are a set as the number of equations can become large, in which case removing duplicates while inserting equations can be very time consuming.
Definition at line 150 of file data_specification.h.
|
mutableprotected |
Set containing system defined all mappings, including the system defined ones. The types in these mappings are normalised.
Definition at line 140 of file data_specification.h.
|
protected |
A mapping of sort expressions to the constructors corresponding to that sort.
Definition at line 123 of file data_specification.h.
|
protected |
The equations of the specification.
Definition at line 129 of file data_specification.h.
|
protected |
The mappings of the specification.
Definition at line 126 of file data_specification.h.