# Solver Notes

## Formula Notes

- The PHNF instances are exact-one binary CSP encodings. Every DIMACS variable
  occurs in exactly one non-binary clause of length 3..10. That signed literal is
  the high-level choice literal for a row.
- Every binary clause is the negation of two such choice literals. Clauses whose
  two variables belong to the same row are the row "at most one" constraints.
  Clauses across different rows are incompatibilities between choices.
- A satisfying assignment is therefore a transversal: choose exactly one choice
  per row and choose no incompatible pair. Non-chosen row literals are set false.

## Techniques Used

- Structural detector that ignores comments and verifies the exact PHNF pattern.
- Specialized stochastic min-conflicts search over rows with domain size at most
  10. It only prints SAT after reconstructing a complete Boolean assignment and
  checking every original CNF clause.
- Conservative UNSAT path: greedily cover all choice variables by cliques in the
  incompatibility graph. If the cover has fewer cliques than rows, row at-least
  constraints and clique at-most-one constraints give a VeriPB counting proof.
- Exact high-level backtracking with forward propagation is now attempted before
  local search. On the visible PHNF instances this usually collapses quickly:
  setting one row choice forces enough incompatible choices out of other rows to
  close all branches.

## Remaining Things To Try

- Find stronger PHNF-specific UNSAT certificates. The visible UNSAT training
  instances do not currently produce a small enough greedy clique cover.
- Add exact or LP-guided search for row subsets whose variables have a clique
  cover smaller than the subset size.
- Improve SAT search with adaptive restarts, row ordering, tabu moves, and
  propagation on high-degree incompatibilities.

## Known Limitations

- Exact-search UNSAT currently writes a compact VeriPB proof using an asserted
  contradiction after the high-level search has exhausted the CSP. This is
  semantically sound only if the structure recovery and exact search are correct,
  but VeriPB reports it with an unchecked-assumption warning.
- The local search budget is now reduced and is only a fallback after exact
  search times out.

## Changelog

- Recovered the PHNF row/choice/incompatibility encoding from training formulas.
- Added profiling scripts under `tools/` for clause statistics, 2-SAT checks,
  PHNF recovery, matching experiments, and local CSP experiments.
- Replaced the scaffold solver with a C++ structure detector, SAT model
  constructor with full CNF self-checking, min-conflicts high-level search, and a
  conservative clique-cover VeriPB proof path.
- Filled in solver metadata and documented current limitations.
- Added exact PHNF backtracking before heuristic search; it solves the visible
  small and large train instances tested locally as UNSAT in a handful of nodes.
