CBMC
Loading...
Searching...
No Matches
solver_factory.h
Go to the documentation of this file.
1/*******************************************************************\
2
3Module: Solver Factory
4
5Author: Daniel Kroening, Peter Schrammel
6
7\*******************************************************************/
8
11
12#ifndef CPROVER_GOTO_CHECKER_SOLVER_FACTORY_H
13#define CPROVER_GOTO_CHECKER_SOLVER_FACTORY_H
14
17
18#include <memory>
19
20class cmdlinet;
22class namespacet;
23class optionst;
25
26class solver_factoryt final
27{
28public:
31 const optionst &_options,
32 const namespacet &_ns,
35
36 // The solver class,
37 // which owns a variety of allocated objects.
38 class solvert final
39 {
40 public:
41 explicit solvert(std::unique_ptr<stack_decision_proceduret> p);
42 solvert(
43 std::unique_ptr<stack_decision_proceduret> p1,
44 std::unique_ptr<propt> p2);
45 solvert(
46 std::unique_ptr<stack_decision_proceduret> p1,
47 std::unique_ptr<std::ofstream> p2);
48 solvert(std::unique_ptr<boolbvt> p1, std::unique_ptr<propt> p2);
49
52
53 private:
54 // the objects are deleted in the opposite order they appear below
55 std::unique_ptr<std::ofstream> ofstream_ptr;
56 std::unique_ptr<propt> prop_ptr;
57 std::unique_ptr<stack_decision_proceduret> decision_procedure_ptr;
58 std::unique_ptr<boolbvt> decision_procedure_is_boolbvt_ptr;
59 };
60
62 virtual std::unique_ptr<solvert> get_solver();
63
64 virtual ~solver_factoryt() = default;
65
66protected:
68 const namespacet &ns;
71
72 std::unique_ptr<solvert> get_default();
73 std::unique_ptr<solvert> get_dimacs();
74 std::unique_ptr<solvert> get_external_sat();
75 std::unique_ptr<solvert> get_bv_refinement();
76 std::unique_ptr<solvert> get_string_refinement();
77 std::unique_ptr<solvert> get_incremental_smt2(std::string solver_command);
78 std::unique_ptr<solvert> get_smt2(smt2_dect::solvert solver);
79
81
86 solver_resource_limitst &decision_procedure);
87
88 // consistency checks during solver creation
89 void no_beautification();
91};
92
95void parse_solver_options(const cmdlinet &cmdline, optionst &options);
96
97#define OPT_SOLVER \
98 "(smt1)" /* rejected, will eventually disappear */ \
99 "(smt2)" \
100 "(fpa)" \
101 "(cvc3)" \
102 "(cvc4)(cvc5)(bitwuzla)(boolector)(yices)(z3)" \
103 "(mathsat)" \
104 "(cprover-smt2)" \
105 "(incremental-smt2-solver):" \
106 "(sat-solver):" \
107 "(external-sat-solver):" \
108 "(no-sat-preprocessor)" \
109 "(beautify)" \
110 "(dimacs)" \
111 "(refine)" \
112 "(max-node-refinement):" \
113 "(refine-arrays)" \
114 "(refine-arithmetic)" \
115 "(outfile):" \
116 "(dump-smt-formula):" \
117 "(write-solver-stats-to):"
118
119#define HELP_SOLVER \
120 " {y--sat-solver} {usolver} \t use specified SAT solver\n" \
121 " {y--external-sat-solver} {ucmd} \t command to invoke SAT solver process\n" \
122 " {y--no-sat-preprocessor} \t disable the SAT solver's simplifier\n" \
123 " {y--dimacs} \t generate CNF in DIMACS format\n" \
124 " {y--beautify} \t beautify the counterexample (greedy heuristic)\n" \
125 " {y--smt1} \t use default SMT1 solver (obsolete)\n" \
126 " {y--smt2} \t use default SMT2 solver (Z3)\n" \
127 " {y--bitwuzla} \t use Bitwuzla\n" \
128 " {y--boolector} \t use Boolector\n" \
129 " {y--cprover-smt2} \t use CPROVER SMT2 solver\n" \
130 " {y--cvc3} \t use CVC3\n" \
131 " {y--cvc4} \t use CVC4\n" \
132 " {y--cvc5} \t use CVC5\n" \
133 " {y--mathsat} \t use MathSAT\n" \
134 " {y--yices} \t use Yices\n" \
135 " {y--z3} \t use Z3\n" \
136 " {y--fpa} \t use theory of floating-point arithmetic\n" \
137 " {y--refine} \t use refinement procedure (experimental)\n" \
138 " {y--refine-arrays} \t use refinement for arrays only\n" \
139 " {y--refine-arithmetic} \t refinement of arithmetic expressions only\n" \
140 " {y--max-node-refinement} \t " \
141 "maximum refinement iterations for arithmetic expressions\n" \
142 " {y--incremental-smt2-solver} {ucmd} \t " \
143 "command to invoke external SMT solver for incremental solving " \
144 "(experimental)\n" \
145 " {y--outfile} {ufilename} \t output formula to given file\n" \
146 " {y--dump-smt-formula} {ufilename} \t " \
147 "output smt incremental formula to the given file\n" \
148 " {y--write-solver-stats-to} {ujson-file} \t " \
149 "collect the solver query complexity\n"
150
151#endif // CPROVER_GOTO_CHECKER_SOLVER_FACTORY_H
ait supplies three of the four components needed: an abstract interpreter (in this case handling func...
Definition ai.h:562
A namespacet is essentially one or two symbol tables bound together, to allow for symbol lookups in t...
Definition namespace.h:91
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
stack_decision_proceduret & decision_procedure() const
std::unique_ptr< boolbvt > decision_procedure_is_boolbvt_ptr
message_handlert & message_handler
const optionst & options
const namespacet & ns
std::unique_ptr< solvert > get_external_sat()
std::unique_ptr< solvert > get_default()
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()
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 ~solver_factoryt()=default
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()
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)
Definition solver.cpp:44
void parse_solver_options(const cmdlinet &cmdline, optionst &options)
Parse solver-related command-line parameters in cmdline and set corresponding values in options.