# Solver Notes

## Formula Notes

- The visible family is an XORified sparse ordering principle, with names like
  `xor_op_n40_d3`.
- DIMACS variables are adjacent XOR rails. High-level variable `h` uses CNF
  variables `2h-1` and `2h`, and means their XOR is true.
- The high-level variable count is `n*(n-1)`, matching ordered pairs `(i,j)`
  for `i != j`. The original DIMACS variable count is `2*n*(n-1)`.
- Complete blocks of `2^k` low-level clauses encode one high-level clause:
  same-sign rail pairs are positive high-level literals, and opposite-sign rail
  pairs are negative high-level literals.
- Recovered high-level clauses are:
  - `n` sparse source/no-minimal clauses of width 3.
  - `C(n,2)` antisymmetry clauses `~x_ij OR ~x_ji`.
  - `6*C(n,3)` transitivity clauses `~x_ij OR ~x_jk OR x_ik`.
- Visible stats:
  - `n=38`: 2812 vars, 408044 clauses, 51357 high-level clauses.
  - `n=40`: 3120 vars, 477680 clauses, 60100 high-level clauses.
  - `n=42`: 3444 vars, 554820 clauses, 69783 high-level clauses.

## Techniques Used

- The solver detects the encoding from clause structure and inferred
  `n*(n-1)` high-level variables. It does not use comments or filenames.
- It introduces `$y<h>` auxiliary variables with four `red` clauses proving
  `$y<h> <-> XOR(x(2h-1), x(2h))` as an equisatisfiable extension.
- It derives high-level clauses on demand with compact `pbc` subproofs from the
  corresponding low-level XOR expansion block and the auxiliary definitions.
- It refutes the sparse ordering principle by vertex elimination. When removing
  vertex `r`, any predecessor literal `x_ri` in another vertex clause is
  replaced by `r`'s current predecessors using transitivity; if the replacement
  would be `x_ii`, antisymmetry closes that branch.
- Derived high-level resolvents are logged as annotated RUP steps with the two
  parent constraint IDs, so VeriPB does not scan the full low-level database.

## Local Verification

- `n=38`: solver ~1.2s, proof ~795K, VeriPB ~0.3s.
- `n=40`: solver ~1.5s, proof ~802K, VeriPB ~0.4s.
- `n=42`: solver ~1.7s, proof ~892K, VeriPB ~0.4s.
- All visible proofs verified with `veripb --cnf formula.cnf out.pbp`.

## Remaining Things To Try

- Hidden train/eval sizes likely include `n=44`, `n=46`, and `n=48`; current
  proof size should scale comfortably because min-fill elimination used under
  1,000 high-level resolution steps on visible instances.
- If a future generator uses higher sparse degree, improve elimination order
  with a stronger min-fill/min-degree heuristic.
- A compiled C++ version could reduce Python memory use, but current runtime is
  far below the 600 second per-instance limit on visible instances.

## Known Limitations

- Returns `UNKNOWN` unless the full xorified ordering-principle skeleton is
  detected: adjacent rail pairs, complete XOR expansion groups, all
  antisymmetry clauses, all dense transitivity clauses, and one nonempty source
  clause per vertex.
- Only UNSAT proof generation is implemented. This is intentional for the
  detected family.

## Changelog

- Added repeatable profiling and high-level recovery tools under `tools/`.
- Recovered the XOR rail encoding and ordered-pair high-level variable layout.
- Implemented a Python solver that emits VeriPB proofs using auxiliary XOR
  variables, on-demand high-level clause derivations, and structural vertex
  elimination.
- Deleted the placeholder C++ solver so `build.sh` preserves the Python solver.
- Updated metadata and this notebook for first broker submission.
