# Solver Notes

## Formula Notes

The regular training instances are shuffled `xor-chain` CNFs. For size `n`,
the non-miter files have `3n-2` variables, `8n-6` clauses, exactly two binary
clauses, and all remaining clauses are ternary. Every ternary variable triple
appears exactly four times and encodes one 3-variable XOR equation. All
non-endpoint variables occur in exactly two XOR gates; the two endpoint
variables occur once in the XOR gates and also in the binary pair.

Many instances are UNSAT because summing all ternary XOR equations cancels the
internal variables and derives an endpoint XOR opposite to binary XOR clauses.
Some generated instances can instead contain multiple binary XOR equations, a
smaller inconsistent cycle, or no endpoint binary pair at all, so the solver now
runs GF(2) elimination over all recovered 2-XOR and 3-XOR equations and logs the
actual conflicting dependency it finds. The detector uses clauses only and does
not read or depend on comment lines, filenames, or hashes.

The `x1mul.miter` file is not currently handled: it has many non-XOR clauses and
is deliberately returned as UNKNOWN. A scratch local-search probe in
`tools/localsearch.cpp` got near a satisfying assignment on the visible miter but
did not produce a checked model, so no miter SAT fallback is currently enabled.

## Techniques Used

- Parse sanitized DIMACS and group clauses by absolute variable set.
- Validate every ternary group as a complete four-clause XOR encoding.
- Validate every binary clause pair as a complete 2-XOR encoding. A same-variable
  four-clause binary group is split into the two contradictory 2-XOR equations
  it represents. Pure complete 3-XOR systems with no binary clauses are also
  supported.
- For each 3-XOR, introduce two fresh proof-only variables and emit a constant
  size VeriPB full-adder encoding using `red` and `pol ... d` cutting planes.
- Prove each local parity bit with four reason clauses and a seven-step
  resolution tree against the original XOR clauses.
- Convert each local XOR to two fixed pseudo-Boolean inequalities, sum all lower
  sides and all upper sides for the conflicting dependency.
- Include selected 2-XOR equations directly from their original two clauses;
  divide the aggregate lower side and add the aggregate upper side to obtain the
  empty PB constraint.
- If the endpoint XOR agrees with the sum of all ternary XORs, solve the
  recovered GF(2) linear system directly and print a complete model after
  checking it against the original CNF.

## Remaining Things To Try

- Add support for the miter instance if its circuit structure can be recovered
  safely. It appears to contain many binary implications plus paired ternary and
  five-literal groups in addition to the 70 visible XOR triples.
- Consider deleting the old tree-combination code from `solver.cpp` once this
  linear PB proof has enough broker history; it is currently unused but harmless.

## Known Limitations

- The solver returns UNKNOWN if the CNF is not exactly the recovered XOR-chain
  shape.
- The miter-shaped training instance is unsupported.
- The old proof-size guard remains in code for the unused legacy path, but the
  active proof path is linear in the number of recovered XOR equations.

## Local Verification

Checked locally with `veripb --cnf` on every visible instance where the solver
prints UNSAT. The current visible split has 15 UNSAT instances and one miter
UNKNOWN. The SAT branch was checked on a synthetic satisfiable variant made by
flipping the endpoint binary XOR on `x1_16`; the emitted complete assignment
satisfied every clause. The internal-cycle proof branch was checked on a
synthetic four-equation closed XOR cycle whose contradiction does not use the
binary endpoint equation, both with and without a separate endpoint binary pair.

- `x1_16` and `x2_16`: 582 proof lines, verifies in about 1 ms.
- `x1_48`: 1,798 proof lines, verifies in about 4 ms.
- `x2_128`: 4,838 proof lines, verifies in under 10 ms.
- Every non-miter visible train instance from `x1_16` through `x2_128` was
  checked with `veripb --cnf formula.cnf out.pbp --stats`.

## Parent Provenance

- Parent SHA: `f2c580ebd9cab9d6ba573695429dae1ed0216ac8271d6027d1163207929490f6`
- Parent name: `xor-chain-parity-cp`
- Parent family: `xor-chain`
- Parent run/eval/job: `23ab3be14d2542e1bd50e9e310d114a3` / `1` / `eval_20260507T162801Z_618b6464`
- Parent score: validation solved 4/13, PAR-2 831.739s

## Changelog

- Initial scaffold replaced with a C++ XOR-chain detector and VeriPB proof
  generator.
- Added bounded expansion for XOR joins sharing multiple variables.
- Added proof-size guard and submission metadata.
- Replaced the exponential parity-combination proof with a linear VeriPB
  full-adder/Gaussian-sum proof. Large `x2_128` instances now produce 4,838-line
  proofs instead of returning UNKNOWN.
- Added `tools/localsearch.cpp` as a scratch miter exploration tool; it is not
  called by the submitted solver.
- Added a SAT model branch for consistent XOR-chain instances using sparse
  Gaussian elimination over GF(2), with independent CNF model verification before
  printing `SATISFIABLE`.
- Generalized UNSAT proof selection to use the actual conflicting GF(2)
  dependency found by elimination, including internal cycle contradictions that
  do not involve the endpoint binary clauses.
- Broadened detection to support pure complete 3-XOR systems with no endpoint
  binary pair; SAT models are still CNF-checked and UNSAT proofs use the same
  internal-cycle VeriPB derivation.
- Generalized binary handling from one endpoint pair to any number of complete
  2-XOR clause pairs. Conflicts can now mix selected 2-XOR and 3-XOR equations
  in one aggregate VeriPB contradiction.
- Added support for complete four-clause binary groups by splitting them into
  the even and odd 2-XOR equations; a synthetic all-four-binary-clauses conflict
  verifies locally.
