|
6 | 6 |
|
7 | 7 | \*******************************************************************/
|
8 | 8 |
|
9 |
| - |
10 | 9 | #ifndef CPROVER_UTIL_STD_TYPES_H
|
11 | 10 | #define CPROVER_UTIL_STD_TYPES_H
|
12 | 11 |
|
@@ -1671,4 +1670,71 @@ inline complex_typet &to_complex_type(typet &type)
|
1671 | 1670 | return static_cast<complex_typet &>(type);
|
1672 | 1671 | }
|
1673 | 1672 |
|
| 1673 | +class mathematical_function_typet:public typet |
| 1674 | +{ |
| 1675 | +public: |
| 1676 | + mathematical_function_typet():typet(ID_mathematical_function) |
| 1677 | + { |
| 1678 | + subtypes().resize(2); |
| 1679 | + } |
| 1680 | + |
| 1681 | + // the domain of the function is composed of zero, one, or |
| 1682 | + // many variables |
| 1683 | + class variablet:public irept |
| 1684 | + { |
| 1685 | + public: |
| 1686 | + // the identifier is optional |
| 1687 | + irep_idt get_identifier() const |
| 1688 | + { |
| 1689 | + return get(ID_identifier); |
| 1690 | + } |
| 1691 | + |
| 1692 | + void set_identifier(const irep_idt &identifier) |
| 1693 | + { |
| 1694 | + return set(ID_identifier, identifier); |
| 1695 | + } |
| 1696 | + |
| 1697 | + typet &type() |
| 1698 | + { |
| 1699 | + return (typet &)add(ID_type); |
| 1700 | + } |
| 1701 | + |
| 1702 | + const typet &type() const |
| 1703 | + { |
| 1704 | + return (const typet &)find(ID_type); |
| 1705 | + } |
| 1706 | + }; |
| 1707 | + |
| 1708 | + using domaint=std::vector<variablet>; |
| 1709 | + |
| 1710 | + domaint &domain() |
| 1711 | + { |
| 1712 | + return (domaint &)subtypes()[0].subtypes(); |
| 1713 | + } |
| 1714 | + |
| 1715 | + const domaint &domain() const |
| 1716 | + { |
| 1717 | + return (const domaint &)subtypes()[0].subtypes(); |
| 1718 | + } |
| 1719 | + |
| 1720 | + variablet &add_variable() |
| 1721 | + { |
| 1722 | + auto &d=domain(); |
| 1723 | + d.push_back(variablet()); |
| 1724 | + return d.back(); |
| 1725 | + } |
| 1726 | + |
| 1727 | + // The codomain is the set of values that the |
| 1728 | + // function maps to (the "target") |
| 1729 | + typet &codomain() |
| 1730 | + { |
| 1731 | + return subtypes()[1]; |
| 1732 | + } |
| 1733 | + |
| 1734 | + const typet &codomain() const |
| 1735 | + { |
| 1736 | + return subtypes()[1]; |
| 1737 | + } |
| 1738 | +}; |
| 1739 | + |
1674 | 1740 | #endif // CPROVER_UTIL_STD_TYPES_H
|
0 commit comments