41 bool _output_xml_in_refinement)
55 std::unique_ptr<stack_decision_proceduret> p1,
56 std::unique_ptr<propt> p2)
62 std::unique_ptr<stack_decision_proceduret> p1,
63 std::unique_ptr<std::ofstream> p2)
69 std::unique_ptr<boolbvt> p1,
70 std::unique_ptr<propt> p2)
76 std::unique_ptr<boolbvt> p1,
77 std::unique_ptr<propt> p2,
78 std::unique_ptr<std::ofstream> p3)
105 const int timeout_seconds =
106 options.get_signed_int_option(
"solver-time-limit");
108 if(timeout_seconds > 0)
114 if(
options.get_bool_option(
"dimacs"))
116 if(
options.is_set(
"external-sat-solver"))
119 options.get_bool_option(
"refine") &&
120 !
options.get_bool_option(
"refine-strings"))
124 else if(
options.get_bool_option(
"refine-strings"))
126 const auto incremental_smt2_solver =
127 options.get_option(
"incremental-smt2-solver");
128 if(!incremental_smt2_solver.empty())
130 if(
options.get_bool_option(
"smt2"))
144 if(
options.get_bool_option(
"bitwuzla"))
146 else if(
options.get_bool_option(
"boolector"))
148 else if(
options.get_bool_option(
"cprover-smt2"))
150 else if(
options.get_bool_option(
"mathsat"))
152 else if(
options.get_bool_option(
"cvc3"))
154 else if(
options.get_bool_option(
"cvc4"))
156 else if(
options.get_bool_option(
"cvc5"))
158 else if(
options.get_bool_option(
"yices"))
160 else if(
options.get_bool_option(
"z3"))
162 else if(
options.get_bool_option(
"generic"))
171 const std::string &
solver)
175 <<
"', is not available. "
176 <<
"The default solver will be used instead." <<
messaget::eom;
179template <
typename SatcheckT>
180static typename std::enable_if<
181 !std::is_base_of<hardness_collectort, SatcheckT>::value,
182 std::unique_ptr<SatcheckT>>::type
190 <<
"Configured solver does not support --write-solver-stats-to. "
196template <
typename SatcheckT>
197static typename std::enable_if<
198 std::is_base_of<hardness_collectort, SatcheckT>::value,
199 std::unique_ptr<SatcheckT>>::type
205 std::unique_ptr<solver_hardnesst> solver_hardness =
206 std::make_unique<solver_hardnesst>();
208 satcheck->solver_hardness = std::move(solver_hardness);
213static std::unique_ptr<propt>
223 if(solver_option ==
"zchaff")
225#if defined SATCHECK_ZCHAFF
231 else if(solver_option ==
"booleforce")
233#if defined SATCHECK_BOOLERFORCE
239 else if(solver_option ==
"minisat1")
241#if defined SATCHECK_MINISAT1
247 else if(solver_option ==
"minisat2")
249#if defined SATCHECK_MINISAT2
265 else if(solver_option ==
"ipasir")
267#if defined SATCHECK_IPASIR
273 else if(solver_option ==
"picosat")
275#if defined SATCHECK_PICOSAT
281 else if(solver_option ==
"lingeling")
283#if defined SATCHECK_LINGELING
289 else if(solver_option ==
"glucose")
291#if defined SATCHECK_GLUCOSE
307 else if(solver_option ==
"cadical")
309#if defined SATCHECK_CADICAL
319 log.
error() <<
"unknown solver '" << solver_option <<
"'"
339 const std::string &filename,
341 const std::string &arg_name)
351 "failed to open file: " + filename, arg_name);
363 bool get_array_constraints =
364 options.get_bool_option(
"show-array-constraints");
365 auto bv_pointers = std::make_unique<bv_pointerst>(
368 if(
options.get_option(
"arrays-uf") ==
"never")
370 else if(
options.get_option(
"arrays-uf") ==
"always")
375 std::unique_ptr<boolbvt> boolbv = std::move(bv_pointers);
376 return std::make_unique<solvert>(std::move(boolbv), std::move(sat_solver));
386 std::string filename =
options.get_option(
"outfile");
388 if(filename.empty() || filename ==
"-")
390 std::unique_ptr<boolbvt> bv_dimacs =
393 return std::make_unique<solvert>(std::move(bv_dimacs), std::move(prop));
398 std::unique_ptr<boolbvt> bv_dimacs =
401 return std::make_unique<solvert>(
402 std::move(bv_dimacs), std::move(prop), std::move(outfile));
410 std::string external_sat_solver =
options.get_option(
"external-sat-solver");
414 std::unique_ptr<boolbvt> bv_pointers =
417 return std::make_unique<solvert>(std::move(bv_pointers), std::move(prop));
426 info.
prop = prop.get();
430 if(
options.get_bool_option(
"max-node-refinement"))
432 options.get_unsigned_int_option(
"max-node-refinement");
438 std::unique_ptr<boolbvt> decision_procedure =
439 std::make_unique<bv_refinementt>(info);
441 return std::make_unique<solvert>(
442 std::move(decision_procedure), std::move(prop));
448std::unique_ptr<solver_factoryt::solvert>
454 info.
prop = prop.get();
457 if(
options.get_bool_option(
"max-node-refinement"))
459 options.get_unsigned_int_option(
"max-node-refinement");
464 std::unique_ptr<boolbvt> decision_procedure =
465 std::make_unique<string_refinementt>(info);
467 return std::make_unique<solvert>(
468 std::move(decision_procedure), std::move(prop));
471std::unique_ptr<solver_factoryt::solvert>
476 const std::string outfile_arg =
options.get_option(
"outfile");
477 const std::string dump_smt_formula =
options.get_option(
"dump-smt-formula");
479 if(!outfile_arg.empty() && !dump_smt_formula.empty())
482 "Argument --outfile is incompatible with --dump-smt-formula. ",
486 std::unique_ptr<smt_base_solver_processt> solver_process =
nullptr;
488 if(!outfile_arg.empty())
490 bool on_std_out = outfile_arg ==
"-";
491 std::unique_ptr<std::ostream> outfile =
495 solver_process = std::make_unique<smt_incremental_dry_run_solvert>(
496 message_handler, on_std_out ? std::cout : *outfile, std::move(outfile));
500 const auto out_filename =
options.get_option(
"dump-smt-formula");
504 solver_process = std::make_unique<smt_piped_solver_processt>(
505 std::move(solver_command),
511 return std::make_unique<solvert>(
512 std::make_unique<smt2_incremental_decision_proceduret>(
516std::unique_ptr<solver_factoryt::solvert>
521 const std::string &filename =
options.get_option(
"outfile");
528 "required filename not provided",
530 "provide a filename with --outfile");
533 auto smt2_dec = std::make_unique<smt2_dect>(
539 options.get_option(
"external-smt2-solver"),
542 if(
options.get_bool_option(
"fpa"))
543 smt2_dec->use_FPA_theory =
true;
545 return std::make_unique<solvert>(std::move(smt2_dec));
547 else if(filename ==
"-")
549 auto smt2_conv = std::make_unique<smt2_convt>(
557 if(
options.get_bool_option(
"fpa"))
558 smt2_conv->use_FPA_theory =
true;
560 return std::make_unique<solvert>(std::move(smt2_conv));
566 auto smt2_conv = std::make_unique<smt2_convt>(
574 if(
options.get_bool_option(
"fpa"))
575 smt2_conv->use_FPA_theory =
true;
577 return std::make_unique<solvert>(std::move(smt2_conv), std::move(out));
583 if(
options.get_bool_option(
"beautify"))
586 "the chosen solver does not support beautification",
"--beautify");
592 const bool all_properties =
options.get_bool_option(
"all-properties");
593 const bool cover =
options.is_set(
"cover");
594 const bool incremental_loop =
options.is_set(
"incremental-loop");
599 "the chosen solver does not support incremental solving",
605 "the chosen solver does not support incremental solving",
"--cover");
607 else if(incremental_loop)
610 "the chosen solver does not support incremental solving",
611 "--incremental-loop");
617 if(cmdline.
isset(
"external-sat-solver"))
620 "external-sat-solver", cmdline.
get_value(
"external-sat-solver"));
625 if(cmdline.
isset(
"dimacs"))
628 if(cmdline.
isset(
"sat-solver"))
634 if(cmdline.
isset(
"smt2"))
637 if(cmdline.
isset(
"fpa"))
640 bool solver_set =
false;
642 if(cmdline.
isset(
"bitwuzla"))
648 if(cmdline.
isset(
"boolector"))
654 if(cmdline.
isset(
"cprover-smt2"))
660 if(cmdline.
isset(
"mathsat"))
666 if(cmdline.
isset(
"cvc4"))
672 if(cmdline.
isset(
"cvc5"))
678 if(cmdline.
isset(
"incremental-smt2-solver"))
681 "incremental-smt2-solver", cmdline.
get_value(
"incremental-smt2-solver")),
685 if(cmdline.
isset(
"yices"))
691 if(cmdline.
isset(
"z3"))
697 if(cmdline.
isset(
"external-smt2-solver"))
700 "external-smt2-solver", cmdline.
get_value(
"external-smt2-solver"));
705 if(cmdline.
isset(
"smt2") && !solver_set)
707 if(cmdline.
isset(
"outfile"))
729 std::vector<std::string> solver_flags;
731 if(cmdline.
isset(
"dimacs"))
732 solver_flags.push_back(
"--dimacs");
734 if(cmdline.
isset(
"external-sat-solver"))
735 solver_flags.push_back(
"--external-sat-solver");
739 for(
const char *smt2_flag :
750 "external-smt2-solver"})
752 if(cmdline.
isset(smt2_flag))
754 solver_flags.push_back(std::string(
"--") + smt2_flag);
759 if(cmdline.
isset(
"incremental-smt2-solver"))
760 solver_flags.push_back(
"--incremental-smt2-solver");
762 if(solver_flags.size() > 1)
765 "conflicting solver options: " + solver_flags[0] +
" and " +
766 solver_flags[1] +
" must not be given together",
767 solver_flags[0] +
" " + solver_flags[1]);
771 if(cmdline.
isset(
"incremental-smt2-solver") && cmdline.
isset(
"fpa"))
774 "--fpa is not supported with --incremental-smt2-solver",
775 "--fpa --incremental-smt2-solver");
778 if(cmdline.
isset(
"outfile"))
781 if(cmdline.
isset(
"dump-smt-formula"))
783 "dump-smt-formula", cmdline.
get_value(
"dump-smt-formula"));
785 if(cmdline.
isset(
"write-solver-stats-to"))
788 "write-solver-stats-to", cmdline.
get_value(
"write-solver-stats-to"));
791 if(cmdline.
isset(
"beautify"))
794 if(cmdline.
isset(
"refine-arrays"))
800 if(cmdline.
isset(
"refine-arithmetic"))
806 if(cmdline.
isset(
"refine"))
813 if(cmdline.
isset(
"max-node-refinement"))
816 "max-node-refinement", cmdline.
get_value(
"max-node-refinement"));
Abstraction Refinement Loop.
std::string get_value(char option) const
virtual bool isset(char option) const
Thrown when users pass incorrect command line arguments, for example passing no files to analysis or ...
Class that provides messages with a built-in verbosity 'level'.
mstreamt & warning() const
mstreamt & status() const
A namespacet is essentially one or two symbol tables bound together, to allow for symbol lookups in t...
bool is_set(const std::string &option) const
N.B. opts.is_set("foo") does not imply opts.get_bool_option("foo").
bool get_bool_option(const std::string &option) const
void set_option(const std::string &option, const bool value)
const std::string get_option(const std::string &option) const
std::unique_ptr< stack_decision_proceduret > decision_procedure_ptr
std::unique_ptr< propt > prop_ptr
std::unique_ptr< std::ofstream > ofstream_ptr
boolbvt & boolbv_decision_procedure() const
solvert(std::unique_ptr< stack_decision_proceduret > p)
stack_decision_proceduret & decision_procedure() const
std::unique_ptr< boolbvt > decision_procedure_is_boolbvt_ptr
message_handlert & message_handler
std::unique_ptr< solvert > get_external_sat()
std::unique_ptr< solvert > get_default()
solver_factoryt(const optionst &_options, const namespacet &_ns, message_handlert &_message_handler, bool _output_xml_in_refinement)
Note: The solver returned will hold a reference to the namespace ns.
void set_decision_procedure_time_limit(solver_resource_limitst &decision_procedure)
Sets the timeout of decision_procedure if the solver-time-limit option has a positive value (in secon...
std::unique_ptr< solvert > get_dimacs()
void no_incremental_check()
std::unique_ptr< solvert > get_string_refinement()
the string refinement adds to the bit vector refinement specifications for functions from the Java st...
std::unique_ptr< solvert > get_smt2(smt2_dect::solvert solver)
const bool output_xml_in_refinement
smt2_dect::solvert get_smt2_solver_type() const
Uses the options to pick an SMT 2.0 solver.
virtual std::unique_ptr< solvert > get_solver()
Returns a solvert object.
std::unique_ptr< solvert > get_incremental_smt2(std::string solver_command)
std::unique_ptr< solvert > get_bv_refinement()
virtual void set_time_limit_seconds(uint32_t)=0
Set the limit for the solver to time out in seconds.
Document and give macros for the exit codes of CPROVER binaries.
#define CPROVER_EXIT_USAGE_ERROR
A usage error is returned when the command line is invalid or conflicting.
Allows calling an external SAT solver to allow faster integration of newer SAT solvers.
Decision procedure with incremental SMT2 solving.
void solver(std::vector< framet > &frames, const std::unordered_set< symbol_exprt, irep_hash > &address_taken, const solver_optionst &solver_options, const namespacet &ns, std::vector< propertyt > &properties, std::size_t property_index)
static std::enable_if<!std::is_base_of< hardness_collectort, SatcheckT >::value, std::unique_ptr< SatcheckT > >::type make_satcheck_prop(message_handlert &message_handler, const optionst &options)
static void parse_sat_options(const cmdlinet &cmdline, optionst &options)
static std::unique_ptr< std::ofstream > open_outfile_and_check(const std::string &filename, message_handlert &message_handler, const std::string &arg_name)
static void parse_smt2_options(const cmdlinet &cmdline, optionst &options)
static std::unique_ptr< propt > get_sat_solver(message_handlert &message_handler, const optionst &options)
static void emit_solver_warning(message_handlert &message_handler, const std::string &solver)
Emit a warning for non-existent solver solver via message_handler.
void parse_solver_options(const cmdlinet &cmdline, optionst &options)
Parse solver-related command-line parameters in cmdline and set corresponding values in options.
Solver capability to set resource limits.
#define PRECONDITION(CONDITION)
String support via creating string constraints and progressively instantiating the universal constrai...
#define DEFAULT_MAX_NB_REFINEMENT
unsigned max_node_refinement
Max number of times we refine a formula node.
bool refine_arrays
Enable array refinement.
bool refine_arithmetic
Enable arithmetic refinement.
message_handlert * message_handler
std::size_t refinement_bound
string_refinementt constructor arguments
#define widen_if_needed(s)
const char * CBMC_VERSION