# Solver Notes

## Formula Notes

- The visible training formulas are from the `modcircuits` family. Clause
  structure is consistent with bounded Boolean circuit synthesis: many
  exactly-one selector blocks choose gate inputs or output sources, and the
  remaining large clauses enforce semantic consistency of the selected circuit.
- Variable counts are small compared with clause counts. Visible examples range
  from 267 to 1570 variables and from 23k to 746k clauses.
- Exactly-one blocks are recoverable without comments by finding positive
  clauses whose every pair is forbidden by a negative binary clause. These
  blocks have repeated increasing lengths, matching gate source choices.
- Some instances contain ternary clauses and many unit clauses. The solver uses
  unit clauses as hard fixed literals but does not depend on comments, names, or
  hashes.
- The SAT'09 converter source confirms four main variable families: gate truth
  table bits, gate-input selectors, per-input-assignment gate values, and output
  selectors. Auto-encoding formulas add small residue-code one-hot matrices.
- Two MOD3 witness blocks from the paper are now reconstructed structurally:
  the 9-gate B2 restricted block and the 11-gate U2 auto-encoding block.

## Techniques Used

- Parse sanitized DIMACS directly.
- Detect disjoint one-hot selector blocks structurally.
- Detect gate truth-table bit blocks from repeated four-literal basis clauses.
- For recognized MOD3 block structures, set the recovered high-level circuit
  selectors, gate functions, output selectors, and residue encoding choices;
  then finish the CNF assignment by unit propagation and verify all clauses.
- Initialize stochastic local search so each detected selector block starts in a
  legal one-hot state, which avoids wasting most early flips on cardinality
  repair.
- Use a from-scratch focused local search over all variables with break/make
  scoring, small random noise, and fixed unit literals.
- Fall back to a compact from-scratch CDCL model finder with watched literals,
  first-UIP learning, phase saving, activity branching, and restarts.
- CDCL can now log learned clauses as VeriPB RUP constraints and emit an UNSAT
  proof when it reaches a level-zero contradiction. The OWP training instance
  verifies locally with `veripb --cnf`.
- Verify every SAT assignment against the original CNF before printing
  `s SATISFIABLE`.

## Remaining Things To Try

- Extend direct witness reconstruction to the MOD4 U2 auto-encoding/Stockmeyer
  block and the MOD5 12-gate block.
- Add atomic one-hot block swap moves to the local search in a faster
  incremental form. A prototype was too slow but confirmed that selector flips
  are a major source of local minima.
- Improve proof search for the MOD4 8-gate lower-bound instance. Plain CDCL
  with proof logging did not finish within a 300s local run.
- Improve CDCL clause deletion and branching for the very large b2 instances.

## Known Limitations

- Direct witnesses are intentionally conservative and only fire after structural
  checks; if the completed assignment fails verification the solver returns
  `UNKNOWN`.
- It only emits UNSAT when a VeriPB RUP proof has been generated. Larger
  lower-bound formulas still usually return `UNKNOWN`.
- The CDCL fallback is intentionally small and may time out on instances that a
  production SAT solver can solve.

## Changelog

- Initial scaffold replaced with a C++ solver.
- Added DIMACS parsing and complete model verification.
- Added structural one-hot block detection from clauses only.
- Added one-hot-aware stochastic local-search initialization and repair.
- Added from-scratch watched-literal CDCL fallback for SAT models.
- Added metadata and this working notebook for broker submissions.
- Submitted `eval_20260507T045230Z_bbe8d681`: 2 SAT, 14 UNKNOWN, no invalid
  answers. This is sound but below the baseline solved count.
- Added unit-propagation simplification for the CDCL phase, while keeping local
  search on the original CNF because the unreduced clauses guide repair better.
- Added a bounded large-neighborhood repair attempt around the best local-search
  assignment before full CDCL.
- Added `tools/profile_cnf.py` for comment-independent clause and one-hot
  profiling.
- Reverse-engineered the SAT'09 modcircuits encoding using the public converter
  source and benchmark notes; solver behavior remains based on CNF structure.
- Added direct structural SAT witnesses for the MOD3 3-variable 9-gate
  restricted block and the MOD3 2-variable 11-gate U2 auto-encoding block.
- Added CDCL VeriPB RUP proof logging and verified the OWP 4-variable 5-gate
  UNSAT proof locally.
- Submitted `eval_20260510T010951Z_9b146e53`: 2 SAT, 14 UNKNOWN on the
  broker's 16 visible SAT'09 instances. The direct MOD3 restricted witness
  fired; local-only OWP/MOD3-11 improvements were not in that visible set.
- Restored a simplified-formula non-proof CDCL SAT pass before the final
  proof-producing CDCL pass to recover SAT witnesses that do not need proofs.
