# Solver Notes

## Formula Notes

The clean non-`sc2018` instances match the Samer-Veith treewidth encoding. Variables start at 2. The first `C(n,2)` variables encode a total vertex order, followed by an `n x n` directed arc matrix. Positive binary clauses over opposite directed arcs recover the original graph edges. Unit clauses over order variables are treated as hard precedence constraints. The remaining variables are cardinality auxiliaries for bounding the number of later fill-neighbors.

The `*-sc2018` variants appear to be clause-shuffled and variable/polarity-permuted versions of the same encoding. The structural detector for those is not enabled yet, so they conservatively return `UNKNOWN`.

## Techniques Used

- Detect the clean SV layout from the first transitivity clause and header-derived order/arc ranges.
- Recover graph edges from positive binary clauses `arc(u,v) arc(v,u)`.
- Recover precedence constraints from unit order clauses.
- Generate elimination orders with deterministic and randomized min-fill/min-degree variants, including bounded randomized passes after a candidate fails model completion.
- Construct the directed fill graph from the recovered order, assign order and arc variables, unit-propagate the auxiliary variables, then verify every clause before returning SAT.

## Current Local Results

Verified SAT locally on visible clean instances: `ex039_33`, `ex045_7`, `ex067_10`, `ex175_18`, `ex175_20`, `ex009_10`, and `ex065_25`. The solver returns `UNKNOWN` on unsupported shuffled formulas and on clean formulas where the ordering search does not find a CNF-completable order.

## Remaining Things To Try

- Implement the `sc2018` mapping: identify order variables by length-3 incidence, reconstruct the line graph `L(K_n)`, recover polarity by parity constraints, then map arc variables through binary order/arc clauses.
- Add stronger treewidth search for hard clean instances such as `ex015_14`, `ex025_19`, and `ex175_17`.
- Decode the cardinality network bound directly so bounded search can target the exact threshold instead of relying on failed model completion.

## Known Limitations

- No UNSAT proof generation is implemented; unsupported or unsolved cases return `UNKNOWN`.
- The clean-layout detector intentionally rejects scrambled encodings.
- Randomized search is deterministic from fixed seeds, but may still miss satisfiable instances whose width is below the first heuristic order by several points.

## Changelog

- Replaced the placeholder solver with a C++ Samer-Veith treewidth solver.
- Added CNF profiling and recovery scripts under `tools/`.
- Added graph/precedence recovery, randomized elimination-order search, directed fill assignment, unit propagation, and full model verification.
- Added solver metadata and this working notebook.
- Broker `eval_20260510T204438Z_a99ea41b`: 7 SAT, 13 UNKNOWN, no invalid results. Strengthened failed-candidate randomized search with broader choice distributions and a larger time budget.
- Broker `eval_20260510T205746Z_bf35b52d`: still 7 SAT, 13 UNKNOWN. Fixed the dormant bounded DFS backtracking state and enabled it for small failed targets; local `ex051_9` still remains UNKNOWN.
