Skip to content

Commit 0ac771c

Browse files
committed
Merge master + extend check_with_incremental_cadical to handle assumptions
Integrates the context_delegates PR (#607) with our incremental CaDiCaL branch, then unifies into a single incremental CaDiCaL path that handles both regular check-sat and check-sat-assuming. Merge conflict resolution: - context.h: keep both check_with_incremental_cadical (#if HAVE_CADICAL) and check_with_incremental_delegate (for non-CaDiCaL incremental delegates). - yices_smt2.c: drop the narrow CaDiCaL-only error gate; incremental_delegate() now validates inside context_solver.c. Unified CaDiCaL incremental path: - solve_with_incremental_cadical gains (nassumptions, assumptions, failed) parameters: caller-provided assumptions are forwarded to ccadical_assume (via ic_lit2dimacs for BVA-safe mapping), and failed assumptions are collected via ccadical_failed on UNSAT. - check_with_incremental_cadical gains the same parameters and routes check-sat-assuming directly through the persistent CaDiCaL instance, bypassing the selector-frame machinery and its implicit x+1 mapping. - Dispatch in check_context_with_term_assumptions routes SAT_DELEGATE_CADICAL to check_with_incremental_cadical unconditionally, so both regular push/pop and check-sat-assuming use the explicit bvar_to_dimacs[] map. - Other incremental delegates (cryptominisat with selector-frames) continue to use check_with_incremental_delegate.
2 parents d72fa97 + b2f63a2 commit 0ac771c

44 files changed

Lines changed: 2925 additions & 152 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Makefile.build

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,13 +305,21 @@ static-check-api: static_build_subdirs version
305305
check: regress
306306
mcsat-check: mcsat-regress
307307
static-check: static-regress
308+
delegate-check: delegate-regress
309+
static-delegate-check: static-delegate-regress
308310

309311
regress: build_subdirs version
310312
@ echo "=== Building binaries ==="
311313
@ $(MAKE) -C $(srcdir) BUILD=../$(build_dir) bin
312314
@ echo "=== Running regressions ==="
313315
+@ $(regressdir)/check.sh $(regressdir) $(build_dir)/bin
314316

317+
delegate-regress: build_subdirs version
318+
@ echo "=== Building binaries ==="
319+
@ $(MAKE) -C $(srcdir) BUILD=../$(build_dir) bin
320+
@ echo "=== Running delegate-only regressions ==="
321+
+@ REGRESS_DELEGATE_MODE=only $(regressdir)/check.sh $(regressdir) $(build_dir)/bin
322+
315323

316324
mcsat-regress: build_subdirs version
317325
@ echo "=== Building binaries ==="
@@ -326,6 +334,12 @@ static-regress: static_build_subdirs version
326334
@ echo "=== Running regressions ==="
327335
+@ $(regressdir)/check.sh $(regressdir) $(build_dir)/static_bin
328336

337+
static-delegate-regress: static_build_subdirs version
338+
@ echo "=== Building binaries ==="
339+
@ $(MAKE) -C $(srcdir) BUILD=../$(build_dir) static-bin
340+
@ echo "=== Running delegate-only regressions ==="
341+
+@ REGRESS_DELEGATE_MODE=only $(regressdir)/check.sh $(regressdir) $(build_dir)/static_bin
342+
329343

330344
static-mcsat-regress: static_build_subdirs version
331345
@ echo "=== Building binaries ==="
@@ -335,7 +349,9 @@ static-mcsat-regress: static_build_subdirs version
335349

336350

337351
.PHONY: all obj static-obj lib static-lib bin static-bin test static-test \
338-
regress static-regress check static-check check-api static-check-api
352+
regress delegate-regress static-regress static-delegate-regress \
353+
check delegate-check static-check static-delegate-check \
354+
check-api static-check-api
339355

340356

341357
#

doc/manual/manual.tex

Lines changed: 77 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1455,16 +1455,71 @@ \section{MCSAT}
14551455
non-linear arithmetic are presented in a preprint~\cite{jovanovic2021interpolation}.
14561456

14571457
\section{Third-Party SAT Solvers}
1458+
\label{delegates}
1459+
1460+
Yices supports using third-party Boolean satisfiability solvers as the
1461+
back-end CNF engine for QF\_BV problems. Such solvers, called
1462+
\emph{delegates}, are optional but can provide significant performance
1463+
improvements. When a delegate is selected, Yices performs ``bit
1464+
blasting'' as usual --- converting the problem to an equisatisfiable
1465+
SAT problem in conjunctive normal form (CNF) --- and then hands the
1466+
resulting CNF to the selected delegate instead of the internal Yices
1467+
CDCL SAT solver. Bit-blasting itself is unchanged.
1468+
1469+
Yices recognizes four delegate names. \texttt{y2sat} is an internal
1470+
SAT solver always available in any Yices build. CaDiCaL,
1471+
CryptoMiniSat, and Kissat are external solvers; support for each must
1472+
be enabled at compilation time as explained in
1473+
Chapter~\ref{compilation}. The capability matrix is summarized below.
1474+
\begin{center}
1475+
\begin{tabular}{|l|c|c|c|c|}
1476+
\hline
1477+
Delegate & Always available & Incremental push/pop &
1478+
\texttt{check-sat-assuming} & Unsat core from assumptions \\
1479+
\hline
1480+
\texttt{y2sat} & yes & rebuild on each check & rebuild on each check & no \\
1481+
\texttt{cadical} & no & yes (selector frames) & yes & yes \\
1482+
\texttt{cryptominisat}& no & yes (selector frames) & yes & yes \\
1483+
\texttt{kissat} & no & rebuild on each check & rebuild on each check & no \\
1484+
\hline
1485+
\end{tabular}
1486+
\end{center}
1487+
1488+
A delegate can be selected in three ways:
1489+
\begin{itemize}
1490+
\item from the SMT-LIB~2 frontend, by passing
1491+
\texttt{--delegate=<solver>} to \texttt{yices-smt2}
1492+
(Section~\ref{smt2-tool});
1493+
\item from the API, by setting the \texttt{sat-delegate} parameter on
1494+
the context configuration with \texttt{yices\_set\_config} before
1495+
the context is created;
1496+
\item from the API on a per-check basis, by setting the
1497+
\texttt{delegate} field of a search-parameter record with
1498+
\texttt{yices\_set\_param}, and passing that record to
1499+
\texttt{yices\_check\_context} (or one of its variants).
1500+
\end{itemize}
1501+
The one-shot helpers \texttt{yices\_check\_formula} and
1502+
\texttt{yices\_check\_formulas} also accept a delegate name as their
1503+
last argument; they bit-blast the input formulas into a fresh CNF and
1504+
hand it to the chosen delegate.
1505+
1506+
For incremental QF\_BV contexts (\texttt{push-pop} or
1507+
\texttt{multi-checks} mode), CaDiCaL and CryptoMiniSat support a
1508+
\emph{selector-frames} strategy that keeps the delegate live across
1509+
\texttt{check-sat} calls and uses fresh selector literals to retract
1510+
clauses on \texttt{pop}. This strategy preserves learned clauses
1511+
between checks and is selected by setting the
1512+
\texttt{sat-delegate-selector-frames} configuration parameter to
1513+
\texttt{"true"} on the context. The default is \texttt{"false"}, in
1514+
which case the delegate is rebuilt from the current bit-blasted
1515+
problem at every mutation. The non-incremental delegates
1516+
\texttt{y2sat} and Kissat are always rebuilt on each check; the
1517+
\texttt{sat-delegate-selector-frames} option has no effect for them.
14581518

1459-
In Yices 2.6.2, we have added support for using third-party Boolean
1460-
satisfiability solvers. Such solvers are optional but can provide
1461-
significant performance improvements on bit-vector problems. Use of
1462-
these SAT solvers is enabled by a command-line option and is currently
1463-
restricted to non-incremental QF\_BV problems. If an external solver
1464-
is selected, Yices will perform ``bit blasting,'' that is, convert the
1465-
problem to an equisatisfiable SAT problem in conjunctive normal form
1466-
(CNF) and use the third-party solver to check satisfiability of this
1467-
CNF formula.
1519+
The full list of API names recognized by these mechanisms, together
1520+
with their possible values and error codes, is documented in the
1521+
\texttt{yices.h} header and on the Yices website (see
1522+
Section~\ref{full-api}).
14681523

14691524

14701525

@@ -3652,6 +3707,7 @@ \section{SMT-LIB 2.x}
36523707

36533708

36543709
\subsection{Tool Invocation}
3710+
\label{smt2-tool}
36553711

36563712
To run \texttt{yices-smt2} on an input file, type
36573713
\begin{small}
@@ -3772,7 +3828,13 @@ \subsubsection*{Selecting a Back-end SAT Solver}
37723828
problems by preprocessing and simplification, without producing a CNF
37733829
formula. In such cases, the \texttt{delegate} option is irrelevant.
37743830

3775-
\paragraph{Limitation:} Currently, use of the delegates is restricted to non-incremental problems.
3831+
\paragraph{Incremental use:} Delegates can be used with
3832+
\texttt{--incremental} on QF\_BV problems. CaDiCaL and CryptoMiniSat
3833+
support incremental delegate checks. Non-incremental delegates such as
3834+
\texttt{y2sat} and Kissat are rebuilt from the current bit-blasted
3835+
problem on each \texttt{check-sat}. The selector-frame configuration
3836+
used by the API for incremental delegates has no effect for
3837+
non-incremental delegates.
37763838

37773839
\subsubsection*{Exporting to Dimacs}
37783840

@@ -3864,7 +3926,10 @@ \subsubsection*{All Command-line Options}
38643926

38653927
\item[--delegate=<solver>] Select an external SAT solver for bit-vector problems,
38663928

3867-
The \texttt{<solver>} can be either \texttt{cadical}, or \texttt{cryptominisat}, or \texttt{y2sat}.
3929+
The \texttt{<solver>} can be either \texttt{cadical},
3930+
\texttt{cryptominisat}, \texttt{kissat}, or \texttt{y2sat}. In
3931+
incremental mode, \texttt{y2sat} and Kissat are rebuilt from the
3932+
current bit-blasted problem on each \texttt{check-sat}.
38683933

38693934
\item[--dimacs=<filename>] Bitblast then export the CNF to a file (in DIMACS format).
38703935

@@ -4641,6 +4706,7 @@ \subsection*{Building and Querying a Model}
46414706

46424707

46434708
\section{Full API}
4709+
\label{full-api}
46444710

46454711
The main header file \texttt{yices.h} includes documentation about all
46464712
API functions. We provide more documentation on the Yices website:

doc/sphinx/source/context-operations.rst

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,53 @@ specialized for difference logic and support only mode one-shot.
226226
The default mode is push-pop.
227227

228228

229+
.. _sat_delegate_config:
230+
231+
**SAT Delegate (QF_BV only)**
232+
233+
For QF_BV contexts, Yices can be configured to use a third-party
234+
Boolean SAT solver --- called a *delegate* --- as the back-end CNF
235+
engine. When a delegate is selected, Yices bit-blasts the assertions
236+
to CNF as usual and hands the resulting clause set to the chosen
237+
delegate instead of the internal Yices CDCL SAT solver.
238+
239+
Yices recognizes four delegate names. ``y2sat`` is an internal SAT
240+
solver always available in any Yices build. ``cadical``,
241+
``cryptominisat``, and ``kissat`` are external solvers; their
242+
inclusion in a particular Yices build is optional and can be checked
243+
at runtime with :c:func:`yices_has_delegate`. The capabilities of each
244+
delegate are summarized in the following table.
245+
246+
+-------------------+-------------------+-------------------------+---------------------------+----------------------------------+
247+
| Delegate | Always available | Incremental push/pop | ``check_with_assumptions``| Unsat core from assumptions |
248+
+===================+===================+=========================+===========================+==================================+
249+
| ``y2sat`` | yes | rebuild on each check | rebuild on each check | no |
250+
+-------------------+-------------------+-------------------------+---------------------------+----------------------------------+
251+
| ``cadical`` | optional | yes (selector frames) | yes | yes |
252+
+-------------------+-------------------+-------------------------+---------------------------+----------------------------------+
253+
| ``cryptominisat`` | optional | yes (selector frames) | yes | yes |
254+
+-------------------+-------------------+-------------------------+---------------------------+----------------------------------+
255+
| ``kissat`` | optional | rebuild on each check | rebuild on each check | no |
256+
+-------------------+-------------------+-------------------------+---------------------------+----------------------------------+
257+
258+
For incremental QF_BV contexts (``push-pop`` or ``multi-checks``
259+
mode), CaDiCaL and CryptoMiniSat support a *selector-frames* strategy
260+
that keeps the delegate live across :c:func:`yices_check_context`
261+
calls and uses fresh selector literals to retract clauses on
262+
``yices_pop``. This strategy preserves the delegate's learned clauses
263+
between checks. It is opt-in via the
264+
``sat-delegate-selector-frames`` configuration parameter described
265+
below. When the option is ``"false"`` (the default) or the delegate
266+
is non-incremental, Yices rebuilds the delegate from the current
267+
bit-blasted problem at every mutation.
268+
269+
The delegate can also be selected, or one-shot overridden, on a
270+
per-check basis through the ``delegate`` field of a search-parameter
271+
record (see :ref:`heuristic_parameters`).
272+
273+
The SAT delegate options are ignored for any logic other than QF_BV.
274+
275+
229276

230277
Configuration Descriptor
231278
........................
@@ -288,6 +335,31 @@ arithmetic fragment and the operating mode:
288335
+--------------------+-----------------------------------------------------+
289336

290337

338+
Two more parameters control the SAT back-end for QF_BV contexts.
339+
They are ignored for any other logic. See
340+
:ref:`sat_delegate_config` above for the meaning of each value.
341+
342+
+--------------------------------+---------------------+----------------------------------------------+
343+
| Name | Value | Meaning |
344+
+================================+=====================+==============================================+
345+
| sat-delegate | ``"none"`` | use the internal Yices SAT solver (default) |
346+
| +---------------------+----------------------------------------------+
347+
| | ``"y2sat"`` | use y2sat as the SAT back-end |
348+
| +---------------------+----------------------------------------------+
349+
| | ``"cadical"`` | use CaDiCaL as the SAT back-end |
350+
| +---------------------+----------------------------------------------+
351+
| | ``"cryptominisat"`` | use CryptoMiniSat as the SAT back-end |
352+
| +---------------------+----------------------------------------------+
353+
| | ``"kissat"`` | use Kissat as the SAT back-end |
354+
+--------------------------------+---------------------+----------------------------------------------+
355+
| sat-delegate-selector-frames | ``"false"`` | rebuild the delegate on each context |
356+
| | | mutation (default) |
357+
| +---------------------+----------------------------------------------+
358+
| | ``"true"`` | keep an incremental delegate live across |
359+
| | | checks using selector-guarded frames |
360+
+--------------------------------+---------------------+----------------------------------------------+
361+
362+
291363

292364
A configuration descriptor also stores a logic flag, which can either
293365
be *unknown* (i.e., no logic specified), or the name of an SMT-LIB

doc/sphinx/source/formula-operations.rst

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,21 +69,28 @@ third-party Boolean satisfiability solvers for bit-vector problems.
6969
7070
A delegate is a SAT solver to use as backend when checking satisfiability of a bit-vector
7171
formula. The *delegate* parameter is ignored and has no effect unless the *logic* is "QF_BV".
72-
In the latter case, three different delegates can be used:
72+
In the latter case, four different delegates can be used:
7373
7474
- "cadical": the CaDiCaL solver (https://github.com/arminbiere/cadical)
7575
76-
- "cryptominisat: the CryptoMiniSat solver (https://github.com/msoos/cryptominisat)
76+
- "cryptominisat": the CryptoMiniSat solver (https://github.com/msoos/cryptominisat)
77+
78+
- "kissat": the Kissat solver (https://github.com/arminbiere/kissat)
7779
7880
- "y2sat": an experimental SAT solver included in Yices
7981
80-
These three delegates are known to Yices but support for CaDiCaL and CryptoMiniSat is optional.
82+
These four delegates are known to Yices but support for CaDiCaL, CryptoMiniSat, and Kissat is optional.
8183
They may or may not be available depending on how the Yices library was configured and compiled.
8284
The "y2sat" delegate is always available.
8385
8486
If *delegate* is NULL, the default SAT solver internal to Yices is used (which can be much slower
8587
than state-of-the-art solvers such as CaDiCaL).
8688
89+
The same delegates can also be used through the regular context API
90+
--- including with push/pop and ``check-sat-assuming`` --- by setting
91+
the ``sat-delegate`` configuration parameter on a QF_BV context. See
92+
:ref:`sat_delegate_config`.
93+
8794
8895
**Examples**
8996

doc/sphinx/source/parameters.rst

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -472,3 +472,38 @@ Flattening *(<=> p q)* rewrites the term to *(and (=> p q) (=> q p))*
472472

473473
Flattening *(ite c p q)* rewrites the term to *(and (=> c p) (=> (not c) q)*
474474

475+
476+
477+
SAT Delegate Selection (QF_BV)
478+
------------------------------
479+
480+
For QF_BV contexts, the back-end SAT solver --- called a *delegate*
481+
--- can be selected on a per-check basis through the following
482+
parameter.
483+
484+
+------------+-----------------+---------------------------------------------+
485+
| Parameter | Value | Meaning |
486+
| Name | | |
487+
+============+=================+=============================================+
488+
| delegate | none | use the SAT back-end configured on the |
489+
| | | context (default) |
490+
| +-----------------+---------------------------------------------+
491+
| | y2sat | use y2sat for this check |
492+
| +-----------------+---------------------------------------------+
493+
| | cadical | use CaDiCaL for this check |
494+
| +-----------------+---------------------------------------------+
495+
| | cryptominisat | use CryptoMiniSat for this check |
496+
| +-----------------+---------------------------------------------+
497+
| | kissat | use Kissat for this check |
498+
+------------+-----------------+---------------------------------------------+
499+
500+
If a delegate is set in the parameter record and it differs from the
501+
delegate configured on the context (see :ref:`sat_delegate_config`),
502+
the parameter takes effect for that single call only and the persistent
503+
delegate state of the context is left untouched. If the parameter is
504+
``"none"``, the context's configured delegate is used.
505+
506+
A delegate name in this parameter has no effect for any logic other
507+
than QF_BV. Whether a particular delegate is available in the current
508+
Yices build can be checked with :c:func:`yices_has_delegate`.
509+

0 commit comments

Comments
 (0)