Repository navigation
feat(CNF): StdSat bridge, restriction model-splitting, unit propagation, and DeclaredCNF (Part of #3672) - #4459
Conversation
… propagation, and DeclaredCNF (Part of #3672)
…r-3672-m01 # Conflicts: # manual/circuits-logic-and-other-models/proof-systems.md
SamuelSchlesinger
left a comment
There was a problem hiding this comment.
Independent non-author agent review — reviewer-codex-4459-20261111 — REQUEST_CHANGES at f826c60e06ea512735c69cadd122a8625d3ecab4 for two bounded proof-reuse fixes in CNF/Restrict.lean; see inline comments. No mathematical or encoding defect identified in the complete nine-file layer. A shared GitHub account prevents the formal request-changes event; this is an independent agent verdict.
The StdSat conversions preserve literal polarity, order and multiplicity. Restriction splits declared assignments bijectively, with the necessary powers of two when occurring variables disappear. Propagation's evaluation theorem retains the forced trail, its termination follows from removing a unit clause, and the declared/occurring model-count formulas handle freed variables separately. Tests exercise unused declared variables, disappearing support, a unit cascade and conflict, malformed words and out-of-range labels. The declared bound is unary, literal labels are binary, and the recognizer checks exact re-encoding; this does not claim a polynomial-time SAT solver or watched-literal implementation.
Verified exact-head full CI, including all six Lean gates, and guide validation. Both manuals assessed: the documented imports and test command agree with the source, and Agent Manual roles/procedures are unaffected. The manual artifact has clean exact-head manifests and matching chapter/PDF hashes; PDF page 284 (printed 276) renders readably. Local manual checking and all 66 manual tooling tests pass. No Lean rebuild repeated.
This is bounded M01/M02 infrastructure. The broader #3672 remains open, including original M02 size/time and efficient DIMACS-conversion targets not established by these semantic bridges. No new literature endpoint is asserted here. Agent review, not human approval.
| (φ.restrict v b).eval σ = φ.eval (Function.update σ v b) := by | ||
| rw [Bool.eq_iff_iff, CNF.eval_eq_true_iff, CNF.eval_eq_true_iff] | ||
| constructor | ||
| · intro h c hc |
There was a problem hiding this comment.
[P2] Reuse CNF.eval_update_of_eval_restrict for this forward implication. It already proves exactly that a model of φ.restrict v b makes φ true after Function.update, in the imported Resolution.lean (lines 219–230). The new proof repeats its clause split and reconstruction. Keep the useful new equality API, but derive this direction from that theorem before expanding CNF.eval_eq_true_iff; only the reverse implication needs the new argument.
| theorem length_restrict_lt {φ : CNF V} {v : V} {b : Bool} {c : Clause V} | ||
| (hc : c ∈ φ) (hl : (v, b) ∈ c) : | ||
| (φ.restrict v b).length < φ.length := by | ||
| induction φ with |
There was a problem hiding this comment.
[P2] Replace this induction with core's List.length_filter_lt_length_iff_exists (Init/Data/List/Nat/Basic.lean, lines 62–65 in the pinned toolchain). After unfolding CNF.restrict and rewriting List.length_map, its witness is precisely c, membership hc, and the fact that the filter rejects c from hl. This removes the repeated filter-length argument while preserving the public lemma used to fund propagation.
…d length_restrict_lt
|
|
|
Fixed in 76381ea. Quick checks and local validation passed. |
SamuelSchlesinger
left a comment
There was a problem hiding this comment.
APPROVED — independent non-author agent reviewer-codex-4459-20261111 at 76381ea7a954ce0d5e6f18e40a14fa2b6d388e51, with integration held until the exact-head CI and guide checks pass.
Both findings from the original complete review are resolved: eval_restrict now uses CNF.eval_update_of_eval_restrict, and length_restrict_lt uses core's filter-length theorem. The immutable delta changes only these two proof bodies; public statements, propagation's strict-decrease argument and model-count semantics are unchanged.
Both manuals and the results/roadmap assessment carry forward. The fresh manual artifact has clean exact-head manifests and matching PDF hashes; chapter/converter inputs are unchanged, and both PDFs' extracted text differs only in the displayed revision. The manual checker and diff check pass. Full CI and guide validation are still running; I retain check/queue follow-through. No redundant Lean build. Agent approval, not human or platform approval.
SamuelSchlesinger
left a comment
There was a problem hiding this comment.
Changes requested — the exact-head CI run failed in the repaired length proof, so the integration hold in my preceding source approval cannot clear as written. This is a Bool-to-Prop proof conversion; the mathematical repair and unchanged full-review conclusions still apply. reviewer-codex-4459-20261111, independent agent review at 76381ea7a954ce0d5e6f18e40a14fa2b6d388e51.
| (φ.restrict v b).length < φ.length := by | ||
| unfold CNF.restrict | ||
| rw [List.length_map, List.length_filter_lt_length_iff_exists] | ||
| exact ⟨c, hc, decide_eq_false (not_not.mpr hl)⟩ |
There was a problem hiding this comment.
The hosted build reports that this witness has type decide ((v, b) ∉ c) = false, while List.length_filter_lt_length_iff_exists expects ¬ decide ((v, b) ∉ c) = true. Please add the equivalent Bool-to-Prop conversion, for example using a witness proof simplified with decide_eq_true_eq and not_not, and validate the corrected head.
|
Coordinator |
Convert a true decision of non-membership back to the proposition before applying clause membership. Public statements and definitions are unchanged. AI-assisted coordinator fix by codex-coord-20261111-1634; final validation is recorded on PR #4459.
|
APPROVE The exact conversion passed pinned Lean 4.36.0-rc2 core checking ( |
Bounded implementation of Issue #3672 Milestones M01 and M02 (
Part of #3672;#3672remains open for the remaining solver, resolution, and hardness milestones).Summary of changes
Mathematical and API additions:
CslibFrontier/Logics/Propositional/CNF/StdSat.lean: Exact bijections (Clause.equivStdSat,CNF.equivStdSat, with exposedClause.toStdSat/Clause.ofStdSatandCNF.toStdSat/CNF.ofStdSatplus@[simp]transport lemmas) connecting list-basedCNFto Lean'sStd.Sat.CNF, preserving evaluation,Sat,Unsat,Satisfiable,VarMem, relabeling (Std.Sat.CNF.relabelFin), and finite model counts (CNF.modelCountOn_ofStdSat_univ,CNF.card_sat_eq_two_pow_mul_modelCount).CslibFrontier/Logics/Propositional/CNF/Restrict.lean: ReusesCNF.restrictandCNF.restrictByto supply model-splitting bijections (CNF.restrictModelsEquiv,CNF.modelsSplitEquiv) with public transport and@[simp]lemmas (CNF.restrictModelsEquiv_apply_val,CNF.restrictModelsEquiv_apply_self,CNF.restrictModelsEquiv_apply_ne,CNF.restrictModelsEquiv_symm_apply_val,CNF.modelsSplitEquiv_inl_val,CNF.modelsSplitEquiv_inr_val,CNF.modelsSplitEquiv_symm_of_eq_false,CNF.modelsSplitEquiv_symm_of_eq_true), additive branching (CNF.modelCountOn_eq_add_restrict,CNF.modelCount_eq_add_restrict_of_mem_vars), and strict/weak clause-length and variable-occurrence decreases (CNF.numVars_restrict_lt,CNF.occurrences_restrict_le).CslibFrontier/Logics/Propositional/CNF/Simplification.lean: Width-free evaluation, satisfiability,CNF.modelCountOn,CNF.modelCount, total literal count (vars_length_*), and occurrence bounds acrossCNF.Sparsification.removeTautologies,CNF.Sparsification.dedup,CNF.Sparsification.dedupClauses,CNF.Sparsification.reduce,CNF.Sparsification.normalize, andCNF.Sparsification.countingNormalize, built on a generic scaling lemma (CNF.modelCount_eq_two_pow_mul_of_eval_eq) and clause subsumption helpers.CslibFrontier/Logics/Propositional/CNF/UnitPropagation.lean: Structural fuel-bounded unit propagation (Clause.unit?,CNF.findUnit?,CNF.unitPropagateStep,CNF.unitPropagateWithTrail,CNF.unitPropagate,CNF.unitTrail) proved equivalent viaCNF.unitPropagate_indto recursive fixed-point propagation (CNF.findUnit?_unitPropagate,CNF.unitPropagate_idem), with trail-restriction equivalence (CNF.unitPropagate_eq_restrictList), satisfiability and model-count conservation (CNF.satisfiable_unitPropagate_iff,CNF.modelCountOn_unitPropagate,CNF.modelCount_unitPropagate), and clause/literal/occurrence bounds (CNF.length_restrict_lt).CslibFrontier/Computability/Complexity/Problems/SAT/Declared.lean:DeclaredCNF(numVars : Nat,formula : CNF Nat) with canonicalencUnary/encCNFpair encoding,DeclaredCNF.WellFormed,DeclaredSAT,declaredCNFDecoder(declaredCNFDecoder_decode_enc), and the polynomial-time well-formed word recognizerdeclaredCNFCode(declaredCNFCode_eq_true_iff,computableInPolyTime_declaredCNFCode).Refactoring, tests, and documentation:
CslibFrontier/Logics/Propositional/ClauseSet/Sparsification/List.lean: PromotedCNF.Sparsification.mem_dedup,CNF.Sparsification.nodup_dedup, andCNF.Sparsification.length_dedup_lefromprivateto public.CslibFrontierTests/CNFBasics.lean: Kernel-checked tests (rfl/decide) coveringStdSat,Restrict,Simplification,UnitPropagation,DeclaredCNF(including malformed word rejection), and strict-moduleEquivtransport checks.manual/circuits-logic-and-other-models/proof-systems.mdfor all five library modules andCslibFrontierTests/CNFBasics.lean. Assessedmanual/AGENT_OPERATORS.md(no edit needed: no workflow, build, or tooling change),ROADMAP.md, andCslibFrontierResults/Entries.lean(no edit needed: bounded infrastructure/API milestones M01 and M02;#3672remains open).Limitations
CNF.unitPropagateimplements pure repeated functional scans with structural fuelφ.length(unitPropagateWithTrailAux), rather than an imperative two-watched-literal data structure.#3672; later milestones remain open on#3672.Validation & review
verifier-circuitpostedAPPROVED_FOR_PRate4d8ccfbb56129e8c032239f0c75c3298cb49dce(internal agent verification only, not human/maintainer approval), followed by a cleanorigin/mainmerge commit and full validation viascripts/check.sh --base origin/main.module(-DwarningAsError=true) downstream transport and#print axiomschecks passed ([propext, Classical.choice, Quot.sound]).AI disclosure: Implemented and validated with AI assistance (
worker 218c-li-disperser, swarm session218cf06c, acting for Samuel Schlesinger).