# Solver Notes

## Formula Notes

The family is the shuffled Stone tautology encoding for a width-3 chain DAG.
The detector does not use filenames or comments. For a parameter with
`V = 3 * nmarkers + 2`, the formulas have `V * (V + 1)` variables:

- `V * V` placement variables, recovered from the `V` long clauses of length
  `V`. Each long clause is one graph vertex and says that the vertex has at
  least one stone.
- `V` color variables, recovered as the variables absent from the long clauses.
- `4 * V` binary clauses. Three rows are sources with clauses
  `not placement or red(stone)`, and one row is the sink with
  `not placement or not red(stone)`.
- Propagation clauses for each non-source row. If the two predecessor stones
  are different, the clause has six literals. If they are the same, the
  duplicate color literal collapses and the clause has five literals.

The formulas are literal/variable shuffled, including sign flips. The solver
therefore infers each placement literal's stone by color co-occurrence, and it
infers each color's red literal from the 3-to-1 source/sink binary polarity
pattern.

Visible training sweep after the current implementation:

- nmarkers 08: SAT, solved by a high-level model from one missing propagation
  clause on an ancestor of the sink.
- nmarkers 09, 10, 11, 13, 16, 17, 18, 19, and both 20 variants: UNSAT proofs
  generated locally.
- Local proof checks performed after the deletion optimization include n10,
  n11, n19, and n20. The n20 proof is the heavy upper end: about 584 MB proof,
  553 s VeriPB time, and 7.7 GB RSS on this container.

## Techniques Used

- Structural Stone detector based on clause lengths, long-clause rows, binary
  source/sink rows, and propagation clause parsing.
- High-level SAT assignment for missing propagation clauses that can seed a
  blue stone on an ancestor of the sink. The generated complete DIMACS model is
  checked against every original clause before exit code 10.
- Direct UNSAT proof by induction over the recovered DAG. For each ancestor row
  and stone `z`, the proof derives `not p(row,z) or red(z)` from predecessor
  redness, the predecessor long clauses, and the Stone propagation clauses.
  At the sink these derived redness clauses conflict with the sink-blue
  binaries and the sink long clause.
- VeriPB RUP helper clauses are deleted after each local derivation range,
  reducing the largest observed checker memory from roughly 12 GB to under
  8 GB.

## Remaining Things To Try

- A cutting-planes aggregation proof could replace the many local RUP helper
  clauses and would likely make the n20 proof much faster.
- More aggressive proof deletion for intermediate `E` helper clauses may
  reduce memory further, but their IDs are interleaved with deleted `D` ranges,
  so it needs careful bookkeeping.
- The parser assumes each DIMACS clause is on one line, which matches the
  training files and sanitized broker inputs seen so far. A token-stream parser
  would be safer for arbitrary DIMACS wrapping.

## Known Limitations

- The solver is intentionally specialized. If the Stone structure does not
  validate exactly, it returns `UNKNOWN`.
- UNSAT proof generation is capped at `V <= 62`, which covers the observed
  training scale. Larger future deployments may need the CP proof idea or a
  higher timeout.
- If a missing propagation clause lies on an ancestor of the sink, the solver
  tries the simple single-blue-stone construction. If that model ever failed
  verification, it would return `UNKNOWN` rather than risk unsound output.

## Changelog

- Initial scaffold: placeholder solver returned `UNKNOWN`.
- Added structural recovery for shuffled Stone formulas: long-clause placement
  rows, color variables, source/sink rows, stone alignment, predecessor graph,
  and missing propagation detection.
- Added SAT model construction from a missing ancestor propagation clause with
  full CNF model verification.
- Added direct RUP-based VeriPB proof generation for complete ancestor
  subgraphs.
- Added range deletion for short-lived proof helper clauses; this made the
  largest n20 proof verify locally under the 600 second target.
- Updated metadata for broker submission.
