Skip to content

Commit 82c6032

Browse files
committed
feat: Better lemmas for transferring finite sums along equivalences (#9237)
Lemmas around this were a mess, throth in terms of names, statement and location. This PR standardises everything to be in `Algebra.BigOperators.Basic` and changes the lemmas to take in `InjOn` and `SurjOn` assumptions where possible (and where impossible make sure the hypotheses are taken in the correct order) and moves the equality of functions hypothesis last. Also add a few lemmas that help fix downstream uses by golfing. From LeanAPAP and LeanCamCombi
1 parent 7b59a5f commit 82c6032

38 files changed

+493
-632
lines changed

Mathlib/Algebra/BigOperators/Basic.lean

Lines changed: 227 additions & 117 deletions
Large diffs are not rendered by default.

Mathlib/Algebra/BigOperators/Finprod.lean

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1240,14 +1240,10 @@ theorem finprod_mem_finset_product' [DecidableEq α] [DecidableEq β] (s : Finse
12401240
(f : α × β → M) :
12411241
(∏ᶠ (ab) (_ : ab ∈ s), f ab) =
12421242
∏ᶠ (a) (b) (_ : b ∈ (s.filter fun ab => Prod.fst ab = a).image Prod.snd), f (a, b) := by
1243-
have :
1244-
∀ a,
1245-
(∏ i : β in (s.filter fun ab => Prod.fst ab = a).image Prod.snd, f (a, i)) =
1246-
(Finset.filter (fun ab => Prod.fst ab = a) s).prod f := by
1247-
refine' fun a => Finset.prod_bij (fun b _ => (a, b)) _ _ _ _ <;> simp
1248-
suffices ∀ a' b, (a', b) ∈ s → a' = a → (a, b) ∈ s ∧ a' = a by simpa
1249-
rintro a' b hp rfl
1250-
exact ⟨hp, rfl⟩
1243+
have (a) :
1244+
∏ i in (s.filter fun ab => Prod.fst ab = a).image Prod.snd, f (a, i) =
1245+
(s.filter (Prod.fst · = a)).prod f := by
1246+
refine Finset.prod_nbij' (fun b ↦ (a, b)) Prod.snd ?_ ?_ ?_ ?_ ?_ <;> aesop
12511247
rw [finprod_mem_finset_eq_prod]
12521248
simp_rw [finprod_mem_finset_eq_prod, this]
12531249
rw [finprod_eq_prod_of_mulSupport_subset _

Mathlib/Algebra/BigOperators/Finsupp.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -645,7 +645,7 @@ lemma indicator_eq_sum_attach_single [AddCommMonoid M] {s : Finset α} (f : ∀
645645

646646
lemma indicator_eq_sum_single [AddCommMonoid M] (s : Finset α) (f : α → M) :
647647
indicator s (fun x _ ↦ f x) = ∑ x in s, single x (f x) :=
648-
(indicator_eq_sum_attach_single _).trans <| sum_attach (f := fun x ↦ single x (f x))
648+
(indicator_eq_sum_attach_single _).trans <| sum_attach _ fun x ↦ single x (f x)
649649

650650
@[to_additive (attr := simp)]
651651
lemma prod_indicator_index_eq_prod_attach [Zero M] [CommMonoid N]
@@ -661,7 +661,7 @@ lemma prod_indicator_index_eq_prod_attach [Zero M] [CommMonoid N]
661661
lemma prod_indicator_index [Zero M] [CommMonoid N]
662662
{s : Finset α} (f : α → M) {h : α → M → N} (h_zero : ∀ a ∈ s, h a 0 = 1) :
663663
(indicator s (fun x _ ↦ f x)).prod h = ∏ x in s, h x (f x) :=
664-
(prod_indicator_index_eq_prod_attach _ h_zero).trans <| prod_attach (f := fun x ↦ h x (f x))
664+
(prod_indicator_index_eq_prod_attach _ h_zero).trans <| prod_attach _ fun x ↦ h x (f x)
665665

666666
lemma sum_cons [AddCommMonoid M] (n : ℕ) (σ : Fin n →₀ M) (i : M) :
667667
(sum (cons i σ) fun _ e ↦ e) = i + sum σ (fun _ e ↦ e) := by

Mathlib/Algebra/BigOperators/Intervals.lean

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,10 +123,8 @@ theorem sum_Ico_Ico_comm {M : Type*} [AddCommMonoid M] (a b : ℕ) (f : ℕ →
123123
(∑ i in Finset.Ico a b, ∑ j in Finset.Ico i b, f i j) =
124124
∑ j in Finset.Ico a b, ∑ i in Finset.Ico a (j + 1), f i j := by
125125
rw [Finset.sum_sigma', Finset.sum_sigma']
126-
refine'
127-
Finset.sum_bij' (fun (x : Σ _ : ℕ, ℕ) _ => (⟨x.2, x.1⟩ : Σ _ : ℕ, ℕ)) _ (fun _ _ => rfl)
128-
(fun (x : Σ _ : ℕ, ℕ) _ => (⟨x.2, x.1⟩ : Σ _ : ℕ, ℕ)) _ (by (rintro ⟨⟩ _; rfl))
129-
(by (rintro ⟨⟩ _; rfl)) <;>
126+
refine' sum_nbij' (fun x ↦ ⟨x.2, x.1⟩) (fun x ↦ ⟨x.2, x.1⟩) _ _ (fun _ _ ↦ rfl) (fun _ _ ↦ rfl)
127+
(fun _ _ ↦ rfl) <;>
130128
simp only [Finset.mem_Ico, Sigma.forall, Finset.mem_sigma] <;>
131129
rintro a b ⟨⟨h₁, h₂⟩, ⟨h₃, h₄⟩⟩ <;>
132130
refine' ⟨⟨_, _⟩, ⟨_, _⟩⟩ <;>

Mathlib/Algebra/BigOperators/Ring.lean

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -140,23 +140,18 @@ theorem prod_add [DecidableEq α] (f g : α → β) (s : Finset α) :
140140
prod_sum
141141
_ = ∑ t in s.powerset, (∏ a in t, f a) * ∏ a in s \ t, g a :=
142142
sum_bij'
143-
(fun f _ => s.filter (fun a => ∀ h : a ∈ s, f a h))
144-
(by simp)
145-
(fun a _ => by
146-
rw [prod_ite]
147-
congr 1
148-
exact prod_bij'
149-
(fun a _ => a.1) (by simp) (by simp)
150-
(fun a ha => ⟨a, (mem_filter.1 ha).1⟩) (fun a ha => by simp at ha; simp; tauto)
151-
(by simp) (by simp)
152-
exact prod_bij'
153-
(fun a _ => a.1) (by simp) (by simp)
154-
(fun a ha => ⟨a, (mem_sdiff.1 ha).1⟩) (fun a ha => by simp at ha; simp; tauto)
155-
(by simp) (by simp))
143+
(fun f _ ↦ s.filter fun a ↦ ∃ h : a ∈ s, f a h)
156144
(fun t _ a _ => a ∈ t)
145+
(by simp)
157146
(by simp [Classical.em])
158147
(by simp_rw [mem_filter, Function.funext_iff, eq_iff_iff, mem_pi, mem_insert]; tauto)
159148
(by simp_rw [ext_iff, @mem_filter _ _ (id _), mem_powerset]; tauto)
149+
(fun a _ ↦ by
150+
simp only [prod_ite, filter_attach', prod_map, Function.Embedding.coeFn_mk,
151+
Subtype.map_coe, id_eq, prod_attach, filter_congr_decidable]
152+
congr 2 with x
153+
simp only [mem_filter, mem_sdiff, not_and, not_exists, and_congr_right_iff]
154+
tauto)
160155
#align finset.prod_add Finset.prod_add
161156

162157
/-- `∏ i, (f i + g i) = (∏ i, f i) + ∑ i, g i * (∏ j < i, f j + g j) * (∏ j > i, f j)`. -/

Mathlib/Algebra/Tropical/BigOperators.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,5 +142,5 @@ theorem untrop_sum [ConditionallyCompleteLinearOrder R] [Fintype S] (f : S → T
142142
as it is simply not true on conditionally complete lattices! -/
143143
theorem Finset.untrop_sum [ConditionallyCompleteLinearOrder R] (s : Finset S)
144144
(f : S → Tropical (WithTop R)) : untrop (∑ i in s, f i) = ⨅ i : s, untrop (f i) := by
145-
simpa [← _root_.untrop_sum] using sum_attach.symm
145+
simpa [← _root_.untrop_sum] using (sum_attach _ _).symm
146146
#align finset.untrop_sum Finset.untrop_sum

Mathlib/AlgebraicTopology/AlternatingFaceMapComplex.lean

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -90,17 +90,8 @@ theorem d_squared (n : ℕ) : objD X (n + 1) ≫ objD X n = 0 := by
9090
simp only [Finset.mem_univ, Finset.compl_filter, Finset.mem_filter, true_and_iff, Fin.val_succ,
9191
Fin.coe_castLT] at hij ⊢
9292
linarith
93-
· -- identification of corresponding terms in both sums
94-
rintro ⟨i, j⟩ hij
95-
dsimp
96-
simp only [zsmul_comp, comp_zsmul, smul_smul, ← neg_smul]
97-
congr 1
98-
· simp only [Fin.val_succ, pow_add, pow_one, mul_neg, neg_neg, mul_one]
99-
apply mul_comm
100-
· rw [CategoryTheory.SimplicialObject.δ_comp_δ'']
101-
simpa using hij
10293
· -- φ : S → Sᶜ is injective
103-
rintro ⟨i, j⟩ ⟨i', j'⟩ hij hij' h
94+
rintro ⟨i, j⟩ hij ⟨i', j'⟩ hij' h
10495
rw [Prod.mk.inj_iff]
10596
exact ⟨by simpa using congr_arg Prod.snd h,
10697
by simpa [Fin.castSucc_castLT] using congr_arg Fin.castSucc (congr_arg Prod.fst h)⟩
@@ -114,6 +105,15 @@ theorem d_squared (n : ℕ) : objD X (n + 1) ≫ objD X n = 0 := by
114105
· simpa only [Finset.mem_univ, forall_true_left, Prod.forall, ge_iff_le, Finset.mem_filter,
115106
Fin.coe_castSucc, Fin.coe_pred, true_and] using Nat.le_sub_one_of_lt hij'
116107
· simp only [Fin.castLT_castSucc, Fin.succ_pred]
108+
· -- identification of corresponding terms in both sums
109+
rintro ⟨i, j⟩ hij
110+
dsimp
111+
simp only [zsmul_comp, comp_zsmul, smul_smul, ← neg_smul]
112+
congr 1
113+
· simp only [Fin.val_succ, pow_add, pow_one, mul_neg, neg_neg, mul_one]
114+
apply mul_comm
115+
· rw [CategoryTheory.SimplicialObject.δ_comp_δ'']
116+
simpa using hij
117117
#align algebraic_topology.alternating_face_map_complex.d_squared AlgebraicTopology.AlternatingFaceMapComplex.d_squared
118118

119119
/-!

Mathlib/Analysis/Analytic/Composition.lean

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -616,7 +616,7 @@ def compPartialSumTargetSet (m M N : ℕ) : Set (Σ n, Composition n) :=
616616

617617
theorem compPartialSumTargetSet_image_compPartialSumSource (m M N : ℕ)
618618
(i : Σ n, Composition n) (hi : i ∈ compPartialSumTargetSet m M N) :
619-
∃ (j : _) (hj : j ∈ compPartialSumSource m M N), i = compChangeOfVariables m M N j hj := by
619+
∃ (j : _) (hj : j ∈ compPartialSumSource m M N), compChangeOfVariables m M N j hj = i := by
620620
rcases i with ⟨n, c⟩
621621
refine' ⟨⟨c.length, c.blocksFun⟩, _, _⟩
622622
· simp only [compPartialSumTargetSet, Set.mem_setOf_eq] at hi
@@ -625,7 +625,7 @@ theorem compPartialSumTargetSet_image_compPartialSumSource (m M N : ℕ)
625625
· dsimp [compChangeOfVariables]
626626
rw [Composition.sigma_eq_iff_blocks_eq]
627627
simp only [Composition.blocksFun, Composition.blocks, Subtype.coe_eta, List.get_map]
628-
conv_lhs => rw [← List.ofFn_get c.blocks]
628+
conv_rhs => rw [← List.ofFn_get c.blocks]
629629
#align formal_multilinear_series.comp_partial_sum_target_subset_image_comp_partial_sum_source FormalMultilinearSeries.compPartialSumTargetSet_image_compPartialSumSource
630630

631631
/-- Target set in the change of variables to compute the composition of partial sums of formal
@@ -665,11 +665,8 @@ theorem compChangeOfVariables_sum {α : Type*} [AddCommMonoid α] (m M N : ℕ)
665665
map_ofFn, length_ofFn, true_and_iff, compChangeOfVariables]
666666
intro j
667667
simp only [Composition.blocksFun, (H.right _).right, List.get_ofFn]
668-
-- 2 - show that the composition gives the `comp_along_composition` application
669-
· rintro ⟨k, blocks_fun⟩ H
670-
rw [h]
671-
-- 3 - show that the map is injective
672-
· rintro ⟨k, blocks_fun⟩ ⟨k', blocks_fun'⟩ H H' heq
668+
-- 2 - show that the map is injective
669+
· rintro ⟨k, blocks_fun⟩ H ⟨k', blocks_fun'⟩ H' heq
673670
obtain rfl : k = k' := by
674671
have := (compChangeOfVariables_length m M N H).symm
675672
rwa [heq, compChangeOfVariables_length] at this
@@ -682,10 +679,13 @@ theorem compChangeOfVariables_sum {α : Type*} [AddCommMonoid α] (m M N : ℕ)
682679
apply Composition.blocksFun_congr <;>
683680
first | rw [heq] | rfl
684681
_ = blocks_fun' i := compChangeOfVariables_blocksFun m M N H' i
685-
-- 4 - show that the map is surjective
682+
-- 3 - show that the map is surjective
686683
· intro i hi
687684
apply compPartialSumTargetSet_image_compPartialSumSource m M N i
688685
simpa [compPartialSumTarget] using hi
686+
-- 4 - show that the composition gives the `comp_along_composition` application
687+
· rintro ⟨k, blocks_fun⟩ H
688+
rw [h]
689689
#align formal_multilinear_series.comp_change_of_variables_sum FormalMultilinearSeries.compChangeOfVariables_sum
690690

691691
/-- The auxiliary set corresponding to the composition of partial sums asymptotically contains

Mathlib/Combinatorics/Configuration.lean

Lines changed: 12 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ Together, these four statements say that any two of the following properties imp
3535
-/
3636

3737

38-
open BigOperators
38+
open Finset
39+
open scoped BigOperators
3940

4041
namespace Configuration
4142

@@ -234,17 +235,11 @@ theorem HasLines.card_le [HasLines P L] [Fintype P] [Fintype L] :
234235
∑ p, lineCount L p = ∑ l, pointCount P l := sum_lineCount_eq_sum_pointCount P L
235236
_ ≤ ∑ l, lineCount L (f l) :=
236237
(Finset.sum_le_sum fun l _ => HasLines.pointCount_le_lineCount (hf₂ l))
237-
_ = ∑ p in Finset.univ.image f, lineCount L p :=
238-
(Finset.sum_bij (fun l _ => f l) (fun l hl => Finset.mem_image_of_mem f hl)
239-
(fun l _ => rfl) (fun l₁ l₂ hl₁ hl₂ hl₃ => hf₁ hl₃) fun p => by
240-
rw [Finset.mem_image]
241-
exact fun ⟨a, ⟨h, h'⟩⟩ => ⟨a, ⟨h, h'.symm⟩⟩)
238+
_ = ∑ p in univ.map ⟨f, hf₁⟩, lineCount L p := by rw [sum_map]; dsimp
242239
_ < ∑ p, lineCount L p := by
243240
obtain ⟨p, hp⟩ := not_forall.mp (mt (Fintype.card_le_of_surjective f) hc₂)
244-
refine'
245-
Finset.sum_lt_sum_of_subset (Finset.univ.image f).subset_univ (Finset.mem_univ p) _ _
246-
fun p _ _ => zero_le (lineCount L p)
247-
· simpa only [Finset.mem_image, exists_prop, Finset.mem_univ, true_and_iff]
241+
refine sum_lt_sum_of_subset (subset_univ _) (mem_univ p) ?_ ?_ fun p _ _ ↦ zero_le _
242+
· simpa only [Finset.mem_map, exists_prop, Finset.mem_univ, true_and_iff]
248243
· rw [lineCount, Nat.card_eq_fintype_card, Fintype.card_pos_iff]
249244
obtain ⟨l, _⟩ := @exists_line P L _ _ p
250245
exact
@@ -267,16 +262,8 @@ theorem HasLines.exists_bijective_of_card_eq [HasLines P L] [Fintype P] [Fintype
267262
classical
268263
obtain ⟨f, hf1, hf2⟩ := Nondegenerate.exists_injective_of_card_le (ge_of_eq h)
269264
have hf3 := (Fintype.bijective_iff_injective_and_card f).mpr ⟨hf1, h.symm⟩
270-
refine'
271-
⟨f, hf3, fun l =>
272-
(Finset.sum_eq_sum_iff_of_le fun l _ => HasLines.pointCount_le_lineCount (hf2 l)).mp
273-
((sum_lineCount_eq_sum_pointCount P L).symm.trans
274-
(Finset.sum_bij (fun l _ => f l) (fun l _ => Finset.mem_univ (f l))
275-
(fun l _ => refl (lineCount L (f l))) (fun l₁ l₂ hl₁ hl₂ hl => hf1 hl) fun p hp =>
276-
_).symm)
277-
l (Finset.mem_univ l)⟩
278-
obtain ⟨l, rfl⟩ := hf3.2 p
279-
exact ⟨l, Finset.mem_univ l, rfl⟩
265+
exact ⟨f, hf3, fun l ↦ (sum_eq_sum_iff_of_le fun l _ ↦ pointCount_le_lineCount (hf2 l)).1
266+
((hf3.sum_comp _).trans (sum_lineCount_eq_sum_pointCount P L)).symm _ $ mem_univ _⟩
280267
#align configuration.has_lines.exists_bijective_of_card_eq Configuration.HasLines.exists_bijective_of_card_eq
281268

282269
theorem HasLines.lineCount_eq_pointCount [HasLines P L] [Fintype P] [Fintype L]
@@ -290,15 +277,11 @@ theorem HasLines.lineCount_eq_pointCount [HasLines P L] [Fintype P] [Fintype L]
290277
simp_rw [Finset.sum_const, Finset.card_univ, hPL, sum_lineCount_eq_sum_pointCount]
291278
have step2 : ∑ i in s, lineCount L i.1 = ∑ i in s, pointCount P i.2 := by
292279
rw [s.sum_finset_product Finset.univ fun p => Set.toFinset { l | p ∈ l }]
293-
rw [s.sum_finset_product_right Finset.univ fun l => Set.toFinset { p | p ∈ l }]
294-
refine'
295-
(Finset.sum_bij (fun l _ => f l) (fun l _ => Finset.mem_univ (f l)) (fun l hl => _)
296-
(fun _ _ _ _ h => hf1.1 h) fun p _ => _).symm
297-
· simp_rw [Finset.sum_const, Set.toFinset_card, ← Nat.card_eq_fintype_card]
298-
change pointCount P l • pointCount P l = lineCount L (f l) • lineCount L (f l)
299-
rw [hf2]
300-
· obtain ⟨l, hl⟩ := hf1.2 p
301-
exact ⟨l, Finset.mem_univ l, hl.symm⟩
280+
rw [s.sum_finset_product_right Finset.univ fun l => Set.toFinset { p | p ∈ l }, eq_comm]
281+
refine sum_bijective _ hf1 (by simp) fun l _ ↦ ?_
282+
simp_rw [hf2, sum_const, Set.toFinset_card, ← Nat.card_eq_fintype_card]
283+
change pointCount P l • _ = lineCount L (f l) • _
284+
rw [hf2]
302285
all_goals simp_rw [Finset.mem_univ, true_and_iff, Set.mem_toFinset]; exact fun p => Iff.rfl
303286
have step3 : ∑ i in sᶜ, lineCount L i.1 = ∑ i in sᶜ, pointCount P i.2 := by
304287
rwa [← s.sum_add_sum_compl, ← s.sum_add_sum_compl, step2, add_left_cancel_iff] at step1

Mathlib/Data/Complex/Exponential.lean

Lines changed: 9 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -187,31 +187,12 @@ theorem sum_range_diag_flip {α : Type*} [AddCommMonoid α] (n : ℕ) (f : ℕ
187187
(∑ m in range n, ∑ k in range (m + 1), f k (m - k)) =
188188
∑ m in range n, ∑ k in range (n - m), f m k := by
189189
rw [sum_sigma', sum_sigma']
190-
exact
191-
sum_bij (fun a _ => ⟨a.2, a.1 - a.2⟩)
192-
(fun a ha =>
193-
have h₁ : a.1 < n := mem_range.1 (mem_sigma.1 ha).1
194-
have h₂ : a.2 < Nat.succ a.1 := mem_range.1 (mem_sigma.1 ha).2
195-
mem_sigma.2
196-
⟨mem_range.2 (lt_of_lt_of_le h₂ h₁),
197-
mem_range.2 ((tsub_lt_tsub_iff_right (Nat.le_of_lt_succ h₂)).2 h₁)⟩)
198-
(fun _ _ => rfl)
199-
(fun ⟨a₁, a₂⟩ ⟨b₁, b₂⟩ ha hb h =>
200-
have ha : a₁ < n ∧ a₂ ≤ a₁ :=
201-
⟨mem_range.1 (mem_sigma.1 ha).1, Nat.le_of_lt_succ (mem_range.1 (mem_sigma.1 ha).2)⟩
202-
have hb : b₁ < n ∧ b₂ ≤ b₁ :=
203-
⟨mem_range.1 (mem_sigma.1 hb).1, Nat.le_of_lt_succ (mem_range.1 (mem_sigma.1 hb).2)⟩
204-
have h : a₂ = b₂ ∧ _ := by simpa using h
205-
have h' : a₁ = b₁ - b₂ + a₂ := (tsub_eq_iff_eq_add_of_le ha.2).1 (eq_of_heq h.2)
206-
Sigma.mk.inj_iff.2 ⟨tsub_add_cancel_of_le hb.2 ▸ h'.symm ▸ h.1 ▸ rfl, heq_of_eq h.1⟩)
207-
fun ⟨a₁, a₂⟩ ha =>
208-
have ha : a₁ < n ∧ a₂ < n - a₁ :=
209-
⟨mem_range.1 (mem_sigma.1 ha).1, mem_range.1 (mem_sigma.1 ha).2
210-
⟨⟨a₂ + a₁, a₁⟩,
211-
⟨mem_sigma.2
212-
⟨mem_range.2 (lt_tsub_iff_right.1 ha.2),
213-
mem_range.2 (Nat.lt_succ_of_le (Nat.le_add_left _ _))⟩,
214-
Sigma.mk.inj_iff.2 ⟨rfl, heq_of_eq (add_tsub_cancel_right _ _).symm⟩⟩⟩
190+
refine sum_nbij' (fun a ↦ ⟨a.2, a.1 - a.2⟩) (fun a ↦ ⟨a.1 + a.2, a.1⟩) ?_ ?_ ?_ ?_ ?_ <;>
191+
simp (config := { contextual := true }) only [mem_sigma, mem_range, lt_tsub_iff_left,
192+
Nat.lt_succ_iff, le_add_iff_nonneg_right, zero_le, and_true, and_imp, imp_self, implies_true,
193+
Sigma.forall, forall_const, add_tsub_cancel_of_le, Sigma.mk.inj_iff,
194+
add_tsub_cancel_left, heq_eq_eq]
195+
· exact fun a b han hba ↦ lt_of_le_of_lt hba han
215196
#align sum_range_diag_flip sum_range_diag_flip
216197

217198
end
@@ -1602,20 +1583,9 @@ theorem sum_div_factorial_le {α : Type*} [LinearOrderedField α] (n j : ℕ) (h
16021583
(1 / m.factorial : α)) ≤ n.succ / (n.factorial * n) :=
16031584
calc
16041585
(∑ m in filter (fun k => n ≤ k) (range j), (1 / m.factorial : α)) =
1605-
∑ m in range (j - n), (1 / ((m + n).factorial : α)) :=
1606-
sum_bij (fun m _ => m - n)
1607-
(fun m hm =>
1608-
mem_range.2 <|
1609-
(tsub_lt_tsub_iff_right (by simp at hm; tauto)).2 (by simp at hm; tauto))
1610-
(fun m hm => by rw [tsub_add_cancel_of_le]; simp at *; tauto)
1611-
(fun a₁ a₂ ha₁ ha₂ h => by
1612-
rwa [tsub_eq_iff_eq_add_of_le, tsub_add_eq_add_tsub, eq_comm, tsub_eq_iff_eq_add_of_le,
1613-
add_left_inj, eq_comm] at h <;>
1614-
simp at * <;> aesop)
1615-
fun b hb =>
1616-
⟨b + n,
1617-
mem_filter.2 ⟨mem_range.2 <| lt_tsub_iff_right.mp (mem_range.1 hb), Nat.le_add_left _ _⟩,
1618-
by dsimp; rw [add_tsub_cancel_right]⟩
1586+
∑ m in range (j - n), (1 / ((m + n).factorial : α)) := by
1587+
refine sum_nbij' (· - n) (· + n) ?_ ?_ ?_ ?_ ?_ <;>
1588+
simp (config := { contextual := true }) [lt_tsub_iff_right, tsub_add_cancel_of_le]
16191589
_ ≤ ∑ m in range (j - n), ((n.factorial : α) * (n.succ : α) ^ m)⁻¹ := by
16201590
simp_rw [one_div]
16211591
gcongr

0 commit comments

Comments
 (0)