Skip to content

Limit MiniSat simplifier only when arrays-uf-always is used#8851

Open
tautschnig wants to merge 2 commits intodiffblue:developfrom
tautschnig:bugfixes/no-incremental-simp
Open

Limit MiniSat simplifier only when arrays-uf-always is used#8851
tautschnig wants to merge 2 commits intodiffblue:developfrom
tautschnig:bugfixes/no-incremental-simp

Conversation

@tautschnig
Copy link
Copy Markdown
Collaborator

MiniSat's SimpSolver runs variable elimination (eliminate()) before every solveLimited/solve call by default. When used incrementally in the all-properties verification loop, this repeated elimination can degrade the solver's ability to prove UNSAT, causing the CDCL search to hang indefinitely.

Fix by passing do_simp=false on all calls after the first. The first call still benefits from the full simplification pass, but subsequent incremental calls skip it, preventing the problematic variable elimination between iterations.

This fixes a hang when running:
cbmc --arrays-uf-always --unwind 1 --32 Array_UF23/main.c

  • Each commit message has a non-empty body, explaining why the change was made.
  • n/a Methods or procedures I have added are documented, following the guidelines provided in CODING_STANDARD.md.
  • n/a 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).
  • n/a My commit message includes data points confirming performance improvements (if claimed).
  • My PR is restricted to a single feature or bugfix.
  • n/a White-space or formatting changes outside the feature-related changed lines are in commits of their own.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a hang in CBMC's incremental SAT solving when using MiniSat's SimpSolver. The issue occurs because MiniSat's simplifier runs variable elimination (eliminate()) before every solveLimited/solve call, which can degrade the solver's ability to prove UNSAT during the all-properties verification loop. The fix passes do_simp=false on all calls after the first, allowing the initial full simplification pass but skipping it on subsequent incremental calls.

Changes:

  • Added a solver_was_called flag to satcheck_minisat2_baset to track whether the solver has been called before, and use if constexpr to pass do_simp=false to SimpSolver::solveLimited/solve on subsequent calls
  • Reordered includes to follow the .clang-format priority ordering and added <type_traits> for std::is_same_v
  • Added a regression test (Array_UF23) that reproduces the hang scenario with --arrays-uf-always --unwind 1 --32

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
src/solvers/sat/satcheck_minisat2.h Added solver_was_called boolean member with in-class default initializer
src/solvers/sat/satcheck_minisat2.cpp Used if constexpr to conditionally disable SimpSolver's simplifier after first solve, reordered includes
regression/cbmc/Array_UF23/main.c New regression test C source with VLA array stores and an assertion
regression/cbmc/Array_UF23/test.desc Test descriptor for the regression test

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 5, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.01%. Comparing base (7a4df92) to head (f382772).

Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #8851   +/-   ##
========================================
  Coverage    80.01%   80.01%           
========================================
  Files         1703     1703           
  Lines       188396   188405    +9     
  Branches        73       73           
========================================
+ Hits        150738   150747    +9     
  Misses       37658    37658           

☔ View full report in Codecov by Sentry.
📢 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.

@kroening
Copy link
Copy Markdown
Collaborator

kroening commented Mar 5, 2026

Is this a genuine issue in MiniSat, or are we using it wrong?

@tautschnig
Copy link
Copy Markdown
Collaborator Author

It's a known limitation of MiniSat's SimpSolver when used incrementally. The SimpSolver was designed primarily for single-shot solving — its solve/solveLimited methods run eliminate() before every call by default. While frozen variables are protected from elimination, the variable elimination and subsumption passes restructure the clause database between incremental calls, which can make subsequent UNSAT proofs much harder for the CDCL search.

MiniSat's API does provide the do_simp parameter precisely for this use case (the parameter defaults to true). We just weren't using it. Other incremental SAT solver interfaces (CaDiCaL, etc.) don't have this issue because they don't run preprocessing between incremental calls unless explicitly asked to.

@tautschnig tautschnig force-pushed the bugfixes/no-incremental-simp branch 3 times, most recently from 75c8bd0 to 59fef53 Compare March 8, 2026 19:48
@tautschnig tautschnig marked this pull request as draft March 9, 2026 09:44
@tautschnig tautschnig force-pushed the bugfixes/no-incremental-simp branch 2 times, most recently from c8ca115 to 6052d4b Compare March 10, 2026 09:50
@tautschnig tautschnig marked this pull request as ready for review March 10, 2026 09:50
tautschnig and others added 2 commits March 13, 2026 10:43
MiniSat's SimpSolver runs variable elimination (eliminate()) before
every solveLimited/solve call by default. When used incrementally in
the all-properties verification loop, this repeated elimination can
degrade the solver's ability to prove UNSAT, causing the CDCL search
to hang indefinitely.

Fix by passing do_simp=false on all calls after the first. The first
call still benefits from the full simplification pass, but subsequent
incremental calls skip it, preventing the problematic variable
elimination between iterations.

This fixes a hang when running:
  cbmc --arrays-uf-always --unwind 1 --32 Array_UF23/main.c

Co-authored-by: Kiro <kiro-agent@users.noreply.github.com>
The previous unconditional disabling of the simplifier after the first
incremental solve caused Multi_Dimensional_Array6 to hang in the 32-bit
CI build. The simplifier is beneficial for most workloads; only the
Ackermann-style array encoding (--arrays-uf-always) generates the
problematic pattern of many incremental calls where variable elimination
between solves degrades CDCL performance.

Make the behaviour opt-in via set_limit_incremental_simplification() on
the MiniSat solver, and activate it from solver_factory when arrays-uf
is set to "always".

Co-authored-by: Kiro <kiro-agent@users.noreply.github.com>
@tautschnig tautschnig force-pushed the bugfixes/no-incremental-simp branch from 6052d4b to f382772 Compare March 13, 2026 10:45
@tautschnig tautschnig changed the title Disable MiniSat simplifier after first incremental solve Limit MiniSat simplifier only when arrays-uf-always is used Mar 13, 2026
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.

5 participants