cprover: add external SMT2 solver backend (--smt2-solver)#9068
cprover: add external SMT2 solver backend (--smt2-solver)#9068tautschnig wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds an external SMT-LIBv2 (SMT2) solver backend that can be selected via a new --smt2-solver command-line option, enabling cprover to pipe constraints to an external solver (e.g., z3) instead of the built-in SAT backend.
Changes:
- Introduces
cprover_smt2_dectas an SMT2 decision procedure configured for cprover’s state encoding. - Adds
--smt2-solveroption and plumbs the configured solver binary throughsolver_optionst. - Updates inductiveness subsumption checks and counterexample search to use the external SMT2 solver when configured.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| src/cprover/solver.h | Adds solver_optionst::smt2_solver_binary to configure external SMT2 solver usage. |
| src/cprover/inductiveness.cpp | Routes subsumption and counterexample logic to either external SMT2 or built-in SAT. |
| src/cprover/cprover_smt2_dec.h | Adds a configured SMT2 decision procedure specialization for cprover. |
| src/cprover/cprover_parse_options.h | Registers new CLI option --smt2-solver. |
| src/cprover/cprover_parse_options.cpp | Parses and stores --smt2-solver into solver options. |
| src/cprover/counterexample_found.h | Extends API to pass SMT2 solver binary + adds generic show_assignment overload. |
| src/cprover/counterexample_found.cpp | Adds external SMT2 solver path for counterexample search. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| switch(solver()) | ||
| { | ||
| case decision_proceduret::resultt::D_SATISFIABLE: | ||
| if(verbose) | ||
| show_assignment(solver); | ||
| return counterexample(frames, work, solver, axioms, ns); | ||
| case decision_proceduret::resultt::D_UNSATISFIABLE: | ||
| break; | ||
| case decision_proceduret::resultt::D_ERROR: | ||
| if(!smt2_solver_binary.empty()) | ||
| break; // conservatively treat as no counterexample found | ||
| throw "error reported by solver"; | ||
| } |
| decision_proceduret &solver = | ||
| smt2_solver_binary.empty() | ||
| ? static_cast<decision_proceduret &>(*bv_ptr) | ||
| : static_cast<decision_proceduret &>(*solver_ptr); |
| std::unique_ptr<decision_proceduret> solver_ptr; | ||
| std::unique_ptr<satcheckt> satcheck_ptr; | ||
| std::unique_ptr<bv_pointers_widet> bv_ptr; | ||
|
|
||
| if(!smt2_solver_binary.empty()) | ||
| { | ||
| solver_ptr = std::make_unique<cprover_smt2_dect>( | ||
| ns, smt2_solver_binary, message_handler); | ||
| } | ||
| else | ||
| { | ||
| satcheck_ptr = std::make_unique<satcheckt>(message_handler); | ||
| bv_ptr = std::make_unique<bv_pointers_widet>( | ||
| ns, *satcheck_ptr, message_handler); | ||
| } | ||
|
|
||
| decision_proceduret &solver = | ||
| smt2_solver_binary.empty() | ||
| ? static_cast<decision_proceduret &>(*bv_ptr) | ||
| : static_cast<decision_proceduret &>(*solver_ptr); |
| #include <solvers/smt2/smt2_dec.h> | ||
|
|
||
| /// SMT2 decision procedure configured for cprover's state encoding. | ||
| /// Uses datatypes for structs (instead of bitvector flattening) to | ||
| /// support mathematical types (integer, real, string). | ||
| class cprover_smt2_dect : public smt2_dect | ||
| { | ||
| public: | ||
| cprover_smt2_dect( | ||
| const namespacet &_ns, | ||
| const std::string &_solver_binary, | ||
| message_handlert &_message_handler) |
| "(safety)(no-safety)(no-assertions)" \ | ||
| "(contract):" \ | ||
| "(solve)(unwind):(trace)" \ | ||
| "(smt2-solver):" \ |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #9068 +/- ##
===========================================
- Coverage 80.68% 80.68% -0.01%
===========================================
Files 1714 1716 +2
Lines 189501 189535 +34
Branches 73 73
===========================================
+ Hits 152902 152921 +19
- Misses 36599 36614 +15 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Add cprover_smt2_dect (a decision_proceduret that pipes constraints to an external SMT2 solver such as z3), a --smt2-solver command-line option, the solver_optionst::smt2_solver_binary field, and the plumbing in the inductiveness check and counterexample search to use the external solver when configured (falling back to the built-in SAT backend otherwise). Co-authored-by: Kiro <kiro-agent@users.noreply.github.com>
9530233 to
6f47377
Compare
Add cprover_smt2_dect (a decision_proceduret that pipes constraints to an external SMT2 solver such as z3), a --smt2-solver command-line option, the solver_optionst::smt2_solver_binary field, and the plumbing in the inductiveness check and counterexample search to use the external solver when configured (falling back to the built-in SAT backend otherwise).