@@ -13,6 +13,7 @@ Author: Daniel Kroening, Peter Schrammel
1313
1414#include < util/cmdline.h>
1515#include < util/exception_utils.h>
16+ #include < util/exit_codes.h>
1617#include < util/make_unique.h>
1718#include < util/message.h>
1819#include < util/options.h>
@@ -151,7 +152,7 @@ std::unique_ptr<solver_factoryt::solvert> solver_factoryt::get_solver()
151152 return get_incremental_smt2 (incremental_smt2_solver);
152153 if (options.get_bool_option (" smt2" ))
153154 return get_smt2 (get_smt2_solver_type ());
154- return get_default ();
155+ return get_sat_solver ();
155156}
156157
157158// / Uses the options to pick an SMT 2.0 solver
@@ -213,20 +214,148 @@ make_satcheck_prop(message_handlert &message_handler, const optionst &options)
213214 return satcheck;
214215}
215216
216- std::unique_ptr<solver_factoryt::solvert> solver_factoryt::get_default ()
217+ std::unique_ptr<solver_factoryt::solvert> solver_factoryt::get_sat_solver ()
217218{
218219 auto solver = util_make_unique<solvert>();
219- if (
220- options.get_bool_option (" beautify" ) ||
221- !options.get_bool_option (" sat-preprocessor" )) // no simplifier
220+ bool solver_set = false ;
221+ if (options.is_set (" sat-solver" ))
222222 {
223- // simplifier won't work with beautification
224- solver->set_prop (
225- make_satcheck_prop<satcheck_no_simplifiert>(message_handler, options));
223+ const std::string &solver_option = options.get_option (" sat-solver" );
224+ if (solver_option == " zchaff" )
225+ {
226+ #if defined SATCHECK_ZCHAFF
227+ solver->set_prop (
228+ make_satcheck_prop<satcheck_zchafft>(message_handler, options));
229+ solver_set = true ;
230+ #else
231+ emit_solver_warning (" zchaff" );
232+ #endif
233+ }
234+ else if (solver_option == " booleforce" )
235+ {
236+ #if defined SATCHECK_BOOLERFORCE
237+ solver->set_prop (
238+ make_satcheck_prop<satcheck_booleforcet>(message_handler, options));
239+ solver_set = true ;
240+ #else
241+ emit_solver_warning (" booleforce" );
242+ #endif
243+ }
244+ else if (solver_option == " minisat1" )
245+ {
246+ #if defined SATCHECK_MINISAT1
247+ solver->set_prop (
248+ make_satcheck_prop<satcheck_minisat1t>(message_handler, options));
249+ solver_set = true ;
250+ #else
251+ emit_solver_warning (" minisat1" );
252+ #endif
253+ }
254+ else if (solver_option == " minisat2" )
255+ {
256+ #if defined SATCHECK_MINISAT2
257+ if (
258+ options.get_bool_option (" beautify" ) ||
259+ !options.get_bool_option (" sat-preprocessor" )) // no simplifier
260+ {
261+ // simplifier won't work with beautification
262+ solver->set_prop (make_satcheck_prop<satcheck_minisat_no_simplifiert>(
263+ message_handler, options));
264+ }
265+ else // with simplifier
266+ {
267+ solver->set_prop (make_satcheck_prop<satcheck_minisat_simplifiert>(
268+ message_handler, options));
269+ }
270+ solver_set = true ;
271+ #else
272+ emit_solver_warning (" minisat2" );
273+ #endif
274+ }
275+ else if (solver_option == " ipasir" )
276+ {
277+ #if defined SATCHECK_IPASIR
278+ solver->set_prop (
279+ make_satcheck_prop<satcheck_ipasirt>(message_handler, options));
280+ solver_set = true ;
281+ #else
282+ emit_solver_warning (" ipasir" );
283+ #endif
284+ }
285+ else if (solver_option == " picosat" )
286+ {
287+ #if defined SATCHECK_PICOSAT
288+ solver->set_prop (
289+ make_satcheck_prop<satcheck_picosatt>(message_handler, options));
290+ solver_set = true ;
291+ #else
292+ emit_solver_warning (" picosat" );
293+ #endif
294+ }
295+ else if (solver_option == " lingeling" )
296+ {
297+ #if defined SATCHECK_LINGELING
298+ solver->set_prop (
299+ make_satcheck_prop<satcheck_lingelingt>(message_handler, options));
300+ solver_set = true ;
301+ #else
302+ emit_solver_warning (" lingeling" );
303+ #endif
304+ }
305+ else if (solver_option == " glucose" )
306+ {
307+ #if defined SATCHECK_GLUCOSE
308+ if (
309+ options.get_bool_option (" beautify" ) ||
310+ !options.get_bool_option (" sat-preprocessor" )) // no simplifier
311+ {
312+ // simplifier won't work with beautification
313+ solver->set_prop (make_satcheck_prop<satcheck_glucose_no_simplifiert>(
314+ message_handler, options));
315+ }
316+ else // with simplifier
317+ {
318+ solver->set_prop (make_satcheck_prop<satcheck_glucose_simplifiert>(
319+ message_handler, options));
320+ }
321+ solver_set = true ;
322+ #else
323+ emit_solver_warning (" glucose" );
324+ #endif
325+ }
326+ else if (solver_option == " cadical" )
327+ {
328+ #if defined SATCHECK_CADICAL
329+ solver->set_prop (
330+ make_satcheck_prop<satcheck_cadicalt>(message_handler, options));
331+ solver_set = true ;
332+ #else
333+ emit_solver_warning (" cadical" );
334+ #endif
335+ }
336+ else
337+ {
338+ messaget log (message_handler);
339+ log.error () << " unknown solver '" << solver_option << " '"
340+ << messaget::eom;
341+ exit (CPROVER_EXIT_USAGE_ERROR);
342+ }
226343 }
227- else // with simplifier
344+ if (!solver_set)
228345 {
229- solver->set_prop (make_satcheck_prop<satcheckt>(message_handler, options));
346+ // default solver
347+ if (
348+ options.get_bool_option (" beautify" ) ||
349+ !options.get_bool_option (" sat-preprocessor" )) // no simplifier
350+ {
351+ // simplifier won't work with beautification
352+ solver->set_prop (
353+ make_satcheck_prop<satcheck_no_simplifiert>(message_handler, options));
354+ }
355+ else // with simplifier
356+ {
357+ solver->set_prop (make_satcheck_prop<satcheckt>(message_handler, options));
358+ }
230359 }
231360
232361 bool get_array_constraints =
@@ -245,6 +374,14 @@ std::unique_ptr<solver_factoryt::solvert> solver_factoryt::get_default()
245374 return solver;
246375}
247376
377+ void solver_factoryt::emit_solver_warning (const std::string &solver)
378+ {
379+ messaget log (message_handler);
380+ log.warning () << " The specified solver, '" << solver
381+ << " ', is not available. "
382+ << " The default solver will be used instead." << messaget::eom;
383+ }
384+
248385std::unique_ptr<solver_factoryt::solvert> solver_factoryt::get_dimacs ()
249386{
250387 no_beautification ();
@@ -517,6 +654,9 @@ static void parse_sat_options(const cmdlinet &cmdline, optionst &options)
517654
518655 if (cmdline.isset (" dimacs" ))
519656 options.set_option (" dimacs" , true );
657+
658+ if (cmdline.isset (" sat-solver" ))
659+ options.set_option (" sat-solver" , cmdline.get_value (" sat-solver" ));
520660}
521661
522662static void parse_smt2_options (const cmdlinet &cmdline, optionst &options)
0 commit comments