Conversation
Add config/context-level SAT delegate selection for QF_BV, including\npersistent delegate runtime state across check-sat calls. Implement\nincremental delegate integration for CaDiCaL and CryptoMiniSat with\ncheck-sat-assuming support and unsat-core mapping from failed assumptions.\n\nKeep non-incremental delegates (y2sat, kissat) valid selections but return\nCTX_OPERATION_NOT_SUPPORTED for check-sat-assuming.\n\nAdd selector-frame mode wiring (ignored for non-incremental delegates),\ncontext mutation tracking/cleanup, and API+regression tests for delegate\ncontexts/assumptions.
Context-level QF_BV delegates (Levels 1 and 2 of #453)SummaryThis PR lifts Yices' existing third-party SAT-solver ( Closes issue #453, Levels 1 and 2 (configurable SAT back-end per context, with and without incrementality). Level 3 of #453 (mixed-theory contexts with external SAT back-end) remains out of scope for this PR. What's new for users1.
|
| Delegate | Availability | Incremental push/pop | check-sat-assuming |
Unsat core from assumptions |
|---|---|---|---|---|
y2sat |
always | rebuild per check | rebuild per check | — |
kissat |
optional (build flag) | rebuild per check | rebuild per check | — |
cadical |
optional (build flag) | yes (selector frames) | yes | yes |
cryptominisat |
optional (build flag) | yes (selector frames) | yes | yes |
yices_has_delegate("<name>") returns 1 if the current Yices build includes the back-end.
Assumptions and unsat cores
yices_check_context_with_assumptions now works with a configured delegate:
- For
cadical/cryptominisat, the delegate's native assumption interface is used; the unsat core is filtered back into the caller's term space and accessible viayices_get_unsat_core. - For
y2sat/kissat, the delegate is rebuilt with the assumptions included; no unsat-core extraction (the errorMCSAT_ERROR_...path is unchanged from before).
Model import
On SAT, the delegate's boolean model is imported into the smt-core so that yices_get_model / yices_formula_true_in_model work exactly as they do for the native solver.
Non-goals / limitations
- Logics other than QF_BV: the delegate is only consulted when the context has been configured for QF_BV. For any other logic,
sat-delegateis ignored (andyices_check_contextreturns the usual error if the param-leveldelegateis set on a non-QF_BV context). Mixed-theory delegate support (Level 3 of Feature request: making delegates available when solving from a Yices context #453) is not in this PR. - Selector-frames mode re-feeds the full clause set on each mutation. It preserves the delegate's learned clauses (this is the win), but the input CNF is replayed on each push/assert — no clause-delta plumbing between the smt-core and the delegate. Users of very large incremental problems should benchmark both
sat-delegate-selector-frames=trueand=falseagainst the native solver. - DIMACS export unchanged — the existing
yices-smt2 --dimacs=... --delegate=y2satbehaviour is preserved.
Implementation notes
- New file:
src/api/search_parameters.{h,c}gains shared helperssat_delegate_name,parse_sat_delegate,effective_sat_delegate_mode(used by bothcontext_configandcontext_solver). - New functions:
check_with_incremental_delegate(selector-frames path) andcontext_prepare_incremental_delegateinsrc/context/context_solver.c. Persistent state is held indelegate_state_t, lifecycle-managed by the context (delete_context,reset_context, push/pop). - Generalised clause export: the existing
copy_problem_clausesis refactored into the publicadd_problem_clauses_to_delegate(delegate, core, guard_literal)so the one-shot and the selector-frames paths share the export code. - New capability hooks on
delegate_t:check_assuming,collect_failed_assumptions,add_vars. Predicatesincremental_delegate(...)anddelegate_supports_assumptions(...)provide uniform dispatch.
Tests
tests/api/context_delegate.c is the main new test file. It parameterises every case over every delegate installed in the current build:
- One-shot SAT / UNSAT shapes (
bvadd,bvand,extract,concat). - Push/pop incremental, nested push/pop, branching push/pop.
sat-delegatevia config and via per-check param.sat-delegate-selector-frames="true"with growing CNF variable count across checks, and with assumptions.- Failed-assumption → unsat-core mapping under
cadicalandcryptominisat. - Negative cases: unknown delegate name, delegate not compiled in, wrong logic (
QF_LIA). - Interaction with
assert_formula_true_in_context_modelon every SAT case.
Regression integration: tests/regress/check.sh now opportunistically re-runs every QF_BV regression under each installed delegate (filtered by is_qf_bv_delegate_candidate to skip tests that depend on model/core printing). New top-level targets: make delegate-regress and make static-delegate-regress.
Follow-up documentation
- User manual (doc/manual/manual.tex): expand §"Third-Party SAT Solvers" and the
--delegateoption paragraph to describe the new API-level configuration, the selector-frames option, and the capability matrix above. - Website (doc/sphinx/source/): add rows for
sat-delegateandsat-delegate-selector-framesin the configuration table in context-operations.rst, add adelegateentry in parameters.rst, and cross-reference from formula-operations.rst. - yices.h: expand the comment blocks at the declarations of
yices_set_configandyices_set_paramso the header carries the same capability matrix.
Expand the Third-Party SAT Solvers section of the user manual, the sphinx Contexts and Heuristic Parameters pages, the formula-operations Delegates note, and the comment blocks in yices.h around yices_set_config and yices_set_param so the three documentation surfaces describe the same picture: - sat-delegate context configuration parameter (y2sat / cadical / cryptominisat / kissat) with the capability matrix. - sat-delegate-selector-frames configuration parameter, including the rebuild-on-mutation default and the keep-live behaviour for CaDiCaL / CryptoMiniSat. - delegate per-check search parameter, including the one-shot override semantics relative to the configured context delegate. - Cross-references between formula-operations (one-shot yices_check_formula(s)) and the context-level documentation.
Two low-severity follow-ups from review. 1. yices_check_formula / yices_check_formulas (src/include/yices.h): the public API comment listed valid delegates as "cadical", "cryptominisat", "y2sat" only. The implementation and the rest of the documentation already accept "kissat"; add it to the public header in three places: the valid-delegate list, the build-time note, and the CTX_UNKNOWN_DELEGATE / CTX_DELEGATE_NOT_AVAILABLE error descriptions. 2. tests/regress/check.sh: change the default of REGRESS_DELEGATE_MODE from "auto" to "off". The previous default silently fanned every "make check" / "make regress" out into one extra pass per installed delegate on QF_BV tests, which inflated CI runtime on machines with CaDiCaL / CryptoMiniSat / Kissat installed. The opt-in "make delegate-regress" / "make static-delegate-regress" targets already set REGRESS_DELEGATE_MODE=only explicitly, so they keep working unchanged. Users wanting the combined coverage in a single pass can set REGRESS_DELEGATE_MODE=auto by hand. Documented the three modes inline in check.sh so the default choice has a discoverable rationale.
Code Review by Codex/GPT5.5 :
|
This PR implements Level 1 and Level 2 of context-level SAT delegate support for QF_BV as laid out in #453.
delegate) and context config (sat-delegate).sat-delegate-selector-framesfor incremental delegate frame handling.yices_check_contextthrough the selected delegate when applicable.cadical,cryptominisat) across checks.yices_check_context_with_assumptionson QF_BV contexts.y2sat,kissat) usable in config/params, butcheck-sat-assumingreturnsCTX_OPERATION_NOT_SUPPORTED.--delegate=...is applied through search params and works with incremental mode.Key Behavior
sat-delegatedelegate(per-check override)sat-delegate-selector-framesis only relevant for incremental delegates and ignored for non-incremental delegates.check_context_with_assumptions:cadical/cryptominisat: supported, with unsat-core mapping from failed assumptions.y2sat/kissat:YICES_STATUS_ERROR+CTX_OPERATION_NOT_SUPPORTED.Implementation Notes
context_tnow tracks:CLI and Regress
--incrementalwith--delegate.make delegate-regressmake static-delegate-regressy2satregression case to validate non-incremental delegate behavior in incremental sessions.Tests Run
make check-apiTotal: 24, Pass: 24, Fail: 0make delegate-regressPass: 249, Fail: 0Scope