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

Clause.hpp

Go to the documentation of this file.
00001 
00027 //
00028 //  file Clause.hpp 
00029 //  defines class Clause
00030 //
00031 
00032 
00033 #ifndef __Clause__
00034 #define __Clause__
00035 
00036 
00037 #include "Literal.hpp"
00038 
00039 
00040 class Clause 
00041 {
00042  private:
00043   class Data;
00044 
00045  public:
00046   // constructor
00047   Clause ();
00048   explicit Clause (const LiteralList& lits);
00049   Clause (const Clause& t);
00050   Clause (const VampireKernel::Clause*, const VampireKernel& kernel);
00051   ~Clause ();
00052   void operator= (const Clause& rhs);
00053 
00054   // structure access
00055   const LiteralList& literals () const;
00056 
00057   //miscellaneous
00058   bool isless (Clause l) const;       // comparison, used for normalisation
00059   Compare compare (Clause l) const; // comparison, used for normalisation
00060   void normalize ();
00061   // properties
00062   bool isEqualityAxiom () const;  // is one of the equality axioms
00063   bool isEmpty () const;
00064   bool isFunctionDefinition (Term& lhs, Term& rhs) const; 
00065   bool isRenamingOf (Clause c) const;
00066  private:
00067   // structure
00068   Data* _data;
00069 
00070   // equality axiom check
00071   bool isReflexivityAxiom () const;
00072   bool isFunctionReflexivityAxiom () const;
00073   bool isPredicateReflexivityAxiom () const;
00074   bool isSymmetryAxiom () const;
00075   bool isTransitivityAxiom () const;
00076 }; // class Clause
00077 
00078 
00079 class Clause::Data
00080 #   if DEBUG_PREPRO
00081     : public Memory <CID_CLAUSE>
00082 #   endif
00083 {
00084  public:
00085   Data ();
00086   explicit Data (const LiteralList& literals);
00087 
00088   // structure access
00089   const LiteralList& literals () const;
00090 
00091   void ref ();
00092   void deref ();
00093 
00094  private:
00095   // structure
00096   int _counter;
00097   LiteralList _literals;
00098 }; // class Clause::Data
00099 
00100 
00101 class ClauseList 
00102 : public Lst<Clause>
00103 {
00104  public:
00105   // constructors
00106   ClauseList ();
00107   ClauseList (const ClauseList&);
00108   explicit ClauseList (const Clause& t); // one-element list
00109   ClauseList (const Clause& head, const ClauseList& tail);
00110   explicit ClauseList (LstData<Clause>*);
00111 
00112   // structure access
00113   const LiteralList& literals ();
00114 
00115   // inherited functions
00116   const ClauseList& tail () const
00117     { return static_cast<const ClauseList&>(Lst<Clause>::tail()); }
00118 }; // class ClauseList
00119 
00120 
00121 ostream& operator << (ostream&, Clause);
00122 
00123 
00124 // ******************* class Clause, implementation *********************
00125 
00126 
00127 inline
00128 Clause::Clause () 
00129   : 
00130   _data (0) 
00131 {
00132 } // Clause::Clause
00133 
00134 
00135 inline
00136 Clause::~Clause () 
00137 {
00138   if (_data) {
00139     _data->deref ();
00140   }
00141 } // Clause::~Clause
00142 
00143 
00144 inline
00145 Clause::Clause (const Clause& t)
00146   :
00147   _data (t._data)
00148 {
00149   if (_data) {
00150     _data->ref ();
00151   }
00152 } // Clause::Clause
00153 
00154 
00155 inline
00156 Clause::Clause (const LiteralList& literals)
00157   :
00158   _data (new Data(literals))
00159 {
00160 } // Clause::Clause (const LiteralList&)
00161 
00162 
00163 inline
00164 const LiteralList& Clause::literals () const
00165 {
00166   return _data->literals();
00167 } // Clause::literals ()
00168 
00169 
00170 inline
00171 bool Clause::isEmpty () const
00172 { 
00173   return literals().isEmpty(); 
00174 } // Clause::isEmpty ()
00175 
00176 
00177 // true is this clause is a renaming of c
00178 // 03/10/2002 Manchester
00179 inline
00180 bool Clause::isRenamingOf (Clause c) const
00181 {
00182   return literals().isRenamingOf (c.literals());
00183 } // Clause::isRenamingOf
00184 
00185 
00186 // **************** class Clause::Data implementation ******************
00187 
00188 
00189 inline
00190 Clause::Data::Data (const LiteralList& literals) 
00191   : 
00192   _counter (1),
00193   _literals (literals)
00194 {
00195 } // Clause::Data::Data
00196 
00197 
00198 inline
00199 const LiteralList& Clause::Data::literals () const
00200 {
00201   return _literals;
00202 } // Clause::Data::literals ()
00203 
00204 
00205 inline
00206 void Clause::Data::ref () 
00207 { 
00208   ASS (this);
00209 
00210   _counter++;
00211 } // Clause::Data::ref ()
00212 
00213 
00214 inline
00215 void Clause::Data::deref () 
00216 { 
00217   ASS (this);
00218   ASS (_counter > 0);
00219   _counter--;
00220 
00221   if (_counter == 0) {
00222     delete this;
00223   }
00224 } // Clause::Data::deref ()
00225 
00226 
00227 // ******************* ClauseList definitions ************************
00228 
00229 inline
00230 ClauseList::ClauseList () 
00231   : 
00232   Lst<Clause> ()
00233 {
00234 } // ClauseList::ClauseList
00235 
00236 
00237 inline
00238 ClauseList::ClauseList (const ClauseList& ts)
00239   :
00240   Lst<Clause> (ts)
00241 {
00242 } // ClauseList::ClauseList
00243 
00244 
00245 inline
00246 ClauseList::ClauseList (LstData<Clause>* d)
00247   :
00248   Lst<Clause> (d)
00249 {
00250 } // ClauseList::ClauseList
00251 
00252 
00253 inline
00254 ClauseList::ClauseList (const Clause &hd, const ClauseList& tl)
00255   :
00256   Lst<Clause> (hd,tl)
00257 {
00258 } // ClauseList::ClauseList
00259 
00260 
00261 inline
00262 ClauseList::ClauseList (const Clause &hd)
00263   :
00264   Lst<Clause> (hd)
00265 {
00266 } // ClauseList::ClauseList
00267 
00268 
00269 
00270 #endif // __Clause__

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