-- Mathlib/Probability/Martingale/Centering.lean
theorem martingale_martingalePart (hf : Adapted ℱ f) (hf_int : ∀ n, Integrable (f n) μ)
    [SigmaFiniteFiltration μ ℱ] : Martingale (martingalePart f ℱ μ) ℱ μ

Proof state:
Ω : Type u_1
E : Type u_2
m0 : MeasurableSpace Ω
μ : Measure Ω
inst✝³ : NormedAddCommGroup E
inst✝² : NormedSpace ℝ E
inst✝¹ : CompleteSpace E
f : ℕ → Ω → E
ℱ : Filtration ℕ m0
hf : Adapted ℱ f
hf_int : ∀ (n : ℕ), Integrable (f n) μ
inst✝ : SigmaFiniteFiltration μ ℱ
i j : ℕ
hij : i ≤ j
h_eq_sum :
  μ[martingalePart f ℱ μ j|↑ℱ i] =ᶠ[ae μ]
    f 0 + ∑ k ∈ Finset.range j, (μ[f (k + 1) - f k|↑ℱ i] - μ[μ[f (k + 1) - f k|↑ℱ k]|↑ℱ i])
h_ge : ∀ (k : ℕ), i ≤ k → μ[f (k + 1) - f k|↑ℱ i] - μ[μ[f (k + 1) - f k|↑ℱ k]|↑ℱ i] =ᶠ[ae μ] 0
⊢ ∀ k < i, μ[f (k + 1) - f k|↑ℱ i] - μ[μ[f (k + 1) - f k|↑ℱ k]|↑ℱ i] =ᶠ[ae μ] f (k + 1) - f k - μ[f (k + 1) - f k|↑ℱ k]

Tactic:
refine fun k hk => EventuallyEq.sub ?_ ?_

Result:
case refine_1
Ω : Type u_1
E : Type u_2
m0 : MeasurableSpace Ω
μ : Measure Ω
inst✝³ : NormedAddCommGroup E
inst✝² : NormedSpace ℝ E
inst✝¹ : CompleteSpace E
f : ℕ → Ω → E
ℱ : Filtration ℕ m0
hf : Adapted ℱ f
hf_int : ∀ (n : ℕ), Integrable (f n) μ
inst✝ : SigmaFiniteFiltration μ ℱ
i j : ℕ
hij : i ≤ j
h_eq_sum :
  μ[martingalePart f ℱ μ j|↑ℱ i] =ᶠ[ae μ]
    f 0 + ∑ k ∈ Finset.range j, (μ[f (k + 1) - f k|↑ℱ i] - μ[μ[f (k + 1) - f k|↑ℱ k]|↑ℱ i])
h_ge : ∀ (k : ℕ), i ≤ k → μ[f (k + 1) - f k|↑ℱ i] - μ[μ[f (k + 1) - f k|↑ℱ k]|↑ℱ i] =ᶠ[ae μ] 0
k : ℕ
hk : k < i
⊢ μ[f (k + 1) - f k|↑ℱ i] =ᶠ[ae μ] f (k + 1) - f k

case refine_2
Ω : Type u_1
E : Type u_2
m0 : MeasurableSpace Ω
μ : Measure Ω
inst✝³ : NormedAddCommGroup E
inst✝² : NormedSpace ℝ E
inst✝¹ : CompleteSpace E
f : ℕ → Ω → E
ℱ : Filtration ℕ m0
hf : Adapted ℱ f
hf_int : ∀ (n : ℕ), Integrable (f n) μ
inst✝ : SigmaFiniteFiltration μ ℱ
i j : ℕ
hij : i ≤ j
h_eq_sum :
  μ[martingalePart f ℱ μ j|↑ℱ i] =ᶠ[ae μ]
    f 0 + ∑ k ∈ Finset.range j, (μ[f (k + 1) - f k|↑ℱ i] - μ[μ[f (k + 1) - f k|↑ℱ k]|↑ℱ i])
h_ge : ∀ (k : ℕ), i ≤ k → μ[f (k + 1) - f k|↑ℱ i] - μ[μ[f (k + 1) - f k|↑ℱ k]|↑ℱ i] =ᶠ[ae μ] 0
k : ℕ
hk : k < i
⊢ μ[μ[f (k + 1) - f k|↑ℱ k]|↑ℱ i] =ᶠ[ae μ] μ[f (k + 1) - f k|↑ℱ k]

Proof state:
Ω : Type u_1
E : Type u_2
m0 : MeasurableSpace Ω
μ : Measure Ω
inst✝³ : NormedAddCommGroup E
inst✝² : NormedSpace ℝ E
inst✝¹ : CompleteSpace E
f : ℕ → Ω → E
ℱ : Filtration ℕ m0
hf : Adapted ℱ f
hf_int : ∀ (n : ℕ), Integrable (f n) μ
inst✝ : SigmaFiniteFiltration μ ℱ
i j : ℕ
hij : i ≤ j
h_eq_sum :
  μ[martingalePart f ℱ μ j|↑ℱ i] =ᶠ[ae μ]
    f 0 + ∑ k ∈ Finset.range j, (μ[f (k + 1) - f k|↑ℱ i] - μ[μ[f (k + 1) - f k|↑ℱ k]|↑ℱ i])
k : ℕ
hk : i ≤ k
⊢ μ[f (k + 1) - f k|↑ℱ i] - μ[μ[f (k + 1) - f k|↑ℱ k]|↑ℱ i] =ᶠ[ae μ] 0

Tactic:
have : μ[μ[f (k + 1) - f k|ℱ k]|ℱ i] =ᵐ[μ] μ[f (k + 1) - f k|ℱ i] :=
  condExp_condExp_of_le (ℱ.mono hk) (ℱ.le k)

Result:
Ω : Type u_1
E : Type u_2
m0 : MeasurableSpace Ω
μ : Measure Ω
inst✝³ : NormedAddCommGroup E
inst✝² : NormedSpace ℝ E
inst✝¹ : CompleteSpace E
f : ℕ → Ω → E
ℱ : Filtration ℕ m0
hf : Adapted ℱ f
hf_int : ∀ (n : ℕ), Integrable (f n) μ
inst✝ : SigmaFiniteFiltration μ ℱ
i j : ℕ
hij : i ≤ j
h_eq_sum :
  μ[martingalePart f ℱ μ j|↑ℱ i] =ᶠ[ae μ]
    f 0 + ∑ k ∈ Finset.range j, (μ[f (k + 1) - f k|↑ℱ i] - μ[μ[f (k + 1) - f k|↑ℱ k]|↑ℱ i])
k : ℕ
hk : i ≤ k
this : μ[μ[f (k + 1) - f k|↑ℱ k]|↑ℱ i] =ᶠ[ae μ] μ[f (k + 1) - f k|↑ℱ i]
⊢ μ[f (k + 1) - f k|↑ℱ i] - μ[μ[f (k + 1) - f k|↑ℱ k]|↑ℱ i] =ᶠ[ae μ] 0

Proof state:
case refine_1.hf
Ω : Type u_1
E : Type u_2
m0 : MeasurableSpace Ω
μ : Measure Ω
inst✝³ : NormedAddCommGroup E
inst✝² : NormedSpace ℝ E
inst✝¹ : CompleteSpace E
f : ℕ → Ω → E
ℱ : Filtration ℕ m0
hf : Adapted ℱ f
hf_int : ∀ (n : ℕ), Integrable (f n) μ
inst✝ : SigmaFiniteFiltration μ ℱ
i j : ℕ
hij : i ≤ j
h_eq_sum :
  μ[martingalePart f ℱ μ j|↑ℱ i] =ᶠ[ae μ]
    f 0 + ∑ k ∈ Finset.range j, (μ[f (k + 1) - f k|↑ℱ i] - μ[μ[f (k + 1) - f k|↑ℱ k]|↑ℱ i])
h_ge : ∀ (k : ℕ), i ≤ k → μ[f (k + 1) - f k|↑ℱ i] - μ[μ[f (k + 1) - f k|↑ℱ k]|↑ℱ i] =ᶠ[ae μ] 0
k : ℕ
hk : k < i
⊢ StronglyMeasurable (f (k + 1) - f k)

Tactic:
exact ((hf (k + 1)).mono (ℱ.mono (Nat.succ_le_of_lt hk))).sub ((hf k).mono (ℱ.mono hk.le))

Result:
no goals

Proof state:
Ω : Type u_1
E : Type u_2
m0 : MeasurableSpace Ω
μ : Measure Ω
inst✝³ : NormedAddCommGroup E
inst✝² : NormedSpace ℝ E
inst✝¹ : CompleteSpace E
f : ℕ → Ω → E
ℱ : Filtration ℕ m0
hf : Adapted ℱ f
hf_int : ∀ (n : ℕ), Integrable (f n) μ
inst✝ : SigmaFiniteFiltration μ ℱ
i j : ℕ
hij : i ≤ j
h_eq_sum :
  μ[martingalePart f ℱ μ j|↑ℱ i] =ᶠ[ae μ]
    f 0 + ∑ k ∈ Finset.range j, (μ[f (k + 1) - f k|↑ℱ i] - μ[μ[f (k + 1) - f k|↑ℱ k]|↑ℱ i])
⊢ μ[martingalePart f ℱ μ j|↑ℱ i] =ᶠ[ae μ] martingalePart f ℱ μ i

Tactic:
refine h_eq_sum.trans ?_

Result:
Ω : Type u_1
E : Type u_2
m0 : MeasurableSpace Ω
μ : Measure Ω
inst✝³ : NormedAddCommGroup E
inst✝² : NormedSpace ℝ E
inst✝¹ : CompleteSpace E
f : ℕ → Ω → E
ℱ : Filtration ℕ m0
hf : Adapted ℱ f
hf_int : ∀ (n : ℕ), Integrable (f n) μ
inst✝ : SigmaFiniteFiltration μ ℱ
i j : ℕ
hij : i ≤ j
h_eq_sum :
  μ[martingalePart f ℱ μ j|↑ℱ i] =ᶠ[ae μ]
    f 0 + ∑ k ∈ Finset.range j, (μ[f (k + 1) - f k|↑ℱ i] - μ[μ[f (k + 1) - f k|↑ℱ k]|↑ℱ i])
⊢ f 0 + ∑ k ∈ Finset.range j, (μ[f (k + 1) - f k|↑ℱ i] - μ[μ[f (k + 1) - f k|↑ℱ k]|↑ℱ i]) =ᶠ[ae μ]
    martingalePart f ℱ μ i

Proof state:
Ω : Type u_1
E : Type u_2
m0 : MeasurableSpace Ω
μ : Measure Ω
inst✝³ : NormedAddCommGroup E
inst✝² : NormedSpace ℝ E
inst✝¹ : CompleteSpace E
f : ℕ → Ω → E
ℱ : Filtration ℕ m0
hf : Adapted ℱ f
hf_int : ∀ (n : ℕ), Integrable (f n) μ
inst✝ : SigmaFiniteFiltration μ ℱ
i j : ℕ
hij : i ≤ j
h_eq_sum :
  μ[martingalePart f ℱ μ j|↑ℱ i] =ᶠ[ae μ]
    f 0 + ∑ k ∈ Finset.range j, (μ[f (k + 1) - f k|↑ℱ i] - μ[μ[f (k + 1) - f k|↑ℱ k]|↑ℱ i])
h_ge : ∀ (k : ℕ), i ≤ k → μ[f (k + 1) - f k|↑ℱ i] - μ[μ[f (k + 1) - f k|↑ℱ k]|↑ℱ i] =ᶠ[ae μ] 0
h_lt :
  ∀ k < i, μ[f (k + 1) - f k|↑ℱ i] - μ[μ[f (k + 1) - f k|↑ℱ k]|↑ℱ i] =ᶠ[ae μ] f (k + 1) - f k - μ[f (k + 1) - f k|↑ℱ k]
⊢ ∑ k ∈ Finset.range i, (μ[f (k + 1) - f k|↑ℱ i] - μ[μ[f (k + 1) - f k|↑ℱ k]|↑ℱ i]) +
      ∑ k ∈ Finset.Ico i j, (μ[f (k + 1) - f k|↑ℱ i] - μ[μ[f (k + 1) - f k|↑ℱ k]|↑ℱ i]) =ᶠ[ae μ]
    ∑ i ∈ Finset.range i, (f (i + 1) - f i - μ[f (i + 1) - f i|↑ℱ i]) + 0

Tactic:
refine (eventuallyEq_sum fun k hk => h_lt k (Finset.mem_range.mp hk)).add ?_

Result:
Ω : Type u_1
E : Type u_2
m0 : MeasurableSpace Ω
μ : Measure Ω
inst✝³ : NormedAddCommGroup E
inst✝² : NormedSpace ℝ E
inst✝¹ : CompleteSpace E
f : ℕ → Ω → E
ℱ : Filtration ℕ m0
hf : Adapted ℱ f
hf_int : ∀ (n : ℕ), Integrable (f n) μ
inst✝ : SigmaFiniteFiltration μ ℱ
i j : ℕ
hij : i ≤ j
h_eq_sum :
  μ[martingalePart f ℱ μ j|↑ℱ i] =ᶠ[ae μ]
    f 0 + ∑ k ∈ Finset.range j, (μ[f (k + 1) - f k|↑ℱ i] - μ[μ[f (k + 1) - f k|↑ℱ k]|↑ℱ i])
h_ge : ∀ (k : ℕ), i ≤ k → μ[f (k + 1) - f k|↑ℱ i] - μ[μ[f (k + 1) - f k|↑ℱ k]|↑ℱ i] =ᶠ[ae μ] 0
h_lt :
  ∀ k < i, μ[f (k + 1) - f k|↑ℱ i] - μ[μ[f (k + 1) - f k|↑ℱ k]|↑ℱ i] =ᶠ[ae μ] f (k + 1) - f k - μ[f (k + 1) - f k|↑ℱ k]
⊢ ∑ k ∈ Finset.Ico i j, (μ[f (k + 1) - f k|↑ℱ i] - μ[μ[f (k + 1) - f k|↑ℱ k]|↑ℱ i]) =ᶠ[ae μ] 0