solver/Simplifier.h
00001 /*
00002  * Simplifier.h
00003  *
00004  *  Created on: Jul 29, 2009
00005  *      Author: isil
00006  */
00007 
00008 #ifndef SIMPLIFIER_H_
00009 #define SIMPLIFIER_H_
00010 
00011 #include "SkeletonSolver.h"
00012 #include "CNode.h"
00013 
00014 class DPLLSolver;
00015 
00016 
00017 
00018 class Simplifier {
00019 private:
00020         CNode* simplification;
00021         SkeletonSolver s;
00022         DPLLSolver* dpll_solver;
00023         bool switch_to_boolean;
00024 
00025 public:
00026 
00027         /*
00028          * Constructor for the Simplifier that only simplifies the
00029          * boolean structure, taking into account the background.
00030          * The background may come e.g., from the conflict clauses/
00031          * implications learned while solving the formula.
00032          */
00033         Simplifier(CNode* node, CNode* background);
00034 
00035 
00036         /*
00037          * Constructor for doing theory-specific simplification.
00038          * If switch_to_boolean is true, it will heuristically switch to
00039          * boolean simplification if theory-specific clauses take (both in total
00040          * and on average) too long to verify.
00041          */
00042         Simplifier(CNode* node, DPLLSolver* dpll_solver, bool switch_to_boolean);
00043 
00044         CNode* get_simplification();
00045         ~Simplifier();
00046 
00047 private:
00048         CNode* simplify(CNode* node);
00049 
00050         /*
00051          * Does the current background imply/contradict node?
00052          * It is assumed background is already on the stack.
00053          */
00054         inline bool is_implied(CNode* node);
00055         inline bool is_contradictory(CNode* node);
00056 
00057         inline void push_siblings(cnode_type ct, set<CNode*>& simplified_siblings,
00058                         set<CNode*>::iterator cur_it, set<CNode*>::iterator end_it);
00059 
00060         inline void push(CNode* node);
00061         inline void pop();
00062         /*
00063          * Queries whether the constraints on the stack are SAT.
00064          */
00065         inline bool sat();
00066 
00067 
00068 
00069 
00070 };
00071 
00072 #endif /* SIMPLIFIER_H_ */