solver/Clause.h
00001 /*
00002  * Clause.h
00003  *
00004  *  Created on: Feb 8, 2009
00005  *      Author: tdillig
00006  */
00007 
00008 #ifndef CLAUSE_H_
00009 #define CLAUSE_H_
00010 #include <set>
00011 #include <map>
00012 #include <string>
00013 using namespace std;
00014 
00015 class EqLeaf;
00016 class ILPLeaf;
00017 class QuantifiedLeaf;
00018 class CNode;
00019 class Term;
00020 class Leaf;
00021 class ModLeaf;
00022 
00023 class Clause {
00024 public:
00025         set<EqLeaf*> pos_eq;
00026         set<EqLeaf*> neg_eq;
00027         set<ILPLeaf*> pos_ilp;
00028         set<ILPLeaf*> neg_ilp;
00029         set<ModLeaf*> pos_mod;
00030         set<ModLeaf*> neg_mod;
00031         set<QuantifiedLeaf*> pos_universal;
00032         set<QuantifiedLeaf*> neg_universal;
00033 
00034         /*
00035          * A mapping from old terms to new their denesting variables
00036          * We use this map to avoid introducing redundant variables.
00037          */
00038         map<Term*, Term*> reverse_denestings;
00039 
00040 
00041 public:
00042         Clause();
00043         Clause(CNode* node);
00044 
00045         /*
00046          * Returns true if this clause subsumes other.
00047          */
00048         bool subsumes(Clause & other);
00049 
00050         /*
00051          * Checks whether this clause has an obvious tautology or
00052          * contradiction
00053          */
00054         bool drop_clause();
00055 
00056         string to_string(string c);
00057 
00058         /*
00059          * Converts clause to CNode.
00060          */
00061         CNode* to_cnode(bool use_and = true);
00062 
00063 
00064 
00065 
00066         /*
00067          * Introduces temporaries to ensure function terms do not
00068          * contain arithmetic terms.
00069          */
00070         void denest(map<Term*, Term*>* denestings = NULL);
00071 
00072         virtual ~Clause();
00073 private:
00074         void add_literal(CNode* leaf);
00075         Term* denest_term(Term* t, set<CNode*>& to_add, int& counter,
00076                         map<Term*, Term*>* denestings, bool denest_arithmetic,
00077                         bool denest_function);
00078         CNode* denest_leaf(Leaf* l, set<CNode*>& to_add, int& counter,
00079                         map<Term*, Term*>* denestings);
00080         void make_false();
00081 
00082 };
00083 
00084 #endif /* CLAUSE_H_ */