# Solver Notes

## Formula Notes

The training formulas are exact sanitized outputs of Sam Buss's `StConn`
grid st-connectivity CNF generator.  Variables are red/blue edge variables
on a `d x n` rectangular grid, with constants for the virtual outside edges
at the four path endpoints removed from the CNF.  Clauses are:

- `ZeroOrTwoOf` degree constraints for each color at each non-endpoint vertex.
- `OneOf` endpoint constraints, simplified by forced outside edges.
- Binary negative red/blue clauses forbidding the two colored paths from
  sharing a vertex.

The two train instances are:

- `StConn_8_32`: `936` variables, `6488` clauses.
- `StConn_7_128`: `3306` variables, `22933` clauses.

Both are UNSAT.  Generic CDCL was a poor fit: an initial proof-logging CDCL
attempt produced a 151 MB unfinished proof after about 40 seconds on
`StConn_8_32`.

## Techniques Used

The submitted solver first parses DIMACS and conservatively detects the exact
StConn generator output.  Detection is structural: it solves the variable-count
equation for candidate `(d,n)`, regenerates the sanitized clauses internally,
and compares the clause multiset.  It does not read comments, filenames, or
hashes.

For detected widths `d <= 9`, it emits the bounded-width resolution proof from
the StConn crossing-sequence argument.  A frontier path `pi(i,j)` crosses
`d+1` grid edges.  Each crossed edge contributes one of `e/g/r` (neither,
blue/green, red), and the word is reduced in the group with `g^2 = r^2 = 1`.
The invariant is that every frontier assignment whose reduced word is not `gr`
is banned.  The solver derives banned clauses as VeriPB `rup` steps while
sweeping the frontier across the grid.  Each local transition differs around
one vertex, so a tiny tree-resolution proof over the old edge variables is
enough to lift the next banned clause.

The final right boundary has reduced word `rg`, so the banned-clause invariant
derives the empty clause.  The solver writes only VeriPB RUP constraints and
returns `UNKNOWN` if detection or proof generation falls outside the supported
shape.

## Local Verification

Current local timings after removing global proof deduplication:

- `StConn_8_32`: solver `13.14s`, max RSS `17.6 MB`; proof `867 MB`;
  `veripb` verified in `123.70s`, max RSS `3.98 GB`.
- `StConn_7_128`: solver `14.49s`, max RSS `9.2 MB`; proof `1.1 GB`;
  `veripb` verified in `112.94s`, max RSS `4.68 GB`.

## Remaining Things To Try

- Compress the proof by deriving automaton-prefix clauses instead of every
  banned full frontier assignment.
- Add a direct VeriPB cutting-planes proof for the crossing invariant, if a
  compact parity/topology encoding is found.
- Extend the detector/proof beyond `d <= 9` only with proof-size safeguards.

## Known Limitations

- The proof size is large, roughly 0.9-1.1 GB on the training instances.
- VeriPB checking, not solver generation, is the main runtime and memory cost.
- Unsupported formulas, non-exact StConn encodings, or widths above `9` return
  `UNKNOWN`.

## Changelog

- Replaced the scaffold with an exact StConn detector.
- Added a first proof-logging CDCL experiment; it was retained in source but is
  not used by the final path.
- Implemented the crossing-sequence resolution proof generator with VeriPB RUP
  output.
- Fixed a trinary assignment enumeration bug that sorted the live recursion
  buffer and corrupted backtracking.
- Removed global emitted-clause deduplication, reducing solver memory from about
  1 GB to under 20 MB with no proof-size regression on train.
