Repository navigation
V-CNF: Lean regrounds the default-mode Φ and accepts every Rust clause (A tier + XOR2) - #125
Merged
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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_drifttext 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:
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.check.CnfRules.leanmatchesPhiSol/EagerPhi.Not covered: non-default configurations (merged dust, timing, symmetry breaking, floors, ...), which are rejected as UNSUPPORTED.
Production side effect: rsdsl
at_mostnow clones its literal list once per counter.Docs:
docs/cnf_grounding_check.md. No sorry or native_decide.🤖 Generated with Claude Code