From: vijay_ganesh Date: Tue, 20 Oct 2009 00:44:40 +0000 (+0000) Subject: added an abstraction/refinement loop for clause-addition to the SAT solver X-Git-Url: https://git.unchartedbackwaters.co.uk/w/?a=commitdiff_plain;h=712e149b00aedd5ead6c4d6b022cc11e458e19fb;p=francis%2Fstp.git added an abstraction/refinement loop for clause-addition to the SAT solver git-svn-id: https://stp-fast-prover.svn.sourceforge.net/svnroot/stp-fast-prover/trunk/stp@320 e59a4935-1847-0410-ae03-e826735625c1 --- diff --git a/src/to-sat/BitBlast.cpp b/src/to-sat/BitBlast.cpp index a73a194..b2cf9f2 100644 --- a/src/to-sat/BitBlast.cpp +++ b/src/to-sat/BitBlast.cpp @@ -650,12 +650,21 @@ namespace BEEV // FIXME: Don't bother computing i+1 carry, which is discarded. for (int i = 0; i < n; i++) { - ASTNode nextcin = Majority(sum[i], y[i], cin); + ASTNode nextcin; + if(i != n-1) + { + //Compute this only for i=0 to n-2 + nextcin = Majority(sum[i], y[i], cin); + } sum[i] = _bm->CreateSimpForm(XOR, _bm->CreateSimpForm(XOR, sum[i], y[i]), cin); - cin = nextcin; + if(i != n-1) + { + //Compute this only for i=0 to n-2 + cin = nextcin; + } } // cout << "----------------" << endl << "Result: " << endl; diff --git a/src/to-sat/ToSAT.cpp b/src/to-sat/ToSAT.cpp index d4a0ed2..2036a9b 100644 --- a/src/to-sat/ToSAT.cpp +++ b/src/to-sat/ToSAT.cpp @@ -46,26 +46,19 @@ namespace BEEV bool ToSAT::toSATandSolve(MINISAT::Solver& newS, ClauseList& cll) { CountersAndStats("SAT Solver", bm); - bm->GetRunTimes()->start(RunTimes::SendingToSAT); + + int input_clauselist_size = cll.size(); + if (cll.size() == 0) + { + FatalError("toSATandSolve: Nothing to Solve", ASTUndefined); + } + //iterate through the list (conjunction) of ASTclauses cll ClauseList::const_iterator i = cll.begin(), iend = cll.end(); - - if (i == iend) - FatalError("toSATandSolve: Nothing to Solve", ASTUndefined); - - //turnOffSubsumption - // MKK: My understanding is that the rougly equivalent effect is had - // through setting the second argument of MINISAT::Solver::solve to - // true - //newS.turnOffSubsumption(); - - // (*i) is an ASTVec-ptr which denotes an ASTclause - //**************************************** - // *i = vector* - //**************************************** - for (; i != iend; i++) + //ClauseList::reverse_iterator i = cll.rbegin(), iend = cll.rend(); + for (int count=0; i != iend; i++) { //Clause for the SATSolver MINISAT::vec satSolverClause; @@ -73,60 +66,48 @@ namespace BEEV //now iterate through the internals of the ASTclause itself vector::const_iterator j = (*i)->begin(); - vector::const_iterator jend = (*i)->end(); - + vector::const_iterator jend = (*i)->end(); //j is a disjunct in the ASTclause (*i) for (; j != jend; j++) { ASTNode node = **j; - bool negate = (NOT == node.GetKind()) ? true : false; ASTNode n = negate ? node[0] : node; - - //Lookup or create the MINISAT::Var corresponding to the Booelan - //ASTNode Variable, and push into sat Solver clause MINISAT::Var v = LookupOrCreateSATVar(newS, n); MINISAT::Lit l(v, negate); satSolverClause.push(l); } newS.addClause(satSolverClause); - // clause printing. - // (printClause >)(satSolverClause); - // cout << " 0 "; - // cout << endl; + if(count++ >= input_clauselist_size*0.60) + { + //cout << "Added 90% of clauses\n"; + bm->GetRunTimes()->start(RunTimes::Solving); + newS.solve(); + bm->GetRunTimes()->stop(RunTimes::Solving); + if(!newS.okay()) + { + return false; + } + count = 0; + } if (newS.okay()) { continue; - } + } else { bm->PrintStats(newS); bm->GetRunTimes()->stop(RunTimes::SendingToSAT); return false; - } - } + } + } // End of For-loop adding the clauses bm->GetRunTimes()->stop(RunTimes::SendingToSAT); - - // if input is UNSAT return false, else return true - if (!newS.simplify()) - { - bm->PrintStats(newS); - return false; - } - - //PrintActivityLevels_Of_SATVars("Before SAT:",newS); - //ChangeActivityLevels_Of_SATVars(newS); - //PrintActivityLevels_Of_SATVars("Before SAT and after initial - //bias:",newS); newS.solve(); - + //cout << "Added remaining clauses\n"; bm->GetRunTimes()->start(RunTimes::Solving); newS.solve(); bm->GetRunTimes()->stop(RunTimes::Solving); - - //PrintActivityLevels_Of_SATVars("After SAT",newS); - bm->PrintStats(newS); if (newS.okay()) return true;