12#ifndef MCRL2_DATA_SORT_TYPE_CHECKER_H
13#define MCRL2_DATA_SORT_TYPE_CHECKER_H
36 if (must_check_aliases)
62 std::set<basic_sort> sort_already_seen,
63 const std::map < basic_sort, sort_expression >& alias_map)
67 const basic_sort& sort=atermpp::down_cast<basic_sort>(rhs);
72 if (sort_already_seen.insert(sort).second && alias_map.count(sort)>0)
76 sort_already_seen.erase(sort);
87 const function_sort& sort=atermpp::down_cast<function_sort>(rhs);
106 if (!defined_sorts.insert(sort).second)
113 if (!defined_sorts.insert(a.name()).second)
124 std::map < basic_sort, sort_expression > alias_map;
127 alias_map[a.name()]=a.reference();
130 std::set<data::basic_sort> sort_already_seen;
134 assert(sort_already_seen.size()==0);
136 assert(sort_already_seen.size()==0);
143 (*this)(a.reference());
155 std::set < basic_sort >& visited,
156 const bool observed_a_sort_constructor,
157 const std::map < basic_sort, sort_expression >& alias_map)
161 const basic_sort& s=atermpp::down_cast<basic_sort>(start_search);
165 if (observed_a_sort_constructor)
167 throw mcrl2::runtime_error(
"sort " +
data::pp(end_search) +
" is recursively defined via a function sort, or a set or a bag type container");
171 if (alias_map.count(s)==0 || visited.count(s)>0)
186 const container_sort& start_search_container=atermpp::down_cast<container_sort>(start_search);
198 const function_sort& f_start_search=atermpp::down_cast<function_sort>(start_search);
210 const structured_sort& struct_start_search=atermpp::down_cast<structured_sort>(start_search);
263 const basic_sort& bs = atermpp::down_cast<basic_sort>(x);
273 const function_sort& fs = atermpp::down_cast<function_sort>(x);
299 std::set<sort_expression> possibly_empty_constructor_sorts;
312 for(
bool stable=
false ; !stable ;)
327 bool has_a_domain_sort_possibly_empty_sorts=
false;
333 has_a_domain_sort_possibly_empty_sorts=
true;
337 if (!has_a_domain_sort_possibly_empty_sorts)
349 if (possibly_empty_constructor_sorts.empty())
355 std::string reason=
"the following domains are empty due to recursive constructors:";
358 reason = reason +
"\n" +
data::pp(sort);
\brief Container type for bags
const core::identifier_string & name() const
const container_type & container_name() const
const sort_expression & element_sort() const
sort_expression sort() const
Returns the sort of the data expression.
const sort_expression & codomain() const
const sort_expression_list & domain() const
const sort_expression & sort() const
\brief Container type for sets
const basic_sort_vector & user_defined_sorts() const
Gets all sorts defined by a user (excluding the system defined sorts).
const alias_vector & user_defined_aliases() const
Gets the user defined aliases.
void check_for_sort_alias_loop_through_function_sort(const basic_sort &end_search, const sort_expression &start_search, std::set< basic_sort > &visited, const bool observed_a_sort_constructor, const std::map< basic_sort, sort_expression > &alias_map)
sort_specification m_sort_specification
const sort_specification & get_sort_specification() const
void check_sort_list_is_declared(const sort_expression_list &SortExprList) const
sort_type_checker(const sort_specification &sort_spec, bool must_check_aliases=true)
constructs a sort expression checker.
void operator()(const sort_expression &x) const
Type check a sort expression. Throws an exception if the expression is not well typed.
void check_basic_sort_is_declared(const basic_sort &x) const
void check_for_empty_constructor_domains(const function_symbol_vector &constructors)
void check_alias_circularity(const data::basic_sort &lhs, const data::sort_expression &rhs, std::set< basic_sort > sort_already_seen, const std::map< basic_sort, sort_expression > &alias_map)
void check_sort_is_declared(const sort_expression &x) const
\brief An argument of a constructor of a structured sort
\brief A constructor for a structured sort
function_symbol_vector constructor_functions(const sort_expression &s) const
const structured_sort_constructor_list & constructors() const
Standard exception class for reporting runtime errors.
Search functions of the data library.
std::string pp(const identifier_string &x)
bool is_bool(const sort_expression &e)
Recogniser for sort expression Bool.
bool is_int(const sort_expression &e)
Recogniser for sort expression Int.
const basic_sort & int_()
Constructor for sort expression Int.
const basic_sort & nat()
Constructor for sort expression Nat.
bool is_nat(const sort_expression &e)
Recogniser for sort expression Nat.
bool is_pos(const sort_expression &e)
Recogniser for sort expression Pos.
const basic_sort & pos()
Constructor for sort expression Pos.
const basic_sort & real_()
Constructor for sort expression Real.
bool is_real(const sort_expression &e)
Recogniser for sort expression Real.
bool is_structured_sort(const atermpp::aterm &x)
Returns true if the term t is a structured sort.
std::string pp(const abstraction &x)
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.
data_expression normalize_sorts(const data_expression &x, const data::sort_specification &sortspec)
std::vector< function_symbol > function_symbol_vector
\brief vector of function_symbols
A class that takes a linear process specification and checks all tau-summands of that LPS for conflue...
This file describes the a sort_specification,.