Skip to content

V-CNF: Lean regrounds the default-mode Φ and accepts every Rust clause (A tier + XOR2) - #125

Merged
rollrat merged 2 commits into
masterfrom
claude/fastopt-cnf-grounding
Dec 6, 2026
Merged

rollrat merged 2 commits into
masterfrom
claude/fastopt-cnf-grounding

Conversation

@rollrat

@rollrat rollrat commented Dec 6, 2026

Copy link
Copy Markdown
Member

Adds a checkable link from the Rust-grounded Φ CNF to a Lean transcription of the rules. Until now this rested on hand review plus the lean_rule_drift text hashes.

  • How it works: Lean regrounds the rsdsl rules at the meaning level and looks up variables through a dumped meaning table, so Rust's variable numbering is not trusted. Each Rust clause must be one of:

    • a regrounded clause,
    • a Tseitin junction definition,
    • a validated cardinality clause.

    The final CNF is checked by a unit-propagation replay. No SAT solving.

  • Measured: on 7 default-mode instances (A tier and xor2 2x6x4) every clause is accepted. There are no uncovered rule labels and no Lean clause is missing from Rust. Sign-flip mutants are rejected 8/8. Check time ranges from 15 ms to 1.7 s.

  • Proved (CnfSound.lean): require_sound, normClause_sound, cardValid_sound, checkTrace_sound.

    • Argued: the composition of these through the imperative check.
    • Assumed: that CnfRules.lean matches PhiSol/EagerPhi.
  • Not covered: non-default configurations (merged dust, timing, symmetry breaking, floors, ...), which are rejected as UNSUPPORTED.

  • Production side effect: rsdsl at_most now clones its literal list once per counter.

Docs: docs/cnf_grounding_check.md. No sorry or native_decide.

🤖 Generated with Claude Code

rollrat and others added 2 commits December 6, 2026 19:14
Many optimality certificates rest on OptCert.BudgetFaithful: every Φ layout
within the budget gives a model of the CNF that exact/dsl.rs grounds from
exact_placer.rsdsl. Until now only tests/lean_rule_drift.rs guarded that link,
and it only notices text changes. This commit turns the link into a checkable
artifact, without any SAT solving.

Approach: meaning-level regrounding, a hybrid of options (a) and (b).
- Lean transcribes the default-mode rules (CnfRules.lean) as formulas over atoms
  (Kind/Sig/Rank/Stage/Contrib/Same).
- Lean mirrors the rsdsl encoder: junction normalisation, lit_of, require with
  distribution and shared-OR naming, clause_with, at_most (CnfGround.lean).
- Lean resolves atoms and Tseitin junctions to CNF literals through a dumped
  meaning table. Each lookup is verified against that table, so Rust variable
  numbers and clause order are never trusted.
- Every pre-propagation Rust clause must be one of:
  - a regrounded clause;
  - a junction definition clause;
  - a cardinality clause accepted by a meaning validator.
- The final CNF is checked through a unit-propagation trace.

Results, all measured:
- All 7 instances are fully accepted: not, nor2, nor2_big, or2, and2, nand2,
  xor2 2x6x4.
- 0 uncovered Rust labels and 0 Lean-only clauses.
- 8 of 8 sign-flip mutants are rejected.
- Check takes 15 ms to 1.7 s.

Proved in CnfSound.lean (Audit guards added):
- eval_junction, eval_neg, litVal_litOf and require_sound: the encoder mirror
  preserves Boolean meaning.
- cardValid_sound: the cardinality validator is sound.
- checkTrace_sound and expectedFinal_sound: the final-CNF trace checker is
  sound.

Not yet done:
- The glue through the imperative check is argued only.
- The link CnfRules <-> PhiSol is still an assumption.
docs/cnf_grounding_check.md sections 4 and 6 describe both.

Rust hooks are read-only:
- rsdsl junction_definitions, counters, keep_unpropagated and labels;
- one #[cfg(test)] function in dsl.rs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts:
#	formal/RedstoneFormal.lean
#	formal/RedstoneFormal/Audit.lean
#	formal/lakefile.toml
#	src/transform/place_and_route/local_placer/exact/mod.rs
@rollrat
rollrat merged commit 2509893 into master Dec 6, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant