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

SymCounter.hpp

Go to the documentation of this file.
00001 
00027 //
00028 //  file SymCounter.hpp
00029 //  defines class SymCounter counting occurrences of function and predicate symbols
00030 //
00031 //  01/05/2002, Manchester
00032 //
00033 
00034 #ifndef __sym_counter__
00035 #define __sym_counter__
00036 
00037 
00038 class Problem;
00039 
00040 
00041 #include "Signature.hpp"
00042 #include "Unit.hpp"
00043 
00044 
00045 using namespace std;
00046 
00047 
00048 // ***************** class SymCounter, definition ****************************
00049 
00050 
00051 class SymCounter { 
00052  public:
00053 
00054   class Fun {
00055     Signature::Fun* _fun;
00056     int _occ;
00057    public:
00058     Fun () : _occ(0) {}
00059     void fun (Signature::Fun* f) { _fun = f; }
00060     int occ () const { return _occ; }
00061     Signature::Fun* fun () { return _fun; }
00062     void add (int add) { _occ += add; }
00063   };
00064 
00065   class Pred {
00066     Signature::Pred* _pred;
00067     int _pocc;  // positive occurrences
00068     int _nocc;  // negative occurrences
00069     int _docc;  // double occurrences (under equivalence)
00070    public:
00071     Pred () 
00072       : _pocc (0), 
00073         _nocc (0),
00074         _docc (0) 
00075         {}
00076     void pred (Signature::Pred* p) { _pred = p; }
00077     int pocc () const { return _pocc; }
00078     int nocc () const { return _nocc; }
00079     int docc () const { return _docc; }
00080     Signature::Pred* pred () { return _pred; }
00081     void add (int polarity, int add);
00082   };
00083 
00084   explicit SymCounter (Signature&);
00085   ~SymCounter ();
00086 
00087   // counting functions
00088   void count (Problem&, int);
00089   void count (Unit, int);
00090   void count (Clause, int);
00091   void count (Formula, int polarity, int add);
00092   void count (Literal, int);
00093   void count (Atom a, int polarity, int add);
00094   void count (Term t, int add);
00095 
00096   // get 
00097   Pred* get (const Signature::Pred* p) { return _preds + p->number(); }
00098   Fun* get (const Signature::Fun* f) { return _funs + f->number(); }
00099 
00100   // output
00101   void output (ostream& str) const;
00102 
00103   static SymCounter* norm;    // used for normalisation
00104 
00105  private:
00106 
00107   // structure
00108   int _noOfPreds;
00109   int _noOfFuns;
00110   Pred* _preds;
00111   Fun* _funs;
00112 }; // class SymCounter
00113 
00114 
00115 
00116 inline 
00117 ostream& operator << (ostream& str, const SymCounter& c)
00118 {
00119   c.output(str);
00120   return str;
00121 } // ostream& operator << (ostream& str, const SymCounter& c)
00122 
00123 
00124 #endif // __sym_counter__

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