Repository navigation
Exchange learned clauses between copies of a loaded solver - #3
Merged
Merged
Conversation
STP's parallel mode forks copies of one loaded solver and lets them pass short learned clauses to each other. Add the hooks it needs. kissat_set_learn hands every clause conflict analysis learns, up to a size limit, and every unit derived at the root to a callback in external literals; a clause over a variable that factoring introduced stays private. kissat_set_import polls a callback in the CDCL loop, after propagation and before the next decision, every given number of conflicts, accepting every unit and a per-poll budget of longer clauses. An imported clause must be implied by the added clauses: every enabled technique only adds implied clauses, removes clauses, or eliminates, substitutes or introduces variables while keeping models extendable, so such a clause over still-active variables excludes no model. It becomes a redundant clause, after one backtrack per poll to the level at which two of its literals are open (the root for units). A clause over an eliminated, substituted, unused or factoring variable is dropped rather than restored, nothing is imported while a proof is written, and the debugging checker takes imported clauses as original ones. kissat_diversify changes only search state between solves: the seed, the saved phases (all true, all false or pseudo-random) and, optionally, the decision queue and score order. The search mode stays the 'stable' option, which the first search reads. test/exchange.cpp runs groups of copies in conflict-limited slices that import each other's clauses, under factoring, early inprocessing, every search mode and both incremental modes, and compares each answer with a fresh solver's and each model with the formula. Assisted-by: Claude Opus 5.5, via Claude Code Signed-off-by: Andrew Teylu <andrew@tey.lu>
aytey
force-pushed
the
claude/cool-meitner-eqjarj
branch
from
October 17, 2026 16:07
f8c5fce to
7db70ec
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
STP's parallel mode forks copies of one loaded solver at its before-search point and lets them pass short learned clauses to each other. This adds the hooks it needs, matching the clause-import extension of STP's CaDiCaL fork, so the group can run on Kissat.
kissat_set_learnhands every clause conflict analysis learns, up to a size limit, and every unit derived at the root (kissat_learned_unit) to a callback in external literals. A clause naming a variable that factoring introduced, or one with no external counterpart, is kept back: such a variable means something different in each copy.kissat_set_importpolls a callback in the CDCL loop, after propagation and before the next decision, every given number of conflicts; a poll accepts every unit and a per-poll budget of longer clauses. External literals are mapped read-only through the import table: a clause over a variable that is unused, eliminated, substituted, an extension variable or beyond the table is dropped rather than restored (never throughkissat_add), root-fixed literals satisfy or shorten it, and duplicates and tautologies are caught with the marks. One poll backtracks at most once, to the lowest level at which every accepted clause has two open literals (the root for units). Units are assigned at the root first; longer clauses become redundant clauses watched on two open literals. A clause falsified at the root makes the solver inconsistent. Nothing is imported while a proof is written, and the debugging checker takes each accepted clause as an original one.Every imported clause must be implied by the clauses added to this solver. Every Kissat technique adds implied clauses, removes clauses, eliminates or substitutes variables with reconstruction, or introduces fresh variables (factor), so such a clause over active variables excludes no model the solver could return; unlike CaDiCaL's block, cover, condition and instantiate, nothing needs to be disabled.
kissat_diversifychanges only search state: the seed (option and generator), the saved phases of active variables (all true, all false, or pseudo-random from the seed) and optionally a shuffled decision queue with random scores. The search mode remains thestableoption, which the first search reads.kissat_get_import_statisticscounts polls, imported clauses and units, drops, satisfied clauses and backtracks, andKISSAT_HAS_CLAUSE_EXCHANGEidentifies the extension.The STP side, which pins this commit, is stp/stp#1363.
Verification
test/exchange.cpp, registered as the CTestclause-exchange: groups of 2–4 copies of random 3- and 4-CNF formulas import each other's clauses while searching in conflict-limited slices (incremental) or one after another (non-incremental), under factoring, early probing, elimination, reduction and rephasing, every search mode, both incremental modes andtumbleoff. Each answer is compared with a fresh solver's and each model is checked against the formula; the test fails unless exports, imports, units, drops, satisfied clauses and backtracks all occur.clause-exchangeincluded (150/150 rounds: 95 sat, 55 unsat; 11,154 clauses imported, 115 of them units, 1,070 import backtracks).assert (GET_OPTION (incremental) || !SAVED (idx))inflags.c; with it, it passes.filetests were left out because they assume a user who cannot read/etc/shadow, and these runs were as root.stp-ptest passes with the group on Kissat, and so do STP's before-search API tests on Kissat (details in the STP PR).