diff --git a/Complexity.lean b/Complexity.lean index c902719e64..2d673ab415 100644 --- a/Complexity.lean +++ b/Complexity.lean @@ -805,8 +805,6 @@ public import Complexity.Computability.Complexity.FineGrained.CountingTreeBound public import Complexity.Computability.Complexity.FineGrained.ExhaustiveSearch public import Complexity.Computability.Complexity.FineGrained.Exponents public import Complexity.Computability.Complexity.FineGrained.GeneralCNFBranchSchedule -public import Complexity.Computability.Complexity.FineGrained.GeneralCNFCountingAsymptotics -public import Complexity.Computability.Complexity.FineGrained.GeneralCNFHermiteRecovery public import Complexity.Computability.Complexity.FineGrained.GraphProblems public import Complexity.Computability.Complexity.FineGrained.LocalMapCounting public import Complexity.Computability.Complexity.FineGrained.OrthogonalVectors @@ -818,7 +816,6 @@ public import Complexity.Computability.Complexity.FineGrained.ReplacementSchedul public import Complexity.Computability.Complexity.FineGrained.Schoening public import Complexity.Computability.Complexity.FineGrained.SparseBranchAsymptotics public import Complexity.Computability.Complexity.FineGrained.SparseBranchSchedule -public import Complexity.Computability.Complexity.FineGrained.SparseCNFDesignSchedule public import Complexity.Computability.Complexity.FineGrained.SparseCountingScale public import Complexity.Computability.Complexity.FineGrained.SparseParitySchedule public import Complexity.Computability.Complexity.FineGrained.Sparsification @@ -1446,7 +1443,6 @@ public import Complexity.Computability.PolyTime.BooleanAnalysis.BoundedIncidence public import Complexity.Computability.PolyTime.BooleanAnalysis.BoundedIncidenceStepCert public import Complexity.Computability.PolyTime.BooleanAnalysis.SparsePolyCounter public import Complexity.Computability.PolyTime.CNF.BranchedSparseCNFCounter -public import Complexity.Computability.PolyTime.CNF.ClauseJetEval public import Complexity.Computability.PolyTime.CNF.GreedyParityContext public import Complexity.Computability.PolyTime.CNF.GreedyParitySearch public import Complexity.Computability.PolyTime.CNF.SparseCNFLeafCounter @@ -1902,7 +1898,6 @@ public import Complexity.Foundations.BooleanAnalysis.SignApproximation public import Complexity.Foundations.BooleanAnalysis.SparseBranching public import Complexity.Foundations.BooleanAnalysis.SparseClearedSpecialization public import Complexity.Foundations.BooleanAnalysis.SparseEquations -public import Complexity.Foundations.BooleanAnalysis.SparseHermiteJetRecovery public import Complexity.Foundations.BooleanAnalysis.SparseHermiteRecovery public import Complexity.Foundations.BooleanAnalysis.SparseReplacementDesign public import Complexity.Foundations.BooleanAnalysis.Symmetrization @@ -2330,7 +2325,6 @@ public import Complexity.Logics.Propositional.CNF.Planar.PairedCrossover public import Complexity.Logics.Propositional.CNF.Planar.PairedWire public import Complexity.Logics.Propositional.CNF.PolyTime public import Complexity.Logics.Propositional.CNF.PolynomialTests -public import Complexity.Logics.Propositional.CNF.SatisfactionPolynomial public import Complexity.Logics.Propositional.CNF.SparseDesignCounter public import Complexity.Logics.Propositional.CNF.SparseParityCounter public import Complexity.Logics.Propositional.CNF.ThreeCNF diff --git a/Complexity/Computability/Complexity/FineGrained/GeneralCNFCountingAsymptotics.lean b/Complexity/Computability/Complexity/FineGrained/GeneralCNFCountingAsymptotics.lean deleted file mode 100644 index 7fa9620a61..0000000000 --- a/Complexity/Computability/Complexity/FineGrained/GeneralCNFCountingAsymptotics.lean +++ /dev/null @@ -1,1096 +0,0 @@ -/- -Copyright (c) 2026 Samuel Schlesinger. All rights reserved. -Released under Apache 2.0 license as described in the file LICENSE. -Authors: Samuel Schlesinger --/ - -module --- upstream: candidate - -public import Complexity.Init -public import Complexity.Computability.Complexity.FineGrained.GeneralCNFBranchSchedule -public import Complexity.Computability.Complexity.FineGrained.SparseCountingScale -public import Complexity.Logics.Propositional.ClauseSet.Sparsification.CountingTreeBounds - -/-! -# Section 6.4 Proposition 6.4 tree-wide model-count recovery and total examination bounds - -This module combines the Section 6.4 disjoint sparsification leaf-to-root `ReplacementDesign` -recovery and per-leaf examination bounds -(`Complexity.Computability.Complexity.FineGrained.GeneralCNFBranchSchedule`), the branch-word -representation bridge and `2 ^ (n / B + 1)` leaf-count bounds for normalized clause sets -(`Complexity.Logics.Propositional.ClauseSet.Sparsification.CountingTreeBounds`), and the -asymptotic `interpolationScale` tree-exponent and candidate-query overhead bounds -(`Complexity.Computability.Complexity.FineGrained.SparseCountingScale`) of -[OpenAI, *The Exponential Time Hypothesis is False*][OpenAI2026ETH] (printed pp. 38–47): - -1. **Normalized Proposition 6.4 leaf decomposition (`CNF.prop64NormalizedLeaves`)**: - Normalizing an arbitrary `k`-CNF `φ : CNF V` via `reduce (nontautological φ.toClauseSet)` before - applying `countingLeaves` at geometric threshold schedule - `θ j = (CNF.prop64ThresholdBase k (Fintype.card V)) ^ j` preserves `CNF.modelCountOn declared` - (`CNF.sum_modelCountOn_prop64NormalizedLeaves`) and the exact `0`/`1` assignment partition - (`CNF.countP_eval_toCNF_prop64NormalizedLeaves`) unconditionally (even when `φ` contains - tautological or duplicate clauses), while ensuring every leaf `L ∈ φ.prop64NormalizedLeaves k` is - sparse, reduced, nontautological, of clause width `≤ k`, and of clause length at most - `CNF.prop64LeafClauseRatio k (Fintype.card V) * Fintype.card V` - (`CNF.length_le_of_mem_prop64NormalizedLeaves`). -2. **Proposition 6.4 tree leaf-count bounds against `numGroups` and `interpolationScale`**: - - `CNF.length_prop64NormalizedLeaves_le_two_pow`: whenever `1 ≤ numGroups (Fintype.card V)` and - `∀ c ∈ φ, c.length ≤ k`, - `(φ.prop64NormalizedLeaves k).length ≤ 2 ^ (Fintype.card V / numGroups (Fintype.card V) + 1)`. - - `CNF.length_prop64NormalizedLeaves_le_interpolationScale_of_clog_ge` and - `CNF.length_prop64NormalizedLeaves_le_interpolationScale`: whenever - `640000 ≤ Nat.clog 2 (Fintype.card V)` (in particular for `2 ^ 640000 ≤ Fintype.card V`), - `1 ≤ interpolationScale (Fintype.card V)` and - `((φ.prop64NormalizedLeaves k).length : ℝ) ≤` - `(2 : ℝ) ^ (17 * interpolationScale (Fintype.card V))`. -3. **Lemma 6.2 candidate-query indexing, overhead, and full Proposition 6.4 tree-wide - `interpolationScale` examination bounds**: - - `CNF.LeafCandidateQueryIndex V B ψ` and `CNF.candidateQueryRows A q`: index all parity-row - systems evaluated during the `3 * n` greedy rounds of Lemma 6.2 (`Sum.inl (i, γ')` for - `i : Fin (3 * Fintype.card V)` and ordered candidate list - `γ' : Fin (BitString.greedyRowListLength B ψ.length) → Fin ψ.length × Bool`, including - discarded candidates counted with list multiplicity, plus `Sum.inr ()` for the final query - `A (3 * Fintype.card V)`), with exact cardinality - `3 * Fintype.card V * (2 * ψ.length) ^ P + 1 ≤ CNF.leafCandidateQueryBound B ψ` - (`CNF.card_leafCandidateQueryIndex_eq`, `CNF.card_leafCandidateQueryIndex_le`). - - `CNF.candidateQueryRows_length_and_weight_le`: every candidate or final query - `q : CNF.LeafCandidateQueryIndex V B ψ` has at most `6 * Fintype.card V` parity rows, each of - Hamming weight at most `BitString.initialRowWeightBound B ψ.length`. - - `CNF.greedyRowListLength_le_mul_pow_clog` and - `CNF.exists_prop64_leafCandidateQueryBound_le_interpolationScale`: prove - `BitString.greedyRowListLength B m ≤ 20000 * B ^ 2 * (Nat.clog 2 (2 * m + 4)) ^ 2` - for all `B, m` and apply `SparseCountingScale.eventually_query_overhead_poly_le` to bound - `(CNF.leafCandidateQueryBound B ψ : ℝ) ≤ (2 : ℝ) ^ interpolationScale (Fintype.card V)` for - every Proposition 6.4 leaf formula `ψ = L.toCNF`. - - `CNF.exists_prop64NormalizedLeaves_greedy_total_recovery_and_examBound` and - `CNF.exists_prop64NormalizedLeaves_total_recovery_and_examBound`: for any `k ≥ 2`, there - exists `N₃ ≥ 2 ^ 640000` such that for any finite variable type `V` with - `N₃ ≤ Fintype.card V` and any width-`≤ k` CNF `φ : CNF V`: - - `φ.modelCountOn Finset.univ` equals the sum of `L.toCNF.modelCountOn Finset.univ` across - `L ∈ φ.prop64NormalizedLeaves k`, - - `(φ.prop64NormalizedLeaves k).length ≤ 2 ^ (Fintype.card V / numGroups (Fintype.card V) + 1)` - and `((φ.prop64NormalizedLeaves k).length : ℝ) ≤` - `(2 : ℝ) ^ (17 * interpolationScale (Fintype.card V))`, - - on every leaf `L ∈ φ.prop64NormalizedLeaves k` (`ψ := L.toCNF`), **every** evaluated query - `q : CNF.LeafCandidateQueryIndex V B ψ` (including every discarded candidate - `A i.1 ++ [testRow γ']` for `i < 3 * Fintype.card V` and `γ'` as well as the final query - `A (3 * Fintype.card V)` at `q = Sum.inr ()`, which recovers `ψ.modelCountOn Finset.univ`) - admits concrete per-branch `ReplacementDesign`s `D b` recovering - `commonZeroCount univ (ψ.parityRowSystem (CNF.candidateQueryRows A q))` with branch-summed - examination count - `≤ (2 : ℝ) ^ ((CNF.prop64BranchExamScaleCoeff k + 32) * interpolationScale n)`, - and summing across all `q : CNF.LeafCandidateQueryIndex V B ψ` bounds the leaf's total - candidate-query examination count by - `(2 : ℝ) ^ (CNF.prop64LeafQueryExamScaleCoeff k * interpolationScale n)`, and - - summing across all leaves in `φ.prop64NormalizedLeaves k` bounds the tree-wide examination - count by `(2 : ℝ) ^ (CNF.prop64TreeExamScaleCoeff k * interpolationScale (Fintype.card V))` - and the total candidate-indexed examination count across the entire sparsification tree by - `(2 : ℝ) ^ (CNF.prop64TotalExamScaleCoeff k * interpolationScale (Fintype.card V))`. - -## Main definitions - -* `Cslib.Logic.PL.CNF.prop64NormalizedLeaves` -* `Cslib.Logic.PL.CNF.leafCandidateQueryBound` -* `Cslib.Logic.PL.CNF.LeafCandidateQueryIndex` -* `Cslib.Logic.PL.CNF.candidateQueryRows` -* `Cslib.Logic.PL.CNF.prop64LeafQueryExamScaleCoeff` -* `Cslib.Logic.PL.CNF.prop64TreeExamScaleCoeff` -* `Cslib.Logic.PL.CNF.prop64TotalExamScaleCoeff` - -## Main results - -* `CNF.card_leafCandidateQueryIndex_eq` -* `CNF.card_leafCandidateQueryIndex_le` -* `CNF.sum_modelCountOn_prop64NormalizedLeaves` -* `CNF.countP_eval_toCNF_prop64NormalizedLeaves` -* `CNF.length_le_of_mem_prop64NormalizedLeaves` -* `CNF.length_prop64NormalizedLeaves_le_two_pow` -* `one_le_interpolationScale_of_clog_ge` -* `CNF.length_prop64NormalizedLeaves_le_interpolationScale_of_clog_ge` -* `CNF.length_prop64NormalizedLeaves_le_interpolationScale` -* `CNF.greedyRowListLength_le_mul_pow_clog` -* `CNF.length_candidateQueryRows_le_of_step` -* `CNF.weight_mem_candidateQueryRows_le_of_step` -* `CNF.candidateQueryRows_length_and_weight_le` -* `CNF.sum_leafCandidateQueryIndex_le` -* `CNF.exists_leafCandidateQueryBound_le_interpolationScale` -* `CNF.exists_prop64_leafCandidateQueryBound_le_interpolationScale` -* `CNF.exists_prop64NormalizedLeaves_greedy_total_recovery_and_examBound` -* `CNF.exists_prop64NormalizedLeaves_total_recovery_and_examBound` - -## References - -* [OpenAI, *The Exponential Time Hypothesis is False*][OpenAI2026ETH] - (Sections 6.1–6.4, pp. 39–44; Appendix A, pp. 44–47) --/ - -public noncomputable section - -namespace Cslib.Logic.PL - -open Filter Finset -open Cslib.BitString -open Cslib.LinearAlgebra -open Cslib.Logic.PL.ClauseSet.Sparsification -open Cslib.Complexity.SubexponentialSAT -open Cslib.Complexity.SubexponentialSAT.ReplacementParams -open Cslib.Complexity.SubexponentialSAT.SparseCountingScale - -variable {V : Type*} {n' : ℕ} - -/-! ### 1. Normalized Proposition 6.4 leaf decomposition (`CNF.prop64NormalizedLeaves`) -/ - -/-- The normalized Proposition 6.4 disjoint counting-sparsification leaf list of `φ : CNF V` -obtained by filtering tautological clauses (`nontautological`) and reducing by subsumption -(`reduce`) before applying `countingLeaves` at geometric threshold schedule -`θ j = (CNF.prop64ThresholdBase k (Fintype.card V)) ^ j` -([OpenAI2026ETH], Lemma 6.3, Proposition 6.4, and Appendix A.1–A.3, pp. 43–47). -/ -@[expose] def CNF.prop64NormalizedLeaves (k : ℕ) [Fintype V] [DecidableEq V] (φ : CNF V) : - List (ClauseSet V) := - countingLeaves (fun j => (CNF.prop64ThresholdBase k (Fintype.card V)) ^ j) - (reduce (nontautological φ.toClauseSet)) - -/-- The Lemma 6.2 / Section 6.3 eq. `(6.4)` candidate-query upper bound -`3 * Fintype.card V * (2 * ψ.length + 2) ^ (BitString.greedyRowListLength B ψ.length) + 1` -bounding the number of candidate parity-row systems evaluated across the `3 * n` greedy rounds on a -sparse formula `ψ : CNF V` at clause-density bound `B` ([OpenAI2026ETH], §6.3, p. 43). -/ -@[expose] def CNF.leafCandidateQueryBound [Fintype V] (B : ℕ) (ψ : CNF V) : ℕ := - 3 * Fintype.card V * (2 * ψ.length + 2) ^ (BitString.greedyRowListLength B ψ.length) + 1 - -/-- Index type of all parity-row systems evaluated during the Section 6.3 Lemma 6.2 greedy -procedure on a leaf formula `ψ : CNF V` at clause-density bound `B` -([OpenAI2026ETH], §6.3, eq. `(6.4)`, p. 43): -- `Sum.inl (i, γ')` indexes the candidate system `A i.1 ++ [testRow γ']` at greedy round - `i : Fin (3 * Fintype.card V)` and ordered candidate list - `γ' : Fin (BitString.greedyRowListLength B ψ.length) → Fin ψ.length × Bool` (including discarded - candidates, counted with list multiplicity), and -- `Sum.inr ()` indexes the final system `A (3 * Fintype.card V)`. -/ -abbrev CNF.LeafCandidateQueryIndex (V : Type*) [Fintype V] (B : ℕ) (ψ : CNF V) : Type _ := - (Fin (3 * Fintype.card V) × - (Fin (BitString.greedyRowListLength B ψ.length) → Fin ψ.length × Bool)) ⊕ Unit - -/-- The parity-row list evaluated at query `q : CNF.LeafCandidateQueryIndex V B ψ` along a -trajectory `A : ℕ → List (Fin ψ.length → Bool)` ([OpenAI2026ETH], §6.3, p. 43): -- at `Sum.inl (i, γ')`, the candidate row list `A i.1 ++ [testRow γ']` at round - `i < 3 * Fintype.card V` and ordered candidate list `γ'`, and -- at `Sum.inr ()`, the final row list `A (3 * Fintype.card V)`. -/ -@[expose] def CNF.candidateQueryRows [Fintype V] {B : ℕ} {ψ : CNF V} - (A : ℕ → List (Fin ψ.length → Bool)) : - CNF.LeafCandidateQueryIndex V B ψ → List (Fin ψ.length → Bool) - | Sum.inl (i, γ') => A i.1 ++ [testRow γ'] - | Sum.inr () => A (3 * Fintype.card V) - -/-- Single-leaf `interpolationScale` exponent multiplier -`CNF.prop64BranchExamScaleCoeff k + 33` combining heavy-variable branching (`+ 32`) with the -Lemma 6.2 candidate-query overhead (`+ 1`) of Section 6.3 eq. `(6.4)`. -/ -@[expose] def CNF.prop64LeafQueryExamScaleCoeff (k : ℕ) : ℕ := - CNF.prop64BranchExamScaleCoeff k + 33 - -/-- Tree-summed `interpolationScale` exponent multiplier -`CNF.prop64BranchExamScaleCoeff k + 49` combining per-leaf branch-summed examination (`+ 32`) with -the Proposition 6.4 sparsification tree leaf-count exponent (`+ 17`). -/ -@[expose] def CNF.prop64TreeExamScaleCoeff (k : ℕ) : ℕ := - CNF.prop64BranchExamScaleCoeff k + 49 - -/-- Total Proposition 6.4 `interpolationScale` exponent multiplier -`CNF.prop64BranchExamScaleCoeff k + 50` combining per-leaf branch-summed examination (`+ 32`), -Lemma 6.2 candidate-query overhead (`+ 1`), and the Proposition 6.4 sparsification tree leaf-count -exponent (`+ 17`). -/ -@[expose] def CNF.prop64TotalExamScaleCoeff (k : ℕ) : ℕ := - CNF.prop64BranchExamScaleCoeff k + 50 - -/-- `CNF.leafCandidateQueryBound B ψ` is at least `1`. -/ -theorem CNF.one_le_leafCandidateQueryBound [Fintype V] (B : ℕ) (ψ : CNF V) : - 1 ≤ CNF.leafCandidateQueryBound B ψ := - Nat.succ_pos _ - -/-- The exact number of candidate and final parity-row queries indexed by -`CNF.LeafCandidateQueryIndex V B ψ` is -`3 * Fintype.card V * (2 * ψ.length) ^ (BitString.greedyRowListLength B ψ.length) + 1`. -/ -theorem CNF.card_leafCandidateQueryIndex_eq [Fintype V] (B : ℕ) (ψ : CNF V) : - Fintype.card (CNF.LeafCandidateQueryIndex V B ψ) = - 3 * Fintype.card V * (2 * ψ.length) ^ (BitString.greedyRowListLength B ψ.length) + 1 := by - simp only [CNF.LeafCandidateQueryIndex, Fintype.card_sum, Fintype.card_prod, - Fintype.card_pi, Fintype.card_fin, Fintype.card_bool, Fintype.card_unit, - Finset.prod_const, Finset.card_univ] - ring - -/-- `Fintype.card (CNF.LeafCandidateQueryIndex V B ψ)` is at most -`CNF.leafCandidateQueryBound B ψ`. -/ -theorem CNF.card_leafCandidateQueryIndex_le [Fintype V] (B : ℕ) (ψ : CNF V) : - Fintype.card (CNF.LeafCandidateQueryIndex V B ψ) ≤ CNF.leafCandidateQueryBound B ψ := by - rw [CNF.card_leafCandidateQueryIndex_eq] - unfold CNF.leafCandidateQueryBound - exact Nat.add_le_add_right - (Nat.mul_le_mul_left _ (Nat.pow_le_pow_left (Nat.le_add_right _ 2) _)) 1 - -/-- **Proposition 6.4 normalized additive model-count conservation:** -Summing `L.toCNF.modelCountOn declared` across all leaves `L ∈ φ.prop64NormalizedLeaves k` -recovers `φ.modelCountOn declared` without any nontautology precondition on `φ`. -/ -theorem CNF.sum_modelCountOn_prop64NormalizedLeaves [Fintype V] [DecidableEq V] - (k : ℕ) (φ : CNF V) (declared : Finset V) : - ((φ.prop64NormalizedLeaves k).map fun L => L.toCNF.modelCountOn declared).sum = - φ.modelCountOn declared := - sum_modelCountOn_countingLeaves_nontautological - (fun j => (CNF.prop64ThresholdBase k (Fintype.card V)) ^ j) φ declared - -/-- **Proposition 6.4 normalized exact assignment partition:** -For every assignment `x : V → Bool`, the number of leaf formulas `L.toCNF` -(`L ∈ φ.prop64NormalizedLeaves k`) satisfied by `x` is `1` if `φ.eval x = true` and `0` otherwise. --/ -theorem CNF.countP_eval_toCNF_prop64NormalizedLeaves [Fintype V] [DecidableEq V] - (k : ℕ) (φ : CNF V) (x : V → Bool) : - ((φ.prop64NormalizedLeaves k).map ClauseSet.toCNF).countP (fun F => F.eval x) = - if φ.eval x then 1 else 0 := - countP_eval_toCNF_countingLeaves_nontautological - (fun j => (CNF.prop64ThresholdBase k (Fintype.card V)) ^ j) φ x - -/-- **Proposition 6.4 normalized leaf structural and clause-density bounds:** -If `∀ c ∈ φ, c.length ≤ k`, then for every leaf `L ∈ φ.prop64NormalizedLeaves k`: -1. `L` is `Sparse` at `θ j = (CNF.prop64ThresholdBase k (Fintype.card V)) ^ j`, `Reduced`, and - nontautological. -2. Every clause `c ∈ L.toCNF` has width `c.length ≤ k`. -3. Every variable `v : V` occurs in at most - `2 * ∑ c ∈ range k, (CNF.prop64ThresholdBase k (Fintype.card V)) ^ c` clauses of `L.toCNF`. -4. Whenever `1 ≤ Fintype.card V`, - `L.toCNF.length ≤ CNF.prop64LeafClauseRatio k (Fintype.card V) * Fintype.card V`. -/ -theorem CNF.length_le_of_mem_prop64NormalizedLeaves [Fintype V] [DecidableEq V] - {φ : CNF V} {k : ℕ} (hk : ∀ c ∈ φ, c.length ≤ k) - {L : ClauseSet V} (hL : L ∈ φ.prop64NormalizedLeaves k) : - Sparse (fun j => (CNF.prop64ThresholdBase k (Fintype.card V)) ^ j) L ∧ - Reduced L ∧ - (∀ C ∈ L, ∀ l ∈ C, Std.Sat.Literal.negate l ∉ C) ∧ - (∀ c ∈ L.toCNF, c.length ≤ k) ∧ - (∀ v : V, L.toCNF.occurrences v ≤ - 2 * ∑ c ∈ range k, (CNF.prop64ThresholdBase k (Fintype.card V)) ^ c) ∧ - (1 ≤ Fintype.card V → - L.toCNF.length ≤ CNF.prop64LeafClauseRatio k (Fintype.card V) * Fintype.card V) := by - set M := CNF.prop64ThresholdBase k (Fintype.card V) - have hM2 : 2 ≤ M := CNF.two_le_prop64ThresholdBase k (Fintype.card V) - have hθ1 : ∀ j, 1 ≤ M ^ j := fun j => Nat.one_le_pow j M (by omega) - have hsparse : Sparse (M ^ ·) L := sparse_of_mem_countingLeaves_pow hM2 hL - have hred : Reduced L := reduced_of_mem_countingLeaves (reduced_reduce _) hL - have hnt : ∀ C ∈ L, ∀ l ∈ C, Std.Sat.Literal.negate l ∉ C := - nontautological_of_mem_countingLeaves hθ1 - (fun _ hC => nontautological_of_mem_reduce_nontautological hC) hL - have hroot_k : ∀ C ∈ reduce (nontautological φ.toClauseSet), C.card ≤ k := by - intro C hC - obtain ⟨c, hc, hcard⟩ := - CNF.exists_card_le_of_mem_toClauseSet (nontautological_subset _ (reduce_subset _ hC)) - exact hcard.trans (hk c hc) - have hL_k : ∀ C ∈ L, C.card ≤ k := card_le_of_mem_countingLeaves hroot_k hL - refine ⟨hsparse, hred, hnt, fun c hc => ClauseSet.length_le_of_mem_toCNF hL_k hc, - fun v => ?_, fun hn1 => ?_⟩ - · rw [ClauseSet.occurrences_toCNF] - exact occurrences_le_of_sparse hθ1 hsparse hL_k v - · have hlen_eq : L.toCNF.length = L.card := by - simp only [ClauseSet.toCNF, List.length_map, Finset.length_toList] - have hcard_le : L.card ≤ 2 * (∑ c ∈ range k, M ^ c) * (univ : Finset V).card + 1 := - card_le_of_sparse hθ1 hsparse hL_k univ (fun _ _ _ _ => mem_univ _) - rw [hlen_eq] - rw [card_univ] at hcard_le - unfold CNF.prop64LeafClauseRatio - calc L.card - ≤ 2 * (∑ c ∈ range k, M ^ c) * Fintype.card V + 1 := hcard_le - _ ≤ 2 * (∑ c ∈ range k, M ^ c) * Fintype.card V + Fintype.card V := - Nat.add_le_add_left hn1 _ - _ = (2 * (∑ c ∈ range k, M ^ c) + 1) * Fintype.card V := by ring - -/-! ### 2. Proposition 6.4 tree leaf-count bounds against `numGroups` and `interpolationScale` -/ - -/-- **Proposition 6.4 `2 ^ (n / numGroups n + 1)` leaf-count bound:** -Whenever `1 ≤ numGroups (Fintype.card V)` and `∀ c ∈ φ, c.length ≤ k`, the normalized -counting-sparsification leaf list `φ.prop64NormalizedLeaves k` has length at most -`2 ^ (Fintype.card V / numGroups (Fintype.card V) + 1)`. -/ -theorem CNF.length_prop64NormalizedLeaves_le_two_pow [Fintype V] [DecidableEq V] - {φ : CNF V} {k : ℕ} (hk : ∀ c ∈ φ, c.length ≤ k) - (hs : 1 ≤ numGroups (Fintype.card V)) : - (φ.prop64NormalizedLeaves k).length ≤ - 2 ^ (Fintype.card V / numGroups (Fintype.card V) + 1) := - length_countingLeaves_nontautological_thresholdBase_le hs φ hk Finset.univ - (fun _ _ => mem_univ _) (by rw [card_univ]) - -/-- When `640000 ≤ Nat.clog 2 n`, `1 ≤ interpolationScale n`. -/ -theorem one_le_interpolationScale_of_clog_ge {n : ℕ} (h : 640000 ≤ Nat.clog 2 n) : - 1 ≤ interpolationScale n := by - have hs2 : 2 ≤ numGroups n := two_le_numGroups_of_clog_ge h - have h2pow19 : 2 ^ 19 < Nat.clog 2 n := - lt_of_lt_of_le (by decide : 2 ^ 19 < 640000) h - have hnu20 : 20 ≤ Nat.clog 2 (Nat.clog 2 n) := - (Nat.lt_clog_iff_pow_lt one_lt_two).mpr h2pow19 - have hsq := sq_mul_pow_four_le_clog n - have hclog_le : Nat.clog 2 n ≤ n := - (Nat.clog_le_iff_le_pow one_lt_two).mpr n.lt_two_pow_self.le - have h16_mul : 16 * numGroups n ≤ n := by - have hnu4 : 16 ≤ numGroups n * Nat.clog 2 (Nat.clog 2 n) ^ 4 := by - have : 16 ≤ 2 * 20 ^ 4 := by decide - exact this.trans (Nat.mul_le_mul hs2 (Nat.pow_le_pow_left hnu20 4)) - calc 16 * numGroups n - ≤ (numGroups n * Nat.clog 2 (Nat.clog 2 n) ^ 4) * numGroups n := - Nat.mul_le_mul_right _ hnu4 - _ = numGroups n ^ 2 * Nat.clog 2 (Nat.clog 2 n) ^ 4 := by ring - _ ≤ Nat.clog 2 n := hsq - _ ≤ n := hclog_le - have hs_pos : (0 : ℝ) < numGroups n := Nat.cast_pos.mpr (by omega) - have h16_div : 16 ≤ (n : ℝ) / (numGroups n : ℝ) := by - rw [le_div_iff₀ hs_pos] - exact_mod_cast h16_mul - have hdiv_le := div_numGroups_le_interpolationScale_of_clog_ge h - linarith - -/-- **Proposition 6.4 `(2 : ℝ) ^ (17 * interpolationScale n)` leaf-count bound under -`640000 ≤ Nat.clog 2 (Fintype.card V)`:** -For any width-`≤ k` CNF `φ : CNF V` with `640000 ≤ Nat.clog 2 (Fintype.card V)`, -`((φ.prop64NormalizedLeaves k).length : ℝ) ≤ (2 : ℝ) ^ (17 * interpolationScale (Fintype.card V))`. --/ -theorem CNF.length_prop64NormalizedLeaves_le_interpolationScale_of_clog_ge - [Fintype V] [DecidableEq V] {φ : CNF V} {k : ℕ} (hk : ∀ c ∈ φ, c.length ≤ k) - (h : 640000 ≤ Nat.clog 2 (Fintype.card V)) : - ((φ.prop64NormalizedLeaves k).length : ℝ) ≤ - (2 : ℝ) ^ (17 * interpolationScale (Fintype.card V)) := by - set n := Fintype.card V - have hs2 : 2 ≤ numGroups n := two_le_numGroups_of_clog_ge h - have hlen_nat : (φ.prop64NormalizedLeaves k).length ≤ 2 ^ (n / numGroups n + 1) := - CNF.length_prop64NormalizedLeaves_le_two_pow hk (le_trans one_le_two hs2) - have hlen_r : ((φ.prop64NormalizedLeaves k).length : ℝ) ≤ - (2 : ℝ) ^ (1 : ℝ) * (2 : ℝ) ^ ((n : ℝ) / (numGroups n : ℝ)) := by - have hcast : ((φ.prop64NormalizedLeaves k).length : ℝ) ≤ - ((2 ^ (n / numGroups n + 1) : ℕ) : ℝ) := Nat.cast_le.mpr hlen_nat - refine hcast.trans ?_ - rw [Nat.cast_pow, Nat.cast_ofNat, pow_succ', Real.rpow_one, ← Real.rpow_natCast] - exact mul_le_mul_of_nonneg_left - (Real.rpow_le_rpow_of_exponent_le one_le_two Nat.cast_div_le) zero_le_two - have h1_scale : (2 : ℝ) ^ (1 : ℝ) ≤ (2 : ℝ) ^ interpolationScale n := - Real.rpow_le_rpow_of_exponent_le one_le_two (one_le_interpolationScale_of_clog_ge h) - have h16_scale : - (2 : ℝ) ^ ((n : ℝ) / (numGroups n : ℝ)) ≤ (2 : ℝ) ^ (16 * interpolationScale n) := - Real.rpow_le_rpow_of_exponent_le one_le_two - (div_numGroups_le_interpolationScale_of_clog_ge h) - calc ((φ.prop64NormalizedLeaves k).length : ℝ) - ≤ (2 : ℝ) ^ (1 : ℝ) * (2 : ℝ) ^ ((n : ℝ) / (numGroups n : ℝ)) := hlen_r - _ ≤ (2 : ℝ) ^ interpolationScale n * (2 : ℝ) ^ (16 * interpolationScale n) := - mul_le_mul h1_scale h16_scale (by positivity) (by positivity) - _ = (2 : ℝ) ^ (17 * interpolationScale n) := by rw [← Real.rpow_add two_pos]; ring_nf - -private theorem le_clog_of_two_pow_le {m n : ℕ} (hn : 2 ^ m ≤ n) : m ≤ Nat.clog 2 n := - (Nat.clog_pow 2 m one_lt_two).symm.le.trans (Nat.clog_mono_right 2 hn) - -/-- **Proposition 6.4 `(2 : ℝ) ^ (17 * interpolationScale n)` leaf-count bound for -`2 ^ 640000 ≤ Fintype.card V`:** -For any width-`≤ k` CNF `φ : CNF V` with `2 ^ 640000 ≤ Fintype.card V`, -`((φ.prop64NormalizedLeaves k).length : ℝ) ≤ (2 : ℝ) ^ (17 * interpolationScale (Fintype.card V))`. --/ -theorem CNF.length_prop64NormalizedLeaves_le_interpolationScale - [Fintype V] [DecidableEq V] {φ : CNF V} {k : ℕ} (hk : ∀ c ∈ φ, c.length ≤ k) - (hn : 2 ^ 640000 ≤ Fintype.card V) : - ((φ.prop64NormalizedLeaves k).length : ℝ) ≤ - (2 : ℝ) ^ (17 * interpolationScale (Fintype.card V)) := - CNF.length_prop64NormalizedLeaves_le_interpolationScale_of_clog_ge hk (le_clog_of_two_pow_le hn) - -/-! ### 3. Lemma 6.2 candidate-query overhead and Proposition 6.4 tree-wide examination bounds -/ - -/-- For every `B, m : ℕ`, the Lemma 6.1–6.2 greedy candidate list length -`BitString.greedyRowListLength B m = 20000 * B ^ 2 * (Nat.log 2 m + 1) ^ 2` satisfies -`BitString.greedyRowListLength B m ≤ 20000 * B ^ 2 * (Nat.clog 2 (2 * m + 4)) ^ 2`. -/ -theorem CNF.greedyRowListLength_le_mul_pow_clog (B m : ℕ) : - BitString.greedyRowListLength B m ≤ 20000 * B ^ 2 * (Nat.clog 2 (2 * m + 4)) ^ 2 := by - have hlog_lt : Nat.log 2 m < Nat.clog 2 (2 * m + 4) := by - rw [Nat.lt_clog_iff_pow_lt one_lt_two] - rcases Nat.eq_zero_or_pos m with rfl | hm_pos - · decide - · have hpow : 2 ^ Nat.log 2 m ≤ m := Nat.pow_log_le_self 2 (by omega) - omega - unfold BitString.greedyRowListLength - exact Nat.mul_le_mul_left (20000 * B ^ 2) (Nat.pow_le_pow_left hlog_lt 2) - -private theorem greedyRowListLength_le_initialRowWeightBound (B m : ℕ) : - BitString.greedyRowListLength B m ≤ BitString.initialRowWeightBound B m := by - unfold BitString.greedyRowListLength BitString.initialRowWeightBound - exact Nat.mul_le_mul (Nat.mul_le_mul_right _ (by decide)) - (Nat.pow_le_pow_right (Nat.succ_pos _) (by decide)) - -/-- If a trajectory `A : ℕ → List (Fin ψ.length → Bool)` satisfies -`(A i).length ≤ 3 * Fintype.card V + i` for all `i ≤ 3 * Fintype.card V`, then every query -`q : CNF.LeafCandidateQueryIndex V B ψ` (including every discarded candidate -`A i.1 ++ [testRow γ']` for `i < 3 * Fintype.card V` and the final system -`A (3 * Fintype.card V)`) has at most `6 * Fintype.card V` parity rows. -/ -theorem CNF.length_candidateQueryRows_le_of_step [Fintype V] {B : ℕ} {ψ : CNF V} - {A : ℕ → List (Fin ψ.length → Bool)} - (hlen : ∀ i ≤ 3 * Fintype.card V, (A i).length ≤ 3 * Fintype.card V + i) - (q : CNF.LeafCandidateQueryIndex V B ψ) : - (CNF.candidateQueryRows A q).length ≤ 6 * Fintype.card V := by - rcases q with ⟨i, γ'⟩ | ⟨⟩ - · simp only [CNF.candidateQueryRows, List.length_append, List.length_singleton] - have hi : (A i.1).length ≤ 3 * Fintype.card V + i.1 := hlen i.1 i.2.le - omega - · simp only [CNF.candidateQueryRows] - have h3n := hlen (3 * Fintype.card V) le_rfl - omega - -/-- If every row in `A i` (`i ≤ 3 * Fintype.card V`) has Hamming weight at most -`BitString.initialRowWeightBound B ψ.length`, then every row in `CNF.candidateQueryRows A q` -(including every candidate `testRow γ'`) has Hamming weight at most -`BitString.initialRowWeightBound B ψ.length`. -/ -theorem CNF.weight_mem_candidateQueryRows_le_of_step [Fintype V] {B : ℕ} {ψ : CNF V} - {A : ℕ → List (Fin ψ.length → Bool)} - (hw : ∀ i ≤ 3 * Fintype.card V, ∀ r ∈ A i, - weight r ≤ BitString.initialRowWeightBound B ψ.length) - (q : CNF.LeafCandidateQueryIndex V B ψ) : - ∀ r ∈ CNF.candidateQueryRows A q, weight r ≤ BitString.initialRowWeightBound B ψ.length := by - rcases q with ⟨i, γ'⟩ | ⟨⟩ - · intro r hr - simp only [CNF.candidateQueryRows, List.mem_append, List.mem_singleton] at hr - rcases hr with hr | rfl - · exact hw i.1 i.2.le r hr - · exact (weight_testRow_le γ').trans - (greedyRowListLength_le_initialRowWeightBound B ψ.length) - · exact hw (3 * Fintype.card V) le_rfl - -/-- Along any trajectory `A` starting from `A 0 = A₀` with `A₀.length ≤ 3 * Fintype.card V` -and `∀ r ∈ A₀, weight r ≤ BitString.initialRowWeightBound B ψ.length` and appending one -`testRow (γ i)` per step, every query `q : CNF.LeafCandidateQueryIndex V B ψ` has at most -`6 * Fintype.card V` parity rows, each of Hamming weight at most -`BitString.initialRowWeightBound B ψ.length`. -/ -theorem CNF.candidateQueryRows_length_and_weight_le [Fintype V] {B : ℕ} {ψ : CNF V} - {A₀ : List (Fin ψ.length → Bool)} (hlen0 : A₀.length ≤ 3 * Fintype.card V) - (hw0 : ∀ r ∈ A₀, weight r ≤ BitString.initialRowWeightBound B ψ.length) - {A : ℕ → List (Fin ψ.length → Bool)} - {γ : ℕ → Fin (BitString.greedyRowListLength B ψ.length) → Fin ψ.length × Bool} - (h0 : A 0 = A₀) (hA : ∀ i, A (i + 1) = A i ++ [testRow (γ i)]) - (q : CNF.LeafCandidateQueryIndex V B ψ) : - (CNF.candidateQueryRows A q).length ≤ 6 * Fintype.card V ∧ - ∀ r ∈ CNF.candidateQueryRows A q, weight r ≤ BitString.initialRowWeightBound B ψ.length := by - have hstep : ∀ i, (A i).length ≤ 3 * Fintype.card V + i ∧ - ∀ r ∈ A i, weight r ≤ BitString.initialRowWeightBound B ψ.length := by - intro i - induction i with - | zero => - exact ⟨by simpa [h0] using hlen0, fun r hr => hw0 r (h0 ▸ hr)⟩ - | succ i ih => - rw [hA i, List.length_append, List.length_singleton] - refine ⟨by omega, fun r hr => ?_⟩ - rcases List.mem_append.mp hr with hr | hr - · exact ih.2 r hr - · rw [List.mem_singleton.mp hr] - exact (weight_testRow_le (γ i)).trans - (greedyRowListLength_le_initialRowWeightBound B ψ.length) - exact ⟨CNF.length_candidateQueryRows_le_of_step (fun i _ => (hstep i).1) q, - CNF.weight_mem_candidateQueryRows_le_of_step (fun i _ => (hstep i).2) q⟩ - -/-- If `queryExam q ≤ M` (`0 ≤ M`) for every candidate and final query -`q : CNF.LeafCandidateQueryIndex V B ψ`, then the sum of `queryExam q` across all -`q : CNF.LeafCandidateQueryIndex V B ψ` (counting all `3 * Fintype.card V` rounds and all -ordered candidate lists `γ'` with multiplicity plus the final query) is at most -`(CNF.leafCandidateQueryBound B ψ : ℝ) * M`. -/ -theorem CNF.sum_leafCandidateQueryIndex_le [Fintype V] (B : ℕ) (ψ : CNF V) - (queryExam : CNF.LeafCandidateQueryIndex V B ψ → ℝ) {M : ℝ} (hM : 0 ≤ M) - (hq : ∀ q : CNF.LeafCandidateQueryIndex V B ψ, queryExam q ≤ M) : - (∑ q : CNF.LeafCandidateQueryIndex V B ψ, queryExam q) ≤ - (CNF.leafCandidateQueryBound B ψ : ℝ) * M := by - calc (∑ q : CNF.LeafCandidateQueryIndex V B ψ, queryExam q) - ≤ ∑ _q : CNF.LeafCandidateQueryIndex V B ψ, M := - Finset.sum_le_sum fun q _ => hq q - _ = (Fintype.card (CNF.LeafCandidateQueryIndex V B ψ) : ℝ) * M := by - rw [Finset.sum_const, Finset.card_univ, nsmul_eq_mul] - _ ≤ (CNF.leafCandidateQueryBound B ψ : ℝ) * M := - mul_le_mul_of_nonneg_right - (Nat.cast_le.mpr (CNF.card_leafCandidateQueryIndex_le B ψ)) hM - -/-- **Section 6.3 eq. `(6.4)` candidate-query overhead absorption:** -For any `C_B β_B : ℕ` and any `ε > 0`, there exists `N_q : ℕ` such that for any finite variable -type `V` with `N_q ≤ Fintype.card V`, any CNF `ψ : CNF V`, and any `B : ℕ` satisfying -`ψ.length ≤ B * Fintype.card V` and `B ≤ C_B * (Nat.clog 2 (Fintype.card V)) ^ β_B`, -`(CNF.leafCandidateQueryBound B ψ : ℝ) ≤ (2 : ℝ) ^ (ε * interpolationScale (Fintype.card V))`. -/ -theorem CNF.exists_leafCandidateQueryBound_le_interpolationScale - (C_B β_B : ℕ) {ε : ℝ} (hε : 0 < ε) : - ∃ N_q : ℕ, ∀ {V : Type*} [Fintype V] (ψ : CNF V) {B : ℕ}, - N_q ≤ Fintype.card V → - ψ.length ≤ B * Fintype.card V → - B ≤ C_B * Nat.clog 2 (Fintype.card V) ^ β_B → - (CNF.leafCandidateQueryBound B ψ : ℝ) ≤ - (2 : ℝ) ^ (ε * interpolationScale (Fintype.card V)) := by - obtain ⟨N_q, hN_q⟩ := eventually_atTop.mp - (eventually_query_overhead_poly_le C_B β_B 20000 2 2 hε) - refine ⟨N_q, fun {V _} ψ {B} hcard hm hB => ?_⟩ - have hP := CNF.greedyRowListLength_le_mul_pow_clog B ψ.length - have hbound := hN_q (Fintype.card V) hcard ψ.length B - (BitString.greedyRowListLength B ψ.length) hm hB hP - unfold CNF.leafCandidateQueryBound - exact_mod_cast hbound - -/-- **Proposition 6.4 leaf candidate-query overhead bound (`ε = 1`):** -For any `k ≥ 2`, there exists `N_q ≥ 2` such that for any finite variable type `V` with -`N_q ≤ Fintype.card V` and any `ψ : CNF V` satisfying -`ψ.length ≤ CNF.prop64LeafClauseRatio k (Fintype.card V) * Fintype.card V`, -`(CNF.leafCandidateQueryBound (CNF.prop64LeafClauseRatio k (Fintype.card V)) ψ : ℝ) ≤` -`(2 : ℝ) ^ interpolationScale (Fintype.card V)`. -/ -theorem CNF.exists_prop64_leafCandidateQueryBound_le_interpolationScale {k : ℕ} (hk : 2 ≤ k) : - ∃ N_q : ℕ, 2 ≤ N_q ∧ - ∀ {V : Type*} [Fintype V] (ψ : CNF V), - N_q ≤ Fintype.card V → - ψ.length ≤ CNF.prop64LeafClauseRatio k (Fintype.card V) * Fintype.card V → - (CNF.leafCandidateQueryBound (CNF.prop64LeafClauseRatio k (Fintype.card V)) ψ : ℝ) ≤ - (2 : ℝ) ^ interpolationScale (Fintype.card V) := by - obtain ⟨C_B, _, hCB⟩ := CNF.exists_prop64LeafClauseRatio_le_mul_clog_pow hk - obtain ⟨N_q, hN_q⟩ := - CNF.exists_leafCandidateQueryBound_le_interpolationScale C_B (2 * (k - 1)) one_pos - refine ⟨max N_q 2, le_max_right _ _, fun {V _} ψ hcard hm => ?_⟩ - have hcard_q : N_q ≤ Fintype.card V := (le_max_left _ _).trans hcard - have hn2 : 2 ≤ Fintype.card V := (le_max_right _ _).trans hcard - have hB_le : - CNF.prop64LeafClauseRatio k (Fintype.card V) ≤ - C_B * Nat.clog 2 (Fintype.card V) ^ (2 * (k - 1)) := - hCB (Fintype.card V) hn2 - simpa only [one_mul] using hN_q ψ hcard_q hm hB_le - -private theorem list_sum_map_le_length_mul {α : Type*} (xs : List α) (f : α → ℝ) {M : ℝ} - (hf : ∀ x ∈ xs, f x ≤ M) : - (xs.map f).sum ≤ (xs.length : ℝ) * M := by - simpa only [List.length_map, nsmul_eq_mul] using - List.sum_le_length_nsmul (xs.map f) M (by simpa only [List.forall_mem_map] using hf) - -/-- **Proposition 6.4 end-to-end normalized leaf-to-root greedy recovery, -leaf-count bound, and total candidate-indexed `interpolationScale` examination bounds -([OpenAI2026ETH], §6.4, pp. 43–44 & Appendix A, pp. 44–47):** -For any `k ≥ 2`, there exists `N₃ ≥ 2 ^ 640000` such that for any finite variable type `V` with -`N₃ ≤ Fintype.card V` and any width-`≤ k` CNF `φ : CNF V` (with no clause-count, occurrence, or -nontautology restriction on `φ`): -1. **Exact leaf-summed model-count conservation:** - `((φ.prop64NormalizedLeaves k).map fun L => L.toCNF.modelCountOn Finset.univ).sum =` - `φ.modelCountOn Finset.univ`. -2. **Sparsification tree leaf-count bounds:** - `2 ≤ numGroups (Fintype.card V)`, - `(φ.prop64NormalizedLeaves k).length ≤ 2 ^ (Fintype.card V / numGroups (Fintype.card V) + 1)`, - and `((φ.prop64NormalizedLeaves k).length : ℝ) ≤` - `(2 : ℝ) ^ (17 * interpolationScale (Fintype.card V))`. -3. **Per-leaf greedy parity-design recovery, degree, and candidate-indexed examination bounds:** - For every leaf `L ∈ φ.prop64NormalizedLeaves k` (`ψ := L.toCNF`, - `B := CNF.prop64LeafClauseRatio k (Fintype.card V)`): - - `(CNF.leafCandidateQueryBound B ψ : ℝ) ≤ (2 : ℝ) ^ interpolationScale (Fintype.card V)`, - - `ψ` admits Lemma 6.1 initial parity rows `A₀` such that for any `3 * n`-step greedy trajectory - `(A, γ)`, `CNF.candidateQueryRows A (Sum.inr ()) = A (3 * Fintype.card V)` recovers - `ψ.modelCountOn Finset.univ`, **every** evaluated query `q : CNF.LeafCandidateQueryIndex V B ψ` - (including every discarded candidate `A i.1 ++ [testRow γ']` for `i < 3 * Fintype.card V` and - `γ'` as well as the final query `Sum.inr ()`) has at most `6 * Fintype.card V` rows of weight - `≤ D₀` and admits concrete per-branch `ReplacementDesign`s `D b` recovering - `commonZeroCount univ (ψ.parityRowSystem (CNF.candidateQueryRows A q))` with branch-summed - examination count at most - `(2 : ℝ) ^ ((CNF.prop64BranchExamScaleCoeff k + 32) * interpolationScale (Fintype.card V))`, - and any per-query examination family `queryExam : CNF.LeafCandidateQueryIndex V B ψ → ℝ` - bounded by that single-query bound sums across all `q : CNF.LeafCandidateQueryIndex V B ψ` to - at most - `(2 : ℝ) ^ (CNF.prop64LeafQueryExamScaleCoeff k * interpolationScale (Fintype.card V))`. -4. **Tree-wide and total candidate-indexed examination bounds across `φ.prop64NormalizedLeaves k`:** - - Any per-leaf examination family `leafExam : ClauseSet V → ℝ` bounded on every - `L ∈ φ.prop64NormalizedLeaves k` by - `(2 : ℝ) ^ ((CNF.prop64BranchExamScaleCoeff k + 32) * interpolationScale (Fintype.card V))` - sums across `φ.prop64NormalizedLeaves k` to at most - `(2 : ℝ) ^ (CNF.prop64TreeExamScaleCoeff k * interpolationScale (Fintype.card V))`. - - Any candidate-indexed examination family - `treeQueryExam : (L : ClauseSet V) → CNF.LeafCandidateQueryIndex V B L.toCNF → ℝ` bounded on - every `L ∈ φ.prop64NormalizedLeaves k` and `q : CNF.LeafCandidateQueryIndex V B L.toCNF` by - `(2 : ℝ) ^ ((CNF.prop64BranchExamScaleCoeff k + 32) * interpolationScale (Fintype.card V))` - has total sum - `((φ.prop64NormalizedLeaves k).map fun L =>` - `∑ q : CNF.LeafCandidateQueryIndex V B L.toCNF, treeQueryExam L q).sum` - at most `(2 : ℝ) ^ (CNF.prop64TotalExamScaleCoeff k * interpolationScale (Fintype.card V))`. -/ -theorem CNF.exists_prop64NormalizedLeaves_greedy_total_recovery_and_examBound - {k : ℕ} (hk : 2 ≤ k) : - ∃ N₃ : ℕ, 2 ^ 640000 ≤ N₃ ∧ - ∀ {V : Type*} [Fintype V] [DecidableEq V] - (φ : CNF V), - (∀ c ∈ φ, c.length ≤ k) → - N₃ ≤ Fintype.card V → - let B := CNF.prop64LeafClauseRatio k (Fintype.card V) - ((φ.prop64NormalizedLeaves k).map fun L => L.toCNF.modelCountOn Finset.univ).sum = - φ.modelCountOn Finset.univ ∧ - 2 ≤ numGroups (Fintype.card V) ∧ - (φ.prop64NormalizedLeaves k).length ≤ - 2 ^ (Fintype.card V / numGroups (Fintype.card V) + 1) ∧ - ((φ.prop64NormalizedLeaves k).length : ℝ) ≤ - (2 : ℝ) ^ (17 * interpolationScale (Fintype.card V)) ∧ - (∀ L ∈ φ.prop64NormalizedLeaves k, - let ψ := L.toCNF - let D₀ := BitString.initialRowWeightBound B ψ.length - let P := BitString.greedyRowListLength B ψ.length - let b₀ := CNF.parityBranchThreshold k D₀ (Fintype.card V) - (∀ c ∈ ψ, c.length ≤ k) ∧ - ψ.length ≤ B * Fintype.card V ∧ - (CNF.leafCandidateQueryBound B ψ : ℝ) ≤ - (2 : ℝ) ^ interpolationScale (Fintype.card V) ∧ - ∃ A₀ : List (Fin ψ.length → Bool), A₀.length ≤ 3 * Fintype.card V ∧ - (∀ r ∈ A₀, weight r ≤ D₀) ∧ - ∀ (A : ℕ → List (Fin ψ.length → Bool)) - (γ : ℕ → Fin P → Fin ψ.length × Bool), - A 0 = A₀ → (∀ i, A (i + 1) = A i ++ [testRow (γ i)]) → - (∀ i (γ' : Fin P → Fin ψ.length × Bool), - commonZeroCount univ (ψ.parityRowSystem (A i ++ [testRow (γ i)])) ≤ - commonZeroCount univ (ψ.parityRowSystem (A i ++ [testRow γ']))) → - commonZeroCount univ - (ψ.parityRowSystem (CNF.candidateQueryRows (B := B) A (Sum.inr ()))) = - ψ.modelCountOn Finset.univ ∧ - (∀ q : CNF.LeafCandidateQueryIndex V B ψ, - let rows := CNF.candidateQueryRows A q - rows.length ≤ 6 * Fintype.card V ∧ - (∀ r ∈ rows, weight r ≤ D₀) ∧ - let S := heavyVars univ (univ : Finset (Fin rows.length)) - (fun j => equationScope (ψ.parityRowSystem rows j)) b₀ - ∀ ⦃n' : ℕ⦄ (e : ↥(univ \ S) ≃ Fin n'), - (Fintype.card V ≤ 2 * n' ∧ n' ≤ Fintype.card V) ∧ - (∃ (hF : ∀ b : V → Bool, - Feasible (CNF.prop64ScheduleExponent k) n' (b₀ + 1) - (max (k * (D₀ * 2 ^ k)) 1) - (∑ f : {j : Fin rows.length // - j ∈ (univ : Finset (Fin rows.length))} ⊕ Fin n', - #(branchAugmentedScope S e univ (ψ.parityRowSystem rows) b f))) - (D : ∀ b : V → Bool, - ReplacementDesign - (branchAugmentedScope S e univ (ψ.parityRowSystem rows) b) - (numNodes n') (numGroups n') - (intervalStart (CNF.prop64ScheduleExponent k) n') - (rowBound (CNF.prop64ScheduleExponent k) n') (tauRat n')), - (commonZeroCount (univ : Finset (Fin rows.length)) - (ψ.parityRowSystem rows) : ℤ) = - (∑ b ∈ branchAssignments S, - ((univariateClearedParityTruncatedSum (univ : Finset (Fin rows.length)) - (ψ.branchParityRowSystem rows S e b) - (commonDenom (numNodes n') - (rowBound (CNF.prop64ScheduleExponent k) n') : ℤ) k - (branchPrecision (Fintype.card V)) - (designReplacementScaledIntMap (D b) - (fun j => Sum.inl ⟨j, mem_univ j⟩))).eval 0 / - clearedProductDenom - (commonDenom (numNodes n') - (rowBound (CNF.prop64ScheduleExponent k) n') : ℤ) k - (branchPrecision (Fintype.card V)) - #(univ : Finset (Fin rows.length))) % - ((2 : ℤ) ^ branchPrecision (Fintype.card V))) ∧ - (∀ b : V → Bool, - (univariateClearedParityTruncatedSum (univ : Finset (Fin rows.length)) - (ψ.branchParityRowSystem rows S e b) - (commonDenom (numNodes n') - (rowBound (CNF.prop64ScheduleExponent k) n') : ℤ) k - (branchPrecision (Fintype.card V)) - (designReplacementScaledIntMap (D b) - (fun j => Sum.inl ⟨j, mem_univ j⟩))).natDegree ≤ - (k * (rowBound (CNF.prop64ScheduleExponent k) n' - 1)) * - (8 * Fintype.card V)) ∧ - ∀ (b : V → Bool) - (s_active : Finset - ({j : Fin rows.length // - j ∈ (univ : Finset (Fin rows.length))} ⊕ Fin n')), - let d := k * (rows.length + 2 * (branchPrecision (Fintype.card V) - 1)) - let q_ord := (d * rowBound (CNF.prop64ScheduleExponent k) n') / numNodes n' - let C := (hF b).toCountingDesign (D b) s_active - (∑ t : Fin (numNodes n'), - (#{p : Finset (Fin n') × Finset (Fin n') | - #p.1 ≤ q_ord ∧ p.2 ⊆ p.1} : ℝ) * - (2 * (#(C.measurementBox t) : ℝ) * - ∑ g : Fin (numGroups n'), - (Fintype.card (C.LocalCube t g) : ℝ))) ≤ - (2 : ℝ) ^ ((CNF.prop64BranchExamScaleCoeff k : ℝ) * - interpolationScale (Fintype.card V))) ∧ - ∀ (examSum : (V → Bool) → ℝ), - (∀ b ∈ branchAssignments S, - examSum b ≤ - (2 : ℝ) ^ ((CNF.prop64BranchExamScaleCoeff k : ℝ) * - interpolationScale (Fintype.card V))) → - (∑ b ∈ branchAssignments S, examSum b) ≤ - (2 : ℝ) ^ (((CNF.prop64BranchExamScaleCoeff k + 32 : ℕ) : ℝ) * - interpolationScale (Fintype.card V))) ∧ - ∀ (queryExam : CNF.LeafCandidateQueryIndex V B ψ → ℝ), - (∀ q : CNF.LeafCandidateQueryIndex V B ψ, - queryExam q ≤ - (2 : ℝ) ^ (((CNF.prop64BranchExamScaleCoeff k + 32 : ℕ) : ℝ) * - interpolationScale (Fintype.card V))) → - (∑ q : CNF.LeafCandidateQueryIndex V B ψ, queryExam q) ≤ - (2 : ℝ) ^ ((CNF.prop64LeafQueryExamScaleCoeff k : ℝ) * - interpolationScale (Fintype.card V))) ∧ - (∀ (leafExam : ClauseSet V → ℝ), - (∀ L ∈ φ.prop64NormalizedLeaves k, - leafExam L ≤ - (2 : ℝ) ^ (((CNF.prop64BranchExamScaleCoeff k + 32 : ℕ) : ℝ) * - interpolationScale (Fintype.card V))) → - ((φ.prop64NormalizedLeaves k).map leafExam).sum ≤ - (2 : ℝ) ^ ((CNF.prop64TreeExamScaleCoeff k : ℝ) * - interpolationScale (Fintype.card V))) ∧ - ∀ (treeQueryExam : (L : ClauseSet V) → CNF.LeafCandidateQueryIndex V B L.toCNF → ℝ), - (∀ L ∈ φ.prop64NormalizedLeaves k, ∀ q : CNF.LeafCandidateQueryIndex V B L.toCNF, - treeQueryExam L q ≤ - (2 : ℝ) ^ (((CNF.prop64BranchExamScaleCoeff k + 32 : ℕ) : ℝ) * - interpolationScale (Fintype.card V))) → - ((φ.prop64NormalizedLeaves k).map fun (L : ClauseSet V) => - ∑ q : CNF.LeafCandidateQueryIndex V B L.toCNF, treeQueryExam L q).sum ≤ - (2 : ℝ) ^ ((CNF.prop64TotalExamScaleCoeff k : ℝ) * - interpolationScale (Fintype.card V)) := by - obtain ⟨C_B, _, hCB⟩ := CNF.exists_prop64LeafClauseRatio_le_mul_clog_pow hk - obtain ⟨N_row, hN_row16, hrow_rec⟩ := - CNF.exists_branch_schedule_recovery_and_examBound_parityRowSystem_of_le_clog_pow - k C_B (2 * (k - 1)) - obtain ⟨N_gr, hN_gr16, hgreedy_rec⟩ := - CNF.exists_greedy_parityRowSystem_recovery_and_examBound_of_le_clog_pow k C_B (2 * (k - 1)) - obtain ⟨N_q, _, hquery⟩ := CNF.exists_prop64_leafCandidateQueryBound_le_interpolationScale hk - refine ⟨max (2 ^ 640000) (max (max N_row N_gr) N_q), le_max_left _ _, - fun {V _ _} φ hk_φ hcard => ?_⟩ - intro B - have hpow_le : 2 ^ 640000 ≤ Fintype.card V := (le_max_left _ _).trans hcard - have hN_row_le : N_row ≤ Fintype.card V := - (((le_max_left _ _).trans (le_max_left _ _)).trans (le_max_right _ _)).trans hcard - have hN_gr_le : N_gr ≤ Fintype.card V := - (((le_max_right _ _).trans (le_max_left _ _)).trans (le_max_right _ _)).trans hcard - have hNq_le : N_q ≤ Fintype.card V := - ((le_max_right _ _).trans (le_max_right _ _)).trans hcard - have hs2 : 2 ≤ numGroups (Fintype.card V) := two_le_numGroups_of_pow_le hpow_le - have hn1 : 1 ≤ Fintype.card V := le_trans (by decide : 1 ≤ 16384) (hN_row16.trans hN_row_le) - have hn2 : 2 ≤ Fintype.card V := le_trans (by decide : 2 ≤ 16384) (hN_row16.trans hN_row_le) - have hlen_two_pow : - (φ.prop64NormalizedLeaves k).length ≤ - 2 ^ (Fintype.card V / numGroups (Fintype.card V) + 1) := - CNF.length_prop64NormalizedLeaves_le_two_pow hk_φ (by omega) - have hlen_scale : - ((φ.prop64NormalizedLeaves k).length : ℝ) ≤ - (2 : ℝ) ^ (17 * interpolationScale (Fintype.card V)) := - CNF.length_prop64NormalizedLeaves_le_interpolationScale hk_φ hpow_le - have hsum_leaf_queries : ∀ L ∈ φ.prop64NormalizedLeaves k, - ∀ (queryExam : CNF.LeafCandidateQueryIndex V B L.toCNF → ℝ), - (∀ q : CNF.LeafCandidateQueryIndex V B L.toCNF, - queryExam q ≤ - (2 : ℝ) ^ (((CNF.prop64BranchExamScaleCoeff k + 32 : ℕ) : ℝ) * - interpolationScale (Fintype.card V))) → - (∑ q : CNF.LeafCandidateQueryIndex V B L.toCNF, queryExam q) ≤ - (2 : ℝ) ^ ((CNF.prop64LeafQueryExamScaleCoeff k : ℝ) * - interpolationScale (Fintype.card V)) := by - intro L hL queryExam hq_bound - obtain ⟨_, _, _, _, _, hlen_ψ⟩ := CNF.length_le_of_mem_prop64NormalizedLeaves hk_φ hL - have hq_le := hquery L.toCNF hNq_le (hlen_ψ hn1) - have hsum_q := CNF.sum_leafCandidateQueryIndex_le B L.toCNF queryExam (by positivity) hq_bound - calc (∑ q : CNF.LeafCandidateQueryIndex V B L.toCNF, queryExam q) - ≤ (CNF.leafCandidateQueryBound B L.toCNF : ℝ) * - (2 : ℝ) ^ (((CNF.prop64BranchExamScaleCoeff k + 32 : ℕ) : ℝ) * - interpolationScale (Fintype.card V)) := hsum_q - _ ≤ (2 : ℝ) ^ interpolationScale (Fintype.card V) * - (2 : ℝ) ^ (((CNF.prop64BranchExamScaleCoeff k + 32 : ℕ) : ℝ) * - interpolationScale (Fintype.card V)) := - mul_le_mul_of_nonneg hq_le le_rfl (Nat.cast_nonneg _) (by positivity) - _ = (2 : ℝ) ^ ((CNF.prop64LeafQueryExamScaleCoeff k : ℝ) * - interpolationScale (Fintype.card V)) := by - rw [← Real.rpow_add two_pos] - unfold CNF.prop64LeafQueryExamScaleCoeff - push_cast - ring_nf - refine ⟨CNF.sum_modelCountOn_prop64NormalizedLeaves k φ Finset.univ, hs2, - hlen_two_pow, hlen_scale, fun L hL => ?_, fun leafExam hleaf => ?_, - fun treeQueryExam htree => ?_⟩ - · intro ψ D₀ P b₀ - obtain ⟨_, _, _, hk_ψ, _, hlen_ψ⟩ := CNF.length_le_of_mem_prop64NormalizedLeaves hk_φ hL - have hm_ψ : ψ.length ≤ B * Fintype.card V := hlen_ψ hn1 - have hB1 : 1 ≤ B := CNF.one_le_prop64LeafClauseRatio k (Fintype.card V) - have hB_le : B ≤ C_B * Nat.clog 2 (Fintype.card V) ^ (2 * (k - 1)) := - hCB (Fintype.card V) hn2 - have hq_le : - (CNF.leafCandidateQueryBound B ψ : ℝ) ≤ (2 : ℝ) ^ interpolationScale (Fintype.card V) := - hquery ψ hNq_le hm_ψ - obtain ⟨A₀, hlen0, hw0, hgreedy⟩ := hgreedy_rec ψ hk_ψ hN_gr_le hB1 hB_le hm_ψ - refine ⟨hk_ψ, hm_ψ, hq_le, A₀, hlen0, hw0, fun A γ h0 hA hγ => ?_⟩ - obtain ⟨hcount, _⟩ := hgreedy A γ h0 hA hγ - refine ⟨hcount, fun q => ?_, hsum_leaf_queries L hL⟩ - obtain ⟨hlen_q, hw_q⟩ := CNF.candidateQueryRows_length_and_weight_le hlen0 hw0 h0 hA q - refine ⟨hlen_q, hw_q, fun {n'} e => ?_⟩ - exact hrow_rec hk_ψ hN_row_le hm_ψ hB_le le_rfl hw_q hlen_q e - · calc ((φ.prop64NormalizedLeaves k).map leafExam).sum - ≤ ((φ.prop64NormalizedLeaves k).length : ℝ) * - (2 : ℝ) ^ (((CNF.prop64BranchExamScaleCoeff k + 32 : ℕ) : ℝ) * - interpolationScale (Fintype.card V)) := - list_sum_map_le_length_mul _ _ hleaf - _ ≤ (2 : ℝ) ^ (17 * interpolationScale (Fintype.card V)) * - (2 : ℝ) ^ (((CNF.prop64BranchExamScaleCoeff k + 32 : ℕ) : ℝ) * - interpolationScale (Fintype.card V)) := - mul_le_mul_of_nonneg_right hlen_scale (by positivity) - _ = (2 : ℝ) ^ ((CNF.prop64TreeExamScaleCoeff k : ℝ) * - interpolationScale (Fintype.card V)) := by - rw [← Real.rpow_add two_pos] - unfold CNF.prop64TreeExamScaleCoeff - push_cast - ring_nf - · calc ((φ.prop64NormalizedLeaves k).map fun (L : ClauseSet V) => - ∑ q : CNF.LeafCandidateQueryIndex V B L.toCNF, treeQueryExam L q).sum - ≤ ((φ.prop64NormalizedLeaves k).length : ℝ) * - (2 : ℝ) ^ ((CNF.prop64LeafQueryExamScaleCoeff k : ℝ) * - interpolationScale (Fintype.card V)) := - list_sum_map_le_length_mul _ _ fun L hL => - hsum_leaf_queries L hL (treeQueryExam L) (htree L hL) - _ ≤ (2 : ℝ) ^ (17 * interpolationScale (Fintype.card V)) * - (2 : ℝ) ^ ((CNF.prop64LeafQueryExamScaleCoeff k : ℝ) * - interpolationScale (Fintype.card V)) := - mul_le_mul_of_nonneg_right hlen_scale (by positivity) - _ = (2 : ℝ) ^ ((CNF.prop64TotalExamScaleCoeff k : ℝ) * - interpolationScale (Fintype.card V)) := by - rw [← Real.rpow_add two_pos] - unfold CNF.prop64TotalExamScaleCoeff CNF.prop64LeafQueryExamScaleCoeff - push_cast - ring_nf - -private noncomputable def nextGreedyStep [Fintype V] [DecidableEq V] - (φ : CNF V) (P : ℕ) [Nonempty (Fin φ.length)] - (L : List (Fin φ.length → Bool)) : Fin P → Fin φ.length × Bool := - (exists_min_image (univ : Finset (Fin P → Fin φ.length × Bool)) - (fun γ' => commonZeroCount univ (φ.parityRowSystem (L ++ [testRow γ']))) - univ_nonempty).choose - -private theorem nextGreedyStep_le [Fintype V] [DecidableEq V] - (φ : CNF V) (P : ℕ) [Nonempty (Fin φ.length)] - (L : List (Fin φ.length → Bool)) (γ' : Fin P → Fin φ.length × Bool) : - commonZeroCount univ (φ.parityRowSystem (L ++ [testRow (nextGreedyStep φ P L)])) ≤ - commonZeroCount univ (φ.parityRowSystem (L ++ [testRow γ'])) := - (exists_min_image (univ : Finset (Fin P → Fin φ.length × Bool)) - (fun δ => commonZeroCount univ (φ.parityRowSystem (L ++ [testRow δ]))) - univ_nonempty).choose_spec.2 γ' (mem_univ γ') - -private noncomputable def greedyTrajectory [Fintype V] [DecidableEq V] - (φ : CNF V) (P : ℕ) [Nonempty (Fin φ.length)] - (A₀ : List (Fin φ.length → Bool)) : ℕ → List (Fin φ.length → Bool) - | 0 => A₀ - | i + 1 => - let L := greedyTrajectory φ P A₀ i - L ++ [testRow (nextGreedyStep φ P L)] - -/-- **Proposition 6.4 unconditional normalized leaf-to-root `modelCountOn` recovery -and total candidate-indexed `interpolationScale` examination bounds ([OpenAI2026ETH], §6.4, -pp. 43–44 & Appendix A, pp. 44–47):** -For any `k ≥ 2`, there exists `N₃ ≥ 2 ^ 640000` such that for any finite variable type `V` with -`N₃ ≤ Fintype.card V` and any width-`≤ k` CNF `φ : CNF V`: -1. `((φ.prop64NormalizedLeaves k).map fun L => L.toCNF.modelCountOn Finset.univ).sum =` - `φ.modelCountOn Finset.univ`. -2. `2 ≤ numGroups (Fintype.card V)`, - `(φ.prop64NormalizedLeaves k).length ≤ 2 ^ (Fintype.card V / numGroups (Fintype.card V) + 1)`, - and `((φ.prop64NormalizedLeaves k).length : ℝ) ≤` - `(2 : ℝ) ^ (17 * interpolationScale (Fintype.card V))`. -3. Every leaf `L ∈ φ.prop64NormalizedLeaves k` (`ψ := L.toCNF`) unconditionally admits a greedy - parity-row trajectory `A : ℕ → List (Fin ψ.length → Bool)` such that: - - at the final query `q = Sum.inr ()`, - `commonZeroCount univ (ψ.parityRowSystem (CNF.candidateQueryRows A (Sum.inr ()))) =` - `ψ.modelCountOn Finset.univ`, - - at every greedy round `i : Fin (3 * Fintype.card V)` and every ordered candidate list - `γ' : Fin P → Fin ψ.length × Bool`, - `commonZeroCount univ (ψ.parityRowSystem (A (i.1 + 1))) ≤` - `commonZeroCount univ (ψ.parityRowSystem (CNF.candidateQueryRows A (Sum.inl (i, γ'))))`, - - for **every** evaluated query `q : CNF.LeafCandidateQueryIndex V B ψ` (including every - discarded candidate `Sum.inl (i, γ')` as well as `Sum.inr ()`), - `rows := CNF.candidateQueryRows A q` satisfies `rows.length ≤ 6 * Fintype.card V` and - `∀ r ∈ rows, weight r ≤ D₀`, and for any free-variable equivalence `e : ↥(univ \ S) ≃ Fin n'`, - there exist per-branch `hF b` and concrete `ReplacementDesign`s `D b` recovering - `(commonZeroCount univ (ψ.parityRowSystem rows) : ℤ)` (and hence - `(ψ.modelCountOn Finset.univ : ℤ)` at `q = Sum.inr ()`) via - `univariateClearedParityTruncatedSum` with numerator degree - `≤ (k * (rowBound (CNF.prop64ScheduleExponent k) n' - 1)) * (8 * Fintype.card V)` and - single-branch / branch-summed `interpolationScale` examination bounds, and - - any per-query examination family `queryExam : CNF.LeafCandidateQueryIndex V B ψ → ℝ` bounded - by `(2 : ℝ) ^ ((CNF.prop64BranchExamScaleCoeff k + 32) * interpolationScale n)` sums across all - `q : CNF.LeafCandidateQueryIndex V B ψ` to at most - `(2 : ℝ) ^ (CNF.prop64LeafQueryExamScaleCoeff k * interpolationScale n)`. -4. Summing across all leaves in `φ.prop64NormalizedLeaves k` bounds the tree-wide examination count - by `(2 : ℝ) ^ (CNF.prop64TreeExamScaleCoeff k * interpolationScale (Fintype.card V))` and the - total candidate-indexed examination count by - `(2 : ℝ) ^ (CNF.prop64TotalExamScaleCoeff k * interpolationScale (Fintype.card V))`. -/ -theorem CNF.exists_prop64NormalizedLeaves_total_recovery_and_examBound - {k : ℕ} (hk : 2 ≤ k) : - ∃ N₃ : ℕ, 2 ^ 640000 ≤ N₃ ∧ - ∀ {V : Type*} [Fintype V] [DecidableEq V] - (φ : CNF V), - (∀ c ∈ φ, c.length ≤ k) → - N₃ ≤ Fintype.card V → - let B := CNF.prop64LeafClauseRatio k (Fintype.card V) - ((φ.prop64NormalizedLeaves k).map fun L => L.toCNF.modelCountOn Finset.univ).sum = - φ.modelCountOn Finset.univ ∧ - 2 ≤ numGroups (Fintype.card V) ∧ - (φ.prop64NormalizedLeaves k).length ≤ - 2 ^ (Fintype.card V / numGroups (Fintype.card V) + 1) ∧ - ((φ.prop64NormalizedLeaves k).length : ℝ) ≤ - (2 : ℝ) ^ (17 * interpolationScale (Fintype.card V)) ∧ - (∀ L ∈ φ.prop64NormalizedLeaves k, - let ψ := L.toCNF - let D₀ := BitString.initialRowWeightBound B ψ.length - let P := BitString.greedyRowListLength B ψ.length - let b₀ := CNF.parityBranchThreshold k D₀ (Fintype.card V) - (∀ c ∈ ψ, c.length ≤ k) ∧ - ψ.length ≤ B * Fintype.card V ∧ - (CNF.leafCandidateQueryBound B ψ : ℝ) ≤ - (2 : ℝ) ^ interpolationScale (Fintype.card V) ∧ - ∃ A : ℕ → List (Fin ψ.length → Bool), - commonZeroCount univ - (ψ.parityRowSystem (CNF.candidateQueryRows (B := B) A (Sum.inr ()))) = - ψ.modelCountOn Finset.univ ∧ - (∀ (i : Fin (3 * Fintype.card V)) (γ' : Fin P → Fin ψ.length × Bool), - commonZeroCount univ (ψ.parityRowSystem (A (i.1 + 1))) ≤ - commonZeroCount univ - (ψ.parityRowSystem (CNF.candidateQueryRows A (Sum.inl (i, γ'))))) ∧ - (∀ q : CNF.LeafCandidateQueryIndex V B ψ, - let rows := CNF.candidateQueryRows A q - rows.length ≤ 6 * Fintype.card V ∧ - (∀ r ∈ rows, weight r ≤ D₀) ∧ - let S := heavyVars univ (univ : Finset (Fin rows.length)) - (fun j => equationScope (ψ.parityRowSystem rows j)) b₀ - ∀ ⦃n' : ℕ⦄ (e : ↥(univ \ S) ≃ Fin n'), - (Fintype.card V ≤ 2 * n' ∧ n' ≤ Fintype.card V) ∧ - (∃ (hF : ∀ b : V → Bool, - Feasible (CNF.prop64ScheduleExponent k) n' (b₀ + 1) - (max (k * (D₀ * 2 ^ k)) 1) - (∑ f : {j : Fin rows.length // - j ∈ (univ : Finset (Fin rows.length))} ⊕ Fin n', - #(branchAugmentedScope S e univ (ψ.parityRowSystem rows) b f))) - (D : ∀ b : V → Bool, - ReplacementDesign - (branchAugmentedScope S e univ (ψ.parityRowSystem rows) b) - (numNodes n') (numGroups n') - (intervalStart (CNF.prop64ScheduleExponent k) n') - (rowBound (CNF.prop64ScheduleExponent k) n') (tauRat n')), - (commonZeroCount (univ : Finset (Fin rows.length)) - (ψ.parityRowSystem rows) : ℤ) = - (∑ b ∈ branchAssignments S, - ((univariateClearedParityTruncatedSum (univ : Finset (Fin rows.length)) - (ψ.branchParityRowSystem rows S e b) - (commonDenom (numNodes n') - (rowBound (CNF.prop64ScheduleExponent k) n') : ℤ) k - (branchPrecision (Fintype.card V)) - (designReplacementScaledIntMap (D b) - (fun j => Sum.inl ⟨j, mem_univ j⟩))).eval 0 / - clearedProductDenom - (commonDenom (numNodes n') - (rowBound (CNF.prop64ScheduleExponent k) n') : ℤ) k - (branchPrecision (Fintype.card V)) - #(univ : Finset (Fin rows.length))) % - ((2 : ℤ) ^ branchPrecision (Fintype.card V))) ∧ - (∀ b : V → Bool, - (univariateClearedParityTruncatedSum (univ : Finset (Fin rows.length)) - (ψ.branchParityRowSystem rows S e b) - (commonDenom (numNodes n') - (rowBound (CNF.prop64ScheduleExponent k) n') : ℤ) k - (branchPrecision (Fintype.card V)) - (designReplacementScaledIntMap (D b) - (fun j => Sum.inl ⟨j, mem_univ j⟩))).natDegree ≤ - (k * (rowBound (CNF.prop64ScheduleExponent k) n' - 1)) * - (8 * Fintype.card V)) ∧ - ∀ (b : V → Bool) - (s_active : Finset - ({j : Fin rows.length // - j ∈ (univ : Finset (Fin rows.length))} ⊕ Fin n')), - let d := k * (rows.length + 2 * (branchPrecision (Fintype.card V) - 1)) - let q_ord := (d * rowBound (CNF.prop64ScheduleExponent k) n') / numNodes n' - let C := (hF b).toCountingDesign (D b) s_active - (∑ t : Fin (numNodes n'), - (#{p : Finset (Fin n') × Finset (Fin n') | - #p.1 ≤ q_ord ∧ p.2 ⊆ p.1} : ℝ) * - (2 * (#(C.measurementBox t) : ℝ) * - ∑ g : Fin (numGroups n'), - (Fintype.card (C.LocalCube t g) : ℝ))) ≤ - (2 : ℝ) ^ ((CNF.prop64BranchExamScaleCoeff k : ℝ) * - interpolationScale (Fintype.card V))) ∧ - ∀ (examSum : (V → Bool) → ℝ), - (∀ b ∈ branchAssignments S, - examSum b ≤ - (2 : ℝ) ^ ((CNF.prop64BranchExamScaleCoeff k : ℝ) * - interpolationScale (Fintype.card V))) → - (∑ b ∈ branchAssignments S, examSum b) ≤ - (2 : ℝ) ^ (((CNF.prop64BranchExamScaleCoeff k + 32 : ℕ) : ℝ) * - interpolationScale (Fintype.card V))) ∧ - ∀ (queryExam : CNF.LeafCandidateQueryIndex V B ψ → ℝ), - (∀ q : CNF.LeafCandidateQueryIndex V B ψ, - queryExam q ≤ - (2 : ℝ) ^ (((CNF.prop64BranchExamScaleCoeff k + 32 : ℕ) : ℝ) * - interpolationScale (Fintype.card V))) → - (∑ q : CNF.LeafCandidateQueryIndex V B ψ, queryExam q) ≤ - (2 : ℝ) ^ ((CNF.prop64LeafQueryExamScaleCoeff k : ℝ) * - interpolationScale (Fintype.card V))) ∧ - (∀ (leafExam : ClauseSet V → ℝ), - (∀ L ∈ φ.prop64NormalizedLeaves k, - leafExam L ≤ - (2 : ℝ) ^ (((CNF.prop64BranchExamScaleCoeff k + 32 : ℕ) : ℝ) * - interpolationScale (Fintype.card V))) → - ((φ.prop64NormalizedLeaves k).map leafExam).sum ≤ - (2 : ℝ) ^ ((CNF.prop64TreeExamScaleCoeff k : ℝ) * - interpolationScale (Fintype.card V))) ∧ - ∀ (treeQueryExam : (L : ClauseSet V) → CNF.LeafCandidateQueryIndex V B L.toCNF → ℝ), - (∀ L ∈ φ.prop64NormalizedLeaves k, ∀ q : CNF.LeafCandidateQueryIndex V B L.toCNF, - treeQueryExam L q ≤ - (2 : ℝ) ^ (((CNF.prop64BranchExamScaleCoeff k + 32 : ℕ) : ℝ) * - interpolationScale (Fintype.card V))) → - ((φ.prop64NormalizedLeaves k).map fun (L : ClauseSet V) => - ∑ q : CNF.LeafCandidateQueryIndex V B L.toCNF, treeQueryExam L q).sum ≤ - (2 : ℝ) ^ ((CNF.prop64TotalExamScaleCoeff k : ℝ) * - interpolationScale (Fintype.card V)) := by - obtain ⟨C_B, _, hCB⟩ := CNF.exists_prop64LeafClauseRatio_le_mul_clog_pow hk - obtain ⟨N_row, hN_row16, hrow_rec⟩ := - CNF.exists_branch_schedule_recovery_and_examBound_parityRowSystem_of_le_clog_pow - k C_B (2 * (k - 1)) - obtain ⟨N₃, hN₃, hgreedy_total⟩ := - CNF.exists_prop64NormalizedLeaves_greedy_total_recovery_and_examBound hk - refine ⟨max N₃ N_row, le_trans hN₃ (le_max_left _ _), - fun {V _ _} φ hk_φ hcard => ?_⟩ - intro B - have hN₃_le : N₃ ≤ Fintype.card V := (le_max_left _ _).trans hcard - have hN_row_le : N_row ≤ Fintype.card V := (le_max_right _ _).trans hcard - have hn2 : 2 ≤ Fintype.card V := le_trans (by decide : 2 ≤ 16384) (hN_row16.trans hN_row_le) - obtain ⟨hsum, hs2, hlen_pow, hlen_scale, hleaf, htree, htotal⟩ := hgreedy_total φ hk_φ hN₃_le - refine ⟨hsum, hs2, hlen_pow, hlen_scale, fun L hL => ?_, htree, htotal⟩ - intro ψ D₀ P b₀ - obtain ⟨hk_ψ, hm_ψ, hq_le, A₀, hlen0, hw0, hgreedy⟩ := hleaf L hL - refine ⟨hk_ψ, hm_ψ, hq_le, ?_⟩ - rcases Nat.eq_zero_or_pos ψ.length with hlen_zero | hlen_pos - · have hnil : ψ = [] := List.eq_nil_of_length_eq_zero hlen_zero - let A : ℕ → List (Fin ψ.length → Bool) := fun _ => [] - have hcount_nil : - commonZeroCount univ (ψ.parityRowSystem (CNF.candidateQueryRows (B := B) A (Sum.inr ()))) = - ψ.modelCountOn Finset.univ := by - change commonZeroCount univ (ψ.parityRowSystem []) = ψ.modelCountOn Finset.univ - rw [CNF.commonZeroCount_parityRowSystem_eq_modelCountOn_add] - suffices #{σ : V → Bool | ψ.eval σ = false ∧ PassesTests ψ.violations [] σ} = 0 by omega - rw [card_eq_zero, filter_eq_empty_iff] - intro σ _ ⟨hev, _⟩ - rw [hnil] at hev - exact Bool.noConfusion hev - have hB1 : 1 ≤ B := CNF.one_le_prop64LeafClauseRatio k (Fintype.card V) - have hP_pos : 0 < P := by - change 0 < 20000 * B ^ 2 * (Nat.log 2 ψ.length + 1) ^ 2 - positivity - have hmin_vac : ∀ (i : Fin (3 * Fintype.card V)) (γ' : Fin P → Fin ψ.length × Bool), - commonZeroCount univ (ψ.parityRowSystem (A (i.1 + 1))) ≤ - commonZeroCount univ - (ψ.parityRowSystem (CNF.candidateQueryRows A (Sum.inl (i, γ')))) := by - intro _ γ' - exact Fin.elim0 (hlen_zero ▸ (γ' ⟨0, hP_pos⟩).1) - have hB_le : B ≤ C_B * Nat.clog 2 (Fintype.card V) ^ (2 * (k - 1)) := - hCB (Fintype.card V) hn2 - refine ⟨A, hcount_nil, hmin_vac, fun q => ?_, fun queryExam hq_bound => ?_⟩ - · have hlen_q : (CNF.candidateQueryRows A q).length ≤ 6 * Fintype.card V := - CNF.length_candidateQueryRows_le_of_step (fun _ _ => Nat.zero_le _) q - have hw_q : ∀ r ∈ CNF.candidateQueryRows A q, weight r ≤ D₀ := - CNF.weight_mem_candidateQueryRows_le_of_step (by intro _ _ _ hr; cases hr) q - exact ⟨hlen_q, hw_q, fun {n'} e => - hrow_rec hk_ψ hN_row_le hm_ψ hB_le le_rfl hw_q hlen_q e⟩ - · have hsum_q := CNF.sum_leafCandidateQueryIndex_le B ψ queryExam (by positivity) hq_bound - calc (∑ q : CNF.LeafCandidateQueryIndex V B ψ, queryExam q) - ≤ (CNF.leafCandidateQueryBound B ψ : ℝ) * - (2 : ℝ) ^ (((CNF.prop64BranchExamScaleCoeff k + 32 : ℕ) : ℝ) * - interpolationScale (Fintype.card V)) := hsum_q - _ ≤ (2 : ℝ) ^ interpolationScale (Fintype.card V) * - (2 : ℝ) ^ (((CNF.prop64BranchExamScaleCoeff k + 32 : ℕ) : ℝ) * - interpolationScale (Fintype.card V)) := - mul_le_mul_of_nonneg hq_le le_rfl (Nat.cast_nonneg _) (by positivity) - _ = (2 : ℝ) ^ ((CNF.prop64LeafQueryExamScaleCoeff k : ℝ) * - interpolationScale (Fintype.card V)) := by - rw [← Real.rpow_add two_pos] - unfold CNF.prop64LeafQueryExamScaleCoeff - push_cast - ring_nf - · have : Nonempty (Fin ψ.length) := ⟨⟨0, hlen_pos⟩⟩ - let A := greedyTrajectory ψ P A₀ - let γ : ℕ → Fin P → Fin ψ.length × Bool := fun i => nextGreedyStep ψ P (A i) - have hmin : ∀ i (γ' : Fin P → Fin ψ.length × Bool), - commonZeroCount univ (ψ.parityRowSystem (A i ++ [testRow (γ i)])) ≤ - commonZeroCount univ (ψ.parityRowSystem (A i ++ [testRow γ'])) := - fun i γ' => nextGreedyStep_le ψ P (A i) γ' - obtain ⟨hcount, hq_all, hq_sum⟩ := hgreedy A γ rfl (fun _ => rfl) hmin - exact ⟨A, hcount, fun i γ' => hmin i.1 γ', hq_all, hq_sum⟩ - -end Cslib.Logic.PL diff --git a/Complexity/Computability/Complexity/FineGrained/GeneralCNFHermiteRecovery.lean b/Complexity/Computability/Complexity/FineGrained/GeneralCNFHermiteRecovery.lean deleted file mode 100644 index 9e80c930ad..0000000000 --- a/Complexity/Computability/Complexity/FineGrained/GeneralCNFHermiteRecovery.lean +++ /dev/null @@ -1,1062 +0,0 @@ -/- -Copyright (c) 2026 Samuel Schlesinger. All rights reserved. -Released under Apache 2.0 license as described in the file LICENSE. -Authors: Samuel Schlesinger --/ - -module --- upstream: candidate - -public import Complexity.Init -public import Complexity.Computability.Complexity.FineGrained.GeneralCNFCountingAsymptotics -public import Complexity.Foundations.BooleanAnalysis.SparseHermiteJetRecovery - -/-! -# Stage-1/Stage-2 `clearedParityJetTable` and Hermite–Cramer recovery across Section 6.3/6.4 - -This module connects the Stage-1/Stage-2 `JetTable` bridge and unconditional Hermite–Cramer -determinant recovery (`Complexity.Foundations.BooleanAnalysis.SparseHermiteJetRecovery`) with the -Section 6.3 compiled CNF parity-row schedule -(`Complexity.Computability.Complexity.FineGrained.GeneralCNFBranchSchedule`) and the Section 6.4 -Proposition 6.4 tree-wide candidate-indexed recovery and examination bounds -(`Complexity.Computability.Complexity.FineGrained.GeneralCNFCountingAsymptotics`) of -[OpenAI, *The Exponential Time Hypothesis is False*][OpenAI2026ETH] (Sections 5.4–5.5, 6.1–6.4, -and Appendices A–B, printed pp. 37–50): - -1. **Shared parity-system recovery (Appendix B.2–B.3, printed pp. 48–50):** - `Complexity.Foundations.BooleanAnalysis.SparseHermiteJetRecovery` supplies the generic - `Cslib.BitString` coordinate and arbitrary-finite-type branch recovery lemmas. This module - publicly imports that API and specializes it to CNF parity-row systems below. - -2. **Section 6.3 compiled CNF parity-row schedule Hermite–Cramer and `clearedParityJetTable` - recovery with `interpolationScale` examination bounds (`Cslib.Logic.PL.CNF`, pp. 38–43, 48–50):** - - `CNF.commonZeroCount_parityRowSystem_eq_sum_branch_hermiteCramerNumerator_design`, - `CNF.numPassing_eq_sum_branch_hermiteCramerNumerator_design`, - `CNF.commonZeroCount_parityRowSystem_eq_sum_branch_clearedParityJetTable_design`, and - `CNF.numPassing_eq_sum_branch_clearedParityJetTable_design`: specialize both Hermite–Cramer - recovery forms to `φ.branchParityRowSystem rows S e b` across `b ∈ branchAssignments S`. - - `CNF.exists_branch_schedule_hermiteCramer_and_examBound_parityRowSystem_of_le_clog_pow`, - `CNF.exists_greedy_parityRowSystem_hermiteCramer_recovery_and_examBound_of_le_clog_pow`, and - `CNF.exists_parityRowSystem_modelCountOn_hermiteCramer_recovery_and_examBound_of_le_clog_pow`: - certify that the Lemma 4.8 per-branch `ReplacementDesign` family `D b` at - `b₀ = CNF.parityBranchThreshold k W (Fintype.card V)` and `β = 2 * β_B + 5` has positive node - count `0 < numNodes n'` and simultaneously recovers - `commonZeroCount univ (φ.parityRowSystem rows)` (and `φ.modelCountOn Finset.univ` after - `3 * n` greedy rounds) via **both** explicit Hermite–Cramer truncated-sum determinants and - Stage-1/Stage-2 `clearedParityJetTable` coordinate sums at `nodeInt` and canonical jet order - `J = sparseParityJetOrder k (rowBound (2 * β_B + 5) n') (numNodes n') rows.length ℓ`, while - satisfying the univariate degree bound and the per-branch / branch-summed - `2 ^ (A * interpolationScale (Fintype.card V))` domain-examination bounds. - -3. **Proposition 6.4 tree-wide candidate-indexed Hermite–Cramer & `clearedParityJetTable` recovery - and total examination bounds (`Cslib.Logic.PL.CNF`, §6.4 & Appendices A–B, pp. 43–50):** - - `CNF.exists_prop64NormalizedLeaves_greedy_total_hermiteCramer_recovery_and_examBound` and - `CNF.exists_prop64NormalizedLeaves_total_hermiteCramer_recovery_and_examBound`: for any - `k ≥ 2`, there exists `N₃ ≥ 2 ^ 640000` such that for any finite variable type `V` with - `N₃ ≤ Fintype.card V` and any width-`≤ k` CNF `φ : CNF V`, on every normalized leaf - `L ∈ φ.prop64NormalizedLeaves k` (`ψ := L.toCNF`) and every candidate query - `q : CNF.LeafCandidateQueryIndex V B ψ` (covering all `3 * n` greedy stages and all ordered - candidate lists `γ'` with list multiplicity, including discarded candidates, plus the final - query `Sum.inr ()`), the certified per-branch `ReplacementDesign` family `D q b` recovers - `commonZeroCount univ (ψ.parityRowSystem (CNF.candidateQueryRows A q))` via **both** explicit - Hermite–Cramer truncated-sum determinants and Stage-1/Stage-2 `clearedParityJetTable` - coordinate sums at `nodeInt` and canonical jet order `sparseParityJetOrder`, while satisfying - the per-query (`≤ 2 ^ ((CNF.prop64BranchExamScaleCoeff k + 32) * interpolationScale n)`), - per-leaf candidate-summed - (`≤ 2 ^ (CNF.prop64LeafQueryExamScaleCoeff k * interpolationScale n)`), - and tree-wide candidate-summed - (`≤ 2 ^ (CNF.prop64TotalExamScaleCoeff k * interpolationScale n)`) - domain-examination bounds. - -## Main results - -* `Cslib.Logic.PL.CNF.commonZeroCount_parityRowSystem_eq_sum_branch_hermiteCramerNumerator_design`, - `Cslib.Logic.PL.CNF.numPassing_eq_sum_branch_hermiteCramerNumerator_design`, - `Cslib.Logic.PL.CNF.commonZeroCount_parityRowSystem_eq_sum_branch_clearedParityJetTable_design`, - `Cslib.Logic.PL.CNF.numPassing_eq_sum_branch_clearedParityJetTable_design` -* `CNF.exists_branch_schedule_hermiteCramer_and_examBound_parityRowSystem_of_le_clog_pow`, - `CNF.exists_greedy_parityRowSystem_hermiteCramer_recovery_and_examBound_of_le_clog_pow`, - `CNF.exists_parityRowSystem_modelCountOn_hermiteCramer_recovery_and_examBound_of_le_clog_pow` -* `CNF.exists_prop64NormalizedLeaves_greedy_total_hermiteCramer_recovery_and_examBound`, - `CNF.exists_prop64NormalizedLeaves_total_hermiteCramer_recovery_and_examBound` - -## References - -* [OpenAI, *The Exponential Time Hypothesis is False*][OpenAI2026ETH] - (Sections 5.4–5.5, pp. 38–39; Sections 6.1–6.4, pp. 39–44; Appendices A–B, pp. 44–50) --/ - -@[expose] public noncomputable section - -open Finset Polynomial -open scoped BigOperators - -/-! ### 2. Section 6.3 CNF parity-row schedule Hermite–Cramer & `clearedParityJetTable` recovery -/ - -namespace Cslib.Logic.PL - -open Cslib.BitString -open Cslib.LinearAlgebra -open Cslib.Logic.PL.ClauseSet.Sparsification -open Cslib.Complexity.SubexponentialSAT -open Cslib.Complexity.SubexponentialSAT.ReplacementParams - -variable {V : Type*} - -section CNFDeterminantRecovery - -variable [Fintype V] [DecidableEq V] {n' Q r A₀ R : ℕ} {τ : ℚ} - -/-- **§5.4–5.5 & §6.3 branch-summed Hermite–Cramer truncated-sum recovery of `commonZeroCount` on -`φ.parityRowSystem rows`**: when every clause of `φ` has width at most `k` and `0 < Q`, summing the -per-branch `hermiteCramerNumerator` quotients of `univariateClearedParityTruncatedSum` at `nodeInt` -and canonical jet order `J = sparseParityJetOrder k R Q #(univ : Finset (Fin rows.length)) ℓ` -across `b ∈ branchAssignments S` recovers `commonZeroCount univ (φ.parityRowSystem rows)`. -/ -theorem CNF.commonZeroCount_parityRowSystem_eq_sum_branch_hermiteCramerNumerator_design - {F : (V → Bool) → Type*} [∀ b, Fintype (F b)] {φ : CNF V} {k : ℕ} - (hk : ∀ c ∈ φ, c.length ≤ k) (rows : List (Fin φ.length → Bool)) - (S : Finset V) (e : ↥(univ \ S) ≃ Fin n') - (scope : (b : V → Bool) → F b → Finset (Fin n')) - (D : (b : V → Bool) → ReplacementDesign (scope b) Q r A₀ R τ) - (emb : (b : V → Bool) → Fin rows.length → F b) (hQ : 0 < Q) : - let ℓ := branchPrecision (Fintype.card V) - let J := sparseParityJetOrder k R Q #(univ : Finset (Fin rows.length)) ℓ - (commonZeroCount (univ : Finset (Fin rows.length)) (φ.parityRowSystem rows) : ℤ) = - ∑ b ∈ branchAssignments S, - (hermiteCramerNumerator (nodeInt (Q := Q)) hQ - (sparseParityJetOrder_pos k R Q #(univ : Finset (Fin rows.length)) ℓ) - (fun t j => - (Polynomial.taylor (nodeInt t) - (univariateClearedParityTruncatedSum (univ : Finset (Fin rows.length)) - (φ.branchParityRowSystem rows S e b) (commonDenom Q R : ℤ) k ℓ - (designReplacementScaledIntMap (D b) (emb b)))).coeff j) / - (clearedProductDenom (commonDenom Q R : ℤ) k ℓ #(univ : Finset (Fin rows.length)) * - (Polynomial.hermiteMatrix (nodeInt (Q := Q)) J).det)) % ((2 : ℤ) ^ ℓ) := - commonZeroCount_eq_sum_branch_hermiteCramerNumerator_design_of_fintype S e - (univ : Finset (Fin rows.length)) (φ.parityRowSystem rows) scope D emb hQ - (fun j _ _M hM => CNF.card_mem_parityRowSystem_le hk rows j hM) - -/-- **§5.4–5.5 & §6.3 branch-summed Hermite–Cramer truncated-sum recovery of `numPassing`**: -under the same hypotheses, the branch-summed `hermiteCramerNumerator` quotients recover -`numPassing φ.violations rows`. -/ -theorem CNF.numPassing_eq_sum_branch_hermiteCramerNumerator_design - {F : (V → Bool) → Type*} [∀ b, Fintype (F b)] {φ : CNF V} {k : ℕ} - (hk : ∀ c ∈ φ, c.length ≤ k) (rows : List (Fin φ.length → Bool)) - (S : Finset V) (e : ↥(univ \ S) ≃ Fin n') - (scope : (b : V → Bool) → F b → Finset (Fin n')) - (D : (b : V → Bool) → ReplacementDesign (scope b) Q r A₀ R τ) - (emb : (b : V → Bool) → Fin rows.length → F b) (hQ : 0 < Q) : - let ℓ := branchPrecision (Fintype.card V) - let J := sparseParityJetOrder k R Q #(univ : Finset (Fin rows.length)) ℓ - (numPassing φ.violations rows : ℤ) = - ∑ b ∈ branchAssignments S, - (hermiteCramerNumerator (nodeInt (Q := Q)) hQ - (sparseParityJetOrder_pos k R Q #(univ : Finset (Fin rows.length)) ℓ) - (fun t j => - (Polynomial.taylor (nodeInt t) - (univariateClearedParityTruncatedSum (univ : Finset (Fin rows.length)) - (φ.branchParityRowSystem rows S e b) (commonDenom Q R : ℤ) k ℓ - (designReplacementScaledIntMap (D b) (emb b)))).coeff j) / - (clearedProductDenom (commonDenom Q R : ℤ) k ℓ #(univ : Finset (Fin rows.length)) * - (Polynomial.hermiteMatrix (nodeInt (Q := Q)) J).det)) % ((2 : ℤ) ^ ℓ) := by - rw [← CNF.commonZeroCount_parityRowSystem] - exact CNF.commonZeroCount_parityRowSystem_eq_sum_branch_hermiteCramerNumerator_design hk rows S e - scope D emb hQ - -/-- **§5.4–5.5, §6.3 & Appendix B.2–B.3 branch-summed Stage-1/Stage-2 `clearedParityJetTable` -Hermite–Cramer coordinate recovery of `commonZeroCount` on `φ.parityRowSystem rows`**: under the -same hypotheses, summing the coordinate Cramer quotients of `clearedParityJetTable` over -`s : Fin ℓ` modulo `2 ^ ℓ` on each branch and summing across `b ∈ branchAssignments S` recovers -`commonZeroCount univ (φ.parityRowSystem rows)`. -/ -theorem CNF.commonZeroCount_parityRowSystem_eq_sum_branch_clearedParityJetTable_design - {F : (V → Bool) → Type*} [∀ b, Fintype (F b)] {φ : CNF V} {k : ℕ} - (hk : ∀ c ∈ φ, c.length ≤ k) (rows : List (Fin φ.length → Bool)) - (S : Finset V) (e : ↥(univ \ S) ≃ Fin n') - (scope : (b : V → Bool) → F b → Finset (Fin n')) - (D : (b : V → Bool) → ReplacementDesign (scope b) Q r A₀ R τ) - (emb : (b : V → Bool) → Fin rows.length → F b) (hQ : 0 < Q) : - let ℓ := branchPrecision (Fintype.card V) - let J := sparseParityJetOrder k R Q #(univ : Finset (Fin rows.length)) ℓ - (commonZeroCount (univ : Finset (Fin rows.length)) (φ.parityRowSystem rows) : ℤ) = - ∑ b ∈ branchAssignments S, - (∑ s : Fin ℓ, - hermiteCramerNumerator (nodeInt (Q := Q)) hQ - (sparseParityJetOrder_pos k R Q #(univ : Finset (Fin rows.length)) ℓ) - (fun t j => - clearedParityJetTable (univ : Finset (Fin rows.length)) - (φ.branchParityRowSystem rows S e b) (commonDenom Q R : ℤ) k ℓ J - (designReplacementScaledIntMap (D b) (emb b)) (nodeInt t) j s) / - (clearedProductDenom (commonDenom Q R : ℤ) k ℓ #(univ : Finset (Fin rows.length)) * - (Polynomial.hermiteMatrix (nodeInt (Q := Q)) J).det)) % ((2 : ℤ) ^ ℓ) := - commonZeroCount_eq_sum_branch_clearedParityJetTable_design S e - (univ : Finset (Fin rows.length)) (φ.parityRowSystem rows) scope D emb hQ - (fun j _ _M hM => CNF.card_mem_parityRowSystem_le hk rows j hM) - -/-- **§5.4–5.5, §6.3 & Appendix B.2–B.3 branch-summed Stage-1/Stage-2 `clearedParityJetTable` -Hermite–Cramer coordinate recovery of `numPassing`**: under the same hypotheses, the branch-summed -coordinate Cramer quotients of `clearedParityJetTable` recover `numPassing φ.violations rows`. -/ -theorem CNF.numPassing_eq_sum_branch_clearedParityJetTable_design - {F : (V → Bool) → Type*} [∀ b, Fintype (F b)] {φ : CNF V} {k : ℕ} - (hk : ∀ c ∈ φ, c.length ≤ k) (rows : List (Fin φ.length → Bool)) - (S : Finset V) (e : ↥(univ \ S) ≃ Fin n') - (scope : (b : V → Bool) → F b → Finset (Fin n')) - (D : (b : V → Bool) → ReplacementDesign (scope b) Q r A₀ R τ) - (emb : (b : V → Bool) → Fin rows.length → F b) (hQ : 0 < Q) : - let ℓ := branchPrecision (Fintype.card V) - let J := sparseParityJetOrder k R Q #(univ : Finset (Fin rows.length)) ℓ - (numPassing φ.violations rows : ℤ) = - ∑ b ∈ branchAssignments S, - (∑ s : Fin ℓ, - hermiteCramerNumerator (nodeInt (Q := Q)) hQ - (sparseParityJetOrder_pos k R Q #(univ : Finset (Fin rows.length)) ℓ) - (fun t j => - clearedParityJetTable (univ : Finset (Fin rows.length)) - (φ.branchParityRowSystem rows S e b) (commonDenom Q R : ℤ) k ℓ J - (designReplacementScaledIntMap (D b) (emb b)) (nodeInt t) j s) / - (clearedProductDenom (commonDenom Q R : ℤ) k ℓ #(univ : Finset (Fin rows.length)) * - (Polynomial.hermiteMatrix (nodeInt (Q := Q)) J).det)) % ((2 : ℤ) ^ ℓ) := by - rw [← CNF.commonZeroCount_parityRowSystem] - exact CNF.commonZeroCount_parityRowSystem_eq_sum_branch_clearedParityJetTable_design hk rows S e - scope D emb hQ - -end CNFDeterminantRecovery - -/-- Helper: any `Feasible β n b w M` instance implies `0 < numNodes n`. -/ -theorem _root_.Cslib.Complexity.SubexponentialSAT.ReplacementParams.Feasible.numNodes_pos - {β n b w M : ℕ} (hF : Feasible β n b w M) : - 0 < numNodes n := by - have hR := hF.thirtyTwo_le_rowBound - have hQ := hF.six_mul_rowBound_le_numNodes - omega - -/-- **Unified Section 6.3 schedule feasibility, Hermite–Cramer & `clearedParityJetTable` recovery, -degree bound, and `2 ^ (A * interpolationScale n)` examination bound for `CNF.parityRowSystem` -([OpenAI2026ETH], §§5.4–5.5, 6.3, and Appendix B.2–B.3, printed pp. 38–43, 48–50):** -For any `k C_B β_B : ℕ`, at the threshold `N₁ ≥ 16384` of -`CNF.exists_branch_schedule_recovery_and_examBound_parityRowSystem_of_le_clog_pow k C_B β_B`, -whenever `∀ c ∈ φ, c.length ≤ k`, `N₁ ≤ Fintype.card V`, `φ.length ≤ B * Fintype.card V`, -`B ≤ C_B * Nat.clog 2 (Fintype.card V) ^ β_B`, `W ≤ BitString.initialRowWeightBound B φ.length`, -`∀ r ∈ rows, weight r ≤ W`, and `rows.length ≤ 6 * Fintype.card V`, at -`b₀ = CNF.parityBranchThreshold k W (Fintype.card V)` and `β = 2 * β_B + 5`, for any -free-variable equivalence `e : ↥(univ \ S) ≃ Fin n'`, there exist `hQ : 0 < numNodes n'`, -per-branch feasibility proofs `hF b`, and concrete `ReplacementDesign`s `D b` such that at shared -precision `ℓ = branchPrecision (Fintype.card V)` and canonical jet order -`J = sparseParityJetOrder k (rowBound (2 * β_B + 5) n') (numNodes n')` -`#(univ : Finset (Fin rows.length)) ℓ`: -1. `(commonZeroCount univ (φ.parityRowSystem rows) : ℤ)` equals the branch-summed Hermite–Cramer - truncated-sum determinant residue at `nodeInt` and jet order `J`. -2. `(commonZeroCount univ (φ.parityRowSystem rows) : ℤ)` ALSO equals the branch-summed - Stage-1/Stage-2 `clearedParityJetTable` coordinate Hermite–Cramer residue over `s : Fin ℓ` at - `nodeInt` and jet order `J` (Appendix B.2–B.3, eq. `(B.1)`). -3. Every branch polynomial has - `natDegree ≤ (k * (rowBound (2 * β_B + 5) n' - 1)) * (8 * Fintype.card V)`. -4. Every branch `b : V → Bool` has domain-examination count at most - `(2 : ℝ) ^ ((CNF.parityBranchExamScaleCoeff k β_B : ℝ) * interpolationScale (Fintype.card V))`, - and any per-branch examination family bounded by that quantity sums across `branchAssignments S` - to at most `(2 : ℝ) ^ (((CNF.parityBranchExamScaleCoeff k β_B + 32 : ℕ) : ℝ) *` - `interpolationScale (Fintype.card V))`. -/ -theorem CNF.exists_branch_schedule_hermiteCramer_and_examBound_parityRowSystem_of_le_clog_pow - (k C_B β_B : ℕ) : - ∃ N₁ : ℕ, 16384 ≤ N₁ ∧ - ∀ {V : Type*} [Fintype V] [DecidableEq V] - {φ : CNF V} ⦃n' B W : ℕ⦄, - (∀ c ∈ φ, c.length ≤ k) → - N₁ ≤ Fintype.card V → - φ.length ≤ B * Fintype.card V → - B ≤ C_B * Nat.clog 2 (Fintype.card V) ^ β_B → - W ≤ BitString.initialRowWeightBound B φ.length → - ∀ {rows : List (Fin φ.length → Bool)}, - (∀ r ∈ rows, weight r ≤ W) → - rows.length ≤ 6 * Fintype.card V → - let b₀ := CNF.parityBranchThreshold k W (Fintype.card V) - let S := heavyVars univ (univ : Finset (Fin rows.length)) - (fun j => equationScope (φ.parityRowSystem rows j)) b₀ - ∀ (e : ↥(univ \ S) ≃ Fin n'), - (Fintype.card V ≤ 2 * n' ∧ n' ≤ Fintype.card V) ∧ - (∃ (hQ : 0 < numNodes n') - (hF : ∀ b : V → Bool, - Feasible (2 * β_B + 5) n' (b₀ + 1) (max (k * (W * 2 ^ k)) 1) - (∑ f : {j : Fin rows.length // j ∈ (univ : Finset (Fin rows.length))} ⊕ Fin n', - #(branchAugmentedScope S e univ (φ.parityRowSystem rows) b f))) - (D : ∀ b : V → Bool, - ReplacementDesign - (branchAugmentedScope S e univ (φ.parityRowSystem rows) b) - (numNodes n') (numGroups n') (intervalStart (2 * β_B + 5) n') - (rowBound (2 * β_B + 5) n') (tauRat n')), - let ℓ := branchPrecision (Fintype.card V) - let J := sparseParityJetOrder k (rowBound (2 * β_B + 5) n') (numNodes n') - #(univ : Finset (Fin rows.length)) ℓ - (commonZeroCount (univ : Finset (Fin rows.length)) (φ.parityRowSystem rows) : ℤ) = - (∑ b ∈ branchAssignments S, - (hermiteCramerNumerator (nodeInt (Q := numNodes n')) hQ - (sparseParityJetOrder_pos k (rowBound (2 * β_B + 5) n') (numNodes n') - #(univ : Finset (Fin rows.length)) ℓ) - (fun t j => - (Polynomial.taylor (nodeInt t) - (univariateClearedParityTruncatedSum (univ : Finset (Fin rows.length)) - (φ.branchParityRowSystem rows S e b) - (commonDenom (numNodes n') (rowBound (2 * β_B + 5) n') : ℤ) k ℓ - (designReplacementScaledIntMap (D b) - (fun j => Sum.inl ⟨j, mem_univ j⟩)))).coeff j) / - (clearedProductDenom - (commonDenom (numNodes n') (rowBound (2 * β_B + 5) n') : ℤ) k ℓ - #(univ : Finset (Fin rows.length)) * - (Polynomial.hermiteMatrix (nodeInt (Q := numNodes n')) J).det)) % - ((2 : ℤ) ^ ℓ)) ∧ - (commonZeroCount (univ : Finset (Fin rows.length)) (φ.parityRowSystem rows) : ℤ) = - (∑ b ∈ branchAssignments S, - (∑ s : Fin ℓ, - hermiteCramerNumerator (nodeInt (Q := numNodes n')) hQ - (sparseParityJetOrder_pos k (rowBound (2 * β_B + 5) n') (numNodes n') - #(univ : Finset (Fin rows.length)) ℓ) - (fun t j => - clearedParityJetTable (univ : Finset (Fin rows.length)) - (φ.branchParityRowSystem rows S e b) - (commonDenom (numNodes n') (rowBound (2 * β_B + 5) n') : ℤ) k ℓ J - (designReplacementScaledIntMap (D b) - (fun j => Sum.inl ⟨j, mem_univ j⟩)) (nodeInt t) j s) / - (clearedProductDenom - (commonDenom (numNodes n') (rowBound (2 * β_B + 5) n') : ℤ) k ℓ - #(univ : Finset (Fin rows.length)) * - (Polynomial.hermiteMatrix (nodeInt (Q := numNodes n')) J).det)) % - ((2 : ℤ) ^ ℓ)) ∧ - (∀ b : V → Bool, - (univariateClearedParityTruncatedSum (univ : Finset (Fin rows.length)) - (φ.branchParityRowSystem rows S e b) - (commonDenom (numNodes n') (rowBound (2 * β_B + 5) n') : ℤ) k ℓ - (designReplacementScaledIntMap (D b) - (fun j => Sum.inl ⟨j, mem_univ j⟩))).natDegree ≤ - (k * (rowBound (2 * β_B + 5) n' - 1)) * (8 * Fintype.card V)) ∧ - ∀ (b : V → Bool) - (s_active : Finset - ({j : Fin rows.length // j ∈ (univ : Finset (Fin rows.length))} ⊕ Fin n')), - let d := k * (rows.length + 2 * (branchPrecision (Fintype.card V) - 1)) - let q := (d * rowBound (2 * β_B + 5) n') / numNodes n' - let C := (hF b).toCountingDesign (D b) s_active - (∑ t : Fin (numNodes n'), - (#{p : Finset (Fin n') × Finset (Fin n') | #p.1 ≤ q ∧ p.2 ⊆ p.1} : ℝ) * - (2 * (#(C.measurementBox t) : ℝ) * - ∑ g : Fin (numGroups n'), (Fintype.card (C.LocalCube t g) : ℝ))) ≤ - (2 : ℝ) ^ ((CNF.parityBranchExamScaleCoeff k β_B : ℝ) * - interpolationScale (Fintype.card V))) ∧ - ∀ (examSum : (V → Bool) → ℝ), - (∀ b ∈ branchAssignments S, - examSum b ≤ - (2 : ℝ) ^ ((CNF.parityBranchExamScaleCoeff k β_B : ℝ) * - interpolationScale (Fintype.card V))) → - (∑ b ∈ branchAssignments S, examSum b) ≤ - (2 : ℝ) ^ (((CNF.parityBranchExamScaleCoeff k β_B + 32 : ℕ) : ℝ) * - interpolationScale (Fintype.card V)) := by - obtain ⟨N₁, hN₁, hrec⟩ := - CNF.exists_branch_schedule_recovery_and_examBound_parityRowSystem_of_le_clog_pow k C_B β_B - refine ⟨N₁, hN₁, fun {V _ _ φ n' B W} hk hcard hm hB hW_bound {rows} hW hlen => ?_⟩ - intro b₀ S e - obtain ⟨hn_bounds, ⟨hF, D, _, hdeg, hexam⟩, hsum⟩ := - hrec hk hcard hm hB hW_bound hW hlen e - have hQ : 0 < numNodes n' := (hF (fun _ => false)).numNodes_pos - refine ⟨hn_bounds, ⟨hQ, hF, D, ?_, ?_, hdeg, hexam⟩, hsum⟩ - · exact CNF.commonZeroCount_parityRowSystem_eq_sum_branch_hermiteCramerNumerator_design hk rows - S e (fun b => branchAugmentedScope S e univ (φ.parityRowSystem rows) b) D - (fun _ j => Sum.inl ⟨j, mem_univ j⟩) hQ - · exact CNF.commonZeroCount_parityRowSystem_eq_sum_branch_clearedParityJetTable_design hk rows - S e (fun b => branchAugmentedScope S e univ (φ.parityRowSystem rows) b) D - (fun _ j => Sum.inl ⟨j, mem_univ j⟩) hQ - -/-- **Unified Lemma 6.1 + Lemma 6.2 + Section 6.3 greedy parity-test schedule with -Hermite–Cramer & `clearedParityJetTable` recovery and `2 ^ (A * interpolationScale n)` bounds:** -At every stage `i ≤ 3 * Fintype.card V`, the greedy trajectory `A i` admits per-branch `hF b` and -`D b` recovering `commonZeroCount univ (φ.parityRowSystem (A i))` (and `φ.modelCountOn Finset.univ` -at stage `3 * Fintype.card V`) via **both** explicit Hermite–Cramer truncated-sum determinants and -Stage-1/Stage-2 `clearedParityJetTable` coordinate sums at `nodeInt` and canonical jet order -`sparseParityJetOrder`, with single-branch and branch-summed `interpolationScale` examination -bounds. -/ -theorem CNF.exists_greedy_parityRowSystem_hermiteCramer_recovery_and_examBound_of_le_clog_pow - (k C_B β_B : ℕ) : - ∃ N₁ : ℕ, 16384 ≤ N₁ ∧ - ∀ {V : Type*} [Fintype V] [DecidableEq V] - (φ : CNF V) {B : ℕ}, - (∀ c ∈ φ, c.length ≤ k) → - N₁ ≤ Fintype.card V → - 1 ≤ B → - B ≤ C_B * Nat.clog 2 (Fintype.card V) ^ β_B → - φ.length ≤ B * Fintype.card V → - let D₀ := BitString.initialRowWeightBound B φ.length - let P := BitString.greedyRowListLength B φ.length - let b₀ := CNF.parityBranchThreshold k D₀ (Fintype.card V) - ∃ A₀ : List (Fin φ.length → Bool), A₀.length ≤ 3 * Fintype.card V ∧ - (∀ r ∈ A₀, weight r ≤ D₀) ∧ - ∀ (A : ℕ → List (Fin φ.length → Bool)) - (γ : ℕ → Fin P → Fin φ.length × Bool), - A 0 = A₀ → (∀ i, A (i + 1) = A i ++ [testRow (γ i)]) → - (∀ i (γ' : Fin P → Fin φ.length × Bool), - commonZeroCount univ (φ.parityRowSystem (A i ++ [testRow (γ i)])) ≤ - commonZeroCount univ (φ.parityRowSystem (A i ++ [testRow γ']))) → - commonZeroCount univ (φ.parityRowSystem (A (3 * Fintype.card V))) = - φ.modelCountOn Finset.univ ∧ - ∀ i ≤ 3 * Fintype.card V, - (A i).length ≤ 6 * Fintype.card V ∧ - let S := heavyVars univ (univ : Finset (Fin (A i).length)) - (fun j => equationScope (φ.parityRowSystem (A i) j)) b₀ - ∀ ⦃n' : ℕ⦄ (e : ↥(univ \ S) ≃ Fin n'), - (Fintype.card V ≤ 2 * n' ∧ n' ≤ Fintype.card V) ∧ - (∃ (hQ : 0 < numNodes n') - (hF : ∀ b : V → Bool, - Feasible (2 * β_B + 5) n' (b₀ + 1) (max (k * (D₀ * 2 ^ k)) 1) - (∑ f : {j : Fin (A i).length // - j ∈ (univ : Finset (Fin (A i).length))} ⊕ Fin n', - #(branchAugmentedScope S e univ (φ.parityRowSystem (A i)) b f))) - (D : ∀ b : V → Bool, - ReplacementDesign - (branchAugmentedScope S e univ (φ.parityRowSystem (A i)) b) - (numNodes n') (numGroups n') (intervalStart (2 * β_B + 5) n') - (rowBound (2 * β_B + 5) n') (tauRat n')), - let ℓ := branchPrecision (Fintype.card V) - let J := sparseParityJetOrder k (rowBound (2 * β_B + 5) n') (numNodes n') - #(univ : Finset (Fin (A i).length)) ℓ - (commonZeroCount (univ : Finset (Fin (A i).length)) - (φ.parityRowSystem (A i)) : ℤ) = - (∑ b ∈ branchAssignments S, - (hermiteCramerNumerator (nodeInt (Q := numNodes n')) hQ - (sparseParityJetOrder_pos k (rowBound (2 * β_B + 5) n') (numNodes n') - #(univ : Finset (Fin (A i).length)) ℓ) - (fun t j => - (Polynomial.taylor (nodeInt t) - (univariateClearedParityTruncatedSum - (univ : Finset (Fin (A i).length)) - (φ.branchParityRowSystem (A i) S e b) - (commonDenom (numNodes n') (rowBound (2 * β_B + 5) n') : ℤ) k ℓ - (designReplacementScaledIntMap (D b) - (fun j => Sum.inl ⟨j, mem_univ j⟩)))).coeff j) / - (clearedProductDenom - (commonDenom (numNodes n') (rowBound (2 * β_B + 5) n') : ℤ) k ℓ - #(univ : Finset (Fin (A i).length)) * - (Polynomial.hermiteMatrix (nodeInt (Q := numNodes n')) J).det)) % - ((2 : ℤ) ^ ℓ)) ∧ - (commonZeroCount (univ : Finset (Fin (A i).length)) - (φ.parityRowSystem (A i)) : ℤ) = - (∑ b ∈ branchAssignments S, - (∑ s : Fin ℓ, - hermiteCramerNumerator (nodeInt (Q := numNodes n')) hQ - (sparseParityJetOrder_pos k (rowBound (2 * β_B + 5) n') (numNodes n') - #(univ : Finset (Fin (A i).length)) ℓ) - (fun t j => - clearedParityJetTable (univ : Finset (Fin (A i).length)) - (φ.branchParityRowSystem (A i) S e b) - (commonDenom (numNodes n') (rowBound (2 * β_B + 5) n') : ℤ) k ℓ J - (designReplacementScaledIntMap (D b) - (fun j => Sum.inl ⟨j, mem_univ j⟩)) (nodeInt t) j s) / - (clearedProductDenom - (commonDenom (numNodes n') (rowBound (2 * β_B + 5) n') : ℤ) k ℓ - #(univ : Finset (Fin (A i).length)) * - (Polynomial.hermiteMatrix (nodeInt (Q := numNodes n')) J).det)) % - ((2 : ℤ) ^ ℓ)) ∧ - (∀ b : V → Bool, - (univariateClearedParityTruncatedSum (univ : Finset (Fin (A i).length)) - (φ.branchParityRowSystem (A i) S e b) - (commonDenom (numNodes n') (rowBound (2 * β_B + 5) n') : ℤ) k ℓ - (designReplacementScaledIntMap (D b) - (fun j => Sum.inl ⟨j, mem_univ j⟩))).natDegree ≤ - (k * (rowBound (2 * β_B + 5) n' - 1)) * (8 * Fintype.card V)) ∧ - ∀ (b : V → Bool) - (s_active : Finset - ({j : Fin (A i).length // - j ∈ (univ : Finset (Fin (A i).length))} ⊕ Fin n')), - let d := k * ((A i).length + 2 * (branchPrecision (Fintype.card V) - 1)) - let q := (d * rowBound (2 * β_B + 5) n') / numNodes n' - let C := (hF b).toCountingDesign (D b) s_active - (∑ t : Fin (numNodes n'), - (#{p : Finset (Fin n') × Finset (Fin n') | #p.1 ≤ q ∧ p.2 ⊆ p.1} : ℝ) * - (2 * (#(C.measurementBox t) : ℝ) * - ∑ g : Fin (numGroups n'), (Fintype.card (C.LocalCube t g) : ℝ))) ≤ - (2 : ℝ) ^ ((CNF.parityBranchExamScaleCoeff k β_B : ℝ) * - interpolationScale (Fintype.card V))) ∧ - ∀ (examSum : (V → Bool) → ℝ), - (∀ b ∈ branchAssignments S, - examSum b ≤ - (2 : ℝ) ^ ((CNF.parityBranchExamScaleCoeff k β_B : ℝ) * - interpolationScale (Fintype.card V))) → - (∑ b ∈ branchAssignments S, examSum b) ≤ - (2 : ℝ) ^ (((CNF.parityBranchExamScaleCoeff k β_B + 32 : ℕ) : ℝ) * - interpolationScale (Fintype.card V)) := by - obtain ⟨N₁, hN₁, hgreedy⟩ := - CNF.exists_greedy_parityRowSystem_recovery_and_examBound_of_le_clog_pow k C_B β_B - refine ⟨N₁, hN₁, fun {V _ _} φ {B} hk hcard hB1 hB_le hm => ?_⟩ - intro D₀ P b₀ - obtain ⟨A₀, hlen0, hw0, htraj⟩ := hgreedy φ hk hcard hB1 hB_le hm - refine ⟨A₀, hlen0, hw0, fun A γ h0 hA hγ => ?_⟩ - obtain ⟨hcount, hstage⟩ := htraj A γ h0 hA hγ - refine ⟨hcount, fun i hi => ?_⟩ - obtain ⟨hlen_i, hstage_e⟩ := hstage i hi - refine ⟨hlen_i, fun ⦃n'⦄ e => ?_⟩ - obtain ⟨hn_bounds, ⟨hF, D, _, hdeg, hexam⟩, hsum⟩ := hstage_e e - have hQ : 0 < numNodes n' := (hF (fun _ => false)).numNodes_pos - refine ⟨hn_bounds, ⟨hQ, hF, D, ?_, ?_, hdeg, hexam⟩, hsum⟩ - · exact CNF.commonZeroCount_parityRowSystem_eq_sum_branch_hermiteCramerNumerator_design hk (A i) - _ e (fun b => branchAugmentedScope _ e univ (φ.parityRowSystem (A i)) b) D - (fun _ j => Sum.inl ⟨j, mem_univ j⟩) hQ - · exact CNF.commonZeroCount_parityRowSystem_eq_sum_branch_clearedParityJetTable_design hk (A i) - _ e (fun b => branchAugmentedScope _ e univ (φ.parityRowSystem (A i)) b) D - (fun _ j => Sum.inl ⟨j, mem_univ j⟩) hQ - -/-- **Unconditional Section 6.3 parity-row system existence, Hermite–Cramer & -`clearedParityJetTable` recovery of `φ.modelCountOn Finset.univ`, degree bound, and -`2 ^ (A * interpolationScale n)` examination bound:** -For any `k C_B β_B : ℕ`, at `N₁ ≥ 16384`, for any width-`≤ k` CNF `φ : CNF V` with -`N₁ ≤ Fintype.card V`, `1 ≤ B`, `B ≤ C_B * Nat.clog 2 (Fintype.card V) ^ β_B`, and -`φ.length ≤ B * Fintype.card V` (including `φ = []`), there exists a parity-row list -`rows : List (Fin φ.length → Bool)` (`rows.length ≤ 6 * Fintype.card V`) such that -`commonZeroCount univ (φ.parityRowSystem rows) = φ.modelCountOn Finset.univ`, and for any -free-variable equivalence `e : ↥(univ \ S) ≃ Fin n'`, there exist `hQ : 0 < numNodes n'`, -per-branch `hF b`, and concrete `ReplacementDesign`s `D b` recovering -`(φ.modelCountOn Finset.univ : ℤ)` via **both** explicit Hermite–Cramer truncated-sum determinants -and Stage-1/Stage-2 `clearedParityJetTable` coordinate sums at `nodeInt` and canonical jet order -`sparseParityJetOrder`, with single-branch and branch-summed `interpolationScale` examination -bounds. -/ -theorem CNF.exists_parityRowSystem_modelCountOn_hermiteCramer_recovery_and_examBound_of_le_clog_pow - (k C_B β_B : ℕ) : - ∃ N₁ : ℕ, 16384 ≤ N₁ ∧ - ∀ {V : Type*} [Fintype V] [DecidableEq V] - (φ : CNF V) {B : ℕ}, - (∀ c ∈ φ, c.length ≤ k) → - N₁ ≤ Fintype.card V → - 1 ≤ B → - B ≤ C_B * Nat.clog 2 (Fintype.card V) ^ β_B → - φ.length ≤ B * Fintype.card V → - let D₀ := BitString.initialRowWeightBound B φ.length - let b₀ := CNF.parityBranchThreshold k D₀ (Fintype.card V) - ∃ rows : List (Fin φ.length → Bool), - rows.length ≤ 6 * Fintype.card V ∧ - commonZeroCount univ (φ.parityRowSystem rows) = φ.modelCountOn Finset.univ ∧ - let S := heavyVars univ (univ : Finset (Fin rows.length)) - (fun j => equationScope (φ.parityRowSystem rows j)) b₀ - ∀ ⦃n' : ℕ⦄ (e : ↥(univ \ S) ≃ Fin n'), - (Fintype.card V ≤ 2 * n' ∧ n' ≤ Fintype.card V) ∧ - (∃ (hQ : 0 < numNodes n') - (hF : ∀ b : V → Bool, - Feasible (2 * β_B + 5) n' (b₀ + 1) (max (k * (D₀ * 2 ^ k)) 1) - (∑ f : {j : Fin rows.length // - j ∈ (univ : Finset (Fin rows.length))} ⊕ Fin n', - #(branchAugmentedScope S e univ (φ.parityRowSystem rows) b f))) - (D : ∀ b : V → Bool, - ReplacementDesign - (branchAugmentedScope S e univ (φ.parityRowSystem rows) b) - (numNodes n') (numGroups n') (intervalStart (2 * β_B + 5) n') - (rowBound (2 * β_B + 5) n') (tauRat n')), - let ℓ := branchPrecision (Fintype.card V) - let J := sparseParityJetOrder k (rowBound (2 * β_B + 5) n') (numNodes n') - #(univ : Finset (Fin rows.length)) ℓ - (φ.modelCountOn Finset.univ : ℤ) = - (∑ b ∈ branchAssignments S, - (hermiteCramerNumerator (nodeInt (Q := numNodes n')) hQ - (sparseParityJetOrder_pos k (rowBound (2 * β_B + 5) n') (numNodes n') - #(univ : Finset (Fin rows.length)) ℓ) - (fun t j => - (Polynomial.taylor (nodeInt t) - (univariateClearedParityTruncatedSum (univ : Finset (Fin rows.length)) - (φ.branchParityRowSystem rows S e b) - (commonDenom (numNodes n') (rowBound (2 * β_B + 5) n') : ℤ) k ℓ - (designReplacementScaledIntMap (D b) - (fun j => Sum.inl ⟨j, mem_univ j⟩)))).coeff j) / - (clearedProductDenom - (commonDenom (numNodes n') (rowBound (2 * β_B + 5) n') : ℤ) k ℓ - #(univ : Finset (Fin rows.length)) * - (Polynomial.hermiteMatrix (nodeInt (Q := numNodes n')) J).det)) % - ((2 : ℤ) ^ ℓ)) ∧ - (φ.modelCountOn Finset.univ : ℤ) = - (∑ b ∈ branchAssignments S, - (∑ s : Fin ℓ, - hermiteCramerNumerator (nodeInt (Q := numNodes n')) hQ - (sparseParityJetOrder_pos k (rowBound (2 * β_B + 5) n') (numNodes n') - #(univ : Finset (Fin rows.length)) ℓ) - (fun t j => - clearedParityJetTable (univ : Finset (Fin rows.length)) - (φ.branchParityRowSystem rows S e b) - (commonDenom (numNodes n') (rowBound (2 * β_B + 5) n') : ℤ) k ℓ J - (designReplacementScaledIntMap (D b) - (fun j => Sum.inl ⟨j, mem_univ j⟩)) (nodeInt t) j s) / - (clearedProductDenom - (commonDenom (numNodes n') (rowBound (2 * β_B + 5) n') : ℤ) k ℓ - #(univ : Finset (Fin rows.length)) * - (Polynomial.hermiteMatrix (nodeInt (Q := numNodes n')) J).det)) % - ((2 : ℤ) ^ ℓ)) ∧ - (∀ b : V → Bool, - (univariateClearedParityTruncatedSum (univ : Finset (Fin rows.length)) - (φ.branchParityRowSystem rows S e b) - (commonDenom (numNodes n') (rowBound (2 * β_B + 5) n') : ℤ) k ℓ - (designReplacementScaledIntMap (D b) - (fun j => Sum.inl ⟨j, mem_univ j⟩))).natDegree ≤ - (k * (rowBound (2 * β_B + 5) n' - 1)) * (8 * Fintype.card V)) ∧ - ∀ (b : V → Bool) - (s_active : Finset - ({j : Fin rows.length // j ∈ (univ : Finset (Fin rows.length))} ⊕ Fin n')), - let d := k * (rows.length + 2 * (branchPrecision (Fintype.card V) - 1)) - let q := (d * rowBound (2 * β_B + 5) n') / numNodes n' - let C := (hF b).toCountingDesign (D b) s_active - (∑ t : Fin (numNodes n'), - (#{p : Finset (Fin n') × Finset (Fin n') | #p.1 ≤ q ∧ p.2 ⊆ p.1} : ℝ) * - (2 * (#(C.measurementBox t) : ℝ) * - ∑ g : Fin (numGroups n'), (Fintype.card (C.LocalCube t g) : ℝ))) ≤ - (2 : ℝ) ^ ((CNF.parityBranchExamScaleCoeff k β_B : ℝ) * - interpolationScale (Fintype.card V))) ∧ - ∀ (examSum : (V → Bool) → ℝ), - (∀ b ∈ branchAssignments S, - examSum b ≤ - (2 : ℝ) ^ ((CNF.parityBranchExamScaleCoeff k β_B : ℝ) * - interpolationScale (Fintype.card V))) → - (∑ b ∈ branchAssignments S, examSum b) ≤ - (2 : ℝ) ^ (((CNF.parityBranchExamScaleCoeff k β_B + 32 : ℕ) : ℝ) * - interpolationScale (Fintype.card V)) := by - obtain ⟨N₁, hN₁, hmodel⟩ := - CNF.exists_parityRowSystem_modelCountOn_recovery_and_examBound_of_le_clog_pow k C_B β_B - refine ⟨N₁, hN₁, fun {V _ _} φ {B} hk hcard hB1 hB_le hm => ?_⟩ - intro D₀ b₀ - obtain ⟨rows, hlen, hcount, hstage⟩ := hmodel φ hk hcard hB1 hB_le hm - refine ⟨rows, hlen, hcount, fun ⦃n'⦄ e => ?_⟩ - obtain ⟨hn_bounds, ⟨hF, D, _, hdeg, hexam⟩, hsum⟩ := hstage e - have hQ : 0 < numNodes n' := (hF (fun _ => false)).numNodes_pos - refine ⟨hn_bounds, ⟨hQ, hF, D, ?_, ?_, hdeg, hexam⟩, hsum⟩ - · rw [← hcount] - exact CNF.commonZeroCount_parityRowSystem_eq_sum_branch_hermiteCramerNumerator_design hk rows - _ e (fun b => branchAugmentedScope _ e univ (φ.parityRowSystem rows) b) D - (fun _ j => Sum.inl ⟨j, mem_univ j⟩) hQ - · rw [← hcount] - exact CNF.commonZeroCount_parityRowSystem_eq_sum_branch_clearedParityJetTable_design hk rows - _ e (fun b => branchAugmentedScope _ e univ (φ.parityRowSystem rows) b) D - (fun _ j => Sum.inl ⟨j, mem_univ j⟩) hQ - -/-! ### 3. Proposition 6.4 tree-wide Hermite–Cramer & `clearedParityJetTable` recovery -/ - -/-- **Proposition 6.4 tree-wide candidate-indexed Hermite–Cramer & `clearedParityJetTable` -recovery and total `2 ^ (O_k(interpolationScale n))` examination bounds ([OpenAI2026ETH], -§§5.4–5.5, 6.1–6.4, and Appendices A–B, printed pp. 38–50):** -For any `k ≥ 2`, there exists `N₃ ≥ 2 ^ 640000` such that for any finite variable type `V` with -`N₃ ≤ Fintype.card V` and any width-`≤ k` CNF `φ : CNF V`: -1. **Exact leaf-summed model-count conservation and `2 ^ (17 * interpolationScale n)` leaf-count - bound:** - `((φ.prop64NormalizedLeaves k).map fun L => L.toCNF.modelCountOn Finset.univ).sum =` - `φ.modelCountOn Finset.univ`, `2 ≤ numGroups (Fintype.card V)`, - `(φ.prop64NormalizedLeaves k).length ≤ 2 ^ (Fintype.card V / numGroups (Fintype.card V) + 1)`, - and `((φ.prop64NormalizedLeaves k).length : ℝ) ≤` - `(2 : ℝ) ^ (17 * interpolationScale (Fintype.card V))`. -2. **Per-leaf candidate-query cardinality and overhead bound:** - For every leaf `L ∈ φ.prop64NormalizedLeaves k` (`ψ := L.toCNF`), - `Fintype.card (CNF.LeafCandidateQueryIndex V B ψ) = 3 * Fintype.card V * (2 * ψ.length) ^ P + 1` - `≤ CNF.leafCandidateQueryBound B ψ`, and - `(CNF.leafCandidateQueryBound B ψ : ℝ) ≤ (2 : ℝ) ^ interpolationScale (Fintype.card V)`. -3. **Every candidate query and final query certified via explicit Hermite–Cramer determinants, - Stage-1/Stage-2 `clearedParityJetTable` coordinate sums, and `interpolationScale` examination - bounds:** - There exist Lemma 6.1 initial rows `A₀` such that for any Lemma 6.2 greedy trajectory `A`: - - `commonZeroCount univ (ψ.parityRowSystem (A (3 * Fintype.card V))) = ψ.modelCountOn univ`, - - for **every** query `q : CNF.LeafCandidateQueryIndex V B ψ` (every candidate `(i, γ')` across - `i < 3 * n` and ordered candidate list `γ'` with list multiplicity, including discarded - candidates, plus the final query `Sum.inr ()`), and any free-variable equivalence - `e : ↥(univ \ S_q) ≃ Fin n'`, there exist `hQ : 0 < numNodes n'`, per-branch `hF b`, and - concrete `ReplacementDesign`s `D b` at schedule exponent `β = CNF.prop64ScheduleExponent k` - recovering `commonZeroCount univ (ψ.parityRowSystem (CNF.candidateQueryRows A q))` via **both** - explicit Hermite–Cramer truncated-sum determinants and Stage-1/Stage-2 `clearedParityJetTable` - coordinate sums at `nodeInt` and canonical jet order `sparseParityJetOrder`, with single-query - branch-summed examination count at most - `(2 : ℝ) ^ (((CNF.prop64BranchExamScaleCoeff k + 32 : ℕ) : ℝ) * interpolationScale n)` and - candidate-summed leaf examination count `∑ q, queryExam q` at most - `(2 : ℝ) ^ ((CNF.prop64LeafQueryExamScaleCoeff k : ℝ) * interpolationScale n)`. -4. **Tree-wide single-query and total candidate-indexed examination bounds:** - Summing across `φ.prop64NormalizedLeaves k` bounds the tree-wide single-query examination count - by `(2 : ℝ) ^ ((CNF.prop64TreeExamScaleCoeff k : ℝ) * interpolationScale (Fintype.card V))` and - the total candidate-indexed examination count across the entire sparsification tree by - `(2 : ℝ) ^ ((CNF.prop64TotalExamScaleCoeff k : ℝ) * interpolationScale (Fintype.card V))`. -/ -theorem CNF.exists_prop64NormalizedLeaves_greedy_total_hermiteCramer_recovery_and_examBound - {k : ℕ} (hk : 2 ≤ k) : - ∃ N₃ : ℕ, 2 ^ 640000 ≤ N₃ ∧ - ∀ {V : Type*} [Fintype V] [DecidableEq V] - (φ : CNF V), - (∀ c ∈ φ, c.length ≤ k) → - N₃ ≤ Fintype.card V → - let B := CNF.prop64LeafClauseRatio k (Fintype.card V) - ((φ.prop64NormalizedLeaves k).map fun L => L.toCNF.modelCountOn Finset.univ).sum = - φ.modelCountOn Finset.univ ∧ - 2 ≤ numGroups (Fintype.card V) ∧ - (φ.prop64NormalizedLeaves k).length ≤ - 2 ^ (Fintype.card V / numGroups (Fintype.card V) + 1) ∧ - ((φ.prop64NormalizedLeaves k).length : ℝ) ≤ - (2 : ℝ) ^ (17 * interpolationScale (Fintype.card V)) ∧ - (∀ L ∈ φ.prop64NormalizedLeaves k, - let ψ := L.toCNF - let D₀ := BitString.initialRowWeightBound B ψ.length - let P := BitString.greedyRowListLength B ψ.length - let b₀ := CNF.parityBranchThreshold k D₀ (Fintype.card V) - (∀ c ∈ ψ, c.length ≤ k) ∧ - ψ.length ≤ B * Fintype.card V ∧ - Fintype.card (CNF.LeafCandidateQueryIndex V B ψ) = - 3 * Fintype.card V * (2 * ψ.length) ^ P + 1 ∧ - Fintype.card (CNF.LeafCandidateQueryIndex V B ψ) ≤ - CNF.leafCandidateQueryBound B ψ ∧ - (CNF.leafCandidateQueryBound B ψ : ℝ) ≤ - (2 : ℝ) ^ interpolationScale (Fintype.card V) ∧ - ∃ A₀ : List (Fin ψ.length → Bool), A₀.length ≤ 3 * Fintype.card V ∧ - (∀ r ∈ A₀, weight r ≤ D₀) ∧ - ∀ (A : ℕ → List (Fin ψ.length → Bool)) - (γ : ℕ → Fin P → Fin ψ.length × Bool), - A 0 = A₀ → (∀ i, A (i + 1) = A i ++ [testRow (γ i)]) → - (∀ i (γ' : Fin P → Fin ψ.length × Bool), - commonZeroCount univ (ψ.parityRowSystem (A i ++ [testRow (γ i)])) ≤ - commonZeroCount univ (ψ.parityRowSystem (A i ++ [testRow γ']))) → - commonZeroCount univ (ψ.parityRowSystem (A (3 * Fintype.card V))) = - ψ.modelCountOn Finset.univ ∧ - (∀ (q : CNF.LeafCandidateQueryIndex V B ψ), - let rows := CNF.candidateQueryRows A q - rows.length ≤ 6 * Fintype.card V ∧ - (∀ r ∈ rows, weight r ≤ D₀) ∧ - let S := heavyVars univ (univ : Finset (Fin rows.length)) - (fun j => equationScope (ψ.parityRowSystem rows j)) b₀ - ∀ ⦃n' : ℕ⦄ (e : ↥(univ \ S) ≃ Fin n'), - (Fintype.card V ≤ 2 * n' ∧ n' ≤ Fintype.card V) ∧ - (∃ (hQ : 0 < numNodes n') - (hF : ∀ b : V → Bool, - Feasible (CNF.prop64ScheduleExponent k) n' (b₀ + 1) - (max (k * (D₀ * 2 ^ k)) 1) - (∑ f : {j : Fin rows.length // - j ∈ (univ : Finset (Fin rows.length))} ⊕ Fin n', - #(branchAugmentedScope S e univ (ψ.parityRowSystem rows) b f))) - (D : ∀ b : V → Bool, - ReplacementDesign - (branchAugmentedScope S e univ (ψ.parityRowSystem rows) b) - (numNodes n') (numGroups n') - (intervalStart (CNF.prop64ScheduleExponent k) n') - (rowBound (CNF.prop64ScheduleExponent k) n') (tauRat n')), - let ℓ := branchPrecision (Fintype.card V) - let J := sparseParityJetOrder k (rowBound (CNF.prop64ScheduleExponent k) n') - (numNodes n') #(univ : Finset (Fin rows.length)) ℓ - (commonZeroCount (univ : Finset (Fin rows.length)) - (ψ.parityRowSystem rows) : ℤ) = - (∑ b ∈ branchAssignments S, - (hermiteCramerNumerator (nodeInt (Q := numNodes n')) hQ - (sparseParityJetOrder_pos k - (rowBound (CNF.prop64ScheduleExponent k) n') (numNodes n') - #(univ : Finset (Fin rows.length)) ℓ) - (fun t j => - (Polynomial.taylor (nodeInt t) - (univariateClearedParityTruncatedSum - (univ : Finset (Fin rows.length)) - (ψ.branchParityRowSystem rows S e b) - (commonDenom (numNodes n') - (rowBound (CNF.prop64ScheduleExponent k) n') : ℤ) k ℓ - (designReplacementScaledIntMap (D b) - (fun j => Sum.inl ⟨j, mem_univ j⟩)))).coeff j) / - (clearedProductDenom - (commonDenom (numNodes n') - (rowBound (CNF.prop64ScheduleExponent k) n') : ℤ) k ℓ - #(univ : Finset (Fin rows.length)) * - (Polynomial.hermiteMatrix (nodeInt (Q := numNodes n')) J).det)) % - ((2 : ℤ) ^ ℓ)) ∧ - (commonZeroCount (univ : Finset (Fin rows.length)) - (ψ.parityRowSystem rows) : ℤ) = - (∑ b ∈ branchAssignments S, - (∑ s : Fin ℓ, - hermiteCramerNumerator (nodeInt (Q := numNodes n')) hQ - (sparseParityJetOrder_pos k - (rowBound (CNF.prop64ScheduleExponent k) n') (numNodes n') - #(univ : Finset (Fin rows.length)) ℓ) - (fun t j => - clearedParityJetTable (univ : Finset (Fin rows.length)) - (ψ.branchParityRowSystem rows S e b) - (commonDenom (numNodes n') - (rowBound (CNF.prop64ScheduleExponent k) n') : ℤ) k ℓ J - (designReplacementScaledIntMap (D b) - (fun j => Sum.inl ⟨j, mem_univ j⟩)) (nodeInt t) j s) / - (clearedProductDenom - (commonDenom (numNodes n') - (rowBound (CNF.prop64ScheduleExponent k) n') : ℤ) k ℓ - #(univ : Finset (Fin rows.length)) * - (Polynomial.hermiteMatrix (nodeInt (Q := numNodes n')) J).det)) % - ((2 : ℤ) ^ ℓ)) ∧ - (∀ b : V → Bool, - (univariateClearedParityTruncatedSum (univ : Finset (Fin rows.length)) - (ψ.branchParityRowSystem rows S e b) - (commonDenom (numNodes n') - (rowBound (CNF.prop64ScheduleExponent k) n') : ℤ) k ℓ - (designReplacementScaledIntMap (D b) - (fun j => Sum.inl ⟨j, mem_univ j⟩))).natDegree ≤ - (k * (rowBound (CNF.prop64ScheduleExponent k) n' - 1)) * - (8 * Fintype.card V)) ∧ - ∀ (b : V → Bool) - (s_active : Finset - ({j : Fin rows.length // - j ∈ (univ : Finset (Fin rows.length))} ⊕ Fin n')), - let d := k * (rows.length + 2 * (branchPrecision (Fintype.card V) - 1)) - let q_jet := (d * rowBound (CNF.prop64ScheduleExponent k) n') / numNodes n' - let C := (hF b).toCountingDesign (D b) s_active - (∑ t : Fin (numNodes n'), - (#{p : Finset (Fin n') × Finset (Fin n') | - #p.1 ≤ q_jet ∧ p.2 ⊆ p.1} : ℝ) * - (2 * (#(C.measurementBox t) : ℝ) * - ∑ g : Fin (numGroups n'), - (Fintype.card (C.LocalCube t g) : ℝ))) ≤ - (2 : ℝ) ^ ((CNF.prop64BranchExamScaleCoeff k : ℝ) * - interpolationScale (Fintype.card V))) ∧ - ∀ (examSum : (V → Bool) → ℝ), - (∀ b ∈ branchAssignments S, - examSum b ≤ - (2 : ℝ) ^ ((CNF.prop64BranchExamScaleCoeff k : ℝ) * - interpolationScale (Fintype.card V))) → - (∑ b ∈ branchAssignments S, examSum b) ≤ - (2 : ℝ) ^ (((CNF.prop64BranchExamScaleCoeff k + 32 : ℕ) : ℝ) * - interpolationScale (Fintype.card V))) ∧ - ∀ (queryExam : CNF.LeafCandidateQueryIndex V B ψ → ℝ), - (∀ q : CNF.LeafCandidateQueryIndex V B ψ, - queryExam q ≤ - (2 : ℝ) ^ (((CNF.prop64BranchExamScaleCoeff k + 32 : ℕ) : ℝ) * - interpolationScale (Fintype.card V))) → - (∑ q : CNF.LeafCandidateQueryIndex V B ψ, queryExam q) ≤ - (2 : ℝ) ^ ((CNF.prop64LeafQueryExamScaleCoeff k : ℝ) * - interpolationScale (Fintype.card V))) ∧ - (∀ (leafExam : ClauseSet V → ℝ), - (∀ L ∈ φ.prop64NormalizedLeaves k, - leafExam L ≤ - (2 : ℝ) ^ (((CNF.prop64BranchExamScaleCoeff k + 32 : ℕ) : ℝ) * - interpolationScale (Fintype.card V))) → - (((φ.prop64NormalizedLeaves k).map leafExam).sum) ≤ - (2 : ℝ) ^ ((CNF.prop64TreeExamScaleCoeff k : ℝ) * - interpolationScale (Fintype.card V))) ∧ - (∀ (treeQueryExam : (L : ClauseSet V) → - CNF.LeafCandidateQueryIndex V B L.toCNF → ℝ), - (∀ L ∈ φ.prop64NormalizedLeaves k, - ∀ q : CNF.LeafCandidateQueryIndex V B L.toCNF, - treeQueryExam L q ≤ - (2 : ℝ) ^ (((CNF.prop64BranchExamScaleCoeff k + 32 : ℕ) : ℝ) * - interpolationScale (Fintype.card V))) → - (((φ.prop64NormalizedLeaves k).map fun (L : ClauseSet V) => - ∑ q : CNF.LeafCandidateQueryIndex V B L.toCNF, treeQueryExam L q).sum) ≤ - (2 : ℝ) ^ ((CNF.prop64TotalExamScaleCoeff k : ℝ) * - interpolationScale (Fintype.card V))) := by - obtain ⟨N₃, hN₃, hprop64⟩ := - CNF.exists_prop64NormalizedLeaves_greedy_total_recovery_and_examBound hk - refine ⟨N₃, hN₃, fun {V _ _} φ hk_φ hcard => ?_⟩ - intro B - obtain ⟨hsum_mc, hs2, hlen_pow, hlen_scale, hleaf, htree_branch, htree_total⟩ := - hprop64 φ hk_φ hcard - refine ⟨hsum_mc, hs2, hlen_pow, hlen_scale, fun L hL => ?_, htree_branch, htree_total⟩ - intro ψ D₀ P b₀ - obtain ⟨hk_ψ, hm_ψ, hcand_scale, A₀, hlen0, hw0, htraj⟩ := hleaf L hL - refine ⟨hk_ψ, hm_ψ, CNF.card_leafCandidateQueryIndex_eq B ψ, - CNF.card_leafCandidateQueryIndex_le B ψ, hcand_scale, A₀, hlen0, hw0, - fun A γ h0 hA hmin => ?_⟩ - obtain ⟨hcount, hquery, hleaf_sum⟩ := htraj A γ h0 hA hmin - refine ⟨hcount, fun q => ?_, hleaf_sum⟩ - obtain ⟨hlen_q, hw_q, hstage_q⟩ := hquery q - refine ⟨hlen_q, hw_q, fun ⦃n'⦄ e => ?_⟩ - obtain ⟨hn_bounds, ⟨hF, D, _, hdeg, hexam⟩, hsum⟩ := hstage_q e - have hQ : 0 < numNodes n' := (hF (fun _ => false)).numNodes_pos - refine ⟨hn_bounds, ⟨hQ, hF, D, ?_, ?_, hdeg, hexam⟩, hsum⟩ - · exact CNF.commonZeroCount_parityRowSystem_eq_sum_branch_hermiteCramerNumerator_design hk_ψ - (CNF.candidateQueryRows A q) _ e - (fun b => branchAugmentedScope _ e univ (ψ.parityRowSystem (CNF.candidateQueryRows A q)) b) D - (fun _ j => Sum.inl ⟨j, mem_univ j⟩) hQ - · exact CNF.commonZeroCount_parityRowSystem_eq_sum_branch_clearedParityJetTable_design hk_ψ - (CNF.candidateQueryRows A q) _ e - (fun b => branchAugmentedScope _ e univ (ψ.parityRowSystem (CNF.candidateQueryRows A q)) b) D - (fun _ j => Sum.inl ⟨j, mem_univ j⟩) hQ - -/-- **Proposition 6.4 unconditional trajectory-instantiated tree-wide Hermite–Cramer & -`clearedParityJetTable` recovery and total candidate-indexed `2 ^ (O_k(interpolationScale n))` -examination bounds ([OpenAI2026ETH], §6.4 & Appendices A–B, printed pp. 43–50):** -For any `k ≥ 2`, at `N₃ ≥ 2 ^ 640000`, for any finite variable type `V` with `N₃ ≤ Fintype.card V` -and any width-`≤ k` CNF `φ : CNF V`, every leaf `L ∈ φ.prop64NormalizedLeaves k` (`ψ := L.toCNF`) -unconditionally admits a concrete Lemma 6.2 greedy trajectory `A : ℕ → List (Fin ψ.length → Bool)` -such that -`commonZeroCount univ (ψ.parityRowSystem (CNF.candidateQueryRows (B := B) A (Sum.inr ()))) =` -`ψ.modelCountOn Finset.univ`, every round satisfies the Lemma 6.2 minimality inequality, and -every candidate query `q : CNF.LeafCandidateQueryIndex V B ψ` (including discarded candidates with -list multiplicity and the final query `Sum.inr ()`) is recovered via **both** explicit -Hermite–Cramer truncated-sum determinants and Stage-1/Stage-2 `clearedParityJetTable` coordinate -sums at `nodeInt` and canonical jet order `sparseParityJetOrder`, with per-query, per-leaf -candidate-summed, and tree-wide candidate-summed `interpolationScale` examination bounds. -/ -theorem CNF.exists_prop64NormalizedLeaves_total_hermiteCramer_recovery_and_examBound - {k : ℕ} (hk : 2 ≤ k) : - ∃ N₃ : ℕ, 2 ^ 640000 ≤ N₃ ∧ - ∀ {V : Type*} [Fintype V] [DecidableEq V] - (φ : CNF V), - (∀ c ∈ φ, c.length ≤ k) → - N₃ ≤ Fintype.card V → - let B := CNF.prop64LeafClauseRatio k (Fintype.card V) - ((φ.prop64NormalizedLeaves k).map fun L => L.toCNF.modelCountOn Finset.univ).sum = - φ.modelCountOn Finset.univ ∧ - 2 ≤ numGroups (Fintype.card V) ∧ - (φ.prop64NormalizedLeaves k).length ≤ - 2 ^ (Fintype.card V / numGroups (Fintype.card V) + 1) ∧ - ((φ.prop64NormalizedLeaves k).length : ℝ) ≤ - (2 : ℝ) ^ (17 * interpolationScale (Fintype.card V)) ∧ - (∀ L ∈ φ.prop64NormalizedLeaves k, - let ψ := L.toCNF - let D₀ := BitString.initialRowWeightBound B ψ.length - let P := BitString.greedyRowListLength B ψ.length - let b₀ := CNF.parityBranchThreshold k D₀ (Fintype.card V) - (∀ c ∈ ψ, c.length ≤ k) ∧ - ψ.length ≤ B * Fintype.card V ∧ - Fintype.card (CNF.LeafCandidateQueryIndex V B ψ) = - 3 * Fintype.card V * (2 * ψ.length) ^ P + 1 ∧ - Fintype.card (CNF.LeafCandidateQueryIndex V B ψ) ≤ - CNF.leafCandidateQueryBound B ψ ∧ - (CNF.leafCandidateQueryBound B ψ : ℝ) ≤ - (2 : ℝ) ^ interpolationScale (Fintype.card V) ∧ - ∃ A : ℕ → List (Fin ψ.length → Bool), - commonZeroCount univ - (ψ.parityRowSystem (CNF.candidateQueryRows (B := B) A (Sum.inr ()))) = - ψ.modelCountOn Finset.univ ∧ - (∀ (i : Fin (3 * Fintype.card V)) (γ' : Fin P → Fin ψ.length × Bool), - commonZeroCount univ (ψ.parityRowSystem (A (i.1 + 1))) ≤ - commonZeroCount univ - (ψ.parityRowSystem (CNF.candidateQueryRows A (Sum.inl (i, γ'))))) ∧ - (∀ (q : CNF.LeafCandidateQueryIndex V B ψ), - let rows := CNF.candidateQueryRows A q - rows.length ≤ 6 * Fintype.card V ∧ - (∀ r ∈ rows, weight r ≤ D₀) ∧ - let S := heavyVars univ (univ : Finset (Fin rows.length)) - (fun j => equationScope (ψ.parityRowSystem rows j)) b₀ - ∀ ⦃n' : ℕ⦄ (e : ↥(univ \ S) ≃ Fin n'), - (Fintype.card V ≤ 2 * n' ∧ n' ≤ Fintype.card V) ∧ - (∃ (hQ : 0 < numNodes n') - (hF : ∀ b : V → Bool, - Feasible (CNF.prop64ScheduleExponent k) n' (b₀ + 1) - (max (k * (D₀ * 2 ^ k)) 1) - (∑ f : {j : Fin rows.length // - j ∈ (univ : Finset (Fin rows.length))} ⊕ Fin n', - #(branchAugmentedScope S e univ (ψ.parityRowSystem rows) b f))) - (D : ∀ b : V → Bool, - ReplacementDesign - (branchAugmentedScope S e univ (ψ.parityRowSystem rows) b) - (numNodes n') (numGroups n') - (intervalStart (CNF.prop64ScheduleExponent k) n') - (rowBound (CNF.prop64ScheduleExponent k) n') (tauRat n')), - let ℓ := branchPrecision (Fintype.card V) - let J := sparseParityJetOrder k (rowBound (CNF.prop64ScheduleExponent k) n') - (numNodes n') #(univ : Finset (Fin rows.length)) ℓ - (commonZeroCount (univ : Finset (Fin rows.length)) - (ψ.parityRowSystem rows) : ℤ) = - (∑ b ∈ branchAssignments S, - (hermiteCramerNumerator (nodeInt (Q := numNodes n')) hQ - (sparseParityJetOrder_pos k - (rowBound (CNF.prop64ScheduleExponent k) n') (numNodes n') - #(univ : Finset (Fin rows.length)) ℓ) - (fun t j => - (Polynomial.taylor (nodeInt t) - (univariateClearedParityTruncatedSum - (univ : Finset (Fin rows.length)) - (ψ.branchParityRowSystem rows S e b) - (commonDenom (numNodes n') - (rowBound (CNF.prop64ScheduleExponent k) n') : ℤ) k ℓ - (designReplacementScaledIntMap (D b) - (fun j => Sum.inl ⟨j, mem_univ j⟩)))).coeff j) / - (clearedProductDenom - (commonDenom (numNodes n') - (rowBound (CNF.prop64ScheduleExponent k) n') : ℤ) k ℓ - #(univ : Finset (Fin rows.length)) * - (Polynomial.hermiteMatrix (nodeInt (Q := numNodes n')) J).det)) % - ((2 : ℤ) ^ ℓ)) ∧ - (commonZeroCount (univ : Finset (Fin rows.length)) - (ψ.parityRowSystem rows) : ℤ) = - (∑ b ∈ branchAssignments S, - (∑ s : Fin ℓ, - hermiteCramerNumerator (nodeInt (Q := numNodes n')) hQ - (sparseParityJetOrder_pos k - (rowBound (CNF.prop64ScheduleExponent k) n') (numNodes n') - #(univ : Finset (Fin rows.length)) ℓ) - (fun t j => - clearedParityJetTable (univ : Finset (Fin rows.length)) - (ψ.branchParityRowSystem rows S e b) - (commonDenom (numNodes n') - (rowBound (CNF.prop64ScheduleExponent k) n') : ℤ) k ℓ J - (designReplacementScaledIntMap (D b) - (fun j => Sum.inl ⟨j, mem_univ j⟩)) (nodeInt t) j s) / - (clearedProductDenom - (commonDenom (numNodes n') - (rowBound (CNF.prop64ScheduleExponent k) n') : ℤ) k ℓ - #(univ : Finset (Fin rows.length)) * - (Polynomial.hermiteMatrix (nodeInt (Q := numNodes n')) J).det)) % - ((2 : ℤ) ^ ℓ)) ∧ - (∀ b : V → Bool, - (univariateClearedParityTruncatedSum (univ : Finset (Fin rows.length)) - (ψ.branchParityRowSystem rows S e b) - (commonDenom (numNodes n') - (rowBound (CNF.prop64ScheduleExponent k) n') : ℤ) k ℓ - (designReplacementScaledIntMap (D b) - (fun j => Sum.inl ⟨j, mem_univ j⟩))).natDegree ≤ - (k * (rowBound (CNF.prop64ScheduleExponent k) n' - 1)) * - (8 * Fintype.card V)) ∧ - ∀ (b : V → Bool) - (s_active : Finset - ({j : Fin rows.length // - j ∈ (univ : Finset (Fin rows.length))} ⊕ Fin n')), - let d := k * (rows.length + 2 * (branchPrecision (Fintype.card V) - 1)) - let q_jet := (d * rowBound (CNF.prop64ScheduleExponent k) n') / numNodes n' - let C := (hF b).toCountingDesign (D b) s_active - (∑ t : Fin (numNodes n'), - (#{p : Finset (Fin n') × Finset (Fin n') | - #p.1 ≤ q_jet ∧ p.2 ⊆ p.1} : ℝ) * - (2 * (#(C.measurementBox t) : ℝ) * - ∑ g : Fin (numGroups n'), - (Fintype.card (C.LocalCube t g) : ℝ))) ≤ - (2 : ℝ) ^ ((CNF.prop64BranchExamScaleCoeff k : ℝ) * - interpolationScale (Fintype.card V))) ∧ - ∀ (examSum : (V → Bool) → ℝ), - (∀ b ∈ branchAssignments S, - examSum b ≤ - (2 : ℝ) ^ ((CNF.prop64BranchExamScaleCoeff k : ℝ) * - interpolationScale (Fintype.card V))) → - (∑ b ∈ branchAssignments S, examSum b) ≤ - (2 : ℝ) ^ (((CNF.prop64BranchExamScaleCoeff k + 32 : ℕ) : ℝ) * - interpolationScale (Fintype.card V))) ∧ - ∀ (queryExam : CNF.LeafCandidateQueryIndex V B ψ → ℝ), - (∀ q : CNF.LeafCandidateQueryIndex V B ψ, - queryExam q ≤ - (2 : ℝ) ^ (((CNF.prop64BranchExamScaleCoeff k + 32 : ℕ) : ℝ) * - interpolationScale (Fintype.card V))) → - (∑ q : CNF.LeafCandidateQueryIndex V B ψ, queryExam q) ≤ - (2 : ℝ) ^ ((CNF.prop64LeafQueryExamScaleCoeff k : ℝ) * - interpolationScale (Fintype.card V))) ∧ - (∀ (leafExam : ClauseSet V → ℝ), - (∀ L ∈ φ.prop64NormalizedLeaves k, - leafExam L ≤ - (2 : ℝ) ^ (((CNF.prop64BranchExamScaleCoeff k + 32 : ℕ) : ℝ) * - interpolationScale (Fintype.card V))) → - (((φ.prop64NormalizedLeaves k).map leafExam).sum) ≤ - (2 : ℝ) ^ ((CNF.prop64TreeExamScaleCoeff k : ℝ) * - interpolationScale (Fintype.card V))) ∧ - (∀ (treeQueryExam : (L : ClauseSet V) → - CNF.LeafCandidateQueryIndex V B L.toCNF → ℝ), - (∀ L ∈ φ.prop64NormalizedLeaves k, - ∀ q : CNF.LeafCandidateQueryIndex V B L.toCNF, - treeQueryExam L q ≤ - (2 : ℝ) ^ (((CNF.prop64BranchExamScaleCoeff k + 32 : ℕ) : ℝ) * - interpolationScale (Fintype.card V))) → - (((φ.prop64NormalizedLeaves k).map fun (L : ClauseSet V) => - ∑ q : CNF.LeafCandidateQueryIndex V B L.toCNF, treeQueryExam L q).sum) ≤ - (2 : ℝ) ^ ((CNF.prop64TotalExamScaleCoeff k : ℝ) * - interpolationScale (Fintype.card V))) := by - obtain ⟨N₃, hN₃, htotal⟩ := - CNF.exists_prop64NormalizedLeaves_total_recovery_and_examBound hk - refine ⟨N₃, hN₃, fun {V _ _} φ hk_φ hcard => ?_⟩ - intro B - obtain ⟨hsum_mc, hs2, hlen_pow, hlen_scale, hleaf, htree_branch, htree_total⟩ := - htotal φ hk_φ hcard - refine ⟨hsum_mc, hs2, hlen_pow, hlen_scale, fun L hL => ?_, htree_branch, htree_total⟩ - intro ψ D₀ P b₀ - obtain ⟨hk_ψ, hm_ψ, hcand_scale, A, hcount, hmin, hquery, hleaf_sum⟩ := hleaf L hL - refine ⟨hk_ψ, hm_ψ, CNF.card_leafCandidateQueryIndex_eq B ψ, - CNF.card_leafCandidateQueryIndex_le B ψ, hcand_scale, A, hcount, hmin, - fun q => ?_, hleaf_sum⟩ - obtain ⟨hlen_q, hw_q, hstage_q⟩ := hquery q - refine ⟨hlen_q, hw_q, fun ⦃n'⦄ e => ?_⟩ - obtain ⟨hn_bounds, ⟨hF, D, _, hdeg, hexam⟩, hsum⟩ := hstage_q e - have hQ : 0 < numNodes n' := (hF (fun _ => false)).numNodes_pos - refine ⟨hn_bounds, ⟨hQ, hF, D, ?_, ?_, hdeg, hexam⟩, hsum⟩ - · exact CNF.commonZeroCount_parityRowSystem_eq_sum_branch_hermiteCramerNumerator_design hk_ψ - (CNF.candidateQueryRows A q) _ e - (fun b => branchAugmentedScope _ e univ (ψ.parityRowSystem (CNF.candidateQueryRows A q)) b) D - (fun _ j => Sum.inl ⟨j, mem_univ j⟩) hQ - · exact CNF.commonZeroCount_parityRowSystem_eq_sum_branch_clearedParityJetTable_design hk_ψ - (CNF.candidateQueryRows A q) _ e - (fun b => branchAugmentedScope _ e univ (ψ.parityRowSystem (CNF.candidateQueryRows A q)) b) D - (fun _ j => Sum.inl ⟨j, mem_univ j⟩) hQ - -end Cslib.Logic.PL diff --git a/Complexity/Computability/Complexity/FineGrained/SparseCNFDesignSchedule.lean b/Complexity/Computability/Complexity/FineGrained/SparseCNFDesignSchedule.lean deleted file mode 100644 index 4f6392f997..0000000000 --- a/Complexity/Computability/Complexity/FineGrained/SparseCNFDesignSchedule.lean +++ /dev/null @@ -1,708 +0,0 @@ -/- -Copyright (c) 2026 Samuel Schlesinger. All rights reserved. -Released under Apache 2.0 license as described in the file LICENSE. -Authors: Samuel Schlesinger --/ - -module --- upstream: candidate - -public import Complexity.Init -public import Complexity.Computability.Complexity.FineGrained.SparseParitySchedule -public import Complexity.Logics.Propositional.CNF.SparseDesignCounter - -/-! -# Schedule-Instantiated Exact Recovery for the CNF Sparse Parity-Design Counter - -This module composes the Section 6.3 compiled parity-row schedule supplier of -`Complexity.Computability.Complexity.FineGrained.SparseParitySchedule` with the `ReplacementDesign` -constant-term recovery and univariate numerator degree bounds of -`Complexity.Logics.Propositional.CNF.SparseDesignCounter`, following Sections 5.4–5.5 and 6.1–6.3 -(printed pp. 38–43) of [OpenAI, *The Exponential Time Hypothesis is False*][OpenAI2026ETH]: - -1. **Index-equivalence bridge between `Fin m ⊕ Fin n'` and `{j : Fin m // j ∈ univ} ⊕ Fin n'`**: - - `CNF.parityRowAugmentedIndexEquiv`: canonical equivalence - `Fin m ⊕ Fin n' ≃ {j : Fin m // j ∈ (univ : Finset (Fin m))} ⊕ Fin n'`. - - `CNF.parityRowAugmentedInl`: active-equation factor embedding into `{j // j ∈ univ} ⊕ Fin n'`. - - `CNF.branchAugmentedScope_parityRowAugmentedInl`, - `CNF.branchAugmentedScope_parityRowSystem_comp_equiv_inl`, and - `CNF.branchAugmentedScope_parityRowSystem_comp_equiv_inr`: evaluate - `branchAugmentedScope S e univ (φ.parityRowSystem rows) b` along `CNF.parityRowAugmentedInl` - and `CNF.parityRowAugmentedIndexEquiv`. -2. **Schedule-instantiated exact recovery of `commonZeroCount` and `numPassing` (§5.4–5.5 & §6.3)**: - - `CNF.exists_branch_replacementDesign_commonZeroCount_parityRowSystem_eq`: given per-branch - `Feasible β n' (b₀ + 1) (max (k * (W * 2 ^ k)) 1) M'_b`, consumes - `CNF.exists_branch_replacementDesign_parityRowSystem` and recovers - `commonZeroCount univ (φ.parityRowSystem rows)` and `numPassing φ.violations rows` with - univariate numerator degree at most - `(k * (rowBound β n' - 1)) * (rows.length + 2 * (branchPrecision (Fintype.card V) - 1))`. - - `CNF.exists_schedule_design_commonZeroCount_parityRowSystem_eq` and - `CNF.exists_schedule_design_numPassing_eq`: combine - `CNF.exists_branch_schedule_parityRowSystem` with - `CNF.commonZeroCount_parityRowSystem_eq_sum_branch_emod_ediv_design` and - `CNF.numPassing_eq_sum_branch_emod_ediv_design` under polylogarithmic schedule bounds. - - `CNF.exists_schedule_design_commonZeroCount_parityRowSystem_of_le_clog_pow` and - `CNF.exists_schedule_design_numPassing_of_le_clog_pow`: combine the unconditional - polylogarithmic schedule supplier `CNF.exists_branch_schedule_parityRowSystem_of_le_clog_pow` - (`B ≤ C_B * (Nat.clog 2 n) ^ β_B`, `b₀ = CNF.parityBranchThreshold k W n`, - `β = 2 * β_B + 5`) with exact branch-summed constant-term recovery and numerator degree bounds. -3. **End-to-end greedy `modelCountOn` schedule-design recovery (§6.1–6.3)**: - - In Lemma 6.2 and Section 6.3, every candidate and final parity-row system has equation-count - ratio `6` (`rows.length ≤ 6 * Fintype.card V`, giving - `rows.length + 2 * (branchPrecision n - 1) ≤ 8 * n`), whereas Theorem 2.2's parameter - `c = c(k)` bounds both equation count and the monomial-sparsity exponent; our theorems keep the - equation-count bound `rows.length ≤ 6 * Fintype.card V` and the monomial-sparsity bound - `W * 2 ^ k` explicit. - - `CNF.exists_greedy_testRow_trajectory`: finite-minimization existence of a greedy parity-row - trajectory `(A, γ)` whenever `Nonempty (Fin P → Fin φ.length × Bool)`. - - `CNF.exists_greedy_parityRowSystem_schedule_design_modelCountOn_eq` and - `CNF.exists_greedy_parityRowSystem_schedule_design_modelCountOn_of_le_clog_pow`: combine - `CNF.exists_greedy_parityRowSystem_branch_schedule` and - `CNF.exists_greedy_parityRowSystem_branch_schedule_of_le_clog_pow` with exact branch-summed - constant-term recovery of `φ.modelCountOn Finset.univ` and the - `(k * (rowBound _ n' - 1)) * (8 * Fintype.card V)` numerator degree bound after `3 * n` greedy - rounds. - -## Main definitions - -* `Cslib.Logic.PL.CNF.parityRowAugmentedIndexEquiv` -* `Cslib.Logic.PL.CNF.parityRowAugmentedInl` - -## Main results - -* `Cslib.Logic.PL.CNF.branchAugmentedScope_parityRowAugmentedInl` -* `Cslib.Logic.PL.CNF.branchAugmentedScope_parityRowSystem_comp_equiv_inl` -* `Cslib.Logic.PL.CNF.branchAugmentedScope_parityRowSystem_comp_equiv_inr` -* `Cslib.Logic.PL.CNF.exists_branch_replacementDesign_commonZeroCount_parityRowSystem_eq` -* `Cslib.Logic.PL.CNF.exists_schedule_design_commonZeroCount_parityRowSystem_eq` -* `Cslib.Logic.PL.CNF.exists_schedule_design_numPassing_eq` -* `Cslib.Logic.PL.CNF.exists_schedule_design_commonZeroCount_parityRowSystem_of_le_clog_pow` -* `Cslib.Logic.PL.CNF.exists_schedule_design_numPassing_of_le_clog_pow` -* `Cslib.Logic.PL.CNF.exists_greedy_testRow_trajectory` -* `Cslib.Logic.PL.CNF.exists_greedy_parityRowSystem_schedule_design_modelCountOn_eq` -* `Cslib.Logic.PL.CNF.exists_greedy_parityRowSystem_schedule_design_modelCountOn_of_le_clog_pow` - -## References - -* [OpenAI, *The Exponential Time Hypothesis is False*][OpenAI2026ETH] - (Sections 5.4–5.5, pp. 38–39; Sections 6.1–6.3, pp. 39–43) --/ - -public section - -namespace Cslib.Logic.PL - -open Finset -open Cslib.BitString -open Cslib.LinearAlgebra -open Cslib.Complexity.SubexponentialSAT.ReplacementParams - -variable {V : Type*} {n' : ℕ} - -/-! ### 1. Index-equivalence bridge between `Fin m ⊕ Fin n'` and `{j // j ∈ univ} ⊕ Fin n'` -/ - -/-- Canonical equivalence between the flat factor index `Fin m ⊕ Fin n'` of -`CNF.branchParityRowNeutralScope` and the active-subtype factor index -`{j : Fin m // j ∈ (univ : Finset (Fin m))} ⊕ Fin n'` of `branchAugmentedScope`. -/ -@[expose] -def CNF.parityRowAugmentedIndexEquiv (m n' : ℕ) : - Fin m ⊕ Fin n' ≃ {j : Fin m // j ∈ (univ : Finset (Fin m))} ⊕ Fin n' := - Equiv.sumCongr (Equiv.subtypeUnivEquiv mem_univ).symm (Equiv.refl (Fin n')) - -/-- Active-equation factor embedding `Fin m → {j : Fin m // j ∈ univ} ⊕ Fin n'` into the left -summand of `branchAugmentedScope`. -/ -@[expose] -def CNF.parityRowAugmentedInl {m n' : ℕ} (j : Fin m) : - {j : Fin m // j ∈ (univ : Finset (Fin m))} ⊕ Fin n' := - Sum.inl ⟨j, mem_univ j⟩ - -@[simp] -theorem CNF.parityRowAugmentedIndexEquiv_inl {m n' : ℕ} (j : Fin m) : - CNF.parityRowAugmentedIndexEquiv m n' (Sum.inl j) = CNF.parityRowAugmentedInl j := - rfl - -@[simp] -theorem CNF.parityRowAugmentedIndexEquiv_inr {m n' : ℕ} (v : Fin n') : - CNF.parityRowAugmentedIndexEquiv m n' (Sum.inr v) = Sum.inr v := - rfl - -/-- Evaluating `branchAugmentedScope S e univ (φ.parityRowSystem rows) b` at -`CNF.parityRowAugmentedInl j` yields `branchEquationScope S e (φ.parityRowSystem rows) b j`. -/ -@[simp] -theorem CNF.branchAugmentedScope_parityRowAugmentedInl [Fintype V] [DecidableEq V] - (φ : CNF V) (rows : List (Fin φ.length → Bool)) (S : Finset V) - (e : ↥(univ \ S) ≃ Fin n') (b : V → Bool) (j : Fin rows.length) : - branchAugmentedScope S e univ (φ.parityRowSystem rows) b (CNF.parityRowAugmentedInl j) = - branchEquationScope S e (φ.parityRowSystem rows) b j := - branchAugmentedScope_inl S e univ (φ.parityRowSystem rows) b ⟨j, mem_univ j⟩ - -/-- Evaluating `branchAugmentedScope S e univ (φ.parityRowSystem rows) b` at -`CNF.parityRowAugmentedIndexEquiv rows.length n' (Sum.inl j)` yields -`branchEquationScope S e (φ.parityRowSystem rows) b j`. -/ -theorem CNF.branchAugmentedScope_parityRowSystem_comp_equiv_inl [Fintype V] [DecidableEq V] - (φ : CNF V) (rows : List (Fin φ.length → Bool)) (S : Finset V) - (e : ↥(univ \ S) ≃ Fin n') (b : V → Bool) (j : Fin rows.length) : - branchAugmentedScope S e univ (φ.parityRowSystem rows) b - (CNF.parityRowAugmentedIndexEquiv rows.length n' (Sum.inl j)) = - branchEquationScope S e (φ.parityRowSystem rows) b j := - branchAugmentedScope_inl S e univ (φ.parityRowSystem rows) b ⟨j, mem_univ j⟩ - -/-- Evaluating `branchAugmentedScope S e univ (φ.parityRowSystem rows) b` at -`CNF.parityRowAugmentedIndexEquiv rows.length n' (Sum.inr v)` yields the neutral singleton scope -`{v}`. -/ -theorem CNF.branchAugmentedScope_parityRowSystem_comp_equiv_inr [Fintype V] [DecidableEq V] - (φ : CNF V) (rows : List (Fin φ.length → Bool)) (S : Finset V) - (e : ↥(univ \ S) ≃ Fin n') (b : V → Bool) (v : Fin n') : - branchAugmentedScope S e univ (φ.parityRowSystem rows) b - (CNF.parityRowAugmentedIndexEquiv rows.length n' (Sum.inr v)) = {v} := - branchAugmentedScope_inr S e univ (φ.parityRowSystem rows) b v - -/-! ### 2. Schedule-instantiated exact recovery of `commonZeroCount` and `numPassing` -/ - -/-- **§5.4–5.5 & §6.3 (`Feasible`-instantiated `ReplacementDesign` recovery of `commonZeroCount` -and `numPassing` on `φ.parityRowSystem rows`)**: given a width-`≤ k` CNF `φ : CNF V`, a parity-row -list `rows : List (Fin φ.length → Bool)` with `∀ r_row ∈ rows, weight r_row ≤ W`, heavy-variable -set `S = heavyVars univ univ (fun j => equationScope (φ.parityRowSystem rows j)) b₀`, free-variable -relabeling `e : ↥(univ \ S) ≃ Fin n'`, and per-branch -`Feasible β n' (b₀ + 1) (max (k * (W * 2 ^ k)) 1) M'_b`, -there exists a family `D` of concrete Lemma 4.8 schedule `ReplacementDesign`s across all branches -`b : V → Bool` recovering `commonZeroCount univ (φ.parityRowSystem rows)` and -`numPassing φ.violations rows` via constant-term evaluation with univariate numerator degree at most -`(k * (rowBound β n' - 1)) * (rows.length + 2 * (branchPrecision (Fintype.card V) - 1))`. -/ -theorem CNF.exists_branch_replacementDesign_commonZeroCount_parityRowSystem_eq - [Fintype V] [DecidableEq V] {φ : CNF V} {β k W b₀ : ℕ} - (hk : ∀ c ∈ φ, c.length ≤ k) - {rows : List (Fin φ.length → Bool)} (hW : ∀ r_row ∈ rows, weight r_row ≤ W) - (e : ↥(univ \ heavyVars univ (univ : Finset (Fin rows.length)) - (fun j => equationScope (φ.parityRowSystem rows j)) b₀) ≃ Fin n') - (hF : ∀ b : V → Bool, - Feasible β n' (b₀ + 1) (max (k * (W * 2 ^ k)) 1) - (∑ f : {j : Fin rows.length // j ∈ (univ : Finset (Fin rows.length))} ⊕ Fin n', - #(branchAugmentedScope - (heavyVars univ (univ : Finset (Fin rows.length)) - (fun j => equationScope (φ.parityRowSystem rows j)) b₀) - e univ (φ.parityRowSystem rows) b f))) : - let S := heavyVars univ (univ : Finset (Fin rows.length)) - (fun j => equationScope (φ.parityRowSystem rows j)) b₀ - ∃ D : (b : V → Bool) → - ReplacementDesign (branchAugmentedScope S e univ (φ.parityRowSystem rows) b) - (numNodes n') (numGroups n') (intervalStart β n') (rowBound β n') (tauRat n'), - (commonZeroCount (univ : Finset (Fin rows.length)) (φ.parityRowSystem rows) : ℤ) = - (∑ b ∈ branchAssignments S, - ((univariateClearedParityTruncatedSum (univ : Finset (Fin rows.length)) - (φ.branchParityRowSystem rows S e b) - (commonDenom (numNodes n') (rowBound β n') : ℤ) k - (branchPrecision (Fintype.card V)) - (designReplacementScaledIntMap (D b) CNF.parityRowAugmentedInl)).eval 0 / - clearedProductDenom (commonDenom (numNodes n') (rowBound β n') : ℤ) k - (branchPrecision (Fintype.card V)) - #(univ : Finset (Fin rows.length))) % - ((2 : ℤ) ^ branchPrecision (Fintype.card V))) ∧ - (numPassing φ.violations rows : ℤ) = - (∑ b ∈ branchAssignments S, - ((univariateClearedParityTruncatedSum (univ : Finset (Fin rows.length)) - (φ.branchParityRowSystem rows S e b) - (commonDenom (numNodes n') (rowBound β n') : ℤ) k - (branchPrecision (Fintype.card V)) - (designReplacementScaledIntMap (D b) CNF.parityRowAugmentedInl)).eval 0 / - clearedProductDenom (commonDenom (numNodes n') (rowBound β n') : ℤ) k - (branchPrecision (Fintype.card V)) - #(univ : Finset (Fin rows.length))) % - ((2 : ℤ) ^ branchPrecision (Fintype.card V))) ∧ - ∀ b : V → Bool, - (univariateClearedParityTruncatedSum (univ : Finset (Fin rows.length)) - (φ.branchParityRowSystem rows S e b) - (commonDenom (numNodes n') (rowBound β n') : ℤ) k - (branchPrecision (Fintype.card V)) - (designReplacementScaledIntMap (D b) CNF.parityRowAugmentedInl)).natDegree ≤ - (k * (rowBound β n' - 1)) * - (rows.length + 2 * (branchPrecision (Fintype.card V) - 1)) := by - intro S - let D : (b : V → Bool) → - ReplacementDesign (branchAugmentedScope S e univ (φ.parityRowSystem rows) b) - (numNodes n') (numGroups n') (intervalStart β n') (rowBound β n') (tauRat n') := - fun b => Classical.choice - (φ.exists_branch_replacementDesign_parityRowSystem hk hW e b (hF b)) - have hcz := CNF.commonZeroCount_parityRowSystem_eq_sum_branch_emod_ediv_design hk rows S e - (fun b => branchAugmentedScope S e univ (φ.parityRowSystem rows) b) D - (fun _ => CNF.parityRowAugmentedInl) - refine ⟨D, hcz, ?_, fun b => ?_⟩ - · rw [← CNF.commonZeroCount_parityRowSystem] - exact hcz - · exact CNF.natDegree_univariateClearedParityTruncatedSum_branchParityRowSystem_le hk rows S e b - (D b) CNF.parityRowAugmentedInl (branchPrecision (Fintype.card V)) - -/-- **§5.4–5.5 & §6.3 (schedule-instantiated `ReplacementDesign` recovery of `commonZeroCount` on -`φ.parityRowSystem rows`)**: for every `1 ≤ β`, the threshold `n₀ ≥ 20` of -`CNF.exists_branch_schedule_parityRowSystem` guarantees that whenever `n₀ ≤ n'`, -`b₀ + 1 ≤ (Nat.clog 2 n') ^ β`, `max (k * (W * 2 ^ k)) 1 ≤ (Nat.clog 2 n') ^ β`, -`∀ c ∈ φ, c.length ≤ k`, and `∀ r_row ∈ rows, weight r_row ≤ W`, there exists a family `D` of -concrete Lemma 4.8 schedule `ReplacementDesign`s across all branches `b : V → Bool` (with every -branch satisfying `Feasible`) such that the branch-summed modular evaluation of -`univariateClearedParityTruncatedSum` at `T = 0` equals -`(commonZeroCount univ (φ.parityRowSystem rows) : ℤ)` and every branch numerator has degree at most -`(k * (rowBound β n' - 1)) * (rows.length + 2 * (branchPrecision (Fintype.card V) - 1))`. -/ -theorem CNF.exists_schedule_design_commonZeroCount_parityRowSystem_eq {β : ℕ} (hβ : 1 ≤ β) : - ∃ n₀ : ℕ, 20 ≤ n₀ ∧ - ∀ {V : Type*} [Fintype V] [DecidableEq V] - {φ : CNF V} ⦃n' k W b₀ : ℕ⦄, - (∀ c ∈ φ, c.length ≤ k) → - ∀ {rows : List (Fin φ.length → Bool)}, - (∀ r_row ∈ rows, weight r_row ≤ W) → - let S := heavyVars univ (univ : Finset (Fin rows.length)) - (fun j => equationScope (φ.parityRowSystem rows j)) b₀ - ∀ (e : ↥(univ \ S) ≃ Fin n'), - n₀ ≤ n' → - b₀ + 1 ≤ Nat.clog 2 n' ^ β → - max (k * (W * 2 ^ k)) 1 ≤ Nat.clog 2 n' ^ β → - (∀ b : V → Bool, - Feasible β n' (b₀ + 1) (max (k * (W * 2 ^ k)) 1) - (∑ f : {j : Fin rows.length // j ∈ (univ : Finset (Fin rows.length))} ⊕ Fin n', - #(branchAugmentedScope S e univ (φ.parityRowSystem rows) b f))) ∧ - ∃ D : (b : V → Bool) → - ReplacementDesign (branchAugmentedScope S e univ (φ.parityRowSystem rows) b) - (numNodes n') (numGroups n') (intervalStart β n') (rowBound β n') (tauRat n'), - (commonZeroCount (univ : Finset (Fin rows.length)) (φ.parityRowSystem rows) : ℤ) = - (∑ b ∈ branchAssignments S, - ((univariateClearedParityTruncatedSum (univ : Finset (Fin rows.length)) - (φ.branchParityRowSystem rows S e b) - (commonDenom (numNodes n') (rowBound β n') : ℤ) k - (branchPrecision (Fintype.card V)) - (designReplacementScaledIntMap (D b) CNF.parityRowAugmentedInl)).eval 0 / - clearedProductDenom (commonDenom (numNodes n') (rowBound β n') : ℤ) k - (branchPrecision (Fintype.card V)) - #(univ : Finset (Fin rows.length))) % - ((2 : ℤ) ^ branchPrecision (Fintype.card V))) ∧ - ∀ b : V → Bool, - (univariateClearedParityTruncatedSum (univ : Finset (Fin rows.length)) - (φ.branchParityRowSystem rows S e b) - (commonDenom (numNodes n') (rowBound β n') : ℤ) k - (branchPrecision (Fintype.card V)) - (designReplacementScaledIntMap (D b) CNF.parityRowAugmentedInl)).natDegree ≤ - (k * (rowBound β n' - 1)) * - (rows.length + 2 * (branchPrecision (Fintype.card V) - 1)) := by - obtain ⟨n₀, hn₀20, hsched⟩ := CNF.exists_branch_schedule_parityRowSystem hβ - refine ⟨n₀, hn₀20, fun {V _ _ φ n' k W b₀} hk {rows} hW => ?_⟩ - intro S e hn' hb₀ hw - have h_all := hsched hk hW e hn' hb₀ hw - obtain ⟨D, hcz, _, hdeg⟩ := - φ.exists_branch_replacementDesign_commonZeroCount_parityRowSystem_eq hk hW e - (fun b => (h_all b).1) - exact ⟨fun b => (h_all b).1, D, hcz, hdeg⟩ - -/-- **§5.4–5.5 & §6.3 (schedule-instantiated `ReplacementDesign` recovery of -`numPassing φ.violations rows`)**: under the hypotheses of -`CNF.exists_schedule_design_commonZeroCount_parityRowSystem_eq`, the branch-summed constant-term -evaluation from the schedule `ReplacementDesign` family `D` recovers -`(numPassing φ.violations rows : ℤ)`. -/ -theorem CNF.exists_schedule_design_numPassing_eq {β : ℕ} (hβ : 1 ≤ β) : - ∃ n₀ : ℕ, 20 ≤ n₀ ∧ - ∀ {V : Type*} [Fintype V] [DecidableEq V] - {φ : CNF V} ⦃n' k W b₀ : ℕ⦄, - (∀ c ∈ φ, c.length ≤ k) → - ∀ {rows : List (Fin φ.length → Bool)}, - (∀ r_row ∈ rows, weight r_row ≤ W) → - let S := heavyVars univ (univ : Finset (Fin rows.length)) - (fun j => equationScope (φ.parityRowSystem rows j)) b₀ - ∀ (e : ↥(univ \ S) ≃ Fin n'), - n₀ ≤ n' → - b₀ + 1 ≤ Nat.clog 2 n' ^ β → - max (k * (W * 2 ^ k)) 1 ≤ Nat.clog 2 n' ^ β → - (∀ b : V → Bool, - Feasible β n' (b₀ + 1) (max (k * (W * 2 ^ k)) 1) - (∑ f : {j : Fin rows.length // j ∈ (univ : Finset (Fin rows.length))} ⊕ Fin n', - #(branchAugmentedScope S e univ (φ.parityRowSystem rows) b f))) ∧ - ∃ D : (b : V → Bool) → - ReplacementDesign (branchAugmentedScope S e univ (φ.parityRowSystem rows) b) - (numNodes n') (numGroups n') (intervalStart β n') (rowBound β n') (tauRat n'), - (numPassing φ.violations rows : ℤ) = - (∑ b ∈ branchAssignments S, - ((univariateClearedParityTruncatedSum (univ : Finset (Fin rows.length)) - (φ.branchParityRowSystem rows S e b) - (commonDenom (numNodes n') (rowBound β n') : ℤ) k - (branchPrecision (Fintype.card V)) - (designReplacementScaledIntMap (D b) CNF.parityRowAugmentedInl)).eval 0 / - clearedProductDenom (commonDenom (numNodes n') (rowBound β n') : ℤ) k - (branchPrecision (Fintype.card V)) - #(univ : Finset (Fin rows.length))) % - ((2 : ℤ) ^ branchPrecision (Fintype.card V))) ∧ - ∀ b : V → Bool, - (univariateClearedParityTruncatedSum (univ : Finset (Fin rows.length)) - (φ.branchParityRowSystem rows S e b) - (commonDenom (numNodes n') (rowBound β n') : ℤ) k - (branchPrecision (Fintype.card V)) - (designReplacementScaledIntMap (D b) CNF.parityRowAugmentedInl)).natDegree ≤ - (k * (rowBound β n' - 1)) * - (rows.length + 2 * (branchPrecision (Fintype.card V) - 1)) := by - obtain ⟨n₀, hn₀20, hsched⟩ := CNF.exists_schedule_design_commonZeroCount_parityRowSystem_eq hβ - refine ⟨n₀, hn₀20, fun {V _ _ φ n' k W b₀} hk {rows} hW => ?_⟩ - intro S e hn' hb₀ hw - rw [← CNF.commonZeroCount_parityRowSystem] - exact hsched hk hW e hn' hb₀ hw - -/-- **Unconditional Section 6.3 schedule-design recovery of `commonZeroCount` for -`B ≤ C_B * (Nat.clog 2 n) ^ β_B`**: combines -`CNF.exists_branch_schedule_parityRowSystem_of_le_clog_pow` with -`CNF.commonZeroCount_parityRowSystem_eq_sum_branch_emod_ediv_design` and -`CNF.natDegree_univariateClearedParityTruncatedSum_branchParityRowSystem_le`. -/ -theorem CNF.exists_schedule_design_commonZeroCount_parityRowSystem_of_le_clog_pow - (k C_B β_B : ℕ) : - ∃ N₀ : ℕ, 20 ≤ N₀ ∧ - ∀ {V : Type*} [Fintype V] [DecidableEq V] - {φ : CNF V} ⦃n' B W : ℕ⦄, - (∀ c ∈ φ, c.length ≤ k) → - N₀ ≤ Fintype.card V → - φ.length ≤ B * Fintype.card V → - B ≤ C_B * Nat.clog 2 (Fintype.card V) ^ β_B → - W ≤ BitString.initialRowWeightBound B φ.length → - ∀ {rows : List (Fin φ.length → Bool)}, - (∀ r_row ∈ rows, weight r_row ≤ W) → - rows.length ≤ 6 * Fintype.card V → - let b₀ := CNF.parityBranchThreshold k W (Fintype.card V) - let S := heavyVars univ (univ : Finset (Fin rows.length)) - (fun j => equationScope (φ.parityRowSystem rows j)) b₀ - ∀ (e : ↥(univ \ S) ≃ Fin n'), - 2 ≤ (Nat.clog 2 (Fintype.card V)).sqrt ∧ - (Fintype.card V ≤ 2 * n' ∧ Fintype.card V / 2 ≤ n') ∧ - #(branchAssignments S) ≤ - 2 ^ (Fintype.card V / (Nat.clog 2 (Fintype.card V)).sqrt) ∧ - (∀ b : V → Bool, - Feasible (2 * β_B + 5) n' (b₀ + 1) (max (k * (W * 2 ^ k)) 1) - (∑ f : {j : Fin rows.length // j ∈ (univ : Finset (Fin rows.length))} ⊕ Fin n', - #(branchAugmentedScope S e univ (φ.parityRowSystem rows) b f))) ∧ - ∃ D : (b : V → Bool) → - ReplacementDesign (branchAugmentedScope S e univ (φ.parityRowSystem rows) b) - (numNodes n') (numGroups n') (intervalStart (2 * β_B + 5) n') - (rowBound (2 * β_B + 5) n') (tauRat n'), - (commonZeroCount (univ : Finset (Fin rows.length)) (φ.parityRowSystem rows) : ℤ) = - (∑ b ∈ branchAssignments S, - ((univariateClearedParityTruncatedSum (univ : Finset (Fin rows.length)) - (φ.branchParityRowSystem rows S e b) - (commonDenom (numNodes n') (rowBound (2 * β_B + 5) n') : ℤ) k - (branchPrecision (Fintype.card V)) - (designReplacementScaledIntMap (D b) CNF.parityRowAugmentedInl)).eval 0 / - clearedProductDenom - (commonDenom (numNodes n') (rowBound (2 * β_B + 5) n') : ℤ) k - (branchPrecision (Fintype.card V)) - #(univ : Finset (Fin rows.length))) % - ((2 : ℤ) ^ branchPrecision (Fintype.card V))) ∧ - ∀ b : V → Bool, - (univariateClearedParityTruncatedSum (univ : Finset (Fin rows.length)) - (φ.branchParityRowSystem rows S e b) - (commonDenom (numNodes n') (rowBound (2 * β_B + 5) n') : ℤ) k - (branchPrecision (Fintype.card V)) - (designReplacementScaledIntMap (D b) CNF.parityRowAugmentedInl)).natDegree ≤ - (k * (rowBound (2 * β_B + 5) n' - 1)) * - (rows.length + 2 * (branchPrecision (Fintype.card V) - 1)) := by - obtain ⟨N₀, hN₀20, hsched⟩ := CNF.exists_branch_schedule_parityRowSystem_of_le_clog_pow k C_B β_B - refine ⟨N₀, hN₀20, fun {V _ _ φ n' B W} hk hN₀ hm hB hW_bound {rows} hW hlen => ?_⟩ - intro b₀ S e - obtain ⟨hsqrt, hcard, hbr, h_all⟩ := hsched hk hN₀ hm hB hW_bound hW hlen e - obtain ⟨D, hcz, _, hdeg⟩ := - φ.exists_branch_replacementDesign_commonZeroCount_parityRowSystem_eq hk hW e - (fun b => (h_all b).1) - exact ⟨hsqrt, hcard, hbr, fun b => (h_all b).1, D, hcz, hdeg⟩ - -/-- **Unconditional Section 6.3 schedule-design recovery of `numPassing φ.violations rows` for -`B ≤ C_B * (Nat.clog 2 n) ^ β_B`**. -/ -theorem CNF.exists_schedule_design_numPassing_of_le_clog_pow (k C_B β_B : ℕ) : - ∃ N₀ : ℕ, 20 ≤ N₀ ∧ - ∀ {V : Type*} [Fintype V] [DecidableEq V] - {φ : CNF V} ⦃n' B W : ℕ⦄, - (∀ c ∈ φ, c.length ≤ k) → - N₀ ≤ Fintype.card V → - φ.length ≤ B * Fintype.card V → - B ≤ C_B * Nat.clog 2 (Fintype.card V) ^ β_B → - W ≤ BitString.initialRowWeightBound B φ.length → - ∀ {rows : List (Fin φ.length → Bool)}, - (∀ r_row ∈ rows, weight r_row ≤ W) → - rows.length ≤ 6 * Fintype.card V → - let b₀ := CNF.parityBranchThreshold k W (Fintype.card V) - let S := heavyVars univ (univ : Finset (Fin rows.length)) - (fun j => equationScope (φ.parityRowSystem rows j)) b₀ - ∀ (e : ↥(univ \ S) ≃ Fin n'), - 2 ≤ (Nat.clog 2 (Fintype.card V)).sqrt ∧ - (Fintype.card V ≤ 2 * n' ∧ Fintype.card V / 2 ≤ n') ∧ - #(branchAssignments S) ≤ - 2 ^ (Fintype.card V / (Nat.clog 2 (Fintype.card V)).sqrt) ∧ - (∀ b : V → Bool, - Feasible (2 * β_B + 5) n' (b₀ + 1) (max (k * (W * 2 ^ k)) 1) - (∑ f : {j : Fin rows.length // j ∈ (univ : Finset (Fin rows.length))} ⊕ Fin n', - #(branchAugmentedScope S e univ (φ.parityRowSystem rows) b f))) ∧ - ∃ D : (b : V → Bool) → - ReplacementDesign (branchAugmentedScope S e univ (φ.parityRowSystem rows) b) - (numNodes n') (numGroups n') (intervalStart (2 * β_B + 5) n') - (rowBound (2 * β_B + 5) n') (tauRat n'), - (numPassing φ.violations rows : ℤ) = - (∑ b ∈ branchAssignments S, - ((univariateClearedParityTruncatedSum (univ : Finset (Fin rows.length)) - (φ.branchParityRowSystem rows S e b) - (commonDenom (numNodes n') (rowBound (2 * β_B + 5) n') : ℤ) k - (branchPrecision (Fintype.card V)) - (designReplacementScaledIntMap (D b) CNF.parityRowAugmentedInl)).eval 0 / - clearedProductDenom - (commonDenom (numNodes n') (rowBound (2 * β_B + 5) n') : ℤ) k - (branchPrecision (Fintype.card V)) - #(univ : Finset (Fin rows.length))) % - ((2 : ℤ) ^ branchPrecision (Fintype.card V))) ∧ - ∀ b : V → Bool, - (univariateClearedParityTruncatedSum (univ : Finset (Fin rows.length)) - (φ.branchParityRowSystem rows S e b) - (commonDenom (numNodes n') (rowBound (2 * β_B + 5) n') : ℤ) k - (branchPrecision (Fintype.card V)) - (designReplacementScaledIntMap (D b) CNF.parityRowAugmentedInl)).natDegree ≤ - (k * (rowBound (2 * β_B + 5) n' - 1)) * - (rows.length + 2 * (branchPrecision (Fintype.card V) - 1)) := by - obtain ⟨N₀, hN₀20, hsched⟩ := - CNF.exists_schedule_design_commonZeroCount_parityRowSystem_of_le_clog_pow k C_B β_B - refine ⟨N₀, hN₀20, fun {V _ _ φ n' B W} hk hN₀ hm hB hW_bound {rows} hW hlen => ?_⟩ - intro b₀ S e - rw [← CNF.commonZeroCount_parityRowSystem] - exact hsched hk hN₀ hm hB hW_bound hW hlen e - -/-! ### 3. End-to-end greedy `modelCountOn` schedule-design recovery -/ - -/-- Finite-minimization existence of a greedy parity-row trajectory `(A, γ)` starting from any -initial row list `A₀`, provided the candidate tuple type `Fin P → Fin φ.length × Bool` is nonempty -(for instance whenever `1 ≤ φ.length`). -/ -theorem CNF.exists_greedy_testRow_trajectory [Fintype V] [DecidableEq V] - (φ : CNF V) (P : ℕ) [Nonempty (Fin P → Fin φ.length × Bool)] - (A₀ : List (Fin φ.length → Bool)) : - ∃ (A : ℕ → List (Fin φ.length → Bool)) - (γ : ℕ → Fin P → Fin φ.length × Bool), - A 0 = A₀ ∧ - (∀ i, A (i + 1) = A i ++ [testRow (γ i)]) ∧ - (∀ i (γ' : Fin P → Fin φ.length × Bool), - commonZeroCount univ (φ.parityRowSystem (A i ++ [testRow (γ i)])) ≤ - commonZeroCount univ (φ.parityRowSystem (A i ++ [testRow γ']))) := by - have hmin : ∀ rows : List (Fin φ.length → Bool), - ∃ γ₀ : Fin P → Fin φ.length × Bool, - ∀ γ' : Fin P → Fin φ.length × Bool, - commonZeroCount univ (φ.parityRowSystem (rows ++ [testRow γ₀])) ≤ - commonZeroCount univ (φ.parityRowSystem (rows ++ [testRow γ'])) := fun rows => by - obtain ⟨γ₀, _, hγ₀⟩ := - exists_min_image (univ : Finset (Fin P → Fin φ.length × Bool)) - (fun γ' => commonZeroCount univ (φ.parityRowSystem (rows ++ [testRow γ']))) - univ_nonempty - exact ⟨γ₀, fun γ' => hγ₀ γ' (mem_univ γ')⟩ - choose nextGamma hnextGamma using hmin - let A : ℕ → List (Fin φ.length → Bool) := - fun i => Nat.recOn i A₀ (fun _ rows => rows ++ [testRow (nextGamma rows)]) - refine ⟨A, fun i => nextGamma (A i), rfl, fun _ => rfl, fun i γ' => hnextGamma (A i) γ'⟩ - -/-- **Lemmas 6.1–6.2 & §§5.4–5.5, 6.3 (conditional greedy parity-test schedule-design recovery of -`φ.modelCountOn Finset.univ`)**: combines `CNF.exists_greedy_parityRowSystem_branch_schedule` with -`CNF.commonZeroCount_parityRowSystem_eq_sum_branch_emod_ediv_design` so that at every stage -`i ≤ 3 * n`, concrete Lemma 4.8 schedule `ReplacementDesign`s exist across all heavy-variable -branches (with equation-count bound `(A i).length ≤ 6 * n`), and at the final stage `i = 3 * n`, -they recover `(φ.modelCountOn Finset.univ : ℤ)` with univariate numerator degree at most -`(k * (rowBound β n' - 1)) * (8 * Fintype.card V)`. -/ -theorem CNF.exists_greedy_parityRowSystem_schedule_design_modelCountOn_eq {β : ℕ} (hβ : 1 ≤ β) : - ∃ n₀ : ℕ, 20 ≤ n₀ ∧ - ∀ {V : Type*} [Fintype V] [DecidableEq V] - (φ : CNF V) {k B : ℕ}, - (∀ c ∈ φ, c.length ≤ k) → - 1 ≤ Fintype.card V → - 1 ≤ B → - φ.length ≤ B * Fintype.card V → - let D₀ := BitString.initialRowWeightBound B φ.length - let P := BitString.greedyRowListLength B φ.length - ∃ A₀ : List (Fin φ.length → Bool), A₀.length ≤ 3 * Fintype.card V ∧ - (∀ r_row ∈ A₀, weight r_row ≤ D₀) ∧ - ∀ (A : ℕ → List (Fin φ.length → Bool)) - (γ : ℕ → Fin P → Fin φ.length × Bool), - A 0 = A₀ → (∀ i, A (i + 1) = A i ++ [testRow (γ i)]) → - (∀ i (γ' : Fin P → Fin φ.length × Bool), - commonZeroCount univ (φ.parityRowSystem (A i ++ [testRow (γ i)])) ≤ - commonZeroCount univ (φ.parityRowSystem (A i ++ [testRow γ']))) → - commonZeroCount univ (φ.parityRowSystem (A (3 * Fintype.card V))) = - φ.modelCountOn Finset.univ ∧ - (∀ i ≤ 3 * Fintype.card V, - (A i).length ≤ 6 * Fintype.card V ∧ - ∀ ⦃n' b₀ : ℕ⦄ - (e : ↥(univ \ heavyVars univ (univ : Finset (Fin (A i).length)) - (fun j => equationScope (φ.parityRowSystem (A i) j)) b₀) ≃ Fin n'), - n₀ ≤ n' → - b₀ + 1 ≤ Nat.clog 2 n' ^ β → - max (k * (max D₀ P * 2 ^ k)) 1 ≤ Nat.clog 2 n' ^ β → - ∀ b : V → Bool, - Feasible β n' (b₀ + 1) (max (k * (max D₀ P * 2 ^ k)) 1) - (∑ f : {j : Fin (A i).length // - j ∈ (univ : Finset (Fin (A i).length))} ⊕ Fin n', - #(branchAugmentedScope - (heavyVars univ (univ : Finset (Fin (A i).length)) - (fun j => equationScope (φ.parityRowSystem (A i) j)) b₀) - e univ (φ.parityRowSystem (A i)) b f)) ∧ - Nonempty - (ReplacementDesign - (branchAugmentedScope - (heavyVars univ (univ : Finset (Fin (A i).length)) - (fun j => equationScope (φ.parityRowSystem (A i) j)) b₀) - e univ (φ.parityRowSystem (A i)) b) - (numNodes n') (numGroups n') (intervalStart β n') - (rowBound β n') (tauRat n'))) ∧ - ∀ ⦃n' b₀ : ℕ⦄, - let rows := A (3 * Fintype.card V) - let S := heavyVars univ (univ : Finset (Fin rows.length)) - (fun j => equationScope (φ.parityRowSystem rows j)) b₀ - ∀ (e : ↥(univ \ S) ≃ Fin n'), - n₀ ≤ n' → - b₀ + 1 ≤ Nat.clog 2 n' ^ β → - max (k * (max D₀ P * 2 ^ k)) 1 ≤ Nat.clog 2 n' ^ β → - ∃ D : (b : V → Bool) → - ReplacementDesign (branchAugmentedScope S e univ (φ.parityRowSystem rows) b) - (numNodes n') (numGroups n') (intervalStart β n') (rowBound β n') (tauRat n'), - (φ.modelCountOn Finset.univ : ℤ) = - (∑ b ∈ branchAssignments S, - ((univariateClearedParityTruncatedSum (univ : Finset (Fin rows.length)) - (φ.branchParityRowSystem rows S e b) - (commonDenom (numNodes n') (rowBound β n') : ℤ) k - (branchPrecision (Fintype.card V)) - (designReplacementScaledIntMap (D b) CNF.parityRowAugmentedInl)).eval 0 / - clearedProductDenom (commonDenom (numNodes n') (rowBound β n') : ℤ) k - (branchPrecision (Fintype.card V)) - #(univ : Finset (Fin rows.length))) % - ((2 : ℤ) ^ branchPrecision (Fintype.card V))) ∧ - ∀ b : V → Bool, - (univariateClearedParityTruncatedSum (univ : Finset (Fin rows.length)) - (φ.branchParityRowSystem rows S e b) - (commonDenom (numNodes n') (rowBound β n') : ℤ) k - (branchPrecision (Fintype.card V)) - (designReplacementScaledIntMap (D b) CNF.parityRowAugmentedInl)).natDegree ≤ - (k * (rowBound β n' - 1)) * (8 * Fintype.card V) := by - obtain ⟨n₀, hn₀20, hgreedy_sched⟩ := CNF.exists_greedy_parityRowSystem_branch_schedule hβ - refine ⟨n₀, hn₀20, fun {V _ _} φ {k B} hk hn hB hm => ?_⟩ - intro D₀ P - obtain ⟨A₀, hlen0, hw0, hgreedy⟩ := hgreedy_sched φ hk hn hB hm - refine ⟨A₀, hlen0, hw0, fun A γ h0 hA hγ => ?_⟩ - obtain ⟨hcount, hstage⟩ := hgreedy A γ h0 hA hγ - refine ⟨hcount, hstage, fun {n' b₀} => ?_⟩ - intro rows S e hn' hb₀ hw - obtain ⟨hlen_final, h_all⟩ := hstage (3 * Fintype.card V) le_rfl - let D : (b : V → Bool) → - ReplacementDesign (branchAugmentedScope S e univ (φ.parityRowSystem rows) b) - (numNodes n') (numGroups n') (intervalStart β n') (rowBound β n') (tauRat n') := - fun b => Classical.choice (h_all e hn' hb₀ hw b).2 - refine ⟨D, ?_, fun b => ?_⟩ - · rw [← hcount] - exact CNF.commonZeroCount_parityRowSystem_eq_sum_branch_emod_ediv_design hk rows S e - (fun b => branchAugmentedScope S e univ (φ.parityRowSystem rows) b) D - (fun _ => CNF.parityRowAugmentedInl) - · have hdeg := - CNF.natDegree_univariateClearedParityTruncatedSum_branchParityRowSystem_le hk rows S e b - (D b) CNF.parityRowAugmentedInl (branchPrecision (Fintype.card V)) - have hrows : rows.length ≤ 6 * Fintype.card V := hlen_final - refine hdeg.trans (Nat.mul_le_mul_left _ ?_) - unfold branchPrecision - omega - -/-- **Unconditional Section 6.3 greedy parity-test schedule-design recovery of -`φ.modelCountOn Finset.univ` for `B ≤ C_B * (Nat.clog 2 n) ^ β_B`**: combines -`CNF.exists_greedy_parityRowSystem_branch_schedule_of_le_clog_pow` with exact branch-summed -constant-term recovery and univariate numerator degree bounds. -/ -theorem CNF.exists_greedy_parityRowSystem_schedule_design_modelCountOn_of_le_clog_pow - (k C_B β_B : ℕ) : - ∃ N₀ : ℕ, 20 ≤ N₀ ∧ - ∀ {V : Type*} [Fintype V] [DecidableEq V] - (φ : CNF V) {B : ℕ}, - (∀ c ∈ φ, c.length ≤ k) → - N₀ ≤ Fintype.card V → - 1 ≤ B → - B ≤ C_B * Nat.clog 2 (Fintype.card V) ^ β_B → - φ.length ≤ B * Fintype.card V → - let D₀ := BitString.initialRowWeightBound B φ.length - let P := BitString.greedyRowListLength B φ.length - let b₀ := CNF.parityBranchThreshold k D₀ (Fintype.card V) - ∃ A₀ : List (Fin φ.length → Bool), A₀.length ≤ 3 * Fintype.card V ∧ - (∀ r_row ∈ A₀, weight r_row ≤ D₀) ∧ - ∀ (A : ℕ → List (Fin φ.length → Bool)) - (γ : ℕ → Fin P → Fin φ.length × Bool), - A 0 = A₀ → (∀ i, A (i + 1) = A i ++ [testRow (γ i)]) → - (∀ i (γ' : Fin P → Fin φ.length × Bool), - commonZeroCount univ (φ.parityRowSystem (A i ++ [testRow (γ i)])) ≤ - commonZeroCount univ (φ.parityRowSystem (A i ++ [testRow γ']))) → - commonZeroCount univ (φ.parityRowSystem (A (3 * Fintype.card V))) = - φ.modelCountOn Finset.univ ∧ - (∀ i ≤ 3 * Fintype.card V, - (A i).length ≤ 6 * Fintype.card V ∧ - ∀ ⦃n' : ℕ⦄ - (e : ↥(univ \ heavyVars univ (univ : Finset (Fin (A i).length)) - (fun j => equationScope (φ.parityRowSystem (A i) j)) b₀) ≃ Fin n'), - (Fintype.card V ≤ 2 * n' ∧ Fintype.card V / 2 ≤ n') ∧ - #(branchAssignments - (heavyVars univ (univ : Finset (Fin (A i).length)) - (fun j => equationScope (φ.parityRowSystem (A i) j)) b₀)) ≤ - 2 ^ (Fintype.card V / (Nat.clog 2 (Fintype.card V)).sqrt) ∧ - ∀ b : V → Bool, - Feasible (2 * β_B + 5) n' (b₀ + 1) (max (k * (D₀ * 2 ^ k)) 1) - (∑ f : {j : Fin (A i).length // - j ∈ (univ : Finset (Fin (A i).length))} ⊕ Fin n', - #(branchAugmentedScope - (heavyVars univ (univ : Finset (Fin (A i).length)) - (fun j => equationScope (φ.parityRowSystem (A i) j)) b₀) - e univ (φ.parityRowSystem (A i)) b f)) ∧ - Nonempty - (ReplacementDesign - (branchAugmentedScope - (heavyVars univ (univ : Finset (Fin (A i).length)) - (fun j => equationScope (φ.parityRowSystem (A i) j)) b₀) - e univ (φ.parityRowSystem (A i)) b) - (numNodes n') (numGroups n') (intervalStart (2 * β_B + 5) n') - (rowBound (2 * β_B + 5) n') (tauRat n'))) ∧ - ∀ ⦃n' : ℕ⦄, - let rows := A (3 * Fintype.card V) - let S := heavyVars univ (univ : Finset (Fin rows.length)) - (fun j => equationScope (φ.parityRowSystem rows j)) b₀ - ∀ (e : ↥(univ \ S) ≃ Fin n'), - ∃ D : (b : V → Bool) → - ReplacementDesign (branchAugmentedScope S e univ (φ.parityRowSystem rows) b) - (numNodes n') (numGroups n') (intervalStart (2 * β_B + 5) n') - (rowBound (2 * β_B + 5) n') (tauRat n'), - (φ.modelCountOn Finset.univ : ℤ) = - (∑ b ∈ branchAssignments S, - ((univariateClearedParityTruncatedSum (univ : Finset (Fin rows.length)) - (φ.branchParityRowSystem rows S e b) - (commonDenom (numNodes n') (rowBound (2 * β_B + 5) n') : ℤ) k - (branchPrecision (Fintype.card V)) - (designReplacementScaledIntMap (D b) CNF.parityRowAugmentedInl)).eval 0 / - clearedProductDenom - (commonDenom (numNodes n') (rowBound (2 * β_B + 5) n') : ℤ) k - (branchPrecision (Fintype.card V)) - #(univ : Finset (Fin rows.length))) % - ((2 : ℤ) ^ branchPrecision (Fintype.card V))) ∧ - ∀ b : V → Bool, - (univariateClearedParityTruncatedSum (univ : Finset (Fin rows.length)) - (φ.branchParityRowSystem rows S e b) - (commonDenom (numNodes n') (rowBound (2 * β_B + 5) n') : ℤ) k - (branchPrecision (Fintype.card V)) - (designReplacementScaledIntMap (D b) CNF.parityRowAugmentedInl)).natDegree ≤ - (k * (rowBound (2 * β_B + 5) n' - 1)) * (8 * Fintype.card V) := by - obtain ⟨N₀, hN₀20, hgreedy_sched⟩ := - CNF.exists_greedy_parityRowSystem_branch_schedule_of_le_clog_pow k C_B β_B - refine ⟨N₀, hN₀20, fun {V _ _} φ {B} hk hN₀ hB1 hB_le hm => ?_⟩ - intro D₀ P b₀ - obtain ⟨A₀, hlen0, hw0, hgreedy⟩ := hgreedy_sched φ hk hN₀ hB1 hB_le hm - refine ⟨A₀, hlen0, hw0, fun A γ h0 hA hγ => ?_⟩ - obtain ⟨hcount, hstage⟩ := hgreedy A γ h0 hA hγ - refine ⟨hcount, hstage, fun {n'} => ?_⟩ - intro rows S e - obtain ⟨hlen_final, h_all⟩ := hstage (3 * Fintype.card V) le_rfl - let D : (b : V → Bool) → - ReplacementDesign (branchAugmentedScope S e univ (φ.parityRowSystem rows) b) - (numNodes n') (numGroups n') (intervalStart (2 * β_B + 5) n') - (rowBound (2 * β_B + 5) n') (tauRat n') := - fun b => Classical.choice ((h_all e).2.2 b).2 - refine ⟨D, ?_, fun b => ?_⟩ - · rw [← hcount] - exact CNF.commonZeroCount_parityRowSystem_eq_sum_branch_emod_ediv_design hk rows S e - (fun b => branchAugmentedScope S e univ (φ.parityRowSystem rows) b) D - (fun _ => CNF.parityRowAugmentedInl) - · have hdeg := - CNF.natDegree_univariateClearedParityTruncatedSum_branchParityRowSystem_le hk rows S e b - (D b) CNF.parityRowAugmentedInl (branchPrecision (Fintype.card V)) - have hrows : rows.length ≤ 6 * Fintype.card V := hlen_final - refine hdeg.trans (Nat.mul_le_mul_left _ ?_) - unfold branchPrecision - omega - -end Cslib.Logic.PL diff --git a/Complexity/Computability/PolyTime/CNF/ClauseJetEval.lean b/Complexity/Computability/PolyTime/CNF/ClauseJetEval.lean deleted file mode 100644 index 463a22cabc..0000000000 --- a/Complexity/Computability/PolyTime/CNF/ClauseJetEval.lean +++ /dev/null @@ -1,411 +0,0 @@ -/- -Copyright (c) 2026 Anton Kovsharov. All rights reserved. -Released under Apache 2.0 license as described in the file LICENSE. -Authors: Anton Kovsharov --/ - -module --- upstream: candidate - -public import Complexity.Init -public import Complexity.Computability.Machines.Turing.MultiTape.Encodings.Bool -public import Complexity.Computability.PolyTime.Int.Jet -public import Complexity.Logics.Propositional.CNF.SatisfactionPolynomial -public import Mathlib.Algebra.Order.Ring.Rat -import Complexity.Computability.Machines.Turing.MultiTape.Complexity.PolyTime.Int.Binary -import Complexity.Computability.Machines.Turing.MultiTape.Complexity.PolyTime.List -import Complexity.Computability.Machines.Turing.MultiTape.Complexity.PolyTime.Plain -import Complexity.Computability.Machines.Turing.MultiTape.Encodings.Length - -/-! -# Executable cleared-denominator clause jet evaluation in polynomial time - -Executable cleared clause-satisfaction and clause-group product evaluators in `ℤ[z] / (z ^ J)`, -building on `Cslib.mulZJet`, `Cslib.truncZJet`, `Cslib.IntJet`, and -`Cslib.Logic.PL.CNF.clauseSatPoly` / `Cslib.Logic.PL.CNF.cnfSatPoly`, following Appendix B.4 -(p. 51) and §2.2 (p. 8) of [OpenAI, *The Exponential Time Hypothesis is False*][OpenAI2026ETH]. - -## Main definitions and results - -* `Cslib.Logic.PL.CNF.evalClauseClearedJet`, `Cslib.Logic.PL.CNF.evalGroupClauseProductJet`. -* `Cslib.Logic.PL.CNF.X_pow_dvd_evalClauseClearedJet`, - `Cslib.Logic.PL.CNF.X_pow_dvd_evalGroupClauseProductJet`, - `Cslib.Logic.PL.CNF.X_pow_dvd_evalClauseClearedJet_clauseSatPoly`, - `Cslib.Logic.PL.CNF.X_pow_dvd_evalGroupClauseProductJet_cnfSatPoly`. -* `Cslib.Logic.PL.CNF.coeffNorm1_evalClauseClearedJet_le`, - `Cslib.Logic.PL.CNF.coeffNorm1_evalClauseClearedJet_le_pow`, - `Cslib.Logic.PL.CNF.coeffNorm1_evalGroupClauseProductJet_le`, - `Cslib.Logic.PL.CNF.coeffNorm1_evalGroupClauseProductJet_le_pow`, - `Cslib.Logic.PL.CNF.length_encIntBin_getD_evalGroupClauseProductJet_le`. -* `Cslib.Logic.PL.CNF.computableInPolyTime_evalClauseClearedJet`, - `Cslib.Logic.PL.CNF.computableInPolyTime_evalGroupClauseProductJet`. - -## References - -* [OpenAI, *The Exponential Time Hypothesis is False*][OpenAI2026ETH], §2.2 (p. 8), Appendix B.4 - (p. 51). --/ - -@[expose] public section - -open scoped BigOperators -open Turing.MultiTapeTM - -namespace Cslib.Logic.PL.CNF - -/-- Cleared clause-satisfaction jet evaluator (Appendix B.4, p. 51 of [OpenAI2026ETH]): computes -`δ ^ litJets.length - ∏_{(pol, X̃) ∈ litJets} (if pol then δ - X̃ else X̃)` modulo `z ^ J` via -`Cslib.mulZJet`, `Cslib.truncZJet`, and `Cslib.IntJet.subConst`. - -* **Polarity convention**: each `(pol, X̃)` carries literal polarity `pol : Bool` and cleared - variable jet `X̃ : List ℤ`; a positive literal (`pol = true`) contributes dissatisfaction factor - `IntJet.subConst J δ X̃` (`δ - X̃`), and a negative literal (`pol = false`) contributes `X̃`. -* **Totality and shape**: input lists `X̃` may have any length (`getD _ 0` zero-pads missing - coefficients and truncates degrees `≥ J`), and the output always has exact length `J`. -* **Denominator convention**: total for all `δ : ℤ` (satisfying `X_pow_dvd_evalClauseClearedJet` - unconditionally, including at `δ = 0`); dividing by `δ` to match `δ ^ |C| * Φ_C(X̃ / δ)` over - `ℚ[X]` (`X_pow_dvd_evalClauseClearedJet_clauseSatPoly`) requires `δ ≠ 0`. -/ -def evalClauseClearedJet (J : ℕ) (δ : ℤ) (litJets : List (Bool × List ℤ)) : List ℤ := - IntJet.subConst J (δ ^ litJets.length) - (litJets.foldl - (fun acc lit => Cslib.mulZJet J acc (if lit.1 then IntJet.subConst J δ lit.2 else lit.2)) - (Cslib.truncZJet J [1])) - -/-- Sequential cleared clause-product jet evaluator (Appendix B.4, p. 51 of [OpenAI2026ETH]): -multiplies the cleared clause jets of `clauses` modulo `z ^ J` via `Cslib.mulZJet` over staged -denominator `δ ^ (∑ |C|)`. - -* **Polarity and totality**: inherits the `(pol, X̃)` convention of `evalClauseClearedJet`; input - literal lists `X̃ : List ℤ` need not have length `J` (`getD _ 0` zero-pads short lists and - truncates degrees `≥ J`), and the output always has exact length `J` (`Cslib.truncZJet J [1]` - when `clauses = []`). -* **Denominator convention**: total for all `δ : ℤ` (satisfying - `X_pow_dvd_evalGroupClauseProductJet` unconditionally, including at `δ = 0`), while the rational - `δ ^ φ.totalLiterals * Φ_φ(X̃ / δ)` congruence (`X_pow_dvd_evalGroupClauseProductJet_cnfSatPoly`) - requires `δ ≠ 0`. -/ -def evalGroupClauseProductJet (J : ℕ) (δ : ℤ) (clauses : List (List (Bool × List ℤ))) : List ℤ := - clauses.foldl (fun acc litJets => Cslib.mulZJet J acc (evalClauseClearedJet J δ litJets)) - (Cslib.truncZJet J [1]) - -@[simp] theorem length_evalClauseClearedJet (J : ℕ) (δ : ℤ) (litJets : List (Bool × List ℤ)) : - (evalClauseClearedJet J δ litJets).length = J := - IntJet.length_subConst J _ _ - -@[simp] theorem length_evalGroupClauseProductJet (J : ℕ) (δ : ℤ) - (clauses : List (List (Bool × List ℤ))) : - (evalGroupClauseProductJet J δ clauses).length = J := - IntJet.length_foldl_mulZJet J (evalClauseClearedJet J δ) clauses (Cslib.length_truncZJet J [1]) - -/-- **Exact polynomial congruence for `evalClauseClearedJet` modulo `X ^ J`** over `ℤ[X]` (valid -for all `δ : ℤ`, including `δ = 0`). -/ -theorem X_pow_dvd_evalClauseClearedJet (J : ℕ) (δ : ℤ) (litJets : List (Bool × List ℤ)) : - Polynomial.X ^ J ∣ - Polynomial.ofCoeffList (evalClauseClearedJet J δ litJets) - - (Polynomial.C (δ ^ litJets.length) - - (litJets.map fun lit => if lit.1 then Polynomial.C δ - Polynomial.ofCoeffList lit.2 - else Polynomial.ofCoeffList lit.2).prod) := by - unfold evalClauseClearedJet - set foldOut := litJets.foldl - (fun acc lit => Cslib.mulZJet J acc (if lit.1 then IntJet.subConst J δ lit.2 else lit.2)) - (Cslib.truncZJet J [1]) - have hfold := IntJet.X_pow_dvd_foldl_mulZJet J litJets - (fun lit => if lit.1 then IntJet.subConst J δ lit.2 else lit.2) - (fun lit => if lit.1 then Polynomial.C δ - Polynomial.ofCoeffList lit.2 - else Polynomial.ofCoeffList lit.2) - (fun lit _ => by - cases lit.1 - · simp only [Bool.false_eq_true, ↓reduceIte, sub_self, dvd_zero] - · simp only [↓reduceIte]; exact IntJet.X_pow_dvd_subConst J δ lit.2) - (Cslib.truncZJet J [1]) 1 - (by simpa only [map_one] using IntJet.X_pow_dvd_truncZJet_singleton J 1) - rw [one_mul] at hfold - convert dvd_sub (IntJet.X_pow_dvd_subConst J (δ ^ litJets.length) foldOut) hfold using 1 - ring - -/-- **Exact polynomial congruence for `evalGroupClauseProductJet` modulo `X ^ J`** over `ℤ[X]` -(valid for all `δ : ℤ`, including `δ = 0`). -/ -theorem X_pow_dvd_evalGroupClauseProductJet (J : ℕ) (δ : ℤ) - (clauses : List (List (Bool × List ℤ))) : - Polynomial.X ^ J ∣ - Polynomial.ofCoeffList (evalGroupClauseProductJet J δ clauses) - - (clauses.map fun litJets => Polynomial.C (δ ^ litJets.length) - - (litJets.map fun lit => if lit.1 then Polynomial.C δ - Polynomial.ofCoeffList lit.2 - else Polynomial.ofCoeffList lit.2).prod).prod := by - unfold evalGroupClauseProductJet - have hfold := IntJet.X_pow_dvd_foldl_mulZJet J clauses (evalClauseClearedJet J δ) - (fun litJets => Polynomial.C (δ ^ litJets.length) - - (litJets.map fun lit => if lit.1 then Polynomial.C δ - Polynomial.ofCoeffList lit.2 - else Polynomial.ofCoeffList lit.2).prod) - (fun litJets _ => X_pow_dvd_evalClauseClearedJet J δ litJets) (Cslib.truncZJet J [1]) 1 - (by simpa only [map_one] using IntJet.X_pow_dvd_truncZJet_singleton J 1) - rwa [one_mul] at hfold - -private theorem X_pow_dvd_map_rat {J : ℕ} {P : Polynomial ℤ} (h : Polynomial.X ^ J ∣ P) : - (Polynomial.X : Polynomial ℚ) ^ J ∣ P.map (Int.castRingHom ℚ) := by - simpa only [Polynomial.map_pow, Polynomial.map_X] using - Polynomial.map_dvd (Int.castRingHom ℚ) h - -private theorem cleared_clauseSatPoly_rat_eq {V : Type*} (δ : ℤ) (hδ : δ ≠ 0) - (varJet : V → List ℤ) (C : Clause V) : - ((Polynomial.C (δ ^ (C.map fun l => (l.2, varJet l.1)).length) - - ((C.map fun l => (l.2, varJet l.1)).map fun lit => - if lit.1 then Polynomial.C δ - Polynomial.ofCoeffList lit.2 - else Polynomial.ofCoeffList lit.2).prod).map (Int.castRingHom ℚ)) = - Polynomial.C (δ : ℚ) ^ C.length * MvPolynomial.aeval - (fun v => (Polynomial.ofCoeffList (varJet v)).map (Int.castRingHom ℚ) * - Polynomial.C ((δ : ℚ)⁻¹)) (clauseSatPoly ℚ C) := by - set qJet : V → Polynomial ℚ := fun v => - (Polynomial.ofCoeffList (varJet v)).map (Int.castRingHom ℚ) * Polynomial.C ((δ : ℚ)⁻¹) - have hCinv : (Polynomial.C (δ : ℚ)) * Polynomial.C ((δ : ℚ)⁻¹) = 1 := by - rw [← Polynomial.C_mul, mul_inv_cancel₀ (Int.cast_ne_zero.mpr hδ), Polynomial.C_1] - have hlit (l : Std.Sat.Literal V) : - (if l.2 then Polynomial.C δ - Polynomial.ofCoeffList (varJet l.1) - else Polynomial.ofCoeffList (varJet l.1)).map (Int.castRingHom ℚ) = - Polynomial.C (δ : ℚ) * MvPolynomial.aeval qJet (1 - literalPoly ℚ l) := by - rcases l with ⟨v, _ | _⟩ - · simp only [Bool.false_eq_true, ↓reduceIte, literalPoly_neg, sub_sub_cancel, - MvPolynomial.aeval_X, qJet] - calc _ = (Polynomial.ofCoeffList (varJet v)).map (Int.castRingHom ℚ) * - (Polynomial.C (δ : ℚ) * Polynomial.C ((δ : ℚ)⁻¹)) := by rw [hCinv, mul_one] - _ = _ := by ring - · simp only [↓reduceIte, literalPoly_pos, Polynomial.map_sub, Polynomial.map_C, - Int.coe_castRingHom, map_sub, map_one, MvPolynomial.aeval_X, qJet] - calc _ = Polynomial.C (δ : ℚ) * 1 - - (Polynomial.ofCoeffList (varJet v)).map (Int.castRingHom ℚ) * - (Polynomial.C (δ : ℚ) * Polynomial.C ((δ : ℚ)⁻¹)) := by rw [mul_one, hCinv, mul_one] - _ = _ := by ring - rw [List.length_map, Polynomial.map_sub, Polynomial.map_C, map_pow, Int.coe_castRingHom, - Polynomial.C_pow, Polynomial.map_list_prod, clauseSatPoly, map_sub, map_one, map_list_prod, - mul_sub, mul_one] - congr 1; simp only [List.map_map, Function.comp_def] - induction C with - | nil => simp - | cons l C ih => - rw [List.length_cons, pow_succ', List.map_cons, List.map_cons, List.prod_cons, List.prod_cons, - ih, hlit l]; ring - -/-- **Rational `clauseSatPoly` congruence for `evalClauseClearedJet`**: when `δ ≠ 0`, -`evalClauseClearedJet` on `C` is congruent modulo `X ^ J` over `ℚ[X]` to `δ ^ |C| * Φ_C(X̃ / δ)`. -/ -theorem X_pow_dvd_evalClauseClearedJet_clauseSatPoly {V : Type*} (J : ℕ) {δ : ℤ} (hδ : δ ≠ 0) - (varJet : V → List ℤ) (C : Clause V) : - (Polynomial.X : Polynomial ℚ) ^ J ∣ - (Polynomial.ofCoeffList (evalClauseClearedJet J δ (C.map fun l => (l.2, varJet l.1)))).map - (Int.castRingHom ℚ) - - Polynomial.C (δ : ℚ) ^ C.length * MvPolynomial.aeval - (fun v => (Polynomial.ofCoeffList (varJet v)).map (Int.castRingHom ℚ) * - Polynomial.C ((δ : ℚ)⁻¹)) (clauseSatPoly ℚ C) := by - have hdvd := X_pow_dvd_map_rat - (X_pow_dvd_evalClauseClearedJet J δ (C.map fun l => (l.2, varJet l.1))) - rwa [Polynomial.map_sub, cleared_clauseSatPoly_rat_eq δ hδ varJet C] at hdvd - -/-- **Rational `cnfSatPoly` congruence for `evalGroupClauseProductJet`**: when `δ ≠ 0`, -`evalGroupClauseProductJet` on `φ` is congruent modulo `X ^ J` over `ℚ[X]` to -`δ ^ φ.totalLiterals * Φ_φ(X̃ / δ)`. -/ -theorem X_pow_dvd_evalGroupClauseProductJet_cnfSatPoly {V : Type*} (J : ℕ) {δ : ℤ} (hδ : δ ≠ 0) - (varJet : V → List ℤ) (φ : CNF V) : - (Polynomial.X : Polynomial ℚ) ^ J ∣ - (Polynomial.ofCoeffList (evalGroupClauseProductJet J δ - (φ.map fun C => C.map fun l => (l.2, varJet l.1)))).map (Int.castRingHom ℚ) - - Polynomial.C (δ : ℚ) ^ φ.totalLiterals * MvPolynomial.aeval - (fun v => (Polynomial.ofCoeffList (varJet v)).map (Int.castRingHom ℚ) * - Polynomial.C ((δ : ℚ)⁻¹)) (cnfSatPoly ℚ φ) := by - have hprod : - (φ.map fun C : Clause V => Polynomial.map (Int.castRingHom ℚ) - (Polynomial.C (δ ^ (C.map fun l => (l.2, varJet l.1)).length) - - ((C.map fun l => (l.2, varJet l.1)).map fun lit => - if lit.1 then Polynomial.C δ - Polynomial.ofCoeffList lit.2 - else Polynomial.ofCoeffList lit.2).prod)).prod = - Polynomial.C (δ : ℚ) ^ φ.totalLiterals * MvPolynomial.aeval - (fun v => (Polynomial.ofCoeffList (varJet v)).map (Int.castRingHom ℚ) * - Polynomial.C ((δ : ℚ)⁻¹)) (cnfSatPoly ℚ φ) := by - induction φ with - | nil => simp - | cons C φ ih => - rw [List.map_cons, List.prod_cons, ih, totalLiterals_cons, pow_add, cnfSatPoly_cons, map_mul, - cleared_clauseSatPoly_rat_eq δ hδ varJet C]; ring - have hdvd := X_pow_dvd_map_rat - (X_pow_dvd_evalGroupClauseProductJet J δ (φ.map fun C => C.map fun l => (l.2, varJet l.1))) - rw [Polynomial.map_sub, Polynomial.map_list_prod] at hdvd - simp only [List.map_map, Function.comp_def] at hprod hdvd - rwa [hprod] at hdvd - -/-- Explicit `ℓ₁` bound on `evalClauseClearedJet` in terms of the literal `ℓ₁` norms. -/ -theorem coeffNorm1_evalClauseClearedJet_le (J : ℕ) (δ : ℤ) (litJets : List (Bool × List ℤ)) : - (Polynomial.ofCoeffList (evalClauseClearedJet J δ litJets)).coeffNorm1 ≤ - 2 * (litJets.map fun lit => δ.natAbs + (Polynomial.ofCoeffList lit.2).coeffNorm1).prod := by - unfold evalClauseClearedJet - refine (IntJet.coeffNorm1_subConst_le J (δ ^ litJets.length) _).trans ?_ - rw [Int.natAbs_pow, Nat.two_mul] - have hpow : δ.natAbs ^ litJets.length ≤ - (litJets.map fun lit => δ.natAbs + (Polynomial.ofCoeffList lit.2).coeffNorm1).prod := by - induction litJets with - | nil => simp - | cons _ _ ih => - rw [List.length_cons, Nat.pow_succ', List.map_cons, List.prod_cons] - exact Nat.mul_le_mul (Nat.le_add_right _ _) ih - have hfold := IntJet.coeffNorm1_foldl_mulZJet_le J litJets - (fun lit => if lit.1 then IntJet.subConst J δ lit.2 else lit.2) - (fun lit => δ.natAbs + (Polynomial.ofCoeffList lit.2).coeffNorm1) - (fun lit _ => by - cases lit.1 - · exact Nat.le_add_left _ _ - · exact IntJet.coeffNorm1_subConst_le J δ lit.2) (Cslib.truncZJet J [1]) - have h1 : (Polynomial.ofCoeffList (Cslib.truncZJet J [1])).coeffNorm1 ≤ 1 := - IntJet.coeffNorm1_truncZJet_singleton_le J 1 - exact Nat.add_le_add hpow - (hfold.trans (by simpa only [Nat.one_mul] using Nat.mul_le_mul_right _ h1)) - -/-- Uniform `ℓ₁` bound on `evalClauseClearedJet` when every literal jet has `coeffNorm1 ≤ B`. -/ -theorem coeffNorm1_evalClauseClearedJet_le_pow (J : ℕ) (δ : ℤ) - (litJets : List (Bool × List ℤ)) (B : ℕ) - (hB : ∀ lit ∈ litJets, (Polynomial.ofCoeffList lit.2).coeffNorm1 ≤ B) : - (Polynomial.ofCoeffList (evalClauseClearedJet J δ litJets)).coeffNorm1 ≤ - 2 * (δ.natAbs + B) ^ litJets.length := by - refine (coeffNorm1_evalClauseClearedJet_le J δ litJets).trans (Nat.mul_le_mul_left 2 ?_) - induction litJets with - | nil => simp - | cons lit _ ih => - rw [List.map_cons, List.prod_cons, List.length_cons, Nat.pow_succ'] - exact Nat.mul_le_mul (Nat.add_le_add_left (hB lit List.mem_cons_self) _) - (ih fun m hm => hB m (List.mem_cons_of_mem _ hm)) - -/-- Explicit `ℓ₁` bound on `evalGroupClauseProductJet` across all clauses. -/ -theorem coeffNorm1_evalGroupClauseProductJet_le (J : ℕ) (δ : ℤ) - (clauses : List (List (Bool × List ℤ))) : - (Polynomial.ofCoeffList (evalGroupClauseProductJet J δ clauses)).coeffNorm1 ≤ - (clauses.map fun C => - 2 * (C.map fun lit => δ.natAbs + (Polynomial.ofCoeffList lit.2).coeffNorm1).prod).prod := by - unfold evalGroupClauseProductJet - have h1 : (Polynomial.ofCoeffList (Cslib.truncZJet J [1])).coeffNorm1 ≤ 1 := - IntJet.coeffNorm1_truncZJet_singleton_le J 1 - exact (IntJet.coeffNorm1_foldl_mulZJet_le J clauses (evalClauseClearedJet J δ) _ - (fun C _ => coeffNorm1_evalClauseClearedJet_le J δ C) (Cslib.truncZJet J [1])).trans - (by simpa only [Nat.one_mul] using Nat.mul_le_mul_right _ h1) - -/-- **Appendix B.4 `ℓ₁` norm bound on `evalGroupClauseProductJet`**: if every input literal jet has -`coeffNorm1 ≤ B`, then the product has `coeffNorm1 ≤ 2 ^ |clauses| * (|δ| + B) ^ (∑ |C|)`. -/ -theorem coeffNorm1_evalGroupClauseProductJet_le_pow (J : ℕ) (δ : ℤ) - (clauses : List (List (Bool × List ℤ))) (B : ℕ) - (hB : ∀ C ∈ clauses, ∀ lit ∈ C, (Polynomial.ofCoeffList lit.2).coeffNorm1 ≤ B) : - (Polynomial.ofCoeffList (evalGroupClauseProductJet J δ clauses)).coeffNorm1 ≤ - 2 ^ clauses.length * (δ.natAbs + B) ^ (clauses.map List.length).sum := by - unfold evalGroupClauseProductJet - have h1 : (Polynomial.ofCoeffList (Cslib.truncZJet J [1])).coeffNorm1 ≤ 1 := - IntJet.coeffNorm1_truncZJet_singleton_le J 1 - refine (IntJet.coeffNorm1_foldl_mulZJet_le J clauses (evalClauseClearedJet J δ) - (fun C => 2 * (δ.natAbs + B) ^ C.length) - (fun C hC => coeffNorm1_evalClauseClearedJet_le_pow J δ C B (hB C hC)) - (Cslib.truncZJet J [1])).trans ?_ - refine (Nat.mul_le_mul_right _ h1).trans ?_ - rw [Nat.one_mul] - induction clauses with - | nil => simp - | cons C cs ih => - rw [List.map_cons, List.prod_cons, List.length_cons, List.map_cons, List.sum_cons, - Nat.pow_succ', pow_add] - exact (Nat.mul_le_mul_left _ (ih fun D hD => hB D (List.mem_cons_of_mem _ hD))).trans_eq - (by ring) - -/-- **Appendix B.4 binary bit-length bound** (applicable to `clauses` and to every prefix -`clauses.take i`): when every literal jet in `clauses` has `coeffNorm1 ≤ B`, every output -coefficient of `evalGroupClauseProductJet J δ clauses` has `encIntBin` bit-length at most -`clauses.length + (clauses.map List.length).sum * (δ.natAbs + B).size + 3`. -/ -theorem length_encIntBin_getD_evalGroupClauseProductJet_le (J : ℕ) (δ : ℤ) - (clauses : List (List (Bool × List ℤ))) (B : ℕ) - (hB : ∀ C ∈ clauses, ∀ lit ∈ C, (Polynomial.ofCoeffList lit.2).coeffNorm1 ≤ B) (k : ℕ) : - (encIntBin ((evalGroupClauseProductJet J δ clauses).getD k 0)).length ≤ - clauses.length + (clauses.map List.length).sum * (δ.natAbs + B).size + 3 := by - refine (IntJet.length_encIntBin_getD_le_coeffNorm1 _ k).trans ?_ - have hsize := (Nat.size_le_size (coeffNorm1_evalGroupClauseProductJet_le_pow J δ clauses B - hB)).trans (Nat.size_mul_le _ _) - have h2 : (2 ^ clauses.length).size ≤ clauses.length + 1 := - Nat.size_le.mpr (Nat.pow_lt_pow_right (by omega) (Nat.lt_succ_self _)) - have hpow := Nat.size_pow_le (δ.natAbs + B) (clauses.map List.length).sum - omega - -section PolyTime - -local notation "encJet" => encList encIntBin -local notation "encLitJet" => encPair encBool (encList encIntBin) -local notation "encClauseJet" => encList (encPair encBool (encList encIntBin)) - -@[fun_prop] theorem computableInPolyTime_evalClauseClearedJet' {γ : Type} {encIn : γ ↪ List Bool} - {J : γ → ℕ} {δ : γ → ℤ} {litJets : γ → List (Bool × List ℤ)} - (hJ : ComputableInPolyTime J encIn encUnary) (hδ : ComputableInPolyTime δ encIn encIntBin) - (hlits : ComputableInPolyTime litJets encIn encClauseJet) : - ComputableInPolyTime (fun x => evalClauseClearedJet (J x) (δ x) (litJets x)) encIn encJet := by - unfold evalClauseClearedJet - have hfold := IntJet.computableInPolyTime_foldl_mulZJet encLitJet - (fun j d lit => if lit.1 then IntJet.subConst j d lit.2 else lit.2) hJ hδ hlits (by fun_prop) - (K := fun x => (encIntBin (δ x)).length + 2 * (encClauseJet (litJets x)).length + 2) - ((hδ.tidy.polyBounded_length.add ((PolyBounded.const 2).mul hlits.tidy.polyBounded_length)).add - (.const 2)) - (fun x lit hlit => by - have hδ_sz : (δ x).natAbs.size ≤ (encIntBin (δ x)).length := by rw [length_encIntBin]; omega - have hlit_enc : (encJet lit.2).length ≤ (encClauseJet (litJets x)).length := - (length_le_encPair_right encBool encJet lit).trans (length_le_encList_of_mem encLitJet hlit) - have hlit_sz := IntJet.size_coeffNorm1_le_length_encList lit.2 - have hle : (Polynomial.ofCoeffList - (if lit.1 then IntJet.subConst (J x) (δ x) lit.2 else lit.2)).coeffNorm1 ≤ - (δ x).natAbs + (Polynomial.ofCoeffList lit.2).coeffNorm1 := by - cases lit.1; exacts [Nat.le_add_left _ _, IntJet.coeffNorm1_subConst_le (J x) (δ x) lit.2] - have hsz := (Nat.size_le_size hle).trans (Nat.size_add_le _ _) - omega) - have hpow : ComputableInPolyTime (fun x => (δ x) ^ (litJets x).length) encIn encIntBin := - .of_tidy (ComputableTidilyInPolyTime.intBin_pow' hδ.tidy - ((ComputableTidilyInPolyTime.length_list encLitJet).comp' hlits.tidy)) - exact IntJet.computableInPolyTime_subConst' hJ hpow hfold - -theorem computableInPolyTime_evalClauseClearedJet : - ComputableInPolyTime - (fun p : (ℕ × ℤ) × List (Bool × List ℤ) => evalClauseClearedJet p.1.1 p.1.2 p.2) - (encPair (encPair encUnary encIntBin) encClauseJet) encJet := by fun_prop - -@[fun_prop] theorem computableInPolyTime_evalGroupClauseProductJet' {γ : Type} - {encIn : γ ↪ List Bool} {J : γ → ℕ} {δ : γ → ℤ} - {clauses : γ → List (List (Bool × List ℤ))} - (hJ : ComputableInPolyTime J encIn encUnary) (hδ : ComputableInPolyTime δ encIn encIntBin) - (hclauses : ComputableInPolyTime clauses encIn (encList encClauseJet)) : - ComputableInPolyTime (fun x => evalGroupClauseProductJet (J x) (δ x) (clauses x)) - encIn encJet := by - unfold evalGroupClauseProductJet - exact IntJet.computableInPolyTime_foldl_mulZJet encClauseJet evalClauseClearedJet - hJ hδ hclauses (by fun_prop) - (K := fun x => - let M := (encIntBin (δ x)).length + (encList encClauseJet (clauses x)).length - 3 + M * (3 * M + 2)) - ((PolyBounded.const 3).add ((hδ.tidy.polyBounded_length.add - hclauses.tidy.polyBounded_length).mul (((PolyBounded.const 3).mul - (hδ.tidy.polyBounded_length.add hclauses.tidy.polyBounded_length)).add (.const 2)))) - (fun x C hC => by - dsimp only - set M := (encIntBin (δ x)).length + (encList encClauseJet (clauses x)).length - have hδ_sz : (δ x).natAbs.size ≤ M := by have h := length_encIntBin (δ x); omega - have hC_enc : (encClauseJet C).length ≤ M := - (length_le_encList_of_mem encClauseJet hC).trans (Nat.le_add_left _ _) - have hC_len : C.length ≤ M := (length_le_length_encList encLitJet C).trans hC_enc - have hB : ∀ lit ∈ C, (Polynomial.ofCoeffList lit.2).coeffNorm1 ≤ 2 ^ (2 * M) := - fun lit hlit => Nat.le_of_lt (Nat.size_le.mp - ((IntJet.size_coeffNorm1_le_length_encList lit.2).trans (Nat.mul_le_mul_left 2 - ((length_le_encPair_right encBool encJet lit).trans - ((length_le_encList_of_mem encLitJet hlit).trans hC_enc))))) - have h2pow : (2 ^ (2 * M)).size ≤ 2 * M + 1 := - Nat.size_le.mpr (Nat.pow_lt_pow_right (by omega) (Nat.lt_succ_self _)) - have hadd_sz : ((δ x).natAbs + 2 ^ (2 * M)).size ≤ 3 * M + 2 := - (Nat.size_add_le _ _).trans (by omega) - have hpow_sz : (((δ x).natAbs + 2 ^ (2 * M)) ^ C.length).size ≤ M * (3 * M + 2) + 1 := - (Nat.size_pow_le _ C.length).trans (Nat.add_le_add_right (Nat.mul_le_mul hC_len hadd_sz) 1) - have h2sz : (2 : ℕ).size ≤ 2 := Nat.size_le.mpr (by omega) - have hsz := (Nat.size_le_size (coeffNorm1_evalClauseClearedJet_le_pow (J x) (δ x) C - (2 ^ (2 * M)) hB)).trans (Nat.size_mul_le 2 _) - omega) - -theorem computableInPolyTime_evalGroupClauseProductJet : - ComputableInPolyTime - (fun p : (ℕ × ℤ) × List (List (Bool × List ℤ)) => - evalGroupClauseProductJet p.1.1 p.1.2 p.2) - (encPair (encPair encUnary encIntBin) (encList encClauseJet)) encJet := by fun_prop - -end PolyTime - -end Cslib.Logic.PL.CNF diff --git a/Complexity/Foundations/BooleanAnalysis/SparseHermiteJetRecovery.lean b/Complexity/Foundations/BooleanAnalysis/SparseHermiteJetRecovery.lean deleted file mode 100644 index 923e8a4779..0000000000 --- a/Complexity/Foundations/BooleanAnalysis/SparseHermiteJetRecovery.lean +++ /dev/null @@ -1,225 +0,0 @@ -/- -Copyright (c) 2026 Samuel Schlesinger. All rights reserved. -Released under Apache 2.0 license as described in the file LICENSE. -Authors: Samuel Schlesinger --/ - -module --- upstream: candidate - -public import Complexity.Init -public import Complexity.Foundations.BooleanAnalysis.SparseHermiteRecovery - -/-! -# Stage-1/Stage-2 jet-table Hermite–Cramer recovery - -This module connects `clearedParityJetTable` to the Hermite–Cramer recovery API in -`Complexity.Foundations.BooleanAnalysis.SparseHermiteRecovery`. It proves coordinate recovery -for finite parity systems and branch-summed recovery over arbitrary finite variable types, -independently of CNF formulas. The CNF specializations and examination bounds are in -`Complexity.Computability.Complexity.FineGrained.GeneralCNFHermiteRecovery`. - -## Main results - -* `Cslib.BitString.hermiteCramerNumerator_clearedParityJetTable_eq_mul`, - `Cslib.BitString.emod_sum_hermiteCramerNumerator_clearedParityJetTable_ediv_eq_commonZeroCount`, - `Cslib.BitString.emod_sum_hermiteCramerNumerator_clearedParityJetTable_design_eq_commonZeroCount`, - `Cslib.BitString.commonZeroCount_eq_sum_branch_hermiteCramerNumerator_design_of_fintype`, - `Cslib.BitString.commonZeroCount_eq_sum_branch_clearedParityJetTable_design` - -## References - -* [OpenAI, *The Exponential Time Hypothesis is False*][OpenAI2026ETH] - (Sections 5.4–5.5 and Appendix B.2–B.3, printed pp. 37–39, 48–50) --/ - -@[expose] public noncomputable section - -open Finset Polynomial -open scoped BigOperators - -namespace Cslib.BitString - -open Cslib.LinearAlgebra - -variable {ι κ : Type*} - -/-- **Cramer numerator factorization for `clearedParityJetTable` (Appendix B.2–B.3, eq. `(B.1)`, -pp. 48–50)**: when `(k * R_deg) * (#I + 2 * (ℓ - 1)) < Q * J`, the Cramer determinant of the -`s`-th `V`-degree coordinate (`s : Fin ℓ`) of the Stage-1/Stage-2 integer Taylor-jet table -`clearedParityJetTable I P d_den k ℓ J θ` at `nodes` equals -`(Polynomial.hermiteMatrix nodes J).det *` -`(univariateClearedParityCoord I P d_den k ℓ θ s.1).eval 0`. -/ -theorem hermiteCramerNumerator_clearedParityJetTable_eq_mul [Fintype ι] [DecidableEq ι] - (I : Finset κ) (P : κ → Finset (Finset ι)) (d_den : ℤ) {k ℓ R_deg Q J : ℕ} - (nodes : Fin Q → ℤ) (hQ : 0 < Q) (hJ : 0 < J) - (θ : (ι → Bool) → κ → ι → Polynomial ℤ) - (hk : ∀ i ∈ I, ∀ M ∈ P i, #M ≤ k) - (hθ : ∀ x : ι → Bool, ∀ i ∈ I, ∀ M ∈ P i, ∀ v ∈ M, (θ x i v).natDegree ≤ R_deg) - (hQJ : (k * R_deg) * (#I + 2 * (ℓ - 1)) < Q * J) (s : Fin ℓ) : - hermiteCramerNumerator nodes hQ hJ - (fun t j => clearedParityJetTable I P d_den k ℓ J θ (nodes t) j s) = - (Polynomial.hermiteMatrix nodes J).det * - (univariateClearedParityCoord I P d_den k ℓ θ s.1).eval 0 := by - simp only [clearedParityJetTable_apply] - exact hermiteCramerNumerator_univariateClearedParityCoord_eq_mul I P d_den nodes hQ hJ θ hk hθ - hQJ s.2 - -/-- **Unconditional Stage-1/Stage-2 `clearedParityJetTable` Hermite–Cramer coordinate recovery of -`commonZeroCount` (Appendix B.2–B.3, eq. `(B.1)`, pp. 48–50)**: at distinct integer nodes -`nodes : Fin Q → ℤ` with `(k * R_deg) * (#I + 2 * (ℓ - 1)) < Q * J`, `d_den ≠ 0`, and -`Fintype.card ι < ℓ`, summing the exact integer Cramer quotients of `clearedParityJetTable` over -`s : Fin ℓ` and reducing modulo `2 ^ ℓ` recovers `commonZeroCount I P`. -/ -theorem emod_sum_hermiteCramerNumerator_clearedParityJetTable_ediv_eq_commonZeroCount - [Fintype ι] [DecidableEq ι] (I : Finset κ) (P : κ → Finset (Finset ι)) {d_den : ℤ} - (hd : d_den ≠ 0) {k ℓ R_deg Q J : ℕ} {nodes : Fin Q → ℤ} (hnodes : Function.Injective nodes) - (hQ : 0 < Q) (hJ : 0 < J) (hℓ : Fintype.card ι < ℓ) - (θ : (ι → Bool) → κ → ι → Polynomial ℤ) - (hk : ∀ i ∈ I, ∀ M ∈ P i, #M ≤ k) - (hdeg : ∀ x : ι → Bool, ∀ i ∈ I, ∀ M ∈ P i, ∀ v ∈ M, (θ x i v).natDegree ≤ R_deg) - (hθ : ∀ x : ι → Bool, ∀ i ∈ I, ∀ M ∈ P i, ∀ v ∈ M, - (θ x i v).eval 0 = d_den * bitVal ℤ (x v)) - (hQJ : (k * R_deg) * (#I + 2 * (ℓ - 1)) < Q * J) : - (∑ s : Fin ℓ, - hermiteCramerNumerator nodes hQ hJ - (fun t j => clearedParityJetTable I P d_den k ℓ J θ (nodes t) j s) / - (clearedProductDenom d_den k ℓ #I * (Polynomial.hermiteMatrix nodes J).det)) % - ((2 : ℤ) ^ ℓ) = - commonZeroCount I P := by - simp only [clearedParityJetTable_apply] - rw [Fin.sum_univ_eq_sum_range (fun s => - hermiteCramerNumerator nodes hQ hJ - (fun t j => - (Polynomial.taylor (nodes t) - (univariateClearedParityCoord I P d_den k ℓ θ s)).coeff j.1) / - (clearedProductDenom d_den k ℓ #I * (Polynomial.hermiteMatrix nodes J).det))] - exact emod_sum_hermiteCramerNumerator_ediv_eq_commonZeroCount I P hd hnodes hQ hJ hℓ θ hk hdeg - hθ hQJ - -/-- **Concrete `ReplacementDesign` Stage-1/Stage-2 `clearedParityJetTable` Hermite–Cramer -coordinate recovery of `commonZeroCount` (§5.4 & Appendix B.2–B.3, eq. `(B.1)`, pp. 48–50)**: -for any `D : ReplacementDesign scope Q r A₀ R τ` with `0 < Q`, `0 < J`, `n < ℓ`, -`∀ i ∈ I, ∀ M ∈ P i, #M ≤ k`, and `(k * (R - 1)) * (#I + 2 * (ℓ - 1)) < Q * J`, summing the -Cramer quotients of `clearedParityJetTable` at `nodeInt` over `s : Fin ℓ` and reducing modulo -`2 ^ ℓ` recovers `commonZeroCount I P`. -/ -theorem emod_sum_hermiteCramerNumerator_clearedParityJetTable_design_eq_commonZeroCount - {n Q r A₀ R : ℕ} {τ : ℚ} {F : Type*} [Fintype F] - {scope : F → Finset (Fin n)} (D : ReplacementDesign scope Q r A₀ R τ) (emb : κ → F) - (I : Finset κ) (P : κ → Finset (Finset (Fin n))) {k ℓ J : ℕ} - (hQ : 0 < Q) (hJ : 0 < J) (hℓ : n < ℓ) - (hk : ∀ i ∈ I, ∀ M ∈ P i, #M ≤ k) - (hQJ : (k * (R - 1)) * (#I + 2 * (ℓ - 1)) < Q * J) : - (∑ s : Fin ℓ, - hermiteCramerNumerator (nodeInt (Q := Q)) hQ hJ - (fun t j => - clearedParityJetTable I P (commonDenom Q R : ℤ) k ℓ J - (designReplacementScaledIntMap D emb) (nodeInt t) j s) / - (clearedProductDenom (commonDenom Q R : ℤ) k ℓ #I * - (Polynomial.hermiteMatrix (nodeInt (Q := Q)) J).det)) % ((2 : ℤ) ^ ℓ) = - commonZeroCount I P := by - simp only [clearedParityJetTable_apply] - rw [Fin.sum_univ_eq_sum_range (fun s => - hermiteCramerNumerator (nodeInt (Q := Q)) hQ hJ - (fun t j => - (Polynomial.taylor (nodeInt t) - (univariateClearedParityCoord I P (commonDenom Q R : ℤ) k ℓ - (designReplacementScaledIntMap D emb) s)).coeff j.1) / - (clearedProductDenom (commonDenom Q R : ℤ) k ℓ #I * - (Polynomial.hermiteMatrix (nodeInt (Q := Q)) J).det))] - exact emod_sum_hermiteCramerNumerator_design_eq_commonZeroCount D emb I P hQ hJ hℓ hk hQJ - -/-- **§5.5 & Appendix B.3 branch-summed Hermite–Cramer truncated-sum recovery of `commonZeroCount` -over arbitrary finite variable types `[Fintype ι] [DecidableEq ι]`**: given a heavy-variable subset -`S : Finset ι`, a free-variable relabeling `e : ↥(univ \ S) ≃ Fin n'`, and a per-branch -`ReplacementDesign` family `D b` (`0 < Q`), summing the branch modular residues of the concrete -`hermiteCramerNumerator` quotients at `nodeInt` and canonical jet order -`J = sparseParityJetOrder k R Q #I (branchPrecision (Fintype.card ι))` across -`b ∈ branchAssignments S` recovers `commonZeroCount I P`. -/ -theorem commonZeroCount_eq_sum_branch_hermiteCramerNumerator_design_of_fintype - [Fintype ι] [DecidableEq ι] {n' Q r A₀ R : ℕ} {τ : ℚ} - {F : (ι → Bool) → Type*} [∀ b, Fintype (F b)] - (S : Finset ι) (e : ↥(univ \ S) ≃ Fin n') - (I : Finset κ) (P : κ → Finset (Finset ι)) {k : ℕ} - (scope : (b : ι → Bool) → F b → Finset (Fin n')) - (D : (b : ι → Bool) → ReplacementDesign (scope b) Q r A₀ R τ) - (emb : (b : ι → Bool) → κ → F b) - (hQ : 0 < Q) (hk : ∀ i ∈ I, ∀ M ∈ P i, #M ≤ k) : - let ℓ := branchPrecision (Fintype.card ι) - let J := sparseParityJetOrder k R Q #I ℓ - (commonZeroCount I P : ℤ) = - ∑ b ∈ branchAssignments S, - (hermiteCramerNumerator (nodeInt (Q := Q)) hQ (sparseParityJetOrder_pos k R Q #I ℓ) - (fun t j => - (Polynomial.taylor (nodeInt t) - (univariateClearedParityTruncatedSum I - (fun i => relabelRestrictedMonomials S e b (P i)) - (commonDenom Q R : ℤ) k ℓ - (designReplacementScaledIntMap (D b) (emb b)))).coeff j) / - (clearedProductDenom (commonDenom Q R : ℤ) k ℓ #I * - (Polynomial.hermiteMatrix (nodeInt (Q := Q)) J).det)) % ((2 : ℤ) ^ ℓ) := by - intro ℓ J - rw [commonZeroCount_eq_sum_branch_emod_ediv_cleared S e I P (commonDenom_intCast_ne_zero Q R) - (fun b => designReplacementScaledIntMap (D b) (emb b)) hk - (fun b _ x j _ _ _ v _ => eval_zero_designReplacementScaledIntMap (D b) (emb b) x j v)] - refine sum_congr rfl fun b _ => ?_ - have hlt : n' < ℓ := by - have hle : n' ≤ Fintype.card ι := by - simpa only [Fintype.card_fin] using - (Fintype.card_congr e).symm.trans_le (Fintype.card_subtype_le _) - change n' < Fintype.card ι + 1 - omega - have hk_branch : ∀ i ∈ I, ∀ M ∈ relabelRestrictedMonomials S e b (P i), #M ≤ k := - fun i hi M hM => card_mem_relabelRestrictedMonomials_le (hk i hi) M hM - rw [emod_hermiteCramerNumerator_truncatedSum_design_eq_commonZeroCount (D b) (emb b) I - (fun i => relabelRestrictedMonomials S e b (P i)) hQ (sparseParityJetOrder_pos k R Q #I ℓ) - hlt hk_branch (lt_mul_sparseParityJetOrder k R #I ℓ hQ)] - exact emod_ediv_eval_zero_clearedParityTruncatedSum_design_eq_commonZeroCount (D b) (emb b) I - (fun i => relabelRestrictedMonomials S e b (P i)) hlt hk_branch - -/-- **§5.5 & Appendix B.2–B.3 branch-summed Stage-1/Stage-2 `clearedParityJetTable` Hermite–Cramer -coordinate recovery of `commonZeroCount` over arbitrary finite variable types**: under the same -hypotheses, summing the coordinate Cramer quotients of `clearedParityJetTable` over `s : Fin ℓ` -modulo `2 ^ ℓ` on each branch and summing across `b ∈ branchAssignments S` recovers -`commonZeroCount I P`. -/ -theorem commonZeroCount_eq_sum_branch_clearedParityJetTable_design - [Fintype ι] [DecidableEq ι] {n' Q r A₀ R : ℕ} {τ : ℚ} - {F : (ι → Bool) → Type*} [∀ b, Fintype (F b)] - (S : Finset ι) (e : ↥(univ \ S) ≃ Fin n') - (I : Finset κ) (P : κ → Finset (Finset ι)) {k : ℕ} - (scope : (b : ι → Bool) → F b → Finset (Fin n')) - (D : (b : ι → Bool) → ReplacementDesign (scope b) Q r A₀ R τ) - (emb : (b : ι → Bool) → κ → F b) - (hQ : 0 < Q) (hk : ∀ i ∈ I, ∀ M ∈ P i, #M ≤ k) : - let ℓ := branchPrecision (Fintype.card ι) - let J := sparseParityJetOrder k R Q #I ℓ - (commonZeroCount I P : ℤ) = - ∑ b ∈ branchAssignments S, - (∑ s : Fin ℓ, - hermiteCramerNumerator (nodeInt (Q := Q)) hQ (sparseParityJetOrder_pos k R Q #I ℓ) - (fun t j => - clearedParityJetTable I - (fun i => relabelRestrictedMonomials S e b (P i)) - (commonDenom Q R : ℤ) k ℓ J - (designReplacementScaledIntMap (D b) (emb b)) (nodeInt t) j s) / - (clearedProductDenom (commonDenom Q R : ℤ) k ℓ #I * - (Polynomial.hermiteMatrix (nodeInt (Q := Q)) J).det)) % ((2 : ℤ) ^ ℓ) := by - intro ℓ J - rw [commonZeroCount_eq_sum_branch_emod_ediv_cleared S e I P (commonDenom_intCast_ne_zero Q R) - (fun b => designReplacementScaledIntMap (D b) (emb b)) hk - (fun b _ x j _ _ _ v _ => eval_zero_designReplacementScaledIntMap (D b) (emb b) x j v)] - refine sum_congr rfl fun b _ => ?_ - have hlt : n' < ℓ := by - have hle : n' ≤ Fintype.card ι := by - simpa only [Fintype.card_fin] using - (Fintype.card_congr e).symm.trans_le (Fintype.card_subtype_le _) - change n' < Fintype.card ι + 1 - omega - have hk_branch : ∀ i ∈ I, ∀ M ∈ relabelRestrictedMonomials S e b (P i), #M ≤ k := - fun i hi M hM => card_mem_relabelRestrictedMonomials_le (hk i hi) M hM - rw [emod_sum_hermiteCramerNumerator_clearedParityJetTable_design_eq_commonZeroCount (D b) (emb b) - I (fun i => relabelRestrictedMonomials S e b (P i)) hQ (sparseParityJetOrder_pos k R Q #I ℓ) - hlt hk_branch (lt_mul_sparseParityJetOrder k R #I ℓ hQ)] - exact emod_ediv_eval_zero_clearedParityTruncatedSum_design_eq_commonZeroCount (D b) (emb b) I - (fun i => relabelRestrictedMonomials S e b (P i)) hlt hk_branch - -end Cslib.BitString diff --git a/Complexity/Logics/Propositional/CNF/SatisfactionPolynomial.lean b/Complexity/Logics/Propositional/CNF/SatisfactionPolynomial.lean deleted file mode 100644 index a5b3af8763..0000000000 --- a/Complexity/Logics/Propositional/CNF/SatisfactionPolynomial.lean +++ /dev/null @@ -1,417 +0,0 @@ -/- -Copyright (c) 2026 Anton Kovsharov. All rights reserved. -Released under Apache 2.0 license as described in the file LICENSE. -Authors: Anton Kovsharov --/ - -module --- upstream: candidate - -public import Complexity.Init -public import Complexity.Foundations.BooleanAnalysis.MultilinearExtension -public import Complexity.Foundations.Data.MvPolynomial.AffineTaylor -public import Complexity.Logics.Propositional.CNF.ModelCount.Declared -public import Mathlib.Algebra.MvPolynomial.Variables -import Mathlib.Algebra.BigOperators.Ring.List -import Mathlib.Algebra.MvPolynomial.CommRing -import Mathlib.Algebra.MvPolynomial.Rename -import Mathlib.Algebra.Polynomial.BigOperators -import Mathlib.Algebra.Polynomial.Degree.Lemmas - -/-! -# Clause satisfaction polynomials and univariate replacement counting families - -Algebraic encoding of propositional clauses, CNF formulas, and linear-form variable replacements -over an arbitrary commutative ring `R`, following §§2.1–2.3 (equations (2.1)–(2.4), pp. 7–9) of -[OpenAI, *The Exponential Time Hypothesis is False*][OpenAI2026ETH]. - -## Main definitions and results - -* `Cslib.Logic.PL.CNF.totalLiterals`, `Cslib.Logic.PL.CNF.totalLiterals_le_mul_card`. -* `Cslib.Logic.PL.CNF.literalPoly`, `Cslib.Logic.PL.CNF.clauseSatPoly`, - `Cslib.Logic.PL.CNF.cnfSatPoly`, `Cslib.Logic.PL.CNF.clauseOccurrenceSatPoly`, - `Cslib.Logic.PL.CNF.replacementCountPoly`. -* `Cslib.Logic.PL.CNF.eval_one_sub_literalPoly_bitPoint`, - `Cslib.Logic.PL.CNF.eval_clauseSatPoly_bitPoint`, `Cslib.Logic.PL.CNF.eval_cnfSatPoly_bitPoint`, - `Cslib.Logic.PL.CNF.sum_eval_cnfSatPoly_eq_modelCountOn`. -* `Cslib.Logic.PL.CNF.totalDegree_clauseSatPoly_le`, `Cslib.Logic.PL.CNF.vars_clauseSatPoly_subset`, - `Cslib.Logic.PL.CNF.totalDegree_cnfSatPoly_le`, - `Cslib.Logic.PL.CNF.eval_zero_replacementCountPoly`, - `Cslib.Logic.PL.CNF.natDegree_replacementCountPoly_le`. - -## References - -* [OpenAI, *The Exponential Time Hypothesis is False*][OpenAI2026ETH], §§2.1–2.3, pp. 7–9. --/ - -@[expose] public section - -open scoped BigOperators - -namespace Cslib.Logic.PL.CNF - -variable {V W : Type*} - -/-- Total number of literal occurrences across all clauses of `φ`, `M = ∑_{C ∈ φ} |C|` in equation -(2.1) of [OpenAI2026ETH]. -/ -abbrev totalLiterals (φ : CNF V) : ℕ := (φ.map List.length).sum - -@[simp] theorem totalLiterals_nil : totalLiterals ([] : CNF V) = 0 := rfl - -@[simp] theorem totalLiterals_cons (C : Clause V) (φ : CNF V) : - totalLiterals (C :: φ) = C.length + totalLiterals φ := by simp [totalLiterals] - -/-- `totalLiterals` equals the length of the flattened variable-occurrence list `φ.vars`. -/ -theorem totalLiterals_eq_length_vars (φ : CNF V) : φ.totalLiterals = φ.vars.length := - (CNF.length_vars φ).symm - -/-- Equation (2.1) occurrence bound: if every variable occurring in `φ` belongs to `declared` and -appears at most `k` times in `φ.vars`, then `φ.totalLiterals ≤ k * declared.card`. -/ -theorem totalLiterals_le_mul_card [DecidableEq V] {φ : CNF V} {declared : Finset V} {k : ℕ} - (hvars : φ.vars.toFinset ⊆ declared) (hocc : ∀ v ∈ φ.vars, φ.vars.count v ≤ k) : - φ.totalLiterals ≤ k * declared.card := by - rw [totalLiterals_eq_length_vars, ← List.sum_map_count_dedup_eq_length] - have hsum : (φ.vars.dedup.map fun v => φ.vars.count v).sum ≤ φ.vars.dedup.length * k := by - refine (List.sum_le_length_nsmul _ k fun n hn => ?_).trans (by simp) - rcases List.mem_map.mp hn with ⟨v, hv, rfl⟩ - exact hocc v (List.mem_dedup.mp hv) - have hcard : φ.vars.dedup.length ≤ declared.card := by - rw [← List.toFinset_card_of_nodup (List.nodup_dedup _)] - exact Finset.card_le_card fun v hv => - hvars (List.mem_toFinset.mpr (List.mem_dedup.mp (List.mem_toFinset.mp hv))) - exact hsum.trans ((Nat.mul_le_mul_right k hcard).trans (Nat.mul_comm _ _).le) - -/-- Satisfaction polynomial of a literal `l = (v, b)`: `X_v` when `b = true` and `1 - X_v` when -`b = false` (§2.2, p. 8 of [OpenAI2026ETH]). -/ -noncomputable def literalPoly (R : Type*) [CommRing R] (l : Std.Sat.Literal V) : - MvPolynomial V R := - if l.2 then MvPolynomial.X l.1 else 1 - MvPolynomial.X l.1 - -@[simp] theorem literalPoly_pos (R : Type*) [CommRing R] (v : V) : - literalPoly R (v, true) = MvPolynomial.X v := rfl - -@[simp] theorem literalPoly_neg (R : Type*) [CommRing R] (v : V) : - literalPoly R (v, false) = 1 - MvPolynomial.X v := rfl - -/-- The dissatisfaction factor `1 - literalPoly R l` is `1 - X_v` (`l.2 = true`) or `X_v` -(`l.2 = false`). -/ -theorem one_sub_literalPoly (R : Type*) [CommRing R] (l : Std.Sat.Literal V) : - 1 - literalPoly R l = if l.2 then 1 - MvPolynomial.X l.1 else MvPolynomial.X l.1 := by - rcases l with ⟨v, _ | _⟩; exacts [sub_sub_cancel 1 _, rfl] - -/-- Satisfaction polynomial of a clause `C`: `Φ_C(X) = 1 - ∏_{l ∈ C} (1 - L_l(X))` (§2.2, p. 8 of -[OpenAI2026ETH]). -/ -noncomputable def clauseSatPoly (R : Type*) [CommRing R] (C : Clause V) : MvPolynomial V R := - 1 - (C.map fun l => 1 - literalPoly R l).prod - -@[simp] theorem clauseSatPoly_nil (R : Type*) [CommRing R] : clauseSatPoly R ([] : Clause V) = 0 := - sub_self 1 - -/-- Evaluating `literalPoly R l` at `Cslib.BitString.bitPoint x` yields `1` if `l` holds under `x` -and `0` otherwise. -/ -theorem eval_literalPoly_bitPoint (R : Type*) [CommRing R] (x : V → Bool) (l : Literal V) : - MvPolynomial.eval (Cslib.BitString.bitPoint x) (literalPoly R l) = - if l.eval x then 1 else 0 := by - rcases l with ⟨v, _ | _⟩ <;> cases h : x v <;> - simp [literalPoly, Cslib.BitString.bitPoint, Literal.eval, h] - -/-- Evaluating `1 - literalPoly R l` at `Cslib.BitString.bitPoint x` yields `0` if `l` holds under -`x` and `1` otherwise. -/ -theorem eval_one_sub_literalPoly_bitPoint (R : Type*) [CommRing R] (x : V → Bool) - (l : Literal V) : - MvPolynomial.eval (Cslib.BitString.bitPoint x) (1 - literalPoly R l) = - if l.eval x then 0 else 1 := by - rw [map_sub, map_one, eval_literalPoly_bitPoint]; cases l.eval x <;> simp - -/-- Unconditional Boolean indicator property of `clauseSatPoly`: for every clause `C : Clause V` -(including `[]`, unit clauses, duplicate literals, and tautological clauses), `Φ_C` evaluates on -`Cslib.BitString.bitPoint x` to `1` when `C` is satisfied by `x` and `0` otherwise. -/ -theorem eval_clauseSatPoly_bitPoint (R : Type*) [CommRing R] (x : V → Bool) (C : Clause V) : - MvPolynomial.eval (Cslib.BitString.bitPoint x) (clauseSatPoly R C) = - if C.eval x then 1 else 0 := by - suffices hprod : MvPolynomial.eval (Cslib.BitString.bitPoint x) - ((C.map fun l => 1 - literalPoly R l).prod) = if C.eval x then 0 else 1 by - rw [clauseSatPoly, map_sub, map_one, hprod]; cases C.eval x <;> simp - induction C with - | nil => simp - | cons l C ih => - rw [List.map_cons, List.prod_cons, map_mul, eval_one_sub_literalPoly_bitPoint, ih, - Clause.eval_cons] - cases l.eval x <;> cases Clause.eval x C <;> simp - -theorem totalDegree_literalPoly_le (R : Type*) [CommRing R] (l : Std.Sat.Literal V) : - (literalPoly R l).totalDegree ≤ 1 := by - rcases l with ⟨v, _ | _⟩ - · exact (MvPolynomial.totalDegree_sub _ _).trans - (max_le (by simp) (MvPolynomial.totalDegree_X_le v)) - · exact MvPolynomial.totalDegree_X_le v - -theorem totalDegree_one_sub_literalPoly_le (R : Type*) [CommRing R] (l : Std.Sat.Literal V) : - (1 - literalPoly R l).totalDegree ≤ 1 := - (MvPolynomial.totalDegree_sub _ _).trans (max_le (by simp) (totalDegree_literalPoly_le R l)) - -/-- The total degree of `clauseSatPoly R C` is at most `C.length`. -/ -theorem totalDegree_clauseSatPoly_le (R : Type*) [CommRing R] (C : Clause V) : - (clauseSatPoly R C).totalDegree ≤ C.length := by - rw [clauseSatPoly] - refine (MvPolynomial.totalDegree_sub _ _).trans (max_le (by simp) ?_) - induction C with - | nil => simp - | cons l C ih => - rw [List.map_cons, List.prod_cons, List.length_cons, Nat.add_comm] - exact (MvPolynomial.totalDegree_mul _ _).trans - (Nat.add_le_add (totalDegree_one_sub_literalPoly_le R l) ih) - -/-- Every variable occurring in `clauseSatPoly R C` belongs to `C.map Prod.fst`. -/ -theorem vars_clauseSatPoly_subset {R : Type*} [CommRing R] {C : Clause V} {v : V} - (hv : v ∈ (clauseSatPoly R C).vars) : v ∈ C.map Prod.fst := by - classical - have hx_eq : ∀ {w : V}, v ∈ (MvPolynomial.X w : MvPolynomial V R).vars → v = w := - fun {w} hw => by - by_contra hne - exact (MvPolynomial.mem_vars_iff_degreeOf_ne_zero.mp hw) (MvPolynomial.degreeOf_X_of_ne hne) - unfold clauseSatPoly at hv - rcases Finset.mem_union.mp (MvPolynomial.vars_sub_subset 1 hv) with h1 | hp - · rw [MvPolynomial.vars_one] at h1; exact False.elim (Finset.notMem_empty v h1) - · clear hv - induction C with - | nil => - rw [List.map_nil, List.prod_nil, MvPolynomial.vars_one] at hp - exact False.elim (Finset.notMem_empty v hp) - | cons l D ih => - rw [List.map_cons, List.prod_cons] at hp - rcases Finset.mem_union.mp (MvPolynomial.vars_mul _ _ hp) with hl | hD' - · rcases l with ⟨w, _ | _⟩ - · rw [literalPoly_neg, sub_sub_cancel] at hl - rw [List.map_cons, hx_eq hl]; exact List.mem_cons_self - · rw [literalPoly_pos] at hl - rcases Finset.mem_union.mp (MvPolynomial.vars_sub_subset 1 hl) with h1 | hx - · rw [MvPolynomial.vars_one] at h1; exact False.elim (Finset.notMem_empty v h1) - · rw [List.map_cons, hx_eq hx]; exact List.mem_cons_self - · exact List.mem_cons_of_mem _ (ih hD') - -theorem rename_literalPoly (R : Type*) [CommRing R] (f : V → W) (l : Std.Sat.Literal V) : - MvPolynomial.rename f (literalPoly R l) = literalPoly R (Prod.map f id l) := by - rcases l with ⟨v, _ | _⟩ <;> simp [literalPoly, Prod.map] - -/-- Renaming variables in `clauseSatPoly` commutes with `Clause.relabel`. -/ -theorem rename_clauseSatPoly (R : Type*) [CommRing R] (f : V → W) (C : Clause V) : - MvPolynomial.rename f (clauseSatPoly R C) = clauseSatPoly R (C.relabel f) := by - unfold clauseSatPoly Clause.relabel - rw [map_sub, map_one, map_list_prod] - simp only [List.map_map, Function.comp_def, map_sub, map_one, rename_literalPoly] - -/-- Satisfaction polynomial of a CNF formula `φ`: `∏_{C ∈ φ} Φ_C` (equation (2.2), p. 8 of -[OpenAI2026ETH]). -/ -noncomputable def cnfSatPoly (R : Type*) [CommRing R] (φ : CNF V) : MvPolynomial V R := - (φ.map (clauseSatPoly R)).prod - -@[simp] theorem cnfSatPoly_nil (R : Type*) [CommRing R] : cnfSatPoly R ([] : CNF V) = 1 := rfl - -@[simp] theorem cnfSatPoly_cons (R : Type*) [CommRing R] (C : Clause V) (φ : CNF V) : - cnfSatPoly R (C :: φ) = clauseSatPoly R C * cnfSatPoly R φ := rfl - -/-- Renaming variables in `cnfSatPoly` commutes with `CNF.relabel`. -/ -theorem rename_cnfSatPoly (R : Type*) [CommRing R] (f : V → W) (φ : CNF V) : - MvPolynomial.rename f (cnfSatPoly R φ) = cnfSatPoly R (φ.relabel f) := by - unfold cnfSatPoly CNF.relabel - rw [map_list_prod]; simp only [List.map_map, Function.comp_def, rename_clauseSatPoly] - -/-- Evaluating `cnfSatPoly R φ` at `Cslib.BitString.bitPoint x` yields `1` when `φ` holds under `x` -and `0` otherwise. -/ -theorem eval_cnfSatPoly_bitPoint (R : Type*) [CommRing R] (x : V → Bool) (φ : CNF V) : - MvPolynomial.eval (Cslib.BitString.bitPoint x) (cnfSatPoly R φ) = - if φ.eval x then 1 else 0 := by - induction φ with - | nil => simp - | cons C φ ih => - rw [cnfSatPoly_cons, map_mul, eval_clauseSatPoly_bitPoint, ih, CNF.eval_cons] - cases C.eval x <;> cases CNF.eval x φ <;> simp - -/-- The total degree of `cnfSatPoly R φ` is at most `φ.totalLiterals` (§2.2, p. 8 of -[OpenAI2026ETH]). -/ -theorem totalDegree_cnfSatPoly_le (R : Type*) [CommRing R] (φ : CNF V) : - (cnfSatPoly R φ).totalDegree ≤ φ.totalLiterals := by - induction φ with - | nil => simp - | cons C φ ih => - rw [cnfSatPoly_cons, totalLiterals_cons] - exact (MvPolynomial.totalDegree_mul _ _).trans - (Nat.add_le_add (totalDegree_clauseSatPoly_le R C) ih) - -/-- Under `φ.totalLiterals ≤ 3 * n` (equation (2.1)), `(cnfSatPoly R φ).totalDegree ≤ 3 * n`. -/ -theorem totalDegree_cnfSatPoly_le_three_mul (R : Type*) [CommRing R] {φ : CNF V} {n : ℕ} - (hM : φ.totalLiterals ≤ 3 * n) : (cnfSatPoly R φ).totalDegree ≤ 3 * n := - (totalDegree_cnfSatPoly_le R φ).trans hM - -/-- Every variable occurring in `cnfSatPoly R φ` belongs to `φ.vars`. -/ -theorem vars_cnfSatPoly_subset {R : Type*} [CommRing R] {φ : CNF V} {v : V} - (hv : v ∈ (cnfSatPoly R φ).vars) : v ∈ φ.vars := by - classical - induction φ with - | nil => - rw [cnfSatPoly_nil, MvPolynomial.vars_one] at hv - exact False.elim (Finset.notMem_empty v hv) - | cons C φ ih => - rw [cnfSatPoly_cons] at hv - simp only [CNF.vars, List.flatten_cons, List.map_append, List.mem_append] - exact (Finset.mem_union.mp (MvPolynomial.vars_mul _ _ hv)).imp vars_clauseSatPoly_subset ih - -/-- **Declared-variable polynomial model-count identity** (equation (2.2), p. 8 of -[OpenAI2026ETH]): summing `cnfSatPoly R φ` over all Boolean assignments on `declared` (extended by -`false` outside `declared`) equals `(φ.modelCountOn declared : R)` unconditionally. -/ -theorem sum_eval_cnfSatPoly_eq_modelCountOn (R : Type*) [CommRing R] [DecidableEq V] - (φ : CNF V) (declared : Finset V) : - (∑ σ : declared → Bool, - MvPolynomial.eval - (Cslib.BitString.bitPoint (fun v => if h : v ∈ declared then σ ⟨v, h⟩ else false)) - (cnfSatPoly R φ)) = (φ.modelCountOn declared : R) := by - simp only [eval_cnfSatPoly_bitPoint, Finset.sum_boole]; rfl - -/-- Clause satisfaction polynomial with distinct formal inputs indexed by `Fin C.length`. -/ -noncomputable def clauseOccurrenceSatPoly (R : Type*) [CommRing R] (C : Clause V) : - MvPolynomial (Fin C.length) R := - clauseSatPoly R (List.ofFn fun j : Fin C.length => (j, C[j].2)) - -/-- Renaming each occurrence slot `j : Fin C.length` to `C[j].1` recovers `clauseSatPoly R C`. -/ -theorem rename_clauseOccurrenceSatPoly (R : Type*) [CommRing R] (C : Clause V) : - MvPolynomial.rename (fun j : Fin C.length => C[j].1) (clauseOccurrenceSatPoly R C) = - clauseSatPoly R C := by - rw [clauseOccurrenceSatPoly, rename_clauseSatPoly] - exact congrArg (clauseSatPoly R) - (List.ext_getElem (by simp [Clause.relabel]) fun i _ _ => by simp [Clause.relabel]) - -/-- **Univariate replacement counting polynomial** `H(T) ∈ Polynomial R` (equation (2.3), p. 9 of -[OpenAI2026ETH]), defined via `Cslib.AffineTaylor.replacedSum` by substituting for each clause -`e : Fin φ.length` and literal slot `j : Fin φ[e].length` the linear form -`∑_{i ∈ declared} rep e j i * X_i`. -/ -noncomputable def replacementCountPoly {R : Type*} [CommRing R] - (φ : CNF V) (declared : Finset V) - (rep : ∀ e : Fin φ.length, Fin φ[e].length → V → Polynomial R) : Polynomial R := - Cslib.AffineTaylor.replacedSum (Finset.univ : Finset (Fin φ.length)) - (fun e => clauseOccurrenceSatPoly R φ[e]) (fun e j (i : declared) => rep e j i.1) - -/-- When `rep` depends only on `(e, v)`, `replacementCountPoly` coincides directly with -`Cslib.AffineTaylor.replacedSum` on `clauseSatPoly R φ[e]`. -/ -theorem replacementCountPoly_of_var {R : Type*} [CommRing R] - (φ : CNF V) (declared : Finset V) (P : Fin φ.length → V → V → Polynomial R) : - replacementCountPoly φ declared (fun e j => P e φ[e][j].1) = - Cslib.AffineTaylor.replacedSum (Finset.univ : Finset (Fin φ.length)) - (fun e => clauseSatPoly R φ[e]) (fun e v (i : declared) => P e v i.1) := by - unfold replacementCountPoly Cslib.AffineTaylor.replacedSum - refine Finset.sum_congr rfl fun σ _ => Finset.prod_congr rfl fun e _ => ?_ - dsimp only; rw [← rename_clauseOccurrenceSatPoly R φ[e], MvPolynomial.aeval_rename]; rfl - -private theorem sum_eval_zero_rep_eq_bitPoint {R : Type*} [CommRing R] [DecidableEq V] - {declared : Finset V} (σ : declared → Bool) {p : V → Polynomial R} {v : V} - (hp : ∀ i ∈ declared, (p i).eval 0 = if i = v then 1 else 0) : - (∑ i : declared, (p i.1).eval 0 * Cslib.BitString.bitVal R (σ i)) = - Cslib.BitString.bitPoint (fun w => if h : w ∈ declared then σ ⟨w, h⟩ else false) v := by - have hterm : ∀ i : declared, (p i.1).eval 0 * Cslib.BitString.bitVal R (σ i) = - if i.1 = v then Cslib.BitString.bitVal R (σ i) else 0 := fun i => by - rw [hp i.1 i.2]; split_ifs <;> simp - simp only [hterm] - by_cases hv : v ∈ declared - · rw [Finset.sum_eq_single (⟨v, hv⟩ : declared) - (fun i _ hne => by simp only [show i.1 ≠ v from fun heq => hne (Subtype.ext heq), ↓reduceIte]) - (fun h => False.elim (h (Finset.mem_univ _)))] - simp [hv, Cslib.BitString.bitPoint] - · rw [Finset.sum_eq_zero fun i _ => - by simp only [show i.1 ≠ v from fun heq => hv (heq ▸ i.2), ↓reduceIte]] - simp [hv, Cslib.BitString.bitPoint] - -/-- **Restoration at `T = 0`** (first half of equation (2.4), p. 9 of [OpenAI2026ETH]): if every -replacement entry `rep e j i` for `i ∈ declared` evaluates at `0` to `1` when `i = φ[e][j].1` and -`0` otherwise, then `(replacementCountPoly φ declared rep).eval 0 = (φ.modelCountOn declared : R)` -unconditionally. -/ -theorem eval_zero_replacementCountPoly {R : Type*} [CommRing R] [DecidableEq V] - (φ : CNF V) (declared : Finset V) - (rep : ∀ e : Fin φ.length, Fin φ[e].length → V → Polynomial R) - (hzero : ∀ (e : Fin φ.length) (j : Fin φ[e].length), ∀ i ∈ declared, - (rep e j i).eval 0 = if i = φ[e][j].1 then 1 else 0) : - (replacementCountPoly φ declared rep).eval 0 = (φ.modelCountOn declared : R) := by - rw [replacementCountPoly, Cslib.AffineTaylor.eval_replacedSum, - ← sum_eval_cnfSatPoly_eq_modelCountOn R φ declared] - have huniv : ∀ (inst₁ inst₂ : Fintype (declared → Bool)), - @Finset.univ _ inst₁ = @Finset.univ _ inst₂ := fun _ _ => - Finset.ext fun _ => by simp only [Finset.mem_univ] - rw [huniv] - refine Finset.sum_congr rfl fun σ _ => ?_ - let ext : V → R := Cslib.BitString.bitPoint - (fun v => if h : v ∈ declared then σ ⟨v, h⟩ else false) - have hprod_eq : (∏ e : Fin φ.length, MvPolynomial.eval ext (clauseSatPoly R φ[e])) = - MvPolynomial.eval ext (cnfSatPoly R φ) := by - rw [cnfSatPoly, map_list_prod, ← List.prod_ofFn] - exact congrArg List.prod (List.ext_getElem (by simp) fun i _ _ => by simp) - rw [← hprod_eq] - refine Finset.prod_congr rfl fun e _ => ?_ - have hpt : (fun j : Fin φ[e].length => - ∑ i : declared, (rep e j i.1).eval 0 * Cslib.BitString.bitVal R (σ i)) = - fun j : Fin φ[e].length => ext φ[e][j].1 := - funext fun j => sum_eval_zero_rep_eq_bitPoint σ (hzero e j) - rw [hpt, ← Function.comp_def ext (fun j : Fin φ[e].length => φ[e][j].1), - ← MvPolynomial.eval_rename, rename_clauseOccurrenceSatPoly] - -private theorem natDegree_aeval_clauseSatPoly_le {R : Type*} [CommRing R] {κ : Type*} - (C : Clause κ) (g : κ → Polynomial R) (R_deg : ℕ) - (hg : ∀ l ∈ C, (g l.1).natDegree ≤ R_deg) : - (MvPolynomial.aeval g (clauseSatPoly R C)).natDegree ≤ C.length * R_deg := by - rw [clauseSatPoly, map_sub, map_one] - refine (Polynomial.natDegree_sub_le _ _).trans (max_le (by simp) ?_) - rw [map_list_prod] - induction C with - | nil => simp - | cons l C ih => - rw [List.map_cons, List.map_cons, List.prod_cons, List.length_cons, Nat.succ_mul, Nat.add_comm] - have hl_deg : (MvPolynomial.aeval g (1 - literalPoly R l)).natDegree ≤ R_deg := by - rw [one_sub_literalPoly] - rcases l with ⟨v, _ | _⟩ - · simpa only [Bool.false_eq_true, ↓reduceIte, MvPolynomial.aeval_X] using - hg (v, false) List.mem_cons_self - · simp only [↓reduceIte, map_sub, map_one, MvPolynomial.aeval_X] - exact (Polynomial.natDegree_sub_le _ _).trans - (max_le (by simp) (hg (v, true) List.mem_cons_self)) - exact Polynomial.natDegree_mul_le.trans - (Nat.add_le_add hl_deg (ih fun m hm => hg m (List.mem_cons_of_mem _ hm))) - -/-- **Degree bound on `replacementCountPoly`** (second half of equation (2.4), p. 9 of -[OpenAI2026ETH]): if every replacement entry `rep e j i` for `i ∈ declared` has univariate degree at -most `R_deg`, then `(replacementCountPoly φ declared rep).natDegree ≤ φ.totalLiterals * R_deg`. -/ -theorem natDegree_replacementCountPoly_le {R : Type*} [CommRing R] - (φ : CNF V) (declared : Finset V) - (rep : ∀ e : Fin φ.length, Fin φ[e].length → V → Polynomial R) (R_deg : ℕ) - (hdeg : ∀ (e : Fin φ.length) (j : Fin φ[e].length), ∀ i ∈ declared, - (rep e j i).natDegree ≤ R_deg) : - (replacementCountPoly φ declared rep).natDegree ≤ φ.totalLiterals * R_deg := by - classical - rw [replacementCountPoly, Cslib.AffineTaylor.replacedSum] - refine (Polynomial.natDegree_sum_le _ _).trans (Finset.sup_le fun σ _ => ?_) - have hlen_sum : (∑ e : Fin φ.length, φ[e].length) = φ.totalLiterals := by - rw [totalLiterals, ← List.sum_ofFn] - exact congrArg List.sum (List.ext_getElem (by simp) fun i _ _ => by simp) - calc - (∏ e : Fin φ.length, MvPolynomial.aeval - (fun j => ∑ i : declared, rep e j i.1 * Polynomial.C (Cslib.BitString.bitVal R (σ i))) - (clauseOccurrenceSatPoly R φ[e])).natDegree ≤ - ∑ e : Fin φ.length, φ[e].length * R_deg := by - refine (Polynomial.natDegree_prod_le _ _).trans (Finset.sum_le_sum fun e _ => ?_) - rw [clauseOccurrenceSatPoly] - refine (natDegree_aeval_clauseSatPoly_le _ _ R_deg fun l _ => ?_).trans - (by rw [List.length_ofFn]) - exact (Polynomial.natDegree_sum_le _ _).trans (Finset.sup_le fun i _ => - (Polynomial.natDegree_mul_C_le _ _).trans (hdeg e l.1 i.1 i.2)) - _ = φ.totalLiterals * R_deg := by rw [← Finset.sum_mul, hlen_sum] - -/-- Under `φ.totalLiterals ≤ 3 * declared.card` (equation (2.1)), `replacementCountPoly` has degree -at most `3 * declared.card * R_deg` (equation (2.4) of [OpenAI2026ETH]). -/ -theorem natDegree_replacementCountPoly_le_three_mul {R : Type*} [CommRing R] - (φ : CNF V) (declared : Finset V) - (rep : ∀ e : Fin φ.length, Fin φ[e].length → V → Polynomial R) (R_deg : ℕ) - (hM : φ.totalLiterals ≤ 3 * declared.card) - (hdeg : ∀ (e : Fin φ.length) (j : Fin φ[e].length), ∀ i ∈ declared, - (rep e j i).natDegree ≤ R_deg) : - (replacementCountPoly φ declared rep).natDegree ≤ 3 * declared.card * R_deg := - (natDegree_replacementCountPoly_le φ declared rep R_deg hdeg).trans - (Nat.mul_le_mul_right R_deg hM) - -end Cslib.Logic.PL.CNF diff --git a/ComplexityTests/Computability/Complexity/FineGrained/GeneralCNFCountingAsymptotics.lean b/ComplexityTests/Computability/Complexity/FineGrained/GeneralCNFCountingAsymptotics.lean deleted file mode 100644 index 9f115bbd5b..0000000000 --- a/ComplexityTests/Computability/Complexity/FineGrained/GeneralCNFCountingAsymptotics.lean +++ /dev/null @@ -1,327 +0,0 @@ -/- -Copyright (c) 2026 Samuel Schlesinger. All rights reserved. -Released under Apache 2.0 license as described in the file LICENSE. -Authors: Samuel Schlesinger --/ - -module - -public import Complexity.Init -public import Complexity.Computability.Complexity.FineGrained.GeneralCNFCountingAsymptotics - -/-! -# Tests for `Complexity.Computability.Complexity.FineGrained.GeneralCNFCountingAsymptotics` - -Exercises the normalized Proposition 6.4 leaf decomposition (`CNF.prop64NormalizedLeaves`), -leaf-count bounds against `numGroups` and `interpolationScale`, Lemma 6.2 candidate-query indexing -and bounds (`CNF.LeafCandidateQueryIndex`, `CNF.candidateQueryRows`, -`CNF.card_leafCandidateQueryIndex_eq`, `CNF.card_leafCandidateQueryIndex_le`, -`CNF.candidateQueryRows_length_and_weight_le`, `CNF.greedyRowListLength_le_mul_pow_clog`), and the -end-to-end candidate-indexed and tree-wide `ReplacementDesign` recovery and actual -`toCountingDesign` examination bounds on concrete 3-CNF formulas containing tautological clauses. --/ - -public noncomputable section - -namespace CslibTests - -open Finset -open Cslib.BitString -open Cslib.LinearAlgebra -open Cslib.Logic.PL -open Cslib.Logic.PL.ClauseSet.Sparsification -open Cslib.Complexity.SubexponentialSAT -open Cslib.Complexity.SubexponentialSAT.ReplacementParams - -/-- Concrete 3-CNF on `Fin 4` containing a width-3 tautological clause -`[(0, true), (0, false), (1, true)]` together with two non-tautological clauses -`(x₀ ∨ ¬x₁ ∨ x₂) ∧ (¬x₁ ∨ ¬x₃)`. -/ -def sampleTaut3CNF : CNF (Fin 4) := - [[(0, true), (0, false), (1, true)], - [(0, true), (1, false), (2, true)], - [(1, false), (3, false)]] - -theorem sampleTaut3CNF_width_le_three : - ∀ c ∈ sampleTaut3CNF, c.length ≤ 3 := by - decide - -theorem sampleTaut3CNF_modelCountOn_eq_eleven : - sampleTaut3CNF.modelCountOn Finset.univ = 11 := by - decide - -/-- Summing `L.toCNF.modelCountOn Finset.univ` across `sampleTaut3CNF.prop64NormalizedLeaves 3` -recovers the exact model count `11` despite the tautological clause in `sampleTaut3CNF`. -/ -theorem sampleTaut3CNF_sum_modelCountOn_prop64NormalizedLeaves : - ((sampleTaut3CNF.prop64NormalizedLeaves 3).map - fun L => L.toCNF.modelCountOn Finset.univ).sum = 11 := by - rw [CNF.sum_modelCountOn_prop64NormalizedLeaves, sampleTaut3CNF_modelCountOn_eq_eleven] - -/-- On the satisfying assignment `fun _ => false`, exactly `1` normalized leaf formula of -`sampleTaut3CNF` evaluates to `true`. -/ -theorem sampleTaut3CNF_countP_eval_prop64NormalizedLeaves_true : - ((sampleTaut3CNF.prop64NormalizedLeaves 3).map ClauseSet.toCNF).countP - (fun F => F.eval (fun _ : Fin 4 => false)) = 1 := by - rw [CNF.countP_eval_toCNF_prop64NormalizedLeaves] - decide - -/-- On the falsifying assignment `fun _ => true`, `0` normalized leaf formulas of -`sampleTaut3CNF` evaluate to `true`. -/ -theorem sampleTaut3CNF_countP_eval_prop64NormalizedLeaves_false : - ((sampleTaut3CNF.prop64NormalizedLeaves 3).map ClauseSet.toCNF).countP - (fun F => F.eval (fun _ : Fin 4 => true)) = 0 := by - rw [CNF.countP_eval_toCNF_prop64NormalizedLeaves] - decide - -/-- Every leaf `L ∈ sampleTaut3CNF.prop64NormalizedLeaves 3` is reduced, free of complementary -literals within each clause (the tautological clause has been filtered out), has clause width at -most `3`, and satisfies `L.toCNF.length ≤ CNF.prop64LeafClauseRatio 3 4 * 4`. -/ -theorem sampleTaut3CNF_leaf_nontautological_and_length_le - {L : ClauseSet (Fin 4)} (hL : L ∈ sampleTaut3CNF.prop64NormalizedLeaves 3) : - Reduced L ∧ - (∀ C ∈ L, ∀ l ∈ C, Std.Sat.Literal.negate l ∉ C) ∧ - (∀ c ∈ L.toCNF, c.length ≤ 3) ∧ - L.toCNF.length ≤ CNF.prop64LeafClauseRatio 3 4 * 4 := by - obtain ⟨_, hred, hnt, hk_L, _, hlen_L⟩ := - CNF.length_le_of_mem_prop64NormalizedLeaves sampleTaut3CNF_width_le_three hL - exact ⟨hred, hnt, hk_L, hlen_L (by decide : 1 ≤ Fintype.card (Fin 4))⟩ - -/-- Concrete check of `CNF.card_leafCandidateQueryIndex_eq`, `CNF.card_leafCandidateQueryIndex_le`, -`CNF.greedyRowListLength_le_mul_pow_clog`, and `CNF.candidateQueryRows_length_and_weight_le` on -both a round-`0` candidate query `Sum.inl (0, γ₀)` and the final query `Sum.inr ()` for -`sampleTaut3CNF`. -/ -theorem sampleTaut3CNF_candidateQueryIndex_and_rows_bounds : - Fintype.card (CNF.LeafCandidateQueryIndex (Fin 4) 2 sampleTaut3CNF) = - 12 * 6 ^ (Cslib.BitString.greedyRowListLength 2 3) + 1 ∧ - Fintype.card (CNF.LeafCandidateQueryIndex (Fin 4) 2 sampleTaut3CNF) ≤ - CNF.leafCandidateQueryBound 2 sampleTaut3CNF ∧ - Cslib.BitString.greedyRowListLength 2 sampleTaut3CNF.length ≤ - 20000 * 2 ^ 2 * (Nat.clog 2 (2 * sampleTaut3CNF.length + 4)) ^ 2 ∧ - let γ₀ : Fin (Cslib.BitString.greedyRowListLength 2 sampleTaut3CNF.length) → - Fin sampleTaut3CNF.length × Bool := - fun _ => (⟨0, by decide⟩, true) - let A : ℕ → List (Fin sampleTaut3CNF.length → Bool) := - fun i => List.replicate i (testRow γ₀) - let q_cand : CNF.LeafCandidateQueryIndex (Fin 4) 2 sampleTaut3CNF := - Sum.inl (⟨0, by decide⟩, γ₀) - let q_final : CNF.LeafCandidateQueryIndex (Fin 4) 2 sampleTaut3CNF := Sum.inr () - (CNF.candidateQueryRows A q_cand).length ≤ 24 ∧ - (∀ r ∈ CNF.candidateQueryRows A q_cand, - weight r ≤ Cslib.BitString.initialRowWeightBound 2 sampleTaut3CNF.length) ∧ - (CNF.candidateQueryRows A q_final).length ≤ 24 ∧ - (∀ r ∈ CNF.candidateQueryRows A q_final, - weight r ≤ Cslib.BitString.initialRowWeightBound 2 sampleTaut3CNF.length) := by - refine ⟨?_, CNF.card_leafCandidateQueryIndex_le 2 sampleTaut3CNF, - CNF.greedyRowListLength_le_mul_pow_clog 2 sampleTaut3CNF.length, ?_⟩ - · rw [CNF.card_leafCandidateQueryIndex_eq, Fintype.card_fin, - show sampleTaut3CNF.length = 3 by rfl, show 3 * 4 = 12 by rfl, show 2 * 3 = 6 by rfl] - · intro γ₀ A q_cand q_final - have hA : ∀ i, A (i + 1) = A i ++ [testRow γ₀] := fun i => List.replicate_succ' - have hcand := CNF.candidateQueryRows_length_and_weight_le (B := 2) (ψ := sampleTaut3CNF) - (A₀ := []) (Nat.zero_le _) (fun _ hr => nomatch hr) (A := A) (γ := fun _ => γ₀) rfl hA q_cand - have hfinal := CNF.candidateQueryRows_length_and_weight_le (B := 2) (ψ := sampleTaut3CNF) - (A₀ := []) (Nat.zero_le _) (fun _ hr => nomatch hr) (A := A) (γ := fun _ => γ₀) rfl hA q_final - simpa only [Fintype.card_fin] using ⟨hcand.1, hcand.2, hfinal.1, hfinal.2⟩ - -/-- At `k = 3`, the Proposition 6.4 `interpolationScale` exponent multipliers form a strictly -increasing chain. -/ -theorem prop64_scale_coeffs_strict_mono_k3 : - CNF.prop64BranchExamScaleCoeff 3 < CNF.prop64LeafQueryExamScaleCoeff 3 ∧ - CNF.prop64LeafQueryExamScaleCoeff 3 < CNF.prop64TreeExamScaleCoeff 3 ∧ - CNF.prop64TreeExamScaleCoeff 3 < CNF.prop64TotalExamScaleCoeff 3 := by - unfold CNF.prop64LeafQueryExamScaleCoeff CNF.prop64TreeExamScaleCoeff - CNF.prop64TotalExamScaleCoeff - omega - -/-- Concrete 3-CNF on `Fin N` (`1 ≤ N`) with one tautological clause and one width-3 clause. -/ -def sampleLargeTaut3CNF (N : ℕ) [NeZero N] : CNF (Fin N) := - [[(0, true), (0, false), (0, true)], - [(0, true), (0, true), (0, true)]] - -theorem sampleLargeTaut3CNF_width_le_three (N : ℕ) [NeZero N] : - ∀ c ∈ sampleLargeTaut3CNF N, c.length ≤ 3 := by - intro c hc - simp only [sampleLargeTaut3CNF, List.mem_cons, List.not_mem_nil, or_false] at hc - rcases hc with rfl | rfl <;> simp - -private theorem pos_of_two_pow_le {m n : ℕ} (h : 2 ^ m ≤ n) : 0 < n := - lt_of_lt_of_le (Nat.pow_pos two_pos) h - -/-- Nonvacuous instantiation of -`CNF.exists_prop64NormalizedLeaves_total_recovery_and_examBound` at `k = 3` on a concrete 3-CNF -with a tautological clause over `V = Fin N₃`, exercising: -1. exact normalized leaf-summed model-count conservation, -2. the per-leaf greedy trajectory `A` and per-query `ReplacementDesign` recovery and actual - branch-summed `toCountingDesign` examination bound for **every** evaluated query - `q : CNF.LeafCandidateQueryIndex (Fin N₃) B L.toCNF` (including discarded candidates - `Sum.inl (i, γ')` and the final query `Sum.inr ()`), and -3. the candidate-indexed leaf examination sum (`CNF.prop64LeafQueryExamScaleCoeff 3`), - tree-wide final-query examination sum (`CNF.prop64TreeExamScaleCoeff 3`), and - total candidate-indexed tree-wide examination sum (`CNF.prop64TotalExamScaleCoeff 3`) - evaluated on the **actual** `toCountingDesign` examination costs of each query `q`. -/ -theorem nonvacuous_prop64NormalizedLeaves_total_recovery_and_actual_candidate_examBound_k3 : - ∃ (N₃ : ℕ) (_ : NeZero N₃), 2 ^ 640000 ≤ N₃ ∧ - let φ := sampleLargeTaut3CNF N₃ - let B := CNF.prop64LeafClauseRatio 3 (Fintype.card (Fin N₃)) - ((φ.prop64NormalizedLeaves 3).map fun L => L.toCNF.modelCountOn Finset.univ).sum = - φ.modelCountOn Finset.univ ∧ - 2 ≤ numGroups (Fintype.card (Fin N₃)) ∧ - (φ.prop64NormalizedLeaves 3).length ≤ - 2 ^ (Fintype.card (Fin N₃) / numGroups (Fintype.card (Fin N₃)) + 1) ∧ - ((φ.prop64NormalizedLeaves 3).length : ℝ) ≤ - (2 : ℝ) ^ (17 * interpolationScale (Fintype.card (Fin N₃))) ∧ - ∃ (actualQueryExam : (L : ClauseSet (Fin N₃)) → - CNF.LeafCandidateQueryIndex (Fin N₃) B L.toCNF → ℝ), - (∀ L ∈ φ.prop64NormalizedLeaves 3, - let ψ := L.toCNF - let D₀ := Cslib.BitString.initialRowWeightBound B ψ.length - let P := Cslib.BitString.greedyRowListLength B ψ.length - let b₀ := CNF.parityBranchThreshold 3 D₀ (Fintype.card (Fin N₃)) - (∀ c ∈ ψ, c.length ≤ 3) ∧ - ψ.length ≤ B * Fintype.card (Fin N₃) ∧ - ∃ A : ℕ → List (Fin ψ.length → Bool), - commonZeroCount univ - (ψ.parityRowSystem (CNF.candidateQueryRows (B := B) A (Sum.inr ()))) = - ψ.modelCountOn Finset.univ ∧ - (∀ (i : Fin (3 * Fintype.card (Fin N₃))) (γ' : Fin P → Fin ψ.length × Bool), - commonZeroCount univ (ψ.parityRowSystem (A (i.1 + 1))) ≤ - commonZeroCount univ - (ψ.parityRowSystem (CNF.candidateQueryRows A (Sum.inl (i, γ'))))) ∧ - (∀ q : CNF.LeafCandidateQueryIndex (Fin N₃) B ψ, - let rows := CNF.candidateQueryRows A q - rows.length ≤ 6 * Fintype.card (Fin N₃) ∧ - (∀ r ∈ rows, weight r ≤ D₀) ∧ - let S := heavyVars univ (univ : Finset (Fin rows.length)) - (fun j => equationScope (ψ.parityRowSystem rows j)) b₀ - let n' := Fintype.card ↥(univ \ S) - let e : ↥(univ \ S) ≃ Fin n' := Fintype.equivFin ↥(univ \ S) - ∃ (hF : ∀ b : Fin N₃ → Bool, - Feasible (CNF.prop64ScheduleExponent 3) n' (b₀ + 1) - (max (3 * (D₀ * 2 ^ 3)) 1) - (∑ f : {j : Fin rows.length // - j ∈ (univ : Finset (Fin rows.length))} ⊕ Fin n', - #(branchAugmentedScope S e univ (ψ.parityRowSystem rows) b f))) - (D : ∀ b : Fin N₃ → Bool, - ReplacementDesign - (branchAugmentedScope S e univ (ψ.parityRowSystem rows) b) - (numNodes n') (numGroups n') - (intervalStart (CNF.prop64ScheduleExponent 3) n') - (rowBound (CNF.prop64ScheduleExponent 3) n') (tauRat n')), - (commonZeroCount (univ : Finset (Fin rows.length)) - (ψ.parityRowSystem rows) : ℤ) = - (∑ b ∈ branchAssignments S, - ((univariateClearedParityTruncatedSum (univ : Finset (Fin rows.length)) - (ψ.branchParityRowSystem rows S e b) - (commonDenom (numNodes n') - (rowBound (CNF.prop64ScheduleExponent 3) n') : ℤ) 3 - (branchPrecision (Fintype.card (Fin N₃))) - (designReplacementScaledIntMap (D b) - (fun j => Sum.inl ⟨j, mem_univ j⟩))).eval 0 / - clearedProductDenom - (commonDenom (numNodes n') - (rowBound (CNF.prop64ScheduleExponent 3) n') : ℤ) 3 - (branchPrecision (Fintype.card (Fin N₃))) - #(univ : Finset (Fin rows.length))) % - ((2 : ℤ) ^ branchPrecision (Fintype.card (Fin N₃)))) ∧ - actualQueryExam L q = - ∑ b ∈ branchAssignments S, - let d := 3 * (rows.length + 2 * (branchPrecision (Fintype.card (Fin N₃)) - 1)) - let q_ord := (d * rowBound (CNF.prop64ScheduleExponent 3) n') / numNodes n' - let C := (hF b).toCountingDesign (D b) univ - ∑ t : Fin (numNodes n'), - (#{p : Finset (Fin n') × Finset (Fin n') | - #p.1 ≤ q_ord ∧ p.2 ⊆ p.1} : ℝ) * - (2 * (#(C.measurementBox t) : ℝ) * - ∑ g : Fin (numGroups n'), - (Fintype.card (C.LocalCube t g) : ℝ))) ∧ - (∑ q : CNF.LeafCandidateQueryIndex (Fin N₃) B ψ, actualQueryExam L q) ≤ - (2 : ℝ) ^ ((CNF.prop64LeafQueryExamScaleCoeff 3 : ℝ) * - interpolationScale (Fintype.card (Fin N₃)))) ∧ - ((φ.prop64NormalizedLeaves 3).map fun (L : ClauseSet (Fin N₃)) => - actualQueryExam L (Sum.inr ())).sum ≤ - (2 : ℝ) ^ ((CNF.prop64TreeExamScaleCoeff 3 : ℝ) * - interpolationScale (Fintype.card (Fin N₃))) ∧ - ((φ.prop64NormalizedLeaves 3).map fun (L : ClauseSet (Fin N₃)) => - ∑ q : CNF.LeafCandidateQueryIndex (Fin N₃) B L.toCNF, actualQueryExam L q).sum ≤ - (2 : ℝ) ^ ((CNF.prop64TotalExamScaleCoeff 3 : ℝ) * - interpolationScale (Fintype.card (Fin N₃))) := by - obtain ⟨N₃, hN₃, hprop64⟩ := - CNF.exists_prop64NormalizedLeaves_total_recovery_and_examBound (by decide : 2 ≤ 3) - have hpos : 0 < N₃ := pos_of_two_pow_le hN₃ - have : NeZero N₃ := ⟨Nat.ne_of_gt hpos⟩ - have hcard : N₃ ≤ Fintype.card (Fin N₃) := by rw [Fintype.card_fin] - set φ := sampleLargeTaut3CNF N₃ - set B := CNF.prop64LeafClauseRatio 3 (Fintype.card (Fin N₃)) - obtain ⟨hsum, hs2, hlen_pow, hlen_scale, hleaf, htree, htotal⟩ := - hprop64 φ (sampleLargeTaut3CNF_width_le_three N₃) hcard - classical - let actualQueryExam : (L : ClauseSet (Fin N₃)) → - CNF.LeafCandidateQueryIndex (Fin N₃) B L.toCNF → ℝ := - fun L q => - if hL : L ∈ φ.prop64NormalizedLeaves 3 then - let ψ := L.toCNF - let D₀ := Cslib.BitString.initialRowWeightBound B ψ.length - let b₀ := CNF.parityBranchThreshold 3 D₀ (Fintype.card (Fin N₃)) - let A := (hleaf L hL).2.2.2.choose - let hA_spec := (hleaf L hL).2.2.2.choose_spec - let rows := CNF.candidateQueryRows A q - let S := heavyVars univ (univ : Finset (Fin rows.length)) - (fun j => equationScope (ψ.parityRowSystem rows j)) b₀ - let n' := Fintype.card ↥(univ \ S) - let e : ↥(univ \ S) ≃ Fin n' := Fintype.equivFin ↥(univ \ S) - let hpack := ((hA_spec.2.2.1 q).2.2 e).2.1 - let hF := hpack.choose - let D := hpack.choose_spec.choose - ∑ b ∈ branchAssignments S, - let d := 3 * (rows.length + 2 * (branchPrecision (Fintype.card (Fin N₃)) - 1)) - let q_ord := (d * rowBound (CNF.prop64ScheduleExponent 3) n') / numNodes n' - let C := (hF b).toCountingDesign (D b) univ - ∑ t : Fin (numNodes n'), - (#{p : Finset (Fin n') × Finset (Fin n') | - #p.1 ≤ q_ord ∧ p.2 ⊆ p.1} : ℝ) * - (2 * (#(C.measurementBox t) : ℝ) * - ∑ g : Fin (numGroups n'), - (Fintype.card (C.LocalCube t g) : ℝ)) - else 0 - have hactual_bound : ∀ L ∈ φ.prop64NormalizedLeaves 3, - ∀ q : CNF.LeafCandidateQueryIndex (Fin N₃) B L.toCNF, - actualQueryExam L q ≤ - (2 : ℝ) ^ (((CNF.prop64BranchExamScaleCoeff 3 + 32 : ℕ) : ℝ) * - interpolationScale (Fintype.card (Fin N₃))) := by - intro L hL q - dsimp only [actualQueryExam] - rw [dite_eq_left_of_eq_true (eq_true hL)] - let ψ := L.toCNF - let D₀ := Cslib.BitString.initialRowWeightBound B ψ.length - let b₀ := CNF.parityBranchThreshold 3 D₀ (Fintype.card (Fin N₃)) - let A := (hleaf L hL).2.2.2.choose - let hA_spec := (hleaf L hL).2.2.2.choose_spec - let rows := CNF.candidateQueryRows A q - let S := heavyVars univ (univ : Finset (Fin rows.length)) - (fun j => equationScope (ψ.parityRowSystem rows j)) b₀ - let n' := Fintype.card ↥(univ \ S) - let e : ↥(univ \ S) ≃ Fin n' := Fintype.equivFin ↥(univ \ S) - have hq_e := (hA_spec.2.2.1 q).2.2 e - have hexam := hq_e.2.1.choose_spec.choose_spec.2.2 - exact hq_e.2.2 _ fun b _ => hexam b univ - refine ⟨N₃, inferInstance, hN₃, hsum, hs2, hlen_pow, hlen_scale, actualQueryExam, - fun L hL => ?_, - htree (fun L => actualQueryExam L (Sum.inr ())) (fun L hL => hactual_bound L hL (Sum.inr ())), - htotal actualQueryExam hactual_bound⟩ - have hk_ψ := (hleaf L hL).1 - have hm_ψ := (hleaf L hL).2.1 - let A := (hleaf L hL).2.2.2.choose - have hA_spec := (hleaf L hL).2.2.2.choose_spec - refine ⟨hk_ψ, hm_ψ, A, hA_spec.1, hA_spec.2.1, fun q => ?_, - hA_spec.2.2.2 (actualQueryExam L) (hactual_bound L hL)⟩ - obtain ⟨hlen_q, hw_q, hq_all_e⟩ := hA_spec.2.2.1 q - refine ⟨hlen_q, hw_q, ?_⟩ - intro S n' e - have hpack := (hq_all_e e).2.1 - let hF := hpack.choose - let D := hpack.choose_spec.choose - have hrec := hpack.choose_spec.choose_spec.1 - refine ⟨hF, D, hrec, ?_⟩ - dsimp only [actualQueryExam] - rw [dite_eq_left_of_eq_true (eq_true hL)] - -end CslibTests diff --git a/ComplexityTests/Computability/Complexity/FineGrained/GeneralCNFHermiteRecovery.lean b/ComplexityTests/Computability/Complexity/FineGrained/GeneralCNFHermiteRecovery.lean deleted file mode 100644 index 41f80ff893..0000000000 --- a/ComplexityTests/Computability/Complexity/FineGrained/GeneralCNFHermiteRecovery.lean +++ /dev/null @@ -1,409 +0,0 @@ -/- -Copyright (c) 2026 Samuel Schlesinger. All rights reserved. -Released under Apache 2.0 license as described in the file LICENSE. -Authors: Samuel Schlesinger --/ - -module - -public import Complexity.Init -public import Complexity.Computability.Complexity.FineGrained.GeneralCNFHermiteRecovery - -/-! -# Tests for `Complexity.Computability.Complexity.FineGrained.GeneralCNFHermiteRecovery` - -Exercises the Stage-1/Stage-2 `clearedParityJetTable` Hermite–Cramer coordinate recovery -(`hermiteCramerNumerator_clearedParityJetTable_eq_mul`, -`emod_sum_hermiteCramerNumerator_clearedParityJetTable_ediv_eq_commonZeroCount`), -`Feasible.numNodes_pos`, the Section 6.3 compiled CNF parity-row schedule Hermite–Cramer and -`clearedParityJetTable` recovery -(`CNF.exists_parityRowSystem_modelCountOn_hermiteCramer_recovery_and_examBound_of_le_clog_pow`), -and the Proposition 6.4 tree-wide candidate-indexed Hermite–Cramer and `clearedParityJetTable` -recovery and actual `toCountingDesign` examination bounds -(`CNF.exists_prop64NormalizedLeaves_total_hermiteCramer_recovery_and_examBound`) on concrete -systems and 3-CNF formulas. --/ - -public noncomputable section - -namespace CslibTests - -open Finset Polynomial -open Cslib -open Cslib.BitString -open Cslib.LinearAlgebra -open Cslib.Logic.PL -open Cslib.Logic.PL.ClauseSet.Sparsification -open Cslib.Complexity.SubexponentialSAT -open Cslib.Complexity.SubexponentialSAT.ReplacementParams -open scoped BigOperators - -/-- Concrete linear parity system `x₀ + x₁ = 0` on `Fin 2` (`1` equation with monomials `{0}` and -`{1}`), which has `commonZeroCount univ sampleParitySystem2 = 2`. -/ -def sampleParitySystem2 : Fin 1 → Finset (Finset (Fin 2)) := - fun _ => {{0}, {1}} - -theorem commonZeroCount_sampleParitySystem2 : - commonZeroCount (univ : Finset (Fin 1)) sampleParitySystem2 = 2 := by - decide - -/-- Concrete check of `hermiteCramerNumerator_clearedParityJetTable_eq_mul` and -`emod_sum_hermiteCramerNumerator_clearedParityJetTable_ediv_eq_commonZeroCount` on -`sampleParitySystem2` (`commonZeroCount = 2`) with constant replacement map -`θ x i v = Polynomial.C (bitVal ℤ (x v))` (`d_den = 1`, `R_deg = 0`), single interpolation node -`nodes 0 = 0` (`Q = 1`), jet order `J = 1`, and precision `ℓ = 3`: the Stage-1/Stage-2 -`clearedParityJetTable` coordinate Cramer quotients sum modulo `2 ^ 3 = 8` to the exact common-zero -count `2`. -/ -theorem clearedParityJetTable_hermiteCramer_recovers_sampleParitySystem2 : - let I : Finset (Fin 1) := univ - let θ : (Fin 2 → Bool) → Fin 1 → Fin 2 → Polynomial ℤ := - fun x _ v => Polynomial.C (bitVal ℤ (x v)) - let nodes : Fin 1 → ℤ := fun _ => 0 - (∀ s : Fin 3, - hermiteCramerNumerator nodes Nat.one_pos Nat.one_pos - (fun t j => - clearedParityJetTable I sampleParitySystem2 1 1 3 1 θ (nodes t) j s) = - (Polynomial.hermiteMatrix nodes 1).det * - (univariateClearedParityCoord I sampleParitySystem2 1 1 3 θ s.1).eval 0) ∧ - (∑ s : Fin 3, - hermiteCramerNumerator nodes Nat.one_pos Nat.one_pos - (fun t j => - clearedParityJetTable I sampleParitySystem2 1 1 3 1 θ (nodes t) j s) / - (clearedProductDenom 1 1 3 #I * - (Polynomial.hermiteMatrix nodes 1).det)) % ((2 : ℤ) ^ 3) = 2 := by - intro I θ nodes - have hk : ∀ i ∈ I, ∀ M ∈ sampleParitySystem2 i, #M ≤ 1 := by decide - have hdeg : ∀ x : Fin 2 → Bool, ∀ i ∈ I, ∀ M ∈ sampleParitySystem2 i, ∀ v ∈ M, - (θ x i v).natDegree ≤ 0 := by - intro x _ _ _ _ v _ - exact (Polynomial.natDegree_C (bitVal ℤ (x v))).le - have hθ : ∀ x : Fin 2 → Bool, ∀ i ∈ I, ∀ M ∈ sampleParitySystem2 i, ∀ v ∈ M, - (θ x i v).eval 0 = 1 * bitVal ℤ (x v) := by - intro x _ _ _ _ v _ - simp [θ] - have hQJ : (1 * 0) * (#I + 2 * (3 - 1)) < 1 * 1 := by decide - have hnodes : Function.Injective nodes := fun a b _ => Subsingleton.elim a b - have hℓ : Fintype.card (Fin 2) < 3 := by decide - refine ⟨fun s => - hermiteCramerNumerator_clearedParityJetTable_eq_mul I sampleParitySystem2 1 nodes - Nat.one_pos Nat.one_pos θ hk hdeg hQJ s, ?_⟩ - rw [emod_sum_hermiteCramerNumerator_clearedParityJetTable_ediv_eq_commonZeroCount - I sampleParitySystem2 one_ne_zero hnodes Nat.one_pos Nat.one_pos hℓ θ hk hdeg hθ hQJ, - commonZeroCount_sampleParitySystem2] - rfl - -/-- Concrete 3-CNF on `Fin N` (`1 ≤ N`) with one tautological clause and one width-3 clause. -/ -def sampleHermiteTaut3CNF (N : ℕ) [NeZero N] : CNF (Fin N) := - [[(0, true), (0, false), (0, true)], - [(0, true), (0, true), (0, true)]] - -theorem sampleHermiteTaut3CNF_width_le_three (N : ℕ) [NeZero N] : - ∀ c ∈ sampleHermiteTaut3CNF N, c.length ≤ 3 := by - intro c hc - simp only [sampleHermiteTaut3CNF, List.mem_cons, List.not_mem_nil, or_false] at hc - rcases hc with rfl | rfl <;> simp - -private theorem pos_of_le {m n : ℕ} (hm : 0 < m) (h : m ≤ n) : 0 < n := - lt_of_lt_of_le hm h - -private theorem pos_of_two_pow_le {m n : ℕ} (h : 2 ^ m ≤ n) : 0 < n := - lt_of_lt_of_le (Nat.pow_pos two_pos) h - -/-- Nonvacuous Section 6.3 instantiation of -`CNF.exists_parityRowSystem_modelCountOn_hermiteCramer_recovery_and_examBound_of_le_clog_pow` -at `k = 3`, `C_B = 1`, `β_B = 2` on `sampleHermiteTaut3CNF N₁`, verifying `0 < numNodes n'`, -both the Hermite–Cramer truncated-sum determinant recovery and the Stage-1/Stage-2 -`clearedParityJetTable` coordinate recovery of `(φ.modelCountOn Finset.univ : ℤ)`, and the -branch-summed `interpolationScale` examination bound on the actual `toCountingDesign` sum. -/ -theorem nonvacuous_sec63_modelCountOn_hermiteCramer_and_clearedParityJetTable_recovery_k3 : - ∃ (N₁ : ℕ) (_ : NeZero N₁), 16384 ≤ N₁ ∧ - let φ := sampleHermiteTaut3CNF N₁ - let D₀ := Cslib.BitString.initialRowWeightBound 1 φ.length - let b₀ := CNF.parityBranchThreshold 3 D₀ (Fintype.card (Fin N₁)) - ∃ rows : List (Fin φ.length → Bool), - rows.length ≤ 6 * Fintype.card (Fin N₁) ∧ - commonZeroCount univ (φ.parityRowSystem rows) = φ.modelCountOn Finset.univ ∧ - let S := heavyVars univ (univ : Finset (Fin rows.length)) - (fun j => equationScope (φ.parityRowSystem rows j)) b₀ - let n' := Fintype.card ↥(univ \ S) - let e : ↥(univ \ S) ≃ Fin n' := Fintype.equivFin ↥(univ \ S) - ∃ (hQ : 0 < numNodes n') - (hF : ∀ b : Fin N₁ → Bool, - Feasible 9 n' (b₀ + 1) (max (3 * (D₀ * 2 ^ 3)) 1) - (∑ f : {j : Fin rows.length // - j ∈ (univ : Finset (Fin rows.length))} ⊕ Fin n', - #(branchAugmentedScope S e univ (φ.parityRowSystem rows) b f))) - (D : ∀ b : Fin N₁ → Bool, - ReplacementDesign - (branchAugmentedScope S e univ (φ.parityRowSystem rows) b) - (numNodes n') (numGroups n') (intervalStart 9 n') - (rowBound 9 n') (tauRat n')), - let ℓ := branchPrecision (Fintype.card (Fin N₁)) - let J := sparseParityJetOrder 3 (rowBound 9 n') (numNodes n') - #(univ : Finset (Fin rows.length)) ℓ - (φ.modelCountOn Finset.univ : ℤ) = - (∑ b ∈ branchAssignments S, - (hermiteCramerNumerator (nodeInt (Q := numNodes n')) hQ - (sparseParityJetOrder_pos 3 (rowBound 9 n') (numNodes n') - #(univ : Finset (Fin rows.length)) ℓ) - (fun t j => - (Polynomial.taylor (nodeInt t) - (univariateClearedParityTruncatedSum (univ : Finset (Fin rows.length)) - (φ.branchParityRowSystem rows S e b) - (commonDenom (numNodes n') (rowBound 9 n') : ℤ) 3 ℓ - (designReplacementScaledIntMap (D b) - (fun j => Sum.inl ⟨j, mem_univ j⟩)))).coeff j) / - (clearedProductDenom - (commonDenom (numNodes n') (rowBound 9 n') : ℤ) 3 ℓ - #(univ : Finset (Fin rows.length)) * - (Polynomial.hermiteMatrix (nodeInt (Q := numNodes n')) J).det)) % - ((2 : ℤ) ^ ℓ)) ∧ - (φ.modelCountOn Finset.univ : ℤ) = - (∑ b ∈ branchAssignments S, - (∑ s : Fin ℓ, - hermiteCramerNumerator (nodeInt (Q := numNodes n')) hQ - (sparseParityJetOrder_pos 3 (rowBound 9 n') (numNodes n') - #(univ : Finset (Fin rows.length)) ℓ) - (fun t j => - clearedParityJetTable (univ : Finset (Fin rows.length)) - (φ.branchParityRowSystem rows S e b) - (commonDenom (numNodes n') (rowBound 9 n') : ℤ) 3 ℓ J - (designReplacementScaledIntMap (D b) - (fun j => Sum.inl ⟨j, mem_univ j⟩)) (nodeInt t) j s) / - (clearedProductDenom - (commonDenom (numNodes n') (rowBound 9 n') : ℤ) 3 ℓ - #(univ : Finset (Fin rows.length)) * - (Polynomial.hermiteMatrix (nodeInt (Q := numNodes n')) J).det)) % - ((2 : ℤ) ^ ℓ)) ∧ - (∑ b ∈ branchAssignments S, - let d := 3 * (rows.length + 2 * (branchPrecision (Fintype.card (Fin N₁)) - 1)) - let q_ord := (d * rowBound 9 n') / numNodes n' - let C := (hF b).toCountingDesign (D b) univ - ∑ t : Fin (numNodes n'), - (#{p : Finset (Fin n') × Finset (Fin n') | #p.1 ≤ q_ord ∧ p.2 ⊆ p.1} : ℝ) * - (2 * (#(C.measurementBox t) : ℝ) * - ∑ g : Fin (numGroups n'), (Fintype.card (C.LocalCube t g) : ℝ))) ≤ - (2 : ℝ) ^ (((CNF.parityBranchExamScaleCoeff 3 2 + 32 : ℕ) : ℝ) * - interpolationScale (Fintype.card (Fin N₁))) := by - obtain ⟨N₁, hN₁, hsec63⟩ := - CNF.exists_parityRowSystem_modelCountOn_hermiteCramer_recovery_and_examBound_of_le_clog_pow - 3 1 2 - have hpos : 0 < N₁ := pos_of_le (by decide : 0 < 16384) hN₁ - have : NeZero N₁ := ⟨Nat.ne_of_gt hpos⟩ - set φ := sampleHermiteTaut3CNF N₁ - have hcard : N₁ ≤ Fintype.card (Fin N₁) := by rw [Fintype.card_fin] - have hB_le : 1 ≤ 1 * Nat.clog 2 (Fintype.card (Fin N₁)) ^ 2 := by - rw [Fintype.card_fin, one_mul] - have hclog : 1 ≤ Nat.clog 2 N₁ := - (Nat.lt_clog_iff_pow_lt one_lt_two).mpr (by omega : 2 ^ 0 < N₁) - exact Nat.one_le_pow 2 _ hclog - have hm : φ.length ≤ 1 * Fintype.card (Fin N₁) := by - rw [Fintype.card_fin, one_mul] - change 2 ≤ N₁ - omega - obtain ⟨rows, hlen, hcount, hstage⟩ := - hsec63 φ (sampleHermiteTaut3CNF_width_le_three N₁) hcard le_rfl hB_le hm - refine ⟨N₁, inferInstance, hN₁, rows, hlen, hcount, ?_⟩ - intro S n' e - obtain ⟨_, ⟨hQ, hF, D, hrec_trunc, hrec_jet, _, hexam⟩, hsum⟩ := hstage e - exact ⟨hQ, hF, D, hrec_trunc, hrec_jet, hsum _ fun b _ => hexam b univ⟩ - -/-- Nonvacuous Proposition 6.4 instantiation of -`CNF.exists_prop64NormalizedLeaves_total_hermiteCramer_recovery_and_examBound` at `k = 3` on -`sampleHermiteTaut3CNF N₃`, certifying for every normalized leaf `L ∈ φ.prop64NormalizedLeaves 3` -and every candidate query `q : CNF.LeafCandidateQueryIndex (Fin N₃) B L.toCNF` (including -discarded candidates with list multiplicity and the final query `Sum.inr ()`) both the -Hermite–Cramer truncated-sum determinant recovery and the Stage-1/Stage-2 `clearedParityJetTable` -coordinate recovery at `nodeInt` and canonical jet order `sparseParityJetOrder`, together with the -per-leaf candidate-summed, tree-wide final-query, and tree-wide total candidate-indexed -`interpolationScale` bounds evaluated on the **actual** `toCountingDesign` examination costs. -/ -theorem nonvacuous_prop64NormalizedLeaves_total_hermiteCramer_and_jetTable_recovery_k3 : - ∃ (N₃ : ℕ) (_ : NeZero N₃), 2 ^ 640000 ≤ N₃ ∧ - let φ := sampleHermiteTaut3CNF N₃ - let B := CNF.prop64LeafClauseRatio 3 (Fintype.card (Fin N₃)) - ((φ.prop64NormalizedLeaves 3).map fun L => L.toCNF.modelCountOn Finset.univ).sum = - φ.modelCountOn Finset.univ ∧ - ((φ.prop64NormalizedLeaves 3).length : ℝ) ≤ - (2 : ℝ) ^ (17 * interpolationScale (Fintype.card (Fin N₃))) ∧ - ∃ (actualQueryExam : (L : ClauseSet (Fin N₃)) → - CNF.LeafCandidateQueryIndex (Fin N₃) B L.toCNF → ℝ), - (∀ L ∈ φ.prop64NormalizedLeaves 3, - let ψ := L.toCNF - let D₀ := Cslib.BitString.initialRowWeightBound B ψ.length - let P := Cslib.BitString.greedyRowListLength B ψ.length - let b₀ := CNF.parityBranchThreshold 3 D₀ (Fintype.card (Fin N₃)) - Fintype.card (CNF.LeafCandidateQueryIndex (Fin N₃) B ψ) = - 3 * Fintype.card (Fin N₃) * (2 * ψ.length) ^ P + 1 ∧ - ∃ A : ℕ → List (Fin ψ.length → Bool), - commonZeroCount univ - (ψ.parityRowSystem (CNF.candidateQueryRows (B := B) A (Sum.inr ()))) = - ψ.modelCountOn Finset.univ ∧ - (∀ q : CNF.LeafCandidateQueryIndex (Fin N₃) B ψ, - let rows := CNF.candidateQueryRows A q - let S := heavyVars univ (univ : Finset (Fin rows.length)) - (fun j => equationScope (ψ.parityRowSystem rows j)) b₀ - let n' := Fintype.card ↥(univ \ S) - let e : ↥(univ \ S) ≃ Fin n' := Fintype.equivFin ↥(univ \ S) - ∃ (hQ : 0 < numNodes n') - (hF : ∀ b : Fin N₃ → Bool, - Feasible (CNF.prop64ScheduleExponent 3) n' (b₀ + 1) - (max (3 * (D₀ * 2 ^ 3)) 1) - (∑ f : {j : Fin rows.length // - j ∈ (univ : Finset (Fin rows.length))} ⊕ Fin n', - #(branchAugmentedScope S e univ (ψ.parityRowSystem rows) b f))) - (D : ∀ b : Fin N₃ → Bool, - ReplacementDesign - (branchAugmentedScope S e univ (ψ.parityRowSystem rows) b) - (numNodes n') (numGroups n') - (intervalStart (CNF.prop64ScheduleExponent 3) n') - (rowBound (CNF.prop64ScheduleExponent 3) n') (tauRat n')), - let ℓ := branchPrecision (Fintype.card (Fin N₃)) - let J := sparseParityJetOrder 3 (rowBound (CNF.prop64ScheduleExponent 3) n') - (numNodes n') #(univ : Finset (Fin rows.length)) ℓ - (commonZeroCount (univ : Finset (Fin rows.length)) - (ψ.parityRowSystem rows) : ℤ) = - (∑ b ∈ branchAssignments S, - (hermiteCramerNumerator (nodeInt (Q := numNodes n')) hQ - (sparseParityJetOrder_pos 3 - (rowBound (CNF.prop64ScheduleExponent 3) n') (numNodes n') - #(univ : Finset (Fin rows.length)) ℓ) - (fun t j => - (Polynomial.taylor (nodeInt t) - (univariateClearedParityTruncatedSum - (univ : Finset (Fin rows.length)) - (ψ.branchParityRowSystem rows S e b) - (commonDenom (numNodes n') - (rowBound (CNF.prop64ScheduleExponent 3) n') : ℤ) 3 ℓ - (designReplacementScaledIntMap (D b) - (fun j => Sum.inl ⟨j, mem_univ j⟩)))).coeff j) / - (clearedProductDenom - (commonDenom (numNodes n') - (rowBound (CNF.prop64ScheduleExponent 3) n') : ℤ) 3 ℓ - #(univ : Finset (Fin rows.length)) * - (Polynomial.hermiteMatrix (nodeInt (Q := numNodes n')) J).det)) % - ((2 : ℤ) ^ ℓ)) ∧ - (commonZeroCount (univ : Finset (Fin rows.length)) - (ψ.parityRowSystem rows) : ℤ) = - (∑ b ∈ branchAssignments S, - (∑ s : Fin ℓ, - hermiteCramerNumerator (nodeInt (Q := numNodes n')) hQ - (sparseParityJetOrder_pos 3 - (rowBound (CNF.prop64ScheduleExponent 3) n') (numNodes n') - #(univ : Finset (Fin rows.length)) ℓ) - (fun t j => - clearedParityJetTable (univ : Finset (Fin rows.length)) - (ψ.branchParityRowSystem rows S e b) - (commonDenom (numNodes n') - (rowBound (CNF.prop64ScheduleExponent 3) n') : ℤ) 3 ℓ J - (designReplacementScaledIntMap (D b) - (fun j => Sum.inl ⟨j, mem_univ j⟩)) (nodeInt t) j s) / - (clearedProductDenom - (commonDenom (numNodes n') - (rowBound (CNF.prop64ScheduleExponent 3) n') : ℤ) 3 ℓ - #(univ : Finset (Fin rows.length)) * - (Polynomial.hermiteMatrix (nodeInt (Q := numNodes n')) J).det)) % - ((2 : ℤ) ^ ℓ)) ∧ - actualQueryExam L q = - ∑ b ∈ branchAssignments S, - let d := 3 * (rows.length + 2 * (branchPrecision (Fintype.card (Fin N₃)) - 1)) - let q_jet := (d * rowBound (CNF.prop64ScheduleExponent 3) n') / numNodes n' - let C := (hF b).toCountingDesign (D b) univ - ∑ t : Fin (numNodes n'), - (#{p : Finset (Fin n') × Finset (Fin n') | - #p.1 ≤ q_jet ∧ p.2 ⊆ p.1} : ℝ) * - (2 * (#(C.measurementBox t) : ℝ) * - ∑ g : Fin (numGroups n'), - (Fintype.card (C.LocalCube t g) : ℝ))) ∧ - (∑ q : CNF.LeafCandidateQueryIndex (Fin N₃) B ψ, actualQueryExam L q) ≤ - (2 : ℝ) ^ ((CNF.prop64LeafQueryExamScaleCoeff 3 : ℝ) * - interpolationScale (Fintype.card (Fin N₃)))) ∧ - ((φ.prop64NormalizedLeaves 3).map fun (L : ClauseSet (Fin N₃)) => - actualQueryExam L (Sum.inr ())).sum ≤ - (2 : ℝ) ^ ((CNF.prop64TreeExamScaleCoeff 3 : ℝ) * - interpolationScale (Fintype.card (Fin N₃))) ∧ - ((φ.prop64NormalizedLeaves 3).map fun (L : ClauseSet (Fin N₃)) => - ∑ q : CNF.LeafCandidateQueryIndex (Fin N₃) B L.toCNF, actualQueryExam L q).sum ≤ - (2 : ℝ) ^ ((CNF.prop64TotalExamScaleCoeff 3 : ℝ) * - interpolationScale (Fintype.card (Fin N₃))) := by - obtain ⟨N₃, hN₃, hprop64⟩ := - CNF.exists_prop64NormalizedLeaves_total_hermiteCramer_recovery_and_examBound - (by decide : 2 ≤ 3) - have hpos : 0 < N₃ := pos_of_two_pow_le hN₃ - have : NeZero N₃ := ⟨Nat.ne_of_gt hpos⟩ - have hcard : N₃ ≤ Fintype.card (Fin N₃) := by rw [Fintype.card_fin] - set φ := sampleHermiteTaut3CNF N₃ - set B := CNF.prop64LeafClauseRatio 3 (Fintype.card (Fin N₃)) - obtain ⟨hsum, _, _, hlen_scale, hleaf, htree, htotal⟩ := - hprop64 φ (sampleHermiteTaut3CNF_width_le_three N₃) hcard - classical - let actualQueryExam : (L : ClauseSet (Fin N₃)) → - CNF.LeafCandidateQueryIndex (Fin N₃) B L.toCNF → ℝ := - fun L q => - if hL : L ∈ φ.prop64NormalizedLeaves 3 then - let ψ := L.toCNF - let D₀ := Cslib.BitString.initialRowWeightBound B ψ.length - let b₀ := CNF.parityBranchThreshold 3 D₀ (Fintype.card (Fin N₃)) - let A := (hleaf L hL).2.2.2.2.2.choose - let hA_spec := (hleaf L hL).2.2.2.2.2.choose_spec - let rows := CNF.candidateQueryRows A q - let S := heavyVars univ (univ : Finset (Fin rows.length)) - (fun j => equationScope (ψ.parityRowSystem rows j)) b₀ - let n' := Fintype.card ↥(univ \ S) - let e : ↥(univ \ S) ≃ Fin n' := Fintype.equivFin ↥(univ \ S) - let hpack := ((hA_spec.2.2.1 q).2.2 e).2.1 - let hF := hpack.choose_spec.choose - let D := hpack.choose_spec.choose_spec.choose - ∑ b ∈ branchAssignments S, - let d := 3 * (rows.length + 2 * (branchPrecision (Fintype.card (Fin N₃)) - 1)) - let q_jet := (d * rowBound (CNF.prop64ScheduleExponent 3) n') / numNodes n' - let C := (hF b).toCountingDesign (D b) univ - ∑ t : Fin (numNodes n'), - (#{p : Finset (Fin n') × Finset (Fin n') | - #p.1 ≤ q_jet ∧ p.2 ⊆ p.1} : ℝ) * - (2 * (#(C.measurementBox t) : ℝ) * - ∑ g : Fin (numGroups n'), - (Fintype.card (C.LocalCube t g) : ℝ)) - else 0 - have hactual_bound : ∀ L ∈ φ.prop64NormalizedLeaves 3, - ∀ q : CNF.LeafCandidateQueryIndex (Fin N₃) B L.toCNF, - actualQueryExam L q ≤ - (2 : ℝ) ^ (((CNF.prop64BranchExamScaleCoeff 3 + 32 : ℕ) : ℝ) * - interpolationScale (Fintype.card (Fin N₃))) := by - intro L hL q - dsimp only [actualQueryExam] - rw [dite_eq_left_of_eq_true (eq_true hL)] - let ψ := L.toCNF - let D₀ := Cslib.BitString.initialRowWeightBound B ψ.length - let b₀ := CNF.parityBranchThreshold 3 D₀ (Fintype.card (Fin N₃)) - let A := (hleaf L hL).2.2.2.2.2.choose - let hA_spec := (hleaf L hL).2.2.2.2.2.choose_spec - let rows := CNF.candidateQueryRows A q - let S := heavyVars univ (univ : Finset (Fin rows.length)) - (fun j => equationScope (ψ.parityRowSystem rows j)) b₀ - let n' := Fintype.card ↥(univ \ S) - let e : ↥(univ \ S) ≃ Fin n' := Fintype.equivFin ↥(univ \ S) - have hq_e := (hA_spec.2.2.1 q).2.2 e - have hexam := hq_e.2.1.choose_spec.choose_spec.choose_spec.2.2.2 - exact hq_e.2.2 _ fun b _ => hexam b univ - refine ⟨N₃, inferInstance, hN₃, hsum, hlen_scale, actualQueryExam, - fun L hL => ?_, - htree (fun L => actualQueryExam L (Sum.inr ())) (fun L hL => hactual_bound L hL (Sum.inr ())), - htotal actualQueryExam hactual_bound⟩ - have hcard_eq := (hleaf L hL).2.2.1 - let A := (hleaf L hL).2.2.2.2.2.choose - have hA_spec := (hleaf L hL).2.2.2.2.2.choose_spec - refine ⟨hcard_eq, A, hA_spec.1, fun q => ?_, - hA_spec.2.2.2 (actualQueryExam L) (hactual_bound L hL)⟩ - obtain ⟨_, _, hq_all_e⟩ := hA_spec.2.2.1 q - intro rows S n' e - have hpack := (hq_all_e e).2.1 - let hQ := hpack.choose - let hF := hpack.choose_spec.choose - let D := hpack.choose_spec.choose_spec.choose - have hrec_trunc := hpack.choose_spec.choose_spec.choose_spec.1 - have hrec_jet := hpack.choose_spec.choose_spec.choose_spec.2.1 - refine ⟨hQ, hF, D, hrec_trunc, hrec_jet, ?_⟩ - dsimp only [actualQueryExam] - rw [dite_eq_left_of_eq_true (eq_true hL)] - -end CslibTests diff --git a/ComplexityTests/Computability/Complexity/FineGrained/SparseCNFDesignSchedule.lean b/ComplexityTests/Computability/Complexity/FineGrained/SparseCNFDesignSchedule.lean deleted file mode 100644 index 7127520d35..0000000000 --- a/ComplexityTests/Computability/Complexity/FineGrained/SparseCNFDesignSchedule.lean +++ /dev/null @@ -1,315 +0,0 @@ -/- -Copyright (c) 2026 Samuel Schlesinger. All rights reserved. -Released under Apache 2.0 license as described in the file LICENSE. -Authors: Samuel Schlesinger --/ - -module --- upstream: candidate - -public import Complexity.Init -public import Complexity.Computability.Complexity.FineGrained.SparseCNFDesignSchedule - -/-! -# Tests for `SparseCNFDesignSchedule` - -Concrete tests and nonvacuous recovery witnesses on a formula with a nonzero parity row for the -index-equivalence bridge and schedule-instantiated exact recovery theorems in -`Complexity.Computability.Complexity.FineGrained.SparseCNFDesignSchedule`. --/ - -@[expose] public noncomputable section - -namespace Cslib.Complexity.SubexponentialSAT.ReplacementParams.SparseCNFDesignScheduleTests - -open Finset -open Cslib.BitString -open Cslib.LinearAlgebra -open Cslib.Logic.PL -open Cslib.Complexity.SubexponentialSAT.ReplacementParams - -/-! ### 1. Index-equivalence bridge between `Fin m ⊕ Fin n'` and `{j // j ∈ univ} ⊕ Fin n'` -/ - -/-- A 2-CNF over `Fin 3` with two clauses `(x₀ ∨ ¬x₁) ∧ (x₁ ∨ x₂)` and one single-clause row. -/ -def sampleCNF3 : CNF (Fin 3) := - [[⟨0, true⟩, ⟨1, false⟩], [⟨1, true⟩, ⟨2, true⟩]] - -def sampleRow3 : Fin sampleCNF3.length → Bool := - fun i => decide (i = ⟨0, by decide⟩) - -def sampleRows3 : List (Fin sampleCNF3.length → Bool) := [sampleRow3] - -example (j : Fin 1) : - CNF.parityRowAugmentedIndexEquiv 1 3 (Sum.inl j) = CNF.parityRowAugmentedInl j := by - simp only [CNF.parityRowAugmentedIndexEquiv_inl] - -example (v : Fin 3) : - CNF.parityRowAugmentedIndexEquiv 1 3 (Sum.inr v) = Sum.inr v := by - simp only [CNF.parityRowAugmentedIndexEquiv_inr] - -example (e : ↥(univ \ (∅ : Finset (Fin 3))) ≃ Fin 3) (b : Fin 3 → Bool) - (j : Fin sampleRows3.length) : - branchAugmentedScope ∅ e univ (sampleCNF3.parityRowSystem sampleRows3) b - (CNF.parityRowAugmentedInl j) = - branchEquationScope ∅ e (sampleCNF3.parityRowSystem sampleRows3) b j := - sampleCNF3.branchAugmentedScope_parityRowAugmentedInl sampleRows3 ∅ e b j - -example (e : ↥(univ \ (∅ : Finset (Fin 3))) ≃ Fin 3) (b : Fin 3 → Bool) - (j : Fin sampleRows3.length) : - branchAugmentedScope ∅ e univ (sampleCNF3.parityRowSystem sampleRows3) b - (CNF.parityRowAugmentedIndexEquiv sampleRows3.length 3 (Sum.inl j)) = - branchEquationScope ∅ e (sampleCNF3.parityRowSystem sampleRows3) b j := - sampleCNF3.branchAugmentedScope_parityRowSystem_comp_equiv_inl sampleRows3 ∅ e b j - -example (e : ↥(univ \ (∅ : Finset (Fin 3))) ≃ Fin 3) (b : Fin 3 → Bool) (v : Fin 3) : - branchAugmentedScope ∅ e univ (sampleCNF3.parityRowSystem sampleRows3) b - (CNF.parityRowAugmentedIndexEquiv sampleRows3.length 3 (Sum.inr v)) = {v} := - sampleCNF3.branchAugmentedScope_parityRowSystem_comp_equiv_inr sampleRows3 ∅ e b v - -/-! ### 2. Nonzero-row CNF fixture and schedule-instantiated exact recovery witnesses -/ - -/-- A 1-clause CNF `(x₀)` over `Fin (n + 1)` of width `1 ≤ 3`. -/ -def unitClauseCNF (n : ℕ) : CNF (Fin (n + 1)) := - [[⟨0, true⟩]] - -/-- Nonzero parity-row list selecting the unique clause of `unitClauseCNF n`. -/ -def unitClauseRows (n : ℕ) : List (Fin (unitClauseCNF n).length → Bool) := - [fun _ => true] - -theorem width_unitClauseCNF_le_three (n : ℕ) : - ∀ c ∈ unitClauseCNF n, c.length ≤ 3 := by - intro c hc - rcases List.mem_singleton.mp hc with rfl - simp - -theorem weight_unitClauseRows_le_one (n : ℕ) : - ∀ r_row ∈ unitClauseRows n, weight r_row ≤ 1 := by - intro r_row hr - rcases List.mem_singleton.mp hr with rfl - refine (card_filter_le _ _).trans ?_ - rw [card_univ, Fintype.card_fin] - simp [unitClauseCNF] - -theorem heavyVars_unitClauseCNF_eq_empty (n : ℕ) {b₀ : ℕ} (hb₀ : 1 ≤ b₀) : - heavyVars (univ : Finset (Fin (n + 1))) - (univ : Finset (Fin (unitClauseRows n).length)) - (fun j => equationScope ((unitClauseCNF n).parityRowSystem (unitClauseRows n) j)) b₀ = - ∅ := by - ext v - simp only [heavyVars, varIncidence, mem_filter, mem_univ, true_and, notMem_empty, iff_false, - not_lt] - refine (card_filter_le _ _).trans ?_ - rw [card_univ, Fintype.card_fin] - simpa [unitClauseRows] using hb₀ - -/-- Free-variable equivalence for `unitClauseCNF n` and `unitClauseRows n` at any threshold -`1 ≤ b₀`, since `heavyVars` is empty. -/ -def unitClauseEquiv (n : ℕ) {b₀ : ℕ} (hb₀ : 1 ≤ b₀) : - ↥((univ : Finset (Fin (n + 1))) \ - heavyVars (univ : Finset (Fin (n + 1))) - (univ : Finset (Fin (unitClauseRows n).length)) - (fun j => equationScope ((unitClauseCNF n).parityRowSystem (unitClauseRows n) j)) b₀) ≃ - Fin (n + 1) where - toFun v := v.1 - invFun v := ⟨v, by rw [heavyVars_unitClauseCNF_eq_empty n hb₀]; simp⟩ - left_inv v := by ext; rfl - right_inv v := rfl - -private theorem five_le_clog_succ {n : ℕ} (hn : 20 ≤ n) : 5 ≤ Nat.clog 2 (n + 1) := by - have h16 : 2 ^ 4 < n + 1 := by omega - exact (Nat.lt_clog_iff_pow_lt one_lt_two).mpr h16 - -/-- Nonvacuous recovery check for `CNF.exists_schedule_design_commonZeroCount_parityRowSystem_eq` -and `CNF.exists_schedule_design_numPassing_eq` on `unitClauseCNF n₀` with the nonzero parity row -`unitClauseRows n₀` (`W = 1`, `b₀ = 1`, `k = 3`, `β = 5`). -/ -example : - ∃ n₀ : ℕ, 20 ≤ n₀ ∧ - let φ := unitClauseCNF n₀ - let rows := unitClauseRows n₀ - let S := heavyVars univ (univ : Finset (Fin rows.length)) - (fun j => equationScope (φ.parityRowSystem rows j)) 1 - let e := unitClauseEquiv n₀ (b₀ := 1) le_rfl - ∃ (D₁ D₂ : (b : Fin (n₀ + 1) → Bool) → - ReplacementDesign (branchAugmentedScope S e univ (φ.parityRowSystem rows) b) - (numNodes (n₀ + 1)) (numGroups (n₀ + 1)) (intervalStart 5 (n₀ + 1)) - (rowBound 5 (n₀ + 1)) (tauRat (n₀ + 1))), - (commonZeroCount (univ : Finset (Fin rows.length)) (φ.parityRowSystem rows) : ℤ) = - (∑ b ∈ branchAssignments S, - ((univariateClearedParityTruncatedSum (univ : Finset (Fin rows.length)) - (φ.branchParityRowSystem rows S e b) - (commonDenom (numNodes (n₀ + 1)) (rowBound 5 (n₀ + 1)) : ℤ) 3 - (branchPrecision (Fintype.card (Fin (n₀ + 1)))) - (designReplacementScaledIntMap (D₁ b) CNF.parityRowAugmentedInl)).eval 0 / - clearedProductDenom - (commonDenom (numNodes (n₀ + 1)) (rowBound 5 (n₀ + 1)) : ℤ) 3 - (branchPrecision (Fintype.card (Fin (n₀ + 1)))) - #(univ : Finset (Fin rows.length))) % - ((2 : ℤ) ^ branchPrecision (Fintype.card (Fin (n₀ + 1))))) ∧ - (numPassing φ.violations rows : ℤ) = - (∑ b ∈ branchAssignments S, - ((univariateClearedParityTruncatedSum (univ : Finset (Fin rows.length)) - (φ.branchParityRowSystem rows S e b) - (commonDenom (numNodes (n₀ + 1)) (rowBound 5 (n₀ + 1)) : ℤ) 3 - (branchPrecision (Fintype.card (Fin (n₀ + 1)))) - (designReplacementScaledIntMap (D₂ b) CNF.parityRowAugmentedInl)).eval 0 / - clearedProductDenom - (commonDenom (numNodes (n₀ + 1)) (rowBound 5 (n₀ + 1)) : ℤ) 3 - (branchPrecision (Fintype.card (Fin (n₀ + 1)))) - #(univ : Finset (Fin rows.length))) % - ((2 : ℤ) ^ branchPrecision (Fintype.card (Fin (n₀ + 1))))) := by - obtain ⟨n₁, hn₁, hcz⟩ := - CNF.exists_schedule_design_commonZeroCount_parityRowSystem_eq.{0} (β := 5) (by decide) - obtain ⟨n₂, hn₂, hnp⟩ := - CNF.exists_schedule_design_numPassing_eq.{0} (β := 5) (by decide) - let n₀ := max n₁ n₂ - have hn₀ : 20 ≤ n₀ := hn₁.trans (le_max_left n₁ n₂) - refine ⟨n₀, hn₀, ?_⟩ - intro φ rows S e - have h5 : 5 ^ 5 ≤ Nat.clog 2 (n₀ + 1) ^ 5 := - Nat.pow_le_pow_left (five_le_clog_succ hn₀) 5 - have hb₀ : 1 + 1 ≤ Nat.clog 2 (n₀ + 1) ^ 5 := (by decide : 1 + 1 ≤ 5 ^ 5).trans h5 - have hw : max (3 * (1 * 2 ^ 3)) 1 ≤ Nat.clog 2 (n₀ + 1) ^ 5 := - (by decide : max (3 * (1 * 2 ^ 3)) 1 ≤ 5 ^ 5).trans h5 - obtain ⟨_, D₁, hD₁, _⟩ := hcz (width_unitClauseCNF_le_three n₀) (weight_unitClauseRows_le_one n₀) - e ((le_max_left n₁ n₂).trans (Nat.le_succ n₀)) hb₀ hw - obtain ⟨_, D₂, hD₂, _⟩ := hnp (width_unitClauseCNF_le_three n₀) (weight_unitClauseRows_le_one n₀) - e ((le_max_right n₁ n₂).trans (Nat.le_succ n₀)) hb₀ hw - exact ⟨D₁, D₂, hD₁, hD₂⟩ - -/-- Nonvacuous recovery check for -`CNF.exists_schedule_design_commonZeroCount_parityRowSystem_of_le_clog_pow` and -`CNF.exists_schedule_design_numPassing_of_le_clog_pow` on `unitClauseCNF N₀` (`k = 3`, `C_B = 1`, -`β_B = 1`, `B = 1`). -/ -example : - ∃ N₀ : ℕ, 20 ≤ N₀ ∧ - let φ := unitClauseCNF N₀ - let W := BitString.initialRowWeightBound 1 φ.length - let b₀ := CNF.parityBranchThreshold 3 W (Fintype.card (Fin (N₀ + 1))) - ∃ rows : List (Fin φ.length → Bool), - rows.length ≤ 6 * Fintype.card (Fin (N₀ + 1)) ∧ - let S := heavyVars univ (univ : Finset (Fin rows.length)) - (fun j => equationScope (φ.parityRowSystem rows j)) b₀ - let n' := Fintype.card ↥((univ : Finset (Fin (N₀ + 1))) \ S) - let e := Fintype.equivFin ↥((univ : Finset (Fin (N₀ + 1))) \ S) - ∃ (D₁ D₂ : (b : Fin (N₀ + 1) → Bool) → - ReplacementDesign (branchAugmentedScope S e univ (φ.parityRowSystem rows) b) - (numNodes n') (numGroups n') (intervalStart 7 n') - (rowBound 7 n') (tauRat n')), - (commonZeroCount (univ : Finset (Fin rows.length)) (φ.parityRowSystem rows) : ℤ) = - (∑ b ∈ branchAssignments S, - ((univariateClearedParityTruncatedSum (univ : Finset (Fin rows.length)) - (φ.branchParityRowSystem rows S e b) - (commonDenom (numNodes n') (rowBound 7 n') : ℤ) 3 - (branchPrecision (Fintype.card (Fin (N₀ + 1)))) - (designReplacementScaledIntMap (D₁ b) CNF.parityRowAugmentedInl)).eval 0 / - clearedProductDenom - (commonDenom (numNodes n') (rowBound 7 n') : ℤ) 3 - (branchPrecision (Fintype.card (Fin (N₀ + 1)))) - #(univ : Finset (Fin rows.length))) % - ((2 : ℤ) ^ branchPrecision (Fintype.card (Fin (N₀ + 1))))) ∧ - (numPassing φ.violations rows : ℤ) = - (∑ b ∈ branchAssignments S, - ((univariateClearedParityTruncatedSum (univ : Finset (Fin rows.length)) - (φ.branchParityRowSystem rows S e b) - (commonDenom (numNodes n') (rowBound 7 n') : ℤ) 3 - (branchPrecision (Fintype.card (Fin (N₀ + 1)))) - (designReplacementScaledIntMap (D₂ b) CNF.parityRowAugmentedInl)).eval 0 / - clearedProductDenom - (commonDenom (numNodes n') (rowBound 7 n') : ℤ) 3 - (branchPrecision (Fintype.card (Fin (N₀ + 1)))) - #(univ : Finset (Fin rows.length))) % - ((2 : ℤ) ^ branchPrecision (Fintype.card (Fin (N₀ + 1))))) := by - obtain ⟨N₁, hN₁, hcz⟩ := - CNF.exists_schedule_design_commonZeroCount_parityRowSystem_of_le_clog_pow.{0} 3 1 1 - obtain ⟨N₂, hN₂, hnp⟩ := - CNF.exists_schedule_design_numPassing_of_le_clog_pow.{0} 3 1 1 - let N₀ := max N₁ N₂ - have hN₀ : 20 ≤ N₀ := hN₁.trans (le_max_left N₁ N₂) - refine ⟨N₀, hN₀, ?_⟩ - intro φ W b₀ - have hcard₁ : N₁ ≤ Fintype.card (Fin (N₀ + 1)) := by - rw [Fintype.card_fin] - exact (le_max_left N₁ N₂).trans (Nat.le_succ N₀) - have hcard₂ : N₂ ≤ Fintype.card (Fin (N₀ + 1)) := by - rw [Fintype.card_fin] - exact (le_max_right N₁ N₂).trans (Nat.le_succ N₀) - have hm : φ.length ≤ 1 * Fintype.card (Fin (N₀ + 1)) := by simp [φ, unitClauseCNF] - have hB : 1 ≤ 1 * Nat.clog 2 (Fintype.card (Fin (N₀ + 1))) ^ 1 := by - rw [Fintype.card_fin, one_mul, pow_one] - exact (by decide : 1 ≤ 5).trans (five_le_clog_succ hN₀) - have hn1 : 1 ≤ Fintype.card (Fin (N₀ + 1)) := by rw [Fintype.card_fin]; omega - obtain ⟨A₀, hlen0, hw0, _⟩ := - φ.exists_initialTests_commonZeroCount_greedy (width_unitClauseCNF_le_three N₀) hn1 le_rfl hm - have hlen : A₀.length ≤ 6 * Fintype.card (Fin (N₀ + 1)) := - hlen0.trans (Nat.mul_le_mul_right _ (by decide)) - refine ⟨A₀, hlen, ?_⟩ - intro S n' e - obtain ⟨_, _, _, _, D₁, hD₁, _⟩ := hcz (width_unitClauseCNF_le_three N₀) hcard₁ hm hB le_rfl - hw0 hlen e - obtain ⟨_, _, _, _, D₂, hD₂, _⟩ := hnp (width_unitClauseCNF_le_three N₀) hcard₂ hm hB le_rfl - hw0 hlen e - exact ⟨D₁, D₂, hD₁, hD₂⟩ - -/-- Nonvacuous end-to-end greedy model-count recovery check for -`CNF.exists_greedy_parityRowSystem_schedule_design_modelCountOn_of_le_clog_pow` and -`CNF.exists_greedy_testRow_trajectory` on `unitClauseCNF N₀` (`k = 3`, `C_B = 1`, `β_B = 1`, -`B = 1`). -/ -example : - ∃ N₀ : ℕ, 20 ≤ N₀ ∧ - let φ := unitClauseCNF N₀ - let D₀ := BitString.initialRowWeightBound 1 φ.length - let b₀ := CNF.parityBranchThreshold 3 D₀ (Fintype.card (Fin (N₀ + 1))) - ∃ (rows : List (Fin φ.length → Bool)), - rows.length ≤ 6 * Fintype.card (Fin (N₀ + 1)) ∧ - let S := heavyVars univ (univ : Finset (Fin rows.length)) - (fun j => equationScope (φ.parityRowSystem rows j)) b₀ - let n' := Fintype.card ↥((univ : Finset (Fin (N₀ + 1))) \ S) - let e := Fintype.equivFin ↥((univ : Finset (Fin (N₀ + 1))) \ S) - ∃ D : (b : Fin (N₀ + 1) → Bool) → - ReplacementDesign (branchAugmentedScope S e univ (φ.parityRowSystem rows) b) - (numNodes n') (numGroups n') (intervalStart 7 n') (rowBound 7 n') (tauRat n'), - (φ.modelCountOn Finset.univ : ℤ) = - (∑ b ∈ branchAssignments S, - ((univariateClearedParityTruncatedSum (univ : Finset (Fin rows.length)) - (φ.branchParityRowSystem rows S e b) - (commonDenom (numNodes n') (rowBound 7 n') : ℤ) 3 - (branchPrecision (Fintype.card (Fin (N₀ + 1)))) - (designReplacementScaledIntMap (D b) CNF.parityRowAugmentedInl)).eval 0 / - clearedProductDenom - (commonDenom (numNodes n') (rowBound 7 n') : ℤ) 3 - (branchPrecision (Fintype.card (Fin (N₀ + 1)))) - #(univ : Finset (Fin rows.length))) % - ((2 : ℤ) ^ branchPrecision (Fintype.card (Fin (N₀ + 1))))) ∧ - ∀ b : Fin (N₀ + 1) → Bool, - (univariateClearedParityTruncatedSum (univ : Finset (Fin rows.length)) - (φ.branchParityRowSystem rows S e b) - (commonDenom (numNodes n') (rowBound 7 n') : ℤ) 3 - (branchPrecision (Fintype.card (Fin (N₀ + 1)))) - (designReplacementScaledIntMap (D b) CNF.parityRowAugmentedInl)).natDegree ≤ - (3 * (rowBound 7 n' - 1)) * (8 * Fintype.card (Fin (N₀ + 1))) := by - obtain ⟨N₀, hN₀, hgreedy_sched⟩ := - CNF.exists_greedy_parityRowSystem_schedule_design_modelCountOn_of_le_clog_pow.{0} 3 1 1 - refine ⟨N₀, hN₀, ?_⟩ - intro φ D₀ b₀ - have hcard : N₀ ≤ Fintype.card (Fin (N₀ + 1)) := by - rw [Fintype.card_fin] - exact Nat.le_succ N₀ - have hB : 1 ≤ 1 * Nat.clog 2 (Fintype.card (Fin (N₀ + 1))) ^ 1 := by - rw [Fintype.card_fin, one_mul, pow_one] - exact (by decide : 1 ≤ 5).trans (five_le_clog_succ hN₀) - have hm : φ.length ≤ 1 * Fintype.card (Fin (N₀ + 1)) := by simp [φ, unitClauseCNF] - obtain ⟨A₀, _, _, hgreedy⟩ := - hgreedy_sched φ (width_unitClauseCNF_le_three N₀) hcard le_rfl hB hm - let P := BitString.greedyRowListLength 1 φ.length - have : Nonempty (Fin P → Fin φ.length × Bool) := - ⟨fun _ => (⟨0, by simp [φ, unitClauseCNF]⟩, false)⟩ - obtain ⟨A, γ, h0, hA, hγ⟩ := φ.exists_greedy_testRow_trajectory P A₀ - obtain ⟨_, hstage, hrec⟩ := hgreedy A γ h0 hA hγ - have hlen : (A (3 * Fintype.card (Fin (N₀ + 1)))).length ≤ - 6 * Fintype.card (Fin (N₀ + 1)) := - (hstage (3 * Fintype.card (Fin (N₀ + 1))) le_rfl).1 - refine ⟨A (3 * Fintype.card (Fin (N₀ + 1))), hlen, ?_⟩ - intro S n' e - exact hrec e - -end Cslib.Complexity.SubexponentialSAT.ReplacementParams.SparseCNFDesignScheduleTests diff --git a/ComplexityTests/SatisfactionPolynomial.lean b/ComplexityTests/SatisfactionPolynomial.lean deleted file mode 100644 index 3d823a0e98..0000000000 --- a/ComplexityTests/SatisfactionPolynomial.lean +++ /dev/null @@ -1,156 +0,0 @@ -/- -Copyright (c) 2026 Anton Kovsharov. All rights reserved. -Released under Apache 2.0 license as described in the file LICENSE. -Authors: Anton Kovsharov --/ - -import Complexity.Computability.Machines.Turing.MultiTape.Complexity.PolyTime.List -import Complexity.Computability.PolyTime.CNF.ClauseJetEval -import Mathlib.Logic.Equiv.Fin.Basic -import Mathlib.Tactic.Ring - -/-! -# Concrete tests for `SatisfactionPolynomial`, `IntJet`, and `ClauseJetEval` - -Kernel-checked witnesses exercising: -- the manuscript §2.2 example `x₀ ∨ ¬x₁ ∨ x₂`, empty clause `[]`, empty formula `[]`, duplicate - and tautological clauses, and undeclared variable extensions; -- `replacementCountPoly` with a nontrivial degree-`1` replacement verifying `H(0) = #F` and degree - bound `deg H ≤ M · R_deg`; -- `Cslib.IntJet` and `evalClauseClearedJet` / `evalGroupClauseProductJet` with short/overlong input - lists, nontrivial `z ^ 4` truncation, `δ = 0` sanity check, rational `clauseSatPoly`/`cnfSatPoly` - congruence, bit-length bounds, and `by fun_prop` polytime composition. --/ - -open scoped BigOperators -open Cslib Cslib.BitString Cslib.Logic.PL Cslib.Logic.PL.CNF Turing.MultiTapeTM - -namespace SatisfactionPolynomialTests - -private def exClause : Clause (Fin 3) := [(0, true), (1, false), (2, true)] - -example : clauseSatPoly ℤ exClause = - 1 - (1 - MvPolynomial.X 0) * MvPolynomial.X 1 * (1 - MvPolynomial.X 2) := by - unfold clauseSatPoly exClause - simp only [List.map_cons, List.map_nil, List.prod_cons, List.prod_nil, literalPoly_pos, - literalPoly_neg] - ring - -example : MvPolynomial.eval (bitPoint ![false, true, false]) (clauseSatPoly ℤ exClause) = 0 ∧ - MvPolynomial.eval (bitPoint ![true, true, false]) (clauseSatPoly ℤ exClause) = 1 := by - rw [eval_clauseSatPoly_bitPoint, eval_clauseSatPoly_bitPoint]; decide - -private abbrev extOn {V : Type*} [DecidableEq V] (S : Finset V) (σ : S → Bool) (v : V) : Bool := - if h : v ∈ S then σ ⟨v, h⟩ else false - -private abbrev univFin (n : ℕ) : Finset (Fin n) := Finset.univ - -example : (∑ σ : univFin 3 → Bool, - MvPolynomial.eval (bitPoint (extOn (univFin 3) σ)) - (cnfSatPoly ℤ ([exClause] : CNF (Fin 3)))) = 7 := by - rw [sum_eval_cnfSatPoly_eq_modelCountOn] - exact congrArg Nat.cast (by decide : CNF.modelCountOn ([exClause] : CNF (Fin 3)) (univFin 3) = 7) - --- Empty clause `[]` gives count `0`; empty formula `[]` on `3` declared variables gives `2^3 = 8`. -example : (∑ σ : Finset.range 2 → Bool, MvPolynomial.eval (bitPoint (extOn (Finset.range 2) σ)) - (cnfSatPoly ℤ ([[]] : CNF ℕ))) = 0 ∧ - (∑ σ : Finset.range 3 → Bool, MvPolynomial.eval (bitPoint (extOn (Finset.range 3) σ)) - (cnfSatPoly ℤ ([] : CNF ℕ))) = 8 := by - rw [sum_eval_cnfSatPoly_eq_modelCountOn, sum_eval_cnfSatPoly_eq_modelCountOn] - exact ⟨congrArg Nat.cast (by decide : CNF.modelCountOn ([[]] : CNF ℕ) (Finset.range 2) = 0), - congrArg Nat.cast (by decide : CNF.modelCountOn ([] : CNF ℕ) (Finset.range 3) = 8)⟩ - --- Duplicate literal `x₀ ∨ x₀` (`2 X₀ - X₀²`) and tautological clause `x₀ ∨ ¬x₀`. -example : clauseSatPoly ℤ ([(0, true), (0, true)] : Clause (Fin 2)) = - 2 * MvPolynomial.X 0 - MvPolynomial.X 0 ^ 2 ∧ - clauseSatPoly ℤ ([(0, true), (0, false)] : Clause (Fin 2)) = - 1 - (1 - MvPolynomial.X 0) * MvPolynomial.X 0 := by - unfold clauseSatPoly - simp only [List.map_cons, List.map_nil, List.prod_cons, List.prod_nil, literalPoly_pos, - literalPoly_neg] - exact ⟨by ring, by ring⟩ - -example : (∑ σ : univFin 2 → Bool, MvPolynomial.eval (bitPoint (extOn (univFin 2) σ)) - (cnfSatPoly ℤ ([[(0, true), (0, true)]] : CNF (Fin 2)))) = 2 ∧ - (∑ σ : univFin 2 → Bool, MvPolynomial.eval (bitPoint (extOn (univFin 2) σ)) - (cnfSatPoly ℤ ([[(0, true), (0, false)]] : CNF (Fin 2)))) = 4 ∧ - (∑ σ : Finset.range 2 → Bool, MvPolynomial.eval (bitPoint (extOn (Finset.range 2) σ)) - (cnfSatPoly ℤ ([[(2, false)]] : CNF ℕ))) = 4 := by - rw [sum_eval_cnfSatPoly_eq_modelCountOn, sum_eval_cnfSatPoly_eq_modelCountOn, - sum_eval_cnfSatPoly_eq_modelCountOn] - exact ⟨congrArg Nat.cast - (by decide : CNF.modelCountOn ([[(0, true), (0, true)]] : CNF (Fin 2)) (univFin 2) = 2), - congrArg Nat.cast - (by decide : CNF.modelCountOn ([[(0, true), (0, false)]] : CNF (Fin 2)) (univFin 2) = 4), - congrArg Nat.cast (by decide : CNF.modelCountOn ([[(2, false)]] : CNF ℕ) (Finset.range 2) = 4)⟩ - -private def repPhi : CNF (Fin 2) := [[(0, true), (1, false)]] - -private noncomputable def linRep (e : Fin repPhi.length) (j : Fin repPhi[e].length) - (i : Fin 2) : Polynomial ℤ := - if i = repPhi[e][j].1 then 1 + Polynomial.X else Polynomial.X - -example : (replacementCountPoly repPhi Finset.univ linRep).eval 0 = 3 ∧ - (replacementCountPoly repPhi Finset.univ linRep).natDegree ≤ 2 := by - refine ⟨?_, (natDegree_replacementCountPoly_le repPhi Finset.univ linRep 1 - fun e j i _ => ?_).trans (by decide)⟩ - · rw [eval_zero_replacementCountPoly repPhi Finset.univ linRep] - · exact congrArg Nat.cast (by decide : CNF.modelCountOn repPhi Finset.univ = 3) - · intro e j i _; dsimp only [linRep]; split_ifs <;> simp - · dsimp only [linRep]; split_ifs - · exact (Polynomial.natDegree_add_le _ _).trans (max_le (by simp) Polynomial.natDegree_X_le) - · exact Polynomial.natDegree_X_le - -private def testVarJet : Fin 2 → List ℤ - | 0 => [2, 1] - | 1 => [3, -1, 1, 0] - -private def testPhi : CNF (Fin 2) := [[(0, true), (1, false)], [(0, false)]] - -private def testClauses : List (List (Bool × List ℤ)) := - testPhi.map fun C => C.map fun l => (l.2, testVarJet l.1) - -example : evalClauseClearedJet 4 6 (testPhi[0].map fun l => (l.2, testVarJet l.1)) = - [24, 7, -5, 1] ∧ - evalGroupClauseProductJet 4 6 testClauses = [96, 4, -27, 9] ∧ - evalClauseClearedJet 2 0 [(true, [3, 1, 9])] = [3, 1] := by decide - -example : - ((Polynomial.X : Polynomial ℚ) ^ 4 ∣ - (Polynomial.ofCoeffList - (evalClauseClearedJet 4 6 (testPhi[0].map fun l => (l.2, testVarJet l.1)))).map - (Int.castRingHom ℚ) - - Polynomial.C (6 : ℚ) ^ testPhi[0].length * MvPolynomial.aeval - (fun v => (Polynomial.ofCoeffList (testVarJet v)).map (Int.castRingHom ℚ) * - Polynomial.C ((6 : ℚ)⁻¹)) (clauseSatPoly ℚ testPhi[0])) ∧ - ((Polynomial.X : Polynomial ℚ) ^ 4 ∣ - (Polynomial.ofCoeffList (evalGroupClauseProductJet 4 6 - (testPhi.map fun C => C.map fun l => (l.2, testVarJet l.1)))).map (Int.castRingHom ℚ) - - Polynomial.C (6 : ℚ) ^ testPhi.totalLiterals * MvPolynomial.aeval - (fun v => (Polynomial.ofCoeffList (testVarJet v)).map (Int.castRingHom ℚ) * - Polynomial.C ((6 : ℚ)⁻¹)) (cnfSatPoly ℚ testPhi)) ∧ - (encIntBin ((evalGroupClauseProductJet 4 6 testClauses).getD 2 0)).length ≤ 20 := by - refine ⟨X_pow_dvd_evalClauseClearedJet_clauseSatPoly 4 (by decide) testVarJet testPhi[0], - X_pow_dvd_evalGroupClauseProductJet_cnfSatPoly 4 (by decide) testVarJet testPhi, ?_⟩ - have hB : ∀ C ∈ testClauses, ∀ lit ∈ C, (Polynomial.ofCoeffList lit.2).coeffNorm1 ≤ 5 := by - simpa only [Polynomial.coeffNorm1_ofCoeffList] using - (by decide : ∀ C ∈ testClauses, ∀ lit ∈ C, (lit.2.map Int.natAbs).sum ≤ 5) - have h1 := length_encIntBin_getD_evalGroupClauseProductJet_le 4 6 testClauses 5 hB 2 - have hlen : testClauses.length = 2 := rfl - have hsum : (testClauses.map List.length).sum = 3 := rfl - have hsz : ((6 : ℤ).natAbs + 5).size ≤ 4 := Nat.size_le.mpr (by decide) - exact h1.trans (by rw [hlen, hsum]; omega) - --- Plain `ComputableInPolyTime` composition across `ParityFactorEval`, `IntJet`, and `ClauseJetEval` --- via `fun_prop`. -example : ComputableInPolyTime - (fun p : (ℕ × ℤ) × (List (Bool × List ℤ) × List (List (Bool × List ℤ))) => - Cslib.mulZJet p.1.1 (IntJet.add p.1.1 (evalClauseClearedJet p.1.1 p.1.2 p.2.1) - (IntJet.sub p.1.1 (Cslib.truncZJet p.1.1 [p.1.2]) (IntJet.subConst p.1.1 p.1.2 [1, -1]))) - (evalGroupClauseProductJet p.1.1 p.1.2 p.2.2)) - (encPair (encPair encUnary encIntBin) - (encPair (encList (encPair encBool (encList encIntBin))) - (encList (encList (encPair encBool (encList encIntBin)))))) - (encList encIntBin) := by fun_prop - -end SatisfactionPolynomialTests