00001
00002
00003
00004
00005
00006
00007 #ifndef __Literal__
00008 #define __Literal__
00009
00010
00011 #include "Atom.hpp"
00012
00013
00014
00015
00016
00017 class Literal {
00018 private:
00019 class Data;
00020
00021 public:
00022
00023 Literal ();
00024 Literal (bool sign, const Atom& atom);
00025 Literal (const Literal& t);
00026 Literal (const VampireKernel::Literal* lit, const VampireKernel& kernel);
00027 ~Literal ();
00028 void operator= (const Literal& rhs);
00029
00030
00031 bool positive () const;
00032 bool negative () const;
00033 bool sign () const;
00034 const Atom& atom () const;
00035 bool exists () const;
00036
00037
00038 bool isless (Literal l) const;
00039 Compare compare (Literal l) const;
00040 void normalize ();
00041 bool isRenamingOf (Literal l, Substitution& sbst) const;
00042 private:
00043
00044 Data* _data;
00045 };
00046
00047
00048 class Literal::Data
00049 # if DEBUG_PREPRO
00050 : public Memory <CID_LITERAL>
00051 # endif
00052 {
00053 public:
00054 Data ();
00055 Data (bool sign, const Atom& atom);
00056
00057
00058 bool positive () const;
00059 bool negative () const;
00060 bool sign () const;
00061 const Atom& atom () const;
00062
00063 void ref ();
00064 void deref ();
00065
00066 protected:
00067
00068 int _counter;
00069 bool _sign;
00070 Atom _atom;
00071 };
00072
00073
00074 class LiteralList
00075 : public Lst<Literal>
00076 {
00077 public:
00078
00079 LiteralList ();
00080 LiteralList (const LiteralList&);
00081 explicit LiteralList (const Literal& t);
00082 LiteralList (const Literal& head, const LiteralList& tail);
00083 explicit LiteralList (LstData<Literal>*);
00084 LiteralList (const VampireKernel::Literal* lit, const VampireKernel& kernel);
00085
00086
00087 const LiteralList& tail () const
00088 { return static_cast<const LiteralList&>(Lst<Literal>::tail()); }
00089
00090
00091 bool isRenamingOf (LiteralList lst) const;
00092 private:
00093 bool isRenamingOf (LiteralList tried, LiteralList remaining, Substitution sbst) const;
00094 };
00095
00096
00097
00098
00099
00100 inline
00101 Literal::Literal ()
00102 :
00103 _data (0)
00104 {
00105 }
00106
00107
00108 inline
00109 Literal::~Literal ()
00110 {
00111 if (_data) {
00112 _data->deref ();
00113 }
00114 }
00115
00116
00117 inline
00118 Literal::Literal (const Literal& t)
00119 :
00120 _data (t._data)
00121 {
00122 if (_data) {
00123 _data->ref ();
00124 }
00125 }
00126
00127
00128 inline
00129 Literal::Literal (bool sign, const Atom& atom)
00130 :
00131 _data (new Data(sign,atom))
00132 {
00133 }
00134
00135
00136 inline
00137 bool Literal::exists () const
00138 {
00139 return _data != 0;
00140 }
00141
00142
00143 inline
00144 bool Literal::positive () const
00145 {
00146 return _data->sign();
00147 }
00148
00149
00150 inline
00151 bool Literal::negative () const
00152 {
00153 return ! _data->sign();
00154 }
00155
00156
00157 inline
00158 bool Literal::sign () const
00159 {
00160 return _data->sign();
00161 }
00162
00163
00164 inline
00165 const Atom& Literal::atom () const
00166 {
00167 return _data->atom();
00168 }
00169
00170
00171
00172
00173
00174 inline
00175 Literal::Data::Data (bool sign, const Atom& atom)
00176 :
00177 _counter (1),
00178 _sign (sign),
00179 _atom (atom)
00180 {
00181 }
00182
00183
00184 inline
00185 bool Literal::Data::sign () const
00186 {
00187 return _sign;
00188 }
00189
00190
00191 inline
00192 const Atom& Literal::Data::atom () const
00193 {
00194 return _atom;
00195 }
00196
00197
00198 inline
00199 void Literal::Data::ref ()
00200 {
00201 ASS (this);
00202
00203 _counter++;
00204 }
00205
00206
00207 inline
00208 void Literal::Data::deref ()
00209 {
00210 ASS (this);
00211 ASS (_counter > 0);
00212 _counter--;
00213
00214 if (_counter == 0) {
00215 delete this;
00216 }
00217 }
00218
00219
00220
00221
00222 inline
00223 LiteralList::LiteralList ()
00224 :
00225 Lst<Literal> ()
00226 {
00227 }
00228
00229
00230 inline
00231 LiteralList::LiteralList (const LiteralList& ts)
00232 :
00233 Lst<Literal> (ts)
00234 {
00235 }
00236
00237
00238 inline
00239 LiteralList::LiteralList (LstData<Literal>* d)
00240 :
00241 Lst<Literal> (d)
00242 {
00243 }
00244
00245
00246 inline
00247 LiteralList::LiteralList (const Literal &hd, const LiteralList& tl)
00248 :
00249 Lst<Literal> (hd,tl)
00250 {
00251 }
00252
00253
00254 inline
00255 LiteralList::LiteralList (const Literal &hd)
00256 :
00257 Lst<Literal> (hd)
00258 {
00259 }
00260
00261
00262 #endif // Literal