# Solver Notes

## Formula Notes

The training formulas are PEQNP Tseitin encodings for a Fermat factorization
problem. The first two long negative clauses expose two equal-sized input
blocks:

- variables `1..k` encode `a` in little-endian binary
- variables `k+1..2k` encode `b` in little-endian binary

The circuit constructs the odd factors `a-b` and `a+b`, multiplies them, and
compares the product against a constant `N`. Comments sometimes name these
blocks, but the solver ignores comments. The constant is recovered from the
final bit-comparison gadget: the last source block is an arithmetic progression
of variables ending at the source variable in the last complemented equality;
for bits after bit 0, a direct equality pair in the comparator marks a zero bit,
while the absence of that direct pair marks a one bit. Bit 0 is odd and fixed to
one by this family.

Observed training sizes:

- `k=41`: about 5.8k variables and 31.9k clauses
- `k=46`: about 7.2k variables and 40.0k clauses
- `k=51`: about 8.7k variables and 48.9k clauses
- `k=61`: about 12.3k variables and 69.5k clauses

All visible training instances are SAT.

## Techniques Used

- Structural CNF detection from long input-block clauses and final comparator
  clauses.
- Direct 64-bit integer recovery of the hidden constant `N`.
- In-house deterministic Miller-Rabin and Pollard Rho factorization for
  recovered odd 64-bit constants.
- Fermat parameter reconstruction: from any nontrivial factor pair `u*v=N`,
  set `a=(u+v)/2` and `b=(v-u)/2`.
- Full-scan unit propagation to fill all Tseitin variables, followed by an
  independent complete CNF validation before printing `SATISFIABLE`.

## Remaining Things To Try

- Add a multiprecision Pollard Rho path if future instances use constants wider
  than 63 bits.
- Recover and support nearby PEQNP variants with a different final comparator
  layout.
- Design a VeriPB proof path for prime `N` if UNSAT instances appear. The
  current solver returns `UNKNOWN` instead of claiming UNSAT.

## Known Limitations

- Constants wider than 63 bits are currently unsupported and return `UNKNOWN`.
- The solver is intentionally specialized to this PEQNP Fermat layout.
- No UNSAT claims are emitted.

## Changelog

- Replaced the scaffold with a Fermat-specialized C++ solver.
- Added comment-independent detection of input blocks and final comparator
  constants.
- Added 64-bit Miller-Rabin, Pollard Rho, Fermat parameter mapping, unit
  propagation, and complete CNF model validation.
- Updated metadata and documentation for broker submission.
