# Solver Notes

## Formula Notes

The main training family is FRB/model-RB random binary CSP encoded as CNF.
Most files have `N` long clauses of common length `D`; the absolute DIMACS
variables in those clauses partition all CNF variables into `N` high-level
CSP variables with `D` values each. Binary clauses are negative value-pair
clauses: within a group they enforce at-most-one, and across groups they mark
incompatible CSP value pairs.

One `sc2011` variant is the same structure after signed literal scrambling.
The long clauses contain signed value literals, and each binary clause is the
negation of two such value literals. The solver handles this by storing the
signed value literal for each domain value and mapping the final high-level
assignment back through those signs.

The `mgd_c18` file keeps the same signed one-hot value groups but adds merged
two-variable support clauses. Each such clause is decoded semantically: for
each involved group the solver enumerates the domain values that falsify that
side of the clause and forbids the resulting Cartesian product.

The `_ext` and `mgd_ext` files are the same FRB35-17 CSP through a compact
5-bit value encoding. Variables split into contiguous blocks of five. Local
binary clauses leave 17 valid bit patterns per block, and every non-local
clause touches exactly two blocks. The solver enumerates those valid patterns,
decodes each two-block clause into forbidden value masks, and maps the chosen
patterns directly back to DIMACS variables.

## Techniques Used

- Structural detectors for signed one-hot FRB encodings and compact 5-bit
  FRB encodings; no comments, names, or hashes are used.
- General semantic two-variable CSP recovery: clauses are evaluated over the
  recovered per-group domain patterns, so merged support clauses and ordinary
  forbidden-pair clauses share the same bit-mask representation.
- Recovery of the binary CSP into compact bit masks: for each `(variable,
  value, neighbor)` a value mask records forbidden neighbor values.
- SAT search with randomized greedy initialization followed by weighted
  min-conflicts. Local minima trigger breakout weight increments on currently
  violated high-level constraints. Conflict updates are incremental per moved
  variable rather than recomputing all edges after every step.
- Static value tightness is used as a tie-break during greedy construction and
  repair moves; this helps the forced-satisfiable FRB instances without making
  any unverified SAT claim.
- SAT-only Boolean fallback for unsupported or timed-out cases. This is a
  from-scratch WalkSAT-style repair loop over CNF variables with incremental
  clause satisfaction counts. It never reports UNSAT and still requires full
  verification before printing a model.
- Full CNF model reconstruction and independent clause checking before exit
  code 10. If the detector fails or verification fails, the solver exits 0.

## Local Results

The inherited solver solved 12/20 baseline-visible instances with no invalid
models. This run decodes the compact and merged encodings directly: locally,
`frb35-17-5_ext` solves in about 0.04s, `frb35-17-5-mgd_ext` in about 2.1s,
and `frb-40-19-1-mgd_c18` in about 0.1s. Incremental CSP conflict maintenance
also reduced several standard instances substantially, e.g. `frb45-21-1`
from about 49s to about 4s in the stable run. A 60s local pass solved 15/24
training files; with a 140s cap the two `50x23` files and both `45x21` files
solve. The remaining local misses are concentrated around `53x24`, `56x25`,
and `59x26`.

## Remaining Things To Try

- Add a stronger repair/decomposition method for the `53x24` through `59x26`
  hard region. Debug runs show the current local search can reach one-conflict
  assignments on `frb53-24-2`, but fixing only the immediate conflicted
  neighborhood is not enough.
- Tune local-search restart lengths, breakout increments, and variable
  selection against broker per-instance timings.

## Known Limitations

- No UNSAT claims are made, so no VeriPB proof generation is implemented.
- Unsupported encodings return UNKNOWN even when they may be satisfiable.
- The local-search phase is incomplete; hard satisfiable instances may exhaust
  the time budget and return UNKNOWN.

## Changelog

- Replaced the scaffold with a C++ solver for signed one-hot FRB encodings.
- Added weighted min-conflicts with breakout-style constraint weighting.
- Added complete DIMACS model reconstruction and full original-clause
  verification before reporting SAT.
- Updated metadata with the implemented approach and supported techniques.
- Added a verified SAT-only Boolean local-search fallback for extended
  encodings and CSP timeout cases.
- Replaced the strict one-hot-only decoder with semantic binary-CSP recovery
  over enumerated per-group domain patterns.
- Added compact 5-bit FRB decoding for `_ext` and `mgd_ext` instances.
- Added support for merged one-hot support clauses such as `mgd_c18`.
- Made high-level local-search conflict maintenance incremental and added
  static value-tightness tie-breaking.
- Tested wider exact/perturbative low-conflict repairs; they regressed solved
  instances, so the stable submission keeps the smaller bounded exact repair.
