Challenge 25: If the interleaving of two sequences converges to L, then both converge to L
Suppose that the sequence \(c_n\) is an interleaving of the sequences \(a_n\) and \(b_n\); that is, that \[ (c_0, c_1, c_2, \dots) = (a_0, b_0, a_1, b_1, a_2, b_2, \dots) \]
Prove that if \(c_n\) converges to \(L\), then \(a_n\) and \(b_n\) converge to \(L\).
To do so, complete the following theory
import Mathlib.Tactic def SeqLim (a : ℕ → ℝ) (L : ℝ) : Prop := ∀ ε > 0, ∃ k : ℕ, ∀ n ≥ k, |a n - L| < ε example (hc : ∀ n, c n = if Even n then a (n / 2) else b ((n - 1) / 2)) (hL : SeqLim c L) : SeqLim a L ∧ SeqLim b L := by sorry
1. Proof in natural language
First, we prove that \(a\) converges to \(L\). To do so, let \(\varepsilon > 0\); we have to show that there exists \(k \in \mathbb{N}\) such that \[ \forall n \geq k, |a_n - L| < \varepsilon \tag{1} \] Since \(c\) converges to \(L\), there exists \(k \in \mathbb{N}\) such that \[ \forall n \geq k, |c_n - L| < \varepsilon \tag{2} \] Let us show that (1) holds for this \(k\). To do so, let \(n \in \mathbb{N}\) be such that \[ n \geq k \tag{3} \] Then, \[ \begin{array}{llll} |a_n - L| &= |c(2n) - L| &&\text{[since \(2n\) is even]} \\ &< \varepsilon &&\text{[by (2), since \(2n \geq n \geq k\)]} \end{array} \]
Second, we prove that \(b\) converges to \(L\). To do so, let \(\varepsilon > 0\); we have to show that there exists \(k \in \mathbb{N}\) such that \[ \forall n \geq k, |b_n - L| < \varepsilon \tag{4} \] Since \(c\) converges to \(L\), there exists \(k \in \mathbb{N}\) such that \[ \forall n \geq k, |c_n - L| < \varepsilon \tag{5} \] Let us show that (4) holds for this \(k\). To do so, let \(n \in \mathbb{N}\) be such that \[ n \geq k \tag{6} \] Then, \[ \begin{array}{llll} |b_n - L| &= |c(2n+1) - L| &&\text{[since \(2n+1\) is odd]} \\ &< \varepsilon &&\text{[by (5), since \(2n+1 \geq n \geq k\)]} \end{array} \]
2. Proofs in Lean 4
import Mathlib.Tactic def SeqLim (a : ℕ → ℝ) (L : ℝ) : Prop := ∀ ε > 0, ∃ k : ℕ, ∀ n ≥ k, |a n - L| < ε variable {a b c : ℕ → ℝ} variable {L : ℝ} -- Proof 1 -- ======= example (hc : ∀ n, c n = if Even n then a (n / 2) else b ((n - 1) / 2)) (hL : SeqLim c L) : SeqLim a L ∧ SeqLim b L := by constructor · -- ⊢ SeqLim a L intro ε hε -- ε : ℝ -- hε : ε > 0 -- ⊢ ∃ k, ∀ n ≥ k, |a n - L| < ε obtain ⟨k, hk⟩ := hL ε hε -- k : ℕ -- hk : ∀ n ≥ k, |c n - L| < ε use k -- ⊢ ∀ n ≥ k, |a n - L| < ε intro n hn -- n : ℕ -- hn : n ≥ k -- ⊢ |a n - L| < ε calc |a n - L| = |c (2 * n) - L| := by grind _ < ε := by grind · -- ⊢ SeqLim b L intro ε hε -- ε : ℝ -- hε : ε > 0 -- ⊢ ∃ k, ∀ n ≥ k, |b n - L| < ε obtain ⟨k, hk⟩ := hL ε hε -- k : ℕ -- hk : ∀ n ≥ k, |c n - L| < ε use k -- ⊢ ∀ n ≥ k, |b n - L| < ε intro n hn -- n : ℕ -- hn : n ≥ k -- ⊢ |b n - L| < ε calc |b n - L| = |c (2 * n + 1) - L| := by grind _ < ε := by grind -- Proof 2 -- ======= example (hc : ∀ n, c n = if Even n then a (n / 2) else b ((n - 1) / 2)) (hL : SeqLim c L) : SeqLim a L ∧ SeqLim b L := by constructor · -- ⊢ SeqLim a L intro ε hε -- ε : ℝ -- hε : ε > 0 -- ⊢ ∃ k, ∀ n ≥ k, |a n - L| < ε obtain ⟨k, hk⟩ := hL ε hε -- k : ℕ -- hk : ∀ n ≥ k, |c n - L| < ε use k -- ⊢ ∀ n ≥ k, |a n - L| < ε intro n hn -- n : ℕ -- hn : n ≥ k -- ⊢ |a n - L| < ε calc |a n - L| = |c (2 * n) - L| := by congr 1 ; simp [hc] _ < ε := hk (2 * n) (by omega) · -- ⊢ SeqLim b L intro ε hε -- ε : ℝ -- hε : ε > 0 -- ⊢ ∃ k, ∀ n ≥ k, |b n - L| < ε obtain ⟨k, hk⟩ := hL ε hε -- k : ℕ -- hk : ∀ n ≥ k, |c n - L| < ε use k -- ⊢ ∀ n ≥ k, |b n - L| < ε intro n hn -- n : ℕ -- hn : n ≥ k -- ⊢ |b n - L| < ε calc |b n - L| = |c (2 * n + 1) - L| := by congr 1 ; simp [hc] _ < ε := hk (2 * n + 1) (by omega) -- Proof 3 -- ======= private lemma c_even (hc : ∀ n, c n = if Even n then a (n / 2) else b ((n - 1) / 2)) (n : ℕ) : c (2 * n) = a n := by calc c (2 * n) = if Even (2 * n) then a (2 * n / 2) else b ((2 * n - 1) / 2) := hc (2 * n) _ = a (2 * n / 2) := ite_eq_left (even_two_mul n) _ = a n := by simp private lemma c_odd (hc : ∀ n, c n = if Even n then a (n / 2) else b ((n - 1) / 2)) (n : ℕ) : c (2 * n + 1) = b n := by calc c (2 * n + 1) = if Even (2 * n + 1) then a ((2 * n + 1) / 2) else b ((2 * n + 1 - 1) / 2) := hc (2 * n + 1) _ = b ((2 * n + 1 - 1) / 2) := ite_eq_right (Nat.not_even_two_mul_add_one n) _ = b n := by simp example (hc : ∀ n, c n = if Even n then a (n / 2) else b ((n - 1) / 2)) (hL : SeqLim c L) : SeqLim a L ∧ SeqLim b L := by constructor · intro ε hε -- ε : ℝ -- hε : ε > 0 -- ⊢ ∃ k, ∀ n ≥ k, |a n - L| < ε obtain ⟨k, hk⟩ := hL ε hε -- k : ℕ -- hk : ∀ n ≥ k, |c n - L| < ε use k -- ⊢ ∀ n ≥ k, |a n - L| < ε intro n hn -- n : ℕ -- hn : n ≥ k -- ⊢ |a n - L| < ε calc |a n - L| = |c (2 * n) - L| := by rw [c_even hc] _ < ε := hk (2 * n) (by omega) · -- ⊢ SeqLim b L intro ε hε -- ε : ℝ -- hε : ε > 0 -- ⊢ ∃ k, ∀ n ≥ k, |b n - L| < ε obtain ⟨k, hk⟩ := hL ε hε -- k : ℕ -- hk : ∀ n ≥ k, |c n - L| < ε use k -- ⊢ ∀ n ≥ k, |b n - L| < ε intro n hn -- n : ℕ -- hn : n ≥ k -- ⊢ |b n - L| < ε calc |b n - L| = |c (2 * n + 1) - L| := by rw [c_odd hc] _ < ε := hk (2 * n + 1) (by omega) -- Proof 4 -- ======= lemma seqLim_comp {f : ℕ → ℕ} (hL : SeqLim c L) (hf : ∀ n, n ≤ f n) : SeqLim (c ∘ f) L := by intro ε hε -- ε : ℝ -- hε : ε > 0 -- ⊢ ∃ k, ∀ n ≥ k, |(c ∘ f) n - L| < ε obtain ⟨k, hk⟩ := hL ε hε -- k : ℕ -- hk : ∀ n ≥ k, |c n - L| < ε use k -- ⊢ ∀ n ≥ k, |(c ∘ f) n - L| < ε intro n hn -- n : ℕ -- hn : n ≥ k -- ⊢ |(c ∘ f) n - L| < ε have h : k ≤ f n := calc k ≤ n := hn _ ≤ f n := hf n calc |(c ∘ f) n - L| = |c (f n) - L| := rfl _ < ε := hk (f n) h example (hc : ∀ n, c n = if Even n then a (n / 2) else b ((n - 1) / 2)) (hL : SeqLim c L) : SeqLim a L ∧ SeqLim b L := by constructor · -- ⊢ SeqLim a L have ha : a = c ∘ (2 * ·) := funext fun n => (c_even hc n).symm rw [ha] -- ⊢ SeqLim (c ∘ fun x => 2 * x) L exact seqLim_comp (f := (2 * ·)) hL (fun n => by omega) · -- ⊢ SeqLim b L have hb : b = c ∘ (2 * · + 1) := funext fun n => (c_odd hc n).symm rw [hb] -- ⊢ SeqLim (c ∘ fun x => 2 * x + 1) L exact seqLim_comp (f := (2 * · + 1)) hL (fun n => by omega)
You can inspect, modify and run the code of these proofs interactively in Lean 4 Web.
3. Collaborative solutions
How can you post your solution?
- Write your proof in live.lean-lang.org and check that it compiles without errors.
- Copy the code and post it in the comments of this entry, inside a Lean code block:
```lean -- your proof ```
- During the week you will be able to compare your approach with those of other participants. The official solution will be published Monday 2 November 2026.
Comments