12#ifndef MCRL2_DATA_DETAIL_DATA_UTILITY_H
13#define MCRL2_DATA_DETAIL_DATA_UTILITY_H
15#include "mcrl2/data/alias.h"
16#include "mcrl2/data/assignment.h"
17#include "mcrl2/data/detail/data_functional.h"
18#include "mcrl2/data/standard_utility.h"
19#include "mcrl2/utilities/detail/container_utility.h"
25template <
typename Container>
28 data::sort_expression_list sorts;
29 for (
auto const& param: parameters)
31 sorts.push_front(param.sort());
33 return atermpp::reverse(sorts);
39template <
class VariableContainer>
43 std::set<core::identifier_string> variable_names;
44 for (
auto const& var: variables)
46 variable_names.insert(var.name());
48 return variable_names.size() == variables.size();
60 std::set<variable> v(variables.begin(), variables.end());
61 for (
const assignment& a: assignments)
63 if (!contains(v, a.lhs()))
75template <
typename SortContainer>
80 std::set<sort_expression> s_sorts = data::find_sort_expressions(s);
81 remove_if(s_sorts, [](
const sort_expression& x) {
return !is_function_sort(x); });
82 for (
const sort_expression& sort: s_sorts)
84 if (std::find(sorts.begin(), sorts.end(), sort) == sorts.end())
87 if (!(is_system_defined(sort)) && is_alias(sort))
89 alias sort_alias(sort);
91 if (std::find(sorts.begin(), sorts.end(), sort_alias.name()) == sorts.end())
94 const sort_expression& sort_reference(sort_alias.reference());
96 if (std::find(sorts.begin(), sorts.end(), sort_reference) == sorts.end())
99 if (is_structured_sort(sort_reference))
103 else if (is_container_sort(sort_reference))
105 if (std::find(sorts.begin(), sorts.end(), container_sort(sort_reference).element_sort()) == sorts.end())
129template <
typename Iterator,
typename SortContainer>
130bool check_sorts(Iterator first, Iterator last,
const SortContainer& sorts)
132 for (Iterator i = first; i != last; ++i)
134 if (!check_sort(*i, sorts))
146template <
typename VariableContainer,
typename SortContainer>
149 for (
typename VariableContainer::const_iterator i = variables.begin(); i != variables.end(); ++i)
151 if (!check_sort(i->sort(), sorts))
168 for (
const variable& v: variables)
170 if (contains(names, v.name()))
182template <
typename Container,
typename SortContainer >
186 for (
typename Container::const_iterator i = container.begin(); i != container.end(); ++i)
188 if (!check_sort(i->sort(), sorts))
A unordered_map class in which aterms can be stored.
basic_sort(const atermpp::aterm &term)
const container_type & container_name() const
const sort_expression & element_sort() const
container_sort(const atermpp::aterm &term)
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.
bool is_well_typed() const
Returns true if.
bool is_certainly_finite(const sort_expression &s) const
Checks whether a sort is certainly finite.
bool is_finite(const container_sort &s)
bool is_finite(const basic_sort &s)
bool is_finite_aux(const sort_expression &s)
bool is_finite(const sort_expression &s)
std::set< sort_expression > m_visiting
bool is_finite(const alias &)
bool is_finite(const function_sort &s)
const data_specification & m_specification
finiteness_helper(const data_specification &specification)
bool is_finite(const structured_sort &s)
\brief Container type for finite sets
fset_container()
\brief Default constructor X3.
const sort_expression & codomain() const
function_sort(const atermpp::aterm &term)
const sort_expression_list & domain() const
\brief Container type for sets
set_container()
\brief Default constructor X3.
sort_expression & operator=(const sort_expression &) noexcept=default
sort_expression(const sort_expression &) noexcept=default
Move semantics.
void add_system_defined_sort(const sort_expression &s)
Adds a sort to this specification, and marks it as system defined.
void add_predefined_basic_sorts()
void sorts_are_not_necessarily_normalised_anymore() const
void reconstruct_m_normalised_aliases() const
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 add...
structured_sort(const atermpp::aterm &term)
#define mCRL2log(LEVEL)
mCRL2log(LEVEL) provides the stream used to log.
aterm identity(const aterm &x)
The default transformer that maps each term to itself.
std::string file_source(const std::string &filename)
atermpp::aterm load_aterm(std::istream &stream, bool binary=true, const std::string &format="aterm", const std::string &source="", atermpp::aterm_transformer transformer=atermpp::identity)
Attempts to read an aterm from a stream.
bool check_variable_sorts(const VariableContainer &variables, const SortContainer &sorts)
Returns true if the domain sorts and the range sort of the given variables are contained in sorts.
bool check_variable_names(variable_list const &variables, const std::set< core::identifier_string > &names)
Returns true if names of the given variables are not contained in names.
bool check_assignment_variables(assignment_list const &assignments, variable_list const &variables)
Returns true if the left hand sides of assignments are contained in variables.
bool check_sort(const sort_expression &s, const SortContainer &sorts)
Returns true if the domain sorts and the codomain sort of the given sort s are contained in sorts.
bool check_data_spec_sorts(const Container &container, const SortContainer &sorts)
Returns true if the domain sorts and range sort of the given functions are contained in sorts.
data::sort_expression_list parameter_sorts(const Container ¶meters)
Returns the sorts of a sequence of parameters.
bool check_sorts(Iterator first, Iterator last, const SortContainer &sorts)
Returns true if the domain sorts and the range sort of the sorts in the sequence [first,...
bool unique_names(const VariableContainer &variables)
Returns true if the names of the given variables are unique.
Namespace for system defined sort bag.
bool is_bag(const sort_expression &e)
Recogniser for sort expression Bag(s)
Namespace for system defined sort bool_.
const basic_sort & bool_()
Constructor for sort expression Bool.
Namespace for system defined sort fbag.
container_sort fbag(const sort_expression &s)
Constructor for sort expression FBag(S)
bool is_fbag(const sort_expression &e)
Recogniser for sort expression FBag(s)
Namespace for system defined sort fset.
bool is_fset(const sort_expression &e)
Recogniser for sort expression FSet(s)
container_sort fset(const sort_expression &s)
Constructor for sort expression FSet(S)
Namespace for system defined sort int_.
const basic_sort & int_()
Constructor for sort expression Int.
Namespace for system defined sort list.
bool is_list(const sort_expression &e)
Recogniser for sort expression List(s)
Namespace for system defined sort nat.
const basic_sort & nat()
Constructor for sort expression Nat.
const basic_sort & natpair()
Constructor for sort expression @NatPair.
Namespace for system defined sort pos.
const basic_sort & pos()
Constructor for sort expression Pos.
Namespace for system defined sort real_.
const basic_sort & real_()
Constructor for sort expression Real.
Namespace for system defined sort set_.
bool is_set(const sort_expression &e)
Recogniser for sort expression Set(s)
container_sort set_(const sort_expression &s)
Constructor for sort expression Set(S)
bool is_structured_sort(const atermpp::aterm &x)
Returns true if the term t is a structured sort.
static sort_expression find_normal_form(const sort_expression &e, const std::multimap< sort_expression, sort_expression > &map1, std::set< sort_expression > sorts_already_seen=std::set< sort_expression >())
bool is_untyped_possible_sorts(const atermpp::aterm &x)
Returns true if the term t is an expression for multiple possible sorts.
bool is_untyped_sort(const atermpp::aterm &x)
Returns true if the term t is the unknown sort.
bool is_container_sort(const atermpp::aterm &x)
Returns true if the term t is a container sort.
bool is_basic_sort(const atermpp::aterm &x)
Returns true if the term t is a basic sort.
bool is_function_sort(const atermpp::aterm &x)
Returns true if the term t is a function sort.