bm->counterexample_checking_during_refinement = true;
}
+ if(bm->UserFlags.stats_flag)
+ simp->printCacheStatus();
+
+ simp->ClearCaches();
+ bm->ClearAllTables();
+
res =
Ctr_Example->CallSAT_ResultCheck(NewSolver,
simplified_solved_InputToSAT,
// insert back_children at end of front_children
ASTVec &front_children = n_ptr->_children;
+ front_children.reserve(front_children.size()+ back_children.size());
front_children.insert(front_children.end(),
back_children.begin(),
return 1;
unsigned newn = 1;
- ASTVec c = a.GetChildren();
- for (ASTVec::iterator it = c.begin(), itend = c.end(); it != itend; it++)
+ const ASTVec& c = a.GetChildren();
+ for (ASTVec::const_iterator it = c.begin(), itend = c.end(); it != itend; it++)
newn += NodeSize(*it);
return newn;
}
ASTNode s = tosat->SATVar_to_ASTMap(i);
//assemble the counterexample here
- if (s.GetKind() == BVGETBIT && s[0].GetKind() == SYMBOL)
+ if (!s.IsNull() && s.GetKind() == BVGETBIT && s[0].GetKind() == SYMBOL)
{
const ASTNode& symbol = s[0];
const unsigned int symbolWidth = symbol.GetValueWidth();
}
else
{
- if (s.GetKind() == SYMBOL && s.GetType() == BOOLEAN_TYPE)
+ if (!s.IsNull() && s.GetKind() == SYMBOL && s.GetType() == BOOLEAN_TYPE)
{
const char * zz = s.GetName();
//if the variables are not cnf variables then add
cout << "Satisfying assignment: " << endl;
for (int i = 0; i < num_vars; i++)
{
- if (newS.model[i] == MINISAT::l_True)
+ ASTNode s = tosat->SATVar_to_ASTMap(i);
+ if (s.IsNull())
+ continue;
+
+ if (newS.model[i] == MINISAT::l_True)
{
- ASTNode s = tosat->SATVar_to_ASTMap(i);
cout << s << endl;
}
else if (newS.model[i] == MINISAT::l_False)
{
- ASTNode s = tosat->SATVar_to_ASTMap(i);
cout << bm->CreateNode(NOT, s) << endl;
}
}
void Simplifier::printCacheStatus()
{
- cerr << SimplifyMap->size() << endl;
- cerr << SimplifyNegMap->size() << endl;
- //cerr << TermsAlreadySeenMap.size() << endl;
-
- cerr << SimplifyMap->bucket_count() << endl;
- cerr << SimplifyNegMap->bucket_count() << endl;
- //cerr << TermsAlreadySeenMap.bucket_count() << endl;
+ cerr << "SimplifyMap:" << SimplifyMap->size() << ":" << SimplifyMap->bucket_count() << endl;
+ cerr << "SimplifyNegMap:" << SimplifyNegMap->size() << ":" << SimplifyNegMap->bucket_count() << endl;
+ cerr << "AlwaysTrueFormMap" << AlwaysTrueFormMap.size() << ":" << AlwaysTrueFormMap.bucket_count() << endl;
+ cerr << "MultInverseMap" << MultInverseMap.size() << ":" << MultInverseMap.bucket_count() << endl;
+ cerr << "ReadOverWrite_NewName_Map" << ReadOverWrite_NewName_Map->size() << ":" << ReadOverWrite_NewName_Map->bucket_count() << endl;
+ cerr << "NewName_ReadOverWrite_Map" << NewName_ReadOverWrite_Map.size() << ":" << NewName_ReadOverWrite_Map.bucket_count() << endl;
+ cerr << "substn_map" << substitutionMap.Return_SolverMap()->size() << ":" << substitutionMap.Return_SolverMap()->bucket_count() << endl;
+
} //printCacheStatus()
};//end of namespace
MultInverseMap.clear();
substitutionMap.clear();
}
+
+ // These can be cleared (to save memory) without changing the answer.
+ void ClearCaches()
+ {
+ AlwaysTrueFormMap.clear();
+ MultInverseMap.clear();
+ SimplifyMap->clear();
+ SimplifyNegMap->clear();
+ }
+
};//end of class Simplifier
}; //end of namespace
#endif
* unsat. else continue.
*/
bool ToSAT::toSATandSolve(MINISAT::Solver& newSolver,
- ClauseList& cll,
- bool add_xor_clauses,
+ ClauseList& cll,
+ bool final,
+ CNFMgr*& cm,
+ bool add_xor_clauses,
bool enable_clausal_abstraction)
{
CountersAndStats("SAT Solver", bm);
bm->GetRunTimes()->start(RunTimes::SendingToSAT);
-
int input_clauselist_size = cll.size();
if (cll.size() == 0)
{
// Free the clause list before SAT solving.
cll.deleteJustVectors();
+ // Remove references to Tseitin variables.
+ // Delete the cnf generator.
+ if (final)
+ {
+ for (int i =0; i < _SATVar_to_AST_Vector.size();i++)
+ {
+ ASTNode n = _SATVar_to_AST_Vector[i];
+ if (!n.IsNull() && isTseitinVariable(n))
+ {
+ _ASTNode_to_SATVar_Map.erase(n);
+ _SATVar_to_AST_Vector[i] = ASTNode();
+ }
+ }
+ delete cm;
+ cm = NULL;
+ }
+
+
bm->GetRunTimes()->stop(RunTimes::SendingToSAT);
bm->GetRunTimes()->start(RunTimes::Solving);
} //End of SortClauseList_IntoBuckets()
bool ToSAT::CallSAT_On_ClauseBuckets(MINISAT::Solver& SatSolver,
- ClauseBuckets * cb)
+ ClauseBuckets * cb, CNFMgr*& cm)
{
ClauseBuckets::iterator it = cb->begin();
ClauseBuckets::iterator itend = cb->end();
for(int count=1;it!=itend;it++, count++)
{
ClauseList *cl = (*it).second;
- sat = toSATandSolve(SatSolver,*cl);
+ sat = toSATandSolve(SatSolver,*cl, count==cb->size(),cm);
if(!sat)
{
file.close();
}
- CNFMgr cm(bm);
- ClauseList* cl = cm.convertToCNF(BBFormula);
+ // The CNFMgr is deleted inside the CallSAT_On_ClauseBuckets,
+ // just before the final call to the SAT solver.
- ClauseList* xorcl = cm.ReturnXorClauses();
+ CNFMgr* cm = new CNFMgr(bm);
+ ClauseList* cl = cm->convertToCNF(BBFormula);
+ ClauseList* xorcl = cm->ReturnXorClauses();
ClauseBuckets * cb = Sort_ClauseList_IntoBuckets(cl);
cl->asList()->clear(); // clause buckets now point to the clauses.
delete cl;
- bool sat = CallSAT_On_ClauseBuckets(SatSolver, cb);
+ bool sat = CallSAT_On_ClauseBuckets(SatSolver, cb, cm);
for (ClauseBuckets::iterator it = cb->begin(); it != cb->end(); it++)
delete it->second;
{
xorcl->deleteJustVectors();
delete xorcl;
+ if (NULL != cm)
+ delete cm;
return sat;
}
}
#endif
-
delete xorcl;
+ if (NULL != cm)
+ delete cm;
return sat;
}
//Iteratively goes through the Clause Buckets, and calls
//toSATandSolve()
bool CallSAT_On_ClauseBuckets(MINISAT::Solver& SatSolver,
- ClauseBuckets * cb);
+ ClauseBuckets * cb
+ , CNFMgr*& cm);
+
// Converts the clause to SAT and calls SAT solver
bool toSATandSolve(MINISAT::Solver& S,
ClauseList& cll,
+ bool final,
+ CNFMgr*& cm,
+
bool add_xor_clauses=false,
bool enable_clausal_abstraction=false);