00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044 #include "expr.h"
00045
00046 #ifndef _CVC_lite__assumptions_h_
00047 #define _CVC_lite__assumptions_h_
00048
00049 #include <iostream>
00050 #include <functional>
00051 #include <iterator>
00052 #include <vector>
00053
00054
00055
00056
00057 namespace CVCL {
00058
00059
00060 class AssumptionsValue;
00061 class AVHash;
00062
00063 class Assumptions {
00064 private:
00065 AssumptionsValue *d_val;
00066
00067 Assumptions(AssumptionsValue *v);
00068
00069 friend bool findExpr(const Assumptions& a, const Expr& e,
00070 std::vector<Theorem>& gamma);
00071 friend bool findExprs(const Assumptions& a, const std::vector<Expr>& es,
00072 std::vector<Theorem>& gamma);
00073
00074
00075 const Theorem& findTheorem(const Expr& e) const;
00076
00077
00078 public:
00079
00080 Assumptions() : d_val(NULL) { }
00081
00082 Assumptions(const std::vector<Theorem>& v);
00083
00084 Assumptions(const Theorem& t);
00085
00086 Assumptions(const Theorem& t1, const Theorem& t2);
00087
00088
00089 ~Assumptions();
00090
00091
00092
00093 Assumptions(const Assumptions &assump);
00094
00095 Assumptions &operator=(const Assumptions &assump);
00096
00097 bool isNull() const { return d_val == NULL; }
00098
00099
00100 void init();
00101
00102
00103 Assumptions copy() const;
00104
00105
00106 void add(const Theorem& t);
00107 void add(const Assumptions& a);
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122 const Theorem& operator[](const Expr& e) const;
00123
00124
00125 const Theorem& find(const Expr& e) const;
00126
00127
00128 void clear();
00129
00130
00131 int size() const;
00132
00133
00134
00135 class iterator : public std::iterator<std::input_iterator_tag,Theorem,ptrdiff_t> {
00136
00137 friend class Assumptions;
00138 private:
00139 std::vector<Theorem>::const_iterator d_it;
00140
00141 iterator(const std::vector<Theorem>::const_iterator& i): d_it(i) { }
00142 public:
00143
00144 iterator() { }
00145
00146 ~iterator() { }
00147
00148 bool operator==(const iterator& i) const { return (d_it == i.d_it); }
00149
00150 bool operator!=(const iterator& i) const { return (d_it != i.d_it); }
00151
00152 const Theorem& operator*() const { return *d_it; }
00153
00154 const Theorem* operator->() const { return &(operator*()); }
00155
00156 iterator& operator++();
00157
00158 class Proxy {
00159 const Theorem* d_t;
00160 public:
00161 Proxy(const Theorem& t) : d_t(&t) { }
00162 const Theorem& operator*() { return *d_t; }
00163 };
00164
00165 Proxy operator++(int);
00166 };
00167
00168 iterator begin() const;
00169 iterator end() const;
00170
00171
00172 void add(const iterator& it) {
00173 add(*it);
00174 }
00175
00176
00177 bool empty() const;
00178
00179
00180 bool isConst() const;
00181 void setConst();
00182
00183
00184 friend Assumptions operator+(const Assumptions& a1,
00185 const Assumptions& a2);
00186
00187 friend Assumptions operator-(const Assumptions& a1,
00188 const Assumptions& a2);
00189
00190
00191
00192 friend Assumptions operator-(const Assumptions& a,
00193 const Expr& e);
00194 friend Assumptions operator-(const Assumptions& a,
00195 const std::vector<Expr>& es);
00196
00197
00198 std::string toString() const;
00199
00200 friend std::ostream&
00201 operator<<(std::ostream& os, const Assumptions &assump);
00202
00203 friend bool operator==(const Assumptions& a1, const Assumptions& a2);
00204 friend bool operator!=(const Assumptions& a1, const Assumptions& a2);
00205
00206 void print() const;
00207 };
00208
00209 bool operator==(const AssumptionsValue& a1, const AssumptionsValue& a2);
00210 bool operator!=(const AssumptionsValue& a1, const AssumptionsValue& a2);
00211
00212
00213 inline bool operator==(const Assumptions& a1, const Assumptions& a2) {
00214 if (a1.d_val == a2.d_val) return true;
00215 if (a1.d_val == NULL || a2.d_val == NULL) return false;
00216 return (*a1.d_val == *a2.d_val);
00217 }
00218
00219 inline bool operator!=(const Assumptions& a1, const Assumptions& a2) {
00220 if (a1.d_val == a2.d_val) return false;
00221 if (a1.d_val == NULL || a2.d_val == NULL) return true;
00222 return (*a1.d_val != *a2.d_val);
00223 }
00224
00225 }
00226
00227 #endif