Skip to content

cprover: add external SMT2 solver backend (--smt2-solver)#9068

Open
tautschnig wants to merge 1 commit into
diffblue:developfrom
tautschnig:strata/cprover-smt2-solver-backend
Open

cprover: add external SMT2 solver backend (--smt2-solver)#9068
tautschnig wants to merge 1 commit into
diffblue:developfrom
tautschnig:strata/cprover-smt2-solver-backend

Conversation

@tautschnig

Copy link
Copy Markdown
Collaborator

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).

  • Each commit message has a non-empty body, explaining why the change was made.
  • Methods or procedures I have added are documented, following the guidelines provided in CODING_STANDARD.md.
  • The feature or user visible behaviour I have added or modified has been documented in the User Guide in doc/cprover-manual/
  • Regression or unit tests are included, or existing tests cover the modified code (in this case I have detailed which ones those are in the commit message).
  • My commit message includes data points confirming performance improvements (if claimed).
  • My PR is restricted to a single feature or bugfix.
  • White-space or formatting changes outside the feature-related changed lines are in commits of their own.

@tautschnig tautschnig self-assigned this Jun 18, 2026
Copilot AI review requested due to automatic review settings June 18, 2026 21:42

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_dect as an SMT2 decision procedure configured for cprover’s state encoding.
  • Adds --smt2-solver option and plumbs the configured solver binary through solver_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.

Comment on lines 228 to 238
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";
}
Comment on lines +76 to +79
decision_proceduret &solver =
smt2_solver_binary.empty()
? static_cast<decision_proceduret &>(*bv_ptr)
: static_cast<decision_proceduret &>(*solver_ptr);
Comment on lines +199 to +218
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);
Comment on lines +10 to +21
#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

codecov Bot commented Jun 19, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 64.28571% with 15 lines in your changes missing coverage. Please review.
✅ Project coverage is 80.68%. Comparing base (321ba11) to head (6f47377).

Files with missing lines Patch % Lines
src/cprover/cprover_smt2_dec.h 0.00% 6 Missing ⚠️
src/cprover/counterexample_found.cpp 66.66% 5 Missing ⚠️
src/cprover/inductiveness.cpp 78.94% 4 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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>
@tautschnig tautschnig force-pushed the strata/cprover-smt2-solver-backend branch from 9530233 to 6f47377 Compare June 19, 2026 08:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants