00001
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 #ifndef __Inference__
00037 #define __Inference__
00038
00039
00040 #include "Lst.hpp"
00041
00042
00043 class Term;
00044 class Formula;
00045 class Position;
00046 class VarList;
00047 class IntList;
00048
00049
00050 class Inference
00051 {
00052 public:
00053 enum Rule {
00054 FORALL_AND_MINISCOPE,
00055 FORALL_OR_MINISCOPE,
00056 DUMMY_QUANTIFIER_REMOVAL,
00057 FLATTEN,
00058 SWAP
00059 };
00060
00061
00062 Inference (const Inference& inf);
00063 void operator= (const Term& rhs);
00064 ~Inference ();
00065
00066
00067 Inference (Rule r,
00068 const Formula& premise, const Position& p,
00069 const VarList& removedVars);
00070 Inference (Rule r,
00071 const Formula& premise,
00072 const Position& p);
00073 Inference (Rule r,
00074 const Formula& premise,
00075 const Position& p,
00076 const IntList& toppledVarPositions,
00077 const IntList& toppledSubformulaPositions,
00078 int toppledSubformulaIndex);
00079 Inference (Rule r,
00080 const Formula& premise,
00081 const Position& p,
00082 int subformulaIndex);
00083
00084
00085 Rule rule () const;
00086
00087 private:
00088
00089 class Data;
00090 class DFormula;
00091 class DFormula1;
00092 class DClause;
00093 class Type1;
00094 class ForallOrMiniscope;
00095 class DummyQuantifierRemoval;
00096 class Flatten;
00097
00098
00099
00100
00101 private:
00102
00103 Data* _data;
00104 };
00105
00106
00107 class InferenceList
00108 : public Lst<Inference>
00109 {
00110 public:
00111
00112 InferenceList ();
00113 InferenceList (const InferenceList&);
00114 explicit InferenceList (const Inference& inf);
00115 InferenceList (const Inference& inf, const InferenceList& tail);
00116 explicit InferenceList (LstData<Inference>*);
00117
00118
00119 const InferenceList& tail () const
00120 { return static_cast<const InferenceList&>(Lst<Inference>::tail()); }
00121 };
00122
00123
00124
00125 class Inference::Data
00126 {
00127 public:
00128 Data ();
00129 explicit Data (Rule rule);
00130 ~Data ();
00131 Rule rule () const;
00132
00133 void ref ();
00134 void deref ();
00135 void destroy ();
00136
00137 protected:
00138
00139 int _counter;
00140 Rule _rule;
00141 };
00142
00143
00144
00145
00146 inline
00147 Inference::~Inference ()
00148 {
00149 if (_data) {
00150 _data->deref ();
00151 }
00152 }
00153
00154
00155 inline
00156 Inference::Inference (const Inference& t)
00157 :
00158 _data (t._data)
00159 {
00160 if (_data) {
00161 _data->ref ();
00162 }
00163 }
00164
00165
00166 inline
00167 Inference::Rule Inference::rule () const
00168 {
00169 return _data->rule();
00170 }
00171
00172
00173
00174
00175 inline
00176 Inference::Data::Data (Inference::Rule rule)
00177 :
00178 _counter (1),
00179 _rule (rule)
00180 {
00181 }
00182
00183
00184 inline
00185 Inference::Data::~Data ()
00186 {
00187 TRACER( "Inference::Data::~Data" );
00188
00189 ASS (_counter == 0);
00190 }
00191
00192
00193 inline
00194 void Inference::Data::ref ()
00195 {
00196 ASS (this);
00197
00198 _counter++;
00199 }
00200
00201
00202 inline
00203 Inference::Rule Inference::Data::rule () const
00204 {
00205 ASS (this);
00206
00207 return _rule;
00208 }
00209
00210
00211 inline
00212 void Inference::Data::deref ()
00213 {
00214 ASS (this);
00215 ASS (_counter > 0);
00216 _counter--;
00217
00218 if (_counter == 0) {
00219 destroy ();
00220 }
00221 }
00222
00223
00224
00225
00226 inline
00227 InferenceList::InferenceList ()
00228 :
00229 Lst<Inference> ()
00230 {
00231 }
00232
00233
00234 inline
00235 InferenceList::InferenceList (const InferenceList& ts)
00236 :
00237 Lst<Inference> (ts)
00238 {
00239 }
00240
00241
00242 inline
00243 InferenceList::InferenceList (LstData<Inference>* d)
00244 :
00245 Lst<Inference> (d)
00246 {
00247 }
00248
00249
00250 inline
00251 InferenceList::InferenceList (const Inference& hd, const InferenceList& tl)
00252 :
00253 Lst<Inference> (hd,tl)
00254 {
00255 }
00256
00257
00258 inline
00259 InferenceList::InferenceList (const Inference& hd)
00260 :
00261 Lst<Inference> (hd)
00262 {
00263 }
00264
00265
00266
00267 #endif // __Inference__