# Solver Notes

## Formula Notes

- The family is a bit-blasted discrete logarithm problem: recover an exponent
  `x` such that `r = a^x mod n`.
- The solver does not use DIMACS comments or file names. It recovers:
  - exponent width `k` from the first selector block;
  - arithmetic width `w` from the same block;
  - base `a` from the true branch of the first selector;
  - target residue `r` from the trailing unit clauses;
  - final product variables from the last exponent selector;
  - modulus `n` from the final less-than comparator immediately before the
    last selector.
- Each exponent bit selects either the previous state vector or the modular
  multiplication result for the corresponding power of `a`.
- All available train instances are satisfiable. No UNSAT proof path is
  implemented.

## Techniques Used

- Structural detector for the specific selector/comparator layout.
- Baby-step giant-step over the bounded exponent range `0 <= x < 2^k`.
- 128-bit modular multiplication for moduli up to 64 bits.
- High-level reconstruction of every selected state vector and modular product
  vector.
- Unit propagation over the original CNF after seeding high-level variables.
- Final complete assignment validation against every original clause before
  returning exit code 10.

## Remaining Things To Try

- Add a fallback modulus extractor for other comparator layouts if hidden
  instances vary more than the train split.
- Recover and assign quotient variables directly, which could reduce reliance
  on propagation if the Tseitin layout changes.
- Add a non-invertible-base discrete-log fallback. Training moduli have
  `gcd(a, n) = 1`.

## Known Limitations

- Returns `UNKNOWN` if the selector/comparator structure is not recognized.
- Returns `UNKNOWN` when `a` is not invertible modulo `n`, because the current
  BSGS implementation uses `a^(-m)`.
- Does not emit UNSAT proofs.

## Changelog

- Implemented specialized C++ solver that recovers the discrete-log structure,
  solves with baby-step giant-step, propagates through the CNF, and checks the
  final model.
- Completed `meta.json` with solver description and techniques.
- Updated model output so only the final `v` line is terminated with `0`.
- Local validation solved all available `/data/train` instances with exit code
  10 and an internal full-clause model check.
