#include "RunTimes.h"
// BE VERY CAREFUL> Update the Category Names to match.
-std::string RunTimes::CategoryNames[] = { "Transforming", "Simplifying", "Parsing", "CNF Conversion", "Bit Blasting", "SAT Solving", "Bitvector Solving","Create SubstitutionMap", "Sending to SAT Solver", "Counter Example Generation","SAT Simplification"};
+std::string RunTimes::CategoryNames[] = { "Transforming", "Simplifying", "Parsing", "CNF Conversion", "Bit Blasting", "SAT Solving", "Bitvector Solving","Create SubstitutionMap", "Sending to SAT Solver", "Counter Example Generation","SAT Simplification", "Constant Bit Propagation"};
namespace BEEV
{
CreateSubstitutionMap,
SendingToSAT,
CounterExampleGeneration,
- SATSimplifying
+ SATSimplifying,
+ ConstantBitPropagation
};
static std::string CategoryNames[];
#include "STP.h"
#include "DifficultyScore.h"
#include "../to-sat/AIG/ToSATAIG.h"
+#include "../simplifier/constantBitP/ConstantBitPropagation.h"
+#include "../simplifier/constantBitP/NodeToFixedBitsMap.h"
namespace BEEV {
}
while (inputToSAT != simplified_solved_InputToSAT);
+#ifdef WITHCBITP
+ if (bm->UserFlags.bitConstantProp_flag)
+ {
+ bm->ASTNodeStats("Before Constant Bit Propagation begins: ",
+ simplified_solved_InputToSAT);
+
+ bm->GetRunTimes()->start(RunTimes::ConstantBitPropagation);
+ simplifier::constantBitP::ConstantBitPropagation cb(simp, bm->defaultNodeFactory
+ );
+ simplified_solved_InputToSAT = cb.topLevelBothWays(
+ simplified_solved_InputToSAT);
+ bm->GetRunTimes()->stop(RunTimes::ConstantBitPropagation);
+ }
+#endif
+
+
bm->ASTNodeStats("Before SimplifyWrites_Inplace begins: ",
simplified_solved_InputToSAT);
delete bvsolver;
bvsolver = new BVSolver(bm,simp);
+ // If it doesn't contain array operations, use ABC's CNF generation.
+ if (!arrayops)
{
- ToSATAIG toSATAIG(bm);
+ simplifier::constantBitP::ConstantBitPropagation* cb = NULL;
- // If it doesn't contain array operations, use ABC's CNF generation.
- res =
- Ctr_Example->CallSAT_ResultCheck(NewSolver,
- simplified_solved_InputToSAT,
+#ifdef WITHCBITP
+ if (bm->UserFlags.bitConstantProp_flag)
+ {
+ bm->ASTNodeStats("Before Constant Bit Propagation begins: ",
+ simplified_solved_InputToSAT);
+
+ bm->GetRunTimes()->start(RunTimes::ConstantBitPropagation);
+
+ cb = new simplifier::constantBitP::ConstantBitPropagation(simp, bm->defaultNodeFactory);
+ cb->getFixedMap(simplified_solved_InputToSAT);
+
+ bm->GetRunTimes()->stop(RunTimes::ConstantBitPropagation);
+ }
+#endif
+
+ ToSATAIG toSATAIG(bm,cb);
+
+ res =
+ Ctr_Example->CallSAT_ResultCheck(NewSolver,
+ simplified_solved_InputToSAT,
orig_input,
- (arrayops ? ((ToSATBase*)tosat): ((ToSATBase*)&toSATAIG))
+ &toSATAIG
);
+
+ delete cb;
}
+ else
+ {
+ res =
+ Ctr_Example->CallSAT_ResultCheck(NewSolver,
+ simplified_solved_InputToSAT,
+ orig_input,
+ tosat
+ );
+
+ }
if (SOLVER_UNDECIDED != res)
{
* step 5. Call SAT to determine if input is SAT or UNSAT
********************************************************************/
-typedef enum {PRINT_BACK_C=1, PRINT_BACK_CVC, PRINT_BACK_SMTLIB2,PRINT_BACK_SMTLIB1, PRINT_BACK_GDL, PRINT_BACK_DOT, OUTPUT_BENCH, OUTPUT_CNF, USE_SIMPLIFYING_SOLVER, SMT_LIB2_FORMAT, SMT_LIB1_FORMAT} OptionType;
+typedef enum {PRINT_BACK_C=1, PRINT_BACK_CVC, PRINT_BACK_SMTLIB2,PRINT_BACK_SMTLIB1, PRINT_BACK_GDL, PRINT_BACK_DOT, OUTPUT_BENCH, OUTPUT_CNF, USE_SIMPLIFYING_SOLVER, SMT_LIB2_FORMAT, SMT_LIB1_FORMAT, DISABLE_CBITP} OptionType;
int main(int argc, char ** argv) {
char * infile = NULL;
helpstring +=
"-d : check counterexample\n";
helpstring +=
+ "--disable-cbitp : disable constant bit propagation\n";
+ helpstring +=
"-e : expand finite-for construct\n";
helpstring +=
"-f : number of abstraction-refinement loops\n";
lookup.insert(make_pair(tolower("--simplifying-minisat"),USE_SIMPLIFYING_SOLVER));
lookup.insert(make_pair(tolower("--SMTLIB2"),SMT_LIB2_FORMAT));
lookup.insert(make_pair(tolower("--SMTLIB1"),SMT_LIB1_FORMAT));
+ lookup.insert(make_pair(tolower("--disable-cbitp"),DISABLE_CBITP));
switch(lookup[tolower(argv[i])])
{
+ case DISABLE_CBITP:
+ bm->UserFlags.bitConstantProp_flag = false;
+ break;
case PRINT_BACK_C:
bm->UserFlags.print_STPinput_back_C_flag = true;
onePrintBack = true;
#include <map>
#include "FixedBits.h"
#include "../../AST/AST.h"
+#include "NodeToFixedBitsMap.h"
namespace BEEV
{
public:
NodeToFixedBitsMap* fixedMap;
- //MultiplicationStatsMap* multiplicationStats;
+
+#ifdef WITHCBITP
+ MultiplicationStatsMap* multiplicationStats;
+#endif
+
WorkList *workList;
Dependencies * dependents;
Simplifier *simplifier;
~ConstantBitPropagation()
{
+ if (fixedMap != NULL)
+ delete fixedMap;
}
;
private:
ASTNodeToSATVar nodeToSATVar;
+ simplifier::constantBitP::ConstantBitPropagation* cb;
// don't assign or copy construct.
ToSATAIG& operator = (const ToSATAIG& other);
ToSATAIG(STPMgr * bm) :
ToSATBase(bm)
{
+ cb = NULL;
}
+ ToSATAIG(STPMgr * bm, simplifier::constantBitP::ConstantBitPropagation* cb_) :
+ ToSATBase(bm)
+ {
+ cb = cb_;
+ }
+
+
void
ClearAllTables()
{
CallSAT(MINISAT::Solver& satSolver, const ASTNode& input)
{
BBNodeManagerAIG mgr;
- BitBlaster<BBNodeAIG, BBNodeManagerAIG> bb(&mgr);
- set<BBNodeAIG> support;
+ BitBlaster<BBNodeAIG, BBNodeManagerAIG> bb(&mgr,cb);
bm->GetRunTimes()->start(RunTimes::BitBlasting);
- BBNodeAIG BBFormula = bb.BBForm(input, support);
+ BBNodeAIG BBFormula = bb.BBForm(input);
bm->GetRunTimes()->stop(RunTimes::BitBlasting);
- assert(support.size() ==0); // hot handled yet..
assert(satSolver.nVars() ==0);
Cnf_Dat_t* cnfData = NULL;
+
mgr.toCNF(BBFormula, cnfData, nodeToSATVar);
// Free the memory in the AIGs.
* the vector corresponds to bit 0 -- the low-order bit.
********************************************************************/
- using simplifier::constantBitP::FixedBits;
+using simplifier::constantBitP::FixedBits;
#define BBNodeVec vector<BBNode>
#define BBNodeVecMap map<ASTNode, vector<BBNode> >
v.reserve(1);
v.push_back(bb);
bb = v[0];
+ updateTerm(n, v, support);
}
template <class BBNode, class BBNodeManagerT>
if (debug_do_check)
check(result, term);
+ updateTerm(term,result,support);
return (BBTermMemo[term] = result);
}
+template <class BBNode, class BBNodeManagerT>
+const BBNode BitBlaster<BBNode,BBNodeManagerT>::BBForm(const ASTNode& form)
+{
+ BBNodeSet support;
+ BBNode r= BBForm(form,support);
+ vector<BBNode> v;
+ v.insert(v.end(), support.begin(), support.end());
+ v.push_back(r);
+ return nf->CreateNode(AND,v);
+}
+
// bit blast a formula (boolean term). Result is one bit wide,
template <class BBNode, class BBNodeManagerT>
const BBNode BitBlaster<BBNode,BBNodeManagerT>::BBForm(const ASTNode& form, BBNodeSet& support) {
if (debug_do_check)
check(result, form);
+ updateForm(form,result,support);
+
return (BBFormMemo[form] = result);
}
void updateTerm(const ASTNode&n, vector<BBNode>& bb, set<BBNode>& support);
void updateForm(const ASTNode&n, BBNode& bb, set<BBNode>& support);
+ const BBNode BBForm(const ASTNode& form, set<BBNode>& support);
+
public:
BBNodeManagerT* nf;
}
//Bitblast a formula
- const BBNode BBForm(const ASTNode& form, set<BBNode>& support);
+ const BBNode BBForm(const ASTNode& form);
}; //end of class BitBlaster
}
{
BBNodeManagerASTNode nm(bm);
BitBlaster<ASTNode,BBNodeManagerASTNode> BB(&nm);
- set<ASTNode> set;
- BBFormula = BB.BBForm(input,set);
- assert(set.size() == 0); // doesn't yet work.
+ BBFormula = BB.BBForm(input);
}
bm->ASTNodeStats("after bitblasting: ", BBFormula);