import Mathlib /-! # Proof Complexity Frontiers: Sharp Non-Asymptotic Resolution, Polynomial Calculus, # and Sum-of-Squares Lower Bounds & Exact Sharpness Witnesses This file is a completely self-contained, standard-foundations Lean 4 formalization of four interlocking pillars in propositional and algebraic proof complexity: 1. **Pillar 1 — Exact Non-Asymptotic Ben-Sasson–Wigderson (BSW) Resolution Size–Width Trade-Offs**: - Non-tautological clause / CNF / DAG Resolution / Tree-like Resolution framework. - Exact integer ceiling recurrence `bswThresh n d b` with **no-`(-k)` threshold `d ≥ w(F) - 1`** (`bsw_exact_recurrence_tradeoff`). - Non-asymptotic linear ceiling boost `b + 1 ≤ bswThresh n d b` (`bsw_linear_ceiling_boost`). - Exact shrinking-variable falling-product & exponential lower bounds (`bsw_falling_product_lb`, `bsw_exp_lower_bound`). - Two-regime sharp exponential trade-offs (`bsw_sharp_high_width_exp`, `bsw_sharp_low_gap_exp`) strictly dominating Ben-Sasson–Wigderson (2001) on every instance (`W^2/(8n - 2W + 4)` for `W ≥ 2k`, and `k(W - k)/(2n - (W - k) + 1)` for `k < W < 2k`). - Exact tree-like Resolution size–width bound (`treelike_bsw_exact`) and exact `FullCNF_n` sharpness witness (`fullCNF_exact_invariants`). 2. **Pillar 2 — Exact Resolution Width & Exponential Size Lower Bounds for Tseitin & FPHP**: - Tseitin formulas `TseitinCNF G χ` on arbitrary connected finite simple graphs `G` with odd `ZMod 2`-charge `χ`: unsatisfiability (`tseitin_unsat`), proper-subset satisfiability (`tseitin_proper_subset_sat`), exact constant-1 boundary-cut width lower bound (`tseitin_exact_boundary_width_lb`), Pillar 1+2 exponential size lower bound (`tseitin_general_exponential_size_lb`), explicit complete-graph infinite family `K_n` (`tseitin_complete_graph_exact_lb`), and exact cycle sharpness `w_Res(Tseitin(C_n)) = 2` (`tseitin_cycle_exact_sharpness`). - Functional Pigeonhole Principle `FPHPCNF m n` (`m > n ≥ 1`): unsatisfiability (`fphp_unsat`), Resolution width lower bound `≥ n` (`fphp_resolution_width_lb`), exact tree-like leaf-size lower bound `L(T) ≥ 2^n + n` (`fphp_treelike_exact_size_lb`), and exact sharpness at `n = 1` (`fphp12_treelike_exact_sharpness`). 3. **Pillar 3 — Unified Exact Dynamic Polynomial Calculus (Arbitrary Fields `char ≠ 2`) & Sum-of-Squares Lower Bounds for Tseitin + Exact `C_n` Separation**: - Full dynamic Polynomial Calculus (`PCDerives`, `PCRefutes`) on `MvPolynomial E F` over any field `F` with `(2 : F) ≠ 0`, plus exact degree-preserving `±1 ↔ {0,1}` affine isomorphism (`pc_fourier_boolean_iso`). - Cut-equivalence reduction operator proving `deg_PC(Tseitin(G, χ)) ≥ ⌈W̃_r(G)/2⌉` in both Fourier and Boolean bases (`tseitin_dynamic_pc_degree_lb`, `tseitin_boolean_pc_degree_lb`). - Full Sum-of-Squares (`SoSRefutes`) on `MvPolynomial E ℝ` and explicit rank-1 block PSD pseudo-expectation proving `deg_SoS(Tseitin(G, χ)) ≥ 2 ⌈W̃_r(G)/2⌉` (`tseitin_sos_pseudoexp_psd`, `tseitin_sos_degree_lb`) and `K_n` instantiation (`tseitin_Kn_pc_sos_lb`). - Exact odd-cycle sharpness & separation: `deg_SoS(Tseitin(C_n, χ)) = 2 < 3 = deg_PC(Tseitin(C_n, χ))` for every `n ≥ 3` (`tseitin_cycle_sos_exact`, `tseitin_cycle_pc_degree_exact`). 4. **Pillar 4 — Exact Sum-of-Squares Degree & Harmonic Spectral Diagonalization of Boolean Knapsack + 4 Closed-Form Sharpness Regimes + Exact Nullstellensatz vs. SoS Separation**: - Exact Chu–Vandermonde falling-factorial alternating identity (`chu_vandermonde_falling`). - Exact harmonic spectral diagonalization of Grigoriev–Laurent's symmetric pseudo-expectation `knapsackPE n β (p^2) = ∑_{j=0}^d (β^{⌊j⌋} (n - β)^{⌊j⌋} / n^{⌊2j⌋}) ‖h_j‖₂²` (`knapsack_harmonic_diagonalization`). - Exact SoS degree characterization (`knapsack_sos_exact_degree_iff`): for all `n ≥ 2`, `k < n`, `k < β < k + 1`, and `d : ℕ`: `SoSRefutes (knapsackAxioms n β) (2 * d) ↔ min (min (k + 1) (n - k)) (n / 2) + 1 ≤ d`, with explicit closed-form SoS refutations across all 4 regimes (`knapsack_sos_exact_upper_bound`). - Exact Nullstellensatz degree `n + 1` over characteristic-0 fields (`knapsack_nullstellensatz_exact_degree`) and exact constant-4 vs. linear-`(n + 1)` separation between SoS and Nullstellensatz (`knapsack_ns_vs_sos_separation`). -/ open Finset BigOperators namespace ProofComplexityFrontiers -- ============================================================================== -- SECTION 1 (PILLAR 1): RESOLUTION, EXACT BSW RECURRENCE, FALLING PRODUCT & TREE-LIKE BSW -- ============================================================================== section Pillar1 universe u variable {V : Type u} /-- A non-tautological clause over variables `V`: `some true` is the positive literal `x_v`, `some false` is `¬x_v`, and `none` means `v` does not occur. -/ abbrev Clause (V : Type*) := V → Option Bool /-- The empty clause `⊥`. -/ def emptyClause : Clause V := fun _ => none /-- The unit clause containing a single literal `(v, b)`. -/ def unitClause [DecidableEq V] (v : V) (b : Bool) : Clause V := Function.update emptyClause v (some b) /-- A clause `C` is satisfied by an assignment `α : V → Bool`. -/ def evalClause (C : Clause V) (α : V → Bool) : Prop := ∃ v b, C v = some b ∧ α v = b /-- A CNF formula `F` (set of clauses) is satisfied by `α`. -/ def evalCNF (F : Set (Clause V)) (α : V → Bool) : Prop := ∀ C ∈ F, evalClause C α /-- Semantic entailment `F ⊨ C`. -/ def Entails (F : Set (Clause V)) (C : Clause V) : Prop := ∀ α : V → Bool, evalCNF F α → evalClause C α /-- Subclause relation `C₁ ⊆ C₂`. -/ def Subclause (C₁ C₂ : Clause V) : Prop := ∀ v b, C₁ v = some b → C₂ v = some b /-- Width (number of literals) of a clause over a finite variable set. -/ def width [Fintype V] (C : Clause V) : ℕ := (Finset.univ.filter fun v => (C v).isSome).card /-- Variables occurring in a clause. -/ def clauseVars [Fintype V] (C : Clause V) : Finset V := Finset.univ.filter fun v => (C v).isSome lemma width_eq_card_clauseVars [Fintype V] (C : Clause V) : width C = (clauseVars C).card := rfl lemma width_empty [Fintype V] : width (emptyClause : Clause V) = 0 := by simp [width, emptyClause] lemma width_le_card [Fintype V] (C : Clause V) : width C ≤ Fintype.card V := by simpa [width] using Finset.card_le_univ (Finset.univ.filter fun v => (C v).isSome) lemma width_mono [Fintype V] {C₁ C₂ : Clause V} (h : Subclause C₁ C₂) : width C₁ ≤ width C₂ := by apply Finset.card_le_card intro v hv simp only [Finset.mem_filter, Finset.mem_univ, true_and] at hv ⊢ cases hc : C₁ v with | none => simp [hc] at hv | some b => have h2 := h v b hc simp [h2] lemma width_unit [Fintype V] [DecidableEq V] (v : V) (b : Bool) : width (unitClause v b) = 1 := by have : (Finset.univ.filter fun u => (unitClause v b u).isSome) = {v} := by ext u rw [Finset.mem_filter, Finset.mem_singleton] simp only [Finset.mem_univ, true_and, unitClause] by_cases h : u = v · subst h; simp · simp [emptyClause, h] simp [width, this] lemma subclause_empty_iff {C : Clause V} : Subclause C emptyClause ↔ C = emptyClause := by constructor · intro h funext v cases hc : C v with | none => rfl | some b => exact absurd (h v b hc) (by simp [emptyClause]) · rintro rfl v b h; exact h lemma evalClause_empty (α : V → Bool) : ¬ evalClause (emptyClause : Clause V) α := by rintro ⟨v, b, h, _⟩ simp [emptyClause] at h lemma evalClause_mono {C₁ C₂ : Clause V} (h : Subclause C₁ C₂) {α : V → Bool} (h1 : evalClause C₁ α) : evalClause C₂ α := by rcases h1 with ⟨v, b, hc, ha⟩ exact ⟨v, b, h v b hc, ha⟩ /-- Resolution rule: `C` is the resolvent of `C₁` (containing `x_v`) and `C₂` (containing `¬x_v`) on pivot `v`, provided no other variable appears with opposite polarities in `C₁` and `C₂`. -/ def Resolves (C₁ C₂ : Clause V) (v : V) (C : Clause V) : Prop := C₁ v = some true ∧ C₂ v = some false ∧ (∀ u, u ≠ v → ∀ b₁ b₂, C₁ u = some b₁ → C₂ u = some b₂ → b₁ = b₂) ∧ C v = none ∧ (∀ u, u ≠ v → C u = (C₁ u).or (C₂ u)) lemma resolves_sound {C₁ C₂ C : Clause V} {v : V} (hr : Resolves C₁ C₂ v C) {α : V → Bool} (h1 : evalClause C₁ α) (h2 : evalClause C₂ α) : evalClause C α := by rcases hr with ⟨hc1v, hc2v, hcompat, _, hrest⟩ cases hav : α v with | true => rcases h2 with ⟨u, b, hc2u, hau⟩ have huv : u ≠ v := by rintro rfl rw [hc2v] at hc2u cases hc2u simp [hav] at hau refine ⟨u, b, ?_, hau⟩ rw [hrest u huv] cases h1u : C₁ u with | none => simp [hc2u] | some b₁ => have hb : b₁ = b := hcompat u huv b₁ b h1u hc2u subst hb; simp | false => rcases h1 with ⟨u, b, hc1u, hau⟩ have huv : u ≠ v := by rintro rfl rw [hc1v] at hc1u cases hc1u simp [hav] at hau refine ⟨u, b, ?_, hau⟩ rw [hrest u huv] simp [hc1u] /-- A DAG Resolution derivation is a list `π` where each clause is either in `F` or resolves two strictly earlier clauses in `π`. -/ def IsResProof (F : Set (Clause V)) (π : List (Clause V)) : Prop := ∀ i (hi : i < π.length), π[i] ∈ F ∨ ∃ j k, ∃ (hj : j < i) (hk : k < i) (v : V), Resolves (π[j]'(Nat.lt_trans hj hi)) (π[k]'(Nat.lt_trans hk hi)) v π[i] /-- A DAG Resolution refutation derives `emptyClause`. -/ def IsResRefut (F : Set (Clause V)) (π : List (Clause V)) : Prop := IsResProof F π ∧ emptyClause ∈ π /-- A Resolution proof of width at most `W`. -/ def HasWidthRefut [Fintype V] (F : Set (Clause V)) (W : ℕ) : Prop := ∃ π, IsResRefut F π ∧ ∀ C ∈ π, width C ≤ W /-- Number of "fat" clauses in `π` of width strictly greater than `d`. -/ def fatCount [Fintype V] (π : List (Clause V)) (d : ℕ) : ℕ := (π.filter fun C => decide (d < width C)).length lemma fatCount_le_length [Fintype V] (π : List (Clause V)) (d : ℕ) : fatCount π d ≤ π.length := List.length_filter_le _ _ /-- Soundness of DAG Resolution: every derived clause is semantically entailed by `F`. -/ theorem resolution_sound_mem {F : Set (Clause V)} {π : List (Clause V)} (hπ : IsResProof F π) : ∀ i (hi : i < π.length), Entails F π[i] := by intro i induction i using Nat.strong_induction_on with | h i ih => intro hi α hα rcases hπ i hi with hmem | ⟨j, k, hj, hk, v, hres⟩ · exact hα _ hmem · exact resolves_sound hres (ih j hj (Nat.lt_trans hj hi) α hα) (ih k hk (Nat.lt_trans hk hi) α hα) /-- Soundness of DAG Resolution refutations: refutable CNFs are unsatisfiable. -/ theorem resolution_sound {F : Set (Clause V)} {π : List (Clause V)} (hπ : IsResRefut F π) : ¬ ∃ α, evalCNF F α := by rintro ⟨α, hα⟩ rcases List.mem_iff_getElem.mp hπ.2 with ⟨i, hi, heq⟩ have := resolution_sound_mem hπ.1 i hi α hα rw [heq] at this exact evalClause_empty α this /-- Concatenating two valid derivations preserves `IsResProof`. -/ lemma isResProof_append {F : Set (Clause V)} {π₁ π₂ : List (Clause V)} (h1 : IsResProof F π₁) (h2 : IsResProof F π₂) : IsResProof F (π₁ ++ π₂) := by intro i hi by_cases hlt : i < π₁.length · rw [List.getElem_append_left hlt] rcases h1 i hlt with hm | ⟨j, k, hj, hk, v, hr⟩ · exact Or.inl hm · right refine ⟨j, k, hj, hk, v, ?_⟩ simpa [List.getElem_append_left (Nat.lt_trans hj hlt), List.getElem_append_left (Nat.lt_trans hk hlt)] using hr · have hge : π₁.length ≤ i := Nat.le_of_not_lt hlt have hi2 : i - π₁.length < π₂.length := by have : i < π₁.length + π₂.length := by simpa [List.length_append] using hi omega rw [List.getElem_append_right hge] rcases h2 (i - π₁.length) hi2 with hm | ⟨j, k, hj, hk, v, hr⟩ · exact Or.inl hm · right refine ⟨π₁.length + j, π₁.length + k, by omega, by omega, v, ?_⟩ have hj' : π₁.length ≤ π₁.length + j := Nat.le_add_right _ _ have hk' : π₁.length ≤ π₁.length + k := Nat.le_add_right _ _ simpa [List.getElem_append_right hj', List.getElem_append_right hk'] using hr /-- Restricting a clause by deleting variable `v`. -/ def restrictClause (v : V) (C : Clause V) : Clause {u : V // u ≠ v} := fun u => C u.1 /-- Restricting a CNF by setting variable `v` to `val`: clauses satisfied by `(v, val)` are dropped, and the literal `(v, !val)` is removed from surviving clauses. -/ def restrictCNF (F : Set (Clause V)) (v : V) (val : Bool) : Set (Clause {u : V // u ≠ v}) := { D | ∃ C ∈ F, C v ≠ some val ∧ D = restrictClause v C } lemma width_restrictClause [Fintype V] [DecidableEq V] (v : V) (C : Clause V) : width (restrictClause v C) ≤ width C := by have hsub : (Finset.univ.filter fun u : {u : V // u ≠ v} => (restrictClause v C u).isSome).map ⟨Subtype.val, Subtype.val_injective⟩ ⊆ Finset.univ.filter fun u : V => (C u).isSome := by intro x hx simp only [Finset.mem_map, Finset.mem_filter, Finset.mem_univ, true_and, Function.Embedding.coeFn_mk] at hx ⊢ rcases hx with ⟨⟨u, _⟩, hu, rfl⟩ exact hu have := Finset.card_le_card hsub simpa [width] using this lemma width_restrictClause_add_one [Fintype V] [DecidableEq V] (v : V) (C : Clause V) : width C ≤ width (restrictClause v C) + 1 := by have hsub : (Finset.univ.filter fun u : V => (C u).isSome) ⊆ insert v ((Finset.univ.filter fun u : {u : V // u ≠ v} => (restrictClause v C u).isSome).map ⟨Subtype.val, Subtype.val_injective⟩) := by intro x hx simp only [Finset.mem_filter, Finset.mem_univ, true_and] at hx by_cases hxv : x = v · subst hxv; exact Finset.mem_insert_self _ _ · apply Finset.mem_insert_of_mem simp only [Finset.mem_map, Finset.mem_filter, Finset.mem_univ, true_and, Function.Embedding.coeFn_mk] exact ⟨⟨x, hxv⟩, hx, rfl⟩ have h1 := Finset.card_le_card hsub have h2 := Finset.card_insert_le v ((Finset.univ.filter fun u : {u : V // u ≠ v} => (restrictClause v C u).isSome).map ⟨Subtype.val, Subtype.val_injective⟩) simpa [width] using Nat.le_trans h1 h2 lemma restrictCNF_width [Fintype V] [DecidableEq V] {F : Set (Clause V)} {k : ℕ} (hk : ∀ C ∈ F, width C ≤ k) (v : V) (val : Bool) : ∀ D ∈ restrictCNF F v val, width D ≤ k := by rintro D ⟨C, hC, _, rfl⟩ exact Nat.le_trans (width_restrictClause v C) (hk C hC) /-- Helper: given subclauses `D₁ ⊆ C₁`, `D₂ ⊆ C₂` where `C₁, C₂` resolve on `u` to `C`, either `D₁ ⊆ C`, or `D₂ ⊆ C`, or `D₁, D₂` resolve on `u` to some `D ⊆ C`. -/ lemma subclause_resolve_step {W : Type*} {C₁ C₂ C D₁ D₂ : Clause W} {u : W} (hr : Resolves C₁ C₂ u C) (hs1 : Subclause D₁ C₁) (hs2 : Subclause D₂ C₂) : Subclause D₁ C ∨ Subclause D₂ C ∨ ∃ D, Resolves D₁ D₂ u D ∧ Subclause D C := by rcases hr with ⟨hc1u, hc2u, hcompat, hcu, hrest⟩ cases hd1 : D₁ u with | none => left intro w b hdw have hwu : w ≠ u := by rintro rfl; simp [hd1] at hdw rw [hrest w hwu] simp [hs1 w b hdw] | some b1 => have hb1 : b1 = true := by have := hs1 u b1 hd1 rw [hc1u] at this; cases this; rfl subst hb1 cases hd2 : D₂ u with | none => right; left intro w b hdw have hwu : w ≠ u := by rintro rfl; simp [hd2] at hdw rw [hrest w hwu] cases h1w : C₁ w with | none => simp [hs2 w b hdw] | some b₁ => have := hcompat w hwu b₁ b h1w (hs2 w b hdw) subst this; simp | some b2 => have hb2 : b2 = false := by have := hs2 u b2 hd2 rw [hc2u] at this; cases this; rfl subst hb2 right; right classical refine ⟨fun w => if w = u then none else (D₁ w).or (D₂ w), ?_, ?_⟩ · refine ⟨hd1, hd2, ?_, by simp, fun w hwu => by simp [hwu]⟩ intro w hwu b₁ b₂ h1 h2 exact hcompat w hwu b₁ b₂ (hs1 w b₁ h1) (hs2 w b₂ h2) · intro w b hdw by_cases hwu : w = u · simp [hwu] at hdw · simp only [hwu, ↓reduceIte] at hdw rw [hrest w hwu] cases h1w : D₁ w with | none => simp only [h1w, Option.none_or] at hdw have h2c := hs2 w b hdw cases h1c : C₁ w with | none => simp [h2c] | some b₁ => have := hcompat w hwu b₁ b h1c h2c subst this; simp | some b₁ => simp only [h1w, Option.some_or, Option.some.injEq] at hdw subst hdw simp [hs1 w b₁ h1w] /-- Restricting a DAG Resolution refutation by `(v, val)` preserves refutability and removes every fat clause containing `(v, val)`. -/ lemma restrict_refut_fatCount [Fintype V] [DecidableEq V] {F : Set (Clause V)} {π : List (Clause V)} (hπ : IsResRefut F π) (v : V) (val : Bool) (d : ℕ) : ∃ π', IsResRefut (restrictCNF F v val) π' ∧ fatCount π' d ≤ (π.filter fun C => decide (d < width C ∧ C v ≠ some val)).length := by classical -- Inductively build for each prefix `m ≤ π.length` a valid derivation `π'` of `restrictCNF F v val` -- such that every surviving `π[i]` (i < m, `π[i] v ≠ some val`) has a subclause in `π'`, -- and `fatCount π' d ≤ ((π.take m).filter (fun C => d < width C ∧ C v ≠ some val)).length`. have hprefix : ∀ m (hm : m ≤ π.length), ∃ π' : List (Clause {u : V // u ≠ v}), IsResProof (restrictCNF F v val) π' ∧ (∀ i (hi : i < m), (π[i]'(Nat.lt_of_lt_of_le hi hm)) v ≠ some val → ∃ D ∈ π', Subclause D (restrictClause v (π[i]'(Nat.lt_of_lt_of_le hi hm)))) ∧ fatCount π' d ≤ ((π.take m).filter fun C => decide (d < width C ∧ C v ≠ some val)).length := by intro m induction m with | zero => intro _ refine ⟨[], fun i hi => by simp at hi, fun i hi => by omega, by simp [fatCount]⟩ | succ m ih => intro hm have hm_lt : m < π.length := Nat.lt_of_succ_le hm rcases ih (Nat.le_of_lt hm_lt) with ⟨π', hproof', hsub', hfat'⟩ have htake : π.take (m + 1) = π.take m ++ [π[m]] := List.take_succ_eq_append_getElem hm_lt by_cases hsat : π[m] v = some val · -- Clause `π[m]` is satisfied by `(v, val)`: do not append anything. refine ⟨π', hproof', ?_, ?_⟩ · intro i hi hne by_cases him : i < m · exact hsub' i him hne · have : i = m := by omega subst this; exact absurd hsat hne · rw [htake, List.filter_append, List.length_append] exact Nat.le_trans hfat' (Nat.le_add_right _ _) · -- Clause `π[m]` survives restriction. -- Either we reuse an existing subclause in `π'`, or append ONE clause `D ⊆ restrictClause v π[m]`. have hstep : ∃ (add : Option (Clause {u : V // u ≠ v})), match add with | none => ∃ D ∈ π', Subclause D (restrictClause v π[m]) | some D => Subclause D (restrictClause v π[m]) ∧ IsResProof (restrictCNF F v val) (π' ++ [D]) := by rcases hπ.1 m hm_lt with hax | ⟨j, k, hj, hk, pv, hres⟩ · refine ⟨some (restrictClause v π[m]), fun _ _ h => h, ?_⟩ apply isResProof_append hproof' intro idx hidx have hidx0 : idx = 0 := by simpa using hidx subst hidx0 exact Or.inl ⟨π[m], hax, hsat, rfl⟩ · -- Resolution step `π[j], π[k] ⊢_pv π[m]`. by_cases hpv : pv = v · subst pv cases val with | true => have hne_k : (π[k]'(Nat.lt_trans hk hm_lt)) v ≠ some true := by rw [hres.2.1]; simp rcases hsub' k hk hne_k with ⟨Dk, hDk_mem, hDk_sub⟩ refine ⟨none, Dk, hDk_mem, ?_⟩ intro u b hbu have h1 := hDk_sub u b hbu simp only [restrictClause] at h1 ⊢ rw [hres.2.2.2.2 u.1 u.2] cases hjc : (π[j]'(Nat.lt_trans hj hm_lt)) u.1 with | none => simp [h1] | some b₁ => have := hres.2.2.1 u.1 u.2 b₁ b hjc h1 subst this; simp | false => have hne_j : (π[j]'(Nat.lt_trans hj hm_lt)) v ≠ some false := by rw [hres.1]; simp rcases hsub' j hj hne_j with ⟨Dj, hDj_mem, hDj_sub⟩ refine ⟨none, Dj, hDj_mem, ?_⟩ intro u b hbu have h1 := hDj_sub u b hbu simp only [restrictClause] at h1 ⊢ rw [hres.2.2.2.2 u.1 u.2] simp [h1] · -- Pivot `pv ≠ v`: neither parent can have `some val` at `v`! have hne_j : (π[j]'(Nat.lt_trans hj hm_lt)) v ≠ some val := by intro heq have := hres.2.2.2.2 v (Ne.symm hpv) rw [heq] at this exact hsat (by simpa using this) have hne_k : (π[k]'(Nat.lt_trans hk hm_lt)) v ≠ some val := by intro heq have := hres.2.2.2.2 v (Ne.symm hpv) rw [heq] at this cases hjv : (π[j]'(Nat.lt_trans hj hm_lt)) v with | none => exact hsat (by simpa [hjv] using this) | some b₁ => have hb := hres.2.2.1 v (Ne.symm hpv) b₁ val hjv heq subst hb; exact hsat (by simpa [hjv] using this) rcases hsub' j hj hne_j with ⟨Dj, hDj_mem, hDj_sub⟩ rcases hsub' k hk hne_k with ⟨Dk, hDk_mem, hDk_sub⟩ -- Induced resolution on restricted clauses at `⟨pv, hpv⟩`. have hres_r : Resolves (restrictClause v (π[j]'(Nat.lt_trans hj hm_lt))) (restrictClause v (π[k]'(Nat.lt_trans hk hm_lt))) ⟨pv, hpv⟩ (restrictClause v π[m]) := by refine ⟨hres.1, hres.2.1, ?_, hres.2.2.2.1, ?_⟩ · intro u huv b₁ b₂ h1 h2 exact hres.2.2.1 u.1 (fun h => huv (Subtype.ext h)) b₁ b₂ h1 h2 · intro u huv exact hres.2.2.2.2 u.1 (fun h => huv (Subtype.ext h)) rcases subclause_resolve_step hres_r hDj_sub hDk_sub with h1 | h2 | ⟨D, hDr, hDsub⟩ · exact ⟨none, Dj, hDj_mem, h1⟩ · exact ⟨none, Dk, hDk_mem, h2⟩ · refine ⟨some D, hDsub, ?_⟩ rcases List.mem_iff_getElem.mp hDj_mem with ⟨aj, haj, rfl⟩ rcases List.mem_iff_getElem.mp hDk_mem with ⟨ak, hak, rfl⟩ intro idx hidx by_cases hlt : idx < π'.length · rw [List.getElem_append_left hlt] rcases hproof' idx hlt with hm' | ⟨x, y, hx, hy, w, hr'⟩ · exact Or.inl hm' · right refine ⟨x, y, hx, hy, w, ?_⟩ simpa [List.getElem_append_left (Nat.lt_trans hx hlt), List.getElem_append_left (Nat.lt_trans hy hlt)] using hr' · have hidx_eq : idx = π'.length := by have : idx < π'.length + 1 := by simpa using hidx omega subst hidx_eq right refine ⟨aj, ak, haj, hak, ⟨pv, hpv⟩, ?_⟩ simpa [List.getElem_append_left haj, List.getElem_append_left hak] using hDr rcases hstep with ⟨add, hadd⟩ cases add with | none => rcases hadd with ⟨D, hDmem, hDsub⟩ refine ⟨π', hproof', ?_, ?_⟩ · intro i hi hne by_cases him : i < m · exact hsub' i him hne · have : i = m := by omega subst this; exact ⟨D, hDmem, hDsub⟩ · rw [htake, List.filter_append, List.length_append] exact Nat.le_trans hfat' (Nat.le_add_right _ _) | some D => rcases hadd with ⟨hDsub, hproof_new⟩ refine ⟨π' ++ [D], hproof_new, ?_, ?_⟩ · intro i hi hne by_cases him : i < m · rcases hsub' i him hne with ⟨D0, hD0mem, hD0sub⟩ exact ⟨D0, List.mem_append_left _ hD0mem, hD0sub⟩ · have : i = m := by omega subst this exact ⟨D, List.mem_append_right _ (by simp), hDsub⟩ · rw [htake, List.filter_append, List.length_append] unfold fatCount rw [List.filter_append, List.length_append] have hDw : width D ≤ width π[m] := Nat.le_trans (width_mono hDsub) (width_restrictClause v π[m]) have hsingle : ([D].filter fun C => decide (d < width C)).length ≤ ([π[m]].filter fun C => decide (d < width C ∧ C v ≠ some val)).length := by by_cases hdw : d < width D · have hmw : d < width π[m] := Nat.lt_of_lt_of_le hdw hDw simp [hdw, hmw, hsat] · simp [hdw] exact Nat.add_le_add hfat' hsingle rcases hprefix π.length (le_refl _) with ⟨π', hproof', hsub', hfat'⟩ rcases List.mem_iff_getElem.mp hπ.2 with ⟨ie, hie, heq⟩ have hne_e : π[ie] v ≠ some val := by rw [heq]; simp [emptyClause] rcases hsub' ie hie hne_e with ⟨De, hDe_mem, hDe_sub⟩ have hDe_eq : De = emptyClause := by apply subclause_empty_iff.mp intro u b hbu have := hDe_sub u b hbu simp only [restrictClause, heq, emptyClause] at this exact this subst hDe_eq refine ⟨π', ⟨hproof', hDe_mem⟩, ?_⟩ simpa using hfat' /-- Adding literal `(v, b)` to a clause on `{u : V // u ≠ v}`. -/ def liftClause [DecidableEq V] (v : V) (b : Bool) (D : Clause {u : V // u ≠ v}) : Clause V := fun u => if h : u = v then some b else D ⟨u, h⟩ lemma width_liftClause [Fintype V] [DecidableEq V] (v : V) (b : Bool) (D : Clause {u : V // u ≠ v}) : width (liftClause v b D) = width D + 1 := by have hset : (Finset.univ.filter fun u : V => (liftClause v b D u).isSome) = insert v ((Finset.univ.filter fun u : {u : V // u ≠ v} => (D u).isSome).map ⟨Subtype.val, Subtype.val_injective⟩) := by ext x rw [Finset.mem_filter, Finset.mem_insert, Finset.mem_map] simp only [Finset.mem_univ, true_and, Finset.mem_filter, Function.Embedding.coeFn_mk, liftClause] by_cases hxv : x = v · subst hxv; simp · simp only [hxv, ↓reduceDIte, false_or] constructor · intro hx; exact ⟨⟨x, hxv⟩, hx, rfl⟩ · rintro ⟨⟨u, hu⟩, hdu, rfl⟩; exact hdu have hnot : v ∉ (Finset.univ.filter fun u : {u : V // u ≠ v} => (D u).isSome).map ⟨Subtype.val, Subtype.val_injective⟩ := by simp rw [width, hset, Finset.card_insert_of_notMem hnot, Finset.card_map] rfl /-- Lifting a width-`W` refutation of `restrictCNF F v val` produces a width-`(W + 1)` derivation from `F` of either `emptyClause` or `unitClause v (!val)`. -/ lemma lift_refut_add_lit [Fintype V] [DecidableEq V] {F : Set (Clause V)} {v : V} {val : Bool} {W : ℕ} (h : HasWidthRefut (restrictCNF F v val) W) : ∃ π C, IsResProof F π ∧ C ∈ π ∧ (∀ D ∈ π, width D ≤ W + 1) ∧ (C = emptyClause ∨ C = unitClause v (!val)) := by classical rcases h with ⟨π, ⟨hproof, hemp⟩, hwidth⟩ have hprefix : ∀ m (hm : m ≤ π.length), ∃ π' : List (Clause V), IsResProof F π' ∧ (∀ D ∈ π', width D ≤ W + 1) ∧ (∀ i (hi : i < m), ∃ D ∈ π', Subclause D (liftClause v (!val) (π[i]'(Nat.lt_of_lt_of_le hi hm)))) := by intro m induction m with | zero => intro _ exact ⟨[], fun i hi => by simp at hi, fun _ h => by simp at h, fun _ hi => by omega⟩ | succ m ih => intro hm have hm_lt : m < π.length := Nat.lt_of_succ_le hm rcases ih (Nat.le_of_lt hm_lt) with ⟨π', hproof', hw', hsub'⟩ have hWm : width π[m] ≤ W := hwidth π[m] (List.getElem_mem hm_lt) rcases hproof m hm_lt with ⟨C, hCF, hCv, hCeq⟩ | ⟨j, k, hj, hk, pv, hres⟩ · -- Axiom `π[m] = restrictClause v C` with `C ∈ F`, `C v ≠ some val`. have hCsub : Subclause C (liftClause v (!val) π[m]) := by intro u b hub simp only [liftClause] by_cases huv : u = v · subst huv simp only [↓reduceDIte] rw [hub] at hCv cases val <;> cases b <;> simp_all · simp only [huv, ↓reduceDIte] rw [hCeq]; exact hub have hCw : width C ≤ W + 1 := by have := width_mono hCsub rw [width_liftClause] at this exact Nat.le_trans this (Nat.add_le_add_right hWm 1) refine ⟨π' ++ [C], ?_, ?_, ?_⟩ · apply isResProof_append hproof' intro idx hidx have : idx = 0 := by simpa using hidx subst this; exact Or.inl hCF · intro D hD rcases List.mem_append.mp hD with h1 | h2 · exact hw' D h1 · simp only [List.mem_singleton] at h2; subst h2; exact hCw · intro i hi by_cases him : i < m · rcases hsub' i him with ⟨D0, hD0m, hD0s⟩ exact ⟨D0, List.mem_append_left _ hD0m, hD0s⟩ · have : i = m := by omega subst this exact ⟨C, List.mem_append_right _ (by simp), hCsub⟩ · -- Resolution step `π[j], π[k] ⊢_pv π[m]`. rcases hsub' j hj with ⟨Dj, hDj_mem, hDj_sub⟩ rcases hsub' k hk with ⟨Dk, hDk_mem, hDk_sub⟩ have hres_lift : Resolves (liftClause v (!val) (π[j]'(Nat.lt_trans hj hm_lt))) (liftClause v (!val) (π[k]'(Nat.lt_trans hk hm_lt))) pv.1 (liftClause v (!val) π[m]) := by refine ⟨?_, ?_, ?_, ?_, ?_⟩ · simp [liftClause, pv.2, hres.1] · simp [liftClause, pv.2, hres.2.1] · intro u huv b₁ b₂ h1 h2 simp only [liftClause] at h1 h2 by_cases hu : u = v · simp only [hu, ↓reduceDIte] at h1 h2 cases h1; cases h2; rfl · simp only [hu, ↓reduceDIte] at h1 h2 exact hres.2.2.1 ⟨u, hu⟩ (fun heq => huv (congrArg Subtype.val heq)) b₁ b₂ h1 h2 · simp [liftClause, pv.2, hres.2.2.2.1] · intro u huv simp only [liftClause] by_cases hu : u = v · simp [hu] · simp only [hu, ↓reduceDIte] exact hres.2.2.2.2 ⟨u, hu⟩ (fun heq => huv (congrArg Subtype.val heq)) rcases subclause_resolve_step hres_lift hDj_sub hDk_sub with h1 | h2 | ⟨D, hDr, hDsub⟩ · refine ⟨π', hproof', hw', ?_⟩ intro i hi by_cases him : i < m · exact hsub' i him · have : i = m := by omega subst this; exact ⟨Dj, hDj_mem, h1⟩ · refine ⟨π', hproof', hw', ?_⟩ intro i hi by_cases him : i < m · exact hsub' i him · have : i = m := by omega subst this; exact ⟨Dk, hDk_mem, h2⟩ · have hDw : width D ≤ W + 1 := by have := width_mono hDsub rw [width_liftClause] at this exact Nat.le_trans this (Nat.add_le_add_right hWm 1) rcases List.mem_iff_getElem.mp hDj_mem with ⟨aj, haj, rfl⟩ rcases List.mem_iff_getElem.mp hDk_mem with ⟨ak, hak, rfl⟩ refine ⟨π' ++ [D], ?_, ?_, ?_⟩ · intro idx hidx by_cases hlt : idx < π'.length · rw [List.getElem_append_left hlt] rcases hproof' idx hlt with hm' | ⟨x, y, hx, hy, w, hr'⟩ · exact Or.inl hm' · right refine ⟨x, y, hx, hy, w, ?_⟩ simpa [List.getElem_append_left (Nat.lt_trans hx hlt), List.getElem_append_left (Nat.lt_trans hy hlt)] using hr' · have hidx_eq : idx = π'.length := by have : idx < π'.length + 1 := by simpa using hidx omega subst hidx_eq right refine ⟨aj, ak, haj, hak, pv.1, ?_⟩ simpa [List.getElem_append_left haj, List.getElem_append_left hak] using hDr · intro E hE rcases List.mem_append.mp hE with h1 | h2 · exact hw' E h1 · simp only [List.mem_singleton] at h2; subst h2; exact hDw · intro i hi by_cases him : i < m · rcases hsub' i him with ⟨D0, hD0m, hD0s⟩ exact ⟨D0, List.mem_append_left _ hD0m, hD0s⟩ · have : i = m := by omega subst this exact ⟨D, List.mem_append_right _ (by simp), hDsub⟩ rcases hprefix π.length (le_refl _) with ⟨π', hproof', hw', hsub'⟩ rcases List.mem_iff_getElem.mp hemp with ⟨ie, hie, heq⟩ rcases hsub' ie hie with ⟨De, hDe_mem, hDe_sub⟩ refine ⟨π', De, hproof', hDe_mem, hw', ?_⟩ cases hdev : De v with | none => left funext u by_cases huv : u = v · subst huv; exact hdev · cases hdu : De u with | none => rfl | some b => have := hDe_sub u b hdu simp [liftClause, huv, heq, emptyClause] at this | some b => have hb : b = !val := by have h1 := hDe_sub v b hdev simp only [liftClause, ↓reduceDIte, Option.some.injEq] at h1 exact h1.symm subst hb right funext u by_cases huv : u = v · subst huv; simp [unitClause, hdev] · simp only [unitClause, Function.update_of_ne huv, emptyClause] cases hdu : De u with | none => rfl | some b' => have := hDe_sub u b' hdu simp [liftClause, huv, heq, emptyClause] at this /-- Embedding a clause on `{u : V // u ≠ v}` into `Clause V` with `v ↦ none`. -/ def embedClause [DecidableEq V] (v : V) (D : Clause {u : V // u ≠ v}) : Clause V := fun u => if h : u = v then none else D ⟨u, h⟩ lemma width_embedClause [Fintype V] [DecidableEq V] (v : V) (D : Clause {u : V // u ≠ v}) : width (embedClause v D) = width D := by have hset : (Finset.univ.filter fun u : V => (embedClause v D u).isSome) = (Finset.univ.filter fun u : {u : V // u ≠ v} => (D u).isSome).map ⟨Subtype.val, Subtype.val_injective⟩ := by ext x rw [Finset.mem_filter, Finset.mem_map] simp only [Finset.mem_univ, true_and, Finset.mem_filter, Function.Embedding.coeFn_mk, embedClause] by_cases hxv : x = v · subst hxv; simp · simp only [hxv, ↓reduceDIte] constructor · intro hx; exact ⟨⟨x, hxv⟩, hx, rfl⟩ · rintro ⟨⟨u, hu⟩, hdu, rfl⟩; exact hdu rw [width, hset, Finset.card_map]; rfl /-- Resolving a derived unit clause `unitClause v (!val)` against `F` lifts any width-`W` refutation of `restrictCNF F v (!val)` to a width-`W` refutation of `F` (assuming `w(F) ≤ W`). -/ lemma combine_unit_and_restricted_refut [Fintype V] [DecidableEq V] {F : Set (Clause V)} {v : V} {val : Bool} {W : ℕ} (hF : ∀ C ∈ F, width C ≤ W) (h1 : ∃ π₁ C₁, IsResProof F π₁ ∧ C₁ ∈ π₁ ∧ (∀ D ∈ π₁, width D ≤ W) ∧ (C₁ = emptyClause ∨ C₁ = unitClause v (!val))) (h2 : HasWidthRefut (restrictCNF F v (!val)) W) : HasWidthRefut F W := by classical rcases h1 with ⟨π₁, C₁, hproof1, hC1_mem, hw1, hC1_eq | hC1_eq⟩ · subst hC1_eq; exact ⟨π₁, ⟨hproof1, hC1_mem⟩, hw1⟩ · subst hC1_eq rcases h2 with ⟨π₂, ⟨hproof2, hemp2⟩, hw2⟩ -- Build prefix of `π₂` embedded into `Clause V`, starting from `π₁`. have hprefix : ∀ m (hm : m ≤ π₂.length), ∃ π' : List (Clause V), IsResProof F π' ∧ (∀ D ∈ π', width D ≤ W) ∧ unitClause v (!val) ∈ π' ∧ (∀ i (hi : i < m), embedClause v (π₂[i]'(Nat.lt_of_lt_of_le hi hm)) ∈ π') := by intro m induction m with | zero => intro _ exact ⟨π₁, hproof1, hw1, hC1_mem, fun _ hi => by omega⟩ | succ m ih => intro hm have hm_lt : m < π₂.length := Nat.lt_of_succ_le hm rcases ih (Nat.le_of_lt hm_lt) with ⟨π', hproof', hw', hunit', hmem'⟩ have hWm : width (embedClause v π₂[m]) ≤ W := by rw [width_embedClause] exact hw2 π₂[m] (List.getElem_mem hm_lt) rcases hproof2 m hm_lt with ⟨C, hCF, hCv, hCeq⟩ | ⟨j, k, hj, hk, pv, hres⟩ · -- Axiom `π₂[m] = restrictClause v C` with `C ∈ F`, `C v ≠ some (!val)`. cases hcv_opt : C v with | none => have hC_eq_emb : C = embedClause v π₂[m] := by funext u simp only [embedClause] by_cases huv : u = v · subst huv; simp [hcv_opt] · simp only [huv, ↓reduceDIte, hCeq, restrictClause] refine ⟨π' ++ [C], ?_, ?_, List.mem_append_left _ hunit', ?_⟩ · apply isResProof_append hproof' intro idx hidx have : idx = 0 := by simpa using hidx subst this; exact Or.inl hCF · intro D hD rcases List.mem_append.mp hD with h1 | h2 · exact hw' D h1 · rcases List.mem_singleton.mp h2 with rfl; exact hF D hCF · intro i hi by_cases him : i < m · exact List.mem_append_left _ (hmem' i him) · have : i = m := by omega subst this rw [← hC_eq_emb] exact List.mem_append_right _ (by simp) | some b => have hb : b = val := by rw [hcv_opt] at hCv cases val <;> cases b <;> simp_all subst b rcases List.mem_iff_getElem.mp hunit' with ⟨au, hau, hau_eq⟩ have hres_unit : match val with | true => Resolves C (unitClause v false) v (embedClause v π₂[m]) | false => Resolves (unitClause v true) C v (embedClause v π₂[m]) := by cases val with | true => refine ⟨hcv_opt, by simp [unitClause], ?_, by simp [embedClause], ?_⟩ · intro u huv b₁ b₂ _ h2 simp [unitClause, Function.update_of_ne huv, emptyClause] at h2 · intro u huv simp only [embedClause, huv, ↓reduceDIte, unitClause, Function.update_of_ne huv, emptyClause, hCeq, restrictClause] cases C u <;> rfl | false => refine ⟨by simp [unitClause], hcv_opt, ?_, by simp [embedClause], ?_⟩ · intro u huv b₁ b₂ h1 _ simp [unitClause, Function.update_of_ne huv, emptyClause] at h1 · intro u huv simp only [embedClause, huv, ↓reduceDIte, unitClause, Function.update_of_ne huv, emptyClause, hCeq, restrictClause] cases C u <;> rfl refine ⟨π' ++ [C, embedClause v π₂[m]], ?_, ?_, List.mem_append_left _ hunit', ?_⟩ · intro idx hidx by_cases hlt : idx < π'.length · rw [List.getElem_append_left hlt] rcases hproof' idx hlt with hm' | ⟨x, y, hx, hy, w, hr'⟩ · exact Or.inl hm' · right refine ⟨x, y, hx, hy, w, ?_⟩ simpa [List.getElem_append_left (Nat.lt_trans hx hlt), List.getElem_append_left (Nat.lt_trans hy hlt)] using hr' · by_cases heq1 : idx = π'.length · subst heq1 left simpa [List.getElem_append_right (le_refl _)] using hCF · have heq2 : idx = π'.length + 1 := by have : idx < π'.length + 2 := by simpa using hidx omega subst heq2 right cases val with | true => refine ⟨π'.length, au, by omega, by omega, v, ?_⟩ simpa [List.getElem_append_left hau, hau_eq, List.getElem_append_right (le_refl _), List.getElem_append_right (Nat.le_succ _)] using hres_unit | false => refine ⟨au, π'.length, by omega, by omega, v, ?_⟩ simpa [List.getElem_append_left hau, hau_eq, List.getElem_append_right (le_refl _), List.getElem_append_right (Nat.le_succ _)] using hres_unit · intro D hD rcases List.mem_append.mp hD with h1 | h2 · exact hw' D h1 · simp only [List.mem_cons, List.not_mem_nil, or_false] at h2 rcases h2 with rfl | rfl · exact hF D hCF · exact hWm · intro i hi by_cases him : i < m · exact List.mem_append_left _ (hmem' i him) · have : i = m := by omega subst this exact List.mem_append_right _ (by simp) · -- Resolution step `π₂[j], π₂[k] ⊢_pv π₂[m]`. rcases List.mem_iff_getElem.mp (hmem' j hj) with ⟨aj, haj, haj_eq⟩ rcases List.mem_iff_getElem.mp (hmem' k hk) with ⟨ak, hak, hak_eq⟩ have hres_emb : Resolves (embedClause v (π₂[j]'(Nat.lt_trans hj hm_lt))) (embedClause v (π₂[k]'(Nat.lt_trans hk hm_lt))) pv.1 (embedClause v π₂[m]) := by refine ⟨?_, ?_, ?_, ?_, ?_⟩ · simp [embedClause, pv.2, hres.1] · simp [embedClause, pv.2, hres.2.1] · intro u huv b₁ b₂ h1 h2 simp only [embedClause] at h1 h2 by_cases hu : u = v · simp [hu] at h1 · simp only [hu, ↓reduceDIte] at h1 h2 exact hres.2.2.1 ⟨u, hu⟩ (fun heq => huv (congrArg Subtype.val heq)) b₁ b₂ h1 h2 · simp [embedClause, pv.2, hres.2.2.2.1] · intro u huv simp only [embedClause] by_cases hu : u = v · simp [hu] · simp only [hu, ↓reduceDIte] exact hres.2.2.2.2 ⟨u, hu⟩ (fun heq => huv (congrArg Subtype.val heq)) refine ⟨π' ++ [embedClause v π₂[m]], ?_, ?_, List.mem_append_left _ hunit', ?_⟩ · intro idx hidx by_cases hlt : idx < π'.length · rw [List.getElem_append_left hlt] rcases hproof' idx hlt with hm' | ⟨x, y, hx, hy, w, hr'⟩ · exact Or.inl hm' · right refine ⟨x, y, hx, hy, w, ?_⟩ simpa [List.getElem_append_left (Nat.lt_trans hx hlt), List.getElem_append_left (Nat.lt_trans hy hlt)] using hr' · have heq1 : idx = π'.length := by have : idx < π'.length + 1 := by simpa using hidx omega subst heq1 right refine ⟨aj, ak, haj, hak, pv.1, ?_⟩ simpa [List.getElem_append_left haj, List.getElem_append_left hak, haj_eq, hak_eq] using hres_emb · intro D hD rcases List.mem_append.mp hD with h1 | h2 · exact hw' D h1 · simp only [List.mem_singleton] at h2; subst h2; exact hWm · intro i hi by_cases him : i < m · exact List.mem_append_left _ (hmem' i him) · have : i = m := by omega subst this exact List.mem_append_right _ (by simp) rcases hprefix π₂.length (le_refl _) with ⟨π', hproof', hw', _, hmem'⟩ rcases List.mem_iff_getElem.mp hemp2 with ⟨ie, hie, heq⟩ have hemp_in : embedClause v emptyClause ∈ π' := by have := hmem' ie hie rwa [heq] at this have hemb_emp : embedClause v (emptyClause : Clause {u : V // u ≠ v}) = emptyClause := by funext u; by_cases huv : u = v <;> simp [embedClause, huv, emptyClause] rw [hemb_emp] at hemp_in exact ⟨π', ⟨hproof', hemp_in⟩, hw'⟩ /-- Literal averaging (pigeonhole): if `π` has `S ≥ 1` fat clauses of width `> d` over `n` variables, some literal `(v, val)` occurs in at least `⌈((d + 1) * S) / (2 * n)⌉` fat clauses. -/ lemma bsw_pigeonhole_literal [Fintype V] [DecidableEq V] (π : List (Clause V)) (d : ℕ) (hpos : 0 < fatCount π d) : ∃ v : V, ∃ val : Bool, (d + 1) * fatCount π d ≤ 2 * Fintype.card V * (π.filter fun C => decide (d < width C ∧ C v = some val)).length := by classical let fat := π.filter fun C => decide (d < width C) have hS : fat.length = fatCount π d := rfl -- Sum over all (v, val) of occurrences in `fat` equals ∑ C ∈ fat, width C ≥ (d + 1) * fat.length. have hcount_eq : ∀ v (val : Bool), (π.filter fun C => decide (d < width C ∧ C v = some val)).length = (fat.filter fun C => decide (C v = some val)).length := by intro v val simp only [fat, List.filter_filter] congr 1 apply List.filter_congr intro C _ simp [Bool.and_comm] -- Double counting on `fat`. have hsum_ge : (d + 1) * fat.length ≤ ∑ v : V, ∑ val : Bool, (fat.filter fun C => decide (C v = some val)).length := by have h1 : ∀ (L : List (Clause V)), (∀ C ∈ L, d + 1 ≤ width C) → (d + 1) * L.length ≤ ∑ v : V, ∑ val : Bool, (L.filter fun C => decide (C v = some val)).length := by intro L induction L with | nil => intro _; simp | cons C L ih => intro hL have hC : d + 1 ≤ width C := hL C (by simp) have htail := ih (fun C' hC' => hL C' (by simp [hC'])) have hCsum : width C = ∑ v : V, ∑ val : Bool, if C v = some val then 1 else 0 := by rw [width, Finset.card_eq_sum_ones, Finset.sum_filter] apply Finset.sum_congr rfl intro v _ cases C v with | none => simp | some b => cases b <;> simp have hstep : ∑ v : V, ∑ val : Bool, ((C :: L).filter fun C' => decide (C' v = some val)).length = (∑ v : V, ∑ val : Bool, if C v = some val then 1 else 0) + ∑ v : V, ∑ val : Bool, (L.filter fun C' => decide (C' v = some val)).length := by rw [← Finset.sum_add_distrib] apply Finset.sum_congr rfl; intro v _ rw [← Finset.sum_add_distrib] apply Finset.sum_congr rfl; intro val _ by_cases h : C v = some val <;> simp [h, Nat.add_comm] rw [hstep, ← hCsum, List.length_cons, Nat.mul_succ] omega apply h1 fat intro C hC have := (List.mem_filter.mp hC).2 simp only [decide_eq_true_eq] at this omega -- Average over `V × Bool` (size `2 * card V`). have hneV : Nonempty V := by by_contra hemp rw [not_nonempty_iff] at hemp have : fat = [] := by cases hfat : fat with | nil => rfl | cons C _ => have hC : C ∈ fat := by simp [hfat] have hw := (List.mem_filter.mp hC).2 simp only [decide_eq_true_eq] at hw have h0 := width_le_card C rw [Fintype.card_eq_zero] at h0 omega rw [← hS, this] at hpos simp at hpos let f : V × Bool → ℕ := fun p => (fat.filter fun C => decide (C p.1 = some p.2)).length have hsum_prod : (∑ p : V × Bool, f p) = ∑ v : V, ∑ val : Bool, (fat.filter fun C => decide (C v = some val)).length := by simpa [f] using Fintype.sum_prod_type f have hmax : ∃ p : V × Bool, (∑ q : V × Bool, f q) ≤ Fintype.card (V × Bool) * f p := by obtain ⟨p, _, hp⟩ := Finset.exists_max_image (Finset.univ : Finset (V × Bool)) f Finset.univ_nonempty refine ⟨p, ?_⟩ calc ∑ q : V × Bool, f q ≤ ∑ _q : V × Bool, f p := Finset.sum_le_sum fun q _ => hp q (Finset.mem_univ q) _ = Fintype.card (V × Bool) * f p := by simp rcases hmax with ⟨⟨v, val⟩, hp⟩ refine ⟨v, val, ?_⟩ rw [hcount_eq v val] have hcard : Fintype.card (V × Bool) = 2 * Fintype.card V := by rw [Fintype.card_prod, Fintype.card_bool, Nat.mul_comm] rw [hcard] at hp rw [← hS] exact Nat.le_trans hsum_ge (hsum_prod ▸ hp) /-- Exact integer Ben-Sasson–Wigderson ceiling recurrence `T_ℕ(n, d, b)`. For `n > d + b`: `T_ℕ(n, d, 0) = 1` and `T_ℕ(n, d, b + 1) = ⌈2n · T_ℕ(n - 1, d, b) / (2n - (d + 1))⌉`. -/ def bswThresh : ℕ → ℕ → ℕ → ℕ | _, _, 0 => 1 | n, d, b + 1 => if 2 * n ≤ d + 1 then 1 else (2 * n * bswThresh (n - 1) d b + (2 * n - (d + 1)) - 1) / (2 * n - (d + 1)) lemma bswThresh_pos (n d b : ℕ) : 0 < bswThresh n d b := by induction b generalizing n with | zero => simp [bswThresh] | succ b ih => unfold bswThresh split_ifs with h · omega · have hp := ih (n - 1) have hq : 0 < 2 * n - (d + 1) := by omega have hnum : 2 * n - (d + 1) ≤ 2 * n * bswThresh (n - 1) d b + (2 * n - (d + 1)) - 1 := by have : 1 ≤ 2 * n * bswThresh (n - 1) d b := by have : 1 ≤ 2 * n := by omega exact Nat.mul_pos this hp omega exact Nat.div_pos hnum hq /-- Key ceiling property of `bswThresh`: if `S < bswThresh n d (b + 1)` and `2n > d + 1`, then removing a `((d + 1)/(2n))`-fraction drops `S` strictly below `bswThresh (n - 1) d b`. -/ lemma bswThresh_step_lt {n d b S c : ℕ} (hq : d + 1 < 2 * n) (hS : S < bswThresh n d (b + 1)) (hc : (d + 1) * S ≤ 2 * n * c) : S - c < bswThresh (n - 1) d b := by unfold bswThresh at hS rw [if_neg (by omega)] at hS set q := 2 * n - (d + 1) set M := bswThresh (n - 1) d b have hqpos : 0 < q := by omega have hMpos : 0 < M := bswThresh_pos (n - 1) d b -- From `S < (2*n*M + q - 1) / q`, we have `q * S < 2 * n * M`! have hqS : q * S < 2 * n * M := by by_contra hge push Not at hge have hdiv : (2 * n * M + q - 1) / q ≤ S := by rw [Nat.div_le_iff_le_mul_add_pred hqpos] omega omega -- Now `2 * n * (S - c) ≤ 2 * n * S - (d + 1) * S = q * S < 2 * n * M`. by_cases hcs : c ≤ S · have hmul : 2 * n * (S - c) ≤ q * S := by have h1 : 2 * n * (S - c) + 2 * n * c = 2 * n * S := by rw [← Nat.mul_add, Nat.sub_add_cancel hcs] have h2 : q * S + (d + 1) * S = 2 * n * S := by rw [← Nat.add_mul, Nat.sub_add_cancel (by omega : d + 1 ≤ 2 * n)] omega have hlt : 2 * n * (S - c) < 2 * n * M := Nat.lt_of_le_of_lt hmul hqS exact Nat.lt_of_mul_lt_mul_left hlt · have : S - c = 0 := Nat.sub_eq_zero_of_le (Nat.le_of_not_ge hcs) omega /-- Monotonicity of `bswThresh` in `n` in the valid regime `d + b < n`. -/ lemma bswThresh_antitone_n {n d b : ℕ} (hn : d + b < n) : bswThresh (n + 1) d b ≤ bswThresh n d b := by induction b generalizing n with | zero => simp [bswThresh] | succ b ih => unfold bswThresh have hn1 : ¬ 2 * (n + 1) ≤ d + 1 := by omega have hn2 : ¬ 2 * n ≤ d + 1 := by omega rw [if_neg hn1, if_neg hn2] have hprev : bswThresh n d b ≤ bswThresh (n - 1) d b := by have : n = (n - 1) + 1 := by omega rw [this] exact ih (by omega) set M₁ := bswThresh n d b set M₂ := bswThresh (n - 1) d b set q₁ := 2 * (n + 1) - (d + 1) set q₂ := 2 * n - (d + 1) have hq1 : 0 < q₁ := by omega have hq2 : 0 < q₂ := by omega -- Goal: ⌈2(n+1) M₁ / q₁⌉ ≤ ⌈2n M₂ / q₂⌉. -- Suffices to show 2(n+1) M₁ * q₂ ≤ 2n M₂ * q₁ (since ceil is monotone on rationals!). have hcross : 2 * (n + 1) * M₁ * q₂ ≤ 2 * n * M₂ * q₁ := by have hratio : (n + 1) * q₂ ≤ n * q₁ := by -- (n+1)(2n - d - 1) = 2n^2 + 2n - (n+1)(d+1) ≤ 2n^2 + 2n - n(d+1) = n(2n + 2 - d - 1) have h1 : (n + 1) * q₂ + (n + 1) * (d + 1) = (n + 1) * (2 * n) := by rw [← Nat.mul_add, Nat.sub_add_cancel (by omega : d + 1 ≤ 2 * n)] have h2 : n * q₁ + n * (d + 1) = n * (2 * (n + 1)) := by rw [← Nat.mul_add, Nat.sub_add_cancel (by omega : d + 1 ≤ 2 * (n + 1))] nlinarith calc 2 * (n + 1) * M₁ * q₂ = 2 * ((n + 1) * q₂) * M₁ := by ring _ ≤ 2 * (n * q₁) * M₂ := by apply Nat.mul_le_mul (Nat.mul_le_mul_left 2 hratio) hprev _ = 2 * n * M₂ * q₁ := by ring -- Deduce integer ceiling inequality from `a * q₂ ≤ b * q₁`. set k := (2 * n * M₂ + q₂ - 1) / q₂ have hk : 2 * n * M₂ ≤ k * q₂ := by have hdiv : q₂ * k + (2 * n * M₂ + q₂ - 1) % q₂ = 2 * n * M₂ + q₂ - 1 := Nat.div_add_mod (2 * n * M₂ + q₂ - 1) q₂ have hmod : (2 * n * M₂ + q₂ - 1) % q₂ < q₂ := Nat.mod_lt _ hq2 rw [Nat.mul_comm q₂ k] at hdiv omega have hmul : 2 * (n + 1) * M₁ ≤ k * q₁ := by have h1 : 2 * (n + 1) * M₁ * q₂ ≤ k * q₁ * q₂ := by calc 2 * (n + 1) * M₁ * q₂ ≤ 2 * n * M₂ * q₁ := hcross _ ≤ (k * q₂) * q₁ := Nat.mul_le_mul_right q₁ hk _ = k * q₁ * q₂ := by ring exact Nat.le_of_mul_le_mul_right h1 hq2 change (2 * (n + 1) * M₁ + q₁ - 1) / q₁ ≤ k rw [Nat.div_le_iff_le_mul_add_pred hq1, Nat.mul_comm q₁ k] omega /-- **Headline Theorem 1A (Exact Non-Asymptotic BSW Ceiling-Recurrence Trade-Off, No `-k` Penalty):** If every initial clause of `F` on `n = |V|` variables has width `≤ d + 1` (i.e. `d ≥ w(F) - 1`), and `π` is a DAG Resolution refutation of `F` with strictly fewer than `bswThresh n d b` clauses of width `> d`, then `F` admits a Resolution refutation of width `≤ d + b`. -/ theorem bsw_exact_recurrence_tradeoff {V : Type u} [Fintype V] [DecidableEq V] {F : Set (Clause V)} {π : List (Clause V)} {d b : ℕ} (hF : ∀ C ∈ F, width C ≤ d + 1) (hπ : IsResRefut F π) (hS : fatCount π d < bswThresh (Fintype.card V) d b) : HasWidthRefut F (d + b) := by -- Strong induction on `Fintype.card V + b`, generalizing `V : Type u`. suffices hmain : ∀ N (V' : Type u) [Fintype V'] [DecidableEq V'] (F' : Set (Clause V')) (π' : List (Clause V')) (b' : ℕ), Fintype.card V' + b' = N → (∀ C ∈ F', width C ≤ d + 1) → IsResRefut F' π' → (Fintype.card V' ≤ d + b' ∨ fatCount π' d < bswThresh (Fintype.card V') d b') → HasWidthRefut F' (d + b') by exact hmain (Fintype.card V + b) V F π b rfl hF hπ (Or.inr hS) intro N induction N using Nat.strong_induction_on with | h N ih => intro V' _ _ F' π' b' hN hF' hπ' hcond -- Case 0: `card V' ≤ d + b'`: every clause on `V'` automatically has width `≤ card V' ≤ d + b'`. by_cases htriv : Fintype.card V' ≤ d + b' · exact ⟨π', hπ', fun C _ => Nat.le_trans (width_le_card C) htriv⟩ have hgt : d + b' < Fintype.card V' := Nat.lt_of_not_ge htriv have hS' : fatCount π' d < bswThresh (Fintype.card V') d b' := hcond.resolve_left htriv -- Case 1: `fatCount π' d = 0`: `π'` itself already has width `≤ d ≤ d + b'`. by_cases hfat0 : fatCount π' d = 0 · refine ⟨π', hπ', fun C hC => ?_⟩ have hnot : ¬ d < width C := by intro hlt have hmem : C ∈ π'.filter (fun D => decide (d < width D)) := List.mem_filter.mpr ⟨hC, by simp [hlt]⟩ have hpos : 0 < (π'.filter (fun D => decide (d < width D))).length := List.length_pos_of_mem hmem exact absurd hpos (by simpa [fatCount] using hfat0) omega -- Case 2: `b' = 0` is impossible since `bswThresh _ d 0 = 1` and `fatCount > 0`. cases b' with | zero => simp [bswThresh] at hS' exact absurd hS' hfat0 | succ b0 => -- `fatCount π' d > 0` and `d + b0 + 1 < card V'`. have hpos : 0 < fatCount π' d := Nat.pos_of_ne_zero hfat0 rcases bsw_pigeonhole_literal π' d hpos with ⟨v, val, hpig⟩ -- Branch 1: restrict `(v, val)` -> fat count drops strictly below `bswThresh (card V' - 1) d b0`. rcases restrict_refut_fatCount hπ' v val d with ⟨π₁, hπ₁, hfat₁⟩ have hcard_sub : Fintype.card {u : V' // u ≠ v} = Fintype.card V' - 1 := by rw [Fintype.card_subtype_compl, Fintype.card_subtype_eq] have hfat_split : (π'.filter fun C => decide (d < width C ∧ C v ≠ some val)).length + (π'.filter fun C => decide (d < width C ∧ C v = some val)).length = fatCount π' d := by have hgen : ∀ (L : List (Clause V')) (p q : Clause V' → Bool), (L.filter fun C => p C && !q C).length + (L.filter fun C => p C && q C).length = (L.filter p).length := by intro L p q induction L with | nil => simp | cons C L ihL => cases hp : p C <;> cases hq : q C <;> simp [hp, hq] <;> omega have h1 : (π'.filter fun C => decide (d < width C ∧ C v ≠ some val)) = (π'.filter fun C => decide (d < width C) && !decide (C v = some val)) := List.filter_congr fun C _ => by simp have h2 : (π'.filter fun C => decide (d < width C ∧ C v = some val)) = (π'.filter fun C => decide (d < width C) && decide (C v = some val)) := List.filter_congr fun C _ => by simp rw [h1, h2] exact hgen π' (fun C => decide (d < width C)) (fun C => decide (C v = some val)) set c := (π'.filter fun C => decide (d < width C ∧ C v = some val)).length have hfat₁_sub : fatCount π₁ d ≤ fatCount π' d - c := by omega have hlt₁ : fatCount π₁ d < bswThresh (Fintype.card {u : V' // u ≠ v}) d b0 := by rw [hcard_sub] have hstep := bswThresh_step_lt (by omega : d + 1 < 2 * Fintype.card V') hS' hpig exact Nat.lt_of_le_of_lt hfat₁_sub hstep have hwidth₁ : HasWidthRefut (restrictCNF F' v val) (d + b0) := ih (Fintype.card {u : V' // u ≠ v} + b0) (by omega) {u : V' // u ≠ v} (restrictCNF F' v val) π₁ b0 rfl (restrictCNF_width hF' v val) hπ₁ (Or.inr hlt₁) have hlifted := lift_refut_add_lit hwidth₁ -- Branch 2: restrict `(v, !val)` -> `card V'` drops by 1 while `b' = b0 + 1` stays the same! rcases restrict_refut_fatCount hπ' v (!val) d with ⟨π₂, hπ₂, hfat₂⟩ have hfat₂_le : fatCount π₂ d ≤ fatCount π' d := by refine Nat.le_trans hfat₂ ?_ have hgen : ∀ (L : List (Clause V')) (p q : Clause V' → Bool), (L.filter fun C => p C && q C).length ≤ (L.filter p).length := by intro L p q induction L with | nil => simp | cons C L ihL => cases hp : p C <;> cases hq : q C <;> simp [hp, hq] <;> omega have h1 : (π'.filter fun C => decide (d < width C ∧ C v ≠ some (!val))) = (π'.filter fun C => decide (d < width C) && decide (C v ≠ some (!val))) := List.filter_congr fun C _ => by simp rw [h1] exact hgen π' (fun C => decide (d < width C)) (fun C => decide (C v ≠ some (!val))) have hcond₂ : Fintype.card {u : V' // u ≠ v} ≤ d + (b0 + 1) ∨ fatCount π₂ d < bswThresh (Fintype.card {u : V' // u ≠ v}) d (b0 + 1) := by by_cases hsmall : Fintype.card {u : V' // u ≠ v} ≤ d + (b0 + 1) · exact Or.inl hsmall · right have hgt₂ : d + (b0 + 1) < Fintype.card {u : V' // u ≠ v} := Nat.lt_of_not_ge hsmall have hmono : bswThresh (Fintype.card V') d (b0 + 1) ≤ bswThresh (Fintype.card {u : V' // u ≠ v}) d (b0 + 1) := by have heq : Fintype.card V' = Fintype.card {u : V' // u ≠ v} + 1 := by omega rw [heq] exact bswThresh_antitone_n hgt₂ exact Nat.lt_of_le_of_lt hfat₂_le (Nat.lt_of_lt_of_le hS' hmono) have hwidth₂ : HasWidthRefut (restrictCNF F' v (!val)) (d + (b0 + 1)) := ih (Fintype.card {u : V' // u ≠ v} + (b0 + 1)) (by omega) {u : V' // u ≠ v} (restrictCNF F' v (!val)) π₂ (b0 + 1) rfl (restrictCNF_width hF' v (!val)) hπ₂ hcond₂ have hF_W : ∀ C ∈ F', width C ≤ d + (b0 + 1) := fun C hC => Nat.le_trans (hF' C hC) (by omega) exact combine_unit_and_restricted_refut hF_W (by simpa [Nat.add_assoc] using hlifted) hwidth₂ /-- **Headline Theorem 1B (Linear Non-Asymptotic Ceiling Boost):** For all `d + b < n`, `b + 1 ≤ bswThresh n d b`. Consequently, every Resolution refutation of a `k`-CNF requiring width `> k + b - 1` has at least `b + 1` clauses of width `≥ k`, regardless of how large `n` is. -/ theorem bsw_linear_ceiling_boost {n d b : ℕ} (h : d + b < n) : b + 1 ≤ bswThresh n d b := by induction b generalizing n with | zero => simp [bswThresh] | succ b ih => unfold bswThresh have hn : ¬ 2 * n ≤ d + 1 := by omega rw [if_neg hn] set q := 2 * n - (d + 1) set M := bswThresh (n - 1) d b have hq : 0 < q := by omega have hM : b + 1 ≤ M := ih (by omega) -- Since `d + 1 ≥ 1`, `2 * n * M = q * M + (d + 1) * M ≥ q * M + 1`, so `⌈2nM / q⌉ ≥ M + 1`. have hstep : M + 1 ≤ (2 * n * M + q - 1) / q := by rw [Nat.le_div_iff_mul_le hq] have h2n : 2 * n = q + (d + 1) := by omega have hMpos : 1 ≤ M := by omega have hmul : 2 * n * M = q * M + (d + 1) * M := by rw [h2n, Nat.add_mul] have hdm : 1 ≤ (d + 1) * M := Nat.mul_pos (by omega) hMpos have hmq : (M + 1) * q = q * M + q := by ring omega omega /-- **Headline Theorem 1C (Exact Shrinking-Variable Falling-Product Lower Bound):** For all `d + b < n`, `bswThresh n d b` dominates the exact shrinking-variable rational product `∏_{j=0}^{b-1} 2(n - j) / (2(n - j) - (d + 1))`. -/ theorem bsw_falling_product_lb {n d b : ℕ} (h : d + b < n) : (∏ j ∈ Finset.range b, (2 * ((n - j : ℕ) : ℝ)) / (2 * ((n - j : ℕ) : ℝ) - ((d + 1 : ℕ) : ℝ))) ≤ (bswThresh n d b : ℝ) := by induction b generalizing n with | zero => simp [bswThresh] | succ b ih => rw [Finset.prod_range_succ'] simp only [Nat.sub_zero] have hq_nat : d + 1 < 2 * n := by omega have hq_pos : (0 : ℝ) < 2 * (n : ℝ) - ((d + 1 : ℕ) : ℝ) := by have : ((d + 1 : ℕ) : ℝ) < (2 * n : ℝ) := by exact_mod_cast hq_nat linarith have hprev := ih (n := n - 1) (by omega) have hshift : ∏ j ∈ Finset.range b, (2 * ((n - (j + 1) : ℕ) : ℝ)) / (2 * ((n - (j + 1) : ℕ) : ℝ) - ((d + 1 : ℕ) : ℝ)) = ∏ j ∈ Finset.range b, (2 * (((n - 1) - j : ℕ) : ℝ)) / (2 * (((n - 1) - j : ℕ) : ℝ) - ((d + 1 : ℕ) : ℝ)) := by apply Finset.prod_congr rfl intro j _ rw [Nat.sub_sub, Nat.add_comm 1 j] rw [hshift] have hfac_nonneg : (0 : ℝ) ≤ (2 * (n : ℝ)) / (2 * (n : ℝ) - ((d + 1 : ℕ) : ℝ)) := div_nonneg (by positivity) (le_of_lt hq_pos) have hmul : (∏ j ∈ Finset.range b, (2 * (((n - 1) - j : ℕ) : ℝ)) / (2 * (((n - 1) - j : ℕ) : ℝ) - ((d + 1 : ℕ) : ℝ))) * ((2 * (n : ℝ)) / (2 * (n : ℝ) - ((d + 1 : ℕ) : ℝ))) ≤ (bswThresh (n - 1) d b : ℝ) * ((2 * (n : ℝ)) / (2 * (n : ℝ) - ((d + 1 : ℕ) : ℝ))) := mul_le_mul_of_nonneg_right hprev hfac_nonneg refine le_trans hmul ?_ set q := 2 * n - (d + 1) set M := bswThresh (n - 1) d b have hstep_eq : bswThresh n d (b + 1) = (2 * n * M + q - 1) / q := by rw [bswThresh, if_neg (by omega : ¬ 2 * n ≤ d + 1)] rw [hstep_eq] have hq_eq : (q : ℝ) = 2 * (n : ℝ) - ((d + 1 : ℕ) : ℝ) := by rw [Nat.cast_sub (by omega : d + 1 ≤ 2 * n)] push_cast; ring have hceil_nat : 2 * n * M ≤ ((2 * n * M + q - 1) / q) * q := by have hqpos : 0 < q := by omega have hdiv := Nat.div_add_mod (2 * n * M + q - 1) q have hmod := Nat.mod_lt (2 * n * M + q - 1) hqpos rw [Nat.mul_comm q] at hdiv omega have hceil_real : (2 * (n : ℝ)) * (M : ℝ) ≤ (((2 * n * M + q - 1) / q : ℕ) : ℝ) * (q : ℝ) := by exact_mod_cast hceil_nat rw [← hq_eq, mul_div_assoc', div_le_iff₀ (by exact_mod_cast (by omega : 0 < q))] linarith /-- **Headline Theorem 1D (Shrinking-Variable Exponential Lower Bound):** For all `b ≥ 1` and `d + b < n`: `Real.exp ((b * (d + 1) : ℝ) / (2 * n - b + 1)) ≤ (bswThresh n d b : ℝ)`. -/ theorem bsw_exp_lower_bound {n d b : ℕ} (hb : 1 ≤ b) (h : d + b < n) : Real.exp (((b : ℝ) * ((d + 1 : ℕ) : ℝ)) / (2 * (n : ℝ) - (b : ℝ) + 1)) ≤ (bswThresh n d b : ℝ) := by refine le_trans ?_ (bsw_falling_product_lb h) -- Step 1: For each `j < b`, `exp((d+1) / (2(n-j))) ≤ 2(n-j) / (2(n-j) - (d+1))`. have hterm : ∀ j ∈ Finset.range b, Real.exp (((d + 1 : ℕ) : ℝ) / (2 * ((n - j : ℕ) : ℝ))) ≤ (2 * ((n - j : ℕ) : ℝ)) / (2 * ((n - j : ℕ) : ℝ) - ((d + 1 : ℕ) : ℝ)) := by intro j hj have hjlt : j < b := Finset.mem_range.mp hj set A : ℝ := 2 * ((n - j : ℕ) : ℝ) set D : ℝ := ((d + 1 : ℕ) : ℝ) have hApos : 0 < A := by have : 0 < n - j := by omega positivity have hAD : D < A := by have hnat : d + 1 < 2 * (n - j) := by omega have hcast : ((d + 1 : ℕ) : ℝ) < ((2 * (n - j) : ℕ) : ℝ) := Nat.cast_lt.mpr hnat simpa [D, A] using hcast -- Use `1 - D/A ≤ exp(-D/A)`, i.e. `exp(D/A) * (1 - D/A) ≤ 1`. have h1 : 1 - D / A ≤ Real.exp (-(D / A)) := by have := Real.add_one_le_exp (-(D / A)) linarith have h1' : (A - D) / A ≤ Real.exp (-(D / A)) := by have : (A - D) / A = 1 - D / A := by field_simp rwa [this] have hmul : Real.exp (D / A) * ((A - D) / A) ≤ 1 := by calc Real.exp (D / A) * ((A - D) / A) ≤ Real.exp (D / A) * Real.exp (-(D / A)) := mul_le_mul_of_nonneg_left h1' (le_of_lt (Real.exp_pos _)) _ = 1 := by rw [← Real.exp_add, add_neg_cancel, Real.exp_zero] rw [le_div_iff₀ (by linarith : 0 < A - D)] have h2 : Real.exp (D / A) * (A - D) / A ≤ 1 := by simpa [mul_div_assoc] using hmul rwa [div_le_one hApos] at h2 -- Step 2: Product of exponentials = exp of sum. have hprod : Real.exp (∑ j ∈ Finset.range b, ((d + 1 : ℕ) : ℝ) / (2 * ((n - j : ℕ) : ℝ))) ≤ ∏ j ∈ Finset.range b, (2 * ((n - j : ℕ) : ℝ)) / (2 * ((n - j : ℕ) : ℝ) - ((d + 1 : ℕ) : ℝ)) := by rw [Real.exp_sum] exact Finset.prod_le_prod (fun _ _ => le_of_lt (Real.exp_pos _)) hterm refine le_trans ?_ hprod apply Real.exp_le_exp.mpr -- Step 3: Cauchy-Schwarz: `b^2 ≤ (∑ 1/a_j) * (∑ a_j)` with `a_j = 2(n - j)`. have hsum_a : ∑ j ∈ Finset.range b, (2 * ((n - j : ℕ) : ℝ)) = (b : ℝ) * (2 * (n : ℝ) - (b : ℝ) + 1) := by have hinner : ∑ j ∈ Finset.range b, ((n - j : ℕ) : ℝ) = (b : ℝ) * (n : ℝ) - (b : ℝ) * ((b : ℝ) - 1) / 2 := by have hcast : ∑ j ∈ Finset.range b, ((n - j : ℕ) : ℝ) = ∑ j ∈ Finset.range b, ((n : ℝ) - (j : ℝ)) := by apply Finset.sum_congr rfl intro j hj have : j ≤ n := by have := Finset.mem_range.mp hj; omega rw [Nat.cast_sub this] rw [hcast, Finset.sum_sub_distrib, Finset.sum_const, Finset.card_range, nsmul_eq_mul] have hrange : (∑ j ∈ Finset.range b, (j : ℝ)) = (b : ℝ) * ((b : ℝ) - 1) / 2 := by have hnat := Finset.sum_range_id b have h2 : 2 * ∑ j ∈ Finset.range b, j = b * (b - 1) := by rw [hnat, Nat.mul_div_cancel' (Nat.even_mul_pred_self b).two_dvd] have h2r : (2 : ℝ) * ∑ j ∈ Finset.range b, (j : ℝ) = (b : ℝ) * ((b : ℝ) - 1) := by have : (2 : ℝ) * (∑ j ∈ Finset.range b, (j : ℝ)) = ((2 * ∑ j ∈ Finset.range b, j : ℕ) : ℝ) := by push_cast; rfl rw [this, h2, Nat.cast_mul, Nat.cast_sub hb] simp linarith rw [hrange] rw [← Finset.mul_sum, hinner] ring have hcs : ((b : ℝ)) ^ 2 ≤ (∑ j ∈ Finset.range b, (1 : ℝ) / (2 * ((n - j : ℕ) : ℝ))) * (∑ j ∈ Finset.range b, (2 * ((n - j : ℕ) : ℝ))) := by have h := Finset.sum_mul_sq_le_sq_mul_sq (Finset.range b) (fun j => Real.sqrt ((1 : ℝ) / (2 * ((n - j : ℕ) : ℝ)))) (fun j => Real.sqrt (2 * ((n - j : ℕ) : ℝ))) have hlhs : ∑ j ∈ Finset.range b, Real.sqrt ((1 : ℝ) / (2 * ((n - j : ℕ) : ℝ))) * Real.sqrt (2 * ((n - j : ℕ) : ℝ)) = (b : ℝ) := by have : ∀ j ∈ Finset.range b, Real.sqrt ((1 : ℝ) / (2 * ((n - j : ℕ) : ℝ))) * Real.sqrt (2 * ((n - j : ℕ) : ℝ)) = 1 := by intro j hj have hpos : (0 : ℝ) < 2 * ((n - j : ℕ) : ℝ) := by have : 0 < n - j := by have := Finset.mem_range.mp hj; omega positivity rw [← Real.sqrt_mul (by positivity), one_div_mul_cancel (ne_of_gt hpos), Real.sqrt_one] rw [Finset.sum_congr rfl this, Finset.sum_const, Finset.card_range] simp have hr1 : ∑ j ∈ Finset.range b, (Real.sqrt ((1 : ℝ) / (2 * ((n - j : ℕ) : ℝ)))) ^ 2 = ∑ j ∈ Finset.range b, (1 : ℝ) / (2 * ((n - j : ℕ) : ℝ)) := by apply Finset.sum_congr rfl; intro j _ exact Real.sq_sqrt (by positivity) have hr2 : ∑ j ∈ Finset.range b, (Real.sqrt (2 * ((n - j : ℕ) : ℝ))) ^ 2 = ∑ j ∈ Finset.range b, (2 * ((n - j : ℕ) : ℝ)) := by apply Finset.sum_congr rfl; intro j _ exact Real.sq_sqrt (by positivity) rw [hlhs, hr1, hr2] at h exact h have hden_pos : (0 : ℝ) < 2 * (n : ℝ) - (b : ℝ) + 1 := by have : (b : ℝ) < (n : ℝ) := by exact_mod_cast (by omega : b < n) linarith have hb_pos : (0 : ℝ) < (b : ℝ) := by exact_mod_cast (by omega : 0 < b) rw [hsum_a] at hcs have hinv : (b : ℝ) / (2 * (n : ℝ) - (b : ℝ) + 1) ≤ ∑ j ∈ Finset.range b, (1 : ℝ) / (2 * ((n - j : ℕ) : ℝ)) := by rw [div_le_iff₀ hden_pos] have : (b : ℝ) * (b : ℝ) ≤ (∑ j ∈ Finset.range b, (1 : ℝ) / (2 * ((n - j : ℕ) : ℝ))) * (2 * (n : ℝ) - (b : ℝ) + 1) * (b : ℝ) := by nlinarith exact le_of_mul_le_mul_right this hb_pos have hpull : ∑ j ∈ Finset.range b, ((d + 1 : ℕ) : ℝ) / (2 * ((n - j : ℕ) : ℝ)) = ((d + 1 : ℕ) : ℝ) * ∑ j ∈ Finset.range b, (1 : ℝ) / (2 * ((n - j : ℕ) : ℝ)) := by rw [Finset.mul_sum] apply Finset.sum_congr rfl; intro j _; ring rw [hpull] calc ((b : ℝ) * ((d + 1 : ℕ) : ℝ)) / (2 * (n : ℝ) - (b : ℝ) + 1) = ((d + 1 : ℕ) : ℝ) * ((b : ℝ) / (2 * (n : ℝ) - (b : ℝ) + 1)) := by ring _ ≤ ((d + 1 : ℕ) : ℝ) * ∑ j ∈ Finset.range b, (1 : ℝ) / (2 * ((n - j : ℕ) : ℝ)) := mul_le_mul_of_nonneg_left hinv (by positivity) /-- **Headline Theorem 1E (No-`(-k)`-Penalty Sharp High-Width BSW Exponential Bound):** If `F` is a `k`-CNF on `n = |V|` variables with minimum Resolution refutation width `≥ W` where `2 * k ≤ W ≤ n` (and `W ≥ 2`), then EVERY DAG Resolution refutation `π` of `F` has size `S(π) ≥ exp((W^2 - 1) / (8n - 2W + 4))`, completely eliminating the `-k` penalty of Ben-Sasson–Wigderson (2001) and shrinking the denominator from `8n` to `8n - 2W + 4`. -/ theorem bsw_sharp_high_width_exp [Fintype V] [DecidableEq V] {F : Set (Clause V)} {π : List (Clause V)} {k W : ℕ} (hF : ∀ C ∈ F, width C ≤ k) (hW_lo : 2 * k ≤ W) (hW2 : 2 ≤ W) (hW_hi : W ≤ Fintype.card V) (hno : ¬ HasWidthRefut F (W - 1)) (hπ : IsResRefut F π) : Real.exp (((W : ℝ) ^ 2 - 1) / (8 * (Fintype.card V : ℝ) - 2 * (W : ℝ) + 4)) ≤ (π.length : ℝ) := by set d := W / 2 - 1 set b := (W + 1) / 2 have hdb : d + b = W - 1 := by omega have hdk : k ≤ d + 1 := by omega have hb1 : 1 ≤ b := by omega have hlt_n : d + b < Fintype.card V := by omega have hfat_ge : bswThresh (Fintype.card V) d b ≤ fatCount π d := by by_contra hlt push Not at hlt have hw := bsw_exact_recurrence_tradeoff (fun C hC => Nat.le_trans (hF C hC) hdk) hπ hlt rw [hdb] at hw exact hno hw have hlen : (bswThresh (Fintype.card V) d b : ℝ) ≤ (π.length : ℝ) := by exact_mod_cast Nat.le_trans hfat_ge (fatCount_le_length π d) refine le_trans ?_ (le_trans (bsw_exp_lower_bound hb1 hlt_n) hlen) apply Real.exp_le_exp.mpr -- Compare `(W^2 - 1) / (8n - 2W + 4)` vs `b * (d + 1) / (2n - b + 1)`. have hnum_nat : W * W - 1 ≤ 4 * (b * (d + 1)) := by have hbd : d + 1 = W / 2 := by omega rw [hbd] rcases Nat.even_or_odd W with ⟨m, hm⟩ | ⟨m, hm⟩ · have h1 : W / 2 = m := by omega have h2 : b = m := by omega rw [h1, h2, hm] have : (m + m) * (m + m) - 1 ≤ (m + m) * (m + m) := Nat.sub_le _ _ nlinarith · have h1 : W / 2 = m := by omega have h2 : b = m + 1 := by omega rw [h1, h2, hm] have hprod : (2 * m + 1) * (2 * m + 1) = 4 * ((m + 1) * m) + 1 := by ring omega have hnum_real : (W : ℝ) ^ 2 - 1 ≤ 4 * ((b : ℝ) * ((d + 1 : ℕ) : ℝ)) := by have h1 : 1 ≤ W * W := by nlinarith have hcast : ((W * W - 1 : ℕ) : ℝ) ≤ ((4 * (b * (d + 1)) : ℕ) : ℝ) := Nat.cast_le.mpr hnum_nat rw [Nat.cast_sub h1] at hcast simp only [Nat.cast_mul, Nat.cast_ofNat, Nat.cast_one] at hcast nlinarith have hden1 : (0 : ℝ) < 2 * (Fintype.card V : ℝ) - (b : ℝ) + 1 := by have : (b : ℝ) < (Fintype.card V : ℝ) := by exact_mod_cast (by omega : b < Fintype.card V) linarith have hden2 : (0 : ℝ) < 8 * (Fintype.card V : ℝ) - 2 * (W : ℝ) + 4 := by have : (W : ℝ) ≤ (Fintype.card V : ℝ) := by exact_mod_cast hW_hi linarith have hden_cmp : 4 * (2 * (Fintype.card V : ℝ) - (b : ℝ) + 1) ≤ 8 * (Fintype.card V : ℝ) - 2 * (W : ℝ) + 4 := by have : (W : ℝ) ≤ 2 * (b : ℝ) := by exact_mod_cast (by omega : W ≤ 2 * b) linarith rw [div_le_div_iff₀ hden2 hden1] have hpos_rhs : (0 : ℝ) ≤ (b : ℝ) * ((d + 1 : ℕ) : ℝ) := by positivity nlinarith /-- **Headline Theorem 1F (Sharp Low-Gap Linear-in-`k(W-k)` BSW Exponential Bound):** For any `k`-CNF on `n = |V|` variables with `1 ≤ k < W ≤ n` and minimum Resolution width `≥ W`, EVERY DAG Resolution refutation `π` has size `S(π) ≥ exp(k (W - k) / (2n - (W - k) + 1))`, strictly improving the quadratic `(W - k)^2/(8n)` exponent whenever `W < 2k`. -/ theorem bsw_sharp_low_gap_exp [Fintype V] [DecidableEq V] {F : Set (Clause V)} {π : List (Clause V)} {k W : ℕ} (hF : ∀ C ∈ F, width C ≤ k) (hk : 1 ≤ k) (hkW : k < W) (hW_hi : W ≤ Fintype.card V) (hno : ¬ HasWidthRefut F (W - 1)) (hπ : IsResRefut F π) : Real.exp (((W - k : ℕ) : ℝ) * (k : ℝ) / (2 * (Fintype.card V : ℝ) - ((W - k : ℕ) : ℝ) + 1)) ≤ (π.length : ℝ) := by set d := k - 1 set b := W - k have hdb : d + b = W - 1 := by omega have hdk : d + 1 = k := by omega have hb1 : 1 ≤ b := by omega have hlt_n : d + b < Fintype.card V := by omega have hfat_ge : bswThresh (Fintype.card V) d b ≤ fatCount π d := by by_contra hlt push Not at hlt have hw := bsw_exact_recurrence_tradeoff (fun C hC => by rw [hdk]; exact hF C hC) hπ hlt rw [hdb] at hw exact hno hw have hlen : (bswThresh (Fintype.card V) d b : ℝ) ≤ (π.length : ℝ) := by exact_mod_cast Nat.le_trans hfat_ge (fatCount_le_length π d) have hexp := bsw_exp_lower_bound hb1 hlt_n rw [hdk] at hexp exact le_trans hexp hlen -- ------------------------------------------------------------------------------ -- Tree-like Resolution, Exact Tree-like BSW, and Exact FullCNF_n Sharpness Witness -- ------------------------------------------------------------------------------ /-- Tree-like Resolution derivation of `C` from `F`. -/ inductive TreeRes (F : Set (Clause V)) : Clause V → Type _ | leaf (C : Clause V) (hC : C ∈ F) : TreeRes F C | res {C₁ C₂ C : Clause V} (v : V) (t₁ : TreeRes F C₁) (t₂ : TreeRes F C₂) (hr : Resolves C₁ C₂ v C) : TreeRes F C /-- Leaf count (size) of a tree-like Resolution derivation. -/ def treeLeaves {F : Set (Clause V)} : ∀ {C}, TreeRes F C → ℕ | _, TreeRes.leaf _ _ => 1 | _, TreeRes.res _ t₁ t₂ _ => treeLeaves t₁ + treeLeaves t₂ lemma treeLeaves_pos {F : Set (Clause V)} {C : Clause V} (t : TreeRes F C) : 1 ≤ treeLeaves t := by induction t with | leaf _ _ => exact le_refl 1 | res _ _ _ _ ih1 _ => simp only [treeLeaves]; omega /-- Restricting a tree-like derivation by `(v, val)` produces a tree-like derivation of a subclause of `restrictClause v C` with no more leaves. -/ lemma restrict_treeRes [DecidableEq V] {F : Set (Clause V)} (v : V) (val : Bool) : ∀ {C : Clause V} (t : TreeRes F C), C v ≠ some val → ∃ D, Subclause D (restrictClause v C) ∧ ∃ t' : TreeRes (restrictCNF F v val) D, treeLeaves t' ≤ treeLeaves t := by intro C t induction t with | leaf C hC => intro hne exact ⟨restrictClause v C, fun _ _ h => h, TreeRes.leaf _ ⟨C, hC, hne, rfl⟩, le_refl 1⟩ | @res C₁ C₂ C pv t₁ t₂ hr ih1 ih2 => intro hne by_cases hpv : pv = v · subst hpv cases val with | true => have hne2 : C₂ pv ≠ some true := by rw [hr.2.1]; simp rcases ih2 hne2 with ⟨D₂, hsub2, t₂', hl2⟩ refine ⟨D₂, ?_, t₂', by simp only [treeLeaves]; omega⟩ intro u b hbu have h1 := hsub2 u b hbu simp only [restrictClause] at h1 ⊢ rw [hr.2.2.2.2 u.1 u.2] cases h1u : C₁ u.1 with | none => simp [h1] | some b₁ => have := hr.2.2.1 u.1 u.2 b₁ b h1u h1 subst this; simp | false => have hne1 : C₁ pv ≠ some false := by rw [hr.1]; simp rcases ih1 hne1 with ⟨D₁, hsub1, t₁', hl1⟩ refine ⟨D₁, ?_, t₁', by simp only [treeLeaves]; omega⟩ intro u b hbu have h1 := hsub1 u b hbu simp only [restrictClause] at h1 ⊢ rw [hr.2.2.2.2 u.1 u.2] simp [h1] · have hne1 : C₁ v ≠ some val := by intro heq have := hr.2.2.2.2 v (Ne.symm hpv) rw [heq] at this exact hne (by simpa using this) have hne2 : C₂ v ≠ some val := by intro heq have := hr.2.2.2.2 v (Ne.symm hpv) rw [heq] at this cases h1v : C₁ v with | none => exact hne (by simpa [h1v] using this) | some b₁ => have hb := hr.2.2.1 v (Ne.symm hpv) b₁ val h1v heq subst hb; exact hne (by simpa [h1v] using this) rcases ih1 hne1 with ⟨D₁, hsub1, t₁', hl1⟩ rcases ih2 hne2 with ⟨D₂, hsub2, t₂', hl2⟩ have hres_r : Resolves (restrictClause v C₁) (restrictClause v C₂) ⟨pv, hpv⟩ (restrictClause v C) := by refine ⟨hr.1, hr.2.1, ?_, hr.2.2.2.1, ?_⟩ · intro u huv b₁ b₂ h1 h2 exact hr.2.2.1 u.1 (fun h => huv (Subtype.ext h)) b₁ b₂ h1 h2 · intro u huv exact hr.2.2.2.2 u.1 (fun h => huv (Subtype.ext h)) rcases subclause_resolve_step hres_r hsub1 hsub2 with h1 | h2 | ⟨D, hDr, hDsub⟩ · exact ⟨D₁, h1, t₁', by simp only [treeLeaves]; omega⟩ · exact ⟨D₂, h2, t₂', by simp only [treeLeaves]; omega⟩ · exact ⟨D, hDsub, TreeRes.res ⟨pv, hpv⟩ t₁' t₂' hDr, by simp only [treeLeaves]; omega⟩ /-- **Headline Theorem 1G (Exact Tree-Like Resolution Size–Width Trade-Off):** If `F` is a `k`-CNF admitting a tree-like Resolution refutation with leaf count `L < 2^b` (`b ≥ 1`), then `F` admits a Resolution refutation of width at most `k + b - 1`. Equivalently, every tree-like refutation of a `k`-CNF requiring width `W` has at least `2^(W - k)` leaves. -/ theorem treelike_bsw_exact {V : Type u} [Fintype V] [DecidableEq V] {F : Set (Clause V)} {k b : ℕ} (hF : ∀ C ∈ F, width C ≤ k) (hb : 1 ≤ b) (t : TreeRes F emptyClause) (hL : treeLeaves t < 2 ^ b) : HasWidthRefut F (k + b - 1) := by suffices hmain : ∀ N (V' : Type u) [Fintype V'] [DecidableEq V'] (F' : Set (Clause V')) (b' : ℕ) (t' : TreeRes F' emptyClause), Fintype.card V' + b' = N → (∀ C ∈ F', width C ≤ k) → 1 ≤ b' → treeLeaves t' < 2 ^ b' → HasWidthRefut F' (k + b' - 1) by exact hmain (Fintype.card V + b) V F b t rfl hF hb hL intro N induction N using Nat.strong_induction_on with | h N ih => intro V' _ _ F' b' t' hN hF' hb' hL' cases t' with | leaf _ hmem => refine ⟨[emptyClause], ⟨fun i hi => ?_, by simp⟩, fun C hC => ?_⟩ · have : i = 0 := by simpa using hi subst this; exact Or.inl hmem · simp only [List.mem_singleton] at hC; subst hC; simp [width_empty] | @res C₁ C₂ _ v t₁ t₂ hr => -- Since `C₁, C₂` resolve on `v` to `emptyClause`, `C₁ v = some true`, `C₂ v = some false`, -- and for `u ≠ v`, `C₁ u = none` and `C₂ u = none`! have hC1_empty : restrictClause v C₁ = emptyClause := by funext u have h0 := hr.2.2.2.2 u.1 u.2 simp only [emptyClause] at h0 cases h1 : C₁ u.1 with | none => exact h1 | some b1 => simp [h1] at h0 have hC2_empty : restrictClause v C₂ = emptyClause := by funext u have h0 := hr.2.2.2.2 u.1 u.2 simp only [emptyClause] at h0 cases h2 : C₂ u.1 with | none => exact h2 | some b2 => cases h1 : C₁ u.1 with | none => simp [h1, h2] at h0 | some b1 => simp [h1] at h0 have hcard_sub : Fintype.card {u : V' // u ≠ v} = Fintype.card V' - 1 := by rw [Fintype.card_subtype_compl, Fintype.card_subtype_eq] have hcard_pos : 0 < Fintype.card V' := Fintype.card_pos_iff.mpr ⟨v⟩ -- Since `treeLeaves t₁ + treeLeaves t₂ < 2^b'` and both are `≥ 1`, `b' ≥ 2`. have h1pos := treeLeaves_pos t₁ have h2pos := treeLeaves_pos t₂ have hb2 : 2 ≤ b' := by by_contra hlt have hb1 : b' = 1 := by omega subst hb1 simp only [treeLeaves, pow_one] at hL' omega -- Restrict `t₁` by `(v, false)` and `t₂` by `(v, true)`. rcases restrict_treeRes v false t₁ (by rw [hr.1]; simp) with ⟨D₁, hsub1, t₁', hl1⟩ rcases restrict_treeRes v true t₂ (by rw [hr.2.1]; simp) with ⟨D₂, hsub2, t₂', hl2⟩ have hD1 : D₁ = emptyClause := subclause_empty_iff.mp (hC1_empty ▸ hsub1) have hD2 : D₂ = emptyClause := subclause_empty_iff.mp (hC2_empty ▸ hsub2) subst hD1; subst hD2 -- One of `t₁, t₂` has `< 2^(b' - 1)` leaves! have hpow : 2 ^ b' = 2 ^ (b' - 1) + 2 ^ (b' - 1) := by have : b' = (b' - 1) + 1 := by omega conv_lhs => rw [this, pow_succ] ring by_cases hsmall1 : treeLeaves t₁ < 2 ^ (b' - 1) · have hw1 : HasWidthRefut (restrictCNF F' v false) (k + (b' - 1) - 1) := ih (Fintype.card {u : V' // u ≠ v} + (b' - 1)) (by omega) {u : V' // u ≠ v} (restrictCNF F' v false) (b' - 1) t₁' rfl (restrictCNF_width hF' v false) (by omega) (Nat.lt_of_le_of_lt hl1 hsmall1) have hlifted := lift_refut_add_lit hw1 have hw2 : HasWidthRefut (restrictCNF F' v true) (k + b' - 1) := ih (Fintype.card {u : V' // u ≠ v} + b') (by omega) {u : V' // u ≠ v} (restrictCNF F' v true) b' t₂' rfl (restrictCNF_width hF' v true) hb' (by simp only [treeLeaves] at hL'; omega) have heqW : k + (b' - 1) - 1 + 1 = k + b' - 1 := by omega rw [heqW] at hlifted exact combine_unit_and_restricted_refut (fun C hC => Nat.le_trans (hF' C hC) (by omega)) hlifted (by simpa using hw2) · have hsmall2 : treeLeaves t₂ < 2 ^ (b' - 1) := by simp only [treeLeaves] at hL'; omega have hw2 : HasWidthRefut (restrictCNF F' v true) (k + (b' - 1) - 1) := ih (Fintype.card {u : V' // u ≠ v} + (b' - 1)) (by omega) {u : V' // u ≠ v} (restrictCNF F' v true) (b' - 1) t₂' rfl (restrictCNF_width hF' v true) (by omega) (Nat.lt_of_le_of_lt hl2 hsmall2) have hlifted := lift_refut_add_lit hw2 have hw1 : HasWidthRefut (restrictCNF F' v false) (k + b' - 1) := ih (Fintype.card {u : V' // u ≠ v} + b') (by omega) {u : V' // u ≠ v} (restrictCNF F' v false) b' t₁' rfl (restrictCNF_width hF' v false) hb' (by simp only [treeLeaves] at hL'; omega) have heqW : k + (b' - 1) - 1 + 1 = k + b' - 1 := by omega rw [heqW] at hlifted exact combine_unit_and_restricted_refut (fun C hC => Nat.le_trans (hF' C hC) (by omega)) hlifted (by simpa using hw1) /-- The complete binary clause family `FullCNF n`: all `2^n` full-width clauses on `Fin n`. -/ def FullCNF (n : ℕ) : Set (Clause (Fin n)) := { C | ∀ i : Fin n, (C i).isSome } /-- Every clause derived by a tree-like Resolution proof of `FullCNF n` from a subset of assignments falsifying it forces an exact leaf-count lower bound `2^(n - width C)`. -/ lemma fullCNF_treeLeaves_ge (n : ℕ) : ∀ {C : Clause (Fin n)} (t : TreeRes (FullCNF n) C), 2 ^ (n - width C) ≤ treeLeaves t := by intro C t induction t with | leaf C hC => have hw : width C = n := by have : (Finset.univ.filter fun i : Fin n => (C i).isSome) = Finset.univ := by ext i; simp [hC i] simp [width, this] rw [hw, Nat.sub_self, pow_zero] exact le_refl 1 | @res C₁ C₂ C v t₁ t₂ hr ih1 ih2 => have hw1 : width C₁ ≤ width C + 1 := by have hsub : clauseVars C₁ ⊆ insert v (clauseVars C) := by intro u hu by_cases huv : u = v · subst huv; exact Finset.mem_insert_self _ _ · apply Finset.mem_insert_of_mem simp only [clauseVars, Finset.mem_filter, Finset.mem_univ, true_and] at hu ⊢ rw [hr.2.2.2.2 u huv] cases h1 : C₁ u with | none => simp [h1] at hu | some _ => simp calc width C₁ = (clauseVars C₁).card := rfl _ ≤ (insert v (clauseVars C)).card := Finset.card_le_card hsub _ ≤ (clauseVars C).card + 1 := Finset.card_insert_le _ _ have hw2 : width C₂ ≤ width C + 1 := by have hsub : clauseVars C₂ ⊆ insert v (clauseVars C) := by intro u hu by_cases huv : u = v · subst huv; exact Finset.mem_insert_self _ _ · apply Finset.mem_insert_of_mem simp only [clauseVars, Finset.mem_filter, Finset.mem_univ, true_and] at hu ⊢ rw [hr.2.2.2.2 u huv] cases h2 : C₂ u with | none => simp [h2] at hu | some _ => cases C₁ u <;> simp calc width C₂ = (clauseVars C₂).card := rfl _ ≤ (insert v (clauseVars C)).card := Finset.card_le_card hsub _ ≤ (clauseVars C).card + 1 := Finset.card_insert_le _ _ have hwn : width C < n := by have hnot : v ∉ clauseVars C := by simp [clauseVars, hr.2.2.2.1] have hlt : (clauseVars C).card < (Finset.univ : Finset (Fin n)).card := Finset.card_lt_card ⟨Finset.subset_univ _, fun h => hnot (h (Finset.mem_univ v))⟩ rw [width_eq_card_clauseVars] simpa using hlt have hpow : 2 ^ (n - width C) = 2 ^ (n - (width C + 1)) + 2 ^ (n - (width C + 1)) := by have : n - width C = (n - (width C + 1)) + 1 := by omega rw [this, pow_succ]; ring have hm1 : 2 ^ (n - (width C + 1)) ≤ 2 ^ (n - width C₁) := Nat.pow_le_pow_right (by omega) (by omega) have hm2 : 2 ^ (n - (width C + 1)) ≤ 2 ^ (n - width C₂) := Nat.pow_le_pow_right (by omega) (by omega) simp only [treeLeaves] omega /-- Explicit balanced binary-tree refutation of `FullCNF n` with EXACTLY `2^n` leaves. -/ lemma fullCNF_exact_tree_upper (n : ℕ) : ∀ k ≤ n, ∀ (C : Clause (Fin n)), (∀ i : Fin n, i.1 < k → (C i).isSome) → (∀ i : Fin n, k ≤ i.1 → C i = none) → ∃ t : TreeRes (FullCNF n) C, treeLeaves t = 2 ^ (n - k) := by intro k hk -- Downward induction on `n - k`. suffices h : ∀ r k, k + r = n → ∀ (C : Clause (Fin n)), (∀ i : Fin n, i.1 < k → (C i).isSome) → (∀ i : Fin n, k ≤ i.1 → C i = none) → ∃ t : TreeRes (FullCNF n) C, treeLeaves t = 2 ^ r by exact h (n - k) k (Nat.add_sub_of_le hk) intro r induction r with | zero => intro k hk C hlt _ have hmem : C ∈ FullCNF n := fun i => hlt i (by omega) exact ⟨TreeRes.leaf C hmem, rfl⟩ | succ r ih => intro k hk C hlt hge let v : Fin n := ⟨k, by omega⟩ let C₁ : Clause (Fin n) := Function.update C v (some true) let C₂ : Clause (Fin n) := Function.update C v (some false) have hres : Resolves C₁ C₂ v C := by refine ⟨by simp [C₁], by simp [C₂], ?_, hge v (le_refl k), ?_⟩ · intro u huv b₁ b₂ h1 h2 simp only [C₁, C₂, Function.update_of_ne huv] at h1 h2 rw [h1] at h2; cases h2; rfl · intro u huv simp only [C₁, C₂, Function.update_of_ne huv] cases C u <;> simp have hlt1 : ∀ i : Fin n, i.1 < k + 1 → (C₁ i).isSome := by intro i hi by_cases hiv : i = v · subst hiv; simp [C₁] · simp only [C₁, Function.update_of_ne hiv] exact hlt i (by have : i.1 ≠ k := fun h => hiv (Fin.ext h); omega) have hge1 : ∀ i : Fin n, k + 1 ≤ i.1 → C₁ i = none := by intro i hi have hiv : i ≠ v := fun h => by have := congrArg Fin.val h; simp [v] at this; omega simp only [C₁, Function.update_of_ne hiv] exact hge i (by omega) have hlt2 : ∀ i : Fin n, i.1 < k + 1 → (C₂ i).isSome := by intro i hi by_cases hiv : i = v · subst hiv; simp [C₂] · simp only [C₂, Function.update_of_ne hiv] exact hlt i (by have : i.1 ≠ k := fun h => hiv (Fin.ext h); omega) have hge2 : ∀ i : Fin n, k + 1 ≤ i.1 → C₂ i = none := by intro i hi have hiv : i ≠ v := fun h => by have := congrArg Fin.val h; simp [v] at this; omega simp only [C₂, Function.update_of_ne hiv] exact hge i (by omega) rcases ih (k + 1) (by omega) C₁ hlt1 hge1 with ⟨t₁, hl1⟩ rcases ih (k + 1) (by omega) C₂ hlt2 hge2 with ⟨t₂, hl2⟩ refine ⟨TreeRes.res v t₁ t₂ hres, ?_⟩ simp only [treeLeaves, hl1, hl2, pow_succ] ring /-- **Headline Theorem 1H (`FullCNF_n` Exact Tree-Like & Width Sharpness Witness):** For every `n : ℕ`: 1. Every clause of `FullCNF n` has width `= n`, 2. Every tree-like Resolution refutation of `FullCNF n` has at least `2^n` leaves, 3. There exists an explicit tree-like Resolution refutation of `FullCNF n` with EXACTLY `2^n` leaves, and `FullCNF n` has a width-`n` DAG refutation. -/ theorem fullCNF_exact_invariants (n : ℕ) : (∀ C ∈ FullCNF n, width C = n) ∧ (∀ t : TreeRes (FullCNF n) emptyClause, 2 ^ n ≤ treeLeaves t) ∧ (∃ t : TreeRes (FullCNF n) emptyClause, treeLeaves t = 2 ^ n) := by refine ⟨?_, ?_, ?_⟩ · intro C hC have : (Finset.univ.filter fun i : Fin n => (C i).isSome) = Finset.univ := by ext i; simp [hC i] simp [width, this] · intro t simpa [width_empty] using fullCNF_treeLeaves_ge n t · simpa using fullCNF_exact_tree_upper n 0 (Nat.zero_le n) emptyClause (fun _ h => by omega) (fun _ _ => rfl) end Pillar1 -- ============================================================================== -- SECTION 2 (PILLAR 2): TSEITIN RESOLUTION WIDTH/SIZE & FPHP WIDTH / 2^n + n TREE-LIKE SIZE -- ============================================================================== section Pillar2 -- ------------------------------------------------------------------------------ -- 2A. Tseitin Formulas on Arbitrary Connected Finite Simple Graphs -- ------------------------------------------------------------------------------ section TseitinRes variable {V : Type*} [Fintype V] [DecidableEq V] /-- Finite edge type of a simple graph `G` with decidable adjacency. -/ abbrev GEdge (G : SimpleGraph V) [DecidableRel G.Adj] := { e : Sym2 V // e ∈ G.edgeFinset } /-- Star of a vertex `v`: set of edges incident to `v`. -/ def vStar (G : SimpleGraph V) [DecidableRel G.Adj] (v : V) : Finset (GEdge G) := Finset.univ.filter fun e => v ∈ e.1 /-- Edge cut `∂_E(S)`: edges with exactly one endpoint in `S`. -/ def edgeCut (G : SimpleGraph V) [DecidableRel G.Adj] (S : Finset V) : Finset (GEdge G) := Finset.univ.filter fun e => ∃ u w, e.1 = s(u, w) ∧ ((u ∈ S ∧ w ∉ S) ∨ (u ∉ S ∧ w ∈ S)) /-- `ZMod 2`-parity of an edge assignment `α : GEdge G → Bool` at vertex `v`. -/ def vertexParity (G : SimpleGraph V) [DecidableRel G.Adj] (α : GEdge G → Bool) (v : V) : ZMod 2 := ∑ e ∈ vStar G v, if α e then (1 : ZMod 2) else 0 /-- Parity constraint at vertex `v` under charge `χ : V → ZMod 2`. -/ def satTseitinVertex (G : SimpleGraph V) [DecidableRel G.Adj] (χ : V → ZMod 2) (v : V) (α : GEdge G → Bool) : Prop := vertexParity G α v = χ v /-- Handshaking Lemma in `ZMod 2`: every edge has 2 distinct endpoints, so the sum of vertex parities over all vertices is `0`. -/ lemma sum_vertexParity_eq_zero (G : SimpleGraph V) [DecidableRel G.Adj] (α : GEdge G → Bool) : ∑ v : V, vertexParity G α v = 0 := by classical unfold vertexParity vStar simp_rw [Finset.sum_filter] rw [Finset.sum_comm] apply Finset.sum_eq_zero intro e _ rcases e with ⟨e_raw, he_mem⟩ have hnotdiag : ¬ e_raw.IsDiag := G.not_isDiag_of_mem_edgeFinset he_mem induction e_raw using Sym2.ind with | _ u w => have huw : u ≠ w := by intro heq; subst heq; exact hnotdiag (Sym2.mk_isDiag_iff.mpr rfl) have hfilter : (Finset.univ.filter fun v : V => v ∈ s(u, w)) = {u, w} := by ext v; simp [Sym2.mem_iff] rw [← Finset.sum_filter, hfilter, Finset.sum_pair huw] cases α ⟨s(u, w), he_mem⟩ <;> decide /-- Tseitin CNF at a single vertex `v`: all clauses over `vStar G v` forbidding parity-violating assignments on the incident edges of `v`. -/ def tseitinVertexCNF (G : SimpleGraph V) [DecidableRel G.Adj] (χ : V → ZMod 2) (v : V) : Set (Clause (GEdge G)) := { C | (∀ e, (C e).isSome ↔ e ∈ vStar G v) ∧ (∑ e ∈ vStar G v, if C e = some false then (1 : ZMod 2) else 0) ≠ χ v } /-- Tseitin CNF restricted to a subset `S ⊆ V` of vertices. -/ def TseitinSubsetCNF (G : SimpleGraph V) [DecidableRel G.Adj] (χ : V → ZMod 2) (S : Finset V) : Set (Clause (GEdge G)) := { C | ∃ v ∈ S, C ∈ tseitinVertexCNF G χ v } /-- Full Tseitin CNF `Tseitin(G, χ)`. -/ def TseitinCNF (G : SimpleGraph V) [DecidableRel G.Adj] (χ : V → ZMod 2) : Set (Clause (GEdge G)) := TseitinSubsetCNF G χ Finset.univ lemma evalCNF_tseitinVertex_iff (G : SimpleGraph V) [DecidableRel G.Adj] (χ : V → ZMod 2) (v : V) (α : GEdge G → Bool) : evalCNF (tseitinVertexCNF G χ v) α ↔ satTseitinVertex G χ v α := by classical constructor · intro heval by_contra hne -- Construct the clause `C` falsified by `α` on `vStar G v`. let C : Clause (GEdge G) := fun e => if e ∈ vStar G v then some (!α e) else none have hC_mem : C ∈ tseitinVertexCNF G χ v := by refine ⟨fun e => by by_cases h : e ∈ vStar G v <;> simp [C, h], ?_⟩ have hsum : (∑ e ∈ vStar G v, if C e = some false then (1 : ZMod 2) else 0) = vertexParity G α v := by unfold vertexParity apply Finset.sum_congr rfl intro e he simp only [C, he, ↓reduceIte] cases α e <;> simp rw [hsum]; exact hne rcases heval C hC_mem with ⟨e, b, hCe, hae⟩ by_cases he : e ∈ vStar G v · simp only [C, he, ↓reduceIte, Option.some.injEq] at hCe rw [← hCe] at hae cases ha : α e <;> simp [ha] at hae · simp [C, he] at hCe · intro hsat C ⟨hsupp, hbad⟩ by_contra hnot -- If `C` is falsified by `α`, then on every `e ∈ vStar G v`, `C e = some (!α e)`. have hsum : (∑ e ∈ vStar G v, if C e = some false then (1 : ZMod 2) else 0) = vertexParity G α v := by unfold vertexParity apply Finset.sum_congr rfl intro e he have hsome : (C e).isSome := (hsupp e).mpr he cases hCe : C e with | none => simp [hCe] at hsome | some b => have hne_ab : α e ≠ b := fun heq => hnot ⟨e, b, hCe, heq⟩ cases hb : b <;> cases ha : α e <;> simp_all rw [hsum] at hbad exact hbad hsat lemma evalCNF_tseitinSubset_iff (G : SimpleGraph V) [DecidableRel G.Adj] (χ : V → ZMod 2) (S : Finset V) (α : GEdge G → Bool) : evalCNF (TseitinSubsetCNF G χ S) α ↔ ∀ v ∈ S, satTseitinVertex G χ v α := by constructor · intro h v hv exact (evalCNF_tseitinVertex_iff G χ v α).mp fun C hC => h C ⟨v, hv, hC⟩ · intro h C ⟨v, hv, hC⟩ exact (evalCNF_tseitinVertex_iff G χ v α).mpr (h v hv) C hC lemma tseitinCNF_width (G : SimpleGraph V) [DecidableRel G.Adj] (χ : V → ZMod 2) {Δ : ℕ} (hΔ : ∀ v : V, (vStar G v).card ≤ Δ) : ∀ C ∈ TseitinCNF G χ, width C ≤ Δ := by rintro C ⟨v, _, hsupp, _⟩ have heq : (Finset.univ.filter fun e : GEdge G => (C e).isSome) = vStar G v := by ext e; simp [hsupp e] rw [width, heq] exact hΔ v /-- **Headline Theorem 2A (Tseitin Unsatisfiability):** For every graph `G` and charge `χ` with odd total charge `∑ v, χ v = 1`, `TseitinCNF G χ` is unsatisfiable. -/ theorem tseitin_unsat (G : SimpleGraph V) [DecidableRel G.Adj] (χ : V → ZMod 2) (hodd : ∑ v : V, χ v = 1) : ¬ ∃ α, evalCNF (TseitinCNF G χ) α := by rintro ⟨α, hα⟩ have hsat := (evalCNF_tseitinSubset_iff G χ Finset.univ α).mp hα have hsum : ∑ v : V, vertexParity G α v = ∑ v : V, χ v := Finset.sum_congr rfl fun v _ => hsat v (Finset.mem_univ v) rw [sum_vertexParity_eq_zero, hodd] at hsum exact zero_ne_one hsum /-- Flipping a single edge `e = s(u, w)` flips `vertexParity` at `u` and `w` only. -/ lemma vertexParity_flip_edge (G : SimpleGraph V) [DecidableRel G.Adj] (α : GEdge G → Bool) (e : GEdge G) (v : V) : vertexParity G (Function.update α e (!α e)) v = vertexParity G α v + if v ∈ e.1 then (1 : ZMod 2) else 0 := by classical unfold vertexParity by_cases hve : v ∈ e.1 · have he_mem : e ∈ vStar G v := by simp [vStar, hve] rw [← Finset.add_sum_erase _ _ he_mem, ← Finset.add_sum_erase _ _ he_mem] have hrest : ∑ e' ∈ (vStar G v).erase e, (if Function.update α e (!α e) e' then (1 : ZMod 2) else 0) = ∑ e' ∈ (vStar G v).erase e, (if α e' then (1 : ZMod 2) else 0) := by apply Finset.sum_congr rfl intro e' he' rw [Function.update_of_ne (Finset.ne_of_mem_erase he')] rw [hrest, Function.update_self, if_pos hve] cases α e with | false => simp [add_comm] | true => simp only [Bool.not_true, Bool.false_eq_true, ↓reduceIte, zero_add] have h2 : (1 : ZMod 2) + 1 = 0 := by decide calc ∑ x ∈ (vStar G v).erase e, (if α x = true then (1 : ZMod 2) else 0) = (∑ x ∈ (vStar G v).erase e, (if α x = true then (1 : ZMod 2) else 0)) + (1 + 1) := by rw [h2, add_zero] _ = (1 + ∑ x ∈ (vStar G v).erase e, (if α x = true then (1 : ZMod 2) else 0)) + 1 := by ring · rw [if_neg hve, add_zero] apply Finset.sum_congr rfl intro e' he' have hne : e' ≠ e := by rintro rfl simp [vStar, hve] at he' rw [Function.update_of_ne hne] /-- Flipping all edges along a walk from `u` to `r` in `G` flips vertex parity at `u` and `r` (if `u ≠ r`) and leaves every other vertex's parity unchanged. -/ lemma zmod2_ne_add_one {a b : ZMod 2} (h : a ≠ b) : a + 1 = b := by fin_cases a <;> fin_cases b <;> first | rfl | exact absurd rfl h lemma exists_assignment_flip_pair (G : SimpleGraph V) [DecidableRel G.Adj] (u r : V) (hr : G.Reachable u r) (α : GEdge G → Bool) : ∃ α' : GEdge G → Bool, ∀ v : V, vertexParity G α' v = vertexParity G α v + (if v = u then (1 : ZMod 2) else 0) + (if v = r then (1 : ZMod 2) else 0) := by classical rcases hr with ⟨p⟩ induction p with | @nil a => refine ⟨α, fun v => ?_⟩ by_cases h : v = a · subst h simp only [↓reduceIte] have h2 : (1 : ZMod 2) + 1 = 0 := by decide rw [add_assoc, h2, add_zero] · simp [h] | @cons a b c hab p ih => rcases ih with ⟨α1, hα1⟩ let e : GEdge G := ⟨s(a, b), G.mem_edgeFinset.mpr hab⟩ refine ⟨Function.update α1 e (!α1 e), fun v => ?_⟩ rw [vertexParity_flip_edge, hα1 v] have hab_ne : a ≠ b := G.ne_of_adj hab have hmem : (v ∈ e.1) ↔ (v = a ∨ v = b) := by simp [e, Sym2.mem_iff] have h2 : (1 : ZMod 2) + 1 = 0 := by decide by_cases hva : v = a · have hvb : v ≠ b := hva ▸ hab_ne have hv_in : v ∈ e.1 := hmem.mpr (Or.inl hva) rw [if_pos hv_in, if_pos hva, if_neg hvb] ring · by_cases hvb : v = b · have hv_in : v ∈ e.1 := hmem.mpr (Or.inr hvb) rw [if_pos hv_in, if_neg hva, if_pos hvb] calc vertexParity G α v + 1 + (if v = c then (1 : ZMod 2) else 0) + 1 = vertexParity G α v + (1 + 1) + (if v = c then (1 : ZMod 2) else 0) := by ring _ = vertexParity G α v + 0 + (if v = c then (1 : ZMod 2) else 0) := by rw [h2] · have hv_out : v ∉ e.1 := by rw [hmem]; tauto rw [if_neg hv_out, if_neg hva, if_neg hvb] ring /-- **Headline Theorem 2B (Proper-Subset Satisfiability of Tseitin on Connected Graphs):** If `G` is connected, then for EVERY proper subset `S ⊂ V` (`∃ r ∉ S`), `TseitinSubsetCNF G χ S` is satisfiable. -/ theorem tseitin_proper_subset_sat (G : SimpleGraph V) [DecidableRel G.Adj] (hconn : G.Connected) (χ : V → ZMod 2) {S : Finset V} {r : V} (hr : r ∉ S) : ∃ α : GEdge G → Bool, evalCNF (TseitinSubsetCNF G χ S) α := by classical suffices h : ∃ α : GEdge G → Bool, ∀ v ∈ S, vertexParity G α v = χ v by rcases h with ⟨α, hα⟩ exact ⟨α, (evalCNF_tseitinSubset_iff G χ S α).mpr hα⟩ induction S using Finset.induction with | empty => exact ⟨fun _ => false, fun _ h => by simp at h⟩ | @insert u S' hu ih => have hr' : r ∉ S' := fun h => hr (Finset.mem_insert_of_mem h) have hur : u ≠ r := fun h => hr (h ▸ Finset.mem_insert_self u S') rcases ih hr' with ⟨α, hα⟩ by_cases hsat_u : vertexParity G α u = χ u · refine ⟨α, fun v hv => ?_⟩ rcases Finset.mem_insert.mp hv with rfl | hv' · exact hsat_u · exact hα v hv' · rcases exists_assignment_flip_pair G u r (hconn u r) α with ⟨α', hα'⟩ refine ⟨α', fun v hv => ?_⟩ rcases Finset.mem_insert.mp hv with rfl | hv' · rw [hα' v, if_pos rfl, if_neg hur, add_zero] exact zmod2_ne_add_one hsat_u · have hvu : v ≠ u := fun h => hu (h ▸ hv') have hvr : v ≠ r := fun h => hr' (h ▸ hv') rw [hα' v, if_neg hvu, if_neg hvr, add_zero, add_zero] exact hα v hv' /-- BSW complexity measure for Tseitin clauses: minimum `|S|` such that `Tseitin_S ⊨ C`. -/ noncomputable def tseitinMu (G : SimpleGraph V) [DecidableRel G.Adj] (χ : V → ZMod 2) (C : Clause (GEdge G)) : ℕ := sInf { m : ℕ | ∃ S : Finset V, S.card = m ∧ Entails (TseitinSubsetCNF G χ S) C } lemma tseitinMu_exists_min (G : SimpleGraph V) [DecidableRel G.Adj] (χ : V → ZMod 2) (C : Clause (GEdge G)) (hC : Entails (TseitinCNF G χ) C) : ∃ S : Finset V, S.card = tseitinMu G χ C ∧ Entails (TseitinSubsetCNF G χ S) C := by have hne : { m : ℕ | ∃ S : Finset V, S.card = m ∧ Entails (TseitinSubsetCNF G χ S) C }.Nonempty := ⟨Fintype.card V, Finset.univ, Finset.card_univ, hC⟩ exact Nat.sInf_mem hne lemma tseitinMu_le_of_entails (G : SimpleGraph V) [DecidableRel G.Adj] (χ : V → ZMod 2) {C : Clause (GEdge G)} {S : Finset V} (h : Entails (TseitinSubsetCNF G χ S) C) : tseitinMu G χ C ≤ S.card := Nat.sInf_le ⟨S, rfl, h⟩ lemma tseitinMu_axiom_le_one (G : SimpleGraph V) [DecidableRel G.Adj] (χ : V → ZMod 2) {C : Clause (GEdge G)} (hC : C ∈ TseitinCNF G χ) : tseitinMu G χ C ≤ 1 := by rcases hC with ⟨v, _, hv⟩ have hent : Entails (TseitinSubsetCNF G χ {v}) C := by intro α hα exact hα C ⟨v, Finset.mem_singleton_self v, hv⟩ simpa using tseitinMu_le_of_entails G χ hent lemma tseitinMu_empty_eq_card (G : SimpleGraph V) [DecidableRel G.Adj] (hconn : G.Connected) (χ : V → ZMod 2) (hodd : ∑ v : V, χ v = 1) : tseitinMu G χ emptyClause = Fintype.card V := by have hent_all : Entails (TseitinCNF G χ) emptyClause := by intro α hα; exact absurd ⟨α, hα⟩ (tseitin_unsat G χ hodd) rcases tseitinMu_exists_min G χ emptyClause hent_all with ⟨S, hScard, hSent⟩ have hS_univ : S = Finset.univ := by by_contra hne have hlt : S ⊂ Finset.univ := Finset.ssubset_univ_iff.mpr hne rcases Finset.exists_of_ssubset hlt with ⟨r, _, hr⟩ rcases tseitin_proper_subset_sat G hconn χ hr with ⟨α, hα⟩ exact evalClause_empty α (hSent α hα) rw [← hScard, hS_univ, Finset.card_univ] lemma tseitinMu_subadditive (G : SimpleGraph V) [DecidableRel G.Adj] (χ : V → ZMod 2) {C₁ C₂ C : Clause (GEdge G)} {e : GEdge G} (hr : Resolves C₁ C₂ e C) (h1 : Entails (TseitinCNF G χ) C₁) (h2 : Entails (TseitinCNF G χ) C₂) : tseitinMu G χ C ≤ tseitinMu G χ C₁ + tseitinMu G χ C₂ := by classical rcases tseitinMu_exists_min G χ C₁ h1 with ⟨S₁, hS1, hE1⟩ rcases tseitinMu_exists_min G χ C₂ h2 with ⟨S₂, hS2, hE2⟩ have hE : Entails (TseitinSubsetCNF G χ (S₁ ∪ S₂)) C := by intro α hα have hα1 : evalCNF (TseitinSubsetCNF G χ S₁) α := fun D ⟨v, hv, hD⟩ => hα D ⟨v, Finset.mem_union_left S₂ hv, hD⟩ have hα2 : evalCNF (TseitinSubsetCNF G χ S₂) α := fun D ⟨v, hv, hD⟩ => hα D ⟨v, Finset.mem_union_right S₁ hv, hD⟩ exact resolves_sound hr (hE1 α hα1) (hE2 α hα2) calc tseitinMu G χ C ≤ (S₁ ∪ S₂).card := tseitinMu_le_of_entails G χ hE _ ≤ S₁.card + S₂.card := Finset.card_union_le S₁ S₂ _ = tseitinMu G χ C₁ + tseitinMu G χ C₂ := by rw [hS1, hS2] /-- Core Constant-1 Boundary Lemma: if `S` achieves the minimum `tseitinMu G χ C`, then EVERY boundary edge `e ∈ edgeCut G S` MUST appear in `clauseVars C`! -/ lemma tseitin_min_subset_cut_le_vars (G : SimpleGraph V) [DecidableRel G.Adj] (χ : V → ZMod 2) {C : Clause (GEdge G)} {S : Finset V} (hmin : S.card = tseitinMu G χ C) (hent : Entails (TseitinSubsetCNF G χ S) C) : edgeCut G S ⊆ clauseVars C := by classical have hhalf : ∀ (e : GEdge G) (u w : V), e.1 = s(u, w) → u ∈ S → w ∉ S → e ∈ clauseVars C := by intro e u w heq huS hwS by_contra hnot have hCe : C e = none := by simp only [clauseVars, Finset.mem_filter, Finset.mem_univ, true_and, Option.isSome_iff_ne_none, not_not] at hnot exact hnot have hlt : (S.erase u).card < tseitinMu G χ C := by rw [← hmin]; exact Finset.card_erase_lt_of_mem huS have hnot_ent : ¬ Entails (TseitinSubsetCNF G χ (S.erase u)) C := fun h => Nat.not_lt_of_ge (tseitinMu_le_of_entails G χ h) hlt unfold Entails at hnot_ent push Not at hnot_ent rcases hnot_ent with ⟨α, hα_sat, hα_fals⟩ have hsat_erase := (evalCNF_tseitinSubset_iff G χ (S.erase u) α).mp hα_sat have hbad_u : vertexParity G α u ≠ χ u := by intro hgood_u have hsat_S : evalCNF (TseitinSubsetCNF G χ S) α := by rw [evalCNF_tseitinSubset_iff] intro v hv by_cases hvu : v = u · subst hvu; exact hgood_u · exact hsat_erase v (Finset.mem_erase.mpr ⟨hvu, hv⟩) exact hα_fals (hent α hsat_S) let α' := Function.update α e (!α e) have hsat_S' : evalCNF (TseitinSubsetCNF G χ S) α' := by rw [evalCNF_tseitinSubset_iff] intro v hv unfold satTseitinVertex rw [vertexParity_flip_edge] by_cases hvu : v = u · have hv_mem : v ∈ e.1 := by rw [heq, hvu]; simp rw [if_pos hv_mem, hvu] exact zmod2_ne_add_one hbad_u · have hv_not : v ∉ e.1 := by rw [heq, Sym2.mem_iff] rintro (rfl | rfl) · exact hvu rfl · exact hwS hv rw [if_neg hv_not, add_zero] exact hsat_erase v (Finset.mem_erase.mpr ⟨hvu, hv⟩) rcases hent α' hsat_S' with ⟨e', b, hCe', hae'⟩ have hne : e' ≠ e := by rintro rfl; rw [hCe] at hCe'; cases hCe' rw [show α' e' = α e' from Function.update_of_ne hne _ _] at hae' exact hα_fals ⟨e', b, hCe', hae'⟩ intro e he simp only [edgeCut, Finset.mem_filter, Finset.mem_univ, true_and] at he rcases he with ⟨u, w, heq, ⟨huS, hwS⟩ | ⟨huS, hwS⟩⟩ · exact hhalf e u w heq huS hwS · exact hhalf e w u (by rw [heq, Sym2.eq_swap]) hwS huS /-- **Headline Theorem 2C (Exact Constant-1 Tseitin Boundary-Cut Resolution Width Lower Bound):** For EVERY connected finite graph `G`, odd charge `χ`, threshold `k` with `1 ≤ k < |V|`, and DAG Resolution refutation `π` of `TseitinCNF G χ`, there exist a clause `C ∈ π` and a vertex subset `S ⊆ V` with `k / 2 < S.card ≤ k` such that `edgeCut G S ⊆ clauseVars C`, hence `(edgeCut G S).card ≤ width C`. -/ theorem tseitin_exact_boundary_width_lb (G : SimpleGraph V) [DecidableRel G.Adj] (hconn : G.Connected) (χ : V → ZMod 2) (hodd : ∑ v : V, χ v = 1) {k : ℕ} (hk1 : 1 ≤ k) (hkn : k < Fintype.card V) {π : List (Clause (GEdge G))} (hπ : IsResRefut (TseitinCNF G χ) π) : ∃ C ∈ π, ∃ S : Finset V, k / 2 < S.card ∧ S.card ≤ k ∧ (edgeCut G S).card ≤ width C := by -- Find the FIRST index `i` in `π` with `k / 2 < tseitinMu G χ π[i]`. have hex : ∃ i : ℕ, ∃ hi : i < π.length, k / 2 < tseitinMu G χ π[i] := by rcases List.mem_iff_getElem.mp hπ.2 with ⟨ie, hie, heq⟩ refine ⟨ie, hie, ?_⟩ rw [heq, tseitinMu_empty_eq_card G hconn χ hodd] omega -- Choose minimum such `i`. let P : ℕ → Prop := fun i => ∃ hi : i < π.length, k / 2 < tseitinMu G χ π[i] classical have hmin_i := Nat.find_spec hex set i := Nat.find hex rcases hmin_i with ⟨hi, hmu_gt⟩ have hmu_le : tseitinMu G χ π[i] ≤ k := by rcases hπ.1 i hi with hax | ⟨j, r, hj, hr, e, hres⟩ · have h1 := tseitinMu_axiom_le_one G χ hax omega · have hj_le : tseitinMu G χ (π[j]'(Nat.lt_trans hj hi)) ≤ k / 2 := by by_contra hgt; push Not at hgt exact Nat.find_min hex hj ⟨Nat.lt_trans hj hi, hgt⟩ have hr_le : tseitinMu G χ (π[r]'(Nat.lt_trans hr hi)) ≤ k / 2 := by by_contra hgt; push Not at hgt exact Nat.find_min hex hr ⟨Nat.lt_trans hr hi, hgt⟩ have hsub := tseitinMu_subadditive G χ hres (resolution_sound_mem hπ.1 j (Nat.lt_trans hj hi)) (resolution_sound_mem hπ.1 r (Nat.lt_trans hr hi)) omega have hent_i : Entails (TseitinCNF G χ) π[i] := resolution_sound_mem hπ.1 i hi rcases tseitinMu_exists_min G χ π[i] hent_i with ⟨S, hScard, hSent⟩ have hcut_sub := tseitin_min_subset_cut_le_vars G χ hScard hSent refine ⟨π[i], List.getElem_mem hi, S, by omega, by omega, ?_⟩ rw [width_eq_card_clauseVars] exact Finset.card_le_card hcut_sub /-- **Headline Theorem 2D (Pillar 1 + Pillar 2 Tseitin Exponential Size Lower Bound):** For any connected graph `G` with odd charge `χ`, max degree `≤ Δ`, and balanced cut `Φ ≤ |edgeCut G S|` for all `S` with `k / 2 < |S| ≤ k` (where `1 ≤ k < |V|`, `2 * Δ ≤ Φ`, `2 ≤ Φ ≤ |E|`), every DAG Resolution refutation `π` of `TseitinCNF G χ` has size `S(π) ≥ exp((Φ^2 - 1) / (8|E| - 2Φ + 4))`. -/ theorem tseitin_general_exponential_size_lb (G : SimpleGraph V) [DecidableRel G.Adj] (hconn : G.Connected) (χ : V → ZMod 2) (hodd : ∑ v : V, χ v = 1) {Δ Φ k : ℕ} (hΔ : ∀ v : V, (vStar G v).card ≤ Δ) (hk1 : 1 ≤ k) (hkn : k < Fintype.card V) (hΦ : ∀ S : Finset V, k / 2 < S.card → S.card ≤ k → Φ ≤ (edgeCut G S).card) (hΦΔ : 2 * Δ ≤ Φ) (hΦ2 : 2 ≤ Φ) (hΦE : Φ ≤ Fintype.card (GEdge G)) {π : List (Clause (GEdge G))} (hπ : IsResRefut (TseitinCNF G χ) π) : Real.exp (((Φ : ℝ) ^ 2 - 1) / (8 * (Fintype.card (GEdge G) : ℝ) - 2 * (Φ : ℝ) + 4)) ≤ (π.length : ℝ) := by have hno : ¬ HasWidthRefut (TseitinCNF G χ) (Φ - 1) := by rintro ⟨π', hπ', hw'⟩ rcases tseitin_exact_boundary_width_lb G hconn χ hodd hk1 hkn hπ' with ⟨C, hCmem, S, hS1, hS2, hcut⟩ have h1 := hΦ S hS1 hS2 have h2 := hw' C hCmem omega exact bsw_sharp_high_width_exp (tseitinCNF_width G χ hΔ) hΦΔ hΦ2 hΦE hno hπ /-- Cut size in the complete graph `⊤` on `Fin n` is exact: `|edgeCut ⊤ S| = |S| * (n - |S|)`. -/ lemma complete_graph_edgeCut_card (n : ℕ) (S : Finset (Fin n)) : (edgeCut (⊤ : SimpleGraph (Fin n)) S).card = S.card * (n - S.card) := by classical have hbij : (S ×ˢ Sᶜ).card = (edgeCut (⊤ : SimpleGraph (Fin n)) S).card := by refine Finset.card_bij (fun p hp => ⟨s(p.1, p.2), by have h1 : p.1 ∈ S := (Finset.mem_product.mp hp).1 have h2 : p.2 ∉ S := Finset.mem_compl.mp (Finset.mem_product.mp hp).2 simp [show p.1 ≠ p.2 from fun h => h2 (h ▸ h1)]⟩) ?_ ?_ ?_ · intro p hp have h1 : p.1 ∈ S := (Finset.mem_product.mp hp).1 have h2 : p.2 ∉ S := Finset.mem_compl.mp (Finset.mem_product.mp hp).2 simp only [edgeCut, Finset.mem_filter, Finset.mem_univ, true_and] exact ⟨p.1, p.2, rfl, Or.inl ⟨h1, h2⟩⟩ · intro p₁ hp₁ p₂ hp₂ heq have h1a : p₁.1 ∈ S := (Finset.mem_product.mp hp₁).1 have h2b : p₂.2 ∉ S := Finset.mem_compl.mp (Finset.mem_product.mp hp₂).2 have hsym : s(p₁.1, p₁.2) = s(p₂.1, p₂.2) := congrArg Subtype.val heq rw [Sym2.eq_iff] at hsym rcases hsym with ⟨h1, h2⟩ | ⟨h1, _⟩ · exact Prod.ext h1 h2 · exact absurd (h1 ▸ h1a) h2b · intro e he simp only [edgeCut, Finset.mem_filter, Finset.mem_univ, true_and] at he rcases he with ⟨u, w, heq, ⟨hu, hw⟩ | ⟨hu, hw⟩⟩ · refine ⟨(u, w), Finset.mem_product.mpr ⟨hu, Finset.mem_compl.mpr hw⟩, ?_⟩ exact Subtype.ext heq.symm · refine ⟨(w, u), Finset.mem_product.mpr ⟨hw, Finset.mem_compl.mpr hu⟩, ?_⟩ apply Subtype.ext change s(w, u) = e.1 rw [heq, Sym2.eq_swap] rw [← hbij, Finset.card_product, Finset.card_compl, Fintype.card_fin] lemma complete_graph_vStar_card (n : ℕ) (v : Fin n) : (vStar (⊤ : SimpleGraph (Fin n)) v).card = n - 1 := by have heq : vStar (⊤ : SimpleGraph (Fin n)) v = edgeCut (⊤ : SimpleGraph (Fin n)) {v} := by ext e simp only [vStar, edgeCut, Finset.mem_filter, Finset.mem_univ, true_and, Finset.mem_singleton] rcases e with ⟨e_raw, he_mem⟩ have hnd := (⊤ : SimpleGraph (Fin n)).not_isDiag_of_mem_edgeFinset he_mem induction e_raw using Sym2.ind with | _ u w => have huw : u ≠ w := fun h => hnd (by subst h; simp) constructor · intro hv rw [Sym2.mem_iff] at hv rcases hv with rfl | rfl · exact ⟨v, w, rfl, Or.inl ⟨rfl, huw.symm⟩⟩ · exact ⟨u, v, rfl, Or.inr ⟨huw, rfl⟩⟩ · rintro ⟨a, b, hab, ⟨rfl, _⟩ | ⟨_, rfl⟩⟩ <;> rw [hab] <;> simp rw [heq, complete_graph_edgeCut_card, Finset.card_singleton, one_mul] lemma complete_graph_edge_card (n : ℕ) : Fintype.card (GEdge (⊤ : SimpleGraph (Fin n))) = n * (n - 1) / 2 := by classical -- Handshaking: `2 * |E| = ∑ v, |vStar v| = n * (n - 1)`. have h2 : 2 * Fintype.card (GEdge (⊤ : SimpleGraph (Fin n))) = n * (n - 1) := by have hsum : ∑ v : Fin n, (vStar (⊤ : SimpleGraph (Fin n)) v).card = 2 * Fintype.card (GEdge (⊤ : SimpleGraph (Fin n))) := by simp_rw [vStar, Finset.card_eq_sum_ones, Finset.sum_filter] rw [Finset.sum_comm] have heach : ∀ e : GEdge (⊤ : SimpleGraph (Fin n)), (∑ v : Fin n, if v ∈ e.1 then (1 : ℕ) else 0) = 2 := by rintro ⟨e_raw, he_mem⟩ have hnd := (⊤ : SimpleGraph (Fin n)).not_isDiag_of_mem_edgeFinset he_mem induction e_raw using Sym2.ind with | _ u w => have huw : u ≠ w := fun h => hnd (by subst h; simp) have hfilt : (Finset.univ.filter fun v : Fin n => v ∈ s(u, w)) = {u, w} := by ext v; simp [Sym2.mem_iff] rw [← Finset.sum_filter, hfilt, Finset.sum_pair huw] simp_rw [heach] simp [Nat.mul_comm] rw [← hsum] simp_rw [complete_graph_vStar_card] simp omega /-- **Headline Theorem 2E (Explicit Infinite Family: Tseitin on `K_n` Exponential Resolution Lower Bound):** For every `n ≥ 9` and every odd charge `χ : Fin n → ZMod 2`, setting `Φ_n := (n / 3 + 1) * (n - (n / 3 + 1))` (note `Φ_n ≥ 2(n - 1)`): 1. Every Resolution refutation of `TseitinCNF (⊤ : SimpleGraph (Fin n)) χ` has width `≥ Φ_n`, 2. Every DAG Resolution refutation `π` has size `S(π) ≥ exp((Φ_n^2 - 1) / (4 n (n - 1) - 2 Φ_n + 4))` (exponential in `n^2`!). -/ theorem tseitin_complete_graph_exact_lb {n : ℕ} (hn : 9 ≤ n) (χ : Fin n → ZMod 2) (hodd : ∑ v : Fin n, χ v = 1) {π : List (Clause (GEdge (⊤ : SimpleGraph (Fin n))))} (hπ : IsResRefut (TseitinCNF (⊤ : SimpleGraph (Fin n)) χ) π) : let Φ := (2 * n / 3) * (n - 2 * n / 3) (∃ C ∈ π, Φ ≤ width C) ∧ Real.exp (((Φ : ℝ) ^ 2 - 1) / (4 * (n : ℝ) * ((n - 1 : ℕ) : ℝ) - 2 * (Φ : ℝ) + 4)) ≤ (π.length : ℝ) := by intro Φ have hconn : (⊤ : SimpleGraph (Fin n)).Connected := by have : Nonempty (Fin n) := ⟨⟨0, by omega⟩⟩ exact SimpleGraph.connected_top set k := 2 * n / 3 have hk1 : 1 ≤ k := by omega have hkn : k < Fintype.card (Fin n) := by simp [k]; omega -- For any `s` with `k / 2 < s ≤ k`, `n - k ≤ s ≤ k`, so `s * (n - s) ≥ k * (n - k) = Φ`! have hΦ_cut : ∀ S : Finset (Fin n), k / 2 < S.card → S.card ≤ k → Φ ≤ (edgeCut (⊤ : SimpleGraph (Fin n)) S).card := by intro S h1 h2 rw [complete_graph_edgeCut_card] set s := S.card have hnk_le_s : n - k ≤ s := by omega have hs_le_k : s ≤ k := h2 have hle_kn : k ≤ n := by omega -- `s(n - s) - k(n - k) = (k - s)(s - (n - k)) ≥ 0` in `ℤ`! have hZ : (k : ℤ) * ((n : ℤ) - k) ≤ (s : ℤ) * ((n : ℤ) - s) := by have h1z : (n : ℤ) - k ≤ s := by omega have h2z : (s : ℤ) ≤ k := by omega nlinarith have hcast : ((k * (n - k) : ℕ) : ℤ) ≤ ((s * (n - s) : ℕ) : ℤ) := by rw [Nat.cast_mul, Nat.cast_mul, Nat.cast_sub hle_kn, Nat.cast_sub (by omega : s ≤ n)] exact hZ exact Int.ofNat_le.mp hcast have hwidth : ∃ C ∈ π, Φ ≤ width C := by rcases tseitin_exact_boundary_width_lb (⊤ : SimpleGraph (Fin n)) hconn χ hodd hk1 hkn hπ with ⟨C, hCmem, S, hS1, hS2, hcut⟩ exact ⟨C, hCmem, Nat.le_trans (hΦ_cut S hS1 hS2) hcut⟩ refine ⟨hwidth, ?_⟩ have hΦΔ : 2 * (n - 1) ≤ Φ := by have hk_lo : 3 * k ≥ 2 * n - 2 := by omega have hk_hi : 3 * k ≤ 2 * n := by omega have hnk_lo : 3 * (n - k) ≥ n := by omega have h6 : 9 * Φ ≥ (2 * n - 2) * n := by have : 9 * Φ = (3 * k) * (3 * (n - k)) := by dsimp [Φ]; ring nlinarith have h2n2 : 2 * n - 2 = 2 * (n - 1) := by omega have h18 : 18 * (n - 1) ≤ (2 * n - 2) * n := by rw [h2n2] have : 9 * (2 * (n - 1)) ≤ n * (2 * (n - 1)) := Nat.mul_le_mul_right _ hn linarith omega have hΦ2 : 2 ≤ Φ := by omega have hEcard : Fintype.card (GEdge (⊤ : SimpleGraph (Fin n))) = n * (n - 1) / 2 := complete_graph_edge_card n have hΦE : Φ ≤ Fintype.card (GEdge (⊤ : SimpleGraph (Fin n))) := by rw [hEcard] have h2 : 2 * Φ ≤ n * (n - 1) := by have h1 : 2 * k * (n - k) ≤ n * (n - 1) := by have hk_le : k ≤ n := by omega have hZ : 2 * (k : ℤ) * ((n : ℤ) - k) ≤ (n : ℤ) * ((n : ℤ) - 1) := by have hsq : (0 : ℤ) ≤ (2 * (k : ℤ) - n) ^ 2 := sq_nonneg _ have hn2 : (2 : ℤ) ≤ n := by omega nlinarith have hcast : ((2 * (k * (n - k)) : ℕ) : ℤ) ≤ ((n * (n - 1) : ℕ) : ℤ) := by rw [Nat.cast_mul, Nat.cast_mul, Nat.cast_mul, Nat.cast_sub hk_le, Nat.cast_sub (by omega : 1 ≤ n)] push_cast; linarith simpa [Nat.mul_assoc] using Int.ofNat_le.mp hcast simpa [Φ, Nat.mul_assoc] using h1 omega have hexp := tseitin_general_exponential_size_lb (⊤ : SimpleGraph (Fin n)) hconn χ hodd (fun v => le_of_eq (complete_graph_vStar_card n v)) hk1 hkn hΦ_cut hΦΔ hΦ2 hΦE hπ have h8E : 8 * (Fintype.card (GEdge (⊤ : SimpleGraph (Fin n))) : ℝ) = 4 * (n : ℝ) * ((n - 1 : ℕ) : ℝ) := by rw [hEcard] have heven : 2 ∣ n * (n - 1) := (Nat.even_mul_pred_self n).two_dvd have hnat : 8 * (n * (n - 1) / 2) = 4 * (n * (n - 1)) := by have := Nat.mul_div_cancel' heven; omega have hcast : ((8 * (n * (n - 1) / 2) : ℕ) : ℝ) = ((4 * (n * (n - 1)) : ℕ) : ℝ) := congrArg Nat.cast hnat simp only [Nat.cast_mul, Nat.cast_ofNat] at hcast linarith rwa [h8E] at hexp /-- The cycle graph `C_n` on `Fin n` (`n ≥ 3`): vertex `i` is adjacent to `(i + 1) % n` and `(i - 1) % n`. -/ def cycleGraph (n : ℕ) : SimpleGraph (Fin n) := SimpleGraph.fromRel (fun i j : Fin n => (i.1 + 1) % n = j.1) lemma cycleGraph_adj_iff (n : ℕ) (i j : Fin n) : (cycleGraph n).Adj i j ↔ i ≠ j ∧ ((i.1 + 1) % n = j.1 ∨ (j.1 + 1) % n = i.1) := by simp [cycleGraph, SimpleGraph.fromRel_adj] instance (n : ℕ) : DecidableRel (cycleGraph n).Adj := fun i j => decidable_of_iff' _ (cycleGraph_adj_iff n i j) lemma cycleGraph_connected {n : ℕ} (hn : 3 ≤ n) : (cycleGraph n).Connected := by have : Nonempty (Fin n) := ⟨⟨0, by omega⟩⟩ refine SimpleGraph.Connected.mk fun u v => ?_ have hreach0 : ∀ k (hk : k < n), (cycleGraph n).Reachable ⟨0, by omega⟩ ⟨k, hk⟩ := by intro k induction k with | zero => intro _; exact SimpleGraph.Reachable.refl _ | succ k ih => intro hk have hprev := ih (by omega) have hadj : (cycleGraph n).Adj ⟨k, by omega⟩ ⟨k + 1, hk⟩ := (cycleGraph_adj_iff n _ _).mpr ⟨by intro h; simp at h, Or.inl (Nat.mod_eq_of_lt hk)⟩ exact hprev.trans hadj.reachable exact (hreach0 u.1 u.2).symm.trans (hreach0 v.1 v.2) lemma cycleGraph_star_card {n : ℕ} (hn : 3 ≤ n) (v : Fin n) : (vStar (cycleGraph n) v).card = 2 := by classical let e1 : GEdge (cycleGraph n) := ⟨s(v, ⟨(v.1 + 1) % n, Nat.mod_lt _ (by omega)⟩), by rw [SimpleGraph.mem_edgeFinset, SimpleGraph.mem_edgeSet, cycleGraph_adj_iff] refine ⟨?_, Or.inl rfl⟩ intro heq have hv := congrArg Fin.val heq dsimp at hv by_cases hlast : v.1 + 1 < n · rw [Nat.mod_eq_of_lt hlast] at hv; omega · have hveq : v.1 + 1 = n := by omega rw [hveq, Nat.mod_self] at hv; omega⟩ let e2 : GEdge (cycleGraph n) := ⟨s(⟨(v.1 + n - 1) % n, Nat.mod_lt _ (by omega)⟩, v), by rw [SimpleGraph.mem_edgeFinset, SimpleGraph.mem_edgeSet, cycleGraph_adj_iff] refine ⟨?_, Or.inl ?_⟩ · intro heq have hv := congrArg Fin.val heq dsimp at hv by_cases h0 : v.1 = 0 · rw [h0] at hv; simp [Nat.mod_eq_of_lt (by omega : n - 1 < n)] at hv; omega · have : v.1 + n - 1 = n + (v.1 - 1) := by omega rw [this, Nat.add_mod_left, Nat.mod_eq_of_lt (by omega : v.1 - 1 < n)] at hv; omega · by_cases h0 : v.1 = 0 · rw [h0]; simp [Nat.mod_eq_of_lt (by omega : n - 1 < n)] have : n - 1 + 1 = n := by omega rw [this, Nat.mod_self] · change ((v.1 + n - 1) % n + 1) % n = v.1 have hmod1 : (v.1 + n - 1) % n = v.1 - 1 := by have : v.1 + n - 1 = n + (v.1 - 1) := by omega rw [this, Nat.add_mod_left, Nat.mod_eq_of_lt (by omega : v.1 - 1 < n)] rw [hmod1, show v.1 - 1 + 1 = v.1 by omega, Nat.mod_eq_of_lt v.2]⟩ have hne12 : e1 ≠ e2 := by intro heq have hsym := congrArg Subtype.val heq rw [Sym2.eq_iff] at hsym rcases hsym with ⟨h1, h2⟩ | ⟨h1, h2⟩ · have := congrArg Fin.val h1; dsimp at this by_cases h0 : v.1 = 0 · rw [h0] at this; simp [Nat.mod_eq_of_lt (by omega : n - 1 < n)] at this; omega · have hmod : (v.1 + n - 1) % n = v.1 - 1 := by have : v.1 + n - 1 = n + (v.1 - 1) := by omega rw [this, Nat.add_mod_left, Nat.mod_eq_of_lt (by omega)] rw [hmod] at this; omega · have := congrArg Fin.val h2; dsimp at this by_cases h0 : v.1 = 0 · rw [h0] at this have h1' : 1 % n = 1 := Nat.mod_eq_of_lt (by omega) have h2' : (n - 1) % n = n - 1 := Nat.mod_eq_of_lt (by omega) simp [h1', h2'] at this; omega · have hmod2 : (v.1 + n - 1) % n = v.1 - 1 := by have : v.1 + n - 1 = n + (v.1 - 1) := by omega rw [this, Nat.add_mod_left, Nat.mod_eq_of_lt (by omega)] rw [hmod2] at this by_cases hlast : v.1 + 1 < n · rw [Nat.mod_eq_of_lt hlast] at this; omega · have hvlast : v.1 + 1 = n := by omega rw [hvlast, Nat.mod_self] at this; omega have hset : vStar (cycleGraph n) v = {e1, e2} := by ext e simp only [vStar, Finset.mem_filter, Finset.mem_univ, true_and, Finset.mem_insert, Finset.mem_singleton] constructor · intro hv rcases e with ⟨e_raw, he_mem⟩ induction e_raw using Sym2.ind with | _ a b => have hadj : (cycleGraph n).Adj a b := SimpleGraph.mem_edgeFinset.mp he_mem rw [Sym2.mem_iff] at hv have hcase : ∀ x : Fin n, (hx : (cycleGraph n).Adj v x) → (⟨s(v, x), SimpleGraph.mem_edgeFinset.mpr hx⟩ : GEdge (cycleGraph n)) = e1 ∨ (⟨s(v, x), SimpleGraph.mem_edgeFinset.mpr hx⟩ : GEdge (cycleGraph n)) = e2 := by intro x hx rcases ((cycleGraph_adj_iff n v x).mp hx).2 with h1 | h2 · left; apply Subtype.ext change s(v, x) = s(v, ⟨(v.1 + 1) % n, _⟩) congr 1; exact Fin.ext h1.symm · right; apply Subtype.ext change s(v, x) = s(⟨(v.1 + n - 1) % n, _⟩, v) rw [Sym2.eq_swap]; congr 1 apply Fin.ext; dsimp by_cases h0 : v.1 = 0 · rw [h0] at h2 ⊢ have hxn : x.1 + 1 = n := by by_contra hne have hlt : x.1 + 1 < n := by omega rw [Nat.mod_eq_of_lt hlt] at h2; omega have hmod0 : (0 + n - 1) % n = n - 1 := by simp [Nat.mod_eq_of_lt (by omega : n - 1 < n)] omega · have hmod : (v.1 + n - 1) % n = v.1 - 1 := by have : v.1 + n - 1 = n + (v.1 - 1) := by omega rw [this, Nat.add_mod_left, Nat.mod_eq_of_lt (by omega)] rw [hmod] by_cases hlast : x.1 + 1 < n · rw [Nat.mod_eq_of_lt hlast] at h2; omega · have hxlast : x.1 + 1 = n := by omega rw [hxlast, Nat.mod_self] at h2; omega rcases hv with rfl | rfl · exact hcase b hadj · have h := hcase a hadj.symm rcases h with h1 | h2 · left; apply Subtype.ext; change s(a, v) = e1.1; rw [Sym2.eq_swap]; exact congrArg Subtype.val h1 · right; apply Subtype.ext; change s(a, v) = e2.1; rw [Sym2.eq_swap]; exact congrArg Subtype.val h2 · rintro (rfl | rfl) <;> simp [e1, e2] rw [hset, Finset.card_pair hne12] private lemma zmod2_cycle_step1 (a b : Bool) (p c : ZMod 2) (h1 : ((if a = false then (1 : ZMod 2) else 0) + (if b = false then 1 else 0)) ≠ p + c) (h2 : ((if a = false then (1 : ZMod 2) else 0) + 0) ≠ p) : ((if false = false then (1 : ZMod 2) else 0) + (if b = false then 1 else 0)) ≠ c := by revert a b p c; decide private lemma zmod2_cycle_step2a (a : Bool) (p : ZMod 2) (h : ((if a = false then (1 : ZMod 2) else 0) + 0) = p) : ((if a = false then (1 : ZMod 2) else 0) + (if false = false then 1 else 0)) ≠ p := by revert a p; decide private lemma zmod2_cycle_step2b (a b : Bool) (p c : ZMod 2) (h1 : ((if a = false then (1 : ZMod 2) else 0) + (if b = false then 1 else 0)) ≠ p + c) (h2 : ((if a = false then (1 : ZMod 2) else 0) + 0) = p) : ((if true = false then (1 : ZMod 2) else 0) + (if b = false then 1 else 0)) ≠ c := by revert a b p c; decide private lemma zmod2_cycle_close (a b : Bool) (p c : ZMod 2) (htot : p + c = 1) (h1 : ((if a = false then (1 : ZMod 2) else 0) + (if b = false then 1 else 0)) = p) : ((if b = false then (1 : ZMod 2) else 0) + (if a = false then 1 else 0)) ≠ c := by revert a b p c; decide /-- **Headline Theorem 2F (`C_n` Exact Tseitin Resolution Width Sharpness = 2):** For every `n ≥ 3` and every odd charge `χ : Fin n → ZMod 2`, `TseitinCNF (cycleGraph n) χ` has Resolution width EXACTLY `2`: 1. Every Resolution refutation contains a clause of width `≥ 2` (since every nonempty proper subset of `C_n` has `|edgeCut| ≥ 2`), 2. There exists an explicit width-`2` Resolution refutation of `TseitinCNF (cycleGraph n) χ`! -/ theorem tseitin_cycle_exact_sharpness {n : ℕ} (hn : 3 ≤ n) (χ : Fin n → ZMod 2) (hodd : ∑ v : Fin n, χ v = 1) : (∀ π, IsResRefut (TseitinCNF (cycleGraph n) χ) π → ∃ C ∈ π, 2 ≤ width C) ∧ HasWidthRefut (TseitinCNF (cycleGraph n) χ) 2 := by classical have hconn := cycleGraph_connected hn -- Helper: cycle edges `e_i = {i, (i+1) % n}`. let edgeAt : Fin n → GEdge (cycleGraph n) := fun i => ⟨s(i, ⟨(i.1 + 1) % n, Nat.mod_lt _ (by omega)⟩), by rw [SimpleGraph.mem_edgeFinset, SimpleGraph.mem_edgeSet, cycleGraph_adj_iff] refine ⟨?_, Or.inl rfl⟩ intro heq have hv := congrArg Fin.val heq; dsimp at hv by_cases hlt : i.1 + 1 < n · rw [Nat.mod_eq_of_lt hlt] at hv; omega · have : i.1 + 1 = n := by omega rw [this, Nat.mod_self] at hv; omega⟩ have hedge_inj : Function.Injective edgeAt := by intro i j heq have hsym := congrArg Subtype.val heq rw [Sym2.eq_iff] at hsym rcases hsym with ⟨h1, _⟩ | ⟨h1, h2⟩ · exact h1 · have hv1 := congrArg Fin.val h1 have hv2 := congrArg Fin.val h2 dsimp at hv1 hv2 by_cases hi : i.1 + 1 < n <;> by_cases hj : j.1 + 1 < n · rw [Nat.mod_eq_of_lt hi] at hv2; rw [Nat.mod_eq_of_lt hj] at hv1; omega · have hjeq : j.1 + 1 = n := by omega rw [hjeq, Nat.mod_self] at hv1; rw [Nat.mod_eq_of_lt hi] at hv2; omega · have hieq : i.1 + 1 = n := by omega rw [hieq, Nat.mod_self] at hv2; rw [Nat.mod_eq_of_lt hj] at hv1; omega · omega -- Part 1: Every nonempty proper subset of `C_n` has cut ≥ 2. have hcut2 : ∀ S : Finset (Fin n), 0 < S.card → S.card < n → 2 ≤ (edgeCut (cycleGraph n) S).card := by intro S hpos hlt -- At least one edge leaves `S` (`i ∈ S, i+1 ∉ S`) and at least one enters `S` (`j ∉ S, j+1 ∈ S`). have hex_out : ∃ i : Fin n, i ∈ S ∧ ⟨(i.1 + 1) % n, Nat.mod_lt _ (by omega)⟩ ∉ S := by by_contra hall; push Not at hall rcases Finset.card_pos.mp hpos with ⟨x, hx⟩ have hstep : ∀ t : ℕ, ⟨(x.1 + t) % n, Nat.mod_lt _ (by omega)⟩ ∈ S := by intro t induction t with | zero => have : (⟨(x.1 + 0) % n, Nat.mod_lt _ (by omega)⟩ : Fin n) = x := Fin.ext (by simpa using Nat.mod_eq_of_lt x.2) rwa [this] | succ t iht => have hnxt := hall ⟨(x.1 + t) % n, Nat.mod_lt _ (by omega)⟩ iht have heq : ((x.1 + t) % n + 1) % n = (x.1 + (t + 1)) % n := by rw [Nat.add_mod, Nat.mod_mod, ← Nat.add_mod, Nat.add_assoc] exact (Fin.ext heq : (⟨((x.1 + t) % n + 1) % n, _⟩ : Fin n) = ⟨(x.1 + (t + 1)) % n, _⟩) ▸ hnxt have hallS : S = Finset.univ := by ext y simp only [Finset.mem_univ, iff_true] let t := (y.1 + n - x.1) % n have hmem := hstep t have heq : (x.1 + t) % n = y.1 := by dsimp [t] rw [Nat.add_mod, Nat.mod_mod, ← Nat.add_mod] have : x.1 + (y.1 + n - x.1) = y.1 + n := by omega rw [this, Nat.add_mod_right, Nat.mod_eq_of_lt y.2] exact (Fin.ext heq : (⟨(x.1 + t) % n, _⟩ : Fin n) = y) ▸ hmem rw [hallS, Finset.card_univ, Fintype.card_fin] at hlt exact lt_irrefl _ hlt have hex_in : ∃ j : Fin n, j ∉ S ∧ ⟨(j.1 + 1) % n, Nat.mod_lt _ (by omega)⟩ ∈ S := by by_contra hall; push Not at hall have hne_compl : Sᶜ.Nonempty := by rw [← Finset.card_pos, Finset.card_compl, Fintype.card_fin]; omega rcases hne_compl with ⟨x, hx⟩ have hx_not : x ∉ S := Finset.mem_compl.mp hx have hstep : ∀ t : ℕ, ⟨(x.1 + t) % n, Nat.mod_lt _ (by omega)⟩ ∉ S := by intro t induction t with | zero => have : (⟨(x.1 + 0) % n, Nat.mod_lt _ (by omega)⟩ : Fin n) = x := Fin.ext (by simpa using Nat.mod_eq_of_lt x.2) rwa [this] | succ t iht => have hnxt := hall ⟨(x.1 + t) % n, Nat.mod_lt _ (by omega)⟩ iht have heq : ((x.1 + t) % n + 1) % n = (x.1 + (t + 1)) % n := by rw [Nat.add_mod, Nat.mod_mod, ← Nat.add_mod, Nat.add_assoc] exact (Fin.ext heq : (⟨((x.1 + t) % n + 1) % n, _⟩ : Fin n) = ⟨(x.1 + (t + 1)) % n, _⟩) ▸ hnxt rcases Finset.card_pos.mp hpos with ⟨y, hy⟩ let t := (y.1 + n - x.1) % n have hnot := hstep t have heq : (x.1 + t) % n = y.1 := by dsimp [t] rw [Nat.add_mod, Nat.mod_mod, ← Nat.add_mod] have : x.1 + (y.1 + n - x.1) = y.1 + n := by omega rw [this, Nat.add_mod_right, Nat.mod_eq_of_lt y.2] exact hnot ((Fin.ext heq : (⟨(x.1 + t) % n, _⟩ : Fin n) = y) ▸ hy) rcases hex_out with ⟨i, hiS, hi1⟩ rcases hex_in with ⟨j, hjS, hj1⟩ have hij : i ≠ j := fun h => hjS (h ▸ hiS) have hne_e : edgeAt i ≠ edgeAt j := fun h => hij (hedge_inj h) have hsub : ({edgeAt i, edgeAt j} : Finset _) ⊆ edgeCut (cycleGraph n) S := by intro e he simp only [Finset.mem_insert, Finset.mem_singleton] at he simp only [edgeCut, Finset.mem_filter, Finset.mem_univ, true_and] rcases he with rfl | rfl · exact ⟨i, ⟨(i.1 + 1) % n, _⟩, rfl, Or.inl ⟨hiS, hi1⟩⟩ · exact ⟨j, ⟨(j.1 + 1) % n, _⟩, rfl, Or.inr ⟨hjS, hj1⟩⟩ calc 2 = ({edgeAt i, edgeAt j} : Finset _).card := (Finset.card_pair hne_e).symm _ ≤ (edgeCut (cycleGraph n) S).card := Finset.card_le_card hsub refine ⟨?_, ?_⟩ · intro π hπ rcases tseitin_exact_boundary_width_lb (cycleGraph n) hconn χ hodd (k := 2) (by omega) (by simp; omega) hπ with ⟨C, hCmem, S, hS1, hS2, hcut⟩ exact ⟨C, hCmem, Nat.le_trans (hcut2 S (by omega) (by omega)) hcut⟩ · -- Part 2: Explicit width-2 Resolution refutation of `TseitinCNF (cycleGraph n) χ`! -- Helper: 2-literal clause `cl2 e₁ b₁ e₂ b₂`. let cl2 : GEdge (cycleGraph n) → Bool → GEdge (cycleGraph n) → Bool → Clause (GEdge (cycleGraph n)) := fun e₁ b₁ e₂ b₂ => Function.update (Function.update emptyClause e₁ (some b₁)) e₂ (some b₂) have hw_cl2 : ∀ e₁ b₁ e₂ b₂, width (cl2 e₁ b₁ e₂ b₂) ≤ 2 := by intro e₁ b₁ e₂ b₂ have hsub : clauseVars (cl2 e₁ b₁ e₂ b₂) ⊆ {e₁, e₂} := by intro e he simp only [clauseVars, Finset.mem_filter, Finset.mem_univ, true_and, cl2] at he by_cases h2 : e = e₂ · subst h2; simp · rw [Function.update_of_ne h2] at he by_cases h1 : e = e₁ · subst h1; simp · simp [Function.update_of_ne h1, emptyClause] at he calc width (cl2 e₁ b₁ e₂ b₂) = (clauseVars (cl2 e₁ b₁ e₂ b₂)).card := rfl _ ≤ ({e₁, e₂} : Finset _).card := Finset.card_le_card hsub _ ≤ 2 := Finset.card_le_two -- For each `i : Fin n`, the two incident edges of vertex `⟨(i+1)%n⟩` are `edgeAt i` and `edgeAt ⟨(i+1)%n⟩`. -- Actually even simpler: for each `k` (`0 ≤ k < n`), vertex `v_k = ⟨k, hk⟩` has incident edges -- `edgeAt ⟨(k + n - 1) % n⟩` and `edgeAt ⟨k⟩`! -- Define `e_k := edgeAt ⟨k % n, ...⟩`. -- Vertex `k` (`1 ≤ k ≤ n - 1`) connects `e_{k-1}` and `e_k`, with charge `χ ⟨k, _⟩`. -- Vertex `0` connects `e_{n-1}` and `e_0`, with charge `χ ⟨0, _⟩`. -- By induction on `k` (`0 ≤ k ≤ n - 1`), we derive from `TseitinCNF (cycleGraph n) χ` in width `≤ 2` -- BOTH clauses asserting `e_0 ⊕ e_k = s_k` where `s_k = ∑_{j=1}^k χ_j`! -- Wait: at `k = 0`, we don't even need `e_0 = e_0` as a clause — start at `k = 1` from vertex `1`! let eOf : ∀ k : ℕ, GEdge (cycleGraph n) := fun k => edgeAt ⟨k % n, Nat.mod_lt _ (by omega)⟩ have hvStar_eq : ∀ k (hk : k < n), vStar (cycleGraph n) ⟨k, hk⟩ = {eOf (k + n - 1), eOf k} := by intro k hk have hne : eOf (k + n - 1) ≠ eOf k := by intro h have hf := hedge_inj h have hv := congrArg Fin.val hf; dsimp at hv rw [Nat.mod_eq_of_lt hk] at hv by_cases h0 : k = 0 · subst h0; simp [Nat.mod_eq_of_lt (by omega : n - 1 < n)] at hv; omega · have : k + n - 1 = n + (k - 1) := by omega rw [this, Nat.add_mod_left, Nat.mod_eq_of_lt (by omega : k - 1 < n)] at hv; omega have hsub : {eOf (k + n - 1), eOf k} ⊆ vStar (cycleGraph n) ⟨k, hk⟩ := by intro e he simp only [Finset.mem_insert, Finset.mem_singleton] at he simp only [vStar, Finset.mem_filter, Finset.mem_univ, true_and] rcases he with rfl | rfl · dsimp [eOf, edgeAt] rw [Sym2.mem_iff]; right apply Fin.ext; dsimp by_cases h0 : k = 0 · subst h0 have hmod0 : (0 + n - 1) % n = n - 1 := by simp [Nat.mod_eq_of_lt (by omega : n - 1 < n)] rw [hmod0, show n - 1 + 1 = n by omega, Nat.mod_self] · have : (k + n - 1) % n = k - 1 := by have h1 : k + n - 1 = n + (k - 1) := by omega rw [h1, Nat.add_mod_left, Nat.mod_eq_of_lt (by omega)] rw [this, show k - 1 + 1 = k by omega, Nat.mod_eq_of_lt hk] · dsimp [eOf, edgeAt] rw [Sym2.mem_iff]; left exact (Fin.ext (Nat.mod_eq_of_lt hk)).symm exact (Finset.eq_of_subset_of_card_le hsub (by rw [cycleGraph_star_card hn, Finset.card_pair hne])).symm -- Axiom membership for `cl2 (eOf (k + n - 1)) b₁ (eOf k) b₂` at vertex `k` when -- `(if !b₁ then 1 else 0) + (if !b₂ then 1 else 0) ≠ χ ⟨k, hk⟩`. have hcl2_ax : ∀ k (hk : k < n) (b₁ b₂ : Bool), ((if b₁ = false then (1 : ZMod 2) else 0) + (if b₂ = false then (1 : ZMod 2) else 0)) ≠ χ ⟨k, hk⟩ → cl2 (eOf (k + n - 1)) b₁ (eOf k) b₂ ∈ TseitinCNF (cycleGraph n) χ := by intro k hk b₁ b₂ hbad have hne : eOf (k + n - 1) ≠ eOf k := by intro h have hv := congrArg Fin.val (hedge_inj h); dsimp at hv rw [Nat.mod_eq_of_lt hk] at hv by_cases h0 : k = 0 · subst h0; simp [Nat.mod_eq_of_lt (by omega : n - 1 < n)] at hv; omega · have : k + n - 1 = n + (k - 1) := by omega rw [this, Nat.add_mod_left, Nat.mod_eq_of_lt (by omega : k - 1 < n)] at hv; omega refine ⟨⟨k, hk⟩, Finset.mem_univ _, ?_, ?_⟩ · intro e rw [hvStar_eq k hk] simp only [Finset.mem_insert, Finset.mem_singleton, cl2] by_cases h2 : e = eOf k · subst h2; simp · rw [Function.update_of_ne h2] by_cases h1 : e = eOf (k + n - 1) · subst h1; simp · simp [emptyClause, h1, h2] · rw [hvStar_eq k hk, Finset.sum_pair hne] simp only [cl2, Function.update_self, Function.update_of_ne hne, Option.some.injEq] exact hbad -- Helper: resolution step combining `cl2 e₀ a e₁ true` and `cl2 e₁ false e₂ b` into `cl2 e₀ a e₂ b` -- (for distinct `e₀, e₁, e₂`). have hres_chain : ∀ (e₀ e₁ e₂ : GEdge (cycleGraph n)) (a b : Bool), e₀ ≠ e₁ → e₁ ≠ e₂ → e₀ ≠ e₂ → Resolves (cl2 e₀ a e₁ true) (cl2 e₁ false e₂ b) e₁ (cl2 e₀ a e₂ b) := by intro e₀ e₁ e₂ a b h01 h12 h02 refine ⟨by simp [cl2], by simp [cl2, Function.update_of_ne h12], ?_, by simp [cl2, Function.update_of_ne h12, Function.update_of_ne h01.symm, emptyClause], ?_⟩ · intro u hu b₁ b₂ h1 h2 simp only [cl2, Function.update_of_ne hu] at h1 by_cases hu0 : u = e₀ · subst hu0 simp only [cl2, Function.update_of_ne h02, Function.update_of_ne h01, emptyClause] at h2 cases h2 · simp [Function.update_of_ne hu0, emptyClause] at h1 · intro u hu simp only [cl2] by_cases hu2 : u = e₂ · subst hu2 simp [Function.update_of_ne h12.symm, Function.update_of_ne h02.symm, emptyClause] · by_cases hu0 : u = e₀ · subst hu0 simp [Function.update_of_ne h02, Function.update_of_ne h01, emptyClause] · simp [Function.update_of_ne hu2, Function.update_of_ne hu0, Function.update_of_ne hu, emptyClause] -- Also symmetric resolution step `cl2 e₁ true e₂ b` + `cl2 e₀ a e₁ false` -> `cl2 e₀ a e₂ b`. have hres_chain' : ∀ (e₀ e₁ e₂ : GEdge (cycleGraph n)) (a b : Bool), e₀ ≠ e₁ → e₁ ≠ e₂ → e₀ ≠ e₂ → Resolves (cl2 e₁ true e₂ b) (cl2 e₀ a e₁ false) e₁ (cl2 e₀ a e₂ b) := by intro e₀ e₁ e₂ a b h01 h12 h02 refine ⟨by simp [cl2, Function.update_of_ne h12], by simp [cl2], ?_, by simp [cl2, Function.update_of_ne h12, Function.update_of_ne h01.symm, emptyClause], ?_⟩ · intro u hu b₁ b₂ h1 h2 simp only [cl2, Function.update_of_ne hu] at h2 by_cases hu0 : u = e₀ · subst hu0 simp only [cl2, Function.update_of_ne h02, Function.update_of_ne h01, emptyClause] at h1 cases h1 · simp [Function.update_of_ne hu0, emptyClause] at h2 · intro u hu simp only [cl2] by_cases hu2 : u = e₂ · subst hu2 simp [Function.update_of_ne h12.symm, Function.update_of_ne h02.symm, emptyClause] · by_cases hu0 : u = e₀ · subst hu0 simp [Function.update_of_ne h02, Function.update_of_ne h01, emptyClause] · simp [Function.update_of_ne hu2, Function.update_of_ne hu0, Function.update_of_ne hu, emptyClause] -- Helper: derive `cl2 (eOf 0) a (eOf k) b` in width ≤ 2 for `1 ≤ k < n` whenever -- `(if a = false then 1 else 0) + (if b = false then 1 else 0) ≠ psum k`. let psum : ℕ → ZMod 2 := fun k => ∑ j ∈ Finset.range k, if h : j + 1 < n then χ ⟨j + 1, h⟩ else 0 have hderive_step : ∀ k, 1 ≤ k → k < n → ∀ a b : Bool, ((if a = false then (1 : ZMod 2) else 0) + (if b = false then (1 : ZMod 2) else 0)) ≠ psum k → ∃ π, IsResProof (TseitinCNF (cycleGraph n) χ) π ∧ cl2 (eOf 0) a (eOf k) b ∈ π ∧ ∀ C ∈ π, width C ≤ 2 := by intro k induction k with | zero => intro h1; omega | succ k ih => intro _ hkn a b hbad by_cases hk0 : k = 0 · subst hk0 have hps1 : psum 1 = χ ⟨1, by omega⟩ := by simp [psum, show 1 < n by omega] rw [hps1] at hbad have he0 : eOf (1 + n - 1) = eOf 0 := by dsimp [eOf]; congr 1; apply Fin.ext; dsimp rw [show 1 + n - 1 = n by omega, Nat.mod_self] have hax := hcl2_ax 1 (by omega) a b hbad rw [he0] at hax refine ⟨[cl2 (eOf 0) a (eOf 1) b], ?_, by simp, fun C hC => ?_⟩ · intro i hi have : i = 0 := by simpa using hi subst this; exact Or.inl hax · simp only [List.mem_singleton] at hC; subst hC; exact hw_cl2 _ _ _ _ · have hk1 : 1 ≤ k := by omega have hkn' : k < n := by omega have hps_succ : psum (k + 1) = psum k + χ ⟨k + 1, hkn⟩ := by simp [psum, Finset.sum_range_succ, hkn] rw [hps_succ] at hbad have he_prev : eOf (k + 1 + n - 1) = eOf k := by dsimp [eOf]; congr 1; apply Fin.ext; dsimp rw [show k + 1 + n - 1 = k + n by omega, Nat.add_mod_right] have h0k : eOf 0 ≠ eOf k := by intro h; have hv := congrArg Fin.val (hedge_inj h); dsimp at hv rw [Nat.mod_eq_of_lt hkn'] at hv; omega have hk_k1 : eOf k ≠ eOf (k + 1) := by intro h; have hv := congrArg Fin.val (hedge_inj h); dsimp at hv rw [Nat.mod_eq_of_lt hkn', Nat.mod_eq_of_lt hkn] at hv; omega have h0_k1 : eOf 0 ≠ eOf (k + 1) := by intro h; have hv := congrArg Fin.val (hedge_inj h); dsimp at hv rw [Nat.mod_eq_of_lt hkn] at hv; omega by_cases hmid : ((if a = false then (1 : ZMod 2) else 0) + 0) ≠ psum k · -- `m = true`: derive `cl2 (eOf 0) a (eOf k) true` and axiom `cl2 (eOf k) false (eOf (k+1)) b`. have hbad1 : ((if a = false then (1 : ZMod 2) else 0) + (if true = false then (1 : ZMod 2) else 0)) ≠ psum k := by simpa using hmid have hbad2 : ((if false = false then (1 : ZMod 2) else 0) + (if b = false then (1 : ZMod 2) else 0)) ≠ χ ⟨k + 1, hkn⟩ := zmod2_cycle_step1 a b (psum k) (χ ⟨k + 1, hkn⟩) hbad hmid rcases ih hk1 hkn' a true hbad1 with ⟨π₁, hP1, hmem1, hw1⟩ have hax2 : cl2 (eOf k) false (eOf (k + 1)) b ∈ TseitinCNF (cycleGraph n) χ := by rw [← he_prev]; exact hcl2_ax (k + 1) hkn false b hbad2 rcases List.mem_iff_getElem.mp hmem1 with ⟨i1, hi1, hi1_eq⟩ let Cnew := cl2 (eOf 0) a (eOf (k + 1)) b refine ⟨π₁ ++ [cl2 (eOf k) false (eOf (k + 1)) b, Cnew], ?_, by simp [Cnew], ?_⟩ · intro idx hidx by_cases hlt : idx < π₁.length · rw [List.getElem_append_left hlt] rcases hP1 idx hlt with hm | ⟨x, y, hx, hy, w, hr⟩ · exact Or.inl hm · right; refine ⟨x, y, hx, hy, w, ?_⟩ simpa [List.getElem_append_left (Nat.lt_trans hx hlt), List.getElem_append_left (Nat.lt_trans hy hlt)] using hr · by_cases heq1 : idx = π₁.length · subst heq1; left; simpa [List.getElem_append_right (le_refl _)] using hax2 · have heq2 : idx = π₁.length + 1 := by have : idx < π₁.length + 2 := by simpa using hidx omega subst heq2; right refine ⟨i1, π₁.length, by omega, by omega, eOf k, ?_⟩ simpa [List.getElem_append_left hi1, hi1_eq, List.getElem_append_right (le_refl _), List.getElem_append_right (Nat.le_succ _), Cnew] using hres_chain (eOf 0) (eOf k) (eOf (k + 1)) a b h0k hk_k1 h0_k1 · intro C hC rcases List.mem_append.mp hC with h1 | h2 · exact hw1 C h1 · simp only [List.mem_cons, List.not_mem_nil, or_false] at h2 rcases h2 with rfl | rfl <;> exact hw_cl2 _ _ _ _ · -- `m = false`: derive `cl2 (eOf 0) a (eOf k) false` and axiom `cl2 (eOf k) true (eOf (k+1)) b`. push Not at hmid have hbad1 : ((if a = false then (1 : ZMod 2) else 0) + (if false = false then (1 : ZMod 2) else 0)) ≠ psum k := zmod2_cycle_step2a a (psum k) hmid have hbad2 : ((if true = false then (1 : ZMod 2) else 0) + (if b = false then (1 : ZMod 2) else 0)) ≠ χ ⟨k + 1, hkn⟩ := zmod2_cycle_step2b a b (psum k) (χ ⟨k + 1, hkn⟩) hbad hmid rcases ih hk1 hkn' a false hbad1 with ⟨π₁, hP1, hmem1, hw1⟩ have hax2 : cl2 (eOf k) true (eOf (k + 1)) b ∈ TseitinCNF (cycleGraph n) χ := by rw [← he_prev]; exact hcl2_ax (k + 1) hkn true b hbad2 rcases List.mem_iff_getElem.mp hmem1 with ⟨i1, hi1, hi1_eq⟩ let Cnew := cl2 (eOf 0) a (eOf (k + 1)) b refine ⟨π₁ ++ [cl2 (eOf k) true (eOf (k + 1)) b, Cnew], ?_, by simp [Cnew], ?_⟩ · intro idx hidx by_cases hlt : idx < π₁.length · rw [List.getElem_append_left hlt] rcases hP1 idx hlt with hm | ⟨x, y, hx, hy, w, hr⟩ · exact Or.inl hm · right; refine ⟨x, y, hx, hy, w, ?_⟩ simpa [List.getElem_append_left (Nat.lt_trans hx hlt), List.getElem_append_left (Nat.lt_trans hy hlt)] using hr · by_cases heq1 : idx = π₁.length · subst heq1; left; simpa [List.getElem_append_right (le_refl _)] using hax2 · have heq2 : idx = π₁.length + 1 := by have : idx < π₁.length + 2 := by simpa using hidx omega subst heq2; right refine ⟨π₁.length, i1, by omega, by omega, eOf k, ?_⟩ simpa [List.getElem_append_left hi1, hi1_eq, List.getElem_append_right (le_refl _), List.getElem_append_right (Nat.le_succ _), Cnew] using hres_chain' (eOf 0) (eOf k) (eOf (k + 1)) a b h0k hk_k1 h0_k1 · intro C hC rcases List.mem_append.mp hC with h1 | h2 · exact hw1 C h1 · simp only [List.mem_cons, List.not_mem_nil, or_false] at h2 rcases h2 with rfl | rfl <;> exact hw_cl2 _ _ _ _ -- Now close the cycle at vertex `0`, which has `psum (n - 1) + χ ⟨0, _⟩ = ∑ v, χ v = 1`! have htotal : psum (n - 1) + χ ⟨0, by omega⟩ = 1 := by have hsplit : ∑ v : Fin n, χ v = χ ⟨0, by omega⟩ + psum (n - 1) := by have hrew : (∑ v : Fin n, χ v) = ∑ v : Fin n, (if h : v.1 < n then χ ⟨v.1, h⟩ else 0) := by apply Finset.sum_congr rfl; intro v _; simp [v.2] rw [hrew, Fin.sum_univ_eq_sum_range (fun i => if h : i < n then χ ⟨i, h⟩ else 0)] have hrange : Finset.range n = Finset.range ((n - 1) + 1) := by congr 1; omega rw [hrange, Finset.sum_range_succ'] simp only [show 0 < n by omega, ↓reduceDIte, add_comm] rfl rw [← hodd, hsplit, add_comm] have he_n1 : eOf (0 + n - 1) = eOf (n - 1) := by simp have h0_n1 : eOf 0 ≠ eOf (n - 1) := by intro h; have hv := congrArg Fin.val (hedge_inj h); dsimp at hv rw [Nat.mod_eq_of_lt (by omega : n - 1 < n)] at hv; omega -- Derive ALL 4 clauses on `{eOf 0, eOf (n - 1)}` in width ≤ 2! have hall4 : ∀ a b : Bool, ∃ π, IsResProof (TseitinCNF (cycleGraph n) χ) π ∧ cl2 (eOf 0) a (eOf (n - 1)) b ∈ π ∧ ∀ C ∈ π, width C ≤ 2 := by intro a b by_cases h1 : ((if a = false then (1 : ZMod 2) else 0) + (if b = false then (1 : ZMod 2) else 0)) ≠ psum (n - 1) · exact hderive_step (n - 1) (by omega) (by omega) a b h1 · push Not at h1 have h2 : ((if b = false then (1 : ZMod 2) else 0) + (if a = false then (1 : ZMod 2) else 0)) ≠ χ ⟨0, by omega⟩ := zmod2_cycle_close a b (psum (n - 1)) (χ ⟨0, by omega⟩) htotal h1 have hax := hcl2_ax 0 (by omega) b a h2 rw [he_n1] at hax have hswap : cl2 (eOf (n - 1)) b (eOf 0) a = cl2 (eOf 0) a (eOf (n - 1)) b := by funext e simp only [cl2] by_cases h0 : e = eOf 0 · subst h0; simp [Function.update_of_ne h0_n1] · by_cases h1' : e = eOf (n - 1) · subst h1'; simp [Function.update_of_ne h0_n1.symm] · simp [Function.update_of_ne h0, Function.update_of_ne h1', emptyClause] rw [hswap] at hax refine ⟨[cl2 (eOf 0) a (eOf (n - 1)) b], ?_, by simp, fun C hC => ?_⟩ · intro i hi have hi0 : i = 0 := by simpa using hi subst hi0; exact Or.inl hax · simp only [List.mem_singleton] at hC; subst hC; exact hw_cl2 _ _ _ _ -- Combine all 4 clauses `(T,T), (T,F), (F,T), (F,F)` via 3 resolution steps to get `emptyClause`! rcases hall4 true true with ⟨π1, hP1, hm1, hw1⟩ rcases hall4 true false with ⟨π2, hP2, hm2, hw2⟩ rcases hall4 false true with ⟨π3, hP3, hm3, hw3⟩ rcases hall4 false false with ⟨π4, hP4, hm4, hw4⟩ let πbase := π1 ++ π2 ++ π3 ++ π4 have hPbase : IsResProof (TseitinCNF (cycleGraph n) χ) πbase := isResProof_append (isResProof_append (isResProof_append hP1 hP2) hP3) hP4 have hwbase : ∀ C ∈ πbase, width C ≤ 2 := by intro C hC simp only [πbase, List.mem_append] at hC rcases hC with ((h | h) | h) | h · exact hw1 C h · exact hw2 C h · exact hw3 C h · exact hw4 C h have hm1' : cl2 (eOf 0) true (eOf (n - 1)) true ∈ πbase := by simp [πbase, hm1] have hm2' : cl2 (eOf 0) true (eOf (n - 1)) false ∈ πbase := by simp [πbase, hm2] have hm3' : cl2 (eOf 0) false (eOf (n - 1)) true ∈ πbase := by simp [πbase, hm3] have hm4' : cl2 (eOf 0) false (eOf (n - 1)) false ∈ πbase := by simp [πbase, hm4] rcases List.mem_iff_getElem.mp hm1' with ⟨i1, hi1, h1eq⟩ rcases List.mem_iff_getElem.mp hm2' with ⟨i2, hi2, h2eq⟩ rcases List.mem_iff_getElem.mp hm3' with ⟨i3, hi3, h3eq⟩ rcases List.mem_iff_getElem.mp hm4' with ⟨i4, hi4, h4eq⟩ have hr_top : ∀ a : Bool, Resolves (cl2 (eOf 0) a (eOf (n - 1)) true) (cl2 (eOf 0) a (eOf (n - 1)) false) (eOf (n - 1)) (unitClause (eOf 0) a) := by intro a refine ⟨by simp [cl2], by simp [cl2], ?_, by simp [unitClause, Function.update_of_ne h0_n1.symm, emptyClause], ?_⟩ · intro u hu b₁ b₂ h1 h2 simp only [cl2, Function.update_of_ne hu] at h1 h2 rw [h1] at h2; cases h2; rfl · intro u hu simp only [cl2, unitClause, Function.update_of_ne hu] by_cases h0 : u = eOf 0 · subst h0; simp · simp [Function.update_of_ne h0, emptyClause] have hr_bot : Resolves (unitClause (eOf 0) true) (unitClause (eOf 0) false) (eOf 0) emptyClause := by refine ⟨by simp [unitClause], by simp [unitClause], ?_, rfl, ?_⟩ · intro u hu b₁ _ h1; simp [unitClause, Function.update_of_ne hu, emptyClause] at h1 · intro u hu; simp [unitClause, Function.update_of_ne hu, emptyClause] let πfinal := πbase ++ [unitClause (eOf 0) true, unitClause (eOf 0) false, emptyClause] refine ⟨πfinal, ⟨?_, by simp [πfinal]⟩, ?_⟩ · intro idx hidx by_cases hlt : idx < πbase.length · rw [show πfinal[idx] = πbase[idx] from List.getElem_append_left hlt] rcases hPbase idx hlt with hm | ⟨x, y, hx, hy, w, hr⟩ · exact Or.inl hm · right; refine ⟨x, y, hx, hy, w, ?_⟩ simpa [πfinal, List.getElem_append_left (Nat.lt_trans hx hlt), List.getElem_append_left (Nat.lt_trans hy hlt)] using hr · by_cases h1 : idx = πbase.length · subst h1; right refine ⟨i1, i2, hi1, hi2, eOf (n - 1), ?_⟩ simpa [πfinal, List.getElem_append_left hi1, List.getElem_append_left hi2, h1eq, h2eq, List.getElem_append_right (le_refl _)] using hr_top true · by_cases h2 : idx = πbase.length + 1 · subst h2; right refine ⟨i3, i4, by omega, by omega, eOf (n - 1), ?_⟩ simpa [πfinal, List.getElem_append_left hi3, List.getElem_append_left hi4, h3eq, h4eq, List.getElem_append_right (Nat.le_succ _)] using hr_top false · have h3 : idx = πbase.length + 2 := by have : idx < πbase.length + 3 := by simpa [πfinal] using hidx omega subst h3; right refine ⟨πbase.length, πbase.length + 1, by omega, by omega, eOf 0, ?_⟩ simpa [πfinal, List.getElem_append_right (le_refl _), List.getElem_append_right (Nat.le_succ _), List.getElem_append_right (by omega : πbase.length ≤ πbase.length + 2)] using hr_bot · intro C hC simp only [πfinal, List.mem_append, List.mem_cons, List.not_mem_nil, or_false] at hC rcases hC with h | rfl | rfl | rfl · exact hwbase C h · rw [width_unit]; omega · rw [width_unit]; omega · rw [width_empty]; omega end TseitinRes -- ------------------------------------------------------------------------------ -- 2B. Functional Pigeonhole Principle (FPHP_n^m): Width ≥ n & Exact Tree-Like Size ≥ 2^n + n -- ------------------------------------------------------------------------------ section FPHP /-- Pigeon clause `P_i = ⋁_{j : Fin n} p_{i, j}` (width `n`). -/ def pigeonClause (m n : ℕ) (i : Fin m) : Clause (Fin m × Fin n) := fun x => if x.1 = i then some true else none /-- Hole injectivity clause `H_{i, i', j} = ¬p_{i, j} ∨ ¬p_{i', j}` (`i ≠ i'`, width `2`). -/ def holeClause (m n : ℕ) (i i' : Fin m) (j : Fin n) : Clause (Fin m × Fin n) := fun x => if x = (i, j) ∨ x = (i', j) then some false else none /-- Functionality clause `F_{i, j, j'} = ¬p_{i, j} ∨ ¬p_{i, j'}` (`j ≠ j'`, width `2`). -/ def funcClause (m n : ℕ) (i : Fin m) (j j' : Fin n) : Clause (Fin m × Fin n) := fun x => if x = (i, j) ∨ x = (i, j') then some false else none /-- Functional Pigeonhole Principle CNF `FPHPCNF m n` (`m` pigeons into `n` holes). -/ def FPHPCNF (m n : ℕ) : Set (Clause (Fin m × Fin n)) := { C | (∃ i : Fin m, C = pigeonClause m n i) ∨ (∃ (i i' : Fin m) (j : Fin n), i ≠ i' ∧ C = holeClause m n i i' j) ∨ (∃ (i : Fin m) (j j' : Fin n), j ≠ j' ∧ C = funcClause m n i j j') } /-- **Headline Theorem 2G (Functional Pigeonhole Principle Unsatisfiability):** For all `n < m`, `FPHPCNF m n` is unsatisfiable. -/ theorem fphp_unsat {m n : ℕ} (hnm : n < m) : ¬ ∃ α, evalCNF (FPHPCNF m n) α := by rintro ⟨α, hα⟩ have hmap : ∀ i : Fin m, ∃ j : Fin n, α (i, j) = true := by intro i rcases hα (pigeonClause m n i) (Or.inl ⟨i, rfl⟩) with ⟨⟨i', j⟩, b, hcb, hab⟩ simp only [pigeonClause] at hcb split_ifs at hcb with hi · subst hi; cases hcb; exact ⟨j, hab⟩ choose f hf using hmap have hinj : Function.Injective f := by intro i₁ i₂ heq by_contra hne rcases hα (holeClause m n i₁ i₂ (f i₁)) (Or.inr (Or.inl ⟨i₁, i₂, f i₁, hne, rfl⟩)) with ⟨x, b, hcb, hab⟩ simp only [holeClause] at hcb split_ifs at hcb with hx · cases hcb rcases hx with rfl | rfl · rw [hf i₁] at hab; cases hab · rw [heq, hf i₂] at hab; cases hab have hle : Fintype.card (Fin m) ≤ Fintype.card (Fin n) := Fintype.card_le_of_injective f hinj simp only [Fintype.card_fin] at hle omega /-- Partial matching state `(M, Z)` for the zero-forced-move Prover–Delayer game on `FPHP_n^m`: - `M : Finset (Fin m × Fin n)` is a partial matching (`p_{i,j} = 1`), - `Z : Finset (Fin m × Fin n)` is the set of explicit `0`-choices on unmatched pairs. -/ structure PHPState (m n : ℕ) where M : Finset (Fin m × Fin n) Z : Finset (Fin m × Fin n) hMatchP : ∀ p₁ ∈ M, ∀ p₂ ∈ M, p₁.1 = p₂.1 → p₁ = p₂ hMatchH : ∀ p₁ ∈ M, ∀ p₂ ∈ M, p₁.2 = p₂.2 → p₁ = p₂ hDisj : Disjoint M Z /-- Consistency of a clause `C` being falsified by a `PHPState (M, Z)`: every literal `(x, true)` in `C` is forced to `false` by `(M, Z)`, and every literal `(x, false)` in `C` is forced to `true` by `(M, Z)` (i.e. `x ∈ M`). -/ def phpForcesFalse {m n : ℕ} (st : PHPState m n) (x : Fin m × Fin n) : Prop := (∃ j', (x.1, j') ∈ st.M ∧ j' ≠ x.2) ∨ (∃ i', (i', x.2) ∈ st.M ∧ i' ≠ x.1) ∨ x ∈ st.Z def phpFalsifies {m n : ℕ} (st : PHPState m n) (C : Clause (Fin m × Fin n)) : Prop := (∀ x, C x = some true → phpForcesFalse st x) ∧ (∀ x, C x = some false → x ∈ st.M) /-- Every partial matching `M` plus `0`-set `Z` with `|M| + |Z| < n` can NEVER falsify any clause of `FPHPCNF m n`! -/ lemma phpState_no_falsified_axiom {m n : ℕ} (st : PHPState m n) {C : Clause (Fin m × Fin n)} (hC : C ∈ FPHPCNF m n) (hfals : phpFalsifies st C) : n ≤ st.M.card + st.Z.card := by classical rcases hC with ⟨i, rfl⟩ | ⟨i, i', j, hne, rfl⟩ | ⟨i, j, j', hne, rfl⟩ · -- Pigeon clause `pigeonClause m n i`: every `(i, j)` has `phpForcesFalse st (i, j)`. by_cases hmatched : ∃ j₀, (i, j₀) ∈ st.M · rcases hmatched with ⟨j₀, hj₀⟩ have hf := hfals.1 (i, j₀) (by simp [pigeonClause]) rcases hf with ⟨j', hj', hne'⟩ | ⟨i', hi', hne'⟩ | hz · exact absurd (congrArg Prod.snd (st.hMatchP (i, j') hj' (i, j₀) hj₀ rfl)) hne' · exact absurd (congrArg Prod.fst (st.hMatchH (i', j₀) hi' (i, j₀) hj₀ rfl)) hne' · exact absurd hz (Finset.disjoint_left.mp st.hDisj hj₀) · push Not at hmatched -- Every hole `j : Fin n` is either matched in `st.M` or `(i, j) ∈ st.Z`! have hcov : (Finset.univ : Finset (Fin n)) ⊆ st.M.image Prod.snd ∪ st.Z.image Prod.snd := by intro j _ have hf := hfals.1 (i, j) (by simp [pigeonClause]) rcases hf with ⟨j', hj', _⟩ | ⟨i', hi', _⟩ | hz · exact absurd hj' (hmatched j') · exact Finset.mem_union_left _ (Finset.mem_image.mpr ⟨(i', j), hi', rfl⟩) · exact Finset.mem_union_right _ (Finset.mem_image.mpr ⟨(i, j), hz, rfl⟩) calc n = (Finset.univ : Finset (Fin n)).card := (Fintype.card_fin n).symm _ ≤ (st.M.image Prod.snd ∪ st.Z.image Prod.snd).card := Finset.card_le_card hcov _ ≤ (st.M.image Prod.snd).card + (st.Z.image Prod.snd).card := Finset.card_union_le _ _ _ ≤ st.M.card + st.Z.card := Nat.add_le_add Finset.card_image_le Finset.card_image_le · -- Hole clause `H_{i, i', j}`: impossible because `M` is a partial matching! have h1 : (i, j) ∈ st.M := hfals.2 (i, j) (by simp [holeClause]) have h2 : (i', j) ∈ st.M := hfals.2 (i', j) (by simp [holeClause]) exact absurd (congrArg Prod.fst (st.hMatchH (i, j) h1 (i', j) h2 rfl)) hne · -- Functionality clause `F_{i, j, j'}`: impossible because `M` is a partial matching! have h1 : (i, j) ∈ st.M := hfals.2 (i, j) (by simp [funcClause]) have h2 : (i, j') ∈ st.M := hfals.2 (i, j') (by simp [funcClause]) exact absurd (congrArg Prod.snd (st.hMatchP (i, j) h1 (i, j') h2 rfl)) hne /-- Adding an unmatched pair `x` to `M` yields a valid `PHPState`. -/ def phpAddM {m n : ℕ} (st : PHPState m n) (x : Fin m × Fin n) (hxM : x ∉ st.M) (hxF : ¬ phpForcesFalse st x) : PHPState m n where M := insert x st.M Z := st.Z hMatchP := by intro p₁ h1 p₂ h2 heq rcases Finset.mem_insert.mp h1 with h1x | h1' <;> rcases Finset.mem_insert.mp h2 with h2x | h2' · rw [h1x, h2x] · exfalso; apply hxF; left rw [h1x] at heq refine ⟨p₂.2, ?_, ?_⟩ · exact (Prod.ext heq rfl : (x.1, p₂.2) = p₂) ▸ h2' · intro h2eq; exact hxM ((Prod.ext heq h2eq.symm : x = p₂) ▸ h2') · exfalso; apply hxF; left rw [h2x] at heq refine ⟨p₁.2, ?_, ?_⟩ · exact (Prod.ext heq.symm rfl : (x.1, p₁.2) = p₁) ▸ h1' · intro h1eq; exact hxM ((Prod.ext heq.symm h1eq.symm : x = p₁) ▸ h1') · exact st.hMatchP p₁ h1' p₂ h2' heq hMatchH := by intro p₁ h1 p₂ h2 heq rcases Finset.mem_insert.mp h1 with h1x | h1' <;> rcases Finset.mem_insert.mp h2 with h2x | h2' · rw [h1x, h2x] · exfalso; apply hxF; right; left rw [h1x] at heq refine ⟨p₂.1, ?_, ?_⟩ · exact (Prod.ext rfl heq : (p₂.1, x.2) = p₂) ▸ h2' · intro h2eq; exact hxM ((Prod.ext h2eq.symm heq : x = p₂) ▸ h2') · exfalso; apply hxF; right; left rw [h2x] at heq refine ⟨p₁.1, ?_, ?_⟩ · exact (Prod.ext rfl heq.symm : (p₁.1, x.2) = p₁) ▸ h1' · intro h1eq; exact hxM ((Prod.ext h1eq.symm heq.symm : x = p₁) ▸ h1') · exact st.hMatchH p₁ h1' p₂ h2' heq hDisj := Finset.disjoint_insert_left.mpr ⟨fun hz => hxF (Or.inr (Or.inr hz)), st.hDisj⟩ /-- Adding an unmatched pair `x` to `Z` yields a valid `PHPState`. -/ def phpAddZ {m n : ℕ} (st : PHPState m n) (x : Fin m × Fin n) (hxM : x ∉ st.M) : PHPState m n where M := st.M Z := insert x st.Z hMatchP := st.hMatchP hMatchH := st.hMatchH hDisj := Finset.disjoint_insert_right.mpr ⟨hxM, st.hDisj⟩ /-- **Headline Theorem 2H (Resolution Width Lower Bound for `FPHP_n^m`):** For all `m > n ≥ 1`, every DAG Resolution refutation of `FPHPCNF m n` contains a clause of width at least `n`. -/ theorem fphp_resolution_width_lb {m n : ℕ} {π : List (Clause (Fin m × Fin n))} (hπ : IsResRefut (FPHPCNF m n) π) : ∃ C ∈ π, n ≤ width C := by by_contra hnarrow push Not at hnarrow -- Every pigeon clause has width `n`, so no pigeon clause can appear in `π`! -- Thus `π` is a valid Resolution refutation of only hole + functionality clauses, -- which are satisfied by the all-`false` assignment `α ≡ false`! let F_no_pig : Set (Clause (Fin m × Fin n)) := { C | (∃ (i i' : Fin m) (j : Fin n), i ≠ i' ∧ C = holeClause m n i i' j) ∨ (∃ (i : Fin m) (j j' : Fin n), j ≠ j' ∧ C = funcClause m n i j j') } have hproof_no_pig : IsResProof F_no_pig π := by intro idx hidx rcases hπ.1 idx hidx with hax | hres · left rcases hax with ⟨i, heq⟩ | h2 | h3 · exfalso have hw_lt : width π[idx] < n := hnarrow π[idx] (List.getElem_mem hidx) have hw_eq : width (pigeonClause m n i) = n := by have hset : (Finset.univ.filter fun x : Fin m × Fin n => (pigeonClause m n i x).isSome) = Finset.univ.image (fun j : Fin n => (i, j)) := by ext ⟨a, b⟩ simp only [Finset.mem_univ, true_and, Finset.mem_image, pigeonClause, Prod.mk.injEq] by_cases ha : a = i · subst ha; simp · simp [ha, Ne.symm ha] rw [width, hset, Finset.card_image_of_injective _ (fun _ _ h => (Prod.mk.inj h).2), Finset.card_univ, Fintype.card_fin] rw [heq, hw_eq] at hw_lt exact lt_irrefl _ hw_lt · exact Or.inl h2 · exact Or.inr h3 · exact Or.inr hres have hsat : evalCNF F_no_pig (fun _ => false) := by rintro C (⟨i, i', j, _, rfl⟩ | ⟨i, j, j', _, rfl⟩) · exact ⟨(i, j), false, by simp [holeClause], rfl⟩ · exact ⟨(i, j), false, by simp [funcClause], rfl⟩ exact resolution_sound ⟨hproof_no_pig, hπ.2⟩ ⟨fun _ => false, hsat⟩ /-- Base Prover–Delayer lemma for tree-like Resolution of `FPHP_n^m`: `2^(n - (|M| + |Z|)) ≤ treeLeaves t`. -/ lemma fphp_tree_base_lb {m n : ℕ} : ∀ {C : Clause (Fin m × Fin n)} (t : TreeRes (FPHPCNF m n) C) (st : PHPState m n), phpFalsifies st C → 2 ^ (n - (st.M.card + st.Z.card)) ≤ treeLeaves t := by intro C t induction t with | leaf C hC => intro st hfals have hge := phpState_no_falsified_axiom st hC hfals have hsub : n - (st.M.card + st.Z.card) = 0 := Nat.sub_eq_zero_of_le hge rw [hsub, pow_zero] exact le_refl 1 | @res C₁ C₂ C x t₁ t₂ hr ih1 ih2 => intro st hfals classical -- Helper: if `st` falsifies `C`, then `st` falsifies every literal of `C₁, C₂` away from `x`. have hC1_other : ∀ y ≠ x, (C₁ y = some true → phpForcesFalse st y) ∧ (C₁ y = some false → y ∈ st.M) := by intro y hy have hCy := hr.2.2.2.2 y hy constructor · intro h1; apply hfals.1 y; rw [hCy, h1]; rfl · intro h1; apply hfals.2 y; rw [hCy, h1]; rfl have hC2_other : ∀ y ≠ x, (C₂ y = some true → phpForcesFalse st y) ∧ (C₂ y = some false → y ∈ st.M) := by intro y hy have hCy := hr.2.2.2.2 y hy constructor · intro h2; apply hfals.1 y; rw [hCy] cases h1 : C₁ y with | none => simp [h2] | some b₁ => have := hr.2.2.1 y hy b₁ true h1 h2; subst this; simp · intro h2; apply hfals.2 y; rw [hCy] cases h1 : C₁ y with | none => simp [h2] | some b₁ => have := hr.2.2.1 y hy b₁ false h1 h2; subst this; simp by_cases hxM : x ∈ st.M · -- `x` is forced to `true`: follow `t₂`! have hf2 : phpFalsifies st C₂ := by refine ⟨fun y hy => ?_, fun y hy => ?_⟩ · by_cases hyx : y = x · subst hyx; rw [hr.2.1] at hy; cases hy · exact (hC2_other y hyx).1 hy · by_cases hyx : y = x · subst hyx; exact hxM · exact (hC2_other y hyx).2 hy have h2 := ih2 st hf2 simp only [treeLeaves]; omega · by_cases hxF : phpForcesFalse st x · -- `x` is forced to `false`: follow `t₁`! have hf1 : phpFalsifies st C₁ := by refine ⟨fun y hy => ?_, fun y hy => ?_⟩ · by_cases hyx : y = x · subst hyx; exact hxF · exact (hC1_other y hyx).1 hy · by_cases hyx : y = x · subst hyx; rw [hr.1] at hy; cases hy · exact (hC1_other y hyx).2 hy have h1 := ih1 st hf1 simp only [treeLeaves]; omega · -- `x` is undetermined: branch BOTH ways! let st1 := phpAddZ st x hxM let st2 := phpAddM st x hxM hxF have hxZ : x ∉ st.Z := fun hz => hxF (Or.inr (Or.inr hz)) have hcard1 : st1.M.card + st1.Z.card = st.M.card + st.Z.card + 1 := by simp only [st1, phpAddZ, Finset.card_insert_of_notMem hxZ]; omega have hcard2 : st2.M.card + st2.Z.card = st.M.card + st.Z.card + 1 := by simp only [st2, phpAddM, Finset.card_insert_of_notMem hxM]; omega have hf1 : phpFalsifies st1 C₁ := by refine ⟨fun y hy => ?_, fun y hy => ?_⟩ · by_cases hyx : y = x · subst hyx; exact Or.inr (Or.inr (Finset.mem_insert_self _ _)) · rcases (hC1_other y hyx).1 hy with h | h | h · exact Or.inl h · exact Or.inr (Or.inl h) · exact Or.inr (Or.inr (Finset.mem_insert_of_mem h)) · by_cases hyx : y = x · subst hyx; rw [hr.1] at hy; cases hy · exact (hC1_other y hyx).2 hy have hf2 : phpFalsifies st2 C₂ := by refine ⟨fun y hy => ?_, fun y hy => ?_⟩ · by_cases hyx : y = x · subst hyx; rw [hr.2.1] at hy; cases hy · rcases (hC2_other y hyx).1 hy with ⟨j', hj', hne⟩ | ⟨i', hi', hne⟩ | hz · exact Or.inl ⟨j', Finset.mem_insert_of_mem hj', hne⟩ · exact Or.inr (Or.inl ⟨i', Finset.mem_insert_of_mem hi', hne⟩) · exact Or.inr (Or.inr hz) · by_cases hyx : y = x · subst hyx; exact Finset.mem_insert_self _ _ · exact Finset.mem_insert_of_mem ((hC2_other y hyx).2 hy) have h1 := ih1 st1 hf1 have h2 := ih2 st2 hf2 rw [hcard1] at h1 rw [hcard2] at h2 by_cases hlt : st.M.card + st.Z.card < n · have hpow : 2 ^ (n - (st.M.card + st.Z.card)) = 2 ^ (n - (st.M.card + st.Z.card + 1)) + 2 ^ (n - (st.M.card + st.Z.card + 1)) := by have : n - (st.M.card + st.Z.card) = (n - (st.M.card + st.Z.card + 1)) + 1 := by omega rw [this, pow_succ]; ring simp only [treeLeaves]; omega · have hsub : n - (st.M.card + st.Z.card) = 0 := by omega rw [hsub, pow_zero] exact treeLeaves_pos _ /-- Strengthened all-`1`s path Prover–Delayer lemma for `FPHP_n^m`: tracking forced `0`-queries `F0` along `Z = ∅` adds an exact `+ (n - |F0|)` leaf bonus on top of `2^(n - |M|)`. -/ lemma fphp_tree_bonus_lb {m n : ℕ} : ∀ {C : Clause (Fin m × Fin n)} (t : TreeRes (FPHPCNF m n) C) (st : PHPState m n) (F0 : Finset (Fin m × Fin n)), st.Z = ∅ → phpFalsifies st C → (∀ x, C x = some true → x ∈ F0) → 2 ^ (n - st.M.card) + (n - F0.card) ≤ treeLeaves t := by intro C t induction t with | leaf C hC => intro st F0 hZ hfals hF0 have hMge : n ≤ st.M.card := by have := phpState_no_falsified_axiom st hC hfals simpa [hZ] using this -- `C` must be a pigeon clause `pigeonClause m n i`, so all `n` pairs `(i, j)` lie in `F0`. have hF0ge : n ≤ F0.card := by rcases hC with ⟨i, rfl⟩ | ⟨i, i', j, hne, rfl⟩ | ⟨i, j, j', hne, rfl⟩ · have hsub : (Finset.univ.image fun j : Fin n => (i, j)) ⊆ F0 := by intro x hx rcases Finset.mem_image.mp hx with ⟨j, _, rfl⟩ exact hF0 (i, j) (by simp [pigeonClause]) calc n = (Finset.univ.image fun j : Fin n => (i, j)).card := by rw [Finset.card_image_of_injective _ (fun _ _ h => (Prod.mk.inj h).2), Finset.card_univ, Fintype.card_fin] _ ≤ F0.card := Finset.card_le_card hsub · exfalso have h1 : (i, j) ∈ st.M := hfals.2 (i, j) (by simp [holeClause]) have h2 : (i', j) ∈ st.M := hfals.2 (i', j) (by simp [holeClause]) exact hne (congrArg Prod.fst (st.hMatchH (i, j) h1 (i', j) h2 rfl)) · exfalso have h1 : (i, j) ∈ st.M := hfals.2 (i, j) (by simp [funcClause]) have h2 : (i, j') ∈ st.M := hfals.2 (i, j') (by simp [funcClause]) exact hne (congrArg Prod.snd (st.hMatchP (i, j) h1 (i, j') h2 rfl)) have h1 : n - st.M.card = 0 := Nat.sub_eq_zero_of_le hMge have h2 : n - F0.card = 0 := Nat.sub_eq_zero_of_le hF0ge rw [h1, h2, pow_zero] exact le_refl 1 | @res C₁ C₂ C x t₁ t₂ hr ih1 ih2 => intro st F0 hZ hfals hF0 classical have hC1_other : ∀ y ≠ x, (C₁ y = some true → phpForcesFalse st y ∧ y ∈ F0) ∧ (C₁ y = some false → y ∈ st.M) := by intro y hy have hCy := hr.2.2.2.2 y hy refine ⟨fun h1 => ⟨hfals.1 y (by rw [hCy, h1]; rfl), hF0 y (by rw [hCy, h1]; rfl)⟩, fun h1 => hfals.2 y (by rw [hCy, h1]; rfl)⟩ have hC2_other : ∀ y ≠ x, (C₂ y = some true → phpForcesFalse st y ∧ y ∈ F0) ∧ (C₂ y = some false → y ∈ st.M) := by intro y hy have hCy := hr.2.2.2.2 y hy refine ⟨fun h2 => ?_, fun h2 => ?_⟩ · have hCt : C y = some true := by rw [hCy] cases h1 : C₁ y with | none => simp [h2] | some b₁ => have := hr.2.2.1 y hy b₁ true h1 h2; subst this; simp exact ⟨hfals.1 y hCt, hF0 y hCt⟩ · apply hfals.2 y; rw [hCy] cases h1 : C₁ y with | none => simp [h2] | some b₁ => have := hr.2.2.1 y hy b₁ false h1 h2; subst this; simp by_cases hxM : x ∈ st.M · have hf2 : phpFalsifies st C₂ := by refine ⟨fun y hy => ?_, fun y hy => ?_⟩ · by_cases hyx : y = x · subst hyx; rw [hr.2.1] at hy; cases hy · exact (hC2_other y hyx).1 hy |>.1 · by_cases hyx : y = x · subst hyx; exact hxM · exact (hC2_other y hyx).2 hy have hF02 : ∀ y, C₂ y = some true → y ∈ F0 := by intro y hy by_cases hyx : y = x · subst hyx; rw [hr.2.1] at hy; cases hy · exact (hC2_other y hyx).1 hy |>.2 have h2 := ih2 st F0 hZ hf2 hF02 simp only [treeLeaves]; omega · by_cases hxF : phpForcesFalse st x · -- Forced `0`-query: `t₂` peels off at least 1 leaf, while `F0` grows by at most 1! have hf1 : phpFalsifies st C₁ := by refine ⟨fun y hy => ?_, fun y hy => ?_⟩ · by_cases hyx : y = x · subst hyx; exact hxF · exact (hC1_other y hyx).1 hy |>.1 · by_cases hyx : y = x · subst hyx; rw [hr.1] at hy; cases hy · exact (hC1_other y hyx).2 hy have hF01 : ∀ y, C₁ y = some true → y ∈ insert x F0 := by intro y hy by_cases hyx : y = x · subst hyx; exact Finset.mem_insert_self _ _ · exact Finset.mem_insert_of_mem ((hC1_other y hyx).1 hy |>.2) have h1 := ih1 st (insert x F0) hZ hf1 hF01 have h2pos := treeLeaves_pos t₂ have hcard_ins : (insert x F0).card ≤ F0.card + 1 := Finset.card_insert_le _ _ simp only [treeLeaves]; omega · -- Free choice on `x`: `t₁` uses `fphp_tree_base_lb`, `t₂` keeps `Z = ∅` and `F0`! let st1 := phpAddZ st x hxM let st2 := phpAddM st x hxM hxF have hxZ : x ∉ st.Z := by simp [hZ] have hcard1 : st1.M.card + st1.Z.card = st.M.card + 1 := by simp [st1, phpAddZ, hZ] have hcard2 : st2.M.card = st.M.card + 1 := by simp [st2, phpAddM, Finset.card_insert_of_notMem hxM] have hf1 : phpFalsifies st1 C₁ := by refine ⟨fun y hy => ?_, fun y hy => ?_⟩ · by_cases hyx : y = x · subst hyx; exact Or.inr (Or.inr (Finset.mem_insert_self _ _)) · rcases (hC1_other y hyx).1 hy |>.1 with h | h | h · exact Or.inl h · exact Or.inr (Or.inl h) · exact Or.inr (Or.inr (Finset.mem_insert_of_mem h)) · by_cases hyx : y = x · subst hyx; rw [hr.1] at hy; cases hy · exact (hC1_other y hyx).2 hy have hf2 : phpFalsifies st2 C₂ := by refine ⟨fun y hy => ?_, fun y hy => ?_⟩ · by_cases hyx : y = x · subst hyx; rw [hr.2.1] at hy; cases hy · rcases (hC2_other y hyx).1 hy |>.1 with ⟨j', hj', hne⟩ | ⟨i', hi', hne⟩ | hz · exact Or.inl ⟨j', Finset.mem_insert_of_mem hj', hne⟩ · exact Or.inr (Or.inl ⟨i', Finset.mem_insert_of_mem hi', hne⟩) · exact Or.inr (Or.inr hz) · by_cases hyx : y = x · subst hyx; exact Finset.mem_insert_self _ _ · exact Finset.mem_insert_of_mem ((hC2_other y hyx).2 hy) have hF02 : ∀ y, C₂ y = some true → y ∈ F0 := by intro y hy by_cases hyx : y = x · subst hyx; rw [hr.2.1] at hy; cases hy · exact (hC2_other y hyx).1 hy |>.2 have h1 := fphp_tree_base_lb t₁ st1 hf1 have h2 := ih2 st2 F0 hZ hf2 hF02 rw [hcard1] at h1 rw [hcard2] at h2 by_cases hlt : st.M.card < n · have hpow : 2 ^ (n - st.M.card) = 2 ^ (n - (st.M.card + 1)) + 2 ^ (n - (st.M.card + 1)) := by have : n - st.M.card = (n - (st.M.card + 1)) + 1 := by omega rw [this, pow_succ]; ring simp only [treeLeaves]; omega · have hsub : n - st.M.card = 0 := by omega have hsub1 : n - (st.M.card + 1) = 0 := by omega rw [hsub, pow_zero] rw [hsub1, pow_zero] at h1 h2 simp only [treeLeaves]; omega /-- **Headline Theorem 2I (Exact Exponential Tree-Like Resolution Size Lower Bound for `FPHP_n^m`):** For ALL `m, n : ℕ`, EVERY tree-like Resolution refutation `t` of the Functional Pigeonhole Principle `FPHPCNF m n` has at least `2^n + n` leaves! -/ theorem fphp_treelike_exact_size_lb (m n : ℕ) (t : TreeRes (FPHPCNF m n) emptyClause) : 2 ^ n + n ≤ treeLeaves t := by let st0 : PHPState m n := ⟨∅, ∅, fun _ h => by simp at h, fun _ h => by simp at h, Finset.disjoint_empty_left _⟩ have hf0 : phpFalsifies st0 emptyClause := ⟨fun _ h => by simp [emptyClause] at h, fun _ h => by simp [emptyClause] at h⟩ have h := fphp_tree_bonus_lb t st0 ∅ rfl hf0 (fun _ h => by simp [emptyClause] at h) simpa [st0] using h /-- **Headline Theorem 2J (Exact Sharpness of `2^n + n` at `n = 1, m = 2`):** `FPHPCNF 2 1` admits an explicit tree-like Resolution refutation with EXACTLY `3 = 2^1 + 1` leaves, matching `fphp_treelike_exact_size_lb` with equality. -/ theorem fphp12_treelike_exact_sharpness : ∃ t : TreeRes (FPHPCNF 2 1) emptyClause, treeLeaves t = 2 ^ 1 + 1 := by let p0 : Fin 2 × Fin 1 := (⟨0, by omega⟩, ⟨0, by omega⟩) let p1 : Fin 2 × Fin 1 := (⟨1, by omega⟩, ⟨0, by omega⟩) have hp01 : p0 ≠ p1 := by decide let tP0 : TreeRes (FPHPCNF 2 1) (pigeonClause 2 1 ⟨0, by omega⟩) := TreeRes.leaf _ (Or.inl ⟨⟨0, by omega⟩, rfl⟩) let tP1 : TreeRes (FPHPCNF 2 1) (pigeonClause 2 1 ⟨1, by omega⟩) := TreeRes.leaf _ (Or.inl ⟨⟨1, by omega⟩, rfl⟩) let tH : TreeRes (FPHPCNF 2 1) (holeClause 2 1 ⟨0, by omega⟩ ⟨1, by omega⟩ ⟨0, by omega⟩) := TreeRes.leaf _ (Or.inr (Or.inl ⟨⟨0, by omega⟩, ⟨1, by omega⟩, ⟨0, by omega⟩, by decide, rfl⟩)) have hr1 : Resolves (pigeonClause 2 1 ⟨0, by omega⟩) (holeClause 2 1 ⟨0, by omega⟩ ⟨1, by omega⟩ ⟨0, by omega⟩) p0 (unitClause p1 false) := by refine ⟨by simp [pigeonClause, p0], by simp [holeClause, p0], ?_, by simp [unitClause, Function.update_of_ne hp01, emptyClause], ?_⟩ · intro u hu b₁ _ h1 rcases u with ⟨⟨a, ha⟩, ⟨b, hb⟩⟩ have hb0 : b = 0 := by omega subst hb0 have ha1 : a = 1 := by by_contra hne have ha0 : a = 0 := by omega subst ha0; exact hu rfl subst ha1; simp [pigeonClause] at h1 · intro u hu rcases u with ⟨⟨a, ha⟩, ⟨b, hb⟩⟩ have hb0 : b = 0 := by omega subst hb0 have ha1 : a = 1 := by by_contra hne have ha0 : a = 0 := by omega subst ha0; exact hu rfl subst ha1 simp [pigeonClause, holeClause, unitClause, p1] have hr2 : Resolves (pigeonClause 2 1 ⟨1, by omega⟩) (unitClause p1 false) p1 emptyClause := by refine ⟨by simp [pigeonClause, p1], by simp [unitClause], ?_, rfl, ?_⟩ · intro u hu _ b₂ _ h2 simp [unitClause, Function.update_of_ne hu, emptyClause] at h2 · intro u hu rcases u with ⟨⟨a, ha⟩, ⟨b, hb⟩⟩ have hb0 : b = 0 := by omega subst hb0 have ha0 : a = 0 := by by_contra hne have ha1 : a = 1 := by omega subst ha1; exact hu rfl subst ha0 have h00 : ((⟨0, ha⟩, ⟨0, hb⟩) : Fin 2 × Fin 1) ≠ p1 := hu simp only [pigeonClause, unitClause, emptyClause] rw [Function.update_of_ne h00] simp [emptyClause] refine ⟨TreeRes.res p1 tP1 (TreeRes.res p0 tP0 tH hr1) hr2, rfl⟩ end FPHP end Pillar2 -- ============================================================================== -- SECTION 3 (PILLAR 3): UNIFIED DYNAMIC POLYNOMIAL CALCULUS (CHAR ≠ 2) & -- SUM-OF-SQUARES LOWER BOUNDS FOR TSEITIN + EXACT C_n SEPARATION -- ============================================================================== section Pillar3 -- ------------------------------------------------------------------------------ -- 3A. Dynamic Polynomial Calculus & Sum-of-Squares Definitions on MvPolynomial -- ------------------------------------------------------------------------------ /-- Dynamic Polynomial Calculus (PC) derivation of `p` from polynomial axioms `axioms` with degree bound `D` over an arbitrary field `F`: - Axioms of degree `≤ D`, - Addition and scalar multiplication, - Multiplication by a single variable `X e` when `totalDegree p + 1 ≤ D`. -/ inductive PCDerives {E : Type*} (F : Type*) [Field F] (axioms : Set (MvPolynomial E F)) (D : ℕ) : MvPolynomial E F → Prop | ax {p : MvPolynomial E F} (hp : p ∈ axioms) (hd : p.totalDegree ≤ D) : PCDerives F axioms D p | add {p q : MvPolynomial E F} (hp : PCDerives F axioms D p) (hq : PCDerives F axioms D q) : PCDerives F axioms D (p + q) | smul (c : F) {p : MvPolynomial E F} (hp : PCDerives F axioms D p) : PCDerives F axioms D (c • p) | mul_var (e : E) {p : MvPolynomial E F} (hp : PCDerives F axioms D p) (hd : p.totalDegree + 1 ≤ D) : PCDerives F axioms D (MvPolynomial.X e * p) /-- A degree-`D` Dynamic PC refutation derives the unit polynomial `1`. -/ def PCRefutes {E : Type*} (F : Type*) [Field F] (axioms : Set (MvPolynomial E F)) (D : ℕ) : Prop := PCDerives F axioms D 1 lemma mvTotalDegree_X_le {E R : Type*} [CommSemiring R] (e : E) : (MvPolynomial.X e : MvPolynomial E R).totalDegree ≤ 1 := by by_cases h : Nontrivial R · rw [MvPolynomial.totalDegree_X] · rw [not_nontrivial_iff_subsingleton] at h have : (MvPolynomial.X e : MvPolynomial E R) = 0 := Subsingleton.elim _ _ rw [this]; simp lemma pcDerives_totalDegree_le {E : Type*} {F : Type*} [Field F] {axioms : Set (MvPolynomial E F)} {D : ℕ} {p : MvPolynomial E F} (h : PCDerives F axioms D p) : p.totalDegree ≤ D := by induction h with | ax _ hd => exact hd | add _ _ ihp ihq => exact le_trans (MvPolynomial.totalDegree_add _ _) (max_le ihp ihq) | smul c _ ihp => exact le_trans (MvPolynomial.totalDegree_smul_le c _) ihp | @mul_var e q _ hd _ => have hX := mvTotalDegree_X_le (R := F) e have hmul := MvPolynomial.totalDegree_mul (MvPolynomial.X e : MvPolynomial E F) q omega lemma pcDerives_mono {E : Type*} {F : Type*} [Field F] {axioms : Set (MvPolynomial E F)} {D₁ D₂ : ℕ} (hD : D₁ ≤ D₂) {p : MvPolynomial E F} (h : PCDerives F axioms D₁ p) : PCDerives F axioms D₂ p := by induction h with | ax hp hd => exact PCDerives.ax hp (le_trans hd hD) | add _ _ ihp ihq => exact PCDerives.add ihp ihq | smul c _ ihp => exact PCDerives.smul c ihp | mul_var e _ hd ihp => exact PCDerives.mul_var e ihp (le_trans hd hD) /-- Sum-of-Squares (Positivstellensatz) refutation of degree `D` over `ℝ`: `-1 = ∑ p_i^2 + ∑ q_j * g_j` with `2 * deg(p_i) ≤ D`, `g_j ∈ axioms`, and `deg(q_j) + deg(g_j) ≤ D`. -/ def SoSRefutes {E : Type*} (axioms : Set (MvPolynomial E ℝ)) (D : ℕ) : Prop := ∃ (squares : List (MvPolynomial E ℝ)) (idealTerms : List (MvPolynomial E ℝ × MvPolynomial E ℝ)), (∀ p ∈ squares, 2 * p.totalDegree ≤ D) ∧ (∀ t ∈ idealTerms, t.2 ∈ axioms ∧ t.1.totalDegree + t.2.totalDegree ≤ D) ∧ (-1 : MvPolynomial E ℝ) = (squares.map fun p => p ^ 2).sum + (idealTerms.map fun t => t.1 * t.2).sum lemma sosRefutes_mono {E : Type*} {axioms : Set (MvPolynomial E ℝ)} {D₁ D₂ : ℕ} (hD : D₁ ≤ D₂) (h : SoSRefutes axioms D₁) : SoSRefutes axioms D₂ := by rcases h with ⟨sq, idt, hsq, hidt, heq⟩ exact ⟨sq, idt, fun p hp => le_trans (hsq p hp) hD, fun t ht => ⟨(hidt t ht).1, le_trans (hidt t ht).2 hD⟩, heq⟩ -- ------------------------------------------------------------------------------ -- 3B. Exact Degree-Preserving Fourier (±1) ↔ Boolean ({0,1}) PC Isomorphism (char ≠ 2) -- ------------------------------------------------------------------------------ /-- Affine map `x_e ↦ 1 - 2 y_e` transforming Fourier `±1` polynomials to Boolean `{0,1}` ones. -/ noncomputable def fourierToBool {E : Type*} (F : Type*) [Field F] : MvPolynomial E F →ₐ[F] MvPolynomial E F := MvPolynomial.aeval fun e => (1 : MvPolynomial E F) - MvPolynomial.C (2 : F) * MvPolynomial.X e /-- Inverse affine map `y_e ↦ (1/2)(1 - x_e)` transforming Boolean `{0,1}` polynomials to `±1`. -/ noncomputable def boolToFourier {E : Type*} (F : Type*) [Field F] : MvPolynomial E F →ₐ[F] MvPolynomial E F := MvPolynomial.aeval fun e => MvPolynomial.C ((2 : F)⁻¹) * ((1 : MvPolynomial E F) - MvPolynomial.X e) lemma totalDegree_aeval_linear_le {E : Type*} {F : Type*} [Field F] (f : E → MvPolynomial E F) (hf : ∀ e, (f e).totalDegree ≤ 1) (p : MvPolynomial E F) : (MvPolynomial.aeval f p).totalDegree ≤ p.totalDegree := by classical conv_lhs => rw [MvPolynomial.as_sum p, map_sum] refine le_trans (MvPolynomial.totalDegree_finsetSum _ _) ?_ rw [Finset.sup_le_iff] intro m hm rw [MvPolynomial.aeval_monomial, MvPolynomial.algebraMap_eq] have hprod : (m.prod fun e k => f e ^ k).totalDegree ≤ m.sum fun _ k => k := by rw [Finsupp.prod, Finsupp.sum] refine le_trans (MvPolynomial.totalDegree_finsetProd _ _) ?_ apply Finset.sum_le_sum intro e _ calc (f e ^ m e).totalDegree ≤ m e * (f e).totalDegree := MvPolynomial.totalDegree_pow _ _ _ ≤ m e * 1 := Nat.mul_le_mul_left _ (hf e) _ = m e := Nat.mul_one _ calc (MvPolynomial.C (MvPolynomial.coeff m p) * m.prod fun e k => f e ^ k).totalDegree ≤ (MvPolynomial.C (MvPolynomial.coeff m p)).totalDegree + (m.prod fun e k => f e ^ k).totalDegree := MvPolynomial.totalDegree_mul _ _ _ = (m.prod fun e k => f e ^ k).totalDegree := by simp _ ≤ m.sum fun _ k => k := hprod _ ≤ p.totalDegree := MvPolynomial.le_totalDegree hm lemma fourierToBool_comp_boolToFourier {E : Type*} {F : Type*} [Field F] (h2 : (2 : F) ≠ 0) (p : MvPolynomial E F) : fourierToBool F (boolToFourier F p) = p := by have hcomp : (fourierToBool F).comp (boolToFourier F) = AlgHom.id F (MvPolynomial E F) := by apply MvPolynomial.algHom_ext intro e simp only [AlgHom.comp_apply, AlgHom.id_apply, boolToFourier, fourierToBool, MvPolynomial.aeval_X, map_mul, map_sub, map_one, MvPolynomial.aeval_C, MvPolynomial.algebraMap_eq] have hinv : (MvPolynomial.C (2 : F)⁻¹ : MvPolynomial E F) * MvPolynomial.C (2 : F) = 1 := by rw [← map_mul, inv_mul_cancel₀ h2, map_one] calc (MvPolynomial.C (2 : F)⁻¹ : MvPolynomial E F) * (1 - (1 - MvPolynomial.C 2 * MvPolynomial.X e)) = (MvPolynomial.C (2 : F)⁻¹ * MvPolynomial.C 2) * MvPolynomial.X e := by ring _ = MvPolynomial.X e := by rw [hinv, one_mul] exact AlgHom.congr_fun hcomp p lemma boolToFourier_comp_fourierToBool {E : Type*} {F : Type*} [Field F] (h2 : (2 : F) ≠ 0) (p : MvPolynomial E F) : boolToFourier F (fourierToBool F p) = p := by have hcomp : (boolToFourier F).comp (fourierToBool F) = AlgHom.id F (MvPolynomial E F) := by apply MvPolynomial.algHom_ext intro e simp only [AlgHom.comp_apply, AlgHom.id_apply, boolToFourier, fourierToBool, MvPolynomial.aeval_X, map_mul, map_sub, map_one, MvPolynomial.aeval_C, MvPolynomial.algebraMap_eq] have hinv : (MvPolynomial.C (2 : F) : MvPolynomial E F) * MvPolynomial.C (2 : F)⁻¹ = 1 := by rw [← map_mul, mul_inv_cancel₀ h2, map_one] calc (1 : MvPolynomial E F) - MvPolynomial.C 2 * (MvPolynomial.C (2 : F)⁻¹ * (1 - MvPolynomial.X e)) = 1 - (MvPolynomial.C 2 * MvPolynomial.C (2 : F)⁻¹) * (1 - MvPolynomial.X e) := by ring _ = MvPolynomial.X e := by rw [hinv, one_mul]; ring exact AlgHom.congr_fun hcomp p lemma totalDegree_fourierToBool {E : Type*} {F : Type*} [Field F] (h2 : (2 : F) ≠ 0) (p : MvPolynomial E F) : (fourierToBool F p).totalDegree = p.totalDegree := by have hle1 : (fourierToBool F p).totalDegree ≤ p.totalDegree := by apply totalDegree_aeval_linear_le intro e refine le_trans (MvPolynomial.totalDegree_sub _ _) (max_le (by simp) ?_) exact le_trans (MvPolynomial.totalDegree_mul _ _) (by simp) have hle2 : (boolToFourier F (fourierToBool F p)).totalDegree ≤ (fourierToBool F p).totalDegree := by apply totalDegree_aeval_linear_le intro e refine le_trans (MvPolynomial.totalDegree_mul _ _) ?_ simp only [MvPolynomial.totalDegree_C, zero_add] exact le_trans (MvPolynomial.totalDegree_sub _ _) (max_le (by simp) (mvTotalDegree_X_le e)) rw [boolToFourier_comp_fourierToBool h2] at hle2 exact le_antisymm hle1 hle2 lemma totalDegree_boolToFourier {E : Type*} {F : Type*} [Field F] (h2 : (2 : F) ≠ 0) (p : MvPolynomial E F) : (boolToFourier F p).totalDegree = p.totalDegree := by have := totalDegree_fourierToBool h2 (boolToFourier F p) rw [fourierToBool_comp_boolToFourier h2] at this exact this.symm /-- **Headline Theorem 3A (Exact Degree-Preserving Fourier ↔ Boolean Dynamic PC Isomorphism):** Over ANY field `F` with `(2 : F) ≠ 0`, `fourierToBool F` transports degree-`D` Dynamic PC derivations bijectively with exact degree preservation between Fourier (`±1`) and Boolean (`{0, 1}`) axiom systems! -/ theorem pc_fourier_boolean_iso {E : Type*} {F : Type*} [Field F] (h2 : (2 : F) ≠ 0) (axioms : Set (MvPolynomial E F)) (D : ℕ) : PCRefutes F (fourierToBool F '' axioms) D ↔ PCRefutes F axioms D := by have htrans : ∀ (φ : MvPolynomial E F →ₐ[F] MvPolynomial E F) (hdeg : ∀ p, (φ p).totalDegree = p.totalDegree) (hlin : ∀ e, ∃ a b : F, φ (MvPolynomial.X e) = MvPolynomial.C a + MvPolynomial.C b * MvPolynomial.X e) (A : Set (MvPolynomial E F)) (p : MvPolynomial E F), PCDerives F A D p → PCDerives F (φ '' A) D (φ p) := by intro φ hdeg hlin A p hp induction hp with | ax hmem hd => exact PCDerives.ax ⟨_, hmem, rfl⟩ (by rw [hdeg]; exact hd) | add _ _ ih1 ih2 => rw [map_add]; exact PCDerives.add ih1 ih2 | smul c _ ih => rw [map_smul]; exact PCDerives.smul c ih | @mul_var e q hq hd ih => rw [map_mul] rcases hlin e with ⟨a, b, heq⟩ rw [heq, add_mul, mul_assoc] have h1 : PCDerives F (φ '' A) D (MvPolynomial.C a * φ q) := by simpa [MvPolynomial.smul_eq_C_mul] using PCDerives.smul a ih have h2 : PCDerives F (φ '' A) D (MvPolynomial.C b * (MvPolynomial.X e * φ q)) := by have hmul := PCDerives.mul_var e ih (by rw [hdeg]; exact hd) simpa [MvPolynomial.smul_eq_C_mul] using PCDerives.smul b hmul exact PCDerives.add h1 h2 constructor · intro h have h1 := htrans (boolToFourier F) (totalDegree_boolToFourier h2) (fun e => ⟨(2 : F)⁻¹, -(2 : F)⁻¹, by simp only [boolToFourier, MvPolynomial.aeval_X, map_neg] ring⟩) (fourierToBool F '' axioms) 1 h have himg : boolToFourier F '' (fourierToBool F '' axioms) = axioms := by ext p; simp only [Set.mem_image] constructor · rintro ⟨_, ⟨q, hq, rfl⟩, rfl⟩ rwa [boolToFourier_comp_fourierToBool h2] · intro hp exact ⟨fourierToBool F p, ⟨p, hp, rfl⟩, boolToFourier_comp_fourierToBool h2 p⟩ rw [himg, map_one] at h1 exact h1 · intro h have h1 := htrans (fourierToBool F) (totalDegree_fourierToBool h2) (fun e => ⟨1, -2, by simp only [fourierToBool, MvPolynomial.aeval_X, map_neg, map_one] ring⟩) axioms 1 h rwa [map_one] at h1 -- ------------------------------------------------------------------------------ -- 3C. Multilinear Reduction mod (X_e^2 - 1) and Tseitin Cut-Equivalence Operator -- ------------------------------------------------------------------------------ section MultilinearPM1 variable {E : Type*} [DecidableEq E] /-- Odd-exponent support of a monomial `m : E →₀ ℕ`: variables with odd exponent. -/ def oddSupport (m : E →₀ ℕ) : Finset E := m.support.filter fun e => Odd (m e) omit [DecidableEq E] in lemma oddSupport_zero : oddSupport (0 : E →₀ ℕ) = ∅ := by simp [oddSupport] omit [DecidableEq E] in lemma mem_oddSupport (m : E →₀ ℕ) (e : E) : e ∈ oddSupport m ↔ Odd (m e) := by simp only [oddSupport, Finset.mem_filter, Finsupp.mem_support_iff, and_iff_right_iff_imp] intro h he; rw [he] at h; exact Nat.not_odd_zero h lemma oddSupport_single_one (e : E) : oddSupport (Finsupp.single e 1) = {e} := by ext x rw [mem_oddSupport, Finset.mem_singleton] by_cases hx : x = e · subst hx; simp · simp [Finsupp.single_eq_of_ne hx, hx] lemma oddSupport_single_two (e : E) : oddSupport (Finsupp.single e 2) = ∅ := by ext x rw [mem_oddSupport] simp only [Finset.notMem_empty, iff_false] by_cases hx : x = e · subst hx; simp · simp [Finsupp.single_eq_of_ne hx] lemma oddSupport_add (m₁ m₂ : E →₀ ℕ) : oddSupport (m₁ + m₂) = symmDiff (oddSupport m₁) (oddSupport m₂) := by ext e rw [Finset.mem_symmDiff, mem_oddSupport, mem_oddSupport, mem_oddSupport, Finsupp.add_apply] have hadd := Nat.odd_add (m := m₁ e) (n := m₂ e) constructor · intro hodd by_cases h1 : Odd (m₁ e) · left; refine ⟨h1, fun h2 => ?_⟩ exact Nat.not_even_iff_odd.mpr h2 ((hadd.mp hodd).mp h1) · right have h2 : Odd (m₂ e) := Nat.not_even_iff_odd.mp fun he2 => h1 ((hadd.mp hodd).mpr he2) exact ⟨h2, h1⟩ · rintro (⟨h1, h2⟩ | ⟨h2, h1⟩) · exact hadd.mpr ⟨fun _ => Nat.not_odd_iff_even.mp h2, fun _ => h1⟩ · exact hadd.mpr ⟨fun h => absurd h h1, fun h => absurd h (Nat.not_even_iff_odd.mpr h2)⟩ omit [DecidableEq E] in lemma card_oddSupport_le_sum (m : E →₀ ℕ) : (oddSupport m).card ≤ m.sum fun _ k => k := by calc (oddSupport m).card ≤ m.support.card := Finset.card_le_card (Finset.filter_subset _ _) _ = ∑ e ∈ m.support, 1 := by simp _ ≤ ∑ e ∈ m.support, m e := by apply Finset.sum_le_sum intro e he have hne : m e ≠ 0 := Finsupp.mem_support_iff.mp he omega _ = m.sum fun _ k => k := rfl /-- Reduction of `MvPolynomial E R` to multilinear `±1`-coefficients `Finset E → R` modulo `⟨X_e^2 - 1⟩`. -/ noncomputable def toMultilinearPM1 {R : Type*} [CommSemiring R] (p : MvPolynomial E R) : Finset E → R := fun A => ∑ m ∈ p.support, if oddSupport m = A then MvPolynomial.coeff m p else 0 lemma toMultilinearPM1_zero {R : Type*} [CommSemiring R] : toMultilinearPM1 (0 : MvPolynomial E R) = 0 := by funext A; simp [toMultilinearPM1] lemma toMultilinearPM1_add {R : Type*} [CommSemiring R] (p q : MvPolynomial E R) (A : Finset E) : toMultilinearPM1 (p + q) A = toMultilinearPM1 p A + toMultilinearPM1 q A := by classical let S := p.support ∪ q.support have h1 : toMultilinearPM1 (p + q) A = ∑ m ∈ S, if oddSupport m = A then MvPolynomial.coeff m (p + q) else 0 := by unfold toMultilinearPM1 refine Finset.sum_subset MvPolynomial.support_add ?_ intro m _ hnot have hc : MvPolynomial.coeff m (p + q) = 0 := by by_contra hne; exact hnot (MvPolynomial.mem_support_iff.mpr hne) simp [hc] have h2 : toMultilinearPM1 p A = ∑ m ∈ S, if oddSupport m = A then MvPolynomial.coeff m p else 0 := by unfold toMultilinearPM1 refine Finset.sum_subset Finset.subset_union_left ?_ intro m _ hnot have hc : MvPolynomial.coeff m p = 0 := by by_contra hne; exact hnot (MvPolynomial.mem_support_iff.mpr hne) simp [hc] have h3 : toMultilinearPM1 q A = ∑ m ∈ S, if oddSupport m = A then MvPolynomial.coeff m q else 0 := by unfold toMultilinearPM1 refine Finset.sum_subset Finset.subset_union_right ?_ intro m _ hnot have hc : MvPolynomial.coeff m q = 0 := by by_contra hne; exact hnot (MvPolynomial.mem_support_iff.mpr hne) simp [hc] rw [h1, h2, h3, ← Finset.sum_add_distrib] apply Finset.sum_congr rfl; intro m _ rw [MvPolynomial.coeff_add]; split_ifs <;> simp lemma toMultilinearPM1_smul {R : Type*} [CommSemiring R] (c : R) (p : MvPolynomial E R) (A : Finset E) : toMultilinearPM1 (c • p) A = c * toMultilinearPM1 p A := by classical have h1 : toMultilinearPM1 (c • p) A = ∑ m ∈ p.support, if oddSupport m = A then MvPolynomial.coeff m (c • p) else 0 := by unfold toMultilinearPM1 refine Finset.sum_subset (fun m hm => MvPolynomial.support_smul hm) ?_ intro m _ hnot have hc : MvPolynomial.coeff m (c • p) = 0 := by by_contra hne; exact hnot (MvPolynomial.mem_support_iff.mpr hne) simp [hc] rw [h1, toMultilinearPM1, Finset.mul_sum] apply Finset.sum_congr rfl; intro m _ rw [MvPolynomial.coeff_smul, smul_eq_mul]; split_ifs <;> simp lemma toMultilinearPM1_monomial {R : Type*} [CommSemiring R] (m : E →₀ ℕ) (c : R) (A : Finset E) : toMultilinearPM1 (MvPolynomial.monomial m c) A = if oddSupport m = A then c else 0 := by classical unfold toMultilinearPM1 by_cases hc : c = 0 · subst hc; simp · have hsupp : (MvPolynomial.monomial m c).support = {m} := MvPolynomial.support_monomial.trans (if_neg hc) rw [hsupp, Finset.sum_singleton, MvPolynomial.coeff_monomial, if_pos rfl] lemma toMultilinearPM1_one {R : Type*} [CommSemiring R] (A : Finset E) : toMultilinearPM1 (1 : MvPolynomial E R) A = if A = ∅ then 1 else 0 := by have h1 : (1 : MvPolynomial E R) = MvPolynomial.monomial 0 1 := rfl rw [h1, toMultilinearPM1_monomial, oddSupport_zero] by_cases h : A = ∅ <;> simp [h, eq_comm] lemma toMultilinearPM1_support_card_le {R : Type*} [CommSemiring R] {p : MvPolynomial E R} {A : Finset E} (h : toMultilinearPM1 p A ≠ 0) : A.card ≤ p.totalDegree := by unfold toMultilinearPM1 at h rcases Finset.exists_ne_zero_of_sum_ne_zero h with ⟨m, hm, hterm⟩ split_ifs at hterm with heq · rw [← heq] exact le_trans (card_oddSupport_le_sum m) (MvPolynomial.le_totalDegree hm) · exact absurd rfl hterm variable [Fintype E] lemma toMultilinearPM1_mul {R : Type*} [CommSemiring R] (p q : MvPolynomial E R) (A : Finset E) : toMultilinearPM1 (p * q) A = ∑ B : Finset E, toMultilinearPM1 p B * toMultilinearPM1 q (symmDiff B A) := by classical -- Prove by induction on `p` and `q` using `MvPolynomial.induction_on'`! induction p using MvPolynomial.induction_on' with | monomial m₁ c₁ => induction q using MvPolynomial.induction_on' with | monomial m₂ c₂ => rw [MvPolynomial.monomial_mul, toMultilinearPM1_monomial, oddSupport_add] simp_rw [toMultilinearPM1_monomial] rw [Finset.sum_eq_single (oddSupport m₁)] · simp only [↓reduceIte] have hiff : oddSupport m₂ = symmDiff (oddSupport m₁) A ↔ symmDiff (oddSupport m₁) (oddSupport m₂) = A := by constructor · intro h; rw [h, symmDiff_symmDiff_cancel_left] · intro h; rw [← h, symmDiff_symmDiff_cancel_left] by_cases h : symmDiff (oddSupport m₁) (oddSupport m₂) = A · rw [if_pos h, if_pos (hiff.mpr h)] · rw [if_neg h, if_neg (mt hiff.mp h), mul_zero] · intro B _ hne; rw [if_neg (Ne.symm hne), zero_mul] · intro h; exact absurd (Finset.mem_univ _) h | add q₁ q₂ ih1 ih2 => rw [mul_add, toMultilinearPM1_add, ih1, ih2, ← Finset.sum_add_distrib] apply Finset.sum_congr rfl; intro B _; rw [toMultilinearPM1_add, mul_add] | add p₁ p₂ ih1 ih2 => rw [add_mul, toMultilinearPM1_add, ih1, ih2, ← Finset.sum_add_distrib] apply Finset.sum_congr rfl; intro B _; rw [toMultilinearPM1_add, add_mul] lemma toMultilinearPM1_X_mul {R : Type*} [CommSemiring R] (e : E) (p : MvPolynomial E R) (A : Finset E) : toMultilinearPM1 (MvPolynomial.X e * p) A = toMultilinearPM1 p (symmDiff A {e}) := by rw [toMultilinearPM1_mul] have hX : (MvPolynomial.X e : MvPolynomial E R) = MvPolynomial.monomial (Finsupp.single e 1) 1 := rfl rw [hX] simp_rw [toMultilinearPM1_monomial, oddSupport_single_one] rw [Finset.sum_eq_single ({e} : Finset E)] · simp [symmDiff_comm] · intro B _ hne; rw [if_neg (Ne.symm hne), zero_mul] · intro h; exact absurd (Finset.mem_univ _) h omit [Fintype E] in lemma toMultilinearPM1_X_sq_sub_one {R : Type*} [CommRing R] (e : E) (A : Finset E) : toMultilinearPM1 ((MvPolynomial.X e : MvPolynomial E R) ^ 2 - 1) A = 0 := by have hsub : (MvPolynomial.X e : MvPolynomial E R) ^ 2 - 1 = MvPolynomial.monomial (Finsupp.single e 2) 1 + (-1 : R) • MvPolynomial.monomial 0 1 := by rw [sq, MvPolynomial.X, MvPolynomial.monomial_mul, ← Finsupp.single_add, one_mul, MvPolynomial.smul_monomial, smul_eq_mul, mul_one, show (1 : ℕ) + 1 = 2 from rfl, sub_eq_add_neg] have hneg1 : (-1 : MvPolynomial E R) = MvPolynomial.monomial 0 (-1) := by rw [← MvPolynomial.C_apply, map_neg, map_one] rw [hneg1] rw [hsub, toMultilinearPM1_add, toMultilinearPM1_smul, toMultilinearPM1_monomial, toMultilinearPM1_monomial, oddSupport_single_two, oddSupport_zero] split_ifs <;> ring lemma toMultilinearPM1_prod_X {R : Type*} [CommSemiring R] (S : Finset E) (A : Finset E) : toMultilinearPM1 (∏ e ∈ S, (MvPolynomial.X e : MvPolynomial E R)) A = if S = A then 1 else 0 := by induction S using Finset.induction generalizing A with | empty => simp [toMultilinearPM1_one, eq_comm] | @insert e S' he ih => rw [Finset.prod_insert he, toMultilinearPM1_X_mul, ih] have hiff : S' = symmDiff A {e} ↔ insert e S' = A := by constructor · intro h calc insert e S' = symmDiff S' {e} := by ext x; simp only [Finset.mem_insert, Finset.mem_symmDiff, Finset.mem_singleton] by_cases hx : x = e · subst hx; simp [he] · simp [hx] _ = symmDiff (symmDiff A {e}) {e} := by rw [h] _ = A := symmDiff_symmDiff_cancel_right {e} A · intro h rw [← h] ext x; simp only [Finset.mem_symmDiff, Finset.mem_insert, Finset.mem_singleton] by_cases hx : x = e · subst hx; simp [he] · simp [hx] by_cases h : insert e S' = A · rw [if_pos h, if_pos (hiff.mpr h)] · rw [if_neg h, if_neg (mt hiff.mp h)] end MultilinearPM1 -- ------------------------------------------------------------------------------ -- 3D. Tseitin Cut-Equivalence Operator: Unified Dynamic PC & SoS Lower Bounds -- ------------------------------------------------------------------------------ section TseitinAlgebraic variable {V : Type*} [Fintype V] [DecidableEq V] /-- Fourier (`±1`) Tseitin polynomial axioms for `(G, χ)` over any ring `R`: `X_e^2 - 1` for each edge `e` and `(∏_{e ∈ star v} X_e) - (-1)^{χ(v)}` for each vertex `v`. -/ def tseitinPCAxioms (G : SimpleGraph V) [DecidableRel G.Adj] (χ : V → ZMod 2) (R : Type*) [CommRing R] : Set (MvPolynomial (GEdge G) R) := { p | (∃ e : GEdge G, p = (MvPolynomial.X e) ^ 2 - 1) ∨ (∃ v : V, p = (∏ e ∈ vStar G v, MvPolynomial.X e) - MvPolynomial.C (if χ v = 1 then (-1 : R) else 1)) } /-- Edge-cut symmetry: `edgeCut G (S₁ ∆ S₂) = (edgeCut G S₁) ∆ (edgeCut G S₂)`. -/ lemma edgeCut_symmDiff (G : SimpleGraph V) [DecidableRel G.Adj] (S₁ S₂ : Finset V) : edgeCut G (symmDiff S₁ S₂) = symmDiff (edgeCut G S₁) (edgeCut G S₂) := by classical ext e rw [Finset.mem_symmDiff] simp only [edgeCut, Finset.mem_filter, Finset.mem_univ, true_and] rcases e with ⟨e_raw, he_mem⟩ induction e_raw using Sym2.ind with | _ u w => have hmem : ∀ T : Finset V, (∃ a b, s(u, w) = s(a, b) ∧ ((a ∈ T ∧ b ∉ T) ∨ (a ∉ T ∧ b ∈ T))) ↔ ((u ∈ T ∧ w ∉ T) ∨ (u ∉ T ∧ w ∈ T)) := by intro T; constructor · rintro ⟨a, b, hab, h⟩ rw [Sym2.eq_iff] at hab rcases hab with ⟨rfl, rfl⟩ | ⟨rfl, rfl⟩ <;> tauto · intro h; exact ⟨u, w, rfl, h⟩ dsimp only rw [hmem, hmem, hmem] simp only [Finset.mem_symmDiff] by_cases hu1 : u ∈ S₁ <;> by_cases hu2 : u ∈ S₂ <;> by_cases hw1 : w ∈ S₁ <;> by_cases hw2 : w ∈ S₂ <;> simp [hu1, hu2, hw1, hw2] lemma edgeCut_empty (G : SimpleGraph V) [DecidableRel G.Adj] : edgeCut G (∅ : Finset V) = ∅ := by ext e; simp [edgeCut] lemma edgeCut_singleton (G : SimpleGraph V) [DecidableRel G.Adj] (v : V) : edgeCut G {v} = vStar G v := by ext e simp only [edgeCut, vStar, Finset.mem_filter, Finset.mem_univ, true_and, Finset.mem_singleton] rcases e with ⟨e_raw, he_mem⟩ have hnd := G.not_isDiag_of_mem_edgeFinset he_mem induction e_raw using Sym2.ind with | _ u w => have huw : u ≠ w := fun h => hnd (by subst h; simp) constructor · rintro ⟨a, b, hab, ⟨rfl, _⟩ | ⟨_, rfl⟩⟩ <;> rw [hab] <;> simp · intro hv; rw [Sym2.mem_iff] at hv rcases hv with rfl | rfl · exact ⟨v, w, rfl, Or.inl ⟨rfl, huw.symm⟩⟩ · exact ⟨u, v, rfl, Or.inr ⟨huw, rfl⟩⟩ /-- On a connected graph `G`, `edgeCut G S = ∅` implies `S = ∅` or `S = Finset.univ`. -/ lemma edgeCut_eq_empty_iff (G : SimpleGraph V) [DecidableRel G.Adj] (hconn : G.Connected) (S : Finset V) : edgeCut G S = ∅ → S = ∅ ∨ S = Finset.univ := by intro hemp by_cases hS : S = ∅ · exact Or.inl hS · right rcases Finset.nonempty_iff_ne_empty.mpr hS with ⟨u, huS⟩ ext w simp only [Finset.mem_univ, iff_true] rcases hconn u w with ⟨p⟩ induction p with | nil => exact huS | @cons a b c hab p ih => -- If `a ∈ S` and `G.Adj a b`, then `b ∈ S` (otherwise `s(a, b) ∈ edgeCut G S = ∅`). have hbS : b ∈ S := by by_contra hbnot let e : GEdge G := ⟨s(a, b), G.mem_edgeFinset.mpr hab⟩ have he_mem : e ∈ edgeCut G S := by simp only [edgeCut, Finset.mem_filter, Finset.mem_univ, true_and] exact ⟨a, b, rfl, Or.inl ⟨huS, hbnot⟩⟩ rw [hemp] at he_mem simp at he_mem exact ih hbS /-- Multiplicative parity sign `(-1)^{∑_{v ∈ S} χ(v)}` in any ring `R`. -/ def chargeSign {R : Type*} [CommRing R] (χ : V → ZMod 2) (S : Finset V) : R := if (∑ v ∈ S, χ v) = 1 then -1 else 1 omit [Fintype V] [DecidableEq V] in lemma chargeSign_empty {R : Type*} [CommRing R] (χ : V → ZMod 2) : chargeSign (R := R) χ ∅ = 1 := by simp [chargeSign] omit [Fintype V] [DecidableEq V] in lemma chargeSign_singleton {R : Type*} [CommRing R] (χ : V → ZMod 2) (v : V) : chargeSign (R := R) χ {v} = if χ v = 1 then -1 else 1 := by simp [chargeSign] lemma zmod2_sign_mul {R : Type*} [CommRing R] (a b : ZMod 2) : (if a + b = 1 then (-1 : R) else 1) = (if a = 1 then -1 else 1) * (if b = 1 then -1 else 1) := by have hz2 : ∀ x : ZMod 2, x = 0 ∨ x = 1 := fun x => by fin_cases x · left; rfl · right; rfl have h01 : (0 : ZMod 2) ≠ 1 := by decide have h11 : (1 : ZMod 2) + 1 = 0 := by decide rcases hz2 a with rfl | rfl <;> rcases hz2 b with rfl | rfl · simp [h01] · simp [h01] · simp [h01] · simp [h11, h01] omit [Fintype V] in lemma chargeSign_symmDiff {R : Type*} [CommRing R] (χ : V → ZMod 2) (S₁ S₂ : Finset V) : chargeSign (R := R) χ (symmDiff S₁ S₂) = chargeSign (R := R) χ S₁ * chargeSign (R := R) χ S₂ := by classical have hsum : (∑ v ∈ symmDiff S₁ S₂, χ v) = (∑ v ∈ S₁, χ v) + (∑ v ∈ S₂, χ v) := by have h1 : (∑ v ∈ S₁ \ S₂, χ v) + (∑ v ∈ S₁ ∩ S₂, χ v) = ∑ v ∈ S₁, χ v := by rw [← Finset.sum_union (disjoint_sdiff_inter S₁ S₂), Finset.sdiff_union_inter] have h2 : (∑ v ∈ S₂ \ S₁, χ v) + (∑ v ∈ S₂ ∩ S₁, χ v) = ∑ v ∈ S₂, χ v := by rw [← Finset.sum_union (disjoint_sdiff_inter S₂ S₁), Finset.sdiff_union_inter] have hdisj : Disjoint (S₁ \ S₂) (S₂ \ S₁) := disjoint_sdiff_sdiff have hsd : symmDiff S₁ S₂ = (S₁ \ S₂) ∪ (S₂ \ S₁) := Finset.symmDiff_def S₁ S₂ rw [hsd, Finset.sum_union hdisj, ← h1, ← h2, Finset.inter_comm S₂ S₁] have h2z : ∀ x : ZMod 2, x + x = 0 := fun x => by fin_cases x <;> decide calc (∑ v ∈ S₁ \ S₂, χ v) + (∑ v ∈ S₂ \ S₁, χ v) = (∑ v ∈ S₁ \ S₂, χ v) + (∑ v ∈ S₂ \ S₁, χ v) + ((∑ v ∈ S₁ ∩ S₂, χ v) + (∑ v ∈ S₁ ∩ S₂, χ v)) := by rw [h2z, add_zero] _ = ((∑ v ∈ S₁ \ S₂, χ v) + (∑ v ∈ S₁ ∩ S₂, χ v)) + ((∑ v ∈ S₂ \ S₁, χ v) + (∑ v ∈ S₁ ∩ S₂, χ v)) := by ring unfold chargeSign rw [hsum] exact zmod2_sign_mul _ _ /-- Uniqueness of small cut witnesses: if `2 * r < |V|` and `G` is connected, then `edgeCut G S₁ = edgeCut G S₂` with `|S₁|, |S₂| ≤ r` forces `S₁ = S₂`! -/ lemma small_cut_unique (G : SimpleGraph V) [DecidableRel G.Adj] (hconn : G.Connected) {r : ℕ} (hr : 2 * r < Fintype.card V) {S₁ S₂ : Finset V} (h1 : S₁.card ≤ r) (h2 : S₂.card ≤ r) (hcut : edgeCut G S₁ = edgeCut G S₂) : S₁ = S₂ := by classical have hemp : edgeCut G (symmDiff S₁ S₂) = ∅ := by rw [edgeCut_symmDiff, hcut, symmDiff_self]; rfl rcases edgeCut_eq_empty_iff G hconn _ hemp with h0 | huniv · exact symmDiff_eq_bot.mp h0 · exfalso have hcard : (symmDiff S₁ S₂).card ≤ S₁.card + S₂.card := by rw [Finset.symmDiff_def] calc ((S₁ \ S₂) ∪ (S₂ \ S₁)).card ≤ (S₁ \ S₂).card + (S₂ \ S₁).card := Finset.card_union_le _ _ _ ≤ S₁.card + S₂.card := Nat.add_le_add (Finset.card_le_card Finset.sdiff_subset) (Finset.card_le_card Finset.sdiff_subset) rw [huniv, Finset.card_univ] at hcard omega /-- Small-set edge expansion cutoff condition: every set `S` with `r < |S| ≤ 2 * r` has `|edgeCut G S| > M`. -/ def SmallSetCutGt (G : SimpleGraph V) [DecidableRel G.Adj] (r M : ℕ) : Prop := ∀ S : Finset V, r < S.card → S.card ≤ 2 * r → M < (edgeCut G S).card /-- Cut-equivalence relation on edge subsets of size `≤ D`: `A ≈ B` iff `A ∆ B = edgeCut G S` for some vertex set `S` with `|S| ≤ r`. -/ def CutRel (G : SimpleGraph V) [DecidableRel G.Adj] (r : ℕ) (A B : Finset (GEdge G)) : Prop := ∃ S : Finset V, S.card ≤ r ∧ symmDiff A B = edgeCut G S lemma cutRel_refl (G : SimpleGraph V) [DecidableRel G.Adj] (r : ℕ) (A : Finset (GEdge G)) : CutRel G r A A := ⟨∅, Nat.zero_le r, by rw [symmDiff_self, edgeCut_empty]; rfl⟩ lemma cutRel_symm (G : SimpleGraph V) [DecidableRel G.Adj] (r : ℕ) {A B : Finset (GEdge G)} (h : CutRel G r A B) : CutRel G r B A := by rcases h with ⟨S, hS, heq⟩ exact ⟨S, hS, by rw [symmDiff_comm, heq]⟩ lemma symmDiff_cancel_mid {α : Type*} [DecidableEq α] (A B C : Finset α) : symmDiff (symmDiff A B) (symmDiff B C) = symmDiff A C := by rw [symmDiff_assoc, ← symmDiff_assoc B B C, symmDiff_self, bot_symmDiff] lemma symmDiff_cancel_left_eq {α : Type*} [DecidableEq α] (R A B : Finset α) : symmDiff (symmDiff R A) (symmDiff R B) = symmDiff A B := by rw [symmDiff_comm R A, symmDiff_cancel_mid] lemma cutRel_trans (G : SimpleGraph V) [DecidableRel G.Adj] {r D : ℕ} (hcut : SmallSetCutGt G r (2 * D)) {A B C : Finset (GEdge G)} (hA : A.card ≤ D) (hC : C.card ≤ D) (hAB : CutRel G r A B) (hBC : CutRel G r B C) : CutRel G r A C := by classical rcases hAB with ⟨S₁, hS1, h1⟩ rcases hBC with ⟨S₂, hS2, h2⟩ refine ⟨symmDiff S₁ S₂, ?_, ?_⟩ · have hsd_le : (symmDiff S₁ S₂).card ≤ 2 * r := by rw [Finset.symmDiff_def] calc ((S₁ \ S₂) ∪ (S₂ \ S₁)).card ≤ (S₁ \ S₂).card + (S₂ \ S₁).card := Finset.card_union_le _ _ _ ≤ S₁.card + S₂.card := Nat.add_le_add (Finset.card_le_card Finset.sdiff_subset) (Finset.card_le_card Finset.sdiff_subset) _ ≤ 2 * r := by omega have hcut_eq : edgeCut G (symmDiff S₁ S₂) = symmDiff A C := by rw [edgeCut_symmDiff, ← h1, ← h2, symmDiff_cancel_mid] have hcut_le : (edgeCut G (symmDiff S₁ S₂)).card ≤ 2 * D := by rw [hcut_eq, Finset.symmDiff_def] calc ((A \ C) ∪ (C \ A)).card ≤ (A \ C).card + (C \ A).card := Finset.card_union_le _ _ _ ≤ A.card + C.card := Nat.add_le_add (Finset.card_le_card Finset.sdiff_subset) (Finset.card_le_card Finset.sdiff_subset) _ ≤ 2 * D := by omega by_contra hgt push Not at hgt have := hcut (symmDiff S₁ S₂) hgt hsd_le omega · rw [edgeCut_symmDiff, ← h1, ← h2, symmDiff_cancel_mid] /-- Unified Tseitin pseudo-expectation functional `L(A)`: `(-1)^{χ(S)}` if `A = edgeCut G S` for some (unique!) `|S| ≤ r`, and `0` otherwise. -/ noncomputable def tseitinKernel {R : Type*} [CommRing R] (G : SimpleGraph V) [DecidableRel G.Adj] (χ : V → ZMod 2) (r : ℕ) (A : Finset (GEdge G)) : R := by classical exact if h : ∃ S : Finset V, S.card ≤ r ∧ A = edgeCut G S then chargeSign χ (Classical.choose h) else 0 lemma tseitinKernel_of_cut {R : Type*} [CommRing R] (G : SimpleGraph V) [DecidableRel G.Adj] (hconn : G.Connected) (χ : V → ZMod 2) {r : ℕ} (hr : 2 * r < Fintype.card V) {S : Finset V} (hS : S.card ≤ r) : tseitinKernel (R := R) G χ r (edgeCut G S) = chargeSign χ S := by classical unfold tseitinKernel have hex : ∃ S' : Finset V, S'.card ≤ r ∧ edgeCut G S = edgeCut G S' := ⟨S, hS, rfl⟩ rw [dif_pos hex] have hspec := Classical.choose_spec hex have heq : Classical.choose hex = S := small_cut_unique G hconn hr hspec.1 hS hspec.2.symm rw [heq] lemma tseitinKernel_eq_zero_of_not {R : Type*} [CommRing R] (G : SimpleGraph V) [DecidableRel G.Adj] (χ : V → ZMod 2) (r : ℕ) {A : Finset (GEdge G)} (h : ¬ ∃ S : Finset V, S.card ≤ r ∧ A = edgeCut G S) : tseitinKernel (R := R) G χ r A = 0 := by classical unfold tseitinKernel rw [dif_neg h] /-- Linear functional `tseitinPE G χ r p = ∑_A toMultilinearPM1 p A * tseitinKernel G χ r A`. -/ noncomputable def tseitinPE {R : Type*} [CommRing R] (G : SimpleGraph V) [DecidableRel G.Adj] (χ : V → ZMod 2) (r : ℕ) (p : MvPolynomial (GEdge G) R) : R := ∑ A : Finset (GEdge G), toMultilinearPM1 p A * tseitinKernel G χ r A lemma tseitinPE_one {R : Type*} [CommRing R] (G : SimpleGraph V) [DecidableRel G.Adj] (hconn : G.Connected) (χ : V → ZMod 2) {r : ℕ} (hr : 2 * r < Fintype.card V) : tseitinPE (R := R) G χ r 1 = 1 := by unfold tseitinPE rw [Finset.sum_eq_single (∅ : Finset (GEdge G))] · rw [toMultilinearPM1_one, if_pos rfl, one_mul, ← edgeCut_empty G, tseitinKernel_of_cut G hconn χ hr (show (∅ : Finset V).card ≤ r from Nat.zero_le r), chargeSign_empty] · intro A _ hne; rw [toMultilinearPM1_one, if_neg hne, zero_mul] · intro h; exact absurd (Finset.mem_univ _) h lemma tseitinPE_add {R : Type*} [CommRing R] (G : SimpleGraph V) [DecidableRel G.Adj] (χ : V → ZMod 2) (r : ℕ) (p q : MvPolynomial (GEdge G) R) : tseitinPE G χ r (p + q) = tseitinPE G χ r p + tseitinPE G χ r q := by unfold tseitinPE rw [← Finset.sum_add_distrib] apply Finset.sum_congr rfl; intro A _ rw [toMultilinearPM1_add, add_mul] lemma tseitinPE_smul {R : Type*} [CommRing R] (G : SimpleGraph V) [DecidableRel G.Adj] (χ : V → ZMod 2) (r : ℕ) (c : R) (p : MvPolynomial (GEdge G) R) : tseitinPE G χ r (c • p) = c * tseitinPE G χ r p := by unfold tseitinPE rw [Finset.mul_sum] apply Finset.sum_congr rfl; intro A _ rw [toMultilinearPM1_smul, mul_assoc] /-- **Headline Theorem 3B (Exact Dynamic Polynomial Calculus Degree Lower Bound for Tseitin over Arbitrary Fields `char ≠ 2`):** For EVERY field `F`, EVERY connected graph `G`, EVERY charge `χ : V → ZMod 2`, and EVERY cutoff `1 ≤ r` with `2 * r < |V|` and `SmallSetCutGt G r (2 * D)` (i.e. `2D < W̃_r(G)`), NO degree-`D` Dynamic Polynomial Calculus refutation of `tseitinPCAxioms G χ F` exists! -/ theorem tseitin_dynamic_pc_degree_lb {F : Type*} [Field F] (G : SimpleGraph V) [DecidableRel G.Adj] (hconn : G.Connected) (χ : V → ZMod 2) {r D : ℕ} (hr1 : 1 ≤ r) (hr : 2 * r < Fintype.card V) (hcut : SmallSetCutGt G r (2 * D)) : ¬ PCRefutes F (tseitinPCAxioms G χ F) D := by classical -- Key invariant for Dynamic PC: for EVERY `p` derivable in degree `≤ D`, for EVERY base monomial -- `A₀` of size `≤ D`, the cut-class weighted sum `∑_{A : |A| ≤ D} toMultilinearPM1 p A * K(A₀ ∆ A)` vanishes! let inv (p : MvPolynomial (GEdge G) F) : Prop := ∀ A₀ : Finset (GEdge G), A₀.card ≤ D → ∑ A : Finset (GEdge G), toMultilinearPM1 p A * tseitinKernel G χ r (symmDiff A₀ A) = 0 have hpres : ∀ p, PCDerives F (tseitinPCAxioms G χ F) D p → inv p := by intro p hp induction hp with | @ax p hmem hd => intro A₀ hA0 rcases hmem with ⟨e, rfl⟩ | ⟨v, rfl⟩ · -- Axiom `X_e^2 - 1`: `toMultilinearPM1` vanishes identically! apply Finset.sum_eq_zero; intro A _ rw [toMultilinearPM1_X_sq_sub_one, zero_mul] · -- Axiom `(∏_{e ∈ vStar G v} X_e) - sgn(v)` of degree `≤ D`. set sgn : F := if χ v = 1 then (-1 : F) else 1 have hstar_le : (vStar G v).card ≤ D := by -- Compute `toMultilinearPM1` on `∏ X_e - C sgn`: `vStar G v` has coeff `1` (unless `vStar = ∅`). by_cases hne : vStar G v = ∅ · simp [hne] · have hnz : toMultilinearPM1 ((∏ e ∈ vStar G v, (MvPolynomial.X e : MvPolynomial (GEdge G) F)) - MvPolynomial.C sgn) (vStar G v) ≠ 0 := by have hsub : (∏ e ∈ vStar G v, (MvPolynomial.X e : MvPolynomial (GEdge G) F)) - MvPolynomial.C sgn = (∏ e ∈ vStar G v, MvPolynomial.X e) + (-sgn) • (1 : MvPolynomial (GEdge G) F) := by rw [MvPolynomial.smul_eq_C_mul, mul_one, map_neg, sub_eq_add_neg] rw [hsub, toMultilinearPM1_add, toMultilinearPM1_smul, toMultilinearPM1_prod_X, toMultilinearPM1_one, if_pos rfl, if_neg hne] simp exact le_trans (toMultilinearPM1_support_card_le hnz) hd -- Compute the sum explicitly: only `A = vStar G v` (coeff `1`) and `A = ∅` (coeff `-sgn`) contribute! have hrew : (∏ e ∈ vStar G v, (MvPolynomial.X e : MvPolynomial (GEdge G) F)) - MvPolynomial.C sgn = (∏ e ∈ vStar G v, MvPolynomial.X e) + (-sgn) • (1 : MvPolynomial (GEdge G) F) := by rw [MvPolynomial.smul_eq_C_mul, mul_one, map_neg, sub_eq_add_neg] rw [hrew] simp_rw [toMultilinearPM1_add, toMultilinearPM1_smul, toMultilinearPM1_prod_X, toMultilinearPM1_one, add_mul] rw [Finset.sum_add_distrib] have hs1 : ∑ A : Finset (GEdge G), (if vStar G v = A then (1 : F) else 0) * tseitinKernel G χ r (symmDiff A₀ A) = tseitinKernel G χ r (symmDiff A₀ (vStar G v)) := by rw [Finset.sum_eq_single (vStar G v)] · simp · intro A _ hne; rw [if_neg (Ne.symm hne), zero_mul] · intro h; exact absurd (Finset.mem_univ _) h have hs2 : ∑ A : Finset (GEdge G), (-sgn * if A = ∅ then (1 : F) else 0) * tseitinKernel G χ r (symmDiff A₀ A) = -sgn * tseitinKernel G χ r A₀ := by rw [Finset.sum_eq_single (∅ : Finset (GEdge G))] · rw [if_pos rfl, mul_one, show symmDiff A₀ ∅ = A₀ from symmDiff_bot A₀] · intro A _ hne; rw [if_neg hne, mul_zero, zero_mul] · intro h; exact absurd (Finset.mem_univ _) h rw [hs1, hs2] -- Now show `tseitinKernel (symmDiff A₀ (vStar G v)) = sgn * tseitinKernel A₀`! have hstep : tseitinKernel (R := F) G χ r (symmDiff A₀ (vStar G v)) = sgn * tseitinKernel (R := F) G χ r A₀ := by by_cases hA0_cut : ∃ S : Finset V, S.card ≤ r ∧ A₀ = edgeCut G S · rcases hA0_cut with ⟨S, hS, hA0eq⟩ have hcut_eq : symmDiff A₀ (vStar G v) = edgeCut G (symmDiff S {v}) := by rw [hA0eq, ← edgeCut_singleton G v, edgeCut_symmDiff] have hcard_new : (symmDiff A₀ (vStar G v)).card ≤ 2 * D := by rw [Finset.symmDiff_def] calc ((A₀ \ vStar G v) ∪ (vStar G v \ A₀)).card ≤ (A₀ \ vStar G v).card + (vStar G v \ A₀).card := Finset.card_union_le _ _ _ ≤ A₀.card + (vStar G v).card := Nat.add_le_add (Finset.card_le_card Finset.sdiff_subset) (Finset.card_le_card Finset.sdiff_subset) _ ≤ 2 * D := by omega have hSnew_le : (symmDiff S {v}).card ≤ 2 * r := by rw [Finset.symmDiff_def] calc ((S \ {v}) ∪ ({v} \ S)).card ≤ (S \ {v}).card + ({v} \ S).card := Finset.card_union_le _ _ _ ≤ S.card + ({v} : Finset V).card := Nat.add_le_add (Finset.card_le_card Finset.sdiff_subset) (Finset.card_le_card Finset.sdiff_subset) _ ≤ 2 * r := by simp; omega have hSnew_r : (symmDiff S {v}).card ≤ r := by by_contra hgt; push Not at hgt have := hcut (symmDiff S {v}) hgt hSnew_le rw [← hcut_eq] at this; omega rw [hcut_eq, tseitinKernel_of_cut G hconn χ hr hSnew_r, hA0eq, tseitinKernel_of_cut G hconn χ hr hS, chargeSign_symmDiff, chargeSign_singleton, mul_comm] · -- Neither `A₀` nor `symmDiff A₀ (vStar G v)` is a small cut! have hnot_new : ¬ ∃ S' : Finset V, S'.card ≤ r ∧ symmDiff A₀ (vStar G v) = edgeCut G S' := by rintro ⟨S', hS', hS'eq⟩ apply hA0_cut have hA0eq : A₀ = edgeCut G (symmDiff S' {v}) := by rw [edgeCut_symmDiff, ← hS'eq, edgeCut_singleton, symmDiff_symmDiff_cancel_right] have hsd_2r : (symmDiff S' {v}).card ≤ 2 * r := by rw [Finset.symmDiff_def] calc ((S' \ {v}) ∪ ({v} \ S')).card ≤ (S' \ {v}).card + ({v} \ S').card := Finset.card_union_le _ _ _ ≤ S'.card + ({v} : Finset V).card := Nat.add_le_add (Finset.card_le_card Finset.sdiff_subset) (Finset.card_le_card Finset.sdiff_subset) _ ≤ 2 * r := by simp; omega have hsd_r : (symmDiff S' {v}).card ≤ r := by by_contra hgt; push Not at hgt have := hcut (symmDiff S' {v}) hgt hsd_2r rw [← hA0eq] at this; omega exact ⟨symmDiff S' {v}, hsd_r, hA0eq⟩ rw [tseitinKernel_eq_zero_of_not G χ r hnot_new, tseitinKernel_eq_zero_of_not G χ r hA0_cut, mul_zero] rw [hstep]; ring | add _ _ ih1 ih2 => intro A₀ hA0 simp_rw [toMultilinearPM1_add, add_mul] rw [Finset.sum_add_distrib, ih1 A₀ hA0, ih2 A₀ hA0, add_zero] | smul c _ ih => intro A₀ hA0 simp_rw [toMultilinearPM1_smul, mul_assoc] rw [← Finset.mul_sum, ih A₀ hA0, mul_zero] | @mul_var e q hq hd ih => -- **THE KEY DYNAMIC PC STEP!** -- For `A₀` with `|A₀| ≤ D`: -- `∑ A, toMultilinearPM1 (X_e * q) A * K(A₀ ∆ A) = ∑ B, toMultilinearPM1 q B * K((A₀ ∆ {e}) ∆ B)`. -- Wait: `|A₀ ∆ {e}|` might be `D + 1`! -- If NO `B` in the support of `q` (`|B| ≤ D - 1`) satisfies `CutRel G r (A₀ ∆ {e}) B`, the sum is `0`! -- If SOME `B₀` (`|B₀| ≤ D - 1`) satisfies `CutRel G r (A₀ ∆ {e}) B₀` (with witness `|S₀| ≤ r`): -- Then for EVERY `B` with `|B| ≤ D - 1`: -- `K((A₀ ∆ {e}) ∆ B) = chargeSign χ S₀ * K(B₀ ∆ B)`!! -- Because `|(A₀ ∆ {e}) ∆ B| ≤ (D + 1) + (D - 1) = 2 * D < W̃_r(G)`!! -- So `∑ B, c_B * K((A₀ ∆ {e}) ∆ B) = chargeSign χ S₀ * (∑ B, c_B * K(B₀ ∆ B)) = 0` by `ih B₀`!! intro A₀ hA0 have hdeg_q : q.totalDegree ≤ D - 1 := by omega -- Reindex `B = symmDiff A {e}` (bijection on `Finset (GEdge G)`). have hreindex : ∑ A : Finset (GEdge G), toMultilinearPM1 (MvPolynomial.X e * q) A * tseitinKernel G χ r (symmDiff A₀ A) = ∑ B : Finset (GEdge G), toMultilinearPM1 q B * tseitinKernel G χ r (symmDiff (symmDiff A₀ {e}) B) := by refine Finset.sum_bij (fun A _ => symmDiff A {e}) (fun _ _ => Finset.mem_univ _) ?_ ?_ ?_ · intro A₁ _ A₂ _ heq have := congrArg (fun X => symmDiff X {e}) heq simpa [symmDiff_symmDiff_cancel_right] using this · intro B _ exact ⟨symmDiff B {e}, Finset.mem_univ _, symmDiff_symmDiff_cancel_right {e} B⟩ · intro A _ rw [toMultilinearPM1_X_mul] congr 2 rw [symmDiff_comm A {e}, symmDiff_cancel_mid] rw [hreindex] set A₁ := symmDiff A₀ {e} have hA1_card : A₁.card ≤ D + 1 := by dsimp only [A₁] rw [Finset.symmDiff_def] calc ((A₀ \ {e}) ∪ ({e} \ A₀)).card ≤ (A₀ \ {e}).card + ({e} \ A₀).card := Finset.card_union_le _ _ _ ≤ A₀.card + ({e} : Finset (GEdge G)).card := Nat.add_le_add (Finset.card_le_card Finset.sdiff_subset) (Finset.card_le_card Finset.sdiff_subset) _ ≤ D + 1 := by simp; omega by_cases hexB : ∃ B₀ : Finset (GEdge G), B₀.card ≤ D - 1 ∧ ∃ S₀ : Finset V, S₀.card ≤ r ∧ symmDiff A₁ B₀ = edgeCut G S₀ · rcases hexB with ⟨B₀, hB0_card, S₀, hS0_r, hS0_eq⟩ -- Show every nonzero term `B` (`|B| ≤ D - 1`) satisfies `K(A₁ ∆ B) = chargeSign S₀ * K(B₀ ∆ B)`. have hterm : ∀ B : Finset (GEdge G), toMultilinearPM1 q B * tseitinKernel G χ r (symmDiff A₁ B) = chargeSign χ S₀ * (toMultilinearPM1 q B * tseitinKernel G χ r (symmDiff B₀ B)) := by intro B by_cases hqB : toMultilinearPM1 q B = 0 · simp [hqB] · have hB_card : B.card ≤ D - 1 := le_trans (toMultilinearPM1_support_card_le hqB) hdeg_q have hA1B_le : (symmDiff A₁ B).card ≤ 2 * D := by rw [Finset.symmDiff_def] calc ((A₁ \ B) ∪ (B \ A₁)).card ≤ (A₁ \ B).card + (B \ A₁).card := Finset.card_union_le _ _ _ ≤ A₁.card + B.card := Nat.add_le_add (Finset.card_le_card Finset.sdiff_subset) (Finset.card_le_card Finset.sdiff_subset) _ ≤ 2 * D := by omega have hB0B_le : (symmDiff B₀ B).card ≤ 2 * D := by rw [Finset.symmDiff_def] calc ((B₀ \ B) ∪ (B \ B₀)).card ≤ (B₀ \ B).card + (B \ B₀).card := Finset.card_union_le _ _ _ ≤ B₀.card + B.card := Nat.add_le_add (Finset.card_le_card Finset.sdiff_subset) (Finset.card_le_card Finset.sdiff_subset) _ ≤ 2 * D := by omega have hker : tseitinKernel (R := F) G χ r (symmDiff A₁ B) = chargeSign χ S₀ * tseitinKernel (R := F) G χ r (symmDiff B₀ B) := by by_cases hcutB : ∃ S₁ : Finset V, S₁.card ≤ r ∧ symmDiff B₀ B = edgeCut G S₁ · rcases hcutB with ⟨S₁, hS1_r, hS1_eq⟩ have hsd_eq : symmDiff A₁ B = edgeCut G (symmDiff S₀ S₁) := by rw [edgeCut_symmDiff, ← hS0_eq, ← hS1_eq, symmDiff_cancel_mid] have hsd_2r : (symmDiff S₀ S₁).card ≤ 2 * r := by rw [Finset.symmDiff_def] calc ((S₀ \ S₁) ∪ (S₁ \ S₀)).card ≤ (S₀ \ S₁).card + (S₁ \ S₀).card := Finset.card_union_le _ _ _ ≤ S₀.card + S₁.card := Nat.add_le_add (Finset.card_le_card Finset.sdiff_subset) (Finset.card_le_card Finset.sdiff_subset) _ ≤ 2 * r := by omega have hsd_r : (symmDiff S₀ S₁).card ≤ r := by by_contra hgt; push Not at hgt have := hcut (symmDiff S₀ S₁) hgt hsd_2r rw [← hsd_eq] at this; omega rw [hsd_eq, tseitinKernel_of_cut G hconn χ hr hsd_r, hS1_eq, tseitinKernel_of_cut G hconn χ hr hS1_r, chargeSign_symmDiff] · have hnotA : ¬ ∃ S₂ : Finset V, S₂.card ≤ r ∧ symmDiff A₁ B = edgeCut G S₂ := by rintro ⟨S₂, hS2_r, hS2_eq⟩ apply hcutB have hsd_eq : symmDiff B₀ B = edgeCut G (symmDiff S₀ S₂) := by rw [edgeCut_symmDiff, ← hS0_eq, ← hS2_eq, symmDiff_cancel_left_eq] have hsd_2r : (symmDiff S₀ S₂).card ≤ 2 * r := by rw [Finset.symmDiff_def] calc ((S₀ \ S₂) ∪ (S₂ \ S₀)).card ≤ (S₀ \ S₂).card + (S₂ \ S₀).card := Finset.card_union_le _ _ _ ≤ S₀.card + S₂.card := Nat.add_le_add (Finset.card_le_card Finset.sdiff_subset) (Finset.card_le_card Finset.sdiff_subset) _ ≤ 2 * r := by omega have hsd_r : (symmDiff S₀ S₂).card ≤ r := by by_contra hgt; push Not at hgt have := hcut (symmDiff S₀ S₂) hgt hsd_2r rw [← hsd_eq] at this; omega exact ⟨symmDiff S₀ S₂, hsd_r, hsd_eq⟩ rw [tseitinKernel_eq_zero_of_not G χ r hnotA, tseitinKernel_eq_zero_of_not G χ r hcutB, mul_zero] rw [hker]; ring simp_rw [hterm] rw [← Finset.mul_sum, ih B₀ (by omega), mul_zero] · -- No `B` in support of `q` is cut-equivalent to `A₁`: every term is `0`! apply Finset.sum_eq_zero intro B _ by_cases hqB : toMultilinearPM1 q B = 0 · simp [hqB] · have hB_card : B.card ≤ D - 1 := le_trans (toMultilinearPM1_support_card_le hqB) hdeg_q have hnot : ¬ ∃ S₀ : Finset V, S₀.card ≤ r ∧ symmDiff A₁ B = edgeCut G S₀ := fun h => hexB ⟨B, hB_card, h⟩ rw [tseitinKernel_eq_zero_of_not G χ r hnot, mul_zero] -- Apply `hpres` to `1`: `inv 1` at `A₀ = ∅` gives `1 = 0`, contradiction! intro href have h0 := hpres 1 href ∅ (Nat.zero_le D) have h1 : ∑ A : Finset (GEdge G), toMultilinearPM1 (1 : MvPolynomial (GEdge G) F) A * tseitinKernel G χ r (symmDiff ∅ A) = 1 := by have : ∀ A, symmDiff (∅ : Finset (GEdge G)) A = A := fun A => by simp simp_rw [this] exact tseitinPE_one G hconn χ hr rw [h1] at h0 exact one_ne_zero h0 /-- **Headline Theorem 3C (Boolean-Basis Dynamic PC Degree Lower Bound for Tseitin):** Over ANY field `F` with `(2 : F) ≠ 0`, NO degree-`D` Dynamic PC refutation of the Boolean `{0, 1}`-encoded Tseitin system `fourierToBool F '' tseitinPCAxioms G χ F` exists whenever `2 * D < W̃_r(G)`! -/ theorem tseitin_boolean_pc_degree_lb {F : Type*} [Field F] (h2 : (2 : F) ≠ 0) (G : SimpleGraph V) [DecidableRel G.Adj] (hconn : G.Connected) (χ : V → ZMod 2) {r D : ℕ} (hr1 : 1 ≤ r) (hr : 2 * r < Fintype.card V) (hcut : SmallSetCutGt G r (2 * D)) : ¬ PCRefutes F (fourierToBool F '' tseitinPCAxioms G χ F) D := by rw [pc_fourier_boolean_iso h2] exact tseitin_dynamic_pc_degree_lb G hconn χ hr1 hr hcut /-- **Headline Theorem 3D (Explicit Rank-1 Block PSD Factorization of Tseitin Pseudo-Expectation):** Under `2 * r < |V|` and `SmallSetCutGt G r (2 * d)`, for EVERY `p : MvPolynomial (GEdge G) ℝ` with `p.totalDegree ≤ d`, `tseitinPE G χ r (p ^ 2) ≥ 0` (via explicit equivalence-class sum of squares!). -/ theorem tseitin_sos_pseudoexp_psd (G : SimpleGraph V) [DecidableRel G.Adj] (hconn : G.Connected) (χ : V → ZMod 2) {r d : ℕ} (hr : 2 * r < Fintype.card V) (hcut : SmallSetCutGt G r (2 * d)) (p : MvPolynomial (GEdge G) ℝ) (hp : p.totalDegree ≤ d) : 0 ≤ tseitinPE G χ r (p ^ 2) := by classical -- Expand `tseitinPE (p^2) = ∑_{A, B : |A|,|B| ≤ d} c_A * c_B * K(A ∆ B)`. let degLe : Finset (Finset (GEdge G)) := Finset.univ.filter fun A => A.card ≤ d have hexpand : tseitinPE G χ r (p ^ 2) = ∑ A ∈ degLe, ∑ B ∈ degLe, toMultilinearPM1 p A * toMultilinearPM1 p B * tseitinKernel G χ r (symmDiff A B) := by unfold tseitinPE rw [sq] simp_rw [toMultilinearPM1_mul, Finset.sum_mul] rw [Finset.sum_comm] -- For each `B`, reindex `C = symmDiff B A` (so `A = symmDiff B C`, `symmDiff B A = C`). have hinner : ∀ B : Finset (GEdge G), ∑ A : Finset (GEdge G), toMultilinearPM1 p B * toMultilinearPM1 p (symmDiff B A) * tseitinKernel G χ r A = ∑ C : Finset (GEdge G), toMultilinearPM1 p B * toMultilinearPM1 p C * tseitinKernel G χ r (symmDiff B C) := by intro B refine Finset.sum_bij (fun A _ => symmDiff B A) (fun _ _ => Finset.mem_univ _) ?_ ?_ ?_ · intro A₁ _ A₂ _ heq have := congrArg (fun X => symmDiff B X) heq simpa [symmDiff_symmDiff_cancel_left] using this · intro C _ exact ⟨symmDiff B C, Finset.mem_univ _, symmDiff_symmDiff_cancel_left B C⟩ · intro A _; simp [symmDiff_symmDiff_cancel_left] simp_rw [hinner] -- Restrict sums from `univ` to `degLe` since `toMultilinearPM1 p A = 0` for `|A| > d`. rw [← Finset.sum_subset (Finset.subset_univ degLe)] · apply Finset.sum_congr rfl; intro A _ rw [← Finset.sum_subset (Finset.subset_univ degLe)] intro B _ hBnot have h0 : toMultilinearPM1 p B = 0 := by by_contra hne have := le_trans (toMultilinearPM1_support_card_le hne) hp exact hBnot (Finset.mem_filter.mpr ⟨Finset.mem_univ _, this⟩) simp [h0] · intro A _ hAnot apply Finset.sum_eq_zero; intro B _ have h0 : toMultilinearPM1 p A = 0 := by by_contra hne have := le_trans (toMultilinearPM1_support_card_le hne) hp exact hAnot (Finset.mem_filter.mpr ⟨Finset.mem_univ _, this⟩) simp [h0] rw [hexpand] -- Define equivalence relation `CutRel G r` on `degLe`, pick a canonical representative `rep A` -- in each class, and factor `K(A ∆ B) = σ(A) * σ(B)` within each class! let cls (A : Finset (GEdge G)) : Finset (Finset (GEdge G)) := degLe.filter fun B => CutRel G r A B have hcls_nonempty : ∀ A ∈ degLe, (cls A).Nonempty := fun A hA => ⟨A, Finset.mem_filter.mpr ⟨hA, cutRel_refl G r A⟩⟩ have hcls_eq : ∀ A ∈ degLe, ∀ B ∈ degLe, CutRel G r A B → cls A = cls B := by intro A hA B hB hAB ext C simp only [cls, Finset.mem_filter] have hAd : A.card ≤ d := (Finset.mem_filter.mp hA).2 have hBd : B.card ≤ d := (Finset.mem_filter.mp hB).2 constructor · rintro ⟨hC, hAC⟩ exact ⟨hC, cutRel_trans G hcut hBd (Finset.mem_filter.mp hC).2 (cutRel_symm G r hAB) hAC⟩ · rintro ⟨hC, hBC⟩ exact ⟨hC, cutRel_trans G hcut hAd (Finset.mem_filter.mp hC).2 hAB hBC⟩ -- For each class `Q ∈ degLe.image cls`, pick a fixed representative `rep Q ∈ Q`. let rep (Q : Finset (Finset (GEdge G))) : Finset (GEdge G) := if h : Q.Nonempty then Classical.choose h else ∅ have hrep_mem : ∀ A ∈ degLe, rep (cls A) ∈ cls A := by intro A hA; unfold rep; rw [dif_pos (hcls_nonempty A hA)] exact Classical.choose_spec (hcls_nonempty A hA) have hrep_rel : ∀ A ∈ degLe, CutRel G r (rep (cls A)) A := by intro A hA exact cutRel_symm G r (Finset.mem_filter.mp (hrep_mem A hA)).2 have hrep_card : ∀ A ∈ degLe, (rep (cls A)).card ≤ d := by intro A hA exact (Finset.mem_filter.mp (Finset.mem_filter.mp (hrep_mem A hA)).1).2 -- Define `σ(A) := K(rep(cls A) ∆ A) ∈ {-1, 1}` for `A ∈ degLe`. let σ (A : Finset (GEdge G)) : ℝ := tseitinKernel G χ r (symmDiff (rep (cls A)) A) -- Show for `A, B ∈ degLe`: if `cls A = cls B`, then `K(A ∆ B) = σ A * σ B`, else `K(A ∆ B) = 0`! have hfactor : ∀ A ∈ degLe, ∀ B ∈ degLe, tseitinKernel (R := ℝ) G χ r (symmDiff A B) = if cls A = cls B then σ A * σ B else 0 := by intro A hA B hB have hAd : A.card ≤ d := (Finset.mem_filter.mp hA).2 have hBd : B.card ≤ d := (Finset.mem_filter.mp hB).2 by_cases hce : cls A = cls B · rw [if_pos hce] rcases hrep_rel A hA with ⟨SA, hSA, hSAeq⟩ rcases hrep_rel B hB with ⟨SB, hSB, hSBeq⟩ have hAB_cut : symmDiff A B = edgeCut G (symmDiff SA SB) := by rw [edgeCut_symmDiff, ← hSAeq, ← hSBeq, hce, symmDiff_cancel_left_eq] have hsd_2r : (symmDiff SA SB).card ≤ 2 * r := by rw [Finset.symmDiff_def] calc ((SA \ SB) ∪ (SB \ SA)).card ≤ (SA \ SB).card + (SB \ SA).card := Finset.card_union_le _ _ _ ≤ SA.card + SB.card := Nat.add_le_add (Finset.card_le_card Finset.sdiff_subset) (Finset.card_le_card Finset.sdiff_subset) _ ≤ 2 * r := by omega have hsd_r : (symmDiff SA SB).card ≤ r := by by_contra hgt; push Not at hgt have h1 := hcut (symmDiff SA SB) hgt hsd_2r rw [← hAB_cut] at h1 have h2 : (symmDiff A B).card ≤ 2 * d := by rw [Finset.symmDiff_def] calc ((A \ B) ∪ (B \ A)).card ≤ (A \ B).card + (B \ A).card := Finset.card_union_le _ _ _ ≤ A.card + B.card := Nat.add_le_add (Finset.card_le_card Finset.sdiff_subset) (Finset.card_le_card Finset.sdiff_subset) _ ≤ 2 * d := by omega omega rw [hAB_cut, tseitinKernel_of_cut G hconn χ hr hsd_r, chargeSign_symmDiff] dsimp only [σ] rw [hSAeq, hSBeq, tseitinKernel_of_cut G hconn χ hr hSA, tseitinKernel_of_cut G hconn χ hr hSB] · rw [if_neg hce] apply tseitinKernel_eq_zero_of_not rintro ⟨S, hS, hSeq⟩ exact hce (hcls_eq A hA B hB ⟨S, hS, hSeq⟩) -- Rewrite the double sum as `∑_{Q ∈ degLe.image cls} (∑_{A ∈ Q} c_A * σ A)^2 ≥ 0`! have hblock : ∑ A ∈ degLe, ∑ B ∈ degLe, toMultilinearPM1 p A * toMultilinearPM1 p B * tseitinKernel G χ r (symmDiff A B) = ∑ Q ∈ degLe.image cls, (∑ A ∈ Q, toMultilinearPM1 p A * σ A) ^ 2 := by have h1 : ∀ Q ∈ degLe.image cls, (∑ A ∈ Q, toMultilinearPM1 p A * σ A) ^ 2 = ∑ A ∈ Q, ∑ B ∈ Q, (toMultilinearPM1 p A * toMultilinearPM1 p B) * (σ A * σ B) := by intro Q _ rw [sq, Finset.sum_mul_sum] apply Finset.sum_congr rfl; intro A _ apply Finset.sum_congr rfl; intro B _; ring rw [Finset.sum_congr rfl h1] -- Partition `degLe` by fiber `cls A = Q`! have hfib : ∀ Q ∈ degLe.image cls, Q = degLe.filter (fun A => cls A = Q) := by intro Q hQ rcases Finset.mem_image.mp hQ with ⟨A₀, hA0, rfl⟩ ext A simp only [cls, Finset.mem_filter] constructor · rintro ⟨hA, hrel⟩ exact ⟨hA, (hcls_eq A₀ hA0 A hA hrel).symm⟩ · rintro ⟨hA, heq⟩ have hself : A ∈ cls A := Finset.mem_filter.mpr ⟨hA, cutRel_refl G r A⟩ dsimp only [cls] at hself rw [heq] at hself exact Finset.mem_filter.mp hself -- Rewrite LHS by fiber decomposition over `Q ∈ degLe.image cls`. calc ∑ A ∈ degLe, ∑ B ∈ degLe, toMultilinearPM1 p A * toMultilinearPM1 p B * tseitinKernel G χ r (symmDiff A B) = ∑ Q ∈ degLe.image cls, ∑ A ∈ degLe.filter (fun A => cls A = Q), ∑ B ∈ degLe, toMultilinearPM1 p A * toMultilinearPM1 p B * (if cls A = cls B then σ A * σ B else 0) := by rw [← Finset.sum_fiberwise_of_maps_to (fun A hA => Finset.mem_image_of_mem cls hA)] apply Finset.sum_congr rfl; intro Q _ apply Finset.sum_congr rfl; intro A hA have hA' : A ∈ degLe := (Finset.mem_filter.mp hA).1 apply Finset.sum_congr rfl; intro B hB rw [hfactor A hA' B hB] _ = ∑ Q ∈ degLe.image cls, ∑ A ∈ Q, ∑ B ∈ Q, toMultilinearPM1 p A * toMultilinearPM1 p B * (σ A * σ B) := by apply Finset.sum_congr rfl; intro Q hQ rw [← hfib Q hQ] apply Finset.sum_congr rfl; intro A hA have hA' : A ∈ degLe.filter (fun A => cls A = Q) := by rw [← hfib Q hQ]; exact hA have hclsA : cls A = Q := (Finset.mem_filter.mp hA').2 conv_rhs => rw [hfib Q hQ, Finset.sum_filter] apply Finset.sum_congr rfl; intro B _ rw [hclsA] by_cases hB : cls B = Q · rw [if_pos hB, if_pos hB.symm] · rw [if_neg hB, if_neg (Ne.symm hB), mul_zero] rw [hblock] exact Finset.sum_nonneg fun _ _ => sq_nonneg _ /-- Tseitin pseudo-expectation annihilates every degree-`≤ 2d` ideal multiple of a Tseitin axiom! -/ lemma tseitin_sos_pseudoexp_ideal (G : SimpleGraph V) [DecidableRel G.Adj] (hconn : G.Connected) (χ : V → ZMod 2) {r d : ℕ} (hr1 : 1 ≤ r) (hr : 2 * r < Fintype.card V) (hcut : SmallSetCutGt G r (2 * d)) {q g : MvPolynomial (GEdge G) ℝ} (hg : g ∈ tseitinPCAxioms G χ ℝ) (hdeg : q.totalDegree + g.totalDegree ≤ 2 * d) : tseitinPE G χ r (q * g) = 0 := by classical rcases hg with ⟨e, rfl⟩ | ⟨v, rfl⟩ · -- `q * (X_e^2 - 1)`: `toMultilinearPM1` vanishes identically! unfold tseitinPE apply Finset.sum_eq_zero; intro A _ rw [toMultilinearPM1_mul] have h0 : ∀ B, toMultilinearPM1 ((MvPolynomial.X e : MvPolynomial (GEdge G) ℝ) ^ 2 - 1) B = 0 := toMultilinearPM1_X_sq_sub_one e simp [h0] · -- `q * (∏_{e ∈ vStar G v} X_e - sgn(v))` with `deg(q) + deg(star v) ≤ 2 * d`. set sgn : ℝ := if χ v = 1 then (-1 : ℝ) else 1 set g_v : MvPolynomial (GEdge G) ℝ := (∏ e ∈ vStar G v, MvPolynomial.X e) - MvPolynomial.C sgn have hstar_le : (vStar G v).card ≤ g_v.totalDegree := by by_cases hne : vStar G v = ∅ · simp [hne] · have hnz : toMultilinearPM1 g_v (vStar G v) ≠ 0 := by have hrew : g_v = (∏ e ∈ vStar G v, MvPolynomial.X e) + (-sgn) • 1 := by dsimp [g_v]; rw [MvPolynomial.smul_eq_C_mul, mul_one, map_neg, sub_eq_add_neg] rw [hrew, toMultilinearPM1_add, toMultilinearPM1_smul, toMultilinearPM1_prod_X, toMultilinearPM1_one, if_pos rfl, if_neg hne] simp exact toMultilinearPM1_support_card_le hnz -- Expand `tseitinPE (q * g_v) = ∑ B, toMultilinearPM1 q B * (K(B ∆ star v) - sgn * K(B))`. have hrew : g_v = (∏ e ∈ vStar G v, MvPolynomial.X e) + (-sgn) • 1 := by dsimp [g_v]; rw [MvPolynomial.smul_eq_C_mul, mul_one, map_neg, sub_eq_add_neg] have hsum : tseitinPE G χ r (q * g_v) = ∑ B : Finset (GEdge G), toMultilinearPM1 q B * (tseitinKernel G χ r (symmDiff B (vStar G v)) - sgn * tseitinKernel G χ r B) := by unfold tseitinPE simp_rw [toMultilinearPM1_mul, Finset.sum_mul] rw [Finset.sum_comm] apply Finset.sum_congr rfl; intro B _ rw [hrew] simp_rw [toMultilinearPM1_add, toMultilinearPM1_smul, toMultilinearPM1_prod_X, toMultilinearPM1_one, mul_add, add_mul] rw [Finset.sum_add_distrib] have h1 : ∑ A : Finset (GEdge G), toMultilinearPM1 q B * (if vStar G v = symmDiff B A then (1 : ℝ) else 0) * tseitinKernel G χ r A = toMultilinearPM1 q B * tseitinKernel G χ r (symmDiff B (vStar G v)) := by rw [Finset.sum_eq_single (symmDiff B (vStar G v))] · simp [symmDiff_symmDiff_cancel_left] · intro A _ hne have hne' : vStar G v ≠ symmDiff B A := by intro heq; apply hne have := congrArg (fun X => symmDiff B X) heq simpa [symmDiff_symmDiff_cancel_left] using this.symm rw [if_neg hne', mul_zero, zero_mul] · intro h; exact absurd (Finset.mem_univ _) h have h2 : ∑ A : Finset (GEdge G), toMultilinearPM1 q B * (-sgn * if symmDiff B A = ∅ then (1 : ℝ) else 0) * tseitinKernel G χ r A = toMultilinearPM1 q B * (-sgn * tseitinKernel G χ r B) := by rw [Finset.sum_eq_single B] · rw [show symmDiff B B = ∅ from symmDiff_self B, if_pos rfl, mul_one, mul_assoc] · intro A _ hne have hne' : symmDiff B A ≠ ∅ := by intro heq; exact hne (symmDiff_eq_bot.mp heq).symm rw [if_neg hne', mul_zero, mul_zero, zero_mul] · intro h; exact absurd (Finset.mem_univ _) h rw [h1, h2]; ring rw [hsum] apply Finset.sum_eq_zero; intro B _ by_cases hqB : toMultilinearPM1 q B = 0 · simp [hqB] · have hB_le : B.card ≤ q.totalDegree := toMultilinearPM1_support_card_le hqB have hB_2d : B.card ≤ 2 * d := by omega have hBstar_2d : (symmDiff B (vStar G v)).card ≤ 2 * d := by rw [Finset.symmDiff_def] calc ((B \ vStar G v) ∪ (vStar G v \ B)).card ≤ (B \ vStar G v).card + (vStar G v \ B).card := Finset.card_union_le _ _ _ ≤ B.card + (vStar G v).card := Nat.add_le_add (Finset.card_le_card Finset.sdiff_subset) (Finset.card_le_card Finset.sdiff_subset) _ ≤ 2 * d := by omega have heqK : tseitinKernel (R := ℝ) G χ r (symmDiff B (vStar G v)) = sgn * tseitinKernel (R := ℝ) G χ r B := by by_cases hBcut : ∃ S : Finset V, S.card ≤ r ∧ B = edgeCut G S · rcases hBcut with ⟨S, hS, hBeq⟩ have hsd_eq : symmDiff B (vStar G v) = edgeCut G (symmDiff S {v}) := by rw [hBeq, ← edgeCut_singleton G v, edgeCut_symmDiff] have hsd_2r : (symmDiff S {v}).card ≤ 2 * r := by rw [Finset.symmDiff_def] calc ((S \ {v}) ∪ ({v} \ S)).card ≤ (S \ {v}).card + ({v} \ S).card := Finset.card_union_le _ _ _ ≤ S.card + ({v} : Finset V).card := Nat.add_le_add (Finset.card_le_card Finset.sdiff_subset) (Finset.card_le_card Finset.sdiff_subset) _ ≤ 2 * r := by simp; omega have hsd_r : (symmDiff S {v}).card ≤ r := by by_contra hgt; push Not at hgt have := hcut (symmDiff S {v}) hgt hsd_2r rw [← hsd_eq] at this; omega rw [hsd_eq, tseitinKernel_of_cut G hconn χ hr hsd_r, hBeq, tseitinKernel_of_cut G hconn χ hr hS, chargeSign_symmDiff, chargeSign_singleton, mul_comm] · have hnot : ¬ ∃ S' : Finset V, S'.card ≤ r ∧ symmDiff B (vStar G v) = edgeCut G S' := by rintro ⟨S', hS', hS'eq⟩ apply hBcut have hBeq : B = edgeCut G (symmDiff S' {v}) := by rw [edgeCut_symmDiff, ← hS'eq, edgeCut_singleton, symmDiff_symmDiff_cancel_right] have hsd_2r : (symmDiff S' {v}).card ≤ 2 * r := by rw [Finset.symmDiff_def] calc ((S' \ {v}) ∪ ({v} \ S')).card ≤ (S' \ {v}).card + ({v} \ S').card := Finset.card_union_le _ _ _ ≤ S'.card + ({v} : Finset V).card := Nat.add_le_add (Finset.card_le_card Finset.sdiff_subset) (Finset.card_le_card Finset.sdiff_subset) _ ≤ 2 * r := by simp; omega have hsd_r : (symmDiff S' {v}).card ≤ r := by by_contra hgt; push Not at hgt have := hcut (symmDiff S' {v}) hgt hsd_2r rw [← hBeq] at this; omega exact ⟨symmDiff S' {v}, hsd_r, hBeq⟩ rw [tseitinKernel_eq_zero_of_not G χ r hnot, tseitinKernel_eq_zero_of_not G χ r hBcut, mul_zero] rw [heqK, sub_self, mul_zero] /-- **Headline Theorem 3E (Exact Sum-of-Squares Degree Lower Bound for Tseitin Formulas):** For EVERY connected graph `G`, charge `χ`, cutoff `1 ≤ r` with `2 * r < |V|`, and degree `d` satisfying `SmallSetCutGt G r (2 * d)`, NO degree-`2d` Sum-of-Squares refutation of `tseitinPCAxioms G χ ℝ` exists! -/ theorem tseitin_sos_degree_lb (G : SimpleGraph V) [DecidableRel G.Adj] (hconn : G.Connected) (χ : V → ZMod 2) {r d : ℕ} (hr1 : 1 ≤ r) (hr : 2 * r < Fintype.card V) (hcut : SmallSetCutGt G r (2 * d)) : ¬ SoSRefutes (tseitinPCAxioms G χ ℝ) (2 * d) := by rintro ⟨squares, idealTerms, hsq, hidt, heq⟩ have hpe : tseitinPE G χ r (-1 : MvPolynomial (GEdge G) ℝ) = (squares.map fun p => tseitinPE G χ r (p ^ 2)).sum + (idealTerms.map fun t => tseitinPE G χ r (t.1 * t.2)).sum := by have hlist : ∀ (L : List (MvPolynomial (GEdge G) ℝ)), tseitinPE G χ r L.sum = (L.map (tseitinPE G χ r)).sum := by intro L induction L with | nil => simp [tseitinPE, toMultilinearPM1_zero] | cons a tl ih => simp [tseitinPE_add, ih] rw [heq, tseitinPE_add, hlist, hlist, List.map_map, List.map_map] rfl have hlhs : tseitinPE G χ r (-1 : MvPolynomial (GEdge G) ℝ) = -1 := by have : (-1 : MvPolynomial (GEdge G) ℝ) = (-1 : ℝ) • (1 : MvPolynomial (GEdge G) ℝ) := by simp rw [this, tseitinPE_smul, tseitinPE_one G hconn χ hr]; ring have hsq_nn : 0 ≤ (squares.map fun p => tseitinPE G χ r (p ^ 2)).sum := by apply List.sum_nonneg intro x hx rcases List.mem_map.mp hx with ⟨p, hp, rfl⟩ exact tseitin_sos_pseudoexp_psd G hconn χ hr hcut p (by have := hsq p hp; omega) have hidt_zero : (idealTerms.map fun t => tseitinPE G χ r (t.1 * t.2)).sum = 0 := by apply List.sum_eq_zero intro x hx rcases List.mem_map.mp hx with ⟨t, ht, rfl⟩ exact tseitin_sos_pseudoexp_ideal G hconn χ hr1 hr hcut (hidt t ht).1 (hidt t ht).2 rw [hlhs, hidt_zero, add_zero] at hpe linarith /-- **Headline Theorem 3F (Explicit Infinite Family: Complete Graph `K_n` Dynamic PC & SoS Lower Bounds):** For every `n ≥ 10`, odd charge `χ : Fin n → ZMod 2`, and `r = (n - 1) / 3`: setting `M_n := (2 * r) * (n - 2 * r)` (which satisfies `M_n = Θ(n^2)`), for EVERY `D` with `2 * D < M_n`: 1. Over EVERY field `F`, `¬ PCRefutes F (tseitinPCAxioms (⊤ : SimpleGraph (Fin n)) χ F) D`, 2. Over EVERY field `F` with `(2 : F) ≠ 0`, `¬ PCRefutes F (fourierToBool F '' tseitinPCAxioms ⊤ χ F) D`, 3. Over `ℝ`, `¬ SoSRefutes (tseitinPCAxioms (⊤ : SimpleGraph (Fin n)) χ ℝ) (2 * D)`. -/ theorem tseitin_Kn_pc_sos_lb {n : ℕ} (hn : 10 ≤ n) (χ : Fin n → ZMod 2) {D : ℕ} (hD : 2 * D < (((n - 1) / 3) + 1) * (n - (((n - 1) / 3) + 1))) : (∀ (F : Type*) [Field F], ¬ PCRefutes F (tseitinPCAxioms (⊤ : SimpleGraph (Fin n)) χ F) D) ∧ (∀ (F : Type*) [Field F], (2 : F) ≠ 0 → ¬ PCRefutes F (fourierToBool F '' tseitinPCAxioms (⊤ : SimpleGraph (Fin n)) χ F) D) ∧ ¬ SoSRefutes (tseitinPCAxioms (⊤ : SimpleGraph (Fin n)) χ ℝ) (2 * D) := by have hconn : (⊤ : SimpleGraph (Fin n)).Connected := by have : Nonempty (Fin n) := ⟨⟨0, by omega⟩⟩ exact SimpleGraph.connected_top set r := (n - 1) / 3 have hr1 : 1 ≤ r := by omega have hr : 2 * r < Fintype.card (Fin n) := by simp [r]; omega have hcut : SmallSetCutGt (⊤ : SimpleGraph (Fin n)) r (2 * D) := by intro S hS1 hS2 rw [complete_graph_edgeCut_card] set s := S.card set a := r + 1 have hle : a * (n - a) ≤ s * (n - s) := by have ha_le : (a : ℤ) ≤ s := by omega have hs_le : (s : ℤ) ≤ (n : ℤ) - a := by omega have hZ : (a : ℤ) * ((n : ℤ) - a) ≤ (s : ℤ) * ((n : ℤ) - s) := by nlinarith have hcast : ((a * (n - a) : ℕ) : ℤ) ≤ ((s * (n - s) : ℕ) : ℤ) := by rw [Nat.cast_mul, Nat.cast_mul, Nat.cast_sub (by omega : a ≤ n), Nat.cast_sub (by omega : s ≤ n)] exact hZ exact Int.ofNat_le.mp hcast omega refine ⟨fun F _ => tseitin_dynamic_pc_degree_lb _ hconn χ hr1 hr hcut, fun F _ h2 => tseitin_boolean_pc_degree_lb h2 _ hconn χ hr1 hr hcut, tseitin_sos_degree_lb _ hconn χ hr1 hr hcut⟩ -- ------------------------------------------------------------------------------ -- 3E. Exact Odd-Cycle Sharpness & Separation: deg_SoS(C_n) = 2 < 3 = deg_PC(C_n) -- ------------------------------------------------------------------------------ /-- Helper: cycle edges `e_i = s(i, (i+1) % n)` for `C_n` (`n ≥ 3`). -/ def cycleEdge {n : ℕ} (hn : 3 ≤ n) (i : Fin n) : GEdge (cycleGraph n) := ⟨s(i, ⟨(i.1 + 1) % n, Nat.mod_lt _ (by omega)⟩), by rw [SimpleGraph.mem_edgeFinset, SimpleGraph.mem_edgeSet, cycleGraph_adj_iff] refine ⟨?_, Or.inl rfl⟩ intro heq have hv := congrArg Fin.val heq; dsimp at hv by_cases hlt : i.1 + 1 < n · rw [Nat.mod_eq_of_lt hlt] at hv; omega · have : i.1 + 1 = n := by omega rw [this, Nat.mod_self] at hv; omega⟩ lemma cycleEdge_injective {n : ℕ} (hn : 3 ≤ n) : Function.Injective (cycleEdge hn) := by intro i j heq have hsym := congrArg Subtype.val heq dsimp only [cycleEdge] at hsym rw [Sym2.eq_iff] at hsym rcases hsym with ⟨h1, _⟩ | ⟨h1, h2⟩ · exact h1 · have hv1 := congrArg Fin.val h1 have hv2 := congrArg Fin.val h2 dsimp at hv1 hv2 by_cases hi : i.1 + 1 < n <;> by_cases hj : j.1 + 1 < n · rw [Nat.mod_eq_of_lt hi] at hv2; rw [Nat.mod_eq_of_lt hj] at hv1; omega · have hjeq : j.1 + 1 = n := by omega rw [hjeq, Nat.mod_self] at hv1; rw [Nat.mod_eq_of_lt hi] at hv2; omega · have hieq : i.1 + 1 = n := by omega rw [hieq, Nat.mod_self] at hv2; rw [Nat.mod_eq_of_lt hj] at hv1; omega · omega lemma cycleGraph_vStar_pair {n : ℕ} (hn : 3 ≤ n) (k : ℕ) (hk : k < n) : vStar (cycleGraph n) ⟨k, hk⟩ = {cycleEdge hn ⟨(k + n - 1) % n, Nat.mod_lt _ (by omega)⟩, cycleEdge hn ⟨k, hk⟩} := by have hne : cycleEdge hn ⟨(k + n - 1) % n, Nat.mod_lt _ (by omega)⟩ ≠ cycleEdge hn ⟨k, hk⟩ := by intro h have hv := congrArg Fin.val (cycleEdge_injective hn h); dsimp at hv by_cases h0 : k = 0 · subst h0; simp [Nat.mod_eq_of_lt (by omega : n - 1 < n)] at hv; omega · have : k + n - 1 = n + (k - 1) := by omega rw [this, Nat.add_mod_left, Nat.mod_eq_of_lt (by omega : k - 1 < n)] at hv; omega have hsub : {cycleEdge hn ⟨(k + n - 1) % n, Nat.mod_lt _ (by omega)⟩, cycleEdge hn ⟨k, hk⟩} ⊆ vStar (cycleGraph n) ⟨k, hk⟩ := by intro e he simp only [Finset.mem_insert, Finset.mem_singleton] at he simp only [vStar, Finset.mem_filter, Finset.mem_univ, true_and] rcases he with rfl | rfl · dsimp [cycleEdge]; rw [Sym2.mem_iff]; right apply Fin.ext; dsimp by_cases h0 : k = 0 · subst h0 have hm : (0 + n - 1) % n = n - 1 := by simp [Nat.mod_eq_of_lt (by omega : n - 1 < n)] rw [hm, show n - 1 + 1 = n by omega, Nat.mod_self] · have hm : (k + n - 1) % n = k - 1 := by have : k + n - 1 = n + (k - 1) := by omega rw [this, Nat.add_mod_left, Nat.mod_eq_of_lt (by omega)] rw [hm, show k - 1 + 1 = k by omega, Nat.mod_eq_of_lt hk] · dsimp [cycleEdge]; rw [Sym2.mem_iff]; left; rfl exact (Finset.eq_of_subset_of_card_le hsub (by rw [cycleGraph_star_card hn, Finset.card_pair hne])).symm lemma list_sum_flatMap {α β : Type*} [AddCommMonoid β] (L : List α) (f : α → List β) : (L.flatMap f).sum = (L.map fun a => (f a).sum).sum := by induction L with | nil => simp | cons a t ih => simp [List.flatMap_cons, List.sum_append, ih] lemma list_range_map_sum {α : Type*} [AddCommMonoid α] (m : ℕ) (f : ℕ → α) : ((List.range m).map f).sum = ∑ i ∈ Finset.range m, f i := by induction m with | zero => simp | succ k ih => rw [List.range_succ, List.map_append, List.sum_append, List.map_singleton, List.sum_singleton, Finset.sum_range_succ, ih] lemma zmod2_sign_mul_ring {R : Type*} [Ring R] (a b : ZMod 2) : (if a = 1 then (-1 : R) else 1) * (if b = 1 then (-1 : R) else 1) = if a + b = 1 then (-1 : R) else 1 := by have hz2 : ∀ x : ZMod 2, x = 0 ∨ x = 1 := fun x => by fin_cases x · left; rfl · right; rfl have h01 : (0 : ZMod 2) ≠ 1 := by decide have h11 : (1 : ZMod 2) + 1 = 0 := by decide rcases hz2 a with rfl | rfl <;> rcases hz2 b with rfl | rfl · simp [h01] · simp [h01] · simp [h01] · simp [h11, h01] /-- **Headline Theorem 3G (Exact Odd-Cycle `C_n` Sum-of-Squares Degree = 2 Sharpness):** For EVERY `n ≥ 3` and EVERY odd charge `χ : Fin n → ZMod 2`, `tseitinPCAxioms (cycleGraph n) χ ℝ` has an EXPLICIT degree-2 Sum-of-Squares refutation (via the exact Cauchy–Schwarz identity `4 X_0^2 + ∑_{i < j} (a_i - a_j)^2 = n ∑_i (y_i - y_{i+1})^2`), while degree 0 is impossible (since `W̃_1(C_n) = 2 > 0`). Thus `deg_SoS(Tseitin(C_n, χ)) = 2`! -/ theorem tseitin_cycle_sos_exact {n : ℕ} (hn : 3 ≤ n) (χ : Fin n → ZMod 2) (hodd : ∑ v : Fin n, χ v = 1) : ¬ SoSRefutes (tseitinPCAxioms (cycleGraph n) χ ℝ) 0 ∧ SoSRefutes (tseitinPCAxioms (cycleGraph n) χ ℝ) 2 := by classical constructor · -- Degree 0 impossible via `tseitin_sos_degree_lb` with `r = 1, d = 0`! have hcut : SmallSetCutGt (cycleGraph n) 1 0 := by intro S hS1 hS2 -- Every nonempty proper subset of connected `C_n` has nonempty cut. have hne0 : S ≠ ∅ := Finset.nonempty_iff_ne_empty.mp (Finset.card_pos.mp (by omega)) have hneU : S ≠ Finset.univ := by intro h; rw [h, Finset.card_univ, Fintype.card_fin] at hS2; omega have hcut_ne : edgeCut (cycleGraph n) S ≠ ∅ := by intro hemp rcases edgeCut_eq_empty_iff (cycleGraph n) (cycleGraph_connected hn) S hemp with h | h · exact hne0 h · exact hneU h exact Finset.card_pos.mpr (Finset.nonempty_iff_ne_empty.mpr hcut_ne) exact tseitin_sos_degree_lb (d := 0) (cycleGraph n) (cycleGraph_connected hn) χ (le_refl 1) (by simp; omega) hcut · -- Explicit degree-2 SoS refutation via exact algebraic Cauchy–Schwarz identity! let eOf : ℕ → GEdge (cycleGraph n) := fun k => cycleEdge hn ⟨k % n, Nat.mod_lt _ (by omega)⟩ let XOf : ℕ → MvPolynomial (GEdge (cycleGraph n)) ℝ := fun k => MvPolynomial.X (eOf k) let cOf : ℕ → ℝ := fun k => if h : k < n then (if χ ⟨k, h⟩ = 1 then (-1 : ℝ) else 1) else 1 -- Cumulative sign `s_k = ∏_{j=1}^k c_j` for `0 ≤ k ≤ n`. -- Actually define `s(0) = 1`, `s(k + 1) = s(k) * cOf ((k + 1) % n)`! let sOf : ℕ → ℝ := fun k => ∏ j ∈ Finset.range k, cOf ((j + 1) % n) have hsOf_sq : ∀ k, sOf k ^ 2 = 1 := by intro k induction k with | zero => simp [sOf] | succ k ih => rw [show sOf (k + 1) = sOf k * cOf ((k + 1) % n) from Finset.prod_range_succ _ k, mul_pow, ih, one_mul] dsimp [cOf] split_ifs <;> norm_num have hcOf_sq : ∀ k, cOf k ^ 2 = 1 := by intro k; dsimp [cOf]; split_ifs <;> norm_num -- Key parity product: `sOf n = -1` (since `∑ v, χ v = 1` in `ZMod 2`!). have hsOf_n : sOf n = -1 := by have hprod_eq : sOf n = ∏ v : Fin n, (if χ v = 1 then (-1 : ℝ) else 1) := by -- `j ↦ ⟨(j + 1) % n, _⟩` is a bijection `Finset.range n → Finset.univ`! dsimp only [sOf] refine Finset.prod_bij (fun j _ => (⟨(j + 1) % n, Nat.mod_lt _ (by omega)⟩ : Fin n)) (fun _ _ => Finset.mem_univ _) ?_ ?_ ?_ · intro j₁ hj₁ j₂ hj₂ heq have h1 : j₁ < n := Finset.mem_range.mp hj₁ have h2 : j₂ < n := Finset.mem_range.mp hj₂ have hv := congrArg Fin.val heq; dsimp at hv by_cases h1lt : j₁ + 1 < n <;> by_cases h2lt : j₂ + 1 < n · rw [Nat.mod_eq_of_lt h1lt, Nat.mod_eq_of_lt h2lt] at hv; omega · have : j₂ + 1 = n := by omega rw [this, Nat.mod_self, Nat.mod_eq_of_lt h1lt] at hv; omega · have : j₁ + 1 = n := by omega rw [this, Nat.mod_self, Nat.mod_eq_of_lt h2lt] at hv; omega · omega · intro v _ refine ⟨(v.1 + n - 1) % n, Finset.mem_range.mpr (Nat.mod_lt _ (by omega)), ?_⟩ apply Fin.ext; dsimp by_cases h0 : v.1 = 0 · rw [h0]; simp [Nat.mod_eq_of_lt (by omega : n - 1 < n), show n - 1 + 1 = n by omega] · have hm : (v.1 + n - 1) % n = v.1 - 1 := by have : v.1 + n - 1 = n + (v.1 - 1) := by omega rw [this, Nat.add_mod_left, Nat.mod_eq_of_lt (by omega)] rw [hm, show v.1 - 1 + 1 = v.1 by omega, Nat.mod_eq_of_lt v.2] · intro j _ have hlt : (j + 1) % n < n := Nat.mod_lt _ (by omega) simp only [cOf, hlt, ↓reduceDIte] rw [hprod_eq] -- General lemma: `∏ v ∈ S, (if χ v = 1 then -1 else 1) = if (∑ v ∈ S, χ v) = 1 then -1 else 1`. have hgen : ∀ S : Finset (Fin n), (∏ v ∈ S, (if χ v = 1 then (-1 : ℝ) else 1)) = if (∑ v ∈ S, χ v) = 1 then (-1 : ℝ) else 1 := by intro S induction S using Finset.induction with | empty => simp | @insert v S' hv ih => rw [Finset.prod_insert hv, Finset.sum_insert hv, ih] exact zmod2_sign_mul_ring (R := ℝ) (χ v) (∑ u ∈ S', χ u) rw [hgen Finset.univ, hodd, if_pos rfl] -- Define `y_k := C (sOf k) * XOf k` for `0 ≤ k ≤ n`. let yOf : ℕ → MvPolynomial (GEdge (cycleGraph n)) ℝ := fun k => MvPolynomial.C (sOf k) * XOf k have hy0 : yOf 0 = XOf 0 := by simp [yOf, sOf] have hyn : yOf n = -XOf 0 := by simp [yOf, hsOf_n, XOf, eOf] -- Define `a_i := y_i - y_{i+1}` for `i < n`. let aOf : ℕ → MvPolynomial (GEdge (cycleGraph n)) ℝ := fun i => yOf i - yOf (i + 1) -- Telescoping sum: `∑_{i=0}^{n-1} a_i = y_0 - y_n = 2 X_0`! have htele : ∑ i ∈ Finset.range n, aOf i = MvPolynomial.C 2 * XOf 0 := by have hsub : ∀ m, ∑ i ∈ Finset.range m, (yOf i - yOf (i + 1)) = yOf 0 - yOf m := by intro m induction m with | zero => simp | succ m ih => rw [Finset.sum_range_succ, ih]; ring rw [hsub n, hy0, hyn] have h2 : (MvPolynomial.C (2 : ℝ) : MvPolynomial (GEdge (cycleGraph n)) ℝ) = 1 + 1 := by rw [show (2 : ℝ) = 1 + 1 by norm_num, map_add, map_one] rw [h2]; ring -- Exact Lagrange / Cauchy–Schwarz identity in any commutative ring: -- `2 * n * ∑_{i · refine le_trans (MvPolynomial.totalDegree_mul _ _) ?_ rw [MvPolynomial.totalDegree_C, zero_add] exact mvTotalDegree_X_le _ have hdeg_X2 : ∀ e : GEdge (cycleGraph n), ((MvPolynomial.X e : MvPolynomial (GEdge (cycleGraph n)) ℝ) ^ 2 - 1).totalDegree ≤ 2 := by intro e refine le_trans (MvPolynomial.totalDegree_sub _ _) (max_le ?_ (by simp)) have h1 := MvPolynomial.totalDegree_pow (MvPolynomial.X e : MvPolynomial (GEdge (cycleGraph n)) ℝ) 2 have h2 := mvTotalDegree_X_le (R := ℝ) e omega have hdeg_v : ∀ i, (XOf i * XOf (i + 1) - MvPolynomial.C (cOf ((i + 1) % n))).totalDegree ≤ 2 := by intro i refine le_trans (MvPolynomial.totalDegree_sub _ _) (max_le ?_ (by simp)) exact le_trans (MvPolynomial.totalDegree_mul _ _) (Nat.add_le_add (mvTotalDegree_X_le _) (mvTotalDegree_X_le _)) -- Construct the explicit lists `squares` and `idealTerms`! let idxList := List.range n let squares : List (MvPolynomial (GEdge (cycleGraph n)) ℝ) := (idxList.flatMap fun i => idxList.map fun j => MvPolynomial.C ((Real.sqrt 8)⁻¹) * (aOf i - aOf j)) let idealTerms : List (MvPolynomial (GEdge (cycleGraph n)) ℝ × MvPolynomial (GEdge (cycleGraph n)) ℝ) := (1, XOf 0 ^ 2 - 1) :: (idxList.flatMap fun i => [(MvPolynomial.C (-(n : ℝ) / 4), XOf i ^ 2 - 1), (MvPolynomial.C (-(n : ℝ) / 4), XOf (i + 1) ^ 2 - 1), (MvPolynomial.C ((n : ℝ) / 2 * cOf ((i + 1) % n)), XOf i * XOf (i + 1) - MvPolynomial.C (cOf ((i + 1) % n)))]) refine ⟨squares, idealTerms, ?_, ?_, ?_⟩ · intro p hp simp only [squares, List.mem_flatMap, List.mem_map] at hp rcases hp with ⟨i, _, j, _, rfl⟩ have hd : (MvPolynomial.C ((Real.sqrt 8)⁻¹) * (aOf i - aOf j)).totalDegree ≤ 1 := by refine le_trans (MvPolynomial.totalDegree_mul _ _) ?_ simp only [MvPolynomial.totalDegree_C, zero_add] exact le_trans (MvPolynomial.totalDegree_sub _ _) (max_le (hdeg_a i) (hdeg_a j)) omega · intro t ht simp only [idealTerms, List.mem_cons, List.mem_flatMap, List.mem_range, idxList] at ht rcases ht with rfl | ⟨i, hi, hmem⟩ · exact ⟨Or.inl ⟨eOf 0, rfl⟩, by rw [MvPolynomial.totalDegree_one, zero_add]; exact hdeg_X2 (eOf 0)⟩ · simp only [List.not_mem_nil, or_false] at hmem rcases hmem with rfl | rfl | rfl · exact ⟨Or.inl ⟨eOf i, rfl⟩, by rw [MvPolynomial.totalDegree_C, zero_add]; exact hdeg_X2 (eOf i)⟩ · exact ⟨Or.inl ⟨eOf (i + 1), rfl⟩, by rw [MvPolynomial.totalDegree_C, zero_add]; exact hdeg_X2 (eOf (i + 1))⟩ · exact ⟨hvax i hi, by rw [MvPolynomial.totalDegree_C, zero_add]; exact hdeg_v i⟩ · -- Verify the exact polynomial identity! have hsq_sum : (squares.map fun p => p ^ 2).sum = MvPolynomial.C ((8 : ℝ)⁻¹) * ∑ i ∈ Finset.range n, ∑ j ∈ Finset.range n, (aOf i - aOf j) ^ 2 := by have hsqrt8 : (MvPolynomial.C ((Real.sqrt 8)⁻¹) : MvPolynomial (GEdge (cycleGraph n)) ℝ) ^ 2 = MvPolynomial.C (8 : ℝ)⁻¹ := by rw [← map_pow, inv_pow, Real.sq_sqrt (by norm_num : (0 : ℝ) ≤ 8)] dsimp only [squares, idxList] rw [List.map_flatMap, list_sum_flatMap] have hinner : ∀ i, ((List.range n).map (fun j => MvPolynomial.C ((Real.sqrt 8)⁻¹) * (aOf i - aOf j)) |>.map fun p => p ^ 2).sum = MvPolynomial.C (8 : ℝ)⁻¹ * ∑ j ∈ Finset.range n, (aOf i - aOf j) ^ 2 := by intro i rw [List.map_map, list_range_map_sum, Finset.mul_sum] apply Finset.sum_congr rfl; intro j _ dsimp only [Function.comp_apply] rw [mul_pow, hsqrt8] simp_rw [hinner] rw [list_range_map_sum, Finset.mul_sum] have hidt_sum : (idealTerms.map fun t => t.1 * t.2).sum = (XOf 0 ^ 2 - 1) + MvPolynomial.C (-(n : ℝ) / 4) * ∑ i ∈ Finset.range n, aOf i ^ 2 := by dsimp only [idealTerms, idxList] rw [List.map_cons, List.sum_cons, one_mul, List.map_flatMap, list_sum_flatMap] congr 1 have hterm : ∀ i ∈ Finset.range n, (MvPolynomial.C (-(n : ℝ) / 4) * (XOf i ^ 2 - 1) + (MvPolynomial.C (-(n : ℝ) / 4) * (XOf (i + 1) ^ 2 - 1) + (MvPolynomial.C ((n : ℝ) / 2 * cOf ((i + 1) % n)) * (XOf i * XOf (i + 1) - MvPolynomial.C (cOf ((i + 1) % n))) + 0))) = MvPolynomial.C (-(n : ℝ) / 4) * aOf i ^ 2 := by intro i hi rw [ha_sq i hi] have hcoeff : MvPolynomial.C (-(n : ℝ) / 4) * MvPolynomial.C (-2 * cOf ((i + 1) % n)) = (MvPolynomial.C ((n : ℝ) / 2 * cOf ((i + 1) % n)) : MvPolynomial (GEdge (cycleGraph n)) ℝ) := by rw [← map_mul]; congr 1; ring rw [mul_add, mul_add, ← mul_assoc, hcoeff]; ring have hconv : ∀ m ≤ n, ((List.range m).map fun i => ([ (MvPolynomial.C (-(n : ℝ) / 4), XOf i ^ 2 - 1), (MvPolynomial.C (-(n : ℝ) / 4), XOf (i + 1) ^ 2 - 1), (MvPolynomial.C ((n : ℝ) / 2 * cOf ((i + 1) % n)), XOf i * XOf (i + 1) - MvPolynomial.C (cOf ((i + 1) % n))) ].map fun t => t.1 * t.2).sum).sum = MvPolynomial.C (-(n : ℝ) / 4) * ∑ i ∈ Finset.range m, aOf i ^ 2 := by intro m induction m with | zero => intro _; simp | succ m ihm => intro hm rw [List.range_succ, List.map_append, List.sum_append, List.map_singleton, List.sum_singleton, ihm (by omega), Finset.sum_range_succ, mul_add] congr 1 exact hterm m (Finset.mem_range.mpr hm) exact hconv n (le_refl n) rw [hsq_sum, hidt_sum, ← hlagrange, htele] have hc1 : MvPolynomial.C (8 : ℝ)⁻¹ * MvPolynomial.C (2 * (n : ℝ)) + MvPolynomial.C (-(n : ℝ) / 4) = (0 : MvPolynomial (GEdge (cycleGraph n)) ℝ) := by rw [← map_mul, ← map_add] have : (8 : ℝ)⁻¹ * (2 * (n : ℝ)) + -(n : ℝ) / 4 = 0 := by ring rw [this, map_zero] have hc2 : MvPolynomial.C (8 : ℝ)⁻¹ * MvPolynomial.C (2 : ℝ) * (MvPolynomial.C (2 : ℝ)) ^ 2 = (1 : MvPolynomial (GEdge (cycleGraph n)) ℝ) := by rw [← map_pow, ← map_mul, ← map_mul] have : (8 : ℝ)⁻¹ * 2 * (2 : ℝ) ^ 2 = 1 := by norm_num rw [this, map_one] calc (-1 : MvPolynomial (GEdge (cycleGraph n)) ℝ) = 0 * (∑ i ∈ Finset.range n, aOf i ^ 2) + (1 - 1) * XOf 0 ^ 2 - 1 := by ring _ = (MvPolynomial.C (8 : ℝ)⁻¹ * MvPolynomial.C (2 * (n : ℝ)) + MvPolynomial.C (-(n : ℝ) / 4)) * (∑ i ∈ Finset.range n, aOf i ^ 2) + (1 - MvPolynomial.C (8 : ℝ)⁻¹ * MvPolynomial.C (2 : ℝ) * (MvPolynomial.C 2) ^ 2) * XOf 0 ^ 2 - 1 := by rw [hc1, hc2] _ = MvPolynomial.C (8 : ℝ)⁻¹ * (MvPolynomial.C (2 * (n : ℝ)) * (∑ i ∈ Finset.range n, aOf i ^ 2) - MvPolynomial.C 2 * (MvPolynomial.C 2 * XOf 0) ^ 2) + (XOf 0 ^ 2 - 1 + MvPolynomial.C (-(n : ℝ) / 4) * ∑ i ∈ Finset.range n, aOf i ^ 2) := by ring /-- **Headline Theorem 3H (Exact Odd-Cycle `C_n` Dynamic PC Degree = 3 > 2 = SoS Degree Separation):** For EVERY `n ≥ 3`, EVERY odd charge `χ : Fin n → ZMod 2`, and EVERY field `F` with `(2 : F) ≠ 0`: 1. `¬ PCRefutes F (tseitinPCAxioms (cycleGraph n) χ F) 2` (degree 2 is impossible because every axiom has purely even monomial degrees and a degree-2 functional `L` annihilates all axioms with `L(1) = 1`!), 2. `PCRefutes F (tseitinPCAxioms (cycleGraph n) χ F) 3` (explicit degree-3 dynamic PC refutation!). Combined with `tseitin_cycle_sos_exact`, this strictly separates Dynamic PC (`deg = 3`) from both Resolution width (`w = 2`) and Sum-of-Squares (`deg = 2`) on every odd-charged cycle `C_n`! -/ theorem tseitin_cycle_pc_degree_exact {n : ℕ} (hn : 3 ≤ n) (χ : Fin n → ZMod 2) (hodd : ∑ v : Fin n, χ v = 1) {F : Type*} [Field F] (h2 : (2 : F) ≠ 0) : ¬ PCRefutes F (tseitinPCAxioms (cycleGraph n) χ F) 2 ∧ PCRefutes F (tseitinPCAxioms (cycleGraph n) χ F) 3 := by classical let eOf : ℕ → GEdge (cycleGraph n) := fun k => cycleEdge hn ⟨k % n, Nat.mod_lt _ (by omega)⟩ let XOf : ℕ → MvPolynomial (GEdge (cycleGraph n)) F := fun k => MvPolynomial.X (eOf k) let cOf : ℕ → F := fun k => if h : k < n then (if χ ⟨k, h⟩ = 1 then (-1 : F) else 1) else 1 constructor · -- Part 1: No degree-2 Dynamic PC refutation! -- Every axiom of `C_n` has ONLY monomials of even total degree (`0` or `2`). -- Define the linear functional `L : MvPolynomial E F → F` on degree `≤ 2`: -- `L(1) = 1`, `L(X_e^2) = 1`, `L(X_{e_{k-1}} X_{e_k}) = c_k`, and `L(m) = 0` for all other monomials! -- Show by induction on `PCDerives F axioms 2 p` that: -- (a) `p` is purely even-degree (`∀ m ∈ p.support, Even (m.sum fun _ k => k)`), AND -- (b) `L(p) = 0`! -- Wait: for `mul_var e q` with `deg(q) + 1 ≤ 2` (so `deg(q) ≤ 1`): -- Since `q` is purely even-degree AND `deg(q) ≤ 1`, `q` MUST be a constant `C a`! -- Since `L(q) = 0` and `L(C a) = a`, we get `a = 0`, so `q = 0`, so `X_e * q = 0`!! -- OH! THAT PROOF IS 15 LINES AND WORKS FOR EVERY `n ≥ 3`! let evenPoly (p : MvPolynomial (GEdge (cycleGraph n)) F) : Prop := ∀ m ∈ p.support, Even (m.sum fun _ k => k) let monVal (m : GEdge (cycleGraph n) →₀ ℕ) : F := if m = 0 then 1 else if ∃ e, m = Finsupp.single e 2 then 1 else if h : ∃ v : Fin n, m = ∑ e ∈ vStar (cycleGraph n) v, Finsupp.single e 1 then if χ (Classical.choose h) = 1 then -1 else 1 else 0 let L (p : MvPolynomial (GEdge (cycleGraph n)) F) : F := ∑ m ∈ p.support, MvPolynomial.coeff m p * monVal m have hL_add : ∀ p q, L (p + q) = L p + L q := by intro p q let S := p.support ∪ q.support have h1 : L (p + q) = ∑ m ∈ S, MvPolynomial.coeff m (p + q) * monVal m := by dsimp only [L] refine Finset.sum_subset MvPolynomial.support_add ?_ intro m _ hnot have hc : MvPolynomial.coeff m (p + q) = 0 := by by_contra hne; exact hnot (MvPolynomial.mem_support_iff.mpr hne) simp [hc] have h2 : L p = ∑ m ∈ S, MvPolynomial.coeff m p * monVal m := by dsimp only [L] refine Finset.sum_subset Finset.subset_union_left ?_ intro m _ hnot have hc : MvPolynomial.coeff m p = 0 := by by_contra hne; exact hnot (MvPolynomial.mem_support_iff.mpr hne) simp [hc] have h3 : L q = ∑ m ∈ S, MvPolynomial.coeff m q * monVal m := by dsimp only [L] refine Finset.sum_subset Finset.subset_union_right ?_ intro m _ hnot have hc : MvPolynomial.coeff m q = 0 := by by_contra hne; exact hnot (MvPolynomial.mem_support_iff.mpr hne) simp [hc] rw [h1, h2, h3, ← Finset.sum_add_distrib] apply Finset.sum_congr rfl; intro m _ rw [MvPolynomial.coeff_add]; ring have hL_smul : ∀ c p, L (c • p) = c * L p := by intro c p have h1 : L (c • p) = ∑ m ∈ p.support, MvPolynomial.coeff m (c • p) * monVal m := by dsimp only [L] refine Finset.sum_subset (fun m hm => MvPolynomial.support_smul hm) ?_ intro m _ hnot have hc : MvPolynomial.coeff m (c • p) = 0 := by by_contra hne; exact hnot (MvPolynomial.mem_support_iff.mpr hne) simp [hc] rw [h1]; dsimp only [L]; rw [Finset.mul_sum] apply Finset.sum_congr rfl; intro m _ rw [MvPolynomial.coeff_smul, smul_eq_mul]; ring have hL_mon : ∀ m c, L (MvPolynomial.monomial m c) = c * monVal m := by intro m c; dsimp only [L] by_cases hc : c = 0 · subst hc; simp · have hsupp : (MvPolynomial.monomial m c).support = {m} := MvPolynomial.support_monomial.trans (if_neg hc) rw [hsupp, Finset.sum_singleton, MvPolynomial.coeff_monomial, if_pos rfl] -- Uniqueness of vertex `v` for `∑ e ∈ vStar v, single e 1` (since `n ≥ 3`, distinct vertices -- have distinct edge stars!). have hvStar_inj : ∀ v₁ v₂ : Fin n, (∑ e ∈ vStar (cycleGraph n) v₁, Finsupp.single e (1 : ℕ)) = (∑ e ∈ vStar (cycleGraph n) v₂, Finsupp.single e (1 : ℕ)) → v₁ = v₂ := by intro v₁ v₂ heq have hset : vStar (cycleGraph n) v₁ = vStar (cycleGraph n) v₂ := by ext e have h1 : (∑ e' ∈ vStar (cycleGraph n) v₁, Finsupp.single e' (1 : ℕ)) e = if e ∈ vStar (cycleGraph n) v₁ then 1 else 0 := by rw [Finsupp.finsetSum_apply] simp [Finsupp.single_apply, eq_comm] have h2 : (∑ e' ∈ vStar (cycleGraph n) v₂, Finsupp.single e' (1 : ℕ)) e = if e ∈ vStar (cycleGraph n) v₂ then 1 else 0 := by rw [Finsupp.finsetSum_apply] simp [Finsupp.single_apply, eq_comm] have he := congrArg (fun f : GEdge (cycleGraph n) →₀ ℕ => f e) heq rw [h1, h2] at he by_cases h1m : e ∈ vStar (cycleGraph n) v₁ <;> by_cases h2m : e ∈ vStar (cycleGraph n) v₂ <;> simp_all -- Every edge in `vStar v₁ = vStar v₂` contains BOTH `v₁` and `v₂`! -- If `v₁ ≠ v₂`, at most ONE edge `s(v₁, v₂)` can contain both `v₁` and `v₂`, contradicting `|vStar v₁| = 2`! by_contra hne have hcard := cycleGraph_star_card hn v₁ have hsub : vStar (cycleGraph n) v₁ ⊆ (Finset.univ.filter fun e : GEdge (cycleGraph n) => e.1 = s(v₁, v₂)) := by intro e he have he1 : v₁ ∈ e.1 := (Finset.mem_filter.mp he).2 have he2' : e ∈ vStar (cycleGraph n) v₂ := hset ▸ he have he2 : v₂ ∈ e.1 := (Finset.mem_filter.mp he2').2 simp only [Finset.mem_filter, Finset.mem_univ, true_and] rcases e with ⟨e_raw, _⟩ induction e_raw using Sym2.ind with | _ a b => rw [Sym2.mem_iff] at he1 he2 rcases he1 with rfl | rfl <;> rcases he2 with rfl | rfl · exact absurd rfl hne · rfl · exact Sym2.eq_swap · exact absurd rfl hne have hle1 : (Finset.univ.filter fun e : GEdge (cycleGraph n) => e.1 = s(v₁, v₂)).card ≤ 1 := by rw [Finset.card_le_one] intro e₁ h1 e₂ h2 apply Subtype.ext exact (Finset.mem_filter.mp h1).2.trans (Finset.mem_filter.mp h2).2.symm have := Finset.card_le_card hsub omega have h0v : monVal 0 = 1 := if_pos rfl have hinv : ∀ p, PCDerives F (tseitinPCAxioms (cycleGraph n) χ F) 2 p → evenPoly p ∧ L p = 0 := by intro p hp induction hp with | @ax p hmem _ => rcases hmem with ⟨e, rfl⟩ | ⟨v, rfl⟩ · have hrew : (MvPolynomial.X e : MvPolynomial (GEdge (cycleGraph n)) F) ^ 2 - 1 = MvPolynomial.monomial (Finsupp.single e 2) 1 + (-1 : F) • MvPolynomial.monomial 0 1 := by rw [sq, MvPolynomial.X, MvPolynomial.monomial_mul, ← Finsupp.single_add, one_mul, MvPolynomial.smul_monomial, smul_eq_mul, mul_one, show (1 : ℕ) + 1 = 2 from rfl, sub_eq_add_neg] have hneg1 : (-1 : MvPolynomial (GEdge (cycleGraph n)) F) = MvPolynomial.monomial 0 (-1) := by rw [← MvPolynomial.C_apply, map_neg, map_one] rw [hneg1] rw [hrew] constructor · intro m hm have hsub := Finset.mem_of_subset MvPolynomial.support_add hm rcases Finset.mem_union.mp hsub with h1 | h2 · have hm1 : m = Finsupp.single e 2 := Finset.mem_singleton.mp (MvPolynomial.support_monomial_subset h1) rw [hm1, Finsupp.sum_single_index rfl]; exact even_two · have hm2 : m = 0 := by have := MvPolynomial.support_smul (a := (-1 : F)) h2 exact Finset.mem_singleton.mp (MvPolynomial.support_monomial_subset this) rw [hm2, Finsupp.sum_zero_index]; exact ⟨0, rfl⟩ · rw [hL_add, hL_smul, hL_mon, hL_mon] have hne0 : Finsupp.single e (2 : ℕ) ≠ 0 := by intro h; have := congrArg (fun f : GEdge (cycleGraph n) →₀ ℕ => f e) h; simp at this have h2v : monVal (Finsupp.single e 2) = 1 := by dsimp only [monVal] rw [if_neg hne0, if_pos ⟨e, rfl⟩] rw [h2v, h0v]; ring · set sgn : F := if χ v = 1 then (-1 : F) else 1 let mv : GEdge (cycleGraph n) →₀ ℕ := ∑ e ∈ vStar (cycleGraph n) v, Finsupp.single e 1 have hprod_mon : (∏ e ∈ vStar (cycleGraph n) v, (MvPolynomial.X e : MvPolynomial (GEdge (cycleGraph n)) F)) = MvPolynomial.monomial mv 1 := by dsimp only [mv] induction (vStar (cycleGraph n) v) using Finset.induction with | empty => simp | @insert e S he ih => rw [Finset.prod_insert he, Finset.sum_insert he, ih, MvPolynomial.X, MvPolynomial.monomial_mul, one_mul] have hrew : (∏ e ∈ vStar (cycleGraph n) v, (MvPolynomial.X e : MvPolynomial (GEdge (cycleGraph n)) F)) - MvPolynomial.C sgn = MvPolynomial.monomial mv 1 + (-sgn) • MvPolynomial.monomial 0 1 := by rw [hprod_mon, MvPolynomial.smul_monomial, smul_eq_mul, mul_one, ← MvPolynomial.C_apply, map_neg, sub_eq_add_neg] have hmv_sum : (mv.sum fun _ k => k) = 2 := by have hcard := cycleGraph_star_card hn v have h1 : ∀ S : Finset (GEdge (cycleGraph n)), ((∑ e ∈ S, Finsupp.single e (1 : ℕ)).sum fun _ k => k) = S.card := by intro S induction S using Finset.induction with | empty => simp | @insert e S' he ih => rw [Finset.sum_insert he, Finset.card_insert_of_notMem he, Finsupp.sum_add_index' (fun _ => rfl) (fun _ _ _ => rfl), ih, Finsupp.sum_single_index rfl] omega rw [h1, hcard] rw [hrew] constructor · intro m hm have hsub := Finset.mem_of_subset MvPolynomial.support_add hm rcases Finset.mem_union.mp hsub with h1 | h2 · have hm1 : m = mv := Finset.mem_singleton.mp (MvPolynomial.support_monomial_subset h1) rw [hm1, hmv_sum]; exact even_two · have hm2 : m = 0 := by have := MvPolynomial.support_smul (a := -sgn) h2 exact Finset.mem_singleton.mp (MvPolynomial.support_monomial_subset this) rw [hm2, Finsupp.sum_zero_index]; exact ⟨0, rfl⟩ · rw [hL_add, hL_smul, hL_mon, hL_mon] have hmv_ne0 : mv ≠ 0 := by intro h; rw [h] at hmv_sum; simp at hmv_sum have hmv_ne2 : ¬ ∃ e, mv = Finsupp.single e 2 := by rintro ⟨e, he⟩ have hval : mv e ≤ 1 := by dsimp only [mv] rw [Finsupp.finsetSum_apply] have : (∑ e' ∈ vStar (cycleGraph n) v, (Finsupp.single e' (1 : ℕ)) e) = if e ∈ vStar (cycleGraph n) v then 1 else 0 := by simp [Finsupp.single_apply, eq_comm] rw [this]; split_ifs <;> omega rw [he, Finsupp.single_eq_same] at hval; omega have hmv_val : monVal mv = sgn := by unfold monVal rw [if_neg hmv_ne0, if_neg hmv_ne2, dif_pos ⟨v, rfl⟩] have hch : Classical.choose (⟨v, rfl⟩ : ∃ v', mv = ∑ e ∈ vStar (cycleGraph n) v', Finsupp.single e 1) = v := hvStar_inj _ v (Classical.choose_spec (⟨v, rfl⟩ : ∃ v', mv = ∑ e ∈ vStar (cycleGraph n) v', Finsupp.single e 1)).symm rw [hch] rw [hmv_val, h0v]; ring | add _ _ ih1 ih2 => refine ⟨fun m hm => ?_, by rw [hL_add, ih1.2, ih2.2, add_zero]⟩ rcases Finset.mem_union.mp (Finset.mem_of_subset MvPolynomial.support_add hm) with h1 | h2 · exact ih1.1 m h1 · exact ih2.1 m h2 | smul c _ ih => refine ⟨fun m hm => ih.1 m (MvPolynomial.support_smul hm), by rw [hL_smul, ih.2, mul_zero]⟩ | @mul_var e q hq hd ih => -- `deg(q) ≤ 1` and `evenPoly q` implies every `m ∈ q.support` has `m = 0`! have hq0 : q = 0 := by have hsupp : ∀ m ∈ q.support, m = 0 := by intro m hm have heven := ih.1 m hm have hle : (m.sum fun _ k => k) ≤ 1 := le_trans (MvPolynomial.le_totalDegree hm) (by omega) have hzero : (m.sum fun _ k => k) = 0 := by rcases heven with ⟨t, ht⟩; omega ext x by_contra hx simp only [Finsupp.coe_zero, Pi.zero_apply] at hx have hmem : x ∈ m.support := Finsupp.mem_support_iff.mpr hx have hge : m x ≤ m.sum fun _ k => k := Finset.single_le_sum (f := fun y => m y) (fun _ _ => Nat.zero_le _) hmem omega have hqC : q = MvPolynomial.C (MvPolynomial.coeff 0 q) := by conv_lhs => rw [MvPolynomial.as_sum q] by_cases h0 : (0 : GEdge (cycleGraph n) →₀ ℕ) ∈ q.support · rw [Finset.sum_eq_single 0] · rw [MvPolynomial.C_apply] · intro m hm hne; exact absurd (hsupp m hm) hne · intro h; exact absurd h0 h · rw [Finset.sum_eq_zero (fun m hm => absurd (hsupp m hm) (fun heq => h0 (heq ▸ hm)))] have hc0 : MvPolynomial.coeff 0 q = 0 := by by_contra hne; exact h0 (MvPolynomial.mem_support_iff.mpr hne) rw [hc0, map_zero] have hLq : L q = MvPolynomial.coeff 0 q := by conv_lhs => rw [hqC, MvPolynomial.C_apply] rw [hL_mon, h0v, mul_one] rw [ih.2] at hLq rw [hqC, ← hLq, map_zero] rw [hq0, mul_zero] exact ⟨fun _ h => by simp at h, by simp [L]⟩ intro href have h0 := (hinv 1 href).2 have h1 : L 1 = 1 := by have : (1 : MvPolynomial (GEdge (cycleGraph n)) F) = MvPolynomial.monomial 0 1 := rfl rw [this, hL_mon, h0v, mul_one] rw [h1] at h0 exact one_ne_zero h0 · -- Part 2: Explicit degree-3 Dynamic PC refutation of `C_n`! -- For each `1 ≤ k ≤ n - 1`, derive `XOf 0 * XOf k - C (sOf k)` in degree `≤ 3`! let sOf : ℕ → F := fun k => ∏ j ∈ Finset.range k, cOf ((j + 1) % n) have hax_v : ∀ i < n, XOf i * XOf (i + 1) - MvPolynomial.C (cOf ((i + 1) % n)) ∈ tseitinPCAxioms (cycleGraph n) χ F := by intro i hi right let k := (i + 1) % n have hk : k < n := Nat.mod_lt _ (by omega) refine ⟨⟨k, hk⟩, ?_⟩ have hstar := cycleGraph_vStar_pair hn k hk have hprev : (⟨(k + n - 1) % n, Nat.mod_lt _ (by omega)⟩ : Fin n) = ⟨i % n, Nat.mod_lt _ (by omega)⟩ := by apply Fin.ext; dsimp [k] rw [Nat.mod_eq_of_lt hi] by_cases hlt : i + 1 < n · rw [Nat.mod_eq_of_lt hlt, show i + 1 + n - 1 = i + n by omega, Nat.add_mod_right, Nat.mod_eq_of_lt hi] · have hieq : i + 1 = n := by omega rw [hieq, Nat.mod_self] simp [Nat.mod_eq_of_lt (by omega : n - 1 < n)] omega have hne_pair : cycleEdge hn ⟨(k + n - 1) % n, Nat.mod_lt _ (by omega)⟩ ≠ cycleEdge hn ⟨k, hk⟩ := by intro h have hv := congrArg Fin.val (cycleEdge_injective hn h); dsimp at hv by_cases h0 : k = 0 · rw [h0] at hv; simp [Nat.mod_eq_of_lt (by omega : n - 1 < n)] at hv; omega · have : k + n - 1 = n + (k - 1) := by omega rw [this, Nat.add_mod_left, Nat.mod_eq_of_lt (by omega : k - 1 < n)] at hv; omega rw [hstar, Finset.prod_pair hne_pair, hprev] simp [XOf, eOf, cOf, k, hk] have hdeg_lin : ∀ (e₁ e₂ : GEdge (cycleGraph n)) (c : F), (MvPolynomial.X e₁ * MvPolynomial.X e₂ - MvPolynomial.C c).totalDegree ≤ 2 := by intro e₁ e₂ c refine le_trans (MvPolynomial.totalDegree_sub _ _) (max_le ?_ (by simp)) exact le_trans (MvPolynomial.totalDegree_mul _ _) (Nat.add_le_add (mvTotalDegree_X_le _) (mvTotalDegree_X_le _)) have hdeg_sq : ∀ e : GEdge (cycleGraph n), ((MvPolynomial.X e : MvPolynomial (GEdge (cycleGraph n)) F) ^ 2 - 1).totalDegree ≤ 2 := by intro e refine le_trans (MvPolynomial.totalDegree_sub _ _) (max_le ?_ (by simp)) have h1 := MvPolynomial.totalDegree_pow (MvPolynomial.X e : MvPolynomial (GEdge (cycleGraph n)) F) 2 have h2 := mvTotalDegree_X_le (R := F) e omega -- Inductively derive `XOf 0 * XOf k - C (sOf k)` for `1 ≤ k ≤ n`! have hchain : ∀ k, 1 ≤ k → k ≤ n → PCDerives F (tseitinPCAxioms (cycleGraph n) χ F) 3 (XOf 0 * XOf k - MvPolynomial.C (sOf k)) := by intro k induction k with | zero => intro h1; omega | succ k ih => intro _ hkn by_cases hk0 : k = 0 · subst hk0 have hs1 : sOf 1 = cOf (1 % n) := by simp [sOf] rw [hs1] exact PCDerives.ax (hax_v 0 (by omega)) (le_trans (hdeg_lin _ _ _) (by omega)) · have hk1 : 1 ≤ k := by omega have hprev := ih hk1 (by omega) have hnext : PCDerives F (tseitinPCAxioms (cycleGraph n) χ F) 3 (XOf k * XOf (k + 1) - MvPolynomial.C (cOf ((k + 1) % n))) := PCDerives.ax (hax_v k (by omega)) (le_trans (hdeg_lin _ _ _) (by omega)) have hsqk : PCDerives F (tseitinPCAxioms (cycleGraph n) χ F) 3 (XOf k ^ 2 - 1) := PCDerives.ax (Or.inl ⟨eOf k, rfl⟩) (le_trans (hdeg_sq _) (by omega)) -- Combine in degree `≤ 3`! -- 1. `X_{k+1} * (X_0 X_k - s_k) = X_0 X_k X_{k+1} - s_k X_{k+1}` (deg 3) -- 2. `X_0 * (X_k X_{k+1} - c_{k+1}) = X_0 X_k X_{k+1} - c_{k+1} X_0` (deg 3) -- Subtract (1) from (2): `s_k X_{k+1} - c_{k+1} X_0` (deg `≤ 1`!) -- 3. Multiply by `X_0`: `s_k X_0 X_{k+1} - c_{k+1} X_0^2` (deg 2) -- 4. Add `c_{k+1} * (X_0^2 - 1)`: `s_k X_0 X_{k+1} - c_{k+1}` (deg 2) -- 5. Scale by `s_k` (note `s_k^2 = 1`!): `X_0 X_{k+1} - s_k c_{k+1} = X_0 X_{k+1} - s_{k+1}`!! have hp1 := PCDerives.mul_var (eOf (k + 1)) hprev (Nat.add_le_add_right (hdeg_lin _ _ _) 1) have hp2 := PCDerives.mul_var (eOf 0) hnext (Nat.add_le_add_right (hdeg_lin _ _ _) 1) have hlin : PCDerives F (tseitinPCAxioms (cycleGraph n) χ F) 3 (MvPolynomial.C (sOf k) * XOf (k + 1) - MvPolynomial.C (cOf ((k + 1) % n)) * XOf 0) := by have heq : MvPolynomial.C (sOf k) * XOf (k + 1) - MvPolynomial.C (cOf ((k + 1) % n)) * XOf 0 = XOf 0 * (XOf k * XOf (k + 1) - MvPolynomial.C (cOf ((k + 1) % n))) + (-1 : F) • (XOf (k + 1) * (XOf 0 * XOf k - MvPolynomial.C (sOf k))) := by rw [MvPolynomial.smul_eq_C_mul, map_neg, map_one]; ring rw [heq] exact PCDerives.add hp2 (PCDerives.smul (-1) hp1) have hlin_deg : (MvPolynomial.C (sOf k) * XOf (k + 1) - MvPolynomial.C (cOf ((k + 1) % n)) * XOf 0).totalDegree ≤ 1 := by refine le_trans (MvPolynomial.totalDegree_sub _ _) (max_le ?_ ?_) <;> · refine le_trans (MvPolynomial.totalDegree_mul _ _) ?_ rw [MvPolynomial.totalDegree_C, zero_add] exact mvTotalDegree_X_le _ have hp3 := PCDerives.mul_var (eOf 0) hlin (by omega) have hsq0 : PCDerives F (tseitinPCAxioms (cycleGraph n) χ F) 3 (XOf 0 ^ 2 - 1) := PCDerives.ax (Or.inl ⟨eOf 0, rfl⟩) (le_trans (hdeg_sq _) (by omega)) have hs_sq_all : ∀ m, sOf m * sOf m = 1 := by intro m dsimp only [sOf] induction m with | zero => simp | succ j ihj => rw [Finset.prod_range_succ] have hc : cOf ((j + 1) % n) * cOf ((j + 1) % n) = 1 := by dsimp [cOf]; split_ifs <;> ring calc (∏ x ∈ Finset.range j, cOf ((x + 1) % n)) * cOf ((j + 1) % n) * ((∏ x ∈ Finset.range j, cOf ((x + 1) % n)) * cOf ((j + 1) % n)) = ((∏ x ∈ Finset.range j, cOf ((x + 1) % n)) * (∏ x ∈ Finset.range j, cOf ((x + 1) % n))) * (cOf ((j + 1) % n) * cOf ((j + 1) % n)) := by ring _ = 1 := by rw [ihj, hc, one_mul] have hs_sq : sOf k * sOf k = 1 := hs_sq_all k have hfinal_eq : XOf 0 * XOf (k + 1) - MvPolynomial.C (sOf (k + 1)) = (sOf k) • (XOf 0 * (MvPolynomial.C (sOf k) * XOf (k + 1) - MvPolynomial.C (cOf ((k + 1) % n)) * XOf 0) + (cOf ((k + 1) % n)) • (XOf 0 ^ 2 - 1)) := by have hs_succ : sOf (k + 1) = sOf k * cOf ((k + 1) % n) := Finset.prod_range_succ _ k rw [hs_succ, MvPolynomial.smul_eq_C_mul, MvPolynomial.smul_eq_C_mul, map_mul] have hCsq : MvPolynomial.C (sOf k) * MvPolynomial.C (sOf k) = (1 : MvPolynomial (GEdge (cycleGraph n)) F) := by rw [← map_mul, hs_sq, map_one] calc XOf 0 * XOf (k + 1) - MvPolynomial.C (sOf k) * MvPolynomial.C (cOf ((k + 1) % n)) = (MvPolynomial.C (sOf k) * MvPolynomial.C (sOf k)) * (XOf 0 * XOf (k + 1)) - MvPolynomial.C (sOf k) * MvPolynomial.C (cOf ((k + 1) % n)) := by rw [hCsq, one_mul] _ = MvPolynomial.C (sOf k) * (XOf 0 * (MvPolynomial.C (sOf k) * XOf (k + 1) - MvPolynomial.C (cOf ((k + 1) % n)) * XOf 0) + MvPolynomial.C (cOf ((k + 1) % n)) * (XOf 0 ^ 2 - 1)) := by ring rw [hfinal_eq] exact PCDerives.smul (sOf k) (PCDerives.add hp3 (PCDerives.smul _ hsq0)) -- At `k = n`: `XOf 0 * XOf n - C (sOf n) = XOf 0^2 + 1`! -- Subtract `(XOf 0^2 - 1)` to get `2`, then scale by `2⁻¹` to get `1`!! have hsn : sOf n = -1 := by have hprod_eq : sOf n = ∏ v : Fin n, (if χ v = 1 then (-1 : F) else 1) := by dsimp only [sOf] refine Finset.prod_bij (fun j _ => (⟨(j + 1) % n, Nat.mod_lt _ (by omega)⟩ : Fin n)) (fun _ _ => Finset.mem_univ _) ?_ ?_ ?_ · intro j₁ hj₁ j₂ hj₂ heq have h1 : j₁ < n := Finset.mem_range.mp hj₁ have h2' : j₂ < n := Finset.mem_range.mp hj₂ have hv := congrArg Fin.val heq; dsimp at hv by_cases h1lt : j₁ + 1 < n <;> by_cases h2lt : j₂ + 1 < n · rw [Nat.mod_eq_of_lt h1lt, Nat.mod_eq_of_lt h2lt] at hv; omega · have : j₂ + 1 = n := by omega rw [this, Nat.mod_self, Nat.mod_eq_of_lt h1lt] at hv; omega · have : j₁ + 1 = n := by omega rw [this, Nat.mod_self, Nat.mod_eq_of_lt h2lt] at hv; omega · omega · intro v _ refine ⟨(v.1 + n - 1) % n, Finset.mem_range.mpr (Nat.mod_lt _ (by omega)), ?_⟩ apply Fin.ext; dsimp by_cases h0 : v.1 = 0 · rw [h0]; simp [Nat.mod_eq_of_lt (by omega : n - 1 < n), show n - 1 + 1 = n by omega] · have hm : (v.1 + n - 1) % n = v.1 - 1 := by have : v.1 + n - 1 = n + (v.1 - 1) := by omega rw [this, Nat.add_mod_left, Nat.mod_eq_of_lt (by omega)] rw [hm, show v.1 - 1 + 1 = v.1 by omega, Nat.mod_eq_of_lt v.2] · intro j _ have hlt : (j + 1) % n < n := Nat.mod_lt _ (by omega) simp only [cOf, hlt, ↓reduceDIte] rw [hprod_eq] have hgen : ∀ S : Finset (Fin n), (∏ v ∈ S, (if χ v = 1 then (-1 : F) else 1)) = if (∑ v ∈ S, χ v) = 1 then (-1 : F) else 1 := by intro S induction S using Finset.induction with | empty => simp | @insert v S' hv ih => rw [Finset.prod_insert hv, Finset.sum_insert hv, ih] exact zmod2_sign_mul_ring (R := F) (χ v) (∑ u ∈ S', χ u) rw [hgen Finset.univ, hodd, if_pos rfl] have htop := hchain n (by omega) (le_refl n) have hXn : XOf n = XOf 0 := by simp [XOf, eOf] rw [hXn, hsn, ← sq, map_neg, map_one, sub_neg_eq_add] at htop have hsq0 : PCDerives F (tseitinPCAxioms (cycleGraph n) χ F) 3 (XOf 0 ^ 2 - 1) := PCDerives.ax (Or.inl ⟨eOf 0, rfl⟩) (le_trans (hdeg_sq _) (by omega)) have h1eq : (1 : MvPolynomial (GEdge (cycleGraph n)) F) = ((2 : F)⁻¹) • ((XOf 0 ^ 2 + 1) + (-1 : F) • (XOf 0 ^ 2 - 1)) := by rw [MvPolynomial.smul_eq_C_mul, MvPolynomial.smul_eq_C_mul, map_neg, map_one] have h2eq : (XOf 0 ^ 2 + 1) + -1 * (XOf 0 ^ 2 - 1) = MvPolynomial.C (2 : F) := by have : (MvPolynomial.C (2 : F) : MvPolynomial (GEdge (cycleGraph n)) F) = 1 + 1 := by rw [show (2 : F) = 1 + 1 by ring, map_add, map_one] rw [this]; ring rw [h2eq, ← map_mul, inv_mul_cancel₀ h2, map_one] unfold PCRefutes rw [h1eq] exact PCDerives.smul _ (PCDerives.add htop (PCDerives.smul (-1) hsq0)) end TseitinAlgebraic end Pillar3 -- ============================================================================== -- PILLAR 4: EXACT BOOLEAN KNAPSACK SoS DEGREE CHARACTERIZATION, -- ELEMENTARY HARMONIC SPECTRAL DIAGONALIZATION & NS-vs-SoS SEPARATION -- ============================================================================== section Pillar4 -- ------------------------------------------------------------------------------ -- 4A. Falling Factorials, Chu–Vandermonde Identity, and {0,1} Multilinearization -- ------------------------------------------------------------------------------ /-- Falling factorial `a^{⌊r⌋} = a (a - 1) ⋯ (a - r + 1)` over any commutative ring `R`. -/ def descFact {R : Type*} [CommRing R] (a : R) : ℕ → R | 0 => 1 | r + 1 => descFact a r * (a - (r : R)) @[simp] lemma descFact_zero {R : Type*} [CommRing R] (a : R) : descFact a 0 = 1 := rfl lemma descFact_succ {R : Type*} [CommRing R] (a : R) (r : ℕ) : descFact a (r + 1) = descFact a r * (a - (r : R)) := rfl lemma descFact_one {R : Type*} [CommRing R] (a : R) : descFact a 1 = a := by simp [descFact] lemma descFact_succ_left {R : Type*} [CommRing R] (a : R) (r : ℕ) : descFact a (r + 1) = a * descFact (a - 1) r := by induction r with | zero => simp [descFact] | succ t ih => rw [descFact_succ, ih, descFact_succ, mul_assoc] congr 1; push_cast; ring lemma descFact_add {R : Type*} [CommRing R] (a : R) (r s : ℕ) : descFact a (r + s) = descFact a r * descFact (a - (r : R)) s := by induction s with | zero => simp [descFact] | succ t ih => rw [← Nat.add_assoc, descFact_succ, ih, descFact_succ, mul_assoc] congr 1; push_cast; ring lemma descFact_nat_ne_zero {F : Type*} [Field F] [CharZero F] {n r : ℕ} (hr : r ≤ n) : descFact (n : F) r ≠ 0 := by induction r with | zero => simp [descFact] | succ t ih => rw [descFact_succ] refine mul_ne_zero (ih (by omega)) ?_ intro h have hEq : (n : F) = (t : F) := sub_eq_zero.mp h have : n = t := Nat.cast_injective hEq omega lemma descFact_nat_pos_real {n r : ℕ} (hr : r ≤ n) : 0 < descFact (n : ℝ) r := by induction r with | zero => simp [descFact] | succ t ih => rw [descFact_succ] refine mul_pos (ih (by omega)) ?_ have : (t : ℝ) < (n : ℝ) := Nat.cast_lt.mpr (by omega) linarith lemma descFact_pos_of_gt {a : ℝ} {r : ℕ} (ha : (r : ℝ) - 1 < a) : 0 < descFact a r := by induction r with | zero => simp [descFact] | succ t ih => rw [descFact_succ] have ht : (t : ℝ) < a := by push_cast at ha; linarith refine mul_pos (ih (by linarith)) (by linarith) lemma descFact_pos_of_nat_lt {k : ℕ} {β : ℝ} (hk : (k : ℝ) < β) {j : ℕ} (hj : j ≤ k + 1) : 0 < descFact β j := by apply descFact_pos_of_gt have : (j : ℝ) ≤ (k : ℝ) + 1 := by exact_mod_cast hj linarith lemma descFact_sub_pos {n k : ℕ} {β : ℝ} (hβ : β < (k : ℝ) + 1) {j : ℕ} (hj : j ≤ n - k) (hk : k ≤ n) : 0 < descFact ((n : ℝ) - β) j := by apply descFact_pos_of_gt have hj' : (j : ℝ) ≤ (n : ℝ) - (k : ℝ) := by have h1 : (j : ℝ) ≤ ((n - k : ℕ) : ℝ) := by exact_mod_cast hj rw [Nat.cast_sub hk] at h1 exact h1 linarith lemma descFact_neg_at_k_add_two {k : ℕ} {β : ℝ} (hk1 : (k : ℝ) < β) (hk2 : β < (k : ℝ) + 1) : descFact β (k + 2) < 0 := by rw [show k + 2 = (k + 1) + 1 from rfl, descFact_succ] have hpos : 0 < descFact β (k + 1) := descFact_pos_of_nat_lt hk1 (le_refl _) have hneg : β - ((k + 1 : ℕ) : ℝ) < 0 := by push_cast; linarith exact mul_neg_of_pos_of_neg hpos hneg /-- **Headline Theorem 4A (Exact Falling-Factorial Chu–Vandermonde Identity):** For any field `F`, any `a N : F`, and any `m : ℕ` with `N - t ≠ 0` for all `t < m`, `∑_{s=0}^m (-1)^s C(m, s) * (a^{⌊s⌋} / N^{⌊s⌋}) = (N - a)^{⌊m⌋} / N^{⌊m⌋}`. -/ theorem chu_vandermonde_falling {F : Type*} [Field F] (a N : F) (m : ℕ) (hN : ∀ t < m, N - (t : F) ≠ 0) : ∑ s ∈ Finset.range (m + 1), ((-1 : F) ^ s * (Nat.choose m s : F)) * (descFact a s / descFact N s) = descFact (N - a) m / descFact N m := by induction m generalizing a N with | zero => simp [descFact] | succ m ih => have hN0 : N ≠ 0 := by simpa using hN 0 (Nat.zero_lt_succ m) have hN_m : ∀ t < m, N - (t : F) ≠ 0 := fun t ht => hN t (Nat.lt_succ_of_lt ht) have hN1_m : ∀ t < m, (N - 1) - (t : F) ≠ 0 := by intro t ht have h := hN (t + 1) (Nat.succ_lt_succ ht) have heq : (N - 1) - (t : F) = N - ((t + 1 : ℕ) : F) := by push_cast; ring rwa [heq] have hdesc_ne : ∀ (M : F) (k : ℕ), (∀ t < k, M - (t : F) ≠ 0) → descFact M k ≠ 0 := by intro M k induction k with | zero => intro _; simp [descFact] | succ k ihk => intro hM rw [descFact_succ] exact mul_ne_zero (ihk fun t ht => hM t (Nat.lt_succ_of_lt ht)) (hM k (Nat.lt_succ_self k)) have hNm_ne : descFact N m ≠ 0 := hdesc_ne N m hN_m have hNm1_ne : descFact (N - 1) m ≠ 0 := hdesc_ne (N - 1) m hN1_m -- Split `∑_{s=0}^{m+1}` via Pascal's identity `C(m+1, s) = C(m, s) + C(m, s-1)`. have hsplit : ∑ s ∈ Finset.range (m + 2), ((-1 : F) ^ s * (Nat.choose (m + 1) s : F)) * (descFact a s / descFact N s) = (∑ s ∈ Finset.range (m + 1), ((-1 : F) ^ s * (Nat.choose m s : F)) * (descFact a s / descFact N s)) - (a / N) * (∑ t ∈ Finset.range (m + 1), ((-1 : F) ^ t * (Nat.choose m t : F)) * (descFact (a - 1) t / descFact (N - 1) t)) := by rw [Finset.sum_range_succ'] simp only [pow_zero, Nat.choose_zero_right, Nat.cast_one, mul_one, descFact_zero, div_one] have hterm : ∀ k ∈ Finset.range (m + 1), ((-1 : F) ^ (k + 1) * (Nat.choose (m + 1) (k + 1) : F)) * (descFact a (k + 1) / descFact N (k + 1)) = ((-1 : F) ^ (k + 1) * (Nat.choose m (k + 1) : F)) * (descFact a (k + 1) / descFact N (k + 1)) - (a / N) * (((-1 : F) ^ k * (Nat.choose m k : F)) * (descFact (a - 1) k / descFact (N - 1) k)) := by intro k _ rw [Nat.choose_succ_succ, Nat.cast_add, descFact_succ_left a k, descFact_succ_left N k, mul_div_mul_comm] rw [pow_succ] ring rw [Finset.sum_congr rfl hterm, Finset.sum_sub_distrib, ← Finset.mul_sum] -- Combine the `1` term (at `s = 0`) with the `k + 1` terms (`s = 1..m`, noting `C(m, m+1) = 0`)! have hfirst : (∑ k ∈ Finset.range (m + 1), ((-1 : F) ^ (k + 1) * (Nat.choose m (k + 1) : F)) * (descFact a (k + 1) / descFact N (k + 1))) + 1 = ∑ s ∈ Finset.range (m + 1), ((-1 : F) ^ s * (Nat.choose m s : F)) * (descFact a s / descFact N s) := by rw [Finset.sum_range_succ] simp only [Nat.choose_eq_zero_of_lt (Nat.lt_succ_self m), Nat.cast_zero, mul_zero, zero_mul, add_zero] rw [Finset.sum_range_succ'] simp only [pow_zero, Nat.choose_zero_right, Nat.cast_one, mul_one, descFact_zero, div_one] rw [← hfirst]; ring rw [hsplit, ih a N hN_m, ih (a - 1) (N - 1) hN1_m] have hsub_eq : (N - 1) - (a - 1) = N - a := by ring rw [hsub_eq, descFact_succ (N - a) m, descFact_succ N m] have hrel : N * descFact (N - 1) m = descFact N m * (N - (m : F)) := by rw [← descFact_succ_left N m, descFact_succ N m] have hNm_sub_ne : N - (m : F) ≠ 0 := hN m (Nat.lt_succ_self m) field_simp [hNm_ne, hNm1_ne, hN0, hNm_sub_ne] calc descFact (N - a) m * (N * descFact (N - 1) m - a * descFact N m) * (N - (m : F)) = descFact (N - a) m * (descFact N m * (N - (m : F)) - a * descFact N m) * (N - (m : F)) := by rw [hrel] _ = descFact (N - a) m * (descFact N m * (N - (m : F))) * (N - a - (m : F)) := by ring _ = descFact (N - a) m * (N * descFact (N - 1) m) * (N - a - (m : F)) := by rw [← hrel] _ = N * descFact (N - a) m * descFact (N - 1) m * (N - a - (m : F)) := by ring -- ------------------------------------------------------------------------------ -- 4B. Boolean {0, 1} Multilinear Reduction `toMultilinear01` -- ------------------------------------------------------------------------------ section Multilinear01 variable {n : ℕ} lemma finsupp_support_add_nat (m₁ m₂ : Fin n →₀ ℕ) : (m₁ + m₂).support = m₁.support ∪ m₂.support := by ext i simp only [Finsupp.mem_support_iff, Finset.mem_union, Finsupp.add_apply] omega lemma card_finsupp_support_le_sum (m : Fin n →₀ ℕ) : m.support.card ≤ m.sum fun _ k => k := by calc m.support.card = ∑ i ∈ m.support, 1 := by simp _ ≤ ∑ i ∈ m.support, m i := by apply Finset.sum_le_sum; intro i hi have hne : m i ≠ 0 := Finsupp.mem_support_iff.mp hi omega _ = m.sum fun _ k => k := rfl /-- Reduction of `MvPolynomial (Fin n) R` to multilinear `{0, 1}`-coefficients `Finset (Fin n) → R` modulo `⟨X_i^2 - X_i⟩`. -/ noncomputable def toMultilinear01 {R : Type*} [CommSemiring R] (p : MvPolynomial (Fin n) R) : Finset (Fin n) → R := fun A => ∑ m ∈ p.support, if m.support = A then MvPolynomial.coeff m p else 0 lemma toMultilinear01_zero {R : Type*} [CommSemiring R] : toMultilinear01 (0 : MvPolynomial (Fin n) R) = 0 := by funext A; simp [toMultilinear01] lemma toMultilinear01_add {R : Type*} [CommSemiring R] (p q : MvPolynomial (Fin n) R) (A : Finset (Fin n)) : toMultilinear01 (p + q) A = toMultilinear01 p A + toMultilinear01 q A := by classical let S := p.support ∪ q.support have h1 : toMultilinear01 (p + q) A = ∑ m ∈ S, if m.support = A then MvPolynomial.coeff m (p + q) else 0 := by unfold toMultilinear01 refine Finset.sum_subset MvPolynomial.support_add ?_ intro m _ hnot have hc : MvPolynomial.coeff m (p + q) = 0 := by by_contra hne; exact hnot (MvPolynomial.mem_support_iff.mpr hne) simp [hc] have h2 : toMultilinear01 p A = ∑ m ∈ S, if m.support = A then MvPolynomial.coeff m p else 0 := by unfold toMultilinear01 refine Finset.sum_subset Finset.subset_union_left ?_ intro m _ hnot have hc : MvPolynomial.coeff m p = 0 := by by_contra hne; exact hnot (MvPolynomial.mem_support_iff.mpr hne) simp [hc] have h3 : toMultilinear01 q A = ∑ m ∈ S, if m.support = A then MvPolynomial.coeff m q else 0 := by unfold toMultilinear01 refine Finset.sum_subset Finset.subset_union_right ?_ intro m _ hnot have hc : MvPolynomial.coeff m q = 0 := by by_contra hne; exact hnot (MvPolynomial.mem_support_iff.mpr hne) simp [hc] rw [h1, h2, h3, ← Finset.sum_add_distrib] apply Finset.sum_congr rfl; intro m _ rw [MvPolynomial.coeff_add]; split_ifs <;> simp lemma toMultilinear01_smul {R : Type*} [CommSemiring R] (c : R) (p : MvPolynomial (Fin n) R) (A : Finset (Fin n)) : toMultilinear01 (c • p) A = c * toMultilinear01 p A := by classical have h1 : toMultilinear01 (c • p) A = ∑ m ∈ p.support, if m.support = A then MvPolynomial.coeff m (c • p) else 0 := by unfold toMultilinear01 refine Finset.sum_subset (fun m hm => MvPolynomial.support_smul hm) ?_ intro m _ hnot have hc : MvPolynomial.coeff m (c • p) = 0 := by by_contra hne; exact hnot (MvPolynomial.mem_support_iff.mpr hne) simp [hc] rw [h1, toMultilinear01, Finset.mul_sum] apply Finset.sum_congr rfl; intro m _ rw [MvPolynomial.coeff_smul, smul_eq_mul]; split_ifs <;> simp lemma toMultilinear01_sub {R : Type*} [CommRing R] (p q : MvPolynomial (Fin n) R) (A : Finset (Fin n)) : toMultilinear01 (p - q) A = toMultilinear01 p A - toMultilinear01 q A := by rw [sub_eq_add_neg, ← neg_one_smul R q, toMultilinear01_add, toMultilinear01_smul]; ring lemma toMultilinear01_finset_sum {ι : Type*} {R : Type*} [CommSemiring R] (s : Finset ι) (f : ι → MvPolynomial (Fin n) R) (A : Finset (Fin n)) : toMultilinear01 (∑ i ∈ s, f i) A = ∑ i ∈ s, toMultilinear01 (f i) A := by classical induction s using Finset.induction with | empty => simp [toMultilinear01_zero] | @insert a s' ha ih => rw [Finset.sum_insert ha, toMultilinear01_add, ih, Finset.sum_insert ha] lemma toMultilinear01_monomial {R : Type*} [CommSemiring R] (m : Fin n →₀ ℕ) (c : R) (A : Finset (Fin n)) : toMultilinear01 (MvPolynomial.monomial m c) A = if m.support = A then c else 0 := by classical unfold toMultilinear01 by_cases hc : c = 0 · subst hc; simp · have hsupp : (MvPolynomial.monomial m c).support = {m} := MvPolynomial.support_monomial.trans (if_neg hc) rw [hsupp, Finset.sum_singleton, MvPolynomial.coeff_monomial, if_pos rfl] lemma toMultilinear01_one {R : Type*} [CommSemiring R] (A : Finset (Fin n)) : toMultilinear01 (1 : MvPolynomial (Fin n) R) A = if A = ∅ then 1 else 0 := by have h1 : (1 : MvPolynomial (Fin n) R) = MvPolynomial.monomial 0 1 := rfl rw [h1, toMultilinear01_monomial, Finsupp.support_zero] by_cases h : A = ∅ <;> simp [h, eq_comm] lemma toMultilinear01_mul {R : Type*} [CommSemiring R] (p q : MvPolynomial (Fin n) R) (A : Finset (Fin n)) : toMultilinear01 (p * q) A = ∑ B : Finset (Fin n), ∑ C : Finset (Fin n), if B ∪ C = A then toMultilinear01 p B * toMultilinear01 q C else 0 := by classical induction p using MvPolynomial.induction_on' with | monomial m₁ c₁ => induction q using MvPolynomial.induction_on' with | monomial m₂ c₂ => rw [MvPolynomial.monomial_mul, toMultilinear01_monomial, finsupp_support_add_nat] simp_rw [toMultilinear01_monomial] rw [Finset.sum_eq_single m₁.support] · rw [Finset.sum_eq_single m₂.support] · simp only [↓reduceIte] · intro C _ hC; simp [Ne.symm hC] · intro h; exact absurd (Finset.mem_univ _) h · intro B _ hB apply Finset.sum_eq_zero; intro C _ simp [Ne.symm hB] · intro h; exact absurd (Finset.mem_univ _) h | add q₁ q₂ ih1 ih2 => rw [mul_add, toMultilinear01_add, ih1, ih2, ← Finset.sum_add_distrib] apply Finset.sum_congr rfl; intro B _ rw [← Finset.sum_add_distrib] apply Finset.sum_congr rfl; intro C _ rw [toMultilinear01_add]; split_ifs <;> ring | add p₁ p₂ ih1 ih2 => rw [add_mul, toMultilinear01_add, ih1, ih2, ← Finset.sum_add_distrib] apply Finset.sum_congr rfl; intro B _ rw [← Finset.sum_add_distrib] apply Finset.sum_congr rfl; intro C _ rw [toMultilinear01_add]; split_ifs <;> ring lemma toMultilinear01_X_sq_sub_X {R : Type*} [CommRing R] (i : Fin n) (A : Finset (Fin n)) : toMultilinear01 ((MvPolynomial.X i : MvPolynomial (Fin n) R) ^ 2 - MvPolynomial.X i) A = 0 := by have hsub : (MvPolynomial.X i : MvPolynomial (Fin n) R) ^ 2 - MvPolynomial.X i = MvPolynomial.monomial (Finsupp.single i 2) 1 - MvPolynomial.monomial (Finsupp.single i 1) 1 := by rw [sq, MvPolynomial.X, MvPolynomial.monomial_mul, ← Finsupp.single_add, one_mul, show (1 : ℕ) + 1 = 2 from rfl] rw [hsub, toMultilinear01_sub, toMultilinear01_monomial, toMultilinear01_monomial] have hs2 : (Finsupp.single i (2 : ℕ)).support = {i} := Finsupp.support_single i (by omega) have hs1 : (Finsupp.single i (1 : ℕ)).support = {i} := Finsupp.support_single i (by omega) rw [hs2, hs1, sub_self] lemma toMultilinear01_mul_X_sq_sub_X {R : Type*} [CommRing R] (q : MvPolynomial (Fin n) R) (i : Fin n) (A : Finset (Fin n)) : toMultilinear01 (q * ((MvPolynomial.X i) ^ 2 - MvPolynomial.X i)) A = 0 := by rw [toMultilinear01_mul] apply Finset.sum_eq_zero; intro B _ apply Finset.sum_eq_zero; intro C _ rw [toMultilinear01_X_sq_sub_X, mul_zero, ite_self] /-- Multilinear `{0, 1}` monomial `∏_{i ∈ S} X_i`. -/ noncomputable def mon01 {R : Type*} [CommSemiring R] (S : Finset (Fin n)) : MvPolynomial (Fin n) R := ∏ i ∈ S, MvPolynomial.X i lemma totalDegree_mon01_le {R : Type*} [CommSemiring R] (S : Finset (Fin n)) : (mon01 (R := R) S).totalDegree ≤ S.card := by unfold mon01 calc (∏ i ∈ S, (MvPolynomial.X i : MvPolynomial (Fin n) R)).totalDegree ≤ ∑ i ∈ S, (MvPolynomial.X i : MvPolynomial (Fin n) R).totalDegree := MvPolynomial.totalDegree_finsetProd _ _ _ ≤ ∑ _i ∈ S, 1 := Finset.sum_le_sum fun i _ => mvTotalDegree_X_le i _ = S.card := by simp lemma toMultilinear01_mon01 {R : Type*} [CommSemiring R] (S A : Finset (Fin n)) : toMultilinear01 (mon01 (R := R) S) A = if S = A then 1 else 0 := by classical have hprod : mon01 (R := R) S = MvPolynomial.monomial (∑ i ∈ S, Finsupp.single i (1 : ℕ)) 1 := by unfold mon01 induction S using Finset.induction with | empty => simp | @insert a S' ha ih => rw [Finset.prod_insert ha, Finset.sum_insert ha, ih, MvPolynomial.X, MvPolynomial.monomial_mul, one_mul] rw [hprod, toMultilinear01_monomial] have hsupp : (∑ i ∈ S, Finsupp.single i (1 : ℕ)).support = S := by ext x rw [Finsupp.mem_support_iff, Finsupp.finsetSum_apply] have hval : (∑ i ∈ S, (Finsupp.single i (1 : ℕ)) x) = if x ∈ S then 1 else 0 := by simp [Finsupp.single_apply, eq_comm] rw [hval]; split_ifs <;> simp [*] rw [hsupp] lemma toMultilinear01_support_card_le {R : Type*} [CommSemiring R] {p : MvPolynomial (Fin n) R} {A : Finset (Fin n)} (h : toMultilinear01 p A ≠ 0) : A.card ≤ p.totalDegree := by unfold toMultilinear01 at h rcases Finset.exists_ne_zero_of_sum_ne_zero h with ⟨m, hm, hterm⟩ split_ifs at hterm with heq · rw [← heq] exact le_trans (card_finsupp_support_le_sum m) (MvPolynomial.le_totalDegree hm) · exact absurd rfl hterm /-- Linear sum polynomial `∑_{i=0}^{n-1} X_i`. -/ noncomputable def linSum (n : ℕ) {R : Type*} [CommSemiring R] : MvPolynomial (Fin n) R := ∑ i : Fin n, MvPolynomial.X i lemma totalDegree_linSum_le (n : ℕ) {R : Type*} [CommSemiring R] : (linSum n (R := R)).totalDegree ≤ 1 := by unfold linSum refine le_trans (MvPolynomial.totalDegree_finsetSum _ _) ?_ rw [Finset.sup_le_iff] intro i _ exact mvTotalDegree_X_le i lemma totalDegree_linSum_sub_C {n : ℕ} (hn : 1 ≤ n) {F : Type*} [Field F] (β : F) : (linSum n - MvPolynomial.C β).totalDegree = 1 := by have hle : (linSum n - MvPolynomial.C β).totalDegree ≤ 1 := by refine le_trans (MvPolynomial.totalDegree_sub _ _) (max_le (totalDegree_linSum_le n) (by simp)) have hge : 1 ≤ (linSum n - MvPolynomial.C β).totalDegree := by let i0 : Fin n := ⟨0, by omega⟩ have hcoeff : MvPolynomial.coeff (Finsupp.single i0 1) (linSum n - MvPolynomial.C β) = 1 := by rw [MvPolynomial.coeff_sub, linSum, MvPolynomial.coeff_sum] have hC : MvPolynomial.coeff (Finsupp.single i0 1) (MvPolynomial.C β) = 0 := by rw [MvPolynomial.coeff_C, if_neg] intro h; have := congrArg (fun f : Fin n →₀ ℕ => f i0) h; simp at this rw [hC, sub_zero, Finset.sum_eq_single i0] · rw [MvPolynomial.coeff_X] simp · intro j _ hne rw [MvPolynomial.coeff_X, if_neg] intro h have := congrArg (fun f : Fin n →₀ ℕ => f i0) h simp [Finsupp.single_eq_of_ne (Ne.symm hne)] at this · intro h; exact absurd (Finset.mem_univ _) h have hmem : Finsupp.single i0 1 ∈ (linSum n - MvPolynomial.C β).support := MvPolynomial.mem_support_iff.mpr (by rw [hcoeff]; exact one_ne_zero) have := MvPolynomial.le_totalDegree hmem simpa [Finsupp.sum_single_index] using this omega /-- Boolean Knapsack polynomial axioms over any field `F`: `{X_i^2 - X_i : i ∈ Fin n} ∪ {∑_i X_i - β}`. -/ def knapsackAxiomsF (n : ℕ) {F : Type*} [Field F] (β : F) : Set (MvPolynomial (Fin n) F) := { p | (∃ i : Fin n, p = (MvPolynomial.X i) ^ 2 - MvPolynomial.X i) ∨ p = linSum n - MvPolynomial.C β } /-- Boolean Knapsack axioms over `ℝ`. -/ def knapsackAxioms (n : ℕ) (β : ℝ) : Set (MvPolynomial (Fin n) ℝ) := knapsackAxiomsF n β /-- Nullstellensatz refutation of degree `D` over a field `F`: `1 = ∑ q_j * g_j` with `g_j ∈ axioms` and `deg(q_j) + deg(g_j) ≤ D`. -/ def NSRefutes {E : Type*} (F : Type*) [Field F] (axioms : Set (MvPolynomial E F)) (D : ℕ) : Prop := ∃ idealTerms : List (MvPolynomial E F × MvPolynomial E F), (∀ t ∈ idealTerms, t.2 ∈ axioms ∧ t.1.totalDegree + t.2.totalDegree ≤ D) ∧ (1 : MvPolynomial E F) = (idealTerms.map fun t => t.1 * t.2).sum lemma nsRefutes_mono {E : Type*} {F : Type*} [Field F] {axioms : Set (MvPolynomial E F)} {D₁ D₂ : ℕ} (hD : D₁ ≤ D₂) (h : NSRefutes F axioms D₁) : NSRefutes F axioms D₂ := by rcases h with ⟨idt, hidt, heq⟩ exact ⟨idt, fun t ht => ⟨(hidt t ht).1, le_trans (hidt t ht).2 hD⟩, heq⟩ /-- Grigoriev–Laurent Knapsack pseudo-expectation over any characteristic-0 field `F`: `Ẽ[p] = ∑_S toMultilinear01(p, S) * (β^{⌊|S|⌋} / n^{⌊|S|⌋})`. -/ noncomputable def knapsackPEF (n : ℕ) {F : Type*} [Field F] (β : F) (p : MvPolynomial (Fin n) F) : F := ∑ S : Finset (Fin n), toMultilinear01 p S * (descFact β S.card / descFact (n : F) S.card) /-- Grigoriev–Laurent Knapsack pseudo-expectation over `ℝ`. -/ noncomputable def knapsackPE (n : ℕ) (β : ℝ) (p : MvPolynomial (Fin n) ℝ) : ℝ := knapsackPEF n β p lemma knapsackPEF_add {F : Type*} [Field F] (β : F) (p q : MvPolynomial (Fin n) F) : knapsackPEF n β (p + q) = knapsackPEF n β p + knapsackPEF n β q := by unfold knapsackPEF rw [← Finset.sum_add_distrib] apply Finset.sum_congr rfl; intro S _ rw [toMultilinear01_add, add_mul] lemma knapsackPEF_smul {F : Type*} [Field F] (β : F) (c : F) (p : MvPolynomial (Fin n) F) : knapsackPEF n β (c • p) = c * knapsackPEF n β p := by unfold knapsackPEF rw [Finset.mul_sum] apply Finset.sum_congr rfl; intro S _ rw [toMultilinear01_smul, mul_assoc] lemma knapsackPEF_zero {F : Type*} [Field F] (β : F) : knapsackPEF n β (0 : MvPolynomial (Fin n) F) = 0 := by unfold knapsackPEF; simp [toMultilinear01_zero] lemma knapsackPEF_one {F : Type*} [Field F] (β : F) : knapsackPEF n β (1 : MvPolynomial (Fin n) F) = 1 := by unfold knapsackPEF rw [Finset.sum_eq_single (∅ : Finset (Fin n))] · simp [toMultilinear01_one] · intro S _ hne; simp [toMultilinear01_one, hne] · intro h; exact absurd (Finset.mem_univ _) h lemma knapsackPEF_list_sum {F : Type*} [Field F] (β : F) (L : List (MvPolynomial (Fin n) F)) : knapsackPEF n β L.sum = (L.map (knapsackPEF n β)).sum := by induction L with | nil => simp [knapsackPEF_zero] | cons a t ih => simp [knapsackPEF_add, ih] lemma knapsackPEF_mul_bool {F : Type*} [Field F] (β : F) (q : MvPolynomial (Fin n) F) (i : Fin n) : knapsackPEF n β (q * ((MvPolynomial.X i) ^ 2 - MvPolynomial.X i)) = 0 := by unfold knapsackPEF apply Finset.sum_eq_zero; intro S _ rw [toMultilinear01_mul_X_sq_sub_X, zero_mul] lemma knapsackPEF_mul_eq {F : Type*} [Field F] (β : F) (p q : MvPolynomial (Fin n) F) : knapsackPEF n β (p * q) = ∑ A : Finset (Fin n), ∑ B : Finset (Fin n), toMultilinear01 p A * toMultilinear01 q B * (descFact β (A ∪ B).card / descFact (n : F) (A ∪ B).card) := by classical unfold knapsackPEF simp_rw [toMultilinear01_mul, Finset.sum_mul] rw [Finset.sum_comm] apply Finset.sum_congr rfl; intro A _ rw [Finset.sum_comm] apply Finset.sum_congr rfl; intro B _ rw [Finset.sum_eq_single (A ∪ B)] · simp · intro S _ hne; simp [Ne.symm hne] · intro h; exact absurd (Finset.mem_univ _) h lemma knapsackPEF_mul_linSum_sub_C {F : Type*} [Field F] [CharZero F] (β : F) {p : MvPolynomial (Fin n) F} (hp : p.totalDegree < n) : knapsackPEF n β (p * (linSum n - MvPolynomial.C β)) = 0 := by classical rw [knapsackPEF_mul_eq] -- Compute `toMultilinear01 (linSum n - C β) B`: `1` for `B = {i}`, `-β` for `B = ∅`, else `0`! have hlin : ∀ B : Finset (Fin n), toMultilinear01 (linSum n - MvPolynomial.C β) B = (∑ i : Fin n, if ({i} : Finset (Fin n)) = B then (1 : F) else 0) - (if B = ∅ then β else 0) := by intro B rw [toMultilinear01_sub, linSum, toMultilinear01_finset_sum] congr 1 · apply Finset.sum_congr rfl; intro i _ have hX : (MvPolynomial.X i : MvPolynomial (Fin n) F) = mon01 {i} := by simp [mon01] rw [hX, toMultilinear01_mon01] · rw [MvPolynomial.C_apply, toMultilinear01_monomial, Finsupp.support_zero] by_cases hB : B = ∅ <;> simp [hB, eq_comm] apply Finset.sum_eq_zero; intro A _ by_cases hpA : toMultilinear01 p A = 0 · apply Finset.sum_eq_zero; intro B _; simp [hpA] · have hA_lt : A.card < n := lt_of_le_of_lt (toMultilinear01_support_card_le hpA) hp simp_rw [hlin, mul_sub, sub_mul, Finset.sum_sub_distrib, Finset.mul_sum, Finset.sum_mul] rw [Finset.sum_comm] -- First sum: `∑ i : Fin n, toMultilinear01 p A * (β^{|A ∪ {i}|} / n^{|A ∪ {i}|})`. have hsum1 : ∑ i : Fin n, ∑ B : Finset (Fin n), toMultilinear01 p A * (if ({i} : Finset (Fin n)) = B then (1 : F) else 0) * (descFact β (A ∪ B).card / descFact (n : F) (A ∪ B).card) = toMultilinear01 p A * ((A.card : F) * (descFact β A.card / descFact (n : F) A.card) + ((n : F) - (A.card : F)) * (descFact β (A.card + 1) / descFact (n : F) (A.card + 1))) := by have h1 : ∀ i : Fin n, ∑ B : Finset (Fin n), toMultilinear01 p A * (if ({i} : Finset (Fin n)) = B then (1 : F) else 0) * (descFact β (A ∪ B).card / descFact (n : F) (A ∪ B).card) = toMultilinear01 p A * (if i ∈ A then descFact β A.card / descFact (n : F) A.card else descFact β (A.card + 1) / descFact (n : F) (A.card + 1)) := by intro i rw [Finset.sum_eq_single ({i} : Finset (Fin n))] · rw [if_pos rfl, mul_one] congr 1 by_cases hi : i ∈ A · rw [if_pos hi, Finset.union_eq_left.mpr (Finset.singleton_subset_iff.mpr hi)] · rw [if_neg hi, show A ∪ {i} = insert i A by ext x; simp, Finset.card_insert_of_notMem hi] · intro B _ hne; rw [if_neg (Ne.symm hne), mul_zero, zero_mul] · intro h; exact absurd (Finset.mem_univ _) h simp_rw [h1, ← Finset.mul_sum] congr 1 rw [Finset.sum_ite, Finset.sum_const, Finset.sum_const, nsmul_eq_mul, nsmul_eq_mul] have hc1 : (Finset.univ.filter fun i : Fin n => i ∈ A).card = A.card := by congr 1; ext i; simp have hc2 : (Finset.univ.filter fun i : Fin n => i ∉ A).card = n - A.card := by have := Finset.card_compl A rw [Fintype.card_fin] at this rw [← this]; congr 1; ext i; simp rw [hc1, hc2, Nat.cast_sub (le_of_lt hA_lt)] -- Second sum: `toMultilinear01 p A * β * (β^{|A|} / n^{|A|})`. have hsum2 : ∑ B : Finset (Fin n), toMultilinear01 p A * (if B = ∅ then β else 0) * (descFact β (A ∪ B).card / descFact (n : F) (A ∪ B).card) = toMultilinear01 p A * (β * (descFact β A.card / descFact (n : F) A.card)) := by rw [Finset.sum_eq_single (∅ : Finset (Fin n))] · simp [mul_assoc] · intro B _ hne; simp [hne] · intro h; exact absurd (Finset.mem_univ _) h rw [hsum1, hsum2, ← mul_sub] have hinner : (A.card : F) * (descFact β A.card / descFact (n : F) A.card) + ((n : F) - (A.card : F)) * (descFact β (A.card + 1) / descFact (n : F) (A.card + 1)) - β * (descFact β A.card / descFact (n : F) A.card) = 0 := by rw [descFact_succ β A.card, descFact_succ (n : F) A.card] have hden1 : descFact (n : F) A.card ≠ 0 := descFact_nat_ne_zero (le_of_lt hA_lt) have hden2 : (n : F) - (A.card : F) ≠ 0 := by intro h have : n = A.card := Nat.cast_injective (sub_eq_zero.mp h) omega field_simp [hden1, hden2] ring rw [hinner, mul_zero] end Multilinear01 -- ------------------------------------------------------------------------------ -- 4C. Elementary Harmonic Spectral Diagonalization of `knapsackPE` -- ------------------------------------------------------------------------------ section HarmonicDiagonalization variable {n : ℕ} /-- A vector `c : Finset (Fin n) → ℝ` is `j`-harmonic if it is supported on `j`-element subsets and lies in the kernel of the downward incidence operator `D_j`: `∀ T` with `|T| + 1 = j`, `∑_{i ∉ T} c(insert i T) = 0`. -/ def IsHarmonic (j : ℕ) (c : Finset (Fin n) → ℝ) : Prop := (∀ S : Finset (Fin n), S.card ≠ j → c S = 0) ∧ (∀ T : Finset (Fin n), T.card + 1 = j → ∑ i ∈ Tᶜ, c (insert i T) = 0) /-- Harmonic restriction lemma: if `c` is `j`-harmonic, then for EVERY `B` with `|B| < j`, the sum of `c S` over all `j`-subsets `S ⊇ B` is identically `0`! -/ lemma harmonic_sum_superset {j : ℕ} {c : Finset (Fin n) → ℝ} (hc : IsHarmonic j c) : ∀ m : ℕ, ∀ B : Finset (Fin n), B.card + (m + 1) = j → ∑ S ∈ Finset.univ.filter (fun S : Finset (Fin n) => S.card = j ∧ B ⊆ S), c S = 0 := by classical intro m induction m with | zero => intro B hB have hbij : ∑ S ∈ Finset.univ.filter (fun S : Finset (Fin n) => S.card = j ∧ B ⊆ S), c S = ∑ i ∈ Bᶜ, c (insert i B) := by refine (Finset.sum_bij (fun i _ => insert i B) ?_ ?_ ?_ (fun _ _ => rfl)).symm · intro i hi have hnot : i ∉ B := Finset.mem_compl.mp hi simp only [Finset.mem_filter, Finset.mem_univ, true_and] exact ⟨by rw [Finset.card_insert_of_notMem hnot]; omega, Finset.subset_insert i B⟩ · intro i₁ hi₁ i₂ hi₂ heq have h1 : i₁ ∉ B := Finset.mem_compl.mp hi₁ have h2 : i₂ ∉ B := Finset.mem_compl.mp hi₂ have hmem : i₁ ∈ insert i₂ B := heq ▸ Finset.mem_insert_self i₁ B rcases Finset.mem_insert.mp hmem with rfl | hB1 · rfl · exact absurd hB1 h1 · intro S hS rcases (Finset.mem_filter.mp hS).2 with ⟨hScard, hBS⟩ have hdiff_card : (S \ B).card = 1 := by rw [Finset.card_sdiff_of_subset hBS]; omega rcases Finset.card_eq_one.mp hdiff_card with ⟨i, hi_eq⟩ have hi_mem : i ∈ S \ B := by rw [hi_eq]; simp have hiS : i ∈ S := (Finset.mem_sdiff.mp hi_mem).1 have hiB : i ∉ B := (Finset.mem_sdiff.mp hi_mem).2 refine ⟨i, Finset.mem_compl.mpr hiB, ?_⟩ ext x simp only [Finset.mem_insert] constructor · rintro (rfl | hx); exact hiS; exact hBS hx · intro hx by_cases hxB : x ∈ B · exact Or.inr hxB · left have : x ∈ S \ B := Finset.mem_sdiff.mpr ⟨hx, hxB⟩ rw [hi_eq] at this; exact Finset.mem_singleton.mp this rw [hbij] exact hc.2 B (by omega) | succ m ih => intro B hB -- Double count `(i, S)` with `i ∈ S \ B`, `|S| = j`, `B ⊆ S`! have hdc : ((m + 2 : ℕ) : ℝ) * (∑ S ∈ Finset.univ.filter (fun S : Finset (Fin n) => S.card = j ∧ B ⊆ S), c S) = ∑ i ∈ Bᶜ, ∑ S ∈ Finset.univ.filter (fun S : Finset (Fin n) => S.card = j ∧ insert i B ⊆ S), c S := by rw [Finset.mul_sum] calc ∑ S ∈ Finset.univ.filter (fun S : Finset (Fin n) => S.card = j ∧ B ⊆ S), ((m + 2 : ℕ) : ℝ) * c S = ∑ S ∈ Finset.univ.filter (fun S : Finset (Fin n) => S.card = j ∧ B ⊆ S), ∑ i ∈ Bᶜ, if i ∈ S then c S else 0 := by apply Finset.sum_congr rfl; intro S hS rcases (Finset.mem_filter.mp hS).2 with ⟨hScard, hBS⟩ rw [← Finset.sum_filter, Finset.sum_const, nsmul_eq_mul] congr 2 have heq : Bᶜ.filter (fun i => i ∈ S) = S \ B := by ext i; simp [and_comm] rw [heq, Finset.card_sdiff_of_subset hBS]; omega _ = ∑ i ∈ Bᶜ, ∑ S ∈ Finset.univ.filter (fun S : Finset (Fin n) => S.card = j ∧ B ⊆ S), if i ∈ S then c S else 0 := Finset.sum_comm _ = ∑ i ∈ Bᶜ, ∑ S ∈ Finset.univ.filter (fun S : Finset (Fin n) => S.card = j ∧ insert i B ⊆ S), c S := by apply Finset.sum_congr rfl; intro i _ rw [← Finset.sum_filter] apply Finset.sum_congr ?_ (fun _ _ => rfl) ext S simp only [Finset.mem_filter, Finset.mem_univ, true_and, Finset.insert_subset_iff] tauto have hrhs : ∑ i ∈ Bᶜ, ∑ S ∈ Finset.univ.filter (fun S : Finset (Fin n) => S.card = j ∧ insert i B ⊆ S), c S = 0 := by apply Finset.sum_eq_zero; intro i hi have hnot : i ∉ B := Finset.mem_compl.mp hi exact ih (insert i B) (by rw [Finset.card_insert_of_notMem hnot]; omega) rw [hrhs] at hdc have hne : ((m + 2 : ℕ) : ℝ) ≠ 0 := by positivity exact (mul_eq_zero.mp hdc).resolve_left hne /-- Alternating sum over a nonempty Boolean cube `∑_{T ⊆ U} (-1)^{|T|} = 0`. -/ lemma sum_neg_one_pow_card_powerset {U : Finset (Fin n)} (hU : U.Nonempty) : ∑ T ∈ U.powerset, (-1 : ℝ) ^ T.card = 0 := by classical rcases hU with ⟨a, ha⟩ have hpart : U.powerset = (U.erase a).powerset ∪ ((U.erase a).powerset.image (insert a)) := by ext T simp only [Finset.mem_powerset, Finset.mem_union, Finset.mem_image] constructor · intro hTU by_cases haT : a ∈ T · right; refine ⟨T.erase a, ?_, Finset.insert_erase haT⟩ exact Finset.erase_subset_erase a hTU · left; exact Finset.subset_erase.mpr ⟨hTU, haT⟩ · rintro (h | ⟨T', hT', rfl⟩) · exact h.trans (Finset.erase_subset a U) · exact Finset.insert_subset ha (hT'.trans (Finset.erase_subset a U)) have hdisj : Disjoint (U.erase a).powerset ((U.erase a).powerset.image (insert a)) := by rw [Finset.disjoint_left] intro T h1 h2 rcases Finset.mem_image.mp h2 with ⟨T', _, rfl⟩ have ha1 : a ∉ insert a T' := fun h => (Finset.notMem_erase a U) (Finset.mem_powerset.mp h1 h) exact ha1 (Finset.mem_insert_self a T') have hinj : Set.InjOn (insert a) ((U.erase a).powerset : Set (Finset (Fin n))) := by intro T₁ h1 T₂ h2 heq have ha1 : a ∉ T₁ := fun h => (Finset.notMem_erase a U) (Finset.mem_powerset.mp h1 h) have ha2 : a ∉ T₂ := fun h => (Finset.notMem_erase a U) (Finset.mem_powerset.mp h2 h) have := congrArg (fun S => S.erase a) heq simpa [Finset.erase_insert ha1, Finset.erase_insert ha2] using this rw [hpart, Finset.sum_union hdisj, Finset.sum_image hinj] have hneg : ∑ T ∈ (U.erase a).powerset, (-1 : ℝ) ^ (insert a T).card = - ∑ T ∈ (U.erase a).powerset, (-1 : ℝ) ^ T.card := by rw [← Finset.sum_neg_distrib] apply Finset.sum_congr rfl; intro T hT have haT : a ∉ T := fun h => (Finset.notMem_erase a U) (Finset.mem_powerset.mp hT h) rw [Finset.card_insert_of_notMem haT, pow_succ]; ring rw [hneg, add_neg_cancel] /-- Exact inclusion–exclusion on harmonic vectors (Case 1: `|A| = j`): `∑_{S : |S|=j, S ∩ A = R} c S = (-1)^{j - |R|} * c A`. -/ lemma harmonic_sum_exact_inter_eq {j : ℕ} {c : Finset (Fin n) → ℝ} (hc : IsHarmonic j c) {A : Finset (Fin n)} (hA : A.card = j) : ∀ m : ℕ, ∀ R : Finset (Fin n), R ⊆ A → R.card + m = j → ∑ S ∈ Finset.univ.filter (fun S : Finset (Fin n) => S.card = j ∧ S ∩ A = R), c S = (-1 : ℝ) ^ m * c A := by classical intro m induction m using Nat.strong_induction_on with | h m ih => intro R hRA hRm cases m with | zero => have hR_eq : R = A := Finset.eq_of_subset_of_card_le hRA (by omega) rw [hR_eq] have hfilt : Finset.univ.filter (fun S : Finset (Fin n) => S.card = j ∧ S ∩ A = A) = {A} := by ext S simp only [Finset.mem_filter, Finset.mem_univ, true_and, Finset.mem_singleton] constructor · rintro ⟨hSc, hSA⟩ have hAS : A ⊆ S := by rw [← hSA]; exact Finset.inter_subset_left exact (Finset.eq_of_subset_of_card_le hAS (by omega)).symm · rintro rfl; exact ⟨hA, Finset.inter_self S⟩ rw [hfilt, Finset.sum_singleton, pow_zero, one_mul] | succ m' => -- Partition `{S | |S| = j ∧ R ⊆ S}` by `Q = S ∩ A` (`R ⊆ Q ⊆ A`)! have htot : ∑ S ∈ Finset.univ.filter (fun S : Finset (Fin n) => S.card = j ∧ R ⊆ S), c S = 0 := harmonic_sum_superset hc m' R hRm let interSets := A.powerset.filter fun Q => R ⊆ Q have hpart : ∑ S ∈ Finset.univ.filter (fun S : Finset (Fin n) => S.card = j ∧ R ⊆ S), c S = ∑ Q ∈ interSets, ∑ S ∈ Finset.univ.filter (fun S : Finset (Fin n) => S.card = j ∧ S ∩ A = Q), c S := by have hmap : ∀ S ∈ Finset.univ.filter (fun S : Finset (Fin n) => S.card = j ∧ R ⊆ S), S ∩ A ∈ interSets := by intro S hS simp only [interSets, Finset.mem_filter, Finset.mem_powerset] exact ⟨Finset.inter_subset_right, Finset.subset_inter (Finset.mem_filter.mp hS).2.2 hRA⟩ rw [← Finset.sum_fiberwise_of_maps_to hmap] apply Finset.sum_congr rfl; intro Q hQ apply Finset.sum_congr ?_ (fun _ _ => rfl) ext S have hRQ : R ⊆ Q := (Finset.mem_filter.mp hQ).2 simp only [Finset.mem_filter, Finset.mem_univ, true_and] constructor · rintro ⟨⟨hSc, _⟩, hSA⟩; exact ⟨hSc, hSA⟩ · rintro ⟨hSc, hSA⟩; exact ⟨⟨hSc, hRQ.trans (hSA ▸ Finset.inter_subset_left)⟩, hSA⟩ have hR_mem : R ∈ interSets := Finset.mem_filter.mpr ⟨Finset.mem_powerset.mpr hRA, Finset.Subset.refl R⟩ rw [hpart, ← Finset.add_sum_erase _ _ hR_mem] at htot -- For every `Q ∈ interSets.erase R`, `R ⊂ Q ⊆ A`, so `j - Q.card < m' + 1`! have hrest : ∑ Q ∈ interSets.erase R, ∑ S ∈ Finset.univ.filter (fun S : Finset (Fin n) => S.card = j ∧ S ∩ A = Q), c S = (∑ Q ∈ interSets.erase R, (-1 : ℝ) ^ (j - Q.card)) * c A := by rw [Finset.sum_mul] apply Finset.sum_congr rfl; intro Q hQ have hQne : Q ≠ R := (Finset.mem_erase.mp hQ).1 have hQmem : Q ∈ interSets := (Finset.mem_erase.mp hQ).2 have hQA : Q ⊆ A := Finset.mem_powerset.mp (Finset.mem_filter.mp hQmem).1 have hRQ : R ⊆ Q := (Finset.mem_filter.mp hQmem).2 have hlt : R.card < Q.card := Finset.card_lt_card (Finset.ssubset_iff_subset_ne.mpr ⟨hRQ, hQne.symm⟩) have hQle : Q.card ≤ j := by rw [← hA]; exact Finset.card_le_card hQA exact ih (j - Q.card) (by omega) Q hQA (by omega) -- Show `∑_{Q ∈ interSets} (-1)^{j - |Q|} = 0` by bijecting `Q = R ∪ T` with `T ⊆ A \ R`! have halt : ∑ Q ∈ interSets, (-1 : ℝ) ^ (j - Q.card) = 0 := by have hbij : ∑ Q ∈ interSets, (-1 : ℝ) ^ (j - Q.card) = (-1 : ℝ) ^ (m' + 1) * ∑ T ∈ (A \ R).powerset, (-1 : ℝ) ^ T.card := by rw [Finset.mul_sum] refine (Finset.sum_bij (fun T _ => R ∪ T) ?_ ?_ ?_ ?_).symm · intro T hT have hTsub : T ⊆ A \ R := Finset.mem_powerset.mp hT refine Finset.mem_filter.mpr ⟨Finset.mem_powerset.mpr ?_, Finset.subset_union_left⟩ exact Finset.union_subset hRA (hTsub.trans Finset.sdiff_subset) · intro T₁ h1 T₂ h2 heq have hd1 : Disjoint R T₁ := disjoint_sdiff_self_right.mono_right (Finset.mem_powerset.mp h1) have hd2 : Disjoint R T₂ := disjoint_sdiff_self_right.mono_right (Finset.mem_powerset.mp h2) ext x have hmem := congrArg (fun S => x ∈ S) heq simp only [Finset.mem_union] at hmem by_cases hxR : x ∈ R · have h1x : x ∉ T₁ := Finset.disjoint_left.mp hd1 hxR have h2x : x ∉ T₂ := Finset.disjoint_left.mp hd2 hxR simp [h1x, h2x] · simp [hxR] at hmem; exact hmem · intro Q hQ have hQA : Q ⊆ A := Finset.mem_powerset.mp (Finset.mem_filter.mp hQ).1 have hRQ : R ⊆ Q := (Finset.mem_filter.mp hQ).2 refine ⟨Q \ R, Finset.mem_powerset.mpr (Finset.sdiff_subset_sdiff hQA (Finset.Subset.refl R)), Finset.union_sdiff_of_subset hRQ⟩ · intro T hT have hd : Disjoint R T := disjoint_sdiff_self_right.mono_right (Finset.mem_powerset.mp hT) have hcard : (R ∪ T).card = R.card + T.card := Finset.card_union_of_disjoint hd have hTle : T.card ≤ m' + 1 := by have h1 := Finset.card_le_card (Finset.mem_powerset.mp hT) rw [Finset.card_sdiff_of_subset hRA] at h1; omega rw [hcard, show j - (R.card + T.card) = (m' + 1) - T.card by omega] -- `(-1)^(m'+1) * (-1)^|T| = (-1)^((m'+1) - |T|)`! have hpow : (-1 : ℝ) ^ (m' + 1) * (-1 : ℝ) ^ T.card = (-1 : ℝ) ^ (m' + 1 - T.card) := by have h1 : m' + 1 = (m' + 1 - T.card) + T.card := by omega conv_lhs => rw [h1, pow_add, mul_assoc, ← pow_add, ← two_mul, pow_mul] norm_num exact hpow have hne : (A \ R).Nonempty := Finset.card_pos.mp (by rw [Finset.card_sdiff_of_subset hRA]; omega) rw [hbij, sum_neg_one_pow_card_powerset hne, mul_zero] rw [← Finset.add_sum_erase _ _ hR_mem] at halt rw [show j - R.card = m' + 1 by omega] at halt rw [hrest] at htot have hsum_er : ∑ Q ∈ interSets.erase R, (-1 : ℝ) ^ (j - Q.card) = - (-1 : ℝ) ^ (m' + 1) := by linarith rw [hsum_er] at htot linarith /-- Exact inclusion–exclusion on harmonic vectors (Case 2: `|A| < j`): for EVERY `R ⊆ A`, `∑_{S : |S|=j, S ∩ A = R} c S = 0`! -/ lemma harmonic_sum_exact_inter_lt {j : ℕ} {c : Finset (Fin n) → ℝ} (hc : IsHarmonic j c) {A : Finset (Fin n)} (hA : A.card < j) : ∀ m : ℕ, ∀ R : Finset (Fin n), R ⊆ A → R.card + m = A.card → ∑ S ∈ Finset.univ.filter (fun S : Finset (Fin n) => S.card = j ∧ S ∩ A = R), c S = 0 := by classical intro m induction m using Nat.strong_induction_on with | h m ih => intro R hRA hRm cases m with | zero => have hR_eq : R = A := Finset.eq_of_subset_of_card_le hRA (by omega) rw [hR_eq] have heq : Finset.univ.filter (fun S : Finset (Fin n) => S.card = j ∧ S ∩ A = A) = Finset.univ.filter (fun S : Finset (Fin n) => S.card = j ∧ A ⊆ S) := by ext S simp only [Finset.mem_filter, Finset.mem_univ, true_and, Finset.inter_eq_right] rw [heq] exact harmonic_sum_superset hc (j - A.card - 1) A (by omega) | succ m' => have htot : ∑ S ∈ Finset.univ.filter (fun S : Finset (Fin n) => S.card = j ∧ R ⊆ S), c S = 0 := harmonic_sum_superset hc (j - R.card - 1) R (by omega) let interSets := A.powerset.filter fun Q => R ⊆ Q have hpart : ∑ S ∈ Finset.univ.filter (fun S : Finset (Fin n) => S.card = j ∧ R ⊆ S), c S = ∑ Q ∈ interSets, ∑ S ∈ Finset.univ.filter (fun S : Finset (Fin n) => S.card = j ∧ S ∩ A = Q), c S := by have hmap : ∀ S ∈ Finset.univ.filter (fun S : Finset (Fin n) => S.card = j ∧ R ⊆ S), S ∩ A ∈ interSets := by intro S hS simp only [interSets, Finset.mem_filter, Finset.mem_powerset] exact ⟨Finset.inter_subset_right, Finset.subset_inter (Finset.mem_filter.mp hS).2.2 hRA⟩ rw [← Finset.sum_fiberwise_of_maps_to hmap] apply Finset.sum_congr rfl; intro Q hQ apply Finset.sum_congr ?_ (fun _ _ => rfl) ext S have hRQ : R ⊆ Q := (Finset.mem_filter.mp hQ).2 simp only [Finset.mem_filter, Finset.mem_univ, true_and] constructor · rintro ⟨⟨hSc, _⟩, hSA⟩; exact ⟨hSc, hSA⟩ · rintro ⟨hSc, hSA⟩; exact ⟨⟨hSc, hRQ.trans (hSA ▸ Finset.inter_subset_left)⟩, hSA⟩ have hR_mem : R ∈ interSets := Finset.mem_filter.mpr ⟨Finset.mem_powerset.mpr hRA, Finset.Subset.refl R⟩ rw [hpart, ← Finset.add_sum_erase _ _ hR_mem] at htot have hrest : ∑ Q ∈ interSets.erase R, ∑ S ∈ Finset.univ.filter (fun S : Finset (Fin n) => S.card = j ∧ S ∩ A = Q), c S = 0 := by apply Finset.sum_eq_zero; intro Q hQ have hQne : Q ≠ R := (Finset.mem_erase.mp hQ).1 have hQmem : Q ∈ interSets := (Finset.mem_erase.mp hQ).2 have hQA : Q ⊆ A := Finset.mem_powerset.mp (Finset.mem_filter.mp hQmem).1 have hRQ : R ⊆ Q := (Finset.mem_filter.mp hQmem).2 have hlt : R.card < Q.card := Finset.card_lt_card (Finset.ssubset_iff_subset_ne.mpr ⟨hRQ, hQne.symm⟩) have hQle : Q.card ≤ A.card := Finset.card_le_card hQA exact ih (A.card - Q.card) (by omega) Q hQA (by omega) rw [hrest, add_zero] at htot exact htot /-- Orthogonality of `j`-harmonic vectors to all lower-degree monomials `|A| < j` under `knapsackPE`. -/ lemma harmonic_ortho_lower {j : ℕ} {c : Finset (Fin n) → ℝ} (hc : IsHarmonic j c) (β : ℝ) {A : Finset (Fin n)} (hA : A.card < j) : ∑ S : Finset (Fin n), c S * (descFact β (S ∪ A).card / descFact (n : ℝ) (S ∪ A).card) = 0 := by classical -- Restrict to `|S| = j` and group by `R = S ∩ A ∈ A.powerset`. have hres : ∑ S : Finset (Fin n), c S * (descFact β (S ∪ A).card / descFact (n : ℝ) (S ∪ A).card) = ∑ S ∈ Finset.univ.filter (fun S : Finset (Fin n) => S.card = j), c S * (descFact β (S ∪ A).card / descFact (n : ℝ) (S ∪ A).card) := by rw [Finset.sum_filter] apply Finset.sum_congr rfl; intro S _ by_cases hS : S.card = j · rw [if_pos hS] · rw [if_neg hS, hc.1 S hS, zero_mul] rw [hres] rw [← Finset.sum_fiberwise_of_maps_to (g := fun S : Finset (Fin n) => S ∩ A) (t := A.powerset) (fun S _ => Finset.mem_powerset.mpr Finset.inter_subset_right)] apply Finset.sum_eq_zero; intro R hR have hRA : R ⊆ A := Finset.mem_powerset.mp hR have hconst : ∀ S ∈ (Finset.univ.filter fun S : Finset (Fin n) => S.card = j).filter (fun S => S ∩ A = R), (S ∪ A).card = j + A.card - R.card := by intro S hS have hSc : S.card = j := (Finset.mem_filter.mp (Finset.mem_filter.mp hS).1).2 have hSA : S ∩ A = R := (Finset.mem_filter.mp hS).2 have h := Finset.card_union_add_card_inter S A rw [hSc, hSA] at h; omega have hfactor : ∑ S ∈ (Finset.univ.filter fun S : Finset (Fin n) => S.card = j).filter (fun S => S ∩ A = R), c S * (descFact β (S ∪ A).card / descFact (n : ℝ) (S ∪ A).card) = (∑ S ∈ Finset.univ.filter (fun S : Finset (Fin n) => S.card = j ∧ S ∩ A = R), c S) * (descFact β (j + A.card - R.card) / descFact (n : ℝ) (j + A.card - R.card)) := by rw [Finset.sum_mul] apply Finset.sum_congr ?_ ?_ · ext S; simp only [Finset.mem_filter, Finset.mem_univ, true_and] · intro S hS rw [hconst S (by simp only [Finset.mem_filter, Finset.mem_univ, true_and] at hS ⊢; exact hS)] rw [hfactor] have hRle : R.card ≤ A.card := Finset.card_le_card hRA rw [harmonic_sum_exact_inter_lt hc hA (A.card - R.card) R hRA (by omega), zero_mul] /-- Exact eigenvalue identity on the `j`-th harmonic subspace (`2 * j ≤ n`): `∑_{A, S} c A * c S * (β^{⌊|A ∪ S|⌋} / n^{⌊|A ∪ S|⌋}) = (β^{⌊j⌋} (n - β)^{⌊j⌋} / n^{⌊2j⌋}) * ∑_A c(A)^2`! -/ lemma harmonic_pe_sq {j : ℕ} {c : Finset (Fin n) → ℝ} (hc : IsHarmonic j c) (β : ℝ) (hj : 2 * j ≤ n) : ∑ A : Finset (Fin n), ∑ S : Finset (Fin n), c A * c S * (descFact β (A ∪ S).card / descFact (n : ℝ) (A ∪ S).card) = (descFact β j * descFact ((n : ℝ) - β) j / descFact (n : ℝ) (2 * j)) * ∑ A : Finset (Fin n), (c A) ^ 2 := by classical rw [Finset.mul_sum] apply Finset.sum_congr rfl; intro A _ by_cases hA : A.card = j · -- Group `S` (with `|S| = j`) by `R = S ∩ A ∈ A.powerset`! have hinner : ∑ S : Finset (Fin n), c A * c S * (descFact β (A ∪ S).card / descFact (n : ℝ) (A ∪ S).card) = c A * ∑ S ∈ Finset.univ.filter (fun S : Finset (Fin n) => S.card = j), c S * (descFact β (A ∪ S).card / descFact (n : ℝ) (A ∪ S).card) := by rw [Finset.mul_sum, Finset.sum_filter] apply Finset.sum_congr rfl; intro S _ by_cases hS : S.card = j · rw [if_pos hS, mul_assoc] · rw [if_neg hS, hc.1 S hS, mul_zero, zero_mul] rw [hinner] have hfib : ∑ S ∈ Finset.univ.filter (fun S : Finset (Fin n) => S.card = j), c S * (descFact β (A ∪ S).card / descFact (n : ℝ) (A ∪ S).card) = c A * (descFact β j / descFact (n : ℝ) j) * ∑ s ∈ Finset.range (j + 1), ((-1 : ℝ) ^ s * (Nat.choose j s : ℝ)) * (descFact (β - (j : ℝ)) s / descFact ((n : ℝ) - (j : ℝ)) s) := by rw [← Finset.sum_fiberwise_of_maps_to (g := fun S : Finset (Fin n) => S ∩ A) (t := A.powerset) (fun S _ => Finset.mem_powerset.mpr Finset.inter_subset_right)] have hterm : ∀ R ∈ A.powerset, ∑ S ∈ (Finset.univ.filter fun S : Finset (Fin n) => S.card = j).filter (fun S => S ∩ A = R), c S * (descFact β (A ∪ S).card / descFact (n : ℝ) (A ∪ S).card) = c A * (descFact β j / descFact (n : ℝ) j) * ((-1 : ℝ) ^ (j - R.card) * (descFact (β - (j : ℝ)) (j - R.card) / descFact ((n : ℝ) - (j : ℝ)) (j - R.card))) := by intro R hR have hRA : R ⊆ A := Finset.mem_powerset.mp hR have hRle : R.card ≤ j := by rw [← hA]; exact Finset.card_le_card hRA have hconst : ∀ S ∈ (Finset.univ.filter fun S : Finset (Fin n) => S.card = j).filter (fun S => S ∩ A = R), (A ∪ S).card = j + (j - R.card) := by intro S hS have hSc : S.card = j := (Finset.mem_filter.mp (Finset.mem_filter.mp hS).1).2 have hSA : S ∩ A = R := (Finset.mem_filter.mp hS).2 have h := Finset.card_union_add_card_inter A S rw [Finset.inter_comm, hA, hSc, hSA] at h; omega have hpull : ∑ S ∈ (Finset.univ.filter fun S : Finset (Fin n) => S.card = j).filter (fun S => S ∩ A = R), c S * (descFact β (A ∪ S).card / descFact (n : ℝ) (A ∪ S).card) = (∑ S ∈ Finset.univ.filter (fun S : Finset (Fin n) => S.card = j ∧ S ∩ A = R), c S) * (descFact β (j + (j - R.card)) / descFact (n : ℝ) (j + (j - R.card))) := by rw [Finset.sum_mul] apply Finset.sum_congr ?_ ?_ · ext S; simp only [Finset.mem_filter, Finset.mem_univ, true_and] · intro S hS rw [hconst S (by simp only [Finset.mem_filter, Finset.mem_univ, true_and] at hS ⊢; exact hS)] rw [hpull, harmonic_sum_exact_inter_eq hc hA (j - R.card) R hRA (by omega), descFact_add β j (j - R.card), descFact_add (n : ℝ) j (j - R.card), mul_div_mul_comm] ring rw [Finset.sum_congr rfl hterm, ← Finset.mul_sum] congr 1 -- Group `R ∈ A.powerset` by `s = j - R.card ∈ Finset.range (j + 1)`! rw [← Finset.sum_fiberwise_of_maps_to (g := fun R : Finset (Fin n) => j - R.card) (t := Finset.range (j + 1)) (fun R _ => Finset.mem_range.mpr (by omega))] apply Finset.sum_congr rfl; intro s hs have hs_le : s ≤ j := Nat.lt_succ_iff.mp (Finset.mem_range.mp hs) have hconst_s : ∀ R ∈ A.powerset.filter (fun R => j - R.card = s), (-1 : ℝ) ^ (j - R.card) * (descFact (β - (j : ℝ)) (j - R.card) / descFact ((n : ℝ) - (j : ℝ)) (j - R.card)) = (-1 : ℝ) ^ s * (descFact (β - (j : ℝ)) s / descFact ((n : ℝ) - (j : ℝ)) s) := by intro R hR; rw [(Finset.mem_filter.mp hR).2] rw [Finset.sum_congr rfl hconst_s, Finset.sum_const, nsmul_eq_mul] have hcard_s : (A.powerset.filter (fun R => j - R.card = s)).card = Nat.choose j s := by have hfilt_eq : A.powerset.filter (fun R => j - R.card = s) = A.powersetCard (j - s) := by ext R simp only [Finset.mem_filter, Finset.mem_powerset, Finset.mem_powersetCard] constructor · rintro ⟨hRA, hsub⟩ have hRle : R.card ≤ j := by rw [← hA]; exact Finset.card_le_card hRA exact ⟨hRA, by omega⟩ · rintro ⟨hRA, hcard⟩; exact ⟨hRA, by omega⟩ rw [hfilt_eq, Finset.card_powersetCard, hA, Nat.choose_symm hs_le] rw [hcard_s]; ring rw [hfib] have hN : ∀ t < j, ((n : ℝ) - (j : ℝ)) - (t : ℝ) ≠ 0 := by intro t ht have : (j : ℝ) + (t : ℝ) < (n : ℝ) := by exact_mod_cast (show j + t < n by omega) linarith rw [chu_vandermonde_falling (β - (j : ℝ)) ((n : ℝ) - (j : ℝ)) j hN] have hsub : ((n : ℝ) - (j : ℝ)) - (β - (j : ℝ)) = (n : ℝ) - β := by ring have h2j : descFact (n : ℝ) (2 * j) = descFact (n : ℝ) j * descFact ((n : ℝ) - (j : ℝ)) j := by rw [two_mul, descFact_add] rw [hsub, h2j] have hd1 : descFact (n : ℝ) j ≠ 0 := ne_of_gt (descFact_nat_pos_real (by omega)) have hd2 : descFact ((n : ℝ) - (j : ℝ)) j ≠ 0 := by have hpos : 0 < descFact (n : ℝ) (2 * j) := descFact_nat_pos_real hj rw [h2j] at hpos exact ne_of_gt (pos_of_mul_pos_right hpos (le_of_lt (descFact_nat_pos_real (by omega)))) field_simp [hd1, hd2] · rw [hc.1 A hA]; simp /-- Orthogonal decomposition on level `j ≥ 1`: every vector `v` on `j`-subsets splits as `v = h + U_0 w`, where `h` is `j`-harmonic and `w` is supported on `(j - 1)`-subsets! -/ lemma harmonic_level_decomp {j : ℕ} (_hj : 1 ≤ j) (v : Finset (Fin n) → ℝ) : ∃ (h w : Finset (Fin n) → ℝ), IsHarmonic j h ∧ (∀ T : Finset (Fin n), T.card + 1 ≠ j → w T = 0) ∧ (∀ S : Finset (Fin n), S.card = j → v S = h S + ∑ i ∈ S, w (S.erase i)) := by classical let ι := {S : Finset (Fin n) // S.card = j} let τ := {T : Finset (Fin n) // T.card + 1 = j} let U : (τ → ℝ) →ₗ[ℝ] EuclideanSpace ℝ ι := { toFun := fun w => WithLp.toLp 2 fun S : ι => ∑ i ∈ S.1, if h : (S.1.erase i).card + 1 = j then w ⟨S.1.erase i, h⟩ else 0 map_add' := fun w₁ w₂ => by ext S simp only [WithLp.ofLp_add, Pi.add_apply, ← Finset.sum_add_distrib] apply Finset.sum_congr rfl; intro i _; split_ifs <;> ring map_smul' := fun c w => by ext S; simp only [WithLp.ofLp_smul, Pi.smul_apply, smul_eq_mul, RingHom.id_apply, Finset.mul_sum] apply Finset.sum_congr rfl; intro i _; split_ifs <;> ring } let vVec : EuclideanSpace ℝ ι := WithLp.toLp 2 fun S : ι => v S.1 rcases Submodule.exists_add_mem_mem_orthogonal (K := LinearMap.range U) vVec with ⟨y, ⟨w0, rfl⟩, z, hz, hv⟩ let h : Finset (Fin n) → ℝ := fun S => if hS : S.card = j then z.ofLp ⟨S, hS⟩ else 0 let w : Finset (Fin n) → ℝ := fun T => if hT : T.card + 1 = j then w0 ⟨T, hT⟩ else 0 refine ⟨h, w, ⟨?_, ?_⟩, ?_, ?_⟩ · intro S hne; dsimp only [h]; rw [dif_neg hne] · -- Prove `IsHarmonic`: test `⟪U (Pi.single ⟨T, hT⟩ 1), z⟫ = 0`! intro T hT have horth : inner ℝ (U (Pi.single (⟨T, hT⟩ : τ) (1 : ℝ))) z = 0 := (Submodule.mem_orthogonal (LinearMap.range U) z).mp hz _ (LinearMap.mem_range_self U _) rw [PiLp.inner_apply] at horth -- Evaluate each term `inner ℝ (U (Pi.single T 1) S) (z S)`: have hsum_eq : ∑ S : ι, inner ℝ ((U (Pi.single (⟨T, hT⟩ : τ) (1 : ℝ))).ofLp S) (z.ofLp S) = ∑ i ∈ Tᶜ, h (insert i T) := by have hterm : ∀ S : ι, inner ℝ ((U (Pi.single (⟨T, hT⟩ : τ) (1 : ℝ))).ofLp S) (z.ofLp S) = if T ⊆ S.1 then z.ofLp S else 0 := by intro S rw [RCLike.inner_apply, conj_trivial] dsimp only [U, LinearMap.coe_mk, AddHom.coe_mk] by_cases hTS : T ⊆ S.1 · rw [if_pos hTS] have hdiff : (S.1 \ T).card = 1 := by rw [Finset.card_sdiff_of_subset hTS, S.2]; omega rcases Finset.card_eq_one.mp hdiff with ⟨a, ha_eq⟩ have haS : a ∈ S.1 := (Finset.mem_sdiff.mp (ha_eq ▸ Finset.mem_singleton_self a)).1 have haT : a ∉ T := (Finset.mem_sdiff.mp (ha_eq ▸ Finset.mem_singleton_self a)).2 have herase : S.1.erase a = T := by ext x; simp only [Finset.mem_erase] constructor · rintro ⟨hxa, hxS⟩ by_contra hxT have : x ∈ S.1 \ T := Finset.mem_sdiff.mpr ⟨hxS, hxT⟩ rw [ha_eq] at this; exact hxa (Finset.mem_singleton.mp this) · intro hxT; exact ⟨fun h => haT (h ▸ hxT), hTS hxT⟩ have hsum1 : (∑ i ∈ S.1, if h : (S.1.erase i).card + 1 = j then (Pi.single (M := fun _ : τ => ℝ) (⟨T, hT⟩ : τ) (1 : ℝ)) ⟨S.1.erase i, h⟩ else (0 : ℝ)) = 1 := by rw [Finset.sum_eq_single a] · have hc : (S.1.erase a).card + 1 = j := by rw [herase]; exact hT rw [dif_pos hc] have hsub : (⟨S.1.erase a, hc⟩ : τ) = ⟨T, hT⟩ := Subtype.ext herase rw [hsub, Pi.single_eq_same] · intro i hiS hia split_ifs with hc · have hne : (⟨S.1.erase i, hc⟩ : τ) ≠ ⟨T, hT⟩ := by intro heq have h1 := congrArg Subtype.val heq; dsimp at h1 have : a ∈ S.1.erase i := Finset.mem_erase.mpr ⟨hia.symm, haS⟩ rw [h1] at this; exact haT this exact Pi.single_eq_of_ne (M := fun _ : τ => ℝ) hne (1 : ℝ) · rfl · intro h; exact absurd haS h rw [hsum1, mul_one] · rw [if_neg hTS] have hsum0 : (∑ i ∈ S.1, if h : (S.1.erase i).card + 1 = j then (Pi.single (M := fun _ : τ => ℝ) (⟨T, hT⟩ : τ) (1 : ℝ)) ⟨S.1.erase i, h⟩ else (0 : ℝ)) = 0 := by apply Finset.sum_eq_zero; intro i _ split_ifs with hc · have hne : (⟨S.1.erase i, hc⟩ : τ) ≠ ⟨T, hT⟩ := by intro heq have h1 := congrArg Subtype.val heq; dsimp at h1 exact hTS (h1 ▸ Finset.erase_subset i S.1) exact Pi.single_eq_of_ne (M := fun _ : τ => ℝ) hne (1 : ℝ) · rfl rw [hsum0, mul_zero] simp_rw [hterm] rw [← Finset.sum_filter] refine (Finset.sum_bij (fun i (hi : i ∈ Tᶜ) => (⟨insert i T, by rw [Finset.card_insert_of_notMem (Finset.mem_compl.mp hi)]; exact hT⟩ : ι)) ?_ ?_ ?_ ?_).symm · intro i hi; simp [Finset.subset_insert] · intro i₁ hi₁ i₂ hi₂ heq have h1 := congrArg Subtype.val heq; dsimp at h1 have hnot1 : i₁ ∉ T := Finset.mem_compl.mp hi₁ have hmem : i₁ ∈ insert i₂ T := h1 ▸ Finset.mem_insert_self i₁ T rcases Finset.mem_insert.mp hmem with rfl | hT1 · rfl · exact absurd hT1 hnot1 · intro S hS have hTS : T ⊆ S.1 := (Finset.mem_filter.mp hS).2 have hdiff : (S.1 \ T).card = 1 := by rw [Finset.card_sdiff_of_subset hTS, S.2]; omega rcases Finset.card_eq_one.mp hdiff with ⟨a, ha_eq⟩ have haS : a ∈ S.1 := (Finset.mem_sdiff.mp (ha_eq ▸ Finset.mem_singleton_self a)).1 have haT : a ∉ T := (Finset.mem_sdiff.mp (ha_eq ▸ Finset.mem_singleton_self a)).2 refine ⟨a, Finset.mem_compl.mpr haT, Subtype.ext ?_⟩ ext x; simp only [Finset.mem_insert] constructor · rintro (rfl | hxT); exact haS; exact hTS hxT · intro hxS by_cases hxT : x ∈ T · exact Or.inr hxT · left; exact Finset.mem_singleton.mp (ha_eq ▸ Finset.mem_sdiff.mpr ⟨hxS, hxT⟩) · intro i hi have hc : (insert i T).card = j := by rw [Finset.card_insert_of_notMem (Finset.mem_compl.mp hi)]; exact hT dsimp only [h]; rw [dif_pos hc] rw [← hsum_eq, horth] · intro T hne; dsimp only [w]; rw [dif_neg hne] · intro S hS have hpt := congrArg (fun x : EuclideanSpace ℝ ι => x.ofLp ⟨S, hS⟩) hv dsimp only [vVec, U, LinearMap.coe_mk, AddHom.coe_mk] at hpt simp only [WithLp.ofLp_add, Pi.add_apply] at hpt rw [hpt, add_comm] dsimp only [h, w] rw [dif_pos hS] /-- **Headline Theorem 4B (Exact Elementary Harmonic Spectral Diagonalization of `knapsackPE`):** For EVERY `n d : ℕ` with `2 * d ≤ n`, EVERY `β : ℝ`, and EVERY `p : MvPolynomial (Fin n) ℝ` with `p.totalDegree ≤ d`, there exist harmonic vectors `h : Fin (d + 1) → (Finset (Fin n) → ℝ)` (`∀ j, IsHarmonic j.1 (h j)`) such that `knapsackPE n β (p ^ 2) = ∑_{j=0}^d (β^{⌊j⌋} (n - β)^{⌊j⌋} / n^{⌊2j⌋}) * ∑_S (h j S)^2`! -/ theorem knapsack_harmonic_diagonalization {n d : ℕ} (hd : 2 * d ≤ n) (β : ℝ) (p : MvPolynomial (Fin n) ℝ) (hp : p.totalDegree ≤ d) : ∃ h : Fin (d + 1) → (Finset (Fin n) → ℝ), (∀ j : Fin (d + 1), IsHarmonic j.1 (h j)) ∧ knapsackPE n β (p ^ 2) = ∑ j : Fin (d + 1), (descFact β j.1 * descFact ((n : ℝ) - β) j.1 / descFact (n : ℝ) (2 * j.1)) * ∑ S : Finset (Fin n), (h j S) ^ 2 := by classical -- Step 1: Inductively peel off harmonic parts from `k = d` down to `0` modulo `(linSum n - C β)`! have hpeel : ∀ k : ℕ, ∀ f : Finset (Fin n) → ℝ, (∀ S, k < S.card → f S = 0) → ∃ (h : Fin (k + 1) → (Finset (Fin n) → ℝ)) (Q : MvPolynomial (Fin n) ℝ), (∀ j : Fin (k + 1), IsHarmonic j.1 (h j)) ∧ (Q = 0 ∨ Q.totalDegree + 1 ≤ k) ∧ ∀ S : Finset (Fin n), f S = (∑ j : Fin (k + 1), h j S) + toMultilinear01 (Q * (linSum n - MvPolynomial.C β)) S := by intro k induction k with | zero => intro f hf refine ⟨fun _ => f, 0, ?_, Or.inl rfl, ?_⟩ · intro j have hj0 : j.1 = 0 := Nat.lt_one_iff.mp j.2 rw [hj0] exact ⟨fun S hne => hf S (by omega), fun T hT => by omega⟩ · intro S; simp [toMultilinear01_zero] | succ k ih => intro f hf rcases harmonic_level_decomp (show 1 ≤ k + 1 by omega) f with ⟨hTop, w, hhTop, hw_supp, hdecomp⟩ -- Define `qTop := ∑ T, C (w T) * mon01 T` (degree `≤ k`, supported on `|T| = k`)! let qTop : MvPolynomial (Fin n) ℝ := ∑ T ∈ Finset.univ.filter (fun T : Finset (Fin n) => T.card = k), MvPolynomial.C (w T) * mon01 T have hqTop_deg : qTop.totalDegree ≤ k := by refine le_trans (MvPolynomial.totalDegree_finsetSum _ _) ?_ rw [Finset.sup_le_iff] intro T hT have hTk : T.card = k := (Finset.mem_filter.mp hT).2 refine le_trans (MvPolynomial.totalDegree_mul _ _) ?_ rw [MvPolynomial.totalDegree_C, zero_add, ← hTk] exact totalDegree_mon01_le T -- Compute `toMultilinear01 (qTop * (linSum n - C β)) S` for `|S| ≥ k + 1`! have hqTop_ml : ∀ T : Finset (Fin n), toMultilinear01 qTop T = if T.card = k then w T else 0 := by intro T dsimp only [qTop] rw [toMultilinear01_finset_sum] by_cases hTk : T.card = k · rw [if_pos hTk, Finset.sum_eq_single T] · rw [← MvPolynomial.smul_eq_C_mul, toMultilinear01_smul, toMultilinear01_mon01, if_pos rfl, mul_one] · intro T' _ hne rw [← MvPolynomial.smul_eq_C_mul, toMultilinear01_smul, toMultilinear01_mon01, if_neg hne, mul_zero] · intro h; exact absurd (Finset.mem_filter.mpr ⟨Finset.mem_univ T, hTk⟩) h · rw [if_neg hTk] apply Finset.sum_eq_zero; intro T' hT' have hne : T' ≠ T := fun h => hTk (h ▸ (Finset.mem_filter.mp hT').2) rw [← MvPolynomial.smul_eq_C_mul, toMultilinear01_smul, toMultilinear01_mon01, if_neg hne, mul_zero] have hmul_top : ∀ S : Finset (Fin n), k + 1 ≤ S.card → toMultilinear01 (qTop * (linSum n - MvPolynomial.C β)) S = if S.card = k + 1 then ∑ i ∈ S, w (S.erase i) else 0 := by intro S hSge rw [toMultilinear01_mul] -- Compute `toMultilinear01 (linSum n - C β) C`. have hlin : ∀ C : Finset (Fin n), toMultilinear01 (linSum n - MvPolynomial.C β) C = (∑ i : Fin n, if ({i} : Finset (Fin n)) = C then (1 : ℝ) else 0) - (if C = ∅ then β else 0) := by intro C rw [toMultilinear01_sub, linSum, toMultilinear01_finset_sum] congr 1 · apply Finset.sum_congr rfl; intro i _ have hX : (MvPolynomial.X i : MvPolynomial (Fin n) ℝ) = mon01 {i} := by simp [mon01] rw [hX, toMultilinear01_mon01] · rw [MvPolynomial.C_apply, toMultilinear01_monomial, Finsupp.support_zero] by_cases hC : C = ∅ <;> simp [hC, eq_comm] by_cases hSeq : S.card = k + 1 · rw [if_pos hSeq] -- Only pairs `(B, C)` with `|B| = k`, `C = {i}` (`i ∈ S`, `B = S.erase i`) contribute! have hinner : ∀ B : Finset (Fin n), ∑ C : Finset (Fin n), (if B ∪ C = S then toMultilinear01 qTop B * toMultilinear01 (linSum n - MvPolynomial.C β) C else 0) = if ∃ i ∈ S, B = S.erase i then w B else 0 := by intro B rw [hqTop_ml] by_cases hBk : B.card = k · rw [if_pos hBk] by_cases hex : ∃ i ∈ S, B = S.erase i · rw [if_pos hex] rcases hex with ⟨i0, hi0S, rfl⟩ -- Which `C` satisfy `S.erase i0 ∪ C = S` AND `toMultilinear01 (linSum - C β) C ≠ 0`? -- `C = ∅` fails since `S.erase i0 ≠ S`; `C = {i}` satisfies `S.erase i0 ∪ {i} = S` iff `i = i0`! rw [Finset.sum_eq_single ({i0} : Finset (Fin n))] · have hunion : S.erase i0 ∪ {i0} = S := by ext x; simp only [Finset.mem_union, Finset.mem_erase, Finset.mem_singleton] by_cases hx : x = i0 · subst hx; simp [hi0S] · simp [hx] rw [if_pos hunion, hlin] have hne0 : ({i0} : Finset (Fin n)) ≠ ∅ := Finset.singleton_ne_empty i0 rw [if_neg hne0, sub_zero, Finset.sum_eq_single i0] · simp · intro j _ hne; rw [if_neg (fun h => hne (Finset.singleton_injective h))] · intro h; exact absurd (Finset.mem_univ _) h · intro C _ hneC by_cases hu : S.erase i0 ∪ C = S · rw [if_pos hu, hlin] have hCne0 : C ≠ ∅ := by intro h0; rw [h0, Finset.union_empty] at hu have : i0 ∈ S.erase i0 := hu.symm ▸ hi0S exact (Finset.notMem_erase i0 S) this rw [if_neg hCne0, sub_zero] have hsum0 : ∑ i : Fin n, (if ({i} : Finset (Fin n)) = C then (1 : ℝ) else 0) = 0 := by apply Finset.sum_eq_zero; intro i _ rw [if_neg]; intro hCeq have : i0 ∈ S.erase i0 ∪ C := hu.symm ▸ hi0S rw [← hCeq, Finset.mem_union, Finset.mem_singleton] at this rcases this with h1 | rfl · exact (Finset.notMem_erase i0 S) h1 · exact hneC hCeq.symm rw [hsum0, mul_zero] · rw [if_neg hu] · intro h; exact absurd (Finset.mem_univ _) h · rw [if_neg hex] apply Finset.sum_eq_zero; intro C _ by_cases hu : B ∪ C = S · rw [if_pos hu, hlin] have hCne0 : C ≠ ∅ := by intro h0; rw [h0, Finset.union_empty] at hu have := congrArg Finset.card hu; omega rw [if_neg hCne0, sub_zero] have hsum0 : ∑ i : Fin n, (if ({i} : Finset (Fin n)) = C then (1 : ℝ) else 0) = 0 := by apply Finset.sum_eq_zero; intro i _ rw [if_neg]; intro hCeq apply hex have hiS : i ∈ S := hu ▸ Finset.mem_union_right B (hCeq ▸ Finset.mem_singleton_self i) have hiB : i ∉ B := by intro hiB have : B ∪ C = B := by rw [← hCeq, Finset.union_eq_left.mpr (Finset.singleton_subset_iff.mpr hiB)] rw [this] at hu have := congrArg Finset.card hu; omega refine ⟨i, hiS, ?_⟩ ext x; simp only [Finset.mem_erase] rw [← hu, ← hCeq, Finset.mem_union, Finset.mem_singleton] by_cases hx : x = i · subst hx; simp [hiB] · simp [hx] rw [hsum0, mul_zero] · rw [if_neg hu] · rw [if_neg hBk] have hnotex : ¬ ∃ i ∈ S, B = S.erase i := by rintro ⟨i, hiS, rfl⟩ rw [Finset.card_erase_of_mem hiS] at hBk; omega rw [if_neg hnotex] apply Finset.sum_eq_zero; intro C _; simp simp_rw [hinner] rw [← Finset.sum_filter] refine (Finset.sum_bij (fun i _ => S.erase i) ?_ ?_ ?_ (fun _ _ => rfl)).symm · intro i hi; exact Finset.mem_filter.mpr ⟨Finset.mem_univ _, ⟨i, hi, rfl⟩⟩ · intro i₁ hi₁ i₂ hi₂ heq by_contra hne have : i₁ ∈ S.erase i₂ := Finset.mem_erase.mpr ⟨hne, hi₁⟩ rw [← heq] at this; exact (Finset.notMem_erase i₁ S) this · intro B hB rcases (Finset.mem_filter.mp hB).2 with ⟨i, hiS, rfl⟩ exact ⟨i, hiS, rfl⟩ · rw [if_neg hSeq] -- `S.card ≥ k + 2`, so no `(B, C)` with `|B| = k` and `|C| ≤ 1` can have `B ∪ C = S`! apply Finset.sum_eq_zero; intro B _ apply Finset.sum_eq_zero; intro C _ by_cases hu : B ∪ C = S · rw [if_pos hu, hqTop_ml] by_cases hBk : B.card = k · rw [if_pos hBk, hlin] have hC2 : 2 ≤ C.card := by have := Finset.card_union_le B C; rw [hu, hBk] at this; omega have hCne0 : C ≠ ∅ := by intro h; rw [h] at hC2; simp at hC2 rw [if_neg hCne0, sub_zero] have hsum0 : ∑ i : Fin n, (if ({i} : Finset (Fin n)) = C then (1 : ℝ) else 0) = 0 := by apply Finset.sum_eq_zero; intro i _ rw [if_neg]; intro hCeq; rw [← hCeq] at hC2; simp at hC2 rw [hsum0, mul_zero] · rw [if_neg hBk, zero_mul] · rw [if_neg hu] -- Residual `f' S := f S - hTop S - toMultilinear01 (qTop * (linSum - C β)) S` vanishes for `|S| > k`! let f' : Finset (Fin n) → ℝ := fun S => f S - hTop S - toMultilinear01 (qTop * (linSum n - MvPolynomial.C β)) S have hf'_supp : ∀ S, k < S.card → f' S = 0 := by intro S hSgt dsimp only [f'] rw [hmul_top S (by omega)] by_cases hSeq : S.card = k + 1 · rw [if_pos hSeq, hdecomp S hSeq]; ring · rw [if_neg hSeq, hf S (by omega), hhTop.1 S hSeq]; ring rcases ih f' hf'_supp with ⟨hLow, QLow, hhLow, hQLow_deg, hf'_eq⟩ -- Combine `hLow` (on `0..k`) with `hTop` (on `k + 1`) and `QLow + qTop`! let hAll : Fin (k + 2) → (Finset (Fin n) → ℝ) := fun j => if hj : j.1 < k + 1 then hLow ⟨j.1, hj⟩ else hTop refine ⟨hAll, QLow + qTop, ?_, ?_, ?_⟩ · intro j dsimp only [hAll] by_cases hj : j.1 < k + 1 · rw [dif_pos hj]; exact hhLow ⟨j.1, hj⟩ · rw [dif_neg hj, show j.1 = k + 1 by omega]; exact hhTop · right have hQL_le : QLow.totalDegree ≤ k := by rcases hQLow_deg with rfl | h · simp · omega have := le_trans (MvPolynomial.totalDegree_add QLow qTop) (max_le hQL_le hqTop_deg) omega · intro S have hsum_split : ∑ j : Fin (k + 2), hAll j S = (∑ j : Fin (k + 1), hLow j S) + hTop S := by rw [Fin.sum_univ_castSucc] congr 1 · apply Finset.sum_congr rfl; intro j _ dsimp only [hAll]; simp only [Fin.val_castSucc]; rw [dif_pos j.2] · dsimp only [hAll]; simp only [Fin.val_last]; rw [dif_neg (lt_irrefl (k + 1))] rw [hsum_split, add_mul, toMultilinear01_add] have h := hf'_eq S dsimp only [f'] at h linarith -- Step 2: Apply `hpeel d (toMultilinear01 p)`! rcases hpeel d (toMultilinear01 p) (fun S hS => by by_contra hne; have := le_trans (toMultilinear01_support_card_le hne) hp; omega) with ⟨h, Q, hh, hQ_deg, hp_eq⟩ refine ⟨h, hh, ?_⟩ -- Define `H_j := ∑ S, C (h j S) * mon01 S` and `H := ∑ j, H_j`. let HOf (j : Fin (d + 1)) : MvPolynomial (Fin n) ℝ := ∑ S : Finset (Fin n), MvPolynomial.C (h j S) * mon01 S let H : MvPolynomial (Fin n) ℝ := ∑ j : Fin (d + 1), HOf j have hHOf_ml : ∀ j S, toMultilinear01 (HOf j) S = h j S := by intro j S dsimp only [HOf] rw [toMultilinear01_finset_sum, Finset.sum_eq_single S] · rw [← MvPolynomial.smul_eq_C_mul, toMultilinear01_smul, toMultilinear01_mon01, if_pos rfl, mul_one] · intro S' _ hne rw [← MvPolynomial.smul_eq_C_mul, toMultilinear01_smul, toMultilinear01_mon01, if_neg hne, mul_zero] · intro hnot; exact absurd (Finset.mem_univ _) hnot have hH_ml : ∀ S, toMultilinear01 H S = ∑ j : Fin (d + 1), h j S := by intro S; dsimp only [H]; rw [toMultilinear01_finset_sum] apply Finset.sum_congr rfl; intro j _; exact hHOf_ml j S have hH_deg : H.totalDegree ≤ d := by dsimp only [H] refine le_trans (MvPolynomial.totalDegree_finsetSum _ _) ?_ rw [Finset.sup_le_iff]; intro j _ dsimp only [HOf] refine le_trans (MvPolynomial.totalDegree_finsetSum _ _) ?_ rw [Finset.sup_le_iff]; intro S _ by_cases hSc : S.card = j.1 · refine le_trans (MvPolynomial.totalDegree_mul _ _) ?_ rw [MvPolynomial.totalDegree_C, zero_add] exact le_trans (totalDegree_mon01_le S) (by omega) · rw [(hh j).1 S hSc, map_zero, zero_mul]; simp -- Notice `toMultilinear01 p = toMultilinear01 (H + Q * (linSum n - C β))`! have hp_ml_eq : ∀ S, toMultilinear01 p S = toMultilinear01 (H + Q * (linSum n - MvPolynomial.C β)) S := by intro S; rw [toMultilinear01_add, hH_ml]; exact hp_eq S -- Step 3: `knapsackPE n β (p^2) = knapsackPE n β (H^2)` because cross terms vanish! have hpe_eq : knapsackPE n β (p ^ 2) = knapsackPE n β (H ^ 2) := by have hp2_eq : knapsackPE n β (p ^ 2) = knapsackPE n β ((H + Q * (linSum n - MvPolynomial.C β)) ^ 2) := by unfold knapsackPE rw [sq, sq, knapsackPEF_mul_eq, knapsackPEF_mul_eq] apply Finset.sum_congr rfl; intro A _ apply Finset.sum_congr rfl; intro B _ rw [hp_ml_eq A, hp_ml_eq B] rw [hp2_eq] have hexp : (H + Q * (linSum n - MvPolynomial.C β)) ^ 2 = H ^ 2 + ((2 : MvPolynomial (Fin n) ℝ) * H * Q + Q * Q * (linSum n - MvPolynomial.C β)) * (linSum n - MvPolynomial.C β) := by ring rw [hexp] unfold knapsackPE rw [knapsackPEF_add] have hvan : knapsackPEF n β (((2 : MvPolynomial (Fin n) ℝ) * H * Q + Q * Q * (linSum n - MvPolynomial.C β)) * (linSum n - MvPolynomial.C β)) = 0 := by rcases hQ_deg with rfl | hQd · simp [knapsackPEF_zero] · apply knapsackPEF_mul_linSum_sub_C have hlin_deg : (linSum n - MvPolynomial.C β).totalDegree ≤ 1 := le_trans (MvPolynomial.totalDegree_sub _ _) (max_le (totalDegree_linSum_le n) (by simp)) have h2_deg : (2 : MvPolynomial (Fin n) ℝ).totalDegree = 0 := by rw [show (2 : MvPolynomial (Fin n) ℝ) = MvPolynomial.C 2 by rw [show (2 : ℝ) = 1 + 1 by norm_num, map_add, map_one]; ring] exact MvPolynomial.totalDegree_C 2 have ht1 : ((2 : MvPolynomial (Fin n) ℝ) * H * Q).totalDegree < n := by have h1 := MvPolynomial.totalDegree_mul ((2 : MvPolynomial (Fin n) ℝ) * H) Q have h2 := MvPolynomial.totalDegree_mul (2 : MvPolynomial (Fin n) ℝ) H omega have ht2 : (Q * Q * (linSum n - MvPolynomial.C β)).totalDegree < n := by have h1 := MvPolynomial.totalDegree_mul (Q * Q) (linSum n - MvPolynomial.C β) have h2 := MvPolynomial.totalDegree_mul Q Q omega exact lt_of_le_of_lt (MvPolynomial.totalDegree_add _ _) (max_lt ht1 ht2) rw [hvan, add_zero] -- Step 4: Expand `knapsackPE n β (H^2) = ∑_{j₁, j₂} knapsackPE (HOf j₁ * HOf j₂)`! rw [hpe_eq] unfold knapsackPE rw [sq, knapsackPEF_mul_eq] have hlhs_eq : ∑ A : Finset (Fin n), ∑ B : Finset (Fin n), toMultilinear01 H A * toMultilinear01 H B * (descFact β (A ∪ B).card / descFact (n : ℝ) (A ∪ B).card) = ∑ A : Finset (Fin n), ∑ B : Finset (Fin n), ∑ j₁ : Fin (d + 1), ∑ j₂ : Fin (d + 1), h j₁ A * h j₂ B * (descFact β (A ∪ B).card / descFact (n : ℝ) (A ∪ B).card) := by apply Finset.sum_congr rfl; intro A _ apply Finset.sum_congr rfl; intro B _ rw [hH_ml, hH_ml, Finset.sum_mul, Finset.sum_mul] apply Finset.sum_congr rfl; intro j₁ _ rw [Finset.mul_sum, Finset.sum_mul] rw [hlhs_eq] -- Swap sums to `∑ j₁, ∑ j₂, ∑ A, ∑ B, h j₁ A * h j₂ B * (β^{|A ∪ B|} / n^{|A ∪ B|})`. have hswap : ∑ A : Finset (Fin n), ∑ B : Finset (Fin n), ∑ j₁ : Fin (d + 1), ∑ j₂ : Fin (d + 1), h j₁ A * h j₂ B * (descFact β (A ∪ B).card / descFact (n : ℝ) (A ∪ B).card) = ∑ j₁ : Fin (d + 1), ∑ j₂ : Fin (d + 1), ∑ A : Finset (Fin n), ∑ B : Finset (Fin n), h j₁ A * h j₂ B * (descFact β (A ∪ B).card / descFact (n : ℝ) (A ∪ B).card) := by calc ∑ A, ∑ B, ∑ j₁, ∑ j₂, h j₁ A * h j₂ B * (descFact β (A ∪ B).card / descFact (n : ℝ) (A ∪ B).card) = ∑ A, ∑ j₁, ∑ B, ∑ j₂, h j₁ A * h j₂ B * (descFact β (A ∪ B).card / descFact (n : ℝ) (A ∪ B).card) := by apply Finset.sum_congr rfl; intro A _; exact Finset.sum_comm _ = ∑ j₁, ∑ A, ∑ B, ∑ j₂, h j₁ A * h j₂ B * (descFact β (A ∪ B).card / descFact (n : ℝ) (A ∪ B).card) := Finset.sum_comm _ = ∑ j₁, ∑ A, ∑ j₂, ∑ B, h j₁ A * h j₂ B * (descFact β (A ∪ B).card / descFact (n : ℝ) (A ∪ B).card) := by apply Finset.sum_congr rfl; intro j₁ _ apply Finset.sum_congr rfl; intro A _; exact Finset.sum_comm _ = ∑ j₁, ∑ j₂, ∑ A, ∑ B, h j₁ A * h j₂ B * (descFact β (A ∪ B).card / descFact (n : ℝ) (A ∪ B).card) := by apply Finset.sum_congr rfl; intro j₁ _; exact Finset.sum_comm have hrew : ∑ A : Finset (Fin n), ∑ B : Finset (Fin n), ∑ j₁ : Fin (d + 1), ∑ j₂ : Fin (d + 1), h j₁ A * h j₂ B * (descFact β (A ∪ B).card / descFact (n : ℝ) (A ∪ B).card) = ∑ j : Fin (d + 1), (descFact β j.1 * descFact ((n : ℝ) - β) j.1 / descFact (n : ℝ) (2 * j.1)) * ∑ S : Finset (Fin n), (h j S) ^ 2 := by rw [hswap] apply Finset.sum_congr rfl; intro j₁ _ rw [Finset.sum_eq_single j₁] · exact harmonic_pe_sq (hh j₁) β (by omega) · intro j₂ _ hne have hlt_or_gt : j₁.1 < j₂.1 ∨ j₂.1 < j₁.1 := Nat.lt_or_gt_of_ne (fun h => hne (Fin.ext h).symm) rcases hlt_or_gt with hlt | hgt · apply Finset.sum_eq_zero; intro A _ by_cases hA : A.card = j₁.1 · have hfactor : ∑ B : Finset (Fin n), h j₁ A * h j₂ B * (descFact β (A ∪ B).card / descFact (n : ℝ) (A ∪ B).card) = h j₁ A * ∑ B : Finset (Fin n), h j₂ B * (descFact β (B ∪ A).card / descFact (n : ℝ) (B ∪ A).card) := by rw [Finset.mul_sum] apply Finset.sum_congr rfl; intro B _; rw [Finset.union_comm, mul_assoc] rw [hfactor, harmonic_ortho_lower (hh j₂) β (by omega), mul_zero] · apply Finset.sum_eq_zero; intro B _; rw [(hh j₁).1 A hA, zero_mul, zero_mul] · rw [Finset.sum_comm] apply Finset.sum_eq_zero; intro B _ by_cases hB : B.card = j₂.1 · have hfactor : ∑ A : Finset (Fin n), h j₁ A * h j₂ B * (descFact β (A ∪ B).card / descFact (n : ℝ) (A ∪ B).card) = h j₂ B * ∑ A : Finset (Fin n), h j₁ A * (descFact β (A ∪ B).card / descFact (n : ℝ) (A ∪ B).card) := by rw [Finset.mul_sum] apply Finset.sum_congr rfl; intro A _; ring rw [hfactor, harmonic_ortho_lower (hh j₁) β (by omega), mul_zero] · apply Finset.sum_eq_zero; intro A _; rw [(hh j₂).1 B hB, mul_zero, zero_mul] · intro hnot; exact absurd (Finset.mem_univ _) hnot exact hrew /-- **Headline Theorem 4C (Exact Boolean Knapsack Sum-of-Squares Lower Bound):** For EVERY `n ≥ 2`, `k < n`, `β ∈ (k, k + 1)`, and EVERY `d ≤ min (min (k + 1) (n - k)) (n / 2)`, NO degree-`2d` Sum-of-Squares refutation of `knapsackAxioms n β` exists! -/ theorem knapsack_sos_exact_lower_bound {n k d : ℕ} (hn : 2 ≤ n) (hk : k < n) {β : ℝ} (hβ1 : (k : ℝ) < β) (hβ2 : β < (k : ℝ) + 1) (hd : d ≤ min (min (k + 1) (n - k)) (n / 2)) : ¬ SoSRefutes (knapsackAxioms n β) (2 * d) := by have hd_k1 : d ≤ k + 1 := le_trans hd (le_trans (min_le_left _ _) (min_le_left _ _)) have hd_nk : d ≤ n - k := le_trans hd (le_trans (min_le_left _ _) (min_le_right _ _)) have hd_n2 : 2 * d ≤ n := by have := le_trans hd (min_le_right _ _); omega rintro ⟨squares, idealTerms, hsq, hidt, heq⟩ have hpe := congrArg (knapsackPE n β) heq have hlhs : knapsackPE n β (-1) = -1 := by unfold knapsackPE rw [show (-1 : MvPolynomial (Fin n) ℝ) = (-1 : ℝ) • 1 by simp, knapsackPEF_smul, knapsackPEF_one]; ring have hrhs_sq : 0 ≤ knapsackPE n β (squares.map fun p => p ^ 2).sum := by unfold knapsackPE rw [knapsackPEF_list_sum] apply List.sum_nonneg intro x hx rw [List.mem_map] at hx rcases hx with ⟨_, hp_sq, rfl⟩ rw [List.mem_map] at hp_sq rcases hp_sq with ⟨p, hp, rfl⟩ have hp_deg : p.totalDegree ≤ d := by have := hsq p hp; omega rcases knapsack_harmonic_diagonalization hd_n2 β p hp_deg with ⟨h, _, hdiag⟩ change 0 ≤ knapsackPE n β (p ^ 2) rw [hdiag] apply Finset.sum_nonneg; intro j _ refine mul_nonneg ?_ (Finset.sum_nonneg fun _ _ => sq_nonneg _) have hj_d : j.1 ≤ d := Nat.lt_succ_iff.mp j.2 have hnum1 : 0 < descFact β j.1 := descFact_pos_of_nat_lt hβ1 (le_trans hj_d hd_k1) have hnum2 : 0 < descFact ((n : ℝ) - β) j.1 := descFact_sub_pos hβ2 (le_trans hj_d hd_nk) (le_of_lt hk) have hden : 0 < descFact (n : ℝ) (2 * j.1) := descFact_nat_pos_real (by omega) exact le_of_lt (div_pos (mul_pos hnum1 hnum2) hden) have hrhs_id : knapsackPE n β (idealTerms.map fun t => t.1 * t.2).sum = 0 := by unfold knapsackPE rw [knapsackPEF_list_sum] apply List.sum_eq_zero intro x hx rw [List.mem_map] at hx rcases hx with ⟨_, ht_id, rfl⟩ rw [List.mem_map] at ht_id rcases ht_id with ⟨t, ht, rfl⟩ rcases (hidt t ht).1 with ⟨i, hi⟩ | hlin · rw [hi]; exact knapsackPEF_mul_bool β t.1 i · rw [hlin] have hdeg := (hidt t ht).2 rw [hlin, totalDegree_linSum_sub_C (by omega)] at hdeg exact knapsackPEF_mul_linSum_sub_C β (by omega) have hadd : knapsackPE n β ((squares.map fun p => p ^ 2).sum + (idealTerms.map fun t => t.1 * t.2).sum) = knapsackPE n β (squares.map fun p => p ^ 2).sum + knapsackPE n β (idealTerms.map fun t => t.1 * t.2).sum := knapsackPEF_add β _ _ rw [hlhs, hadd, hrhs_id, add_zero] at hpe linarith end HarmonicDiagonalization -- ------------------------------------------------------------------------------ -- 4D. Closed-Form Matching SoS Refutations (All Regimes) & Nullstellensatz -- ------------------------------------------------------------------------------ section KnapsackUpperAndNS /-- Degree-bounded ideal membership over any field `F`. -/ def InIdealF {E : Type*} (F : Type*) [Field F] (axioms : Set (MvPolynomial E F)) (D : ℕ) (p : MvPolynomial E F) : Prop := ∃ idealTerms : List (MvPolynomial E F × MvPolynomial E F), (∀ t ∈ idealTerms, t.2 ∈ axioms ∧ t.1.totalDegree + t.2.totalDegree ≤ D) ∧ p = (idealTerms.map fun t => t.1 * t.2).sum lemma inIdealF_zero {E F : Type*} [Field F] {axioms : Set (MvPolynomial E F)} {D : ℕ} : InIdealF F axioms D 0 := ⟨[], fun _ h => by simp at h, by simp⟩ lemma inIdealF_mono {E F : Type*} [Field F] {axioms : Set (MvPolynomial E F)} {D₁ D₂ : ℕ} (hD : D₁ ≤ D₂) {p : MvPolynomial E F} (h : InIdealF F axioms D₁ p) : InIdealF F axioms D₂ p := by rcases h with ⟨L, hL, heq⟩ exact ⟨L, fun t ht => ⟨(hL t ht).1, le_trans (hL t ht).2 hD⟩, heq⟩ lemma inIdealF_subset {E F : Type*} [Field F] {A₁ A₂ : Set (MvPolynomial E F)} (hA : A₁ ⊆ A₂) {D : ℕ} {p : MvPolynomial E F} (h : InIdealF F A₁ D p) : InIdealF F A₂ D p := by rcases h with ⟨L, hL, heq⟩ exact ⟨L, fun t ht => ⟨hA (hL t ht).1, (hL t ht).2⟩, heq⟩ lemma inIdealF_add {E F : Type*} [Field F] {axioms : Set (MvPolynomial E F)} {D : ℕ} {p q : MvPolynomial E F} (hp : InIdealF F axioms D p) (hq : InIdealF F axioms D q) : InIdealF F axioms D (p + q) := by rcases hp with ⟨L₁, hL₁, rfl⟩ rcases hq with ⟨L₂, hL₂, rfl⟩ refine ⟨L₁ ++ L₂, fun t ht => ?_, by simp [List.map_append, List.sum_append]⟩ rcases List.mem_append.mp ht with h1 | h2 · exact hL₁ t h1 · exact hL₂ t h2 lemma inIdealF_mul_left {E F : Type*} [Field F] {axioms : Set (MvPolynomial E F)} {D₁ D₂ : ℕ} (q : MvPolynomial E F) {p : MvPolynomial E F} (hp : InIdealF F axioms D₁ p) (hdeg : q.totalDegree + D₁ ≤ D₂) : InIdealF F axioms D₂ (q * p) := by rcases hp with ⟨L, hL, rfl⟩ refine ⟨L.map fun t => (q * t.1, t.2), ?_, ?_⟩ · intro t ht rcases List.mem_map.mp ht with ⟨t0, ht0, rfl⟩ refine ⟨(hL t0 ht0).1, ?_⟩ dsimp only have hmul := MvPolynomial.totalDegree_mul q t0.1 have h0 := (hL t0 ht0).2 omega · rw [List.map_map] induction L with | nil => simp | cons a l ih => simp only [List.map_cons, List.sum_cons, Function.comp_apply, mul_add] rw [← mul_assoc, ih (fun t ht => hL t (List.mem_cons_of_mem a ht))] lemma inIdealF_C_mul {E F : Type*} [Field F] {axioms : Set (MvPolynomial E F)} {D : ℕ} (c : F) {p : MvPolynomial E F} (hp : InIdealF F axioms D p) : InIdealF F axioms D (MvPolynomial.C c * p) := inIdealF_mul_left (MvPolynomial.C c) hp (by simp) lemma inIdealF_neg {E F : Type*} [Field F] {axioms : Set (MvPolynomial E F)} {D : ℕ} {p : MvPolynomial E F} (hp : InIdealF F axioms D p) : InIdealF F axioms D (-p) := by have : -p = MvPolynomial.C (-1 : F) * p := by rw [map_neg, map_one]; ring rw [this]; exact inIdealF_C_mul (-1) hp lemma inIdealF_sub {E F : Type*} [Field F] {axioms : Set (MvPolynomial E F)} {D : ℕ} {p q : MvPolynomial E F} (hp : InIdealF F axioms D p) (hq : InIdealF F axioms D q) : InIdealF F axioms D (p - q) := by rw [sub_eq_add_neg]; exact inIdealF_add hp (inIdealF_neg hq) lemma inIdealF_ax {E F : Type*} [Field F] {axioms : Set (MvPolynomial E F)} {D : ℕ} {q g : MvPolynomial E F} (hg : g ∈ axioms) (hd : q.totalDegree + g.totalDegree ≤ D) : InIdealF F axioms D (q * g) := ⟨[(q, g)], fun t ht => by simp at ht; subst ht; exact ⟨hg, hd⟩, by simp⟩ lemma inIdealF_finset_sum {ι E F : Type*} [Field F] {axioms : Set (MvPolynomial E F)} {D : ℕ} (s : Finset ι) (f : ι → MvPolynomial E F) (hf : ∀ i ∈ s, InIdealF F axioms D (f i)) : InIdealF F axioms D (∑ i ∈ s, f i) := by classical induction s using Finset.induction with | empty => simpa using inIdealF_zero | @insert a s' ha ih => rw [Finset.sum_insert ha] exact inIdealF_add (hf a (Finset.mem_insert_self a s')) (ih fun i hi => hf i (Finset.mem_insert_of_mem hi)) /-- Boolean axioms `{X_i^2 - X_i : i ∈ Fin n}` over any field `F`. -/ def boolAxiomsF (n : ℕ) (F : Type*) [Field F] : Set (MvPolynomial (Fin n) F) := { p | ∃ i : Fin n, p = (MvPolynomial.X i) ^ 2 - MvPolynomial.X i } lemma totalDegree_X_sq_sub_X_le {n : ℕ} {F : Type*} [Field F] (i : Fin n) : ((MvPolynomial.X i : MvPolynomial (Fin n) F) ^ 2 - MvPolynomial.X i).totalDegree ≤ 2 := by refine le_trans (MvPolynomial.totalDegree_sub _ _) (max_le ?_ (le_trans (mvTotalDegree_X_le i) (by omega))) have h1 := MvPolynomial.totalDegree_pow (MvPolynomial.X i : MvPolynomial (Fin n) F) 2 have h2 := mvTotalDegree_X_le (R := F) i omega /-- Elementary symmetric polynomial `e_r(X) = ∑_{|S|=r} ∏_{i ∈ S} X_i`. -/ noncomputable def elemSymm (n : ℕ) {F : Type*} [Field F] (r : ℕ) : MvPolynomial (Fin n) F := ∑ S ∈ (Finset.univ : Finset (Fin n)).powersetCard r, mon01 S /-- Falling-factorial polynomial `s^{⌊r⌋} = ∏_{t=0}^{r-1} (s - t)`. -/ noncomputable def fallingPoly {n : ℕ} {F : Type*} [Field F] (s : MvPolynomial (Fin n) F) : ℕ → MvPolynomial (Fin n) F | 0 => 1 | r + 1 => fallingPoly s r * (s - MvPolynomial.C (r : F)) lemma totalDegree_fallingPoly_le {n : ℕ} {F : Type*} [Field F] {s : MvPolynomial (Fin n) F} (hs : s.totalDegree ≤ 1) (r : ℕ) : (fallingPoly s r).totalDegree ≤ r := by induction r with | zero => simp [fallingPoly] | succ r ih => rw [fallingPoly] have hsub : (s - MvPolynomial.C (r : F)).totalDegree ≤ 1 := le_trans (MvPolynomial.totalDegree_sub _ _) (max_le hs (by rw [MvPolynomial.totalDegree_C]; exact Nat.zero_le 1)) have hmul := MvPolynomial.totalDegree_mul (fallingPoly s r) (s - MvPolynomial.C (r : F)) omega /-- Fundamental Boolean-cube identity: for ALL `n, r : ℕ` and any field `F`, `fallingPoly (linSum n) r - r! * elemSymm n r ∈ InIdealF F (boolAxiomsF n F) r`! -/ lemma fallingPoly_sub_elemSymm_inIdeal {n : ℕ} {F : Type*} [Field F] (r : ℕ) : InIdealF F (boolAxiomsF n F) r (fallingPoly (linSum n) r - MvPolynomial.C (Nat.factorial r : F) * elemSymm n r) := by classical induction r with | zero => have h0 : elemSymm n (F := F) 0 = 1 := by unfold elemSymm rw [Finset.powersetCard_zero, Finset.sum_singleton]; simp [mon01] rw [fallingPoly, h0]; simp [inIdealF_zero] | succ r ih => have hstep : fallingPoly (linSum n) (r + 1) - MvPolynomial.C (Nat.factorial (r + 1) : F) * elemSymm n (r + 1) = (linSum n - MvPolynomial.C (r : F)) * (fallingPoly (linSum n) r - MvPolynomial.C (Nat.factorial r : F) * elemSymm n r) + MvPolynomial.C (Nat.factorial r : F) * (elemSymm n r * (linSum n - MvPolynomial.C (r : F)) - MvPolynomial.C ((r + 1 : ℕ) : F) * elemSymm n (r + 1)) := by rw [fallingPoly, Nat.factorial_succ, Nat.cast_mul, map_mul]; ring rw [hstep] refine inIdealF_add ?_ (inIdealF_C_mul _ ?_) · refine inIdealF_mul_left (linSum n - MvPolynomial.C (r : F)) ih ?_ have hsub : (linSum n - MvPolynomial.C (r : F)).totalDegree ≤ 1 := le_trans (MvPolynomial.totalDegree_sub _ _) (max_le (totalDegree_linSum_le n) (by rw [MvPolynomial.totalDegree_C]; exact Nat.zero_le 1)) omega · -- Show `elemSymm n r * (linSum n - C r) - C (r + 1) * elemSymm n (r + 1)` is a sum of -- `mon01 (S.erase i) * (X_i^2 - X_i)` over `|S| = r, i ∈ S`, each of degree `≤ r + 1`! have hexpand : elemSymm n r * (linSum n - MvPolynomial.C (r : F)) - MvPolynomial.C ((r + 1 : ℕ) : F) * elemSymm n (r + 1) = ∑ S ∈ (Finset.univ : Finset (Fin n)).powersetCard r, ∑ i ∈ S, mon01 (S.erase i) * ((MvPolynomial.X i) ^ 2 - MvPolynomial.X i) := by -- Expand `elemSymm n r * linSum n = ∑_{|S|=r} (∑_{i ∈ S} mon01 S * X_i + ∑_{i ∉ S} mon01 (insert i S))`. have h1 : elemSymm n r * linSum n = (∑ S ∈ (Finset.univ : Finset (Fin n)).powersetCard r, ∑ i ∈ S, mon01 (S.erase i) * ((MvPolynomial.X i) ^ 2 - MvPolynomial.X i)) + MvPolynomial.C (r : F) * elemSymm n r + MvPolynomial.C ((r + 1 : ℕ) : F) * elemSymm n (r + 1) := by unfold elemSymm linSum rw [Finset.sum_mul] have hsplit : ∀ S ∈ (Finset.univ : Finset (Fin n)).powersetCard r, mon01 S * ∑ i : Fin n, MvPolynomial.X i = (∑ i ∈ S, mon01 (S.erase i) * ((MvPolynomial.X i) ^ 2 - MvPolynomial.X i)) + MvPolynomial.C (r : F) * mon01 S + ∑ i ∈ Sᶜ, mon01 (insert i S) := by intro S hS have hScard : S.card = r := (Finset.mem_powersetCard.mp hS).2 rw [Finset.mul_sum, ← Finset.sum_add_sum_compl S] have hin : ∑ i ∈ S, mon01 S * MvPolynomial.X i = (∑ i ∈ S, mon01 (S.erase i) * ((MvPolynomial.X i) ^ 2 - MvPolynomial.X i)) + MvPolynomial.C (r : F) * mon01 S := by have hterm : ∀ i ∈ S, mon01 (R := F) S * MvPolynomial.X i = mon01 (S.erase i) * ((MvPolynomial.X i) ^ 2 - MvPolynomial.X i) + mon01 S := by intro i hi have hfac : mon01 (R := F) S = mon01 (S.erase i) * MvPolynomial.X i := by unfold mon01 rw [← Finset.prod_erase_mul S _ hi] rw [hfac]; ring rw [Finset.sum_congr rfl hterm, Finset.sum_add_distrib, Finset.sum_const, hScard, nsmul_eq_mul, ← map_natCast MvPolynomial.C] have hout : ∑ i ∈ Sᶜ, mon01 (R := F) S * MvPolynomial.X i = ∑ i ∈ Sᶜ, mon01 (insert i S) := by apply Finset.sum_congr rfl; intro i hi unfold mon01 rw [Finset.prod_insert (Finset.mem_compl.mp hi), mul_comm] rw [hin, hout] rw [Finset.sum_congr rfl hsplit, Finset.sum_add_distrib, Finset.sum_add_distrib, ← Finset.mul_sum] congr 1 -- Double count `∑_{|S|=r} ∑_{i ∈ Sᶜ} mon01 (insert i S) = (r + 1) * ∑_{|T|=r+1} mon01 T`! have hdc : ∑ S ∈ (Finset.univ : Finset (Fin n)).powersetCard r, ∑ i ∈ Sᶜ, mon01 (R := F) (insert i S) = ∑ T ∈ (Finset.univ : Finset (Fin n)).powersetCard (r + 1), ∑ _i ∈ T, mon01 (R := F) T := by -- Bijection `(S, i)` with `|S|=r, i ∉ S` ↔ `(T, i)` with `|T|=r+1, i ∈ T` via `T = insert i S, S = T.erase i`! rw [Finset.sum_sigma', Finset.sum_sigma'] refine Finset.sum_bij (fun p _ => ⟨insert p.2 p.1, p.2⟩) ?_ ?_ ?_ (fun _ _ => rfl) · rintro ⟨S, i⟩ hp simp only [Finset.mem_sigma, Finset.mem_powersetCard, Finset.subset_univ, true_and, Finset.mem_compl] at hp ⊢ exact ⟨by rw [Finset.card_insert_of_notMem hp.2, hp.1], Finset.mem_insert_self i S⟩ · rintro ⟨S₁, i₁⟩ h1 ⟨S₂, i₂⟩ h2 heq simp only [Sigma.mk.inj_iff] at heq rcases heq with ⟨hins, hi_eq⟩ have hi_eq' : i₁ = i₂ := eq_of_heq hi_eq subst hi_eq' simp only [Finset.mem_sigma, Finset.mem_compl] at h1 h2 have hS : S₁ = S₂ := by have := congrArg (fun X => X.erase i₁) hins simpa [Finset.erase_insert h1.2, Finset.erase_insert h2.2] using this subst hS; rfl · rintro ⟨T, i⟩ hp simp only [Finset.mem_sigma, Finset.mem_powersetCard, Finset.subset_univ, true_and] at hp refine ⟨⟨T.erase i, i⟩, ?_, ?_⟩ · simp only [Finset.mem_sigma, Finset.mem_powersetCard, Finset.subset_univ, true_and, Finset.mem_compl] exact ⟨by rw [Finset.card_erase_of_mem hp.2, hp.1]; exact Nat.add_sub_cancel r 1, Finset.notMem_erase i T⟩ · simp [Finset.insert_erase hp.2] rw [hdc, Finset.mul_sum] apply Finset.sum_congr rfl; intro T hT rw [Finset.sum_const, (Finset.mem_powersetCard.mp hT).2, nsmul_eq_mul, ← map_natCast MvPolynomial.C] calc elemSymm n r * (linSum n - MvPolynomial.C (r : F)) - MvPolynomial.C ((r + 1 : ℕ) : F) * elemSymm n (r + 1) = elemSymm n r * linSum n - MvPolynomial.C (r : F) * elemSymm n r - MvPolynomial.C ((r + 1 : ℕ) : F) * elemSymm n (r + 1) := by ring _ = ∑ S ∈ (Finset.univ : Finset (Fin n)).powersetCard r, ∑ i ∈ S, mon01 (S.erase i) * ((MvPolynomial.X i) ^ 2 - MvPolynomial.X i) := by rw [h1]; ring rw [hexpand] refine inIdealF_finset_sum _ _ fun S hS => inIdealF_finset_sum _ _ fun i hi => ?_ refine inIdealF_ax ⟨i, rfl⟩ ?_ have hSc : S.card = r := (Finset.mem_powersetCard.mp hS).2 have h1 := totalDegree_mon01_le (R := F) (S.erase i) have h2 := totalDegree_X_sq_sub_X_le (F := F) i have h3 : (S.erase i).card = r - 1 := by rw [Finset.card_erase_of_mem hi, hSc] have hr1 : 1 ≤ r := by have := Finset.card_pos.mpr ⟨i, hi⟩; omega omega /-- Exact polynomial division of `fallingPoly s r - C (descFact β r)` by `(s - C β)` in degree `r`! -/ lemma fallingPoly_sub_descFact_inIdeal {n : ℕ} {F : Type*} [Field F] (β : F) (r : ℕ) : InIdealF F (knapsackAxiomsF n β) r (fallingPoly (linSum n) r - MvPolynomial.C (descFact β r)) := by induction r with | zero => simp [fallingPoly, descFact, inIdealF_zero] | succ r ih => have hstep : fallingPoly (linSum n) (r + 1) - MvPolynomial.C (descFact β (r + 1)) = (linSum n - MvPolynomial.C (r : F)) * (fallingPoly (linSum n) r - MvPolynomial.C (descFact β r)) + MvPolynomial.C (descFact β r) * (linSum n - MvPolynomial.C β) := by rw [fallingPoly, descFact_succ, map_mul, map_sub]; ring rw [hstep] refine inIdealF_add ?_ ?_ · refine inIdealF_mul_left (linSum n - MvPolynomial.C (r : F)) ih ?_ have hsub : (linSum n - MvPolynomial.C (r : F)).totalDegree ≤ 1 := le_trans (MvPolynomial.totalDegree_sub _ _) (max_le (totalDegree_linSum_le n) (by rw [MvPolynomial.totalDegree_C]; exact Nat.zero_le 1)) omega · refine inIdealF_ax (Or.inr rfl) ?_ have hsub : (linSum n - MvPolynomial.C β).totalDegree ≤ 1 := le_trans (MvPolynomial.totalDegree_sub _ _) (max_le (totalDegree_linSum_le n) (by simp)) rw [MvPolynomial.totalDegree_C, zero_add]; omega /-- **Headline Theorem 4F (Exact Boolean Knapsack Nullstellensatz Degree = `n + 1`):** Over ANY field `F` of characteristic `0`, for EVERY `n ≥ 1` and EVERY `β : F` with `∀ t ≤ n, β ≠ (t : F)`: `NSRefutes F (knapsackAxiomsF n β) D ↔ n + 1 ≤ D`! -/ theorem knapsack_nullstellensatz_exact_degree {n D : ℕ} (hn : 1 ≤ n) {F : Type*} [Field F] [CharZero F] {β : F} (hβ : ∀ t ≤ n, β ≠ (t : F)) : NSRefutes F (knapsackAxiomsF n β) D ↔ n + 1 ≤ D := by constructor · -- Lower bound: if `D ≤ n`, `knapsackPEF n β` annihilates every ideal term, giving `1 = 0`! intro ⟨idt, hidt, heq⟩ by_contra hlt have hDn : D ≤ n := by omega have hpe := congrArg (knapsackPEF n β) heq rw [knapsackPEF_one, knapsackPEF_list_sum] at hpe have hzero : ((idt.map fun t => t.1 * t.2).map (knapsackPEF n β)).sum = 0 := by apply List.sum_eq_zero intro x hx rw [List.mem_map] at hx rcases hx with ⟨_, ht_id, rfl⟩ rw [List.mem_map] at ht_id rcases ht_id with ⟨t, ht, rfl⟩ rcases (hidt t ht).1 with ⟨i, hi⟩ | hlin · rw [hi]; exact knapsackPEF_mul_bool β t.1 i · rw [hlin] have hdeg := (hidt t ht).2 rw [hlin, totalDegree_linSum_sub_C hn] at hdeg exact knapsackPEF_mul_linSum_sub_C β (by omega) rw [hzero] at hpe exact one_ne_zero hpe · -- Upper bound: `fallingPoly (linSum n) (n + 1) = 0` mod bool axioms, `= descFact β (n + 1) ≠ 0` mod `s - β`! intro hD refine nsRefutes_mono hD ?_ have he0 : elemSymm n (F := F) (n + 1) = 0 := by unfold elemSymm have : (Finset.univ : Finset (Fin n)).powersetCard (n + 1) = ∅ := Finset.powersetCard_eq_empty.mpr (by simp) rw [this, Finset.sum_empty] have hbool : InIdealF F (knapsackAxiomsF n β) (n + 1) (fallingPoly (linSum n) (n + 1)) := by have h := fallingPoly_sub_elemSymm_inIdeal (n := n) (F := F) (n + 1) rw [he0, mul_zero, sub_zero] at h exact inIdealF_subset (fun p hp => Or.inl hp) h have hdiv := fallingPoly_sub_descFact_inIdeal (n := n) (F := F) β (n + 1) have hconst : InIdealF F (knapsackAxiomsF n β) (n + 1) (MvPolynomial.C (descFact β (n + 1))) := by have heq : MvPolynomial.C (descFact β (n + 1)) = fallingPoly (linSum n) (n + 1) - (fallingPoly (linSum n) (n + 1) - MvPolynomial.C (descFact β (n + 1))) := by ring rw [heq]; exact inIdealF_sub hbool hdiv have hne : descFact β (n + 1) ≠ 0 := by have hgen : ∀ m ≤ n + 1, descFact β m ≠ 0 := by intro m induction m with | zero => intro _; simp [descFact] | succ m ih => intro hm rw [descFact_succ] exact mul_ne_zero (ih (by omega)) (sub_ne_zero.mpr (hβ m (by omega))) exact hgen (n + 1) (le_refl _) have h1 : InIdealF F (knapsackAxiomsF n β) (n + 1) 1 := by have heq : (1 : MvPolynomial (Fin n) F) = MvPolynomial.C (descFact β (n + 1))⁻¹ * MvPolynomial.C (descFact β (n + 1)) := by rw [← map_mul, inv_mul_cancel₀ hne, map_one] rw [heq]; exact inIdealF_C_mul _ hconst rcases h1 with ⟨L, hL, hLeq⟩ exact ⟨L, hL, hLeq⟩ /-- Every Boolean monomial satisfies `(mon01 S)^2 - mon01 S ∈ InIdealF ℝ (boolAxiomsF n ℝ) (2 * |S|)`. -/ lemma mon01_sq_sub_mon01_inIdeal {n : ℕ} (S : Finset (Fin n)) : InIdealF ℝ (boolAxiomsF n ℝ) (2 * S.card) ((mon01 S) ^ 2 - mon01 S) := by classical induction S using Finset.induction with | empty => simp [mon01, inIdealF_zero] | @insert a S' ha ih => rw [Finset.card_insert_of_notMem ha] have hprod : mon01 (R := ℝ) (insert a S') = MvPolynomial.X a * mon01 S' := by unfold mon01; exact Finset.prod_insert ha rw [hprod] have hrew : (MvPolynomial.X a * mon01 (R := ℝ) S') ^ 2 - MvPolynomial.X a * mon01 (R := ℝ) S' = (mon01 (R := ℝ) S') ^ 2 * ((MvPolynomial.X a) ^ 2 - MvPolynomial.X a) + MvPolynomial.X a * ((mon01 (R := ℝ) S') ^ 2 - mon01 (R := ℝ) S') := by ring rw [hrew] refine inIdealF_add ?_ ?_ · refine inIdealF_ax ⟨a, rfl⟩ ?_ have h1 := MvPolynomial.totalDegree_pow (mon01 (R := ℝ) S') 2 have h2 := totalDegree_mon01_le (R := ℝ) S' have h3 := totalDegree_X_sq_sub_X_le (F := ℝ) a omega · refine inIdealF_mul_left (MvPolynomial.X a) ih ?_ have hX := mvTotalDegree_X_le (R := ℝ) a omega /-- Exact degree-preserving involution `X_i ↦ 1 - X_i` on `MvPolynomial (Fin n) ℝ` for Regime 2. -/ noncomputable def flipBool01 (n : ℕ) : MvPolynomial (Fin n) ℝ →ₐ[ℝ] MvPolynomial (Fin n) ℝ := MvPolynomial.aeval fun i => (1 : MvPolynomial (Fin n) ℝ) - MvPolynomial.X i lemma flipBool01_totalDegree_le (n : ℕ) (p : MvPolynomial (Fin n) ℝ) : (flipBool01 n p).totalDegree ≤ p.totalDegree := by apply totalDegree_aeval_linear_le intro i exact le_trans (MvPolynomial.totalDegree_sub _ _) (max_le (by simp) (mvTotalDegree_X_le i)) lemma sosRefutes_flipBool01 {n D : ℕ} {β : ℝ} (h : SoSRefutes (knapsackAxioms n ((n : ℝ) - β)) D) : SoSRefutes (knapsackAxioms n β) D := by rcases h with ⟨sq, idt, hsq, hidt, heq⟩ -- For each ideal term `(q, g)`, transform it via `flipBool01 n`! let flipTerm : MvPolynomial (Fin n) ℝ × MvPolynomial (Fin n) ℝ → MvPolynomial (Fin n) ℝ × MvPolynomial (Fin n) ℝ := fun t => if t.2 = linSum n - MvPolynomial.C ((n : ℝ) - β) then (-(flipBool01 n t.1), linSum n - MvPolynomial.C β) else (flipBool01 n t.1, flipBool01 n t.2) have hflip_bool : ∀ i : Fin n, flipBool01 n ((MvPolynomial.X i) ^ 2 - MvPolynomial.X i) = (MvPolynomial.X i) ^ 2 - MvPolynomial.X i := by intro i; simp only [flipBool01, map_sub, map_pow, MvPolynomial.aeval_X]; ring have hflip_lin : flipBool01 n (linSum n - MvPolynomial.C ((n : ℝ) - β)) = -(linSum n - MvPolynomial.C β) := by unfold flipBool01 linSum rw [map_sub, map_sum, MvPolynomial.aeval_C, MvPolynomial.algebraMap_eq] simp_rw [MvPolynomial.aeval_X] rw [Finset.sum_sub_distrib, Finset.sum_const, Finset.card_univ, Fintype.card_fin, nsmul_eq_mul, mul_one, map_sub, map_natCast] ring refine ⟨sq.map (flipBool01 n), idt.map flipTerm, ?_, ?_, ?_⟩ · intro p hp rcases List.mem_map.mp hp with ⟨p0, hp0, rfl⟩ have h1 := flipBool01_totalDegree_le n p0 have h2 := hsq p0 hp0 omega · intro t ht rcases List.mem_map.mp ht with ⟨t0, ht0, rfl⟩ dsimp only [flipTerm] by_cases hlin : t0.2 = linSum n - MvPolynomial.C ((n : ℝ) - β) · rw [if_pos hlin] refine ⟨Or.inr rfl, ?_⟩ dsimp only have hdeg := (hidt t0 ht0).2 rw [hlin] at hdeg have h1 := flipBool01_totalDegree_le n t0.1 rw [MvPolynomial.totalDegree_neg] have hdeg_lin : (linSum n - MvPolynomial.C β).totalDegree = (linSum n - MvPolynomial.C ((n : ℝ) - β)).totalDegree := by by_cases hn0 : n = 0 · subst hn0; simp [linSum] · rw [totalDegree_linSum_sub_C (by omega), totalDegree_linSum_sub_C (by omega)] omega · rw [if_neg hlin] rcases (hidt t0 ht0).1 with ⟨i, hi⟩ | hcontra · rw [hi, hflip_bool i] refine ⟨Or.inl ⟨i, rfl⟩, ?_⟩ dsimp only have h1 := flipBool01_totalDegree_le n t0.1 have h2 := (hidt t0 ht0).2 rw [hi] at h2 omega · exact absurd hcontra hlin · have hmap := congrArg (flipBool01 n) heq rw [map_neg, map_one, map_add] at hmap rw [hmap] have hmap_sq : ∀ L : List (MvPolynomial (Fin n) ℝ), flipBool01 n (L.map fun p => p ^ 2).sum = ((L.map (flipBool01 n)).map fun p => p ^ 2).sum := by intro L induction L with | nil => simp | cons a l ih => simp [map_add, map_pow, ih] have hmap_idt : ∀ L : List (MvPolynomial (Fin n) ℝ × MvPolynomial (Fin n) ℝ), flipBool01 n (L.map fun t => t.1 * t.2).sum = ((L.map flipTerm).map fun t => t.1 * t.2).sum := by intro L induction L with | nil => simp | cons t l ih => simp only [List.map_cons, List.sum_cons, map_add, ih] congr 1 dsimp only [flipTerm] by_cases hlin : t.2 = linSum n - MvPolynomial.C ((n : ℝ) - β) · rw [if_pos hlin, hlin, map_mul, hflip_lin]; ring · rw [if_neg hlin, map_mul] rw [hmap_sq, hmap_idt] /-- **Headline Theorem 4D (Explicit Matching Closed-Form Sum-of-Squares Upper Bound — All Regimes):** For EVERY `n ≥ 2`, `k < n`, and `β ∈ (k, k + 1)`: `SoSRefutes (knapsackAxioms n β) (2 * (min (min (k + 1) (n - k)) (n / 2) + 1))`! -/ theorem knapsack_sos_exact_upper_bound {n k : ℕ} (hn : 2 ≤ n) (hk : k < n) {β : ℝ} (hβ1 : (k : ℝ) < β) (hβ2 : β < (k : ℝ) + 1) : SoSRefutes (knapsackAxioms n β) (2 * (min (min (k + 1) (n - k)) (n / 2) + 1)) := by classical -- Helper for Regime 1 (`k + 1 ≤ n / 2`, degree `2 * (k + 2)`): -- `- descFact β (k + 2) > 0`, and `(k+2)! * ∑_{|S|=k+2} (mon01 S)^2 ≡ descFact β (k + 2)`! have hregime1 : ∀ (k' : ℕ) (β' : ℝ), k' < n → (k' : ℝ) < β' → β' < (k' : ℝ) + 1 → SoSRefutes (knapsackAxioms n β') (2 * (k' + 2)) := by intro k' β' _ h1 h2 let r := k' + 2 have hneg : descFact β' r < 0 := descFact_neg_at_k_add_two h1 h2 let c : ℝ := - descFact β' r have hc : 0 < c := by dsimp only [c]; linarith have hfact_pos : (0 : ℝ) < (Nat.factorial r : ℝ) := by exact_mod_cast Nat.factorial_pos r -- `squares`: `C (sqrt (r! / c)) * mon01 S` for `S ∈ univ.powersetCard r`! let sets : List (Finset (Fin n)) := ((Finset.univ : Finset (Fin n)).powersetCard r).toList let α : ℝ := Real.sqrt ((Nat.factorial r : ℝ) / c) have hα_sq : α ^ 2 = (Nat.factorial r : ℝ) / c := Real.sq_sqrt (le_of_lt (div_pos hfact_pos hc)) let squares : List (MvPolynomial (Fin n) ℝ) := sets.map fun S => MvPolynomial.C α * mon01 S have hsq_deg : ∀ p ∈ squares, 2 * p.totalDegree ≤ 2 * r := by intro p hp rcases List.mem_map.mp hp with ⟨S, hS, rfl⟩ have hSc : S.card = r := (Finset.mem_powersetCard.mp (Finset.mem_toList.mp hS)).2 have hdeg : (MvPolynomial.C α * mon01 S).totalDegree ≤ r := by refine le_trans (MvPolynomial.totalDegree_mul _ _) ?_ rw [MvPolynomial.totalDegree_C, zero_add, ← hSc] exact totalDegree_mon01_le S omega have hsq_sum : (squares.map fun p => p ^ 2).sum = MvPolynomial.C ((Nat.factorial r : ℝ) / c) * ∑ S ∈ (Finset.univ : Finset (Fin n)).powersetCard r, (mon01 S) ^ 2 := by dsimp only [squares] rw [List.map_map] have hnodup : sets.Nodup := Finset.nodup_toList _ have htoFin : sets.toFinset = (Finset.univ : Finset (Fin n)).powersetCard r := by ext S; simp [sets] have hconv : ∀ (L : List (Finset (Fin n))), L.Nodup → (L.map ((fun p => p ^ 2) ∘ fun S => MvPolynomial.C α * mon01 S)).sum = MvPolynomial.C ((Nat.factorial r : ℝ) / c) * ∑ S ∈ L.toFinset, (mon01 S) ^ 2 := by intro L induction L with | nil => intro _; simp | cons S t ih => intro hnd rw [List.nodup_cons] at hnd rw [List.map_cons, List.sum_cons, ih hnd.2, List.toFinset_cons, Finset.sum_insert (by simp [hnd.1]), mul_add] congr 1 dsimp only [Function.comp_apply] rw [mul_pow, ← map_pow, hα_sq] rw [hconv sets hnodup, htoFin] -- Show `-1 - (squares.map (·^2)).sum ∈ InIdealF ℝ (knapsackAxioms n β') (2 * r)`! have hrem_in : InIdealF ℝ (knapsackAxioms n β') (2 * r) (-1 - (squares.map fun p => p ^ 2).sum) := by rw [hsq_sum] -- Multiply `descFact β' r - r! * ∑_{|S|=r} (mon01 S)^2` by `C c⁻¹`! have hrew : -1 - MvPolynomial.C ((Nat.factorial r : ℝ) / c) * ∑ S ∈ (Finset.univ : Finset (Fin n)).powersetCard r, (mon01 S) ^ 2 = MvPolynomial.C c⁻¹ * (-(fallingPoly (linSum n) r - MvPolynomial.C (descFact β' r)) + (fallingPoly (linSum n) r - MvPolynomial.C (Nat.factorial r : ℝ) * elemSymm n r) - MvPolynomial.C (Nat.factorial r : ℝ) * ∑ S ∈ (Finset.univ : Finset (Fin n)).powersetCard r, ((mon01 S) ^ 2 - mon01 S)) := by unfold elemSymm rw [Finset.sum_sub_distrib] have h1 : MvPolynomial.C c⁻¹ * MvPolynomial.C (descFact β' r) = (-1 : MvPolynomial (Fin n) ℝ) := by rw [← map_mul, show descFact β' r = -c by dsimp only [c]; ring, mul_neg, inv_mul_cancel₀ (ne_of_gt hc), map_neg, map_one] have h2 : MvPolynomial.C c⁻¹ * MvPolynomial.C (Nat.factorial r : ℝ) = (MvPolynomial.C ((Nat.factorial r : ℝ) / c) : MvPolynomial (Fin n) ℝ) := by rw [← map_mul]; congr 1; ring calc -1 - MvPolynomial.C ((Nat.factorial r : ℝ) / c) * ∑ S ∈ (Finset.univ : Finset (Fin n)).powersetCard r, (mon01 S) ^ 2 = MvPolynomial.C c⁻¹ * MvPolynomial.C (descFact β' r) - (MvPolynomial.C c⁻¹ * MvPolynomial.C (Nat.factorial r : ℝ)) * ∑ S ∈ (Finset.univ : Finset (Fin n)).powersetCard r, (mon01 S) ^ 2 := by rw [h1, h2] _ = MvPolynomial.C c⁻¹ * (-(fallingPoly (linSum n) r - MvPolynomial.C (descFact β' r)) + (fallingPoly (linSum n) r - MvPolynomial.C (Nat.factorial r : ℝ) * ∑ S ∈ (Finset.univ : Finset (Fin n)).powersetCard r, mon01 S) - MvPolynomial.C (Nat.factorial r : ℝ) * (∑ S ∈ (Finset.univ : Finset (Fin n)).powersetCard r, (mon01 S) ^ 2 - ∑ S ∈ (Finset.univ : Finset (Fin n)).powersetCard r, mon01 S)) := by ring rw [hrew] refine inIdealF_C_mul _ (inIdealF_sub (inIdealF_add (inIdealF_neg ?_) ?_) (inIdealF_C_mul _ ?_)) · exact inIdealF_mono (by omega) (fallingPoly_sub_descFact_inIdeal β' r) · exact inIdealF_mono (by omega) (inIdealF_subset (fun p hp => Or.inl hp) (fallingPoly_sub_elemSymm_inIdeal r)) · refine inIdealF_finset_sum _ _ fun S hS => ?_ have hSc : S.card = r := (Finset.mem_powersetCard.mp hS).2 exact inIdealF_subset (fun p hp => Or.inl hp) (inIdealF_mono (by omega) (mon01_sq_sub_mon01_inIdeal S)) rcases hrem_in with ⟨idt, hidt, hrem_eq⟩ refine ⟨squares, idt, hsq_deg, hidt, ?_⟩ rw [← hrem_eq]; ring -- Split into the 3 exhaustive regimes! by_cases h1 : k + 1 ≤ n / 2 ∧ k + 1 ≤ n - k · have hmin : min (min (k + 1) (n - k)) (n / 2) = k + 1 := by omega rw [hmin] exact hregime1 k β hk hβ1 hβ2 · by_cases h2 : n - k ≤ n / 2 · have hmin : min (min (k + 1) (n - k)) (n / 2) = n - k := by omega rw [hmin] -- Regime 2: apply involution `X_i ↦ 1 - X_i` to `k' = n - 1 - k`, `β' = n - β`! have hk' : n - 1 - k < n := by omega have hβ1' : ((n - 1 - k : ℕ) : ℝ) < (n : ℝ) - β := by have : ((n - 1 - k : ℕ) : ℝ) = (n : ℝ) - 1 - (k : ℝ) := by rw [Nat.cast_sub (by omega), Nat.cast_sub (by omega)]; simp linarith have hβ2' : (n : ℝ) - β < ((n - 1 - k : ℕ) : ℝ) + 1 := by have : ((n - 1 - k : ℕ) : ℝ) = (n : ℝ) - 1 - (k : ℝ) := by rw [Nat.cast_sub (by omega), Nat.cast_sub (by omega)]; simp linarith have hdeg_eq : 2 * (n - 1 - k + 2) = 2 * (n - k + 1) := by omega have hsol := hregime1 (n - 1 - k) ((n : ℝ) - β) hk' hβ1' hβ2' rw [hdeg_eq] at hsol exact sosRefutes_flipBool01 hsol · -- Regime 3: `n / 2 < k + 1` and `n / 2 < n - k`, forcing `n` odd (`2 * (n / 2 + 1) = n + 1`)! have hmin : min (min (k + 1) (n - k)) (n / 2) = n / 2 := by omega have hodd_n : 2 * (n / 2 + 1) = n + 1 := by omega rw [hmin, hodd_n] -- Degree `n + 1` Nullstellensatz refutation immediately yields a degree `n + 1` SoS refutation! have hβ_ne : ∀ t ≤ n, β ≠ (t : ℝ) := by intro t _ heq have ht1 : k < t := Nat.cast_lt.mp (heq ▸ hβ1) have ht2 : t < k + 1 := Nat.cast_lt (α := ℝ).mp (by push_cast; linarith) omega have hns : NSRefutes ℝ (knapsackAxioms n β) (n + 1) := (knapsack_nullstellensatz_exact_degree (by omega) hβ_ne).mpr (le_refl _) rcases hns with ⟨idt, hidt, heq⟩ refine ⟨[], idt.map fun t => (-t.1, t.2), fun _ h => by simp at h, ?_, ?_⟩ · intro t ht rcases List.mem_map.mp ht with ⟨t0, ht0, rfl⟩ exact ⟨(hidt t0 ht0).1, by rw [MvPolynomial.totalDegree_neg]; exact (hidt t0 ht0).2⟩ · simp only [List.map_nil, List.sum_nil, zero_add, List.map_map] have hneg : ∀ L : List (MvPolynomial (Fin n) ℝ × MvPolynomial (Fin n) ℝ), (L.map ((fun t => t.1 * t.2) ∘ fun t => (-t.1, t.2))).sum = -(L.map fun t => t.1 * t.2).sum := by intro L induction L with | nil => simp | cons a l ih => simp only [List.map_cons, List.sum_cons, Function.comp_apply, neg_mul, ih]; ring rw [hneg idt, ← heq] /-- **Headline Theorem 4E (Exact Complete Boolean Knapsack SoS Degree Characterization):** For EVERY `n ≥ 2`, `k < n`, `β ∈ (k, k + 1)`, and EVERY `d : ℕ`: `SoSRefutes (knapsackAxioms n β) (2 * d) ↔ min (min (k + 1) (n - k)) (n / 2) + 1 ≤ d`! -/ theorem knapsack_sos_exact_degree_iff {n k d : ℕ} (hn : 2 ≤ n) (hk : k < n) {β : ℝ} (hβ1 : (k : ℝ) < β) (hβ2 : β < (k : ℝ) + 1) : SoSRefutes (knapsackAxioms n β) (2 * d) ↔ min (min (k + 1) (n - k)) (n / 2) + 1 ≤ d := by constructor · intro href by_contra hlt exact knapsack_sos_exact_lower_bound hn hk hβ1 hβ2 (by omega) href · intro hge exact sosRefutes_mono (by omega) (knapsack_sos_exact_upper_bound hn hk hβ1 hβ2) /-- **Headline Theorem 4G (Exact `O(1)` vs `Ω(n)` SoS vs. Nullstellensatz Separation):** For EVERY `n ≥ 2` and EVERY `β ∈ (0, 1)`: 1. `SoSRefutes (knapsackAxioms n β) 4` (constant degree `4`!), 2. `¬ NSRefutes ℝ (knapsackAxioms n β) n` (Nullstellensatz requires degree `n + 1`!). -/ theorem knapsack_ns_vs_sos_separation {n : ℕ} (hn : 2 ≤ n) {β : ℝ} (hβ0 : 0 < β) (hβ1 : β < 1) : SoSRefutes (knapsackAxioms n β) 4 ∧ ¬ NSRefutes ℝ (knapsackAxioms n β) n := by constructor · have hiff := knapsack_sos_exact_degree_iff (k := 0) (d := 2) hn (by omega) (by simpa using hβ0) (by simpa using hβ1) exact hiff.mpr (by omega) · have hβ_ne : ∀ t ≤ n, β ≠ (t : ℝ) := by intro t _ heq rcases t with _ | t · simp at heq; linarith · have h1 : (1 : ℝ) ≤ ((t + 1 : ℕ) : ℝ) := by exact_mod_cast Nat.succ_pos t linarith intro hns have := (knapsack_nullstellensatz_exact_degree (by omega) hβ_ne).mp hns omega end KnapsackUpperAndNS end Pillar4 end ProofComplexityFrontiers -- ============================================================================== -- VERIFICATION: AXIOM AUDIT FOR ALL 35 HEADLINE THEOREMS -- ============================================================================== -- Pillar 1: Exact Ben-Sasson–Wigderson Resolution Width–Size Trade-offs #print axioms ProofComplexityFrontiers.resolution_sound_mem #print axioms ProofComplexityFrontiers.resolution_sound #print axioms ProofComplexityFrontiers.bsw_exact_recurrence_tradeoff #print axioms ProofComplexityFrontiers.bsw_linear_ceiling_boost #print axioms ProofComplexityFrontiers.bsw_falling_product_lb #print axioms ProofComplexityFrontiers.bsw_exp_lower_bound #print axioms ProofComplexityFrontiers.bsw_sharp_high_width_exp #print axioms ProofComplexityFrontiers.bsw_sharp_low_gap_exp #print axioms ProofComplexityFrontiers.treelike_bsw_exact #print axioms ProofComplexityFrontiers.fullCNF_exact_invariants -- Pillar 2: Exact Exponential Tseitin & FPHP Resolution Lower Bounds #print axioms ProofComplexityFrontiers.tseitin_unsat #print axioms ProofComplexityFrontiers.tseitin_proper_subset_sat #print axioms ProofComplexityFrontiers.tseitin_exact_boundary_width_lb #print axioms ProofComplexityFrontiers.tseitin_general_exponential_size_lb #print axioms ProofComplexityFrontiers.tseitin_complete_graph_exact_lb #print axioms ProofComplexityFrontiers.tseitin_cycle_exact_sharpness #print axioms ProofComplexityFrontiers.fphp_unsat #print axioms ProofComplexityFrontiers.fphp_resolution_width_lb #print axioms ProofComplexityFrontiers.fphp_treelike_exact_size_lb #print axioms ProofComplexityFrontiers.fphp12_treelike_exact_sharpness -- Pillar 3: Dynamic Polynomial Calculus & Sum-of-Squares Lower Bounds + C_n Separation #print axioms ProofComplexityFrontiers.pc_fourier_boolean_iso #print axioms ProofComplexityFrontiers.tseitin_dynamic_pc_degree_lb #print axioms ProofComplexityFrontiers.tseitin_boolean_pc_degree_lb #print axioms ProofComplexityFrontiers.tseitin_sos_pseudoexp_psd #print axioms ProofComplexityFrontiers.tseitin_sos_degree_lb #print axioms ProofComplexityFrontiers.tseitin_Kn_pc_sos_lb #print axioms ProofComplexityFrontiers.tseitin_cycle_sos_exact #print axioms ProofComplexityFrontiers.tseitin_cycle_pc_degree_exact -- Pillar 4: Exact Boolean Knapsack SoS Degree, Harmonic Diagonalization & NS-vs-SoS Separation #print axioms ProofComplexityFrontiers.chu_vandermonde_falling #print axioms ProofComplexityFrontiers.knapsack_harmonic_diagonalization #print axioms ProofComplexityFrontiers.knapsack_sos_exact_lower_bound #print axioms ProofComplexityFrontiers.knapsack_sos_exact_upper_bound #print axioms ProofComplexityFrontiers.knapsack_sos_exact_degree_iff #print axioms ProofComplexityFrontiers.knapsack_nullstellensatz_exact_degree #print axioms ProofComplexityFrontiers.knapsack_ns_vs_sos_separation