@@ -9,6 +9,8 @@ public import Mathlib.Data.Finsupp.Antidiagonal
99public import Mathlib.Data.Finsupp.Order
1010public import Mathlib.LinearAlgebra.Finsupp.LinearCombination
1111
12+ import Mathlib.Algebra.Group.TypeTags.Pointwise
13+
1214/-! # weights of Finsupp functions
1315
1416The theory of multivariate polynomials and power series is built
@@ -261,4 +263,61 @@ lemma range_single_one :
261263 obtain ⟨a, rfl⟩ := (Finsupp.sum_eq_one_iff _).mp hp
262264 use a
263265
266+ lemma degree_mono {R : Type *} [AddCommMonoid R] [PartialOrder R] [CanonicallyOrderedAdd R] :
267+ Monotone (Finsupp.degree (σ := σ) (R := R)) :=
268+ fun _ _ e ↦
269+ (Finset.sum_le_sum_of_subset (support_mono e)).trans (Finset.sum_le_sum fun _ _ ↦ e _)
270+
271+ lemma exists_le_degree_eq {σ : Type *} (f : σ →₀ ℕ) (n : ℕ) (hn : n ≤ f.degree) :
272+ ∃ g ≤ f, g.degree = n := by
273+ induction n with
274+ | zero => simp [degree_eq_zero_iff]
275+ | succ n IH =>
276+ obtain ⟨g, hgf, rfl⟩ := IH (by lia)
277+ obtain ⟨f, rfl⟩ := le_iff_exists_add.mp hgf
278+ obtain ⟨i, hi⟩ : f.support.Nonempty := by aesop
279+ exact ⟨g + .single i 1 , add_le_add_right (by simp; grind) _, by simp⟩
280+
281+ open scoped Pointwise in
282+ lemma degree_preimage_add {σ : Type *} (s t : Set ℕ) :
283+ degree (σ := σ) ⁻¹' (s + t) = degree (σ := σ) ⁻¹' s + degree (σ := σ) ⁻¹' t := by
284+ refine (Set.preimage_add_preimage_subset ..).antisymm' ?_
285+ rintro f ⟨m, hm, n, hn, e : m + n = _⟩
286+ obtain ⟨g, hgf, rfl⟩ := exists_le_degree_eq f m (by grind)
287+ obtain ⟨f, rfl⟩ := le_iff_exists_add.mp hgf
288+ exact Set.add_mem_add hm (by simp_all)
289+
290+ open scoped Pointwise in
291+ lemma degree_preimage_nsmul {σ : Type *} (s : Set ℕ) (n : ℕ) (hn : n ≠ 0 ) :
292+ degree (σ := σ) ⁻¹' (n • s) = n • degree (σ := σ) ⁻¹' s := by
293+ obtain (_ | n) := n; · contradiction
294+ induction n <;> simp_all [succ_nsmul, degree_preimage_add]
295+
296+ open scoped Pointwise in
297+ lemma nsmul_single_one_image {α : Type *} {n : ℕ} {s : Set α} :
298+ n • (single · 1 ) '' s = {x : α →₀ ℕ | x.degree = n ∧ ↑x.support ⊆ s} := by
299+ classical
300+ induction n with
301+ | zero => aesop (add simp degree_eq_zero_iff)
302+ | succ n ih =>
303+ rw [succ_nsmul, ih]
304+ refine subset_antisymm ?_ fun f ⟨f_deg, f_supp⟩ ↦ ?_
305+ · simp [Set.subset_def, Set.mem_add, @forall_comm (α →₀ ℕ)]; grind
306+ obtain ⟨i, hi⟩ : f.support.Nonempty := by aesop
307+ obtain ⟨x, hx⟩ := le_iff_exists_add'.mp
308+ (show single i 1 ≤ f by simpa [Nat.one_le_iff_ne_zero] using hi)
309+ exact ⟨x, by aesop (add simp Set.subset_def), _, ⟨_, f_supp (by simp_all), rfl⟩, hx.symm⟩
310+
311+ open scoped Pointwise in
312+ theorem image_pow_eq_finsuppProd_image {α β : Type *} [CommMonoid β] {f : α → β} {n} {s : Set α} :
313+ (f '' s) ^ n = (·.prod (f · ^ ·)) '' {x : α →₀ ℕ | x.degree = n ∧ ↑x.support ⊆ s} := by
314+ classical
315+ suffices ∀ (s : Set (α →₀ ℕ)), ((·.prod (f · ^ ·)) '' s) ^ n = (·.prod (f · ^ ·)) '' (n • s) by
316+ simp [← nsmul_single_one_image, ← this, Set.image_image]
317+ intro s
318+ refine (Set.image_pow (⟨⟨(·.prod (f · ^ ·)) ∘ Multiplicative.toAdd, by simp⟩,
319+ by simp [Finsupp.prod_add_index, pow_add]⟩ : Multiplicative (α →₀ ℕ) →* β) _ _).symm.trans ?_
320+ simp [-Function.comp_apply, Set.image_comp, show Multiplicative.toAdd '' s = s from
321+ Set.image_id _]
322+
264323end Finsupp
0 commit comments