# Solver Notes

## Formula Notes

The training formulas are conflict-constrained set-cover instances. Detection is based only on sanitized DIMACS structure: every original clause must be either a positive covering row of length at least 3 or a negative binary conflict clause. A model selects variables so every positive row is hit and no selected pair appears in the conflict graph.

Observed train split:

- 32 instances, 500 to 1000 variables.
- Clause shape is exclusively positive long clauses plus negative binary clauses.
- Conflict graph density is about 10 percent of all variable pairs.
- Local train labels after solving: 17 SAT, 15 UNSAT.

## Techniques Used

- Conservative family detector for the positive-row / negative-binary encoding.
- Weighted local search for SAT: minimize uncovered rows plus selected conflict edges, using exact weighted flip deltas and periodic weight bumps on currently bad rows/edges.
- CDCL fallback for UNSAT, written from scratch with watched literals, first-UIP learning, restarts, and a row-aware positive branching heuristic.
- VeriPB proof emission for every learned clause as RUP; final level-0 contradiction is emitted as an empty RUP constraint.
- Every SAT model is checked against all original clauses before exit code 10.

## Local Verification

Full local run on `/data/train` after the weighted-search change:

- SAT: 17/17 models checked by an independent script.
- UNSAT: 15/15 proofs verified with `veripb --cnf formula.cnf out.pbp`.
- No UNKNOWN, timeout, crash, invalid model, or invalid proof locally.
- Total solver wall time for the 32 local train files was about 414 seconds on this container. Slowest local UNSAT was about 60 seconds; SAT cases were under 5 seconds after weighting.

## Remaining Things To Try

- Add learned-clause database reduction to reduce memory and proof-writing overhead on harder UNSAT formulas.
- Tune restart schedules and the row-aware branching score for non-500 UNSAT instances if they appear in hidden evaluation.
- Emit proof deletions only after checking VeriPB memory behavior on larger generated instances.

## Known Limitations

- The solver intentionally returns UNKNOWN for CNFs outside the detected SCPC shape.
- UNSAT support depends on CDCL proving a contradiction within the time budget; there is no separate high-level PB certificate.
- SAT local search is deterministic from formula structure, but very different parameter regimes may need more search budget.

## Changelog

- Initial scaffold replaced with a specialized C++ solver.
- Recovered encoding as conflict-constrained set cover from all-positive long clauses and all-negative binary clauses.
- Added SAT-first weighted local search with exact deltas.
- Added CDCL fallback with RUP VeriPB proof logging for UNSAT.
- Added `tools/profile.py` for reproducible clause-shape profiling.
- Verified all local train SAT models and UNSAT proofs; removed generated run logs before packaging.
