/-Copyright (c) 2026 Carles MarΓn. All rights reserved.Released under Apache 2.0 license as described in the file LICENSE.Authors: Carles MarΓn, Claude (AI assistant)-/module -- encaje: nΓΊcleo de la cota superior del Teorema 2 (qp(P^{m-1} Γ P^3) β€ β4m/3β) de la nota qp_bsr.public import Mathlib.Algebra.Polynomial.RuleOfSignspublic import Mathlib.LinearAlgebra.Matrix.NonsingularInversepublic import Mathlib.Data.Fintype.EquivFinpublic import Mathlib.Basic.Real.Basicpublic import Mathlib.Tactic.FinCasespublic import Mathlib.Tactic.Ring /-!# Descartes' rule and the linear algebra behind `qp(β^{m-1} Γ βΒ³) β€ β4m/3β` This file formalizes the linear-algebra core of the upper bound in Theorem 2 ofC. MarΓn, *Quadratic persistence of Segre varieties and a linear gap between biquadratic SOS rankand Zarankiewicz bounds* (2026). With `b x = (1, x, xΒ³)`: any three `b x` at distinct positivenodes are independent, any six symmetric squares `b x β b x` are independent, and thecoefficients `c i j` attached to one group, or to two disjoint groups `U, V`, satisfying therelations `β_{j β S} c i j β’ b j β β β’ b i` (equation (grupo) of the note) all vanish. Everything is over `β`, with arbitrary distinct positive real nodes (the note uses the integers`1, β¦, m`, a special case). ## Main results * `SegrePersistence.signVariations_lt_card_support`: a nonzero real polynomial has fewer sign variations than nonzero coefficients.* `SegrePersistence.monomial_combination_eq_zero`: a combination of `k` distinct monomials vanishing at `β₯ k` distinct positive nodes is zero (Descartes' rule of signs, `Polynomial.roots_countP_pos_le_signVariations`).* `SegrePersistence.pow_linearIndependent`: the vectors `(t i ^ e j)_j`, for at most `k` distinct positive nodes `t i` and `k` distinct exponents `e j`, are linearly independent.* `SegrePersistence.descartes_six`, `SegrePersistence.three_independent`: the instances with exponents `{0,1,2,3,4,6}` and `{0,1,3}`.* `SegrePersistence.group_vanish`: inside one group (at most three nodes) the relations force `c i j = 0` for `j β i`.* `SegrePersistence.cross_vanish`: the key step for two disjoint groups `U, V`. ## What is not covered The identification of `π` with `βΒ²A* β βΒ²B*`, the factorization`D_{ij} = c_{ij} vol(b_i, b_j, Β·, Β·)` and the derivation of the relations (grupo) from the radicalconditions (hence the statement `qp β€ β4m/3β` itself), and the lower bound of Theorem 2, are notformalized here.-/ @[expose] public section open Polynomial Finset namespace SegrePersistence /-- A nonzero real polynomial has strictly fewer sign variations than nonzero coefficients. -/theorem signVariations_lt_card_support (P : β[X]) (hP : P β 0) : P.signVariations < P.support.card := by classical have hlen : ((P.coeffList.map SignType.sign).filter (Β· β 0)).length = P.support.card := by have hq : P.support = ((List.range (P.natDegree + 1)).filter (fun i => decide (SignType.sign (P.coeff i) β 0))).toFinset := by ext i simp only [mem_support_iff, List.mem_toFinset, List.mem_filter, List.mem_range, decide_eq_true_eq, ne_eq, sign_eq_zero_iff] exact β¨fun h => β¨Nat.lt_succ_of_le (le_natDegree_of_ne_zero h), hβ©, fun h => h.2β© rw [hq, List.toFinset_card_of_nodup (List.nodup_range.filter _), coeffList_of_ne_zero hP, List.map_map, List.filter_map, List.length_map, List.filter_reverse, List.length_reverse] rfl have hpos : 0 < P.support.card := Finset.card_pos.mpr (Polynomial.support_nonempty.mpr hP) have h1 : P.signVariations β€ ((P.coeffList.map SignType.sign).filter (Β· β 0)).length - 1 := by unfold Polynomial.signVariations List.signVariations exact Nat.sub_le_sub_right (List.destutter_sublist _ _).length_le 1 omega /-- **Descartes, monomial form.** A combination of distinct monomials `X ^ e j` that vanishes atat least as many distinct positive nodes as it has monomials is zero. -/theorem monomial_combination_eq_zero {ΞΉ ΞΊ : Type*} [Fintype ΞΉ] [Fintype ΞΊ] (t : ΞΉ β β) (ht : Function.Injective t) (hpos : β i, 0 < t i) (e : ΞΊ β β) (he : Function.Injective e) (hcard : Fintype.card ΞΊ β€ Fintype.card ΞΉ) (c : ΞΊ β β) (h : β i, β j, c j * t i ^ e j = 0) : c = 0 := by classical set P : β[X] := β j, C (c j) * X ^ e j with hPdef have hcoeff : β j, P.coeff (e j) = c j := by intro j rw [hPdef, finsetSum_coeff, Finset.sum_eq_single j] Β· simp Β· intro b _ hb have hne : Β¬ e j = e b := fun hh => hb (he hh.symm) simp only [coeff_C_mul_X_pow, hne, βreduceIte] Β· intro hj; exact absurd (Finset.mem_univ j) hj have heval : β i, P.eval (t i) = 0 := by intro i simp [hPdef, eval_finsetSum, h i] by_contra hc have hP : P β 0 := by intro h0; apply hc; funext j; rw [β hcoeff j, h0]; simp have hsupp : P.support β Finset.univ.image e := by intro n hn rw [mem_support_iff] at hn by_contra hn' apply hn rw [hPdef, finsetSum_coeff] refine Finset.sum_eq_zero fun j _ => ?_ have hne : Β¬ n = e j := by rintro rfl exact hn' (Finset.mem_image.mpr β¨j, Finset.mem_univ _, rflβ©) simp only [coeff_C_mul_X_pow, hne, βreduceIte] have hsc : P.support.card β€ Fintype.card ΞΊ := (Finset.card_le_card hsupp).trans (Finset.card_image_le.trans (by simp)) have hroots : Fintype.card ΞΉ β€ P.roots.countP (0 < Β·) := by rw [Multiset.countP_eq_card_filter] calc Fintype.card ΞΉ = (Finset.univ.image t).card := by rw [Finset.card_image_of_injective _ ht]; simp _ β€ (P.roots.filter (0 < Β·)).toFinset.card := by apply Finset.card_le_card intro x hx obtain β¨i, _, rflβ© := Finset.mem_image.mp hx simp [Multiset.mem_toFinset, mem_roots hP, hpos i, heval i] _ β€ _ := Multiset.toFinset_card_le _ have h1 := roots_countP_pos_le_signVariations P have h2 := signVariations_lt_card_support P hP omega /-- Dual form: at most `k` distinct positive nodes and `k` distinct exponents, a combination ofthe nodes killed by every exponent is zero. -/theorem pow_dual {ΞΉ ΞΊ : Type*} [Fintype ΞΉ] [Fintype ΞΊ] [DecidableEq ΞΉ] (t : ΞΉ β β) (ht : Function.Injective t) (hpos : β i, 0 < t i) (e : ΞΊ β β) (he : Function.Injective e) (hcard : Fintype.card ΞΉ β€ Fintype.card ΞΊ) (a : ΞΉ β β) (h : β j, β i, a i * t i ^ e j = 0) : a = 0 := by obtain β¨fβ© := Function.Embedding.nonempty_of_card_le hcard let M : Matrix ΞΉ ΞΉ β := fun i i' => t i ^ e (f i') have hinj : Function.Injective M.mulVec := by intro x y hxy have hd : M.mulVec (x - y) = 0 := by rw [Matrix.mulVec_sub, hxy, sub_self] have := monomial_combination_eq_zero t ht hpos (e β f) (he.comp f.injective) le_rfl (x - y) (fun i => by have := congrFun hd i simp only [Matrix.mulVec, dotProduct, M, Pi.zero_apply] at this rw [β this] exact Finset.sum_congr rfl fun j _ => by simp [mul_comm]) exact sub_eq_zero.mp this have hv := Matrix.vecMul_injective_iff_isUnit.mpr (Matrix.mulVec_injective_iff_isUnit.mp hinj) apply hv show Matrix.vecMul a M = Matrix.vecMul 0 M rw [Matrix.zero_vecMul] funext i' exact h (f i') /-- **Generalized Vandermonde independence.** For at most `k` distinct positive nodes `t i` and`k` distinct exponents `e j`, the vectors `(t i ^ e j)_j` are linearly independent. -/theorem pow_linearIndependent {ΞΉ ΞΊ : Type*} [Fintype ΞΉ] [Fintype ΞΊ] (t : ΞΉ β β) (ht : Function.Injective t) (hpos : β i, 0 < t i) (e : ΞΊ β β) (he : Function.Injective e) (hcard : Fintype.card ΞΉ β€ Fintype.card ΞΊ) : LinearIndependent β (fun i : ΞΉ => fun j : ΞΊ => t i ^ e j) := by classical rw [Fintype.linearIndependent_iff] intro g hg i have := pow_dual t ht hpos e he hcard g (fun j => by have := congrFun hg j simpa [Finset.sum_apply] using this) exact congrFun this i /-- Finset form of `pow_dual`. -/theorem pow_dual_finset {Ξ± ΞΊ : Type*} [Fintype ΞΊ] (W : Finset Ξ±) (t : Ξ± β β) (ht : Set.InjOn t W) (hpos : β x β W, 0 < t x) (e : ΞΊ β β) (he : Function.Injective e) (hcard : W.card β€ Fintype.card ΞΊ) (a : Ξ± β β) (h : β j, β x β W, a x * t x ^ e j = 0) : β x β W, a x = 0 := by classical have := pow_dual (ΞΉ := W) (fun x => t x) (fun x y hxy => Subtype.ext (ht x.2 y.2 hxy)) (fun x => hpos x x.2) e he (by simpa using hcard) (fun x => a x) (fun j => by rw [Finset.sum_coe_sort W (fun x => a x * t x ^ e j)]; exact h j) intro x hx exact congrFun this β¨x, hxβ© /-- **Six symmetric monomials.** For distinct positive nodes, the vectors`(1, t, tΒ², tΒ³, tβ΄, tβΆ)` are linearly independent in `ββΆ`. -/theorem descartes_six (t : Fin 6 β β) (ht : Function.Injective t) (hpos : β i, 0 < t i) : LinearIndependent β (fun i => ![1, t i, t i ^ 2, t i ^ 3, t i ^ 4, t i ^ 6]) := by have := pow_linearIndependent t ht hpos (![0, 1, 2, 3, 4, 6] : Fin 6 β β) (by decide) le_rfl convert this using 1 funext i j fin_cases j <;> simp /-- **Three monomials.** For distinct positive nodes, the vectors `(1, t, tΒ³)` are linearlyindependent in `βΒ³`. -/theorem three_independent (t : Fin 3 β β) (ht : Function.Injective t) (hpos : β i, 0 < t i) : LinearIndependent β (fun i => ![1, t i, t i ^ 3]) := by have := pow_linearIndependent t ht hpos (![0, 1, 3] : Fin 3 β β) (by decide) le_rfl convert this using 1 funext i j fin_cases j <;> simp /-- The vector `b x = (1, x, xΒ³)` of the note. -/def b (x : β) : Fin 3 β β := ![1, x, x ^ 3] /-- The symmetric square `b x β b x`, as a `3 Γ 3` array. -/def sq (x : β) : Fin 3 β Fin 3 β β := fun p q => b x p * b x q /-- At most three distinct positive nodes: the `b x` are independent (finset form). -/theorem b_independent (S : Finset β) (hpos : β x β S, 0 < x) (hS : S.card β€ 3) (a : β β β) (h : β x β S, a x β’ b x = 0) : β x β S, a x = 0 := by refine pow_dual_finset S id (Set.injOn_id _) hpos (![0, 1, 3] : Fin 3 β β) (by decide) (by simpa using hS) a fun j => ?_ have := congrFun h j rw [Finset.sum_apply] at this refine (Finset.sum_congr rfl fun x _ => ?_).trans this fin_cases j <;> simp [b] /-- At most six distinct positive nodes: the `b x β b x` are independent (finset form). -/theorem sq_independent (S : Finset β) (hpos : β x β S, 0 < x) (hS : S.card β€ 6) (a : β β β) (h : β x β S, a x β’ sq x = 0) : β x β S, a x = 0 := by refine pow_dual_finset S id (Set.injOn_id _) hpos (![0, 1, 2, 3, 4, 6] : Fin 6 β β) (by decide) (by simpa using hS) a fun j => ?_ have key : β p q : Fin 3, β x β S, a x * (b x p * b x q) = 0 := by intro p q have := congrFun (congrFun h p) q rw [Finset.sum_apply, Finset.sum_apply, Pi.zero_apply, Pi.zero_apply] at this rw [β this] simp [sq] fin_cases j Β· refine (Finset.sum_congr rfl fun x _ => ?_).trans (key 0 0); congr 1; simp [b] Β· refine (Finset.sum_congr rfl fun x _ => ?_).trans (key 0 1); congr 1 Β· refine (Finset.sum_congr rfl fun x _ => ?_).trans (key 1 1); congr 1; simp [b]; ring Β· refine (Finset.sum_congr rfl fun x _ => ?_).trans (key 0 2); congr 1; simp [b] Β· refine (Finset.sum_congr rfl fun x _ => ?_).trans (key 1 2); congr 1; simp [b]; ring Β· refine (Finset.sum_congr rfl fun x _ => ?_).trans (key 2 2); congr 1; simp [b]; ring /-- **Vanishing inside a group.** If `S` has at most three distinct positive nodes and, for every`i β S`, `β_{j β S} c i j β’ b j β β β’ b i`, then `c i j = 0` for `i β j` in `S`. -/theorem group_vanish (S : Finset β) (hpos : β x β S, 0 < x) (hS : S.card β€ 3) (c : β β β β β) (h : β i β S, β l : β, β j β S, c i j β’ b j = l β’ b i) : β i β S, β j β S, j β i β c i j = 0 := by classical intro i hi j hj hji obtain β¨l, hlβ© := h i hi have hsum : β k β S, (c i k - if k = i then l else 0) β’ b k = 0 := by simp only [sub_smul, Finset.sum_sub_distrib, ite_smul, zero_smul, Finset.sum_ite_eq' S i, hi, βreduceIte, hl, sub_self] have := b_independent S hpos hS _ hsum j hj simpa [hji] using this /-- **The key step of Theorem 2 (upper bound).** Let `U, V` be disjoint groups of at most threedistinct positive nodes and `c i j` (for `i β U`, `j β V`) real coefficients such that`β_{j β V} c i j β’ b j β β β’ b i` for every `i β U` and `β_{i β U} c i j β’ b i β β β’ b j` for every`j β V`. Then all `c i j` vanish. -/theorem cross_vanish (U V : Finset β) (hUV : Disjoint U V) (hpos : β x β U βͺ V, 0 < x) (hU : U.card β€ 3) (hV : V.card β€ 3) (c : β β β β β) (hrow : β i β U, β l : β, β j β V, c i j β’ b j = l β’ b i) (hcol : β j β V, β m : β, β i β U, c i j β’ b i = m β’ b j) : β i β U, β j β V, c i j = 0 := by classical choose! l hl using hrow choose! m hm using hcol have hl' : β i β U, β q, β j β V, c i j * b j q = l i * b i q := by intro i hi q have := congrFun (hl i hi) q simpa [Finset.sum_apply] using this have hm' : β j β V, β p, β i β U, c i j * b i p = m j * b j p := by intro j hj p have := congrFun (hm j hj) p simpa [Finset.sum_apply] using this -- `T = β c i j b i β b j` written in two ways have key : β p q : Fin 3, β i β U, l i * (b i p * b i q) = β j β V, m j * (b j p * b j q) := by intro p q calc β i β U, l i * (b i p * b i q) = β i β U, b i p * β j β V, c i j * b j q := Finset.sum_congr rfl fun i hi => by rw [hl' i hi q]; ring _ = β i β U, β j β V, c i j * b i p * b j q := Finset.sum_congr rfl fun i _ => by rw [Finset.mul_sum]; exact Finset.sum_congr rfl fun j _ => by ring _ = β j β V, β i β U, c i j * b i p * b j q := Finset.sum_comm _ = β j β V, b j q * β i β U, c i j * b i p := Finset.sum_congr rfl fun j _ => by rw [Finset.mul_sum]; exact Finset.sum_congr rfl fun i _ => by ring _ = β j β V, m j * (b j p * b j q) := Finset.sum_congr rfl fun j hj => by rw [hm' j hj p]; ring -- the at most six squares `b x β b x`, `x β U βͺ V`, are independent set a : β β β := fun x => if x β U then l x else -m x with ha have hsum : β x β U βͺ V, a x β’ sq x = 0 := by funext p q rw [Finset.sum_apply, Finset.sum_apply, Finset.sum_union hUV] have hU' : β x β U, (a x β’ sq x) p q = β x β U, l x * (b x p * b x q) := Finset.sum_congr rfl fun x hx => by simp [ha, hx, sq] have hV' : β x β V, (a x β’ sq x) p q = -β x β V, m x * (b x p * b x q) := by rw [β Finset.sum_neg_distrib] exact Finset.sum_congr rfl fun x hx => by simp [ha, Finset.disjoint_right.mp hUV hx, sq] rw [hU', hV', key p q] simp have hcard : (U βͺ V).card β€ 6 := (Finset.card_union_le U V).trans (by omega) have hzero := sq_independent (U βͺ V) hpos hcard a hsum intro i hi have hli : l i = 0 := by have := hzero i (Finset.mem_union_left V hi) simpa [ha, hi] using this have hrow0 : β j β V, c i j β’ b j = 0 := by rw [hl i hi, hli, zero_smul] exact b_independent V (fun x hx => hpos x (Finset.mem_union_right U hx)) hV (c i) hrow0 end SegrePersistence