3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2026-07-27 01:12:40 +00:00
z3/src/sat/sat_solver
Nikolaj Bjorner 88448d4afd
Fix unsound model from parallel QF_BV solving (#10133) (#10142)
## Problem

Fixes #10133. For `QF_BV` with `parallel.enable=true`, the solver could
return `sat` with a model that violates its own assertions.

`mk_qfbv_tactic` routes SAT solving to `mk_psat_tactic`, which built the
solver via `mk_inc_sat_solver(m, p, false)` (non-incremental). The
parallel cube-and-conquer engine **reuses this single solver** across
many `check_sat(cube)` calls, but SAT variable/blocked-clause
elimination ran because the simplifier's incremental gate was disabled.
Elimination model reconstruction is only sound for a single one-shot
solve; under repeated cube assumptions it produces models where
eliminated Tseitin variables get values contradicting the original
clauses.

## Root cause (two coupled defects)

1. **Stale simplifier cache.** `inc_sat_solver`'s constructor called
`m_solver.set_incremental()` *after* `updt_params()`. The SAT simplifier
caches `m_incremental_mode` from the SAT config *during* `updt_params`,
so setting the incremental flag afterwards left a stale non-incremental
mode and elimination stayed enabled. (This is why simply passing
`incremental_mode=true` had no effect on its own.)
2. **Non-incremental parallel solver.** `mk_psat_tactic` created the
reused solver as non-incremental.

## Fix

- Move `set_incremental()` **before** `updt_params()` in the
`inc_sat_solver` constructor so the simplifier caches the correct mode.
- Create the parallel solver with `incremental_mode=true` in
`mk_psat_tactic`.

## Validation

- Variable elimination on the QF_BV parallel path drops to zero
(`sat-elim-bool-vars-res` 21664 -> 0); remaining `elim-clauses/literals`
are sound cleaner/subsumption steps.
- Consistent with ground truth: on 4.16.0, `sat.elim_vars=false` removed
all 7 `failed to verify` errors; this change disables exactly that
unsound elimination, scoped to the reused/parallel solver.
- A solvable QF_BV instance returns a **valid** model under
`parallel.enable=true model_validate=true`.
- All 92 unit tests pass (`test-z3 /a`).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-07-16 11:47:07 -07:00
..
CMakeLists.txt create simplifier_solver wrapper to supply simplifier layer 2023-01-30 16:12:25 -08:00
inc_sat_solver.cpp Fix unsound model from parallel QF_BV solving (#10133) (#10142) 2026-07-16 11:47:07 -07:00
inc_sat_solver.h booyah 2020-07-04 15:56:30 -07:00
sat_smt_setup.h wip - local search - move to plugin model 2023-02-15 13:32:30 -08:00
sat_smt_solver.cpp refactor solver to include settable stats 2026-06-07 14:17:38 -07:00
sat_smt_solver.h introduce sat-smt-solver 2022-11-28 15:06:31 +07:00