# Solver Notes

## Formula Notes

- The visible `ramsey-30-4` and `ramsey-32-4` formulas are not classic 2-color
  Ramsey formulas. They encode a 4-color triangle-free coloring of `K_n`.
- For these instances:
  - primary edge variables are `n * (n - 1)`, i.e. two Boolean bits for each
    undirected edge of `K_n` in lexicographic edge order;
  - each unordered vertex triangle contributes 9 auxiliary variables and 40
    clauses;
  - total variables are `n * (n - 1) + 9 * C(n, 3)`;
  - total clauses are `40 * C(n, 3)`, with `16 * C(n, 3)` ternary clauses and
    `24 * C(n, 3)` four-literal clauses.
- The clauses per triangle encode that at least one pair of triangle edges has
  different two-bit color, forbidding monochromatic triangles. The auxiliary
  variables encode edge-pair difference and XOR witnesses.
- The visible `constraints_25_4_5_12_12_0_0_0` formula is a different
  R(4,5;25)-style UNSAT encoding with 300 primary edge variables plus many
  symmetry/extension variables. The base layer has `C(25,4)` negative K4
  blockers and `C(25,5)` positive K5 blockers. The tail consists of 300 row-lex
  symmetry-breaking blocks followed by 25 exact-degree-12 sequential counters.
- The SAT04/SAT05 `ramsey.used-as.sat04-872` /
  `ramsey.shuffled-as.sat05-511` files are classic two-color `R(4,4;18)`
  encodings: 153 edge variables and paired positive/negative 6-clauses for each
  4-clique. The SAT05 file is a shuffled version of the same structure.

## Techniques Used

- Structural detector for the 4-color triangle-free encoding using only the
  sanitized CNF header and clause-size distribution, not comments or filenames.
- Deterministic min-conflicts search over the recovered complete graph to find a
  4-coloring with no monochromatic triangle.
- Direct mapping from high-level edge colors to the two edge-bit variables.
- Incidence-based recovery for shuffled 4-color encodings: identify primary
  edge-bit variables by degree, pair the two bits of each edge via shared
  comparator incidence, recover the triangle hypergraph from auxiliary clauses,
  and solve that recovered high-level graph.
- Unit propagation over the full CNF to fill auxiliary variables.
- Final full CNF model check before printing `SATISFIABLE`.
- From-scratch proof-logging CDCL fallback for unsupported medium formulas. It
  emits learned clauses as VeriPB RUP constraints and only claims UNSAT after
  producing a proof file. For the visible R(4,5;25) instance it also restricts
  decisions to recovered graph-edge variables and adds checked exact-degree-12
  RUP propagation.
- SAT-only stochastic fallback for unsupported no-unit CNFs. It is from scratch,
  bounded, and still requires a complete CNF model check. It never returns UNSAT.

## Remaining Things To Try

- Develop a VeriPB proof strategy for the R(4,5;25) UNSAT instance, likely by
  deriving a compact Ramsey counting or symmetry-aware contradiction rather than
  trying to replay a CDCL proof.
- Develop a compact VeriPB proof for the classic `R(4,4;18)` encoding. The
  mathematical proof via `R(3,4)=9` and vertex degree bounds is clear, but the
  current implementation does not yet translate it into a checker-accepted PB
  derivation.
- Add row-lex native propagation for the R(4,5;25) encoding. The CNF has the
  constraints already, but a direct propagator may prune earlier while still
  logging RUP reasons.

## Known Limitations

- The proof-logging CDCL fallback is sound but not yet strong enough locally to
  solve the visible hard UNSAT instances. A 300 second local run on
  `constraints_25_4_5_12_12_0_0_0` returned UNKNOWN.
- No UNSAT claim is produced unless the CDCL engine reaches a root conflict and
  writes a VeriPB proof. Unsupported or proofless cases return UNKNOWN.
- The stochastic fallback may find models for some satisfiable variants, but it
  is not used to justify UNSAT and is skipped after a CDCL attempt to avoid
  exceeding the broker timeout.

## Changelog

- Initial analysis: identified the visible SAT formulas as 4-color
  triangle-free Ramsey encodings with two edge bits and per-triangle
  equality/difference auxiliaries.
- Implemented C++ structural detector, high-level min-conflicts coloring,
  auxiliary unit propagation, and full model checking.
- Added a checked SAT-only stochastic fallback for unsupported no-unit CNFs.
- Filled `meta.json` with solver description and techniques.
- Added incidence-based recovery and model construction for shuffled 4-color
  triangle-free encodings; verified locally by solving a randomly permuted copy
  of `ramsey-30-4`.
- Reverse-engineered `constraints_25_4_5_12_12_0_0_0` as a 12-regular
  R(4,5;25) graph encoding with row-lex symmetry blocks and exact-degree
  counters.
- Added a from-scratch proof-logging CDCL fallback with VeriPB RUP output,
  restricted graph-edge decisions for the 25-vertex constraints encoding,
  exact-degree-12 propagation, phase saving, and basic learned-clause
  minimization.
- Identified the SAT04/SAT05 timeout instances as classic `R(4,4;18)` encodings
  from the SAT competition archives. Current CDCL attempts remain UNKNOWN, so
  those still need a compact Ramsey proof strategy.
