Skip to content

Commit a6d9dfc

Browse files
committed
address comments
1 parent f26226b commit a6d9dfc

File tree

1 file changed

+45
-49
lines changed

1 file changed

+45
-49
lines changed

Mathlib/Combinatorics/Enumerative/Partition/GenFun.lean

Lines changed: 45 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,14 @@ respect the actual value of $f(0, c)$ and $f(i, 0)$, but it makes the otherwise
3333
product potentially infinite.
3434
-/
3535

36-
open PowerSeries
36+
open Finset PowerSeries
3737
open scoped PowerSeries.WithPiTopology
3838

3939
namespace Nat.Partition
40-
variable {M : Type*} [CommSemiring M]
40+
variable {R : Type*} [CommSemiring R]
4141

4242
/-- Convert a `Partition n` to a member of `(Finset.Icc 1 n).finsuppAntidiag n`
43-
(see `Nat.Partition.range_toFinsuppAntidiag` for the proof).
43+
(see `Nat.Partition.toFinsuppAntidiag_mem_finsuppAntidiag` for the proof).
4444
`p.toFinsuppAntidiag i` is defined as `i` times the number of occurrence of `i` in `p`. -/
4545
def toFinsuppAntidiag {n : ℕ} (p : Partition n) : ℕ →₀ ℕ where
4646
toFun m := p.parts.count m * m
@@ -61,33 +61,30 @@ theorem toFinsuppAntidiag_injective (n : ℕ) :
6161
· grind [Multiset.count_eq_zero, → parts_pos]
6262
· exact Nat.eq_of_mul_eq_mul_right h0 <| funext_iff.mp hcount m
6363

64-
theorem range_toFinsuppAntidiag (n : ℕ) :
65-
Set.range (toFinsuppAntidiag (n := n)) ⊆ (Finset.Icc 1 n).finsuppAntidiag n := by
66-
unfold toFinsuppAntidiag
67-
rw [Set.range_subset_iff]
68-
intro p
69-
have hp : p.parts.toFinset ⊆ Finset.Icc 1 n := by
70-
grind [Multiset.mem_toFinset, Finset.mem_Icc, → parts_pos]
71-
suffices ∑ m ∈ Finset.Icc 1 n, Multiset.count m p.parts * m = n by simpa [hp]
64+
theorem toFinsuppAntidiag_mem_finsuppAntidiag {n : ℕ} (p : Partition n) :
65+
p.toFinsuppAntidiag ∈ (Icc 1 n).finsuppAntidiag n := by
66+
have hp : p.parts.toFinset ⊆ Icc 1 n := by
67+
grind [Multiset.mem_toFinset, mem_Icc, → parts_pos]
68+
suffices ∑ m ∈ Icc 1 n, Multiset.count m p.parts * m = n by simpa [toFinsuppAntidiag, hp]
7269
convert ← p.parts_sum
73-
rw [Finset.sum_multiset_count]
74-
apply Finset.sum_subset hp
70+
rw [sum_multiset_count]
71+
apply sum_subset hp
7572
suffices ∀ (x : ℕ), 1 ≤ x → x ≤ n → x ∉ p.parts → x ∉ p.parts ∨ x = 0 by simpa
7673
grind [→ parts_pos]
7774

7875
/-- Generating function associated with character $f(i, c)$ for partition functions, where $i$ is a
7976
part of the partition, and $c$ is the count of that part in the partition. The character function is
8077
multiplied within one `n.Partition`, and summed among all `n.Partition` for a fixed `n`. This way,
8178
each `n` is assigned a value, which we use as the coefficients of the power series. -/
82-
def genFun (f : ℕ → ℕ → M) : M⟦X⟧ :=
79+
def genFun (f : ℕ → ℕ → R) : R⟦X⟧ :=
8380
PowerSeries.mk fun n ↦ ∑ p : n.Partition, ∏ i ∈ p.parts.toFinset, f i (p.parts.count i)
8481

85-
variable [TopologicalSpace M]
82+
variable [TopologicalSpace R]
8683

8784
/-- The infinite sum in the formula `Nat.Partition.hasProd_genFun` always converges. -/
88-
theorem summable_genFun_term (f : ℕ → ℕ → M) (i : ℕ) :
89-
Summable fun j ↦ f (i + 1) (j + 1) • (X : M⟦X⟧) ^ ((i + 1) * (j + 1)) := by
90-
rcases subsingleton_or_nontrivial M with h | h
85+
theorem summable_genFun_term (f : ℕ → ℕ → R) (i : ℕ) :
86+
Summable fun j ↦ f (i + 1) (j + 1) • (X : R⟦X⟧) ^ ((i + 1) * (j + 1)) := by
87+
rcases subsingleton_or_nontrivial R with h | h
9188
· simpa [Subsingleton.eq_zero] using summable_zero
9289
apply WithPiTopology.summable_of_tendsto_order_atTop_nhds_top
9390
refine ENat.tendsto_nhds_top_iff_natCast_lt.mpr (fun n ↦ Filter.eventually_atTop.mpr ⟨n, ?_⟩)
@@ -99,23 +96,23 @@ theorem summable_genFun_term (f : ℕ → ℕ → M) (i : ℕ) :
9996
grind
10097

10198
/-- Alternative form of `summable_genFun_term` that unshifts the first index. -/
102-
theorem summable_genFun_term' (f : ℕ → ℕ → M) {i : ℕ} (hi : i ≠ 0) :
103-
Summable fun j ↦ f i (j + 1) • (X : M⟦X⟧) ^ (i * (j + 1)) := by
99+
theorem summable_genFun_term' (f : ℕ → ℕ → R) {i : ℕ} (hi : i ≠ 0) :
100+
Summable fun j ↦ f i (j + 1) • (X : R⟦X⟧) ^ (i * (j + 1)) := by
104101
obtain ⟨a, rfl⟩ := Nat.exists_eq_add_one_of_ne_zero hi
105102
apply summable_genFun_term
106103

107-
variable [T2Space M]
104+
variable [T2Space R]
108105

109-
private theorem aux_dvd_of_coeff_ne_zero {f : ℕ → ℕ → M} {d : ℕ} {s : Finset ℕ} (hs0 : 0 ∉ s)
106+
private theorem aux_dvd_of_coeff_ne_zero {f : ℕ → ℕ → R} {d : ℕ} {s : Finset ℕ} (hs0 : 0 ∉ s)
110107
{g : ℕ →₀ ℕ} (hg : g ∈ s.finsuppAntidiag d)
111-
(hprod : ∀ i ∈ s, (coeff (g i)) (1 + ∑' j, f i (j + 1) • X ^ (i * (j + 1))) ≠ (0 : M))
112-
(x : ℕ) : x ∣ g x := by
108+
(hprod : ∀ i ∈ s, (coeff (g i)) (1 + ∑' j, f i (j + 1) • X ^ (i * (j + 1))) ≠ (0 : R)) (x : ℕ) :
109+
x ∣ g x := by
113110
by_cases hx : x ∈ s
114111
· specialize hprod x hx
115112
contrapose! hprod
116113
have hx0 : x ≠ 0 := fun h ↦ hs0 (h ▸ hx)
117114
rw [map_add, (summable_genFun_term' f hx0).map_tsum _ (WithPiTopology.continuous_coeff _ _)]
118-
rw [show (0 : M) = 0 + ∑' (i : ℕ), 0 by simp]
115+
rw [show (0 : R) = 0 + ∑' (i : ℕ), 0 by simp]
119116
congrm (?_ + ∑' (i : ℕ), ?_)
120117
· suffices g x ≠ 0 by simp [this]
121118
contrapose! hprod
@@ -127,45 +124,45 @@ private theorem aux_dvd_of_coeff_ne_zero {f : ℕ → ℕ → M} {d : ℕ} {s :
127124
simp [hprod]
128125
· suffices g x = 0 by simp [this]
129126
contrapose! hx
130-
exact Finset.mem_of_subset (Finset.mem_finsuppAntidiag.mp hg).2 <| by simpa using hx
127+
exact mem_of_subset (mem_finsuppAntidiag.mp hg).2 <| by simpa using hx
131128

132-
private theorem aux_prod_coeff_eq_zero_of_notMem_range (f : ℕ → ℕ → M) {d : ℕ} {s : Finset ℕ}
129+
private theorem aux_prod_coeff_eq_zero_of_notMem_range (f : ℕ → ℕ → R) {d : ℕ} {s : Finset ℕ}
133130
(hs0 : 0 ∉ s) {g : ℕ →₀ ℕ} (hg : g ∈ s.finsuppAntidiag d)
134131
(hg' : g ∉ Set.range (toFinsuppAntidiag (n := d))) :
135-
∏ i ∈ s, (coeff (g i)) (1 + ∑' j, f i (j + 1) • X ^ (i * (j + 1)) : M⟦X⟧) = 0 := by
136-
suffices ∃ i ∈ s, (coeff (g i)) ((1 : M⟦X⟧) + ∑' j, f i (j + 1) • X ^ (i * (j + 1))) = 0 by
132+
∏ i ∈ s, (coeff (g i)) (1 + ∑' j, f i (j + 1) • X ^ (i * (j + 1)) : R⟦X⟧) = 0 := by
133+
suffices ∃ i ∈ s, (coeff (g i)) ((1 : R⟦X⟧) + ∑' j, f i (j + 1) • X ^ (i * (j + 1))) = 0 by
137134
obtain ⟨i, hi, hi'⟩ := this
138-
apply Finset.prod_eq_zero hi hi'
135+
apply prod_eq_zero hi hi'
139136
contrapose! hg' with hprod
140137
rw [Set.mem_range]
141138
have hgne0 (i : ℕ) : g i ≠ 0 ↔ i ≠ 0 ∧ i ≤ g i := by
142139
refine ⟨fun h ↦ ⟨?_, ?_⟩, by grind⟩
143140
· contrapose! hs0 with rfl
144-
exact Finset.mem_of_subset (Finset.mem_finsuppAntidiag.mp hg).2 (by simpa using h)
141+
exact mem_of_subset (mem_finsuppAntidiag.mp hg).2 (by simpa using h)
145142
· exact Nat.le_of_dvd (Nat.pos_of_ne_zero h) <| aux_dvd_of_coeff_ne_zero hs0 hg hprod _
146143
refine ⟨Nat.Partition.mk (Finsupp.mk g.support (fun i ↦ g i / i) ?_).toMultiset ?_ ?_, ?_⟩
147144
· simpa using hgne0
148145
· suffices ∀ i, g i ≠ 0 → i ≠ 0 by simpa [Nat.pos_iff_ne_zero]
149146
exact fun i h ↦ ((hgne0 i).mp h).1
150-
· obtain ⟨h1, h2⟩ := Finset.mem_finsuppAntidiag.mp hg
147+
· obtain ⟨h1, h2⟩ := mem_finsuppAntidiag.mp hg
151148
refine Eq.trans ?_ h1
152149
suffices ∑ x ∈ g.support, g x / x * x = ∑ x ∈ s, g x by simpa [Finsupp.sum]
153-
apply Finset.sum_subset_zero_on_sdiff h2 (by simp)
150+
apply sum_subset_zero_on_sdiff h2 (by simp)
154151
exact fun x hx ↦ Nat.div_mul_cancel <| aux_dvd_of_coeff_ne_zero hs0 hg hprod x
155152
· ext x
156153
simpa [toFinsuppAntidiag] using Nat.div_mul_cancel <| aux_dvd_of_coeff_ne_zero hs0 hg hprod x
157154

158-
private theorem aux_prod_f_eq_prod_coeff (f : ℕ → ℕ → M) {n : ℕ} (p : Partition n) {s : Finset ℕ}
159-
(hs : Finset.Icc 1 n ⊆ s) (hs0 : 0 ∉ s) :
155+
private theorem aux_prod_f_eq_prod_coeff (f : ℕ → ℕ → R) {n : ℕ} (p : Partition n) {s : Finset ℕ}
156+
(hs : Icc 1 n ⊆ s) (hs0 : 0 ∉ s) :
160157
∏ i ∈ p.parts.toFinset, f i (Multiset.count i p.parts) =
161158
∏ i ∈ s, coeff (p.toFinsuppAntidiag i) (1 + ∑' j, f i (j + 1) • X ^ (i * (j + 1))) := by
162-
apply Finset.prod_subset_one_on_sdiff
163-
· grind [Multiset.mem_toFinset, Finset.mem_Icc, → parts_pos]
159+
apply prod_subset_one_on_sdiff
160+
· grind [Multiset.mem_toFinset, mem_Icc, → parts_pos]
164161
· intro x hx
165-
rw [Finset.mem_sdiff, Multiset.mem_toFinset] at hx
162+
rw [mem_sdiff, Multiset.mem_toFinset] at hx
166163
have hx0 : x ≠ 0 := fun h ↦ hs0 (h ▸ hx.1)
167164
have hsum := (summable_genFun_term' f hx0).map_tsum _
168-
(WithPiTopology.continuous_constantCoeff M)
165+
(WithPiTopology.continuous_constantCoeff R)
169166
simp [toFinsuppAntidiag, hsum, hx.2, hx0]
170167
· intro i hi
171168
rw [Multiset.mem_toFinset] at hi
@@ -182,23 +179,22 @@ private theorem aux_prod_f_eq_prod_coeff (f : ℕ → ℕ → M) {n : ℕ} (p :
182179
rw [mul_comm i, (mul_left_inj' (Nat.ne_zero_of_lt (p.parts_pos hi))).ne]
183180
grind
184181

185-
theorem hasProd_genFun (f : ℕ → ℕ → M) :
182+
theorem hasProd_genFun (f : ℕ → ℕ → R) :
186183
HasProd (fun i ↦ 1 + ∑' j, f (i + 1) (j + 1) • X ^ ((i + 1) * (j + 1))) (genFun f) := by
187184
rw [HasProd, WithPiTopology.tendsto_iff_coeff_tendsto]
188-
refine fun d ↦ tendsto_atTop_of_eventually_const (fun s (hs : s ≥ Finset.range d) ↦ ?_)
189-
have : ∏ i ∈ s, ((1 : M⟦X⟧) + ∑' j, f (i + 1) (j + 1) • X ^ ((i + 1) * (j + 1)))
190-
= ∏ i ∈ s.map (addRightEmbedding 1), (1 + ∑' j, f i (j + 1) • X ^ (i * (j + 1))) := by
191-
simp
185+
refine fun d ↦ tendsto_atTop_of_eventually_const (fun s (hs : s ≥ range d) ↦ ?_)
186+
have : ∏ i ∈ s, ((1 : R⟦X⟧) + ∑' j, f (i + 1) (j + 1) • X ^ ((i + 1) * (j + 1)))
187+
= ∏ i ∈ s.map (addRightEmbedding 1), (1 + ∑' j, f i (j + 1) • X ^ (i * (j + 1))) := by simp
192188
rw [this]
193-
have hs : Finset.Icc 1 d ⊆ s.map (addRightEmbedding 1) := by
189+
have hs : Icc 1 d ⊆ s.map (addRightEmbedding 1) := by
194190
intro i
195191
suffices 1 ≤ i → i ≤ d → ∃ a ∈ s, a + 1 = i by simpa
196192
intro h1 h2
197-
refine ⟨i - 1, Finset.mem_of_subset hs ?_, ?_⟩ <;> grind
193+
refine ⟨i - 1, mem_of_subset hs ?_, ?_⟩ <;> grind
198194
rw [genFun, coeff_mk, coeff_prod]
199-
refine (Finset.sum_of_injOn toFinsuppAntidiag (toFinsuppAntidiag_injective d).injOn ?_ ?_ ?_).symm
200-
· refine (Set.mapsTo_range _ _).mono_right ((range_toFinsuppAntidiag d).trans ?_)
201-
simpa using Finset.finsuppAntidiag_mono hs.le _
195+
refine (sum_of_injOn toFinsuppAntidiag (toFinsuppAntidiag_injective d).injOn ?_ ?_ ?_).symm
196+
· intro p _
197+
exact mem_of_subset (finsuppAntidiag_mono hs.le _) p.toFinsuppAntidiag_mem_finsuppAntidiag
202198
· exact fun g hg hg' ↦ aux_prod_coeff_eq_zero_of_notMem_range f (by simp) hg (by simpa using hg')
203199
· exact fun p _ ↦ aux_prod_f_eq_prod_coeff f p hs.le (by simp)
204200

0 commit comments

Comments
 (0)