-
Notifications
You must be signed in to change notification settings - Fork 274
Add support for MergeSat #6439
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Add support for MergeSat #6439
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# CBMC only uses part of MergeSat. | ||
# This CMakeLists is designed to build just the parts that are needed. | ||
|
||
add_library(mergesat-condensed | ||
minisat/core/Lookahead.cc | ||
minisat/core/Solver.cc | ||
minisat/simp/SimpSolver.cc | ||
minisat/utils/ccnr.cc | ||
minisat/utils/Options.cc | ||
minisat/utils/System.cc | ||
) | ||
|
||
set_target_properties( | ||
mergesat-condensed | ||
PROPERTIES | ||
CXX_STANDARD 17 | ||
CXX_STANDARD_REQUIRED true | ||
CXX_EXTENSIONS OFF | ||
XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "Developer ID Application: Daniel Kroening" | ||
) | ||
|
||
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") | ||
target_compile_options(mergesat-condensed PUBLIC /w) | ||
endif() | ||
|
||
target_include_directories(mergesat-condensed | ||
PUBLIC | ||
${CMAKE_CURRENT_SOURCE_DIR} | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,7 @@ Author: Daniel Kroening, [email protected] | |
// #define SATCHECK_ZCHAFF | ||
// #define SATCHECK_MINISAT1 | ||
// #define SATCHECK_MINISAT2 | ||
// #define SATCHECK_MERGESAT | ||
// #define SATCHECK_GLUCOSE | ||
// #define SATCHECK_BOOLEFORCE | ||
// #define SATCHECK_PICOSAT | ||
|
@@ -39,6 +40,10 @@ Author: Daniel Kroening, [email protected] | |
#define SATCHECK_MINISAT2 | ||
#endif | ||
|
||
#if defined(HAVE_MERGESAT) && !defined(SATCHECK_MERGESAT) | ||
# define SATCHECK_MERGESAT | ||
#endif | ||
|
||
#if defined(HAVE_GLUCOSE) && !defined(SATCHECK_GLUCOSE) | ||
#define SATCHECK_GLUCOSE | ||
#endif | ||
|
@@ -71,7 +76,7 @@ Author: Daniel Kroening, [email protected] | |
# include "satcheck_minisat.h" | ||
#endif | ||
|
||
#if defined SATCHECK_MINISAT2 | ||
#if defined(SATCHECK_MINISAT2) || defined(SATCHECK_MERGESAT) | ||
# include "satcheck_minisat2.h" | ||
#endif | ||
|
||
|
@@ -110,7 +115,9 @@ typedef satcheck_booleforcet satcheck_no_simplifiert; | |
typedef satcheck_minisat1t satcheckt; | ||
typedef satcheck_minisat1t satcheck_no_simplifiert; | ||
|
||
#elif defined SATCHECK_MINISAT2 | ||
#elif defined SATCHECK_MINISAT2 || defined SATCHECK_MERGESAT | ||
// MergeSat is based on MiniSat2 and is invoked (with suitable defines/ifdefs) | ||
// via satcheck_minisat2.{h,cpp} | ||
|
||
tautschnig marked this conversation as resolved.
Show resolved
Hide resolved
|
||
typedef satcheck_minisat_simplifiert satcheckt; | ||
typedef satcheck_minisat_no_simplifiert satcheck_no_simplifiert; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,17 +13,20 @@ Author: Daniel Kroening, [email protected] | |
# include <unistd.h> | ||
#endif | ||
|
||
#include <limits> | ||
|
||
#include <util/invariant.h> | ||
#include <util/make_unique.h> | ||
#include <util/threeval.h> | ||
|
||
#include <minisat/core/Solver.h> | ||
#include <minisat/simp/SimpSolver.h> | ||
|
||
#ifndef HAVE_MINISAT2 | ||
tautschnig marked this conversation as resolved.
Show resolved
Hide resolved
|
||
#error "Expected HAVE_MINISAT2" | ||
#include <cstdlib> | ||
#include <limits> | ||
|
||
// MergeSat is based on MiniSat2; variations in their API are handled via | ||
// #ifdefs | ||
#if !defined(HAVE_MINISAT2) && !defined(HAVE_MERGESAT) | ||
# error "Expected HAVE_MINISAT2 or HAVE_MERGESAT" | ||
#endif | ||
|
||
void convert(const bvt &bv, Minisat::vec<Minisat::Lit> &dest) | ||
|
@@ -91,7 +94,11 @@ void satcheck_minisat2_baset<T>::set_polarity(literalt a, bool value) | |
try | ||
{ | ||
add_variables(); | ||
#ifdef HAVE_MERGESAT | ||
solver->setPolarity(a.var_no(), value); | ||
#else | ||
solver->setPolarity(a.var_no(), value ? l_True : l_False); | ||
#endif | ||
} | ||
catch(Minisat::OutOfMemoryException) | ||
{ | ||
|
@@ -115,12 +122,20 @@ void satcheck_minisat2_baset<T>::clear_interrupt() | |
|
||
std::string satcheck_minisat_no_simplifiert::solver_text() const | ||
{ | ||
#ifdef HAVE_MERGESAT | ||
return "MergeSat 4.0-rc without simplifier"; | ||
#else | ||
return "MiniSAT 2.2.1 without simplifier"; | ||
#endif | ||
} | ||
|
||
std::string satcheck_minisat_simplifiert::solver_text() const | ||
{ | ||
#ifdef HAVE_MERGESAT | ||
return "MergeSat 4.0-rc4 with simplifier"; | ||
#else | ||
return "MiniSAT 2.2.1 with simplifier"; | ||
#endif | ||
} | ||
|
||
template<typename T> | ||
|
@@ -271,6 +286,15 @@ propt::resultt satcheck_minisat2_baset<T>::do_prop_solve(const bvt &assumptions) | |
|
||
#endif | ||
|
||
#ifdef HAVE_MERGESAT | ||
// We do not actually use MergeSat's "constrain" clauses at the moment, but | ||
// MergeSat internally still uses them to track UNSAT. To make sure we | ||
// aren't stuck with "UNSAT" in incremental calls the status needs to be | ||
// reset. | ||
// See also https://github.com/conp-solutions/mergesat/pull/124 | ||
((Minisat::Solver *)solver.get())->reset_constrain_clause(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not required anymore. There was an issue with how incremental solving was implemented. The latest update of MergeSat has that fixed. Hence, feel free to drop this hunk! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thank you! I don't think we want to merge this PR before MergeSat 4.0 is released, so I suppose 4.0 will include this fix? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Likely yes. On the other hand, I am not sure when I will release 4.0, i.. whether I wait for the SAT competition results or not. Hence, feel free to not wait. The major thing that will change is the default configuration of the solver - and the competition will help to identify which one to pick. |
||
#endif | ||
|
||
if(solver_result == l_True) | ||
{ | ||
log.status() << "SAT checker: instance is SATISFIABLE" << messaget::eom; | ||
|
@@ -328,6 +352,15 @@ satcheck_minisat2_baset<T>::satcheck_minisat2_baset( | |
solver(util_make_unique<T>()), | ||
time_limit_seconds(0) | ||
{ | ||
#ifdef HAVE_MERGESAT | ||
if constexpr(std::is_same<T, Minisat::SimpSolver>::value) | ||
{ | ||
solver->grow_iterations = false; | ||
// limit the amount of work spent in simplification; the optimal value needs | ||
// to be found via benchmarking | ||
solver->nr_max_simp_cls = 1000000; | ||
} | ||
#endif | ||
} | ||
|
||
template <typename T> | ||
|
Uh oh!
There was an error while loading. Please reload this page.