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