# Solver Notes

## Formula Notes

- The train split is edge-matching. Small `em_*` formulas expose exact-one
  groups as positive clauses with all pairwise negative exclusions.
- The useful invariant is stronger than the inherited notes captured: the
  recovered edge-color exact-one groups identify adjacencies between pairs of
  high-level pieces. Those adjacencies form an unlabeled square grid graph
  with degree distribution 4 corners, `4*(n-2)` borders, and `(n-2)^2`
  interiors.
- The positive clauses contain a contiguous block of board-cell placement
  groups. Usually this starts after `n^2` piece groups; the `12_2_4` family has
  one omitted positive piece group, so the solver derives the missing piece
  group as the placement variables not covered before the cell block.
- For a placement variable `p`, clauses containing `-p` and an edge-group
  variable define the compatible tuple of edge group values for that piece in
  that cell/orientation. A complete model is recovered by embedding the piece
  graph into the board grid, selecting one placement/orientation per cell, and
  setting the implied edge-group variables.
- The large Holten `b2005` and `Puzzle20Apr...` formulas use the feature-
  cardinality grid-coloring encoding. The variable order is structural:
  row-major cells allocate newly seen gridline color groups, then `n^2`
  tile-existence variables for that cell, then per-color `NoColor` variables.
  The base-variable count is
  `2*n*(n+1)*colors + n^4 + n^2*colors`.
- In the Holten formulas, tile id `i` corresponds to the generator's original
  cell `i`. Hint tiles appear as positive tile-unit clauses, and their four
  edge colors appear as positive gridline units. For non-hint tiles, clauses
  containing `-TileExistence(cell0,tile)` plus only cell-0 edge/NoColor
  variables recover the four rotations of that tile.
- The older `b1904` formulas are a different encoding. They are guarded out by
  the Holten detector and currently return `UNKNOWN`.

## Techniques Used

- DIMACS parser with original clause storage and literal occurrence lists.
- Structural exact-one detector independent of filenames and comments.
- Contiguous positive-clause block detector for the placement cells and piece
  groups, including the one-missing-piece variant.
- Reconstruction of the hidden piece-adjacency graph from edge-color exact-one
  groups, followed by direct grid-graph embedding.
- Placement/orientation tuple enumeration and full model verification against
  every original clause before returning SAT. The solver never claims UNSAT.
- Holten feature-cardinality decoder: structural row-major variable-layout
  recovery, tile-pattern extraction from local clearing clauses, row-major
  identity reconstruction, and Boolean propagation to fill Tseitin/counter
  auxiliaries before full CNF verification.

## Remaining Things To Try

- Improve the auxiliary fill for the 67M+ Holten series-8 and 16x16 formulas.
  A 67M-clause 14x14 case stayed around 2 GB RSS but ran too close to the
  600s cutoff, so the submitted guard is capped at 40M clauses.
- Decode the older `b1904` encoding. It is small but structurally different
  from the Holten feature-cardinality layout and should not be sent through
  that detector.
- Add a proof strategy only after a high-level UNSAT certificate is clear.

## Known Limitations

- UNSAT instances always return `UNKNOWN`.
- Formulas above 400,000 variables or 40 million clauses are skipped before
  occurrence-list allocation. This keeps the 30-34M Holten 14x14 formulas in
  scope while avoiding the slow 67M+ and 111M-clause variants for this run.
- The solver depends on the square-grid piece-adjacency invariant. If a future
  EM instance uses the same variable vocabulary but a non-grid graph, it should
  return `UNKNOWN`.
- The Holten path assumes the generator's identity tile numbering. The solver
  still verifies the complete original CNF model before printing SAT; if that
  assumption fails, it returns `UNKNOWN`.

## Changelog

- Added C++ DIMACS parser, occurrence lists, model verification, and incomplete
  local-search fallback.
- Added exact-one detector and exact-one-preserving local search.
- Submitted `eval_20260507T231517Z_46e289e4`: 1 SAT, 77 UNKNOWN, no invalid
  answers or crashes. The solved case was `em_14_7_3_all`.
- Disabled the direct DFS for submission because it consumed the cutoff on
  small exact-one instances; increased the local-search cutoff to 585s.
- Submitted `eval_20260507T233625Z_def9971c`: 3 SAT, 71 UNKNOWN, 4 solver OOM.
  Added a conservative header-size guard to avoid unsupported large instances.
- Updated metadata and build notes for broker submission.
- Replaced the inherited stochastic local-search solver with a structural
  grid-reconstruction solver. It detects the placement-cell block, derives the
  piece groups, reconstructs the hidden piece adjacency grid from edge exact-one
  groups, selects orientations, and verifies the full CNF model.
- Local sweep on `/data/train/*-em_*.cnf.xz`: solved 31/31 as SAT with
  internally verified models, including the previous `cmp` and `fbc` timeout
  cases. Representative runtimes were under one second per EM instance.
- Submitted `eval_20260508T041623Z_04b61921`: visible train status was
  30 SAT, 48 UNKNOWN, with no invalid answers, crashes, OOMs, or timeouts.
  This beats the provided `kissat-sc2024` baseline solved count of 27/78 on
  the visible training split.
- Added a Holten feature-cardinality solver path for `b2005` and
  `Puzzle20Apr...` formulas. It reconstructs the row-major gridline/tile
  variable layout, extracts tile rotations from first-cell clearing clauses,
  uses the original tile id as the cell placement, orients via shared gridline
  colors, propagates auxiliary variables with in-house Boolean propagation, and
  verifies every original clause.
- Local checks after the Holten change: `Puzzle20Apr10x10C13H3p1v2` solved in
  about 1.5s; a 5.5M-clause 12x12 case in about 39s and 194MB; a 19M-clause
  12x12 series-7 case in about 42s and 594MB; 30-33M-clause 14x14 cases in
  about 31-32s and under 1GB. A 67M-clause series-8 case remained near 2GB RSS
  but exceeded the practical local cutoff, so the guard was lowered to 40M.
- Added a clause-count guard so the unsupported `b1904` formulas return
  `UNKNOWN` quickly instead of spending time in the Holten detector.
- Submitted `eval_20260508T052526Z_71a2a918`: train-visible result was
  63 SAT, 10 UNKNOWN, and 5 TIMEOUT, with no invalid answers, crashes, OOMs,
  or proof/verifier failures. The timeouts were 14x14 Holten cases in the
  slower auxiliary-completion path.
- Added internal time checks in propagation, greedy auxiliary completion, and
  final verification, and moved the solver deadline to 520s so borderline
  Holten cases return `UNKNOWN` before the broker's 600s cutoff.
- Submitted `eval_20260508T061340Z_893635fc`: aggregate remained
  63 SAT, 10 UNKNOWN, and 5 TIMEOUT. Added an additional deadline check inside
  Holten tile-pattern extraction and candidate iteration, which is the remaining
  suspected long-running path before auxiliary completion.
