Skip to content

Instantly share code, notes, and snippets.

@ValeZAA
Created February 16, 2025 10:18
Show Gist options
  • Save ValeZAA/2217d8d2d41a97f932ee5cc17c6e1a10 to your computer and use it in GitHub Desktop.
Save ValeZAA/2217d8d2d41a97f932ee5cc17c6e1a10 to your computer and use it in GitHub Desktop.
Deepseek R1 chain of thought for Lean 4 proof
Formalize in Lean 4 that every grouping of convergent series is convergent to the the same sum. Grouping is not a rearrangement.
Okay, so I need to formalize in Lean 4 that every grouping of a convergent series is convergent to the same sum. And the user mentioned that grouping is not a rearrangement. Hmm. Let me start by recalling what this means in real analysis.
First, a convergent series means that the partial sums approach a specific limit. Grouping here refers to adding parentheses around certain terms, creating a new series where each term is the sum of a group of original terms. For example, if the original series is a₁ + aβ‚‚ + a₃ + aβ‚„ + ..., a grouping might be (a₁ + aβ‚‚) + (a₃ + aβ‚„) + ..., forming a new series with terms b₁ = a₁ + aβ‚‚, bβ‚‚ = a₃ + aβ‚„, etc. The theorem states that if the original series converges to sum S, then the grouped series also converges to S, provided that the grouping doesn't rearrange the terms, just adds parentheses.
So, to formalize this in Lean 4, I need to work with the definitions of series convergence and groupings. Let me recall that in mathlib, the convergence of a series is typically represented by the convergence of the partial sums. So, for a series `βˆ‘' n, a n`, the partial sums are `fun n => βˆ‘ i in finset.range n, a i`, and `has_sum a S` means that the limit of these partial sums is S.
A grouping would involve taking a sequence of indices where the groups end. For example, if the original series is indexed by β„•, a grouping might be defined by a strictly increasing sequence of natural numbers `k : β„• β†’ β„•` starting at 0, such that each group is the sum from `k n` to `k (n+1) - 1` of the terms a i. Then, the grouped series would be `βˆ‘' n, βˆ‘ i in finset.Ico (k n) (k (n+1)), a i`.
The key point is that if the original series converges to S, then the grouped series also converges to S. To prove this, one would note that the partial sums of the grouped series are a subsequence of the original partial sums. Since the original partial sums converge to S, any subsequence also converges to S. Wait, but is that accurate?
Wait, let me think. Suppose the original partial sums are sβ‚€, s₁, sβ‚‚, s₃, ..., and the grouped partial sums are s_{kβ‚€}, s_{k₁}, s_{kβ‚‚}, ... where kβ‚€, k₁, kβ‚‚, ... are the indices where the groups end. Then, if the original partial sums converge to S, then every subsequence of the partial sums, including the grouped ones, should also converge to S. Therefore, the grouped series must converge to S as well.
But is there a condition on the grouping? The grouping must be such that the group sizes are finite, right? Because if you have infinitely many terms in a group, that would change things. But in the standard theorem, groupings are finite. So each group consists of a finite number of terms. Therefore, the sequence k n must be strictly increasing and cover all natural numbers, so that every term in the original series is included in exactly one group.
So, formalizing this, we can define a grouping as a function k : β„• β†’ β„• where k 0 = 0, and for all n, k n < k (n+1). Then, each term of the grouped series is the sum from i = k n to k (n+1) - 1 of a i. The partial sums of the grouped series would then be s_{k n}, where s_n is the original partial sum. Since s_n β†’ S, then s_{k n} also β†’ S because it's a subsequence.
Therefore, the theorem is that if the original series converges to S, then the grouped series (defined by any such k) also converges to S.
Now, to formalize this in Lean 4, I need to express these concepts. Let's see. In mathlib4, the `HasSum` predicate is used to denote that a series has a certain sum. So, given `a : β„• β†’ Ξ±` where `Ξ±` is a topological space (like a normed vector space), `HasSum a S` means that the partial sums converge to S.
So, the statement would be: If `HasSum a S`, then for any increasing sequence `k : β„• β†’ β„•` with `k 0 = 0` and `βˆ€ n, k n < k (n + 1)`, then `HasSum (fun n => βˆ‘ i in Finset.Ico (k n) (k (n + 1)), a i) S`.
Wait, but `Finset.Ico` is inclusive of the start and exclusive of the end, so `Finset.Ico (k n) (k (n + 1))` gives the indices from `k n` up to `k (n + 1) - 1`, which is correct.
But in Lean, the `HasSum` for the grouped series would require that the partial sums of the grouped series converge to S. The partial sums of the grouped series up to N would be the sum of the first N groups, which corresponds to the original partial sum up to `k N - 1` (since each group ends at `k (n + 1) - 1`). Wait, no: the first group is from `k 0 = 0` to `k 1 - 1`, so the sum of the first group is sum from i=0 to k 1 - 1. The sum of the first N groups is sum from i=0 to k N - 1. Therefore, the partial sums of the grouped series at N is equal to the original partial sum at `k N - 1`. Wait, but `k N` is the starting index of the next group, so the end index of the Nth group is `k (N + 1) - 1`. Wait, maybe I'm getting confused here.
Wait, the grouped series is defined as the sum of the first group, then the sum of the first two groups, etc. The sum of the first N groups would be the sum of all terms up to the end of the Nth group. Since each group n is from `k n` to `k (n + 1) - 1`, inclusive. So the first group is n=0: from k 0 =0 to k 1 -1. The second group is n=1: from k 1 to k 2 -1, etc. Therefore, the sum of the first N groups is the sum up to index k (N + 1) -1. Wait, no: the first group (n=0) is sum up to k 1 -1. The first two groups (n=0 and n=1) are sum up to k 2 -1. Therefore, the sum of the first N groups is the original partial sum up to k N -1. Wait, but N here is the number of groups. Wait, if we have groups 0 to N-1, then the sum would be up to k N -1. Because group 0 is up to k 1 -1, group 1 is up to k 2 -1, ..., group N-1 is up to k N -1. So the partial sum of the grouped series after N groups is the original partial sum at k N -1. Therefore, the partial sums of the grouped series are s_{k 1 -1}, s_{k 2 -1}, s_{k 3 -1}, etc. But the original partial sums s_n converge to S. Therefore, the grouped partial sums are a subsequence of the original partial sums if k N -1 is a subsequence. But if k is increasing, then k N -1 is also increasing. For example, if k N = N * m for some m, then k N -1 = N * m -1. But in general, as long as k is strictly increasing, k N -1 is also strictly increasing, right? Because k (N + 1) -1 β‰₯ k N -1 +1. Because k (N + 1) > k N, so k (N + 1) -1 β‰₯ k N +1 -1 = k N. Therefore, s_{k N -1} is a subsequence of the original partial sums. Therefore, since the original partial sums converge to S, any subsequence also converges to S. Therefore, the grouped partial sums converge to S.
Wait, but in this case, the grouped partial sums are not exactly a subsequence unless k N -1 is strictly increasing. For example, if k N = N + 1, then k N -1 = N, so s_{k N -1} = s_N, which is just the original sequence. But if k N grows faster, like k N = 2N, then k N -1 = 2N -1, so the grouped partial sums are s_{2N -1}, which is a subsequence. So as long as k N -1 tends to infinity as N tends to infinity, which it does since k is strictly increasing, then the partial sums of the grouped series are a subsequence of the original partial sums. Therefore, their limit is also S.
Therefore, the key is that the partial sums of the grouped series are a subsequence of the original partial sums, hence they converge to the same limit.
Therefore, to formalize this in Lean 4, we need to show that given a series `a` that converges to `S`, and a grouping defined by `k : β„• β†’ β„•` with `k 0 = 0` and `k n < k (n + 1)` for all `n`, then the grouped series also converges to `S`.
In Lean, `HasSum` is defined for the series, not just the partial sums. So the grouped series is `fun n => βˆ‘ i in Finset.Ico (k n) (k (n + 1)), a i`, and we need to show that `HasSum (fun n => βˆ‘ i in Finset.Ico (k n) (k (n + 1)), a i) S`.
Given that `HasSum a S`, we can use the fact that the partial sums of the grouped series are the original partial sums evaluated at `k (n + 1) - 1`, which is a subsequence. Therefore, since the original partial sums tend to `S`, so does the subsequence.
But in Lean, to handle this, we need to connect the partial sums of the grouped series to the original partial sums. Let's denote the grouped series as `b`, where `b n = βˆ‘ i in Finset.Ico (k n) (k (n + 1)), a i`. Then the partial sums of `b` up to `N` is `βˆ‘ n in Finset.range (N + 1), b n`, which equals `βˆ‘ n in Finset.range (N + 1), βˆ‘ i in Finset.Ico (k n) (k (n + 1)), a i`. By interchanging the sums, this is equal to `βˆ‘ i in Finset.Ico (k 0) (k (N + 1)), a i`, since the union of `Finset.Ico (k n) (k (n + 1))` for `n` from `0` to `N` is `Finset.Ico 0 (k (N + 1))`. Because `k` is strictly increasing and starts at `0`, `k (N + 1)` is greater than `k N`, etc. Therefore, the partial sum of `b` up to `N` is equal to the original partial sum up to `k (N + 1) - 1`, but wait, actually `Finset.Ico (k 0) (k (N + 1))` is `[k 0, k (N + 1))`, which is `[0, k (N + 1))`, so the sum is `βˆ‘ i in Finset.range (k (N + 1)), a i`, since `Finset.Ico 0 m` is the same as `Finset.range m`.
Therefore, the partial sum of the grouped series `b` up to `N` is equal to the original partial sum up to `k (N + 1) - 1`. Wait, no: `Finset.Ico 0 (k (N + 1))` is `[0, k (N + 1))`, which includes all `i` such that `0 ≀ i < k (N + 1)`. So the sum is `βˆ‘ i in Finset.range (k (N + 1)), a i`, since `Finset.range (k (N + 1))` is `{0, 1, ..., k (N + 1) - 1}`. Therefore, the partial sum of the grouped series up to `N` is equal to the original partial sum up to `k (N + 1) - 1`. Therefore, the partial sums of `b` are `s (k (N + 1) - 1)`.
But in Lean, `HasSum b S` means that the limit of the partial sums of `b` as `N β†’ ∞` is `S`. Since `k (N + 1) - 1` tends to infinity as `N β†’ ∞` (because `k` is strictly increasing), and since the original partial sums `s n` tend to `S`, then `s (k (N + 1) - 1)` also tends to `S` as `N β†’ ∞`. Therefore, the partial sums of `b` converge to `S`.
So, to formalize this, we can use the fact that if `s : β„• β†’ Ξ±` is a sequence converging to `S`, then any subsequence of `s` also converges to `S`. In this case, the partial sums of `b` are a subsequence of `s` composed with the function `N ↦ k (N + 1) - 1`.
But in Lean, we need to express this. So, given `h : HasSum a S`, we can extract the partial sums from `h`, which are `fun n => βˆ‘ i in Finset.range n, a i`, and then show that the partial sums of the grouped series are `fun N => βˆ‘ i in Finset.range (k (N + 1)), a i`, which is equal to `s (k (N + 1))` where `s` is the original partial sum. Wait, no, `Finset.range (k (N + 1))` is `0` to `k (N + 1) - 1`, so the sum is `s (k (N + 1))` minus `a (k (N + 1))`? Wait, no. Wait, `s n = βˆ‘ i in Finset.range n, a i`. So `s (k (N + 1))` is the sum up to `k (N + 1) - 1`. Wait, no: `Finset.range (k (N + 1))` is `{0, 1, ..., k (N + 1) - 1}`, so the sum is `s (k (N + 1))`. But `s (k (N + 1))` is the sum up to `k (N + 1) - 1`. Wait, no: `s n = sum from i=0 to n-1 of a i`. Therefore, `s (k (N + 1))` is the sum from i=0 to `k (N + 1) - 1` of a i. Which matches the partial sum of the grouped series up to N. Therefore, the partial sums of the grouped series `b` are `fun N => s (k (N + 1))`. Therefore, since `s` converges to `S`, the subsequence `s ∘ (fun N => k (N + 1))` also converges to `S`, provided that `k (N + 1)` tends to infinity as `N` tends to infinity. Which it does, because `k` is strictly increasing.
Therefore, in Lean, we can use the lemma `Tendsto.comp` that if `s` tends to `S`, then `s ∘ f` tends to `S` as long as `f` tends to infinity. But here, `k` is a strictly increasing sequence, so `k (N + 1)` tends to infinity as `N` tends to infinity. Therefore, `s ∘ (fun N => k (N + 1))` tends to `S`.
Therefore, the partial sums of the grouped series tend to `S`, hence `HasSum b S`.
So, putting this together in Lean 4, we need to:
1. Define the grouped series `b` based on `a` and the grouping function `k`.
2. Show that the partial sums of `b` are a subsequence of the partial sums of `a`.
3. Use the fact that the original partial sums converge to `S` to conclude that the subsequence also converges to `S`.
Let me look up the relevant Lean 4 theorems. The key theorem here is that if a sequence tends to a limit, then any subsequence also tends to the same limit. In Lean, this is `Filter.Tendsto.comp` where the subsequence index function must tend to infinity. Also, for a strictly increasing function `k : β„• β†’ β„•`, the composition `s ∘ k` tends to the same limit as `s` if `s` tends to some limit.
Wait, but in our case, the partial sums of the grouped series are `s (k (N + 1))`, which is `s ∘ (fun N => k (N + 1))`. So, since `k` is strictly increasing, `fun N => k (N + 1)` is also strictly increasing, hence tends to infinity. Therefore, `s ∘ (fun N => k (N + 1))` tends to `S` as `N` tends to infinity.
Therefore, in Lean, we can use `h.tendsto_sum_nat.comp (tendsto_atTop_atTop_of_monotone' ?_)` where the blank would be a proof that `fun N => k (N + 1)` is monotone and tends to infinity. Since `k` is strictly increasing, `k (N + 1)` is also strictly increasing, hence monotone and unbounded, hence tends to infinity.
Therefore, the code would look something like:
```lean4
theorem hasSum_grouped (a : β„• β†’ Ξ±) (S : Ξ±) (k : β„• β†’ β„•) (hk : StrictMono k) (hkβ‚€ : k 0 = 0)
(h : HasSum a S) : HasSum (fun n => βˆ‘ i in Finset.Ico (k n) (k (n + 1)), a i) S := by
-- The partial sums of the grouped series are a subsequence of the original partial sums.
have h₁ : HasSum (fun n => βˆ‘ i in Finset.Ico (k n) (k (n + 1)), a i) S := by
-- The partial sums of the grouped series are the original partial sums evaluated at k (n + 1).
have hβ‚‚ : βˆ€ n, βˆ‘ i in Finset.range (k (n + 1)), a i = βˆ‘ m in Finset.range (n + 1), βˆ‘ i in Finset.Ico (k m) (k (m + 1)), a i := by
intro n
-- Prove that the sum up to k (n + 1) is the sum of the grouped series up to n.
refine' Finset.sum_range_induction _ _ _ (by simp) (fun m => _)
rw [Finset.sum_Ico_consecutive]
<;> simp [hk, hkβ‚€]
-- Use the fact that the original series converges to S to show the grouped series converges to S.
have h₃ : Tendsto (fun n => βˆ‘ i in Finset.range (k (n + 1)), a i) atTop (𝓝 S) := by
-- The sequence k (n + 1) tends to infinity, so the partial sums tend to S.
apply h.tendsto_sum_nat.comp
apply tendsto_atTop_atTop_of_monotone' _ _
Β· exact fun n m h => hk (by linarith)
Β· intro b
use b
linarith [hk (Nat.le_succ b)]
-- Convert the tendsto result to HasSum.
simpa [hβ‚‚] using h₃
exact h₁
```
Wait, let me check this. The `hβ‚‚` lemma is showing that the sum up to `k (n + 1)` is equal to the sum of the grouped series up to `n`. Then `h₃` is showing that the partial sums of the original series evaluated at `k (n + 1)` tend to `S`, which they do because `k (n + 1)` tends to infinity. Then, by rewriting using `hβ‚‚`, we get that the partial sums of the grouped series tend to `S`, hence `HasSum` holds.
But in Lean, `HasSum` is defined as the convergence of the partial sums. Therefore, by showing that the partial sums of the grouped series are equal to the original partial sums evaluated at `k (n + 1)`, which tend to `S`, we can conclude the result.
But perhaps there's a more straightforward way. Since `h : HasSum a S`, then `h.tendsto_sum_nat` is the statement that `fun n => βˆ‘ i in Finset.range n, a i` tends to `S` at infinity. Then, the partial sums of the grouped series are `fun n => βˆ‘ i in Finset.range (k (n + 1)), a i`, which is `h.tendsto_sum_nat.comp (tendsto_atTop_atTop_of_monotone' hk)`. Wait, but `tendsto_atTop_atTop_of_monotone'` requires that the function is monotone and unbounded. Since `k` is strictly increasing, it's monotone, and since `k` is strictly increasing, `k (n)` tends to infinity as `n` tends to infinity. Therefore, `fun n => k (n + 1)` is also strictly increasing and tends to infinity. Therefore, `tendsto_atTop_atTop_of_monotone'` can be applied here.
Therefore, the code could be structured as:
```lean4
theorem hasSum_grouped (a : β„• β†’ Ξ±) (S : Ξ±) (k : β„• β†’ β„•) (hk : StrictMono k) (hkβ‚€ : k 0 = 0)
(h : HasSum a S) : HasSum (fun n => βˆ‘ i in Finset.Ico (k n) (k (n + 1)), a i) S := by
-- The partial sums of the grouped series are a subsequence of the original partial sums.
have h₁ : Tendsto (fun n => βˆ‘ i in Finset.range (k (n + 1)), a i) atTop (𝓝 S) :=
h.tendsto_sum_nat.comp (tendsto_atTop_atTop_of_monotone' (fun n m hnm => hk (Nat.le_succ _ β–Έ Nat.le_succ hnm))
(fun b => ⟨b, by linarith [hk (Nat.le_succ b)]⟩))
-- Convert the tendsto result to HasSum by showing the equivalence of partial sums.
simpa [Finset.sum_range_induction _ _ (fun n => ?_)] using h₁
<;> simp [hk, hkβ‚€, Finset.sum_Ico_consecutive]
```
But perhaps I need to fill in the `simpa` line with more details. Let me think. The `simpa` tactic is used to simplify the goal using the given lemmas and then apply an assumption. Here, we need to show that the partial sums of the grouped series are equal to the original partial sums evaluated at `k (n + 1)`. The lemma `Finset.sum_range_induction` can be used to break down the sum into the grouped parts.
Alternatively, perhaps we can use `HasSum` directly by recognizing that the grouped series's partial sums match the original's at certain points. Since the partial sums of the grouped series are a subsequence converging to `S`, but `HasSum` requires the entire sequence of partial sums to converge. Wait, no, the partial sums of the grouped series are exactly the subsequence `s (k (n + 1))`. But in general, if a series has partial sums that are a subsequence of a convergent sequence, does that imply the series converges? Not necessarily. Wait, no. The partial sums of the grouped series are a subsequence, but the full sequence of partial sums for the grouped series is different. Wait, actually, no. For example, if the grouped series is defined by grouping terms, then the partial sums of the grouped series are just the sums after each group. So if you have groups of terms, the partial sum after the first group, after the second group, etc. So the partial sums of the grouped series are indeed a subsequence of the original partial sums. But in order to conclude that the grouped series converges, we need to show that its partial sums converge, which they do because they are a subsequence of a convergent sequence. Therefore, the partial sums of the grouped series converge to `S`, hence the grouped series has sum `S`.
Therefore, in Lean, the key step is to show that the partial sums of the grouped series are a subsequence of the original partial sums, hence their limit is `S`. Then, since the partial sums of the grouped series converge to `S`, `HasSum` holds.
So, putting this all together, the code would be:
```lean4
theorem hasSum_grouped (a : β„• β†’ Ξ±) (S : Ξ±) (k : β„• β†’ β„•) (hk : StrictMono k) (hkβ‚€ : k 0 = 0)
(h : HasSum a S) : HasSum (fun n => βˆ‘ i in Finset.Ico (k n) (k (n + 1)), a i) S := by
-- Show that the partial sums of the grouped series are a subsequence of the original partial sums.
have h₁ : Tendsto (fun n => βˆ‘ i in Finset.range (k (n + 1)), a i) atTop (𝓝 S) :=
h.tendsto_sum_nat.comp (tendsto_atTop_atTop_of_monotone' (fun n m hnm => hk (Nat.le_succ _ β–Έ Nat.le_succ hnm))
(fun b => ⟨b, by linarith [hk (Nat.le_succ b)]⟩))
-- Convert this tendsto result to the HasSum statement by equating the partial sums.
have hβ‚‚ : HasSum (fun n => βˆ‘ i in Finset.Ico (k n) (k (n + 1)), a i) S := by
rw [hasSum_iff_tendsto_nat_of_summable_nat]
Β· convert h₁ using 1
ext n
rw [← Finset.sum_range_induction _ _ (fun m => ?_)]
Β· simp [hk, hkβ‚€, Finset.sum_Ico_consecutive]
Β· simp [hk, hkβ‚€, Finset.sum_Ico_consecutive]
Β· -- Prove summability (not necessary if we already have convergence)
-- In this case, since we already have the tendsto result, summability is not required for the conversion.
-- However, in Lean, `hasSum_iff_tendsto_nat_of_summable_nat` requires summability.
-- This might need more work, or perhaps we can use a different lemma.
-- Alternatively, since we have the tendsto result directly, we can use `HasSum` constructor.
-- Wait, maybe `HasSum` can be directly constructed from the tendsto of partial sums.
-- In mathlib, `HasSum` is defined as the tendsto of the partial sums.
-- So if we can show the partial sums of the grouped series tend to S, then `HasSum` holds.
-- The partial sums of the grouped series are exactly `fun n => βˆ‘ i in Finset.range (k (n + 1)), a i`.
-- Therefore, `h₁` is exactly the tendsto result needed for `HasSum`.
-- So perhaps we can use:
simpa [Finset.sum_range_induction] using h₁
exact hβ‚‚
```
But I need to check the exact lemmas available in mathlib4. The lemma `hasSum_iff_tendsto_nat_of_summable_nat` might require the series to be summable, but in our case, we already know the partial sums converge to S, so we can bypass summability. Alternatively, we can use `HasSum` directly by constructing it from the tendsto result.
Alternatively, since the partial sums of the grouped series are exactly `fun n => βˆ‘ i in Finset.range (k (n + 1)), a i`, which tends to `S`, then `HasSum (fun n => βˆ‘ i in Finset.Ico (k n) (k (n + 1)), a i) S` is equivalent to this tendsto statement.
But the key point is that `βˆ‘ n in Finset.range N, βˆ‘ i in Finset.Ico (k n) (k (n + 1)), a i` equals `βˆ‘ i in Finset.range (k N), a i`. Therefore, the partial sums of the grouped series are `fun N => βˆ‘ i in Finset.range (k N), a i`, which is `s (k N)` where `s` is the original partial sum. But `k N` tends to infinity as `N` tends to infinity, so `s (k N)` tends to `S`. Therefore, the partial sums of the grouped series tend to `S`, hence `HasSum` holds.
Therefore, the code can be simplified as:
```lean4
theorem hasSum_grouped (a : β„• β†’ Ξ±) (S : Ξ±) (k : β„• β†’ β„•) (hk : StrictMono k) (hkβ‚€ : k 0 = 0)
(h : HasSum a S) : HasSum (fun n => βˆ‘ i in Finset.Ico (k n) (k (n + 1)), a i) S := by
-- The partial sums of the grouped series are the original partial sums evaluated at k (n + 1).
have h₁ : Tendsto (fun n => βˆ‘ i in Finset.range (k n), a i) atTop (𝓝 S) :=
h.tendsto_sum_nat.comp (hk.tendsto_atTop _)
-- Convert this to the HasSum statement for the grouped series.
convert HasSum.tendsto_sum_nat _ using 1
-- Show that the partial sums of the grouped series match the original partial sums at k n.
ext n
rw [← Finset.sum_range_induction _ _ (fun m => ?_)]
<;> simp [hk, hkβ‚€, Finset.sum_Ico_consecutive]
```
Wait, here `hk.tendsto_atTop` uses the fact that `k` is strictly monotone and hence tends to infinity. Then, `h₁` is the composition of the original tendsto with `k`, giving that `s (k n)` tends to `S`. But the partial sums of the grouped series up to `n` is `s (k (n + 1))`, so perhaps there's an off-by-one error. Wait, in the previous analysis, the partial sum of the grouped series up to `N` is `s (k (N + 1))`. Therefore, `h₁` as defined here is `s (k n)` tends to `S`, but we need `s (k (n + 1))` to tend to `S`. So perhaps the code needs to adjust the index.
Alternatively, we can note that `k (n + 1)` also tends to infinity, hence `s (k (n + 1))` tends to `S`. Therefore, the correct `tendsto` statement is `h.tendsto_sum_nat.comp (hk.tendsto_atTop.const_add 1)` or something like that. But `k (n + 1)` is just `k ∘ Nat.succ`, and since `k` is strictly increasing, `k ∘ Nat.succ` also tends to infinity. Therefore, the composition `h.tendsto_sum_nat.comp (tendsto_succ.comp hk.tendsto_atTop)`.
Alternatively, in the code above, the `h₁` is defined as `Tendsto (fun n => βˆ‘ i in Finset.range (k n), a i) atTop (𝓝 S)`, which is `s ∘ k` tending to `S`. But the partial sums of the grouped series are `s ∘ (fun n => k (n + 1))`. So perhaps:
```lean4
theorem hasSum_grouped (a : β„• β†’ Ξ±) (S : Ξ±) (k : β„• β†’ β„•) (hk : StrictMono k) (hkβ‚€ : k 0 = 0)
(h : HasSum a S) : HasSum (fun n => βˆ‘ i in Finset.Ico (k n) (k (n + 1)), a i) S := by
have h₁ : Tendsto (fun n => βˆ‘ i in Finset.range (k (n + 1)), a i) atTop (𝓝 S) :=
h.tendsto_sum_nat.comp (hk.comp_tendsto tendsto_succ_atTop)
convert HasSum.tendsto_sum_nat _ using 1
ext n
simp [Finset.sum_range_induction, hk, hkβ‚€, Finset.sum_Ico_consecutive]
<;> linarith [hk.strictMono]
```
But I need to check the exact steps. The `h₁` is now correctly defined as the composition of `h.tendsto_sum_nat` with `k ∘ succ`, which tends to infinity. Then, by converting `h₁` to a `HasSum` statement, we need to show that the partial sums of the grouped series equal `fun n => βˆ‘ i in Finset.range (k (n + 1)), a i`.
Using `Finset.sum_range_induction`, which allows us to decompose the sum into the grouped parts. For each `n`, the sum up to `k (n + 1)` can be broken into the sum from `0` to `k 0` (which is `0` since `k 0 = 0`), then adding the sum from `k 0` to `k 1`, and so on up to `k n` to `k (n + 1)`. This exactly matches the grouped series partial sums.
Therefore, after simplifying with `Finset.sum_range_induction`, `hk`, and `hkβ‚€`, we can show that the partial sums of the grouped series are equal to `βˆ‘ i in Finset.range (k (n + 1)), a i`, which is exactly the sequence that tends to `S`.
Thus, the code should work. The key steps are:
1. Show that the partial sums of the grouped series are a subsequence of the original partial sums.
2. Use the fact that the original partial sums converge to `S` to conclude the subsequence also converges.
3. Convert this tendsto result into a `HasSum` statement for the grouped series.
Therefore, the final Lean 4 code formalizes this reasoning.
To formalize that every grouping of a convergent series converges to the same sum in Lean 4, we need to show that the partial sums of the grouped series form a subsequence of the original partial sums. Since the original series converges, any subsequence of its partial sums will also converge to the same limit. Here's the detailed implementation:
lean4
Copy
theorem hasSum_grouped (a : β„• β†’ Ξ±) (S : Ξ±) (k : β„• β†’ β„•) (hk : StrictMono k) (hkβ‚€ : k 0 = 0)
(h : HasSum a S) : HasSum (fun n => βˆ‘ i in Finset.Ico (k n) (k (n + 1)), a i) S := by
-- Show that the partial sums of the grouped series are a subsequence of the original partial sums.
have h₁ : Tendsto (fun n => βˆ‘ i in Finset.range (k (n + 1)), a i) atTop (𝓝 S) :=
h.tendsto_sum_nat.comp (hk.comp_tendsto tendsto_succ_atTop)
-- Convert the tendsto result to the HasSum statement by equating the partial sums.
convert HasSum.tendsto_sum_nat _ using 1
ext n
-- Simplify the expression to show the equivalence of the partial sums.
simp [Finset.sum_range_induction, hk, hkβ‚€, Finset.sum_Ico_consecutive]
<;> linarith [hk.strictMono]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment