Main Page | Namespace List | Class Hierarchy | Compound List | File List | Compound Members | File Members | Related Pages

Inference.hpp

Go to the documentation of this file.
00001 
00027 //
00028 //  file Inference.hpp
00029 //  defines class Inference
00030 //  started 17/04/2003, Barcelona Airport
00031 //  
00032 //  A detailed documentation of all inference rules is given in 
00033 //  the file Inference.cpp
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   // constructor, destructor
00062   Inference (const Inference& inf);
00063   void operator= (const Term& rhs);
00064   ~Inference ();
00065 
00066   // various particular kinds of inferences
00067   Inference (Rule r,                            // dummy quantifier removal
00068              const Formula& premise, const Position& p,
00069              const VarList& removedVars);
00070   Inference (Rule r,                            // forall_and_miniscope
00071              const Formula& premise, 
00072              const Position& p);
00073   Inference (Rule r,                            // forall_or_miniscope
00074              const Formula& premise,
00075              const Position& p,
00076              const IntList& toppledVarPositions,
00077              const IntList& toppledSubformulaPositions,
00078              int toppledSubformulaIndex);
00079   Inference (Rule r,                            // flattening
00080              const Formula& premise,
00081              const Position& p,
00082              int subformulaIndex);
00083 
00084   // structure
00085   Rule rule () const;
00086 
00087 private:
00088   // data for various kinds of inferences
00089   class Data;
00090   class DFormula;    // conclusion is Formula
00091   class DFormula1;   // conclusion is Formula, one premise
00092   class DClause;     // conclusion is Clause
00093   class Type1;       // forall-and-miniscope, swap
00094   class ForallOrMiniscope;
00095   class DummyQuantifierRemoval;
00096   class Flatten;
00097 
00098   // declared but not defined, to prevent on-heap allocation
00099   //  void* operator new (size_t);
00100 
00101  private:
00102   // structure
00103   Data* _data;
00104 }; // class Inference
00105 
00106 
00107 class InferenceList
00108   : public Lst<Inference>
00109 {
00110  public:
00111   // constructors
00112   InferenceList ();
00113   InferenceList (const InferenceList&);
00114   explicit InferenceList (const Inference& inf); // one-element list
00115   InferenceList (const Inference& inf, const InferenceList& tail);
00116   explicit InferenceList (LstData<Inference>*);
00117 
00118   // inherited functions
00119   const InferenceList& tail () const
00120     { return static_cast<const InferenceList&>(Lst<Inference>::tail()); }
00121 }; // class InferenceList
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   // structure
00139   int _counter;
00140   Rule _rule;
00141 }; // class Inference::Data
00142 
00143 
00144 // ******************* Inference definitions ************************
00145 
00146 inline
00147 Inference::~Inference () 
00148 {
00149   if (_data) {
00150     _data->deref ();
00151   }
00152 } // Inference::~Inference
00153 
00154 
00155 inline
00156 Inference::Inference (const Inference& t)
00157   :
00158   _data (t._data)
00159 {
00160   if (_data) {
00161     _data->ref ();
00162   }
00163 } // Inference::Inference
00164 
00165 
00166 inline
00167 Inference::Rule Inference::rule () const 
00168 { 
00169   return _data->rule(); 
00170 } // Inference::rule ()
00171 
00172 
00173 // **************** Inference::Data definitions *********************
00174 
00175 inline
00176 Inference::Data::Data (Inference::Rule rule)
00177   : 
00178   _counter (1),
00179   _rule (rule)
00180 {
00181 } // Inference::Data::Data (Rule rule)
00182 
00183 
00184 inline 
00185 Inference::Data::~Data ()
00186 {
00187   TRACER( "Inference::Data::~Data" );
00188 
00189   ASS (_counter == 0);
00190 } // Inference::Data::~Data ()
00191 
00192 
00193 inline
00194 void Inference::Data::ref () 
00195 { 
00196   ASS (this);
00197 
00198   _counter++;
00199 } // Inference::Data::ref ()
00200 
00201 
00202 inline
00203 Inference::Rule Inference::Data::rule () const 
00204 { 
00205   ASS (this);
00206 
00207   return _rule; 
00208 } // Inference::Data::rule ()
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 } // Inference::Data::deref ()
00222 
00223 
00224 // ******************* InferenceList definitions ************************
00225 
00226 inline
00227 InferenceList::InferenceList () 
00228   : 
00229   Lst<Inference> ()
00230 {
00231 } // InferenceList::InferenceList
00232 
00233 
00234 inline
00235 InferenceList::InferenceList (const InferenceList& ts)
00236   :
00237   Lst<Inference> (ts)
00238 {
00239 } // InferenceList::InferenceList
00240 
00241 
00242 inline
00243 InferenceList::InferenceList (LstData<Inference>* d)
00244   :
00245   Lst<Inference> (d)
00246 {
00247 } // InferenceList::InferenceList
00248 
00249 
00250 inline
00251 InferenceList::InferenceList (const Inference& hd, const InferenceList& tl)
00252   :
00253   Lst<Inference> (hd,tl)
00254 {
00255 } // InferenceList::InferenceList
00256 
00257 
00258 inline
00259 InferenceList::InferenceList (const Inference& hd)
00260   :
00261   Lst<Inference> (hd)
00262 {
00263 } // InferenceList::InferenceList
00264 
00265 
00266 
00267 #endif // __Inference__

Generated on Sat Jun 28 15:08:57 2003 for Vampire by doxygen 1.3.2