# Solver Notes

## Formula Notes

- The family is Van der Waerden style. Sanitized CNFs are monotone: positive clauses are short forbidden arithmetic-progression images, and negative clauses are long AP constraints.
- A SAT model can be viewed as a set `S` of variables assigned false. Positive clauses require that no positive clause is fully contained in `S`; negative clauses require that every negative clause is hit by at least one member of `S`.
- Plain instances have positive 3-clauses and negative `k`-clauses. Palindromic (`pd`) reductions use mirrored variables, which can collapse some positive constraints to binary clauses and some negative constraints to shorter clauses.

## Techniques Used

- Structural detector accepts only all-positive/all-negative monotone CNFs and ignores comments and filenames.
- Main SAT search is focused local search on the recovered coloring. It repeatedly repairs currently unsatisfied AP constraints and uses a small density/noise portfolio, with longer flip runs on larger palindromic reductions.
- For palindromic reductions with at least 200 variables, the local-search restart stream now runs in two independent C++ threads by default. A candidate found by either thread is still checked against every original clause before SAT is printed.
- Small palindromic reductions (`n <= 191`, long AP size at most 20) now get a short local-search SAT probe followed by a from-scratch CDCL search. CDCL decisions are specialized to currently unhit long AP clauses rather than arbitrary unassigned variables.
- CDCL learned clauses are written as VeriPB `rup` constraints. UNSAT is printed only when CDCL derives a root-level contradiction and closes the proof with `output NONE`, `conclusion UNSAT : -1`, and `end pseudo-Boolean proof`.
- The older exact branch-and-propagate proof prototype remains in the source for reference but is not used by default; it produced sound but multi-million-line tree proofs before solving the first UNSAT samples.
- SAT output is a complete DIMACS assignment and is checked against all original clauses immediately before returning exit code 10.

## Remaining Things To Try

- Better large-instance local-search diversification for the harder `pd_25+` and `pd_31` samples.
- Family-specific constructive seeds or density schedules derived from AP parameters rather than random starts.
- Stronger proof search for medium UNSAT reductions (`n` around 200-230). CDCL reaches a valid proof for `n=150`, `157`, and `170` visible samples, but timed out or returned UNKNOWN on the `n=195+` samples tried.

## Known Limitations

- The solver returns `UNKNOWN` for non-monotone inputs or if no model is found before the internal time budget.
- Plain unreduced instances are still returned as `UNKNOWN` by default; a local `TRY_PLAIN=1` experiment on the visible `2-3-31_930` instance did not solve within 180 seconds.
- Palindromic reductions above 470 variables are returned as `UNKNOWN` immediately; broker runs showed these regions consumed time or memory without SAT wins for this solver.
- UNSAT proofs are limited to smaller palindromic reductions. Larger UNSAT-looking reductions return `UNKNOWN` rather than emitting incomplete or oversized proofs.
- Large satisfiable instances may still need more robust diversification than the current focused local search.
- The greedy hitting-set constructor, exact DFS fallback, widened CDCL cutoffs, and gain-based CDCL branching are available only through environment switches for experiments. They did not improve the default configuration in local tests.

## Changelog

- Initial scaffold replaced with C++ monotone AP parser and verified SAT output path.
- Added exact independent hitting-set branch-and-propagate search.
- Added focused local search over complete colorings with tuned false-density restarts.
- Updated metadata and notes for first broker submission.
- Disabled exact fallback after broker OOMs and replaced the single local-search schedule with a density/noise portfolio; locally this preserves fast `pd_22` solves and solves `pd_24_567` in about 160 seconds.
- Added conservative early `UNKNOWN` guards for plain unreduced instances and very large palindromic reductions to avoid broker OOMs and long unsupported runs.
- Added a from-scratch watched-literal CDCL engine with VeriPB RUP proof logging for small palindromic reductions. Locally verified UNSAT proofs with `veripb --cnf` for visible `pd_18_300`, `pd_18_313`, and `pd_19_339` samples.
- Specialized CDCL branching to choose variables from currently unhit long AP clauses and accept partial assignments once every long AP is hit; this made small SAT/UNSAT cases practical while keeping SAT models independently checked.
- Tried clause weighting in the focused local search; it hurt fast SAT samples and did not solve the `pd_25_606` sample within 240 seconds, so it is disabled by default and only available through `CLAUSE_WEIGHTS=1` for experiments.
- Broker run `eval_20260510T183452Z_1f64560a` solved 16 visible train instances (`sat=14`, `unsat=2`, `unknown=72`) with no invalid outputs, beating the listed VBS solved count of 15. Widened the CDCL cutoff from 190 to 191 variables afterward to cover the structurally similar `pd_20_381` region.
- Added an opt-in greedy hitting-set constructor and experimental env gates for exact DFS/proof and wider CDCL testing. Local tests on `pd_24_592`, `pd_25_606`, plain small UNSAT, `pd_21_406`, and `pd_22_445` did not justify enabling those paths by default.
- Reworked focused local search to run independent restart streams in two threads for palindromic reductions with at least 200 variables. Local 135-second sweep solved new visible SAT cases including `pd_24_592`, `pd_22_462`, `pd_25_606`, and `pd_31_915`; `pd_27_663` solved in a longer 160-second run. VeriPB verified the local UNSAT proofs for `pd_18_313`, `pd_19_339`, and `pd_18_300`.
- Broker run `eval_20260510T212837Z_663e658c` solved 17/88 (`sat=15`, `unsat=2`, `unknown=71`) with no invalid outputs, tying the listed VBS solved count. A follow-up run with a 585s small-palindromic CDCL budget (`eval_20260510T220442Z_086c7678`) did not add solves, so the default CDCL budget was returned to 535s.
- Replaced per-candidate occurrence scans in local search with maintained make/break scores. Local smoke tests still verified SAT/UNSAT outputs and improved `pd_25_606` from about 64s to 34s and `pd_31_915` from about 117s to 55s on this machine.
