Skip to content

Commit

Permalink
feat(opensmt/smtsolver/CoreSMTSolver): short SAT functionality
Browse files Browse the repository at this point in the history
close dreal#96
  • Loading branch information
Nina Narodytska authored and soonhokong committed May 4, 2015
1 parent 7c51e81 commit f78ce65
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 3 deletions.
39 changes: 36 additions & 3 deletions src/opensmt/smtsolvers/CoreSMTSolver.C
Original file line number Diff line number Diff line change
Expand Up @@ -1711,9 +1711,16 @@ lbool CoreSMTSolver::search(int nof_conflicts, int nof_learnts)
}

if (next == lit_Undef){
// New variable decision:
decisions++;
next = pickBranchLit(polarity_mode, random_var_freq);
if ((!config.nra_short_sat) || (!entailment())) {
// New variable decision:
DREAL_LOG_INFO << "Pick branch on a lit: " << endl;
decisions++;
next = pickBranchLit(polarity_mode, random_var_freq);
} else {
// SAT formula is satisfiable
next = lit_Undef;
DREAL_LOG_INFO << "Found Model after # decisions " << decisions << endl;
}

// Complete Call
if ( next == lit_Undef )
Expand Down Expand Up @@ -1742,6 +1749,11 @@ lbool CoreSMTSolver::search(int nof_conflicts, int nof_learnts)
if ( res == 2 ) { continue; }
if ( res == -1 ) return l_False;
assert( res == 1 );

if(config.nra_short_sat) {
// the problem is satisfiable as res = 1 at this point
return l_True;
}
// Otherwise we still have to make sure that
// splitting on demand did not add any new variable
decisions++;
Expand Down Expand Up @@ -1950,6 +1962,27 @@ int CoreSMTSolver::restartNextLimit ( int nof_conflicts )
// Standard restart
return nof_conflicts * restart_inc;
}
/*_________________________________________________________________________________________________
|
| entailment : () -> [lbool]
|
| Description:
| Checks if all clauses are satisfied.
|
| Output:
| 'l_True' if all clauses are satisfied. 'l_False'
| if there exists unsatisfied clause.
|________________________________________________________________________________________________@*/

bool CoreSMTSolver::entailment() {
for (int c = 0; c < nClauses(); c++) {
if (!satisfied(*clauses[c])) {
return false;
}
}

return true;
}

#ifdef STATISTICS
void CoreSMTSolver::printStatistics( ostream & os )
Expand Down
1 change: 1 addition & 0 deletions src/opensmt/smtsolvers/CoreSMTSolver.h
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,7 @@ class CoreSMTSolver : public SMTSolver
int restartNextLimit ( int ); // Next conflict limit for restart
Var generateMoreEij ( ); // Generate more eij
Var generateNextEij ( ); // Generate next eij
bool entailment ( ); // Check is a partial assignment entails a formula

#ifndef SMTCOMP
void dumpCNF ( ); // Dumps CNF to cnf.smt2
Expand Down

0 comments on commit f78ce65

Please sign in to comment.