Skip to content

Commit 2551152

Browse files
refactor(multivariate): move first-vars degree helpers into core module
Move firstVarsDegree and related support/monomial lemmas to CompPoly.Data.MvPolynomial so ToMathlib only carries equivalence bridge helpers. Co-authored-by: Aristotle (Harmonic) <aristotle-harmonic@harmonic.fun>
1 parent 6120732 commit 2551152

File tree

2 files changed

+51
-22
lines changed

2 files changed

+51
-22
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/-
2+
Copyright (c) 2025 CompPoly. All rights reserved.
3+
Released under Apache 2.0 license as described in the file LICENSE.
4+
Authors: Elias Judin
5+
-/
6+
7+
import Mathlib.Algebra.MvPolynomial.Basic
8+
import Mathlib.Data.Finsupp.Fin
9+
10+
/-!
11+
# First-variable degree helpers for `MvPolynomial (Fin (n + 1)) R`
12+
13+
This file defines the maximal total degree contributed by the first `n` variables
14+
(i.e., all variables except the last coordinate).
15+
-/
16+
17+
namespace MvPolynomial
18+
19+
open Finsupp
20+
21+
section FirstVarsDegree
22+
23+
variable {n : ℕ} {R : Type*} [CommSemiring R]
24+
25+
/-- Maximal degree contributed by the first `n` variables of a polynomial on `Fin (n + 1)`.
26+
27+
This is the support supremum of the sum of coordinates on `Fin.castSucc`. -/
28+
noncomputable def firstVarsDegree (P : MvPolynomial (Fin (n + 1)) R) : ℕ :=
29+
P.support.sup (fun α => ∑ i : Fin n, α (Fin.castSucc i))
30+
31+
/-- A support element bounds `firstVarsDegree` from below. -/
32+
lemma le_firstVarsDegree_of_mem_support {P : MvPolynomial (Fin (n + 1)) R}
33+
{α : Fin (n + 1) →₀ ℕ} (hα : α ∈ P.support) :
34+
(∑ i : Fin n, α (Fin.castSucc i)) ≤ firstVarsDegree (R := R) P := by
35+
classical
36+
simpa using Finset.le_sup (s := P.support)
37+
(f := fun β : Fin (n + 1) →₀ ℕ => ∑ i : Fin n, β (Fin.castSucc i)) hα
38+
39+
/-- `firstVarsDegree` of a monomial with nonzero coefficient. -/
40+
lemma firstVarsDegree_monomial (α : Fin (n + 1) →₀ ℕ) (c : R) (hc : c ≠ 0) :
41+
firstVarsDegree (R := R) (MvPolynomial.monomial α c) =
42+
(∑ i : Fin n, α (Fin.castSucc i)) := by
43+
classical
44+
have hsupp : (MvPolynomial.monomial α c).support = {α} := by
45+
rw [MvPolynomial.support_monomial, if_neg hc]
46+
simp [firstVarsDegree, hsupp]
47+
48+
end FirstVarsDegree
49+
50+
end MvPolynomial

CompPoly/ToMathlib/MvPolynomial/Equiv.lean

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ Authors: Chung Thai Nguyen, Quang Dao, Elias Judin
55
-/
66

77
import Mathlib.Algebra.MvPolynomial.Equiv
8+
import CompPoly.Data.MvPolynomial.FirstVarsDegree
89
import CompPoly.ToMathlib.Finsupp.Fin
910

1011
/-!
@@ -224,28 +225,6 @@ theorem degreeOf_coeff_finSuccEquivNth (f : MvPolynomial (Fin (n + 1)) R) (j : F
224225
exact Finset.le_sup (f := fun (g : Fin n.succ →₀ ℕ) => g (Fin.succAbove p j))
225226
(support_coeff_finSuccEquivNth.1 hm)
226227

227-
/-- Maximal degree contributed by the first `n` variables of a polynomial on `Fin (n + 1)`.
228-
229-
This is the support supremum of the sum of coordinates on `Fin.castSucc`. -/
230-
noncomputable def firstVarsDegree (P : MvPolynomial (Fin (n + 1)) R) : ℕ :=
231-
P.support.sup (fun α => ∑ i : Fin n, α (Fin.castSucc i))
232-
233-
/-- A support element bounds `firstVarsDegree` from below. -/
234-
lemma le_firstVarsDegree_of_mem_support {P : MvPolynomial (Fin (n + 1)) R}
235-
{α : Fin (n + 1) →₀ ℕ} (hα : α ∈ P.support) :
236-
(∑ i : Fin n, α (Fin.castSucc i)) ≤ firstVarsDegree (R := R) P := by
237-
classical
238-
simpa using Finset.le_sup (s := P.support)
239-
(f := fun β : Fin (n + 1) →₀ ℕ => ∑ i : Fin n, β (Fin.castSucc i)) hα
240-
241-
/-- `firstVarsDegree` of a monomial with nonzero coefficient. -/
242-
lemma firstVarsDegree_monomial (α : Fin (n + 1) →₀ ℕ) (c : R) (hc : c ≠ 0) :
243-
firstVarsDegree (R := R) (MvPolynomial.monomial α c) =
244-
(∑ i : Fin n, α (Fin.castSucc i)) := by
245-
classical
246-
have hsupp : (MvPolynomial.monomial α c).support = {α} := by
247-
rw [MvPolynomial.support_monomial, if_neg hc]
248-
simp [firstVarsDegree, hsupp]
249228

250229
/-- Coefficient in the last variable after `finSuccEquiv`. -/
251230
noncomputable def leadingCoeffFinSucc (P : MvPolynomial (Fin (n + 1)) R)

0 commit comments

Comments
 (0)