mCRL2
Loading...
Searching...
No Matches
is_sub_sort.h
Go to the documentation of this file.
1// Author(s): Wieger Wesselink
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
12#ifndef MCRL2_DATA_IS_SUB_SORT_H
13#define MCRL2_DATA_IS_SUB_SORT_H
14
19
20namespace mcrl2 {
21
22namespace data {
23
24namespace detail {
25
26inline
28{
30}
31
32inline
34{
35 if (sort_pos::is_pos(x) ) { return 0; }
36 if (sort_nat::is_nat(x) ) { return 1; }
37 if (sort_int::is_int(x) ) { return 2; }
38 if (sort_real::is_real(x)) { return 3; }
39 throw mcrl2::runtime_error("numeric_sort_value: argument " + data::pp(x) + " is not a numeric sort!");
40}
41
42} // namespace detail
43
44inline
46{
47 if (x1 == x2)
48 {
49 return true;
50 }
52 {
54 }
56 {
57 const container_sort& s1 = atermpp::down_cast<container_sort>(x1);
58 const container_sort& s2 = atermpp::down_cast<container_sort>(x2);
59 if (s1.container_name() == s2.container_name())
60 {
61 return is_sub_sort(s1.element_sort(), s2.element_sort());
62 }
63 else
64 {
65 return false;
66 }
67 }
69 {
70 const function_sort& s1 = atermpp::down_cast<function_sort>(x1);
71 const function_sort& s2 = atermpp::down_cast<function_sort>(x2);
72 if (s1.domain().size() != s2.domain().size())
73 {
74 return false;
75 }
76 if (!is_sub_sort(s2.codomain(), s1.codomain()))
77 {
78 return false;
79 }
80 auto const& s1_domain = s1.domain();
81 auto const& s2_domain = s2.domain();
82 return std::equal(s1_domain.begin(), s1_domain.end(), s2_domain.begin(), [&](const sort_expression& x, const sort_expression& y) { return is_sub_sort(x, y); });
83 }
84 throw mcrl2::runtime_error("is_sub_sort: not implemented yet!");
85}
86
87} // namespace data
88
89} // namespace mcrl2
90
91#endif // MCRL2_DATA_IS_SUB_SORT_H
size_type size() const
Returns the size of the term_list.
Definition aterm_list.h:256
\brief A container sort
const container_type & container_name() const
const sort_expression & element_sort() const
\brief A function sort
const sort_expression & codomain() const
const sort_expression_list & domain() const
\brief A sort expression
Standard exception class for reporting runtime errors.
Definition exception.h:27
The standard sort function_update.
bool is_numeric_sort(const sort_expression &x)
Definition is_sub_sort.h:27
std::size_t numeric_sort_value(const sort_expression &x)
Definition is_sub_sort.h:33
bool is_int(const sort_expression &e)
Recogniser for sort expression Int.
Definition int1.h:57
bool is_nat(const sort_expression &e)
Recogniser for sort expression Nat.
Definition nat1.h:56
bool is_pos(const sort_expression &e)
Recogniser for sort expression Pos.
Definition pos1.h:55
bool is_real(const sort_expression &e)
Recogniser for sort expression Real.
Definition real1.h:58
std::string pp(const abstraction &x)
Definition data.cpp:39
bool is_sub_sort(const sort_expression &x1, const sort_expression &x2)
Definition is_sub_sort.h:45
bool is_container_sort(const atermpp::aterm &x)
Returns true if the term t is a container sort.
bool is_function_sort(const atermpp::aterm &x)
Returns true if the term t is a function sort.
A class that takes a linear process specification and checks all tau-summands of that LPS for conflue...
Definition indexed_set.h:72
Provides utilities for working with data expressions of standard container sorts.
Provides utilities for working with data expressions of standard sorts.
add your file description here.