l3lab/ntp-mathlib huggingface dataset:
theorem martingale_martingalePart (hf : Adapted ℱ f) (hf_int : ∀ n, Integrable (f n) μ)
    [SigmaFiniteFiltration μ ℱ] : Martingale (martingalePart f ℱ μ) ℱ μ := by
  refine' ⟨adapted_martingalePart hf, fun i j hij => _⟩
  -- ⊢ μ[martingalePart f ℱ μ j | ℱ i] =ᵐ[μ] 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
n : ℕ
hf : Adapted ℱ f
hf_int : ∀ (n : ℕ), Integrable (f n)
inst✝ : SigmaFiniteFiltration μ ℱ
i j : ℕ
hij : i ≤ j
⊢ μ[martingalePart f ℱ μ j|↑ℱ i] =ᵐ[μ] martingalePart f ℱ μ i

Next tactic:
have h_eq_sum : μ[martingalePart f ℱ μ j|ℱ i] =ᵐ[μ]
      f 0 + ∑ k in Finset.range j, (μ[f (k + 1) - f k|ℱ i] - μ[μ[f (k + 1) - f k|ℱ k]|ℱ i]) := by
    rw [martingalePart_eq_sum]
    refine' (condexp_add (hf_int 0) _).trans _
    · exact integrable_finset_sum' _ fun i _ => ((hf_int _).sub (hf_int _)).sub integrable_condexp
    refine' (EventuallyEq.add EventuallyEq.rfl (condexp_finset_sum fun i _ => _)).trans _
    · exact ((hf_int _).sub (hf_int _)).sub integrable_condexp
    refine' EventuallyEq.add _ _
    · rw [condexp_of_stronglyMeasurable (ℱ.le _) _ (hf_int 0)]
      · exact (hf 0).mono (ℱ.mono (zero_le i))
    · exact eventuallyEq_sum fun k _ => condexp_sub ((hf_int _).sub (hf_int _)) integrable_condexp
theorem martingale_martingalePart (hf : Adapted ℱ f) (hf_int : ∀ n, Integrable (f n) μ)
    [SigmaFiniteFiltration μ ℱ] : Martingale (martingalePart f ℱ μ) ℱ μ := by
  refine' ⟨adapted_martingalePart hf, fun i j hij => _⟩
  -- ⊢ μ[martingalePart f ℱ μ j | ℱ i] =ᵐ[μ] martingalePart f ℱ μ i
  have h_eq_sum : μ[martingalePart f ℱ μ j|ℱ i] =ᵐ[μ]
      f 0 + ∑ k in Finset.range j, (μ[f (k + 1) - f k|ℱ i] - μ[μ[f (k + 1) - f k|ℱ k]|ℱ i]) := by
    

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
n : ℕ
hf : Adapted ℱ f
hf_int : ∀ (n : ℕ), Integrable (f n)
inst✝ : SigmaFiniteFiltration μ ℱ
i j : ℕ
hij : i ≤ j
⊢ μ[martingalePart f ℱ μ j|↑ℱ i] =ᵐ[μ]
    f 0 + ∑ k in Finset.range j, (μ[f (k + 1) - f k|↑ℱ i] - μ[μ[f (k + 1) - f k|↑ℱ k]|↑ℱ i])

Next tactic:
rw [martingalePart_eq_sum]
theorem martingale_martingalePart (hf : Adapted ℱ f) (hf_int : ∀ n, Integrable (f n) μ)
    [SigmaFiniteFiltration μ ℱ] : Martingale (martingalePart f ℱ μ) ℱ μ := by
  refine' ⟨adapted_martingalePart hf, fun i j hij => _⟩
  -- ⊢ μ[martingalePart f ℱ μ j | ℱ i] =ᵐ[μ] martingalePart f ℱ μ i
  have h_eq_sum : μ[martingalePart f ℱ μ j|ℱ i] =ᵐ[μ]
      f 0 + ∑ k in Finset.range j, (μ[f (k + 1) - f k|ℱ i] - μ[μ[f (k + 1) - f k|ℱ k]|ℱ i]) := by
    rw [martingalePart_eq_sum]
    

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
n : ℕ
hf : Adapted ℱ f
hf_int : ∀ (n : ℕ), Integrable (f n)
inst✝ : SigmaFiniteFiltration μ ℱ
i j : ℕ
hij : i ≤ j
⊢ μ[(fun n => f 0 + ∑ i in Finset.range n, (f (i + 1) - f i - μ[f (i + 1) - f i|↑ℱ i])) j|↑ℱ i] =ᵐ[μ]
    f 0 + ∑ k in Finset.range j, (μ[f (k + 1) - f k|↑ℱ i] - μ[μ[f (k + 1) - f k|↑ℱ k]|↑ℱ i])

Next tactic:
refine' (condexp_add (hf_int 0) _).trans _
theorem martingale_martingalePart (hf : Adapted ℱ f) (hf_int : ∀ n, Integrable (f n) μ)
    [SigmaFiniteFiltration μ ℱ] : Martingale (martingalePart f ℱ μ) ℱ μ := by
  refine' ⟨adapted_martingalePart hf, fun i j hij => _⟩
  -- ⊢ μ[martingalePart f ℱ μ j | ℱ i] =ᵐ[μ] martingalePart f ℱ μ i
  have h_eq_sum : μ[martingalePart f ℱ μ j|ℱ i] =ᵐ[μ]
      f 0 + ∑ k in Finset.range j, (μ[f (k + 1) - f k|ℱ i] - μ[μ[f (k + 1) - f k|ℱ k]|ℱ i]) := by
    rw [martingalePart_eq_sum]
    refine' (condexp_add (hf_int 0) _).trans _
    · 

Proof state:
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
n : ℕ
hf : Adapted ℱ f
hf_int : ∀ (n : ℕ), Integrable (f n)
inst✝ : SigmaFiniteFiltration μ ℱ
i j : ℕ
hij : i ≤ j
⊢ Integrable (∑ i in Finset.range j, (f (i + 1) - f i - μ[f (i + 1) - f i|↑ℱ i]))

Next tactic:
exact integrable_finset_sum' _ fun i _ => ((hf_int _).sub (hf_int _)).sub integrable_condexp
theorem martingale_martingalePart (hf : Adapted ℱ f) (hf_int : ∀ n, Integrable (f n) μ)
    [SigmaFiniteFiltration μ ℱ] : Martingale (martingalePart f ℱ μ) ℱ μ := by
  refine' ⟨adapted_martingalePart hf, fun i j hij => _⟩
  -- ⊢ μ[martingalePart f ℱ μ j | ℱ i] =ᵐ[μ] martingalePart f ℱ μ i
  have h_eq_sum : μ[martingalePart f ℱ μ j|ℱ i] =ᵐ[μ]
      f 0 + ∑ k in Finset.range j, (μ[f (k + 1) - f k|ℱ i] - μ[μ[f (k + 1) - f k|ℱ k]|ℱ i]) := by
    rw [martingalePart_eq_sum]
    refine' (condexp_add (hf_int 0) _).trans _
    · exact integrable_finset_sum' _ fun i _ => ((hf_int _).sub (hf_int _)).sub integrable_condexp
    

Proof state:
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
n : ℕ
hf : Adapted ℱ f
hf_int : ∀ (n : ℕ), Integrable (f n)
inst✝ : SigmaFiniteFiltration μ ℱ
i j : ℕ
hij : i ≤ j
⊢ μ[f 0|↑ℱ i] + μ[∑ i in Finset.range j, (f (i + 1) - f i - μ[f (i + 1) - f i|↑ℱ i])|↑ℱ i] =ᵐ[μ]
    f 0 + ∑ k in Finset.range j, (μ[f (k + 1) - f k|↑ℱ i] - μ[μ[f (k + 1) - f k|↑ℱ k]|↑ℱ i])

Next tactic:
refine' (EventuallyEq.add EventuallyEq.rfl (condexp_finset_sum fun i _ => _)).trans _
theorem martingale_martingalePart (hf : Adapted ℱ f) (hf_int : ∀ n, Integrable (f n) μ)
    [SigmaFiniteFiltration μ ℱ] : Martingale (martingalePart f ℱ μ) ℱ μ := by
  refine' ⟨adapted_martingalePart hf, fun i j hij => _⟩
  -- ⊢ μ[martingalePart f ℱ μ j | ℱ i] =ᵐ[μ] martingalePart f ℱ μ i
  have h_eq_sum : μ[martingalePart f ℱ μ j|ℱ i] =ᵐ[μ]
      f 0 + ∑ k in Finset.range j, (μ[f (k + 1) - f k|ℱ i] - μ[μ[f (k + 1) - f k|ℱ k]|ℱ i]) := by
    rw [martingalePart_eq_sum]
    refine' (condexp_add (hf_int 0) _).trans _
    · exact integrable_finset_sum' _ fun i _ => ((hf_int _).sub (hf_int _)).sub integrable_condexp
    refine' (EventuallyEq.add EventuallyEq.rfl (condexp_finset_sum fun i _ => _)).trans _
    · 

Proof state:
case refine'_2.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
n : ℕ
hf : Adapted ℱ f
hf_int : ∀ (n : ℕ), Integrable (f n)
inst✝ : SigmaFiniteFiltration μ ℱ
i✝ j : ℕ
hij : i✝ ≤ j
i : ℕ
x✝ : i ∈ Finset.range j
⊢ Integrable (f (i + 1) - f i - μ[f (i + 1) - f i|↑ℱ i])

Next tactic:
exact ((hf_int _).sub (hf_int _)).sub integrable_condexp
theorem martingale_martingalePart (hf : Adapted ℱ f) (hf_int : ∀ n, Integrable (f n) μ)
    [SigmaFiniteFiltration μ ℱ] : Martingale (martingalePart f ℱ μ) ℱ μ := by
  refine' ⟨adapted_martingalePart hf, fun i j hij => _⟩
  -- ⊢ μ[martingalePart f ℱ μ j | ℱ i] =ᵐ[μ] martingalePart f ℱ μ i
  have h_eq_sum : μ[martingalePart f ℱ μ j|ℱ i] =ᵐ[μ]
      f 0 + ∑ k in Finset.range j, (μ[f (k + 1) - f k|ℱ i] - μ[μ[f (k + 1) - f k|ℱ k]|ℱ i]) := by
    rw [martingalePart_eq_sum]
    refine' (condexp_add (hf_int 0) _).trans _
    · exact integrable_finset_sum' _ fun i _ => ((hf_int _).sub (hf_int _)).sub integrable_condexp
    refine' (EventuallyEq.add EventuallyEq.rfl (condexp_finset_sum fun i _ => _)).trans _
    · exact ((hf_int _).sub (hf_int _)).sub integrable_condexp
    

Proof state:
case refine'_2.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
n : ℕ
hf : Adapted ℱ f
hf_int : ∀ (n : ℕ), Integrable (f n)
inst✝ : SigmaFiniteFiltration μ ℱ
i j : ℕ
hij : i ≤ j
⊢ (fun x =>
      (μ[f 0|↑ℱ i]) x +
        Finset.sum (Finset.range j) (fun i_1 => μ[f (i_1 + 1) - f i_1 - μ[f (i_1 + 1) - f i_1|↑ℱ i_1]|↑ℱ i]) x) =ᵐ[μ]
    f 0 + ∑ k in Finset.range j, (μ[f (k + 1) - f k|↑ℱ i] - μ[μ[f (k + 1) - f k|↑ℱ k]|↑ℱ i])

Next tactic:
refine' EventuallyEq.add _ _
theorem martingale_martingalePart (hf : Adapted ℱ f) (hf_int : ∀ n, Integrable (f n) μ)
    [SigmaFiniteFiltration μ ℱ] : Martingale (martingalePart f ℱ μ) ℱ μ := by
  refine' ⟨adapted_martingalePart hf, fun i j hij => _⟩
  -- ⊢ μ[martingalePart f ℱ μ j | ℱ i] =ᵐ[μ] martingalePart f ℱ μ i
  have h_eq_sum : μ[martingalePart f ℱ μ j|ℱ i] =ᵐ[μ]
      f 0 + ∑ k in Finset.range j, (μ[f (k + 1) - f k|ℱ i] - μ[μ[f (k + 1) - f k|ℱ k]|ℱ i]) := by
    rw [martingalePart_eq_sum]
    refine' (condexp_add (hf_int 0) _).trans _
    · exact integrable_finset_sum' _ fun i _ => ((hf_int _).sub (hf_int _)).sub integrable_condexp
    refine' (EventuallyEq.add EventuallyEq.rfl (condexp_finset_sum fun i _ => _)).trans _
    · exact ((hf_int _).sub (hf_int _)).sub integrable_condexp
    refine' EventuallyEq.add _ _
    · 

Proof state:
case refine'_2.refine'_2.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
n : ℕ
hf : Adapted ℱ f
hf_int : ∀ (n : ℕ), Integrable (f n)
inst✝ : SigmaFiniteFiltration μ ℱ
i j : ℕ
hij : i ≤ j
⊢ (fun x => (μ[f 0|↑ℱ i]) x) =ᵐ[μ] fun x => f 0 x

Next tactic:
rw [condexp_of_stronglyMeasurable (ℱ.le _) _ (hf_int 0)]
theorem martingale_martingalePart (hf : Adapted ℱ f) (hf_int : ∀ n, Integrable (f n) μ)
    [SigmaFiniteFiltration μ ℱ] : Martingale (martingalePart f ℱ μ) ℱ μ := by
  refine' ⟨adapted_martingalePart hf, fun i j hij => _⟩
  -- ⊢ μ[martingalePart f ℱ μ j | ℱ i] =ᵐ[μ] martingalePart f ℱ μ i
  have h_eq_sum : μ[martingalePart f ℱ μ j|ℱ i] =ᵐ[μ]
      f 0 + ∑ k in Finset.range j, (μ[f (k + 1) - f k|ℱ i] - μ[μ[f (k + 1) - f k|ℱ k]|ℱ i]) := by
    rw [martingalePart_eq_sum]
    refine' (condexp_add (hf_int 0) _).trans _
    · exact integrable_finset_sum' _ fun i _ => ((hf_int _).sub (hf_int _)).sub integrable_condexp
    refine' (EventuallyEq.add EventuallyEq.rfl (condexp_finset_sum fun i _ => _)).trans _
    · exact ((hf_int _).sub (hf_int _)).sub integrable_condexp
    refine' EventuallyEq.add _ _
    · rw [condexp_of_stronglyMeasurable (ℱ.le _) _ (hf_int 0)]
      · 

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
n : ℕ
hf : Adapted ℱ f
hf_int : ∀ (n : ℕ), Integrable (f n)
inst✝ : SigmaFiniteFiltration μ ℱ
i j : ℕ
hij : i ≤ j
⊢ StronglyMeasurable (f 0)

Next tactic:
exact (hf 0).mono (ℱ.mono (zero_le i))
theorem martingale_martingalePart (hf : Adapted ℱ f) (hf_int : ∀ n, Integrable (f n) μ)
    [SigmaFiniteFiltration μ ℱ] : Martingale (martingalePart f ℱ μ) ℱ μ := by
  refine' ⟨adapted_martingalePart hf, fun i j hij => _⟩
  -- ⊢ μ[martingalePart f ℱ μ j | ℱ i] =ᵐ[μ] martingalePart f ℱ μ i
  have h_eq_sum : μ[martingalePart f ℱ μ j|ℱ i] =ᵐ[μ]
      f 0 + ∑ k in Finset.range j, (μ[f (k + 1) - f k|ℱ i] - μ[μ[f (k + 1) - f k|ℱ k]|ℱ i]) := by
    rw [martingalePart_eq_sum]
    refine' (condexp_add (hf_int 0) _).trans _
    · exact integrable_finset_sum' _ fun i _ => ((hf_int _).sub (hf_int _)).sub integrable_condexp
    refine' (EventuallyEq.add EventuallyEq.rfl (condexp_finset_sum fun i _ => _)).trans _
    · exact ((hf_int _).sub (hf_int _)).sub integrable_condexp
    refine' EventuallyEq.add _ _
    · rw [condexp_of_stronglyMeasurable (ℱ.le _) _ (hf_int 0)]
      · exact (hf 0).mono (ℱ.mono (zero_le i))
    · 

Proof state:
case refine'_2.refine'_2.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
n : ℕ
hf : Adapted ℱ f
hf_int : ∀ (n : ℕ), Integrable (f n)
inst✝ : SigmaFiniteFiltration μ ℱ
i j : ℕ
hij : i ≤ j
⊢ (fun x =>
      Finset.sum (Finset.range j) (fun i_1 => μ[f (i_1 + 1) - f i_1 - μ[f (i_1 + 1) - f i_1|↑ℱ i_1]|↑ℱ i]) x) =ᵐ[μ]
    fun x => Finset.sum (Finset.range j) (fun k => μ[f (k + 1) - f k|↑ℱ i] - μ[μ[f (k + 1) - f k|↑ℱ k]|↑ℱ i]) x

Next tactic:
exact eventuallyEq_sum fun k _ => condexp_sub ((hf_int _).sub (hf_int _)) integrable_condexp
theorem martingale_martingalePart (hf : Adapted ℱ f) (hf_int : ∀ n, Integrable (f n) μ)
    [SigmaFiniteFiltration μ ℱ] : Martingale (martingalePart f ℱ μ) ℱ μ := by
  refine' ⟨adapted_martingalePart hf, fun i j hij => _⟩
  -- ⊢ μ[martingalePart f ℱ μ j | ℱ i] =ᵐ[μ] martingalePart f ℱ μ i
  have h_eq_sum : μ[martingalePart f ℱ μ j|ℱ i] =ᵐ[μ]
      f 0 + ∑ k in Finset.range j, (μ[f (k + 1) - f k|ℱ i] - μ[μ[f (k + 1) - f k|ℱ k]|ℱ i]) := by
    rw [martingalePart_eq_sum]
    refine' (condexp_add (hf_int 0) _).trans _
    · exact integrable_finset_sum' _ fun i _ => ((hf_int _).sub (hf_int _)).sub integrable_condexp
    refine' (EventuallyEq.add EventuallyEq.rfl (condexp_finset_sum fun i _ => _)).trans _
    · exact ((hf_int _).sub (hf_int _)).sub integrable_condexp
    refine' EventuallyEq.add _ _
    · rw [condexp_of_stronglyMeasurable (ℱ.le _) _ (hf_int 0)]
      · exact (hf 0).mono (ℱ.mono (zero_le i))
    · exact eventuallyEq_sum fun k _ => condexp_sub ((hf_int _).sub (hf_int _)) integrable_condexp
  

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
n : ℕ
hf : Adapted ℱ f
hf_int : ∀ (n : ℕ), Integrable (f n)
inst✝ : SigmaFiniteFiltration μ ℱ
i j : ℕ
hij : i ≤ j
h_eq_sum :
  μ[martingalePart f ℱ μ j|↑ℱ i] =ᵐ[μ]
    f 0 + ∑ k in Finset.range j, (μ[f (k + 1) - f k|↑ℱ i] - μ[μ[f (k + 1) - f k|↑ℱ k]|↑ℱ i])
⊢ μ[martingalePart f ℱ μ j|↑ℱ i] =ᵐ[μ] martingalePart f ℱ μ i

Next tactic:
refine' h_eq_sum.trans _
theorem martingale_martingalePart (hf : Adapted ℱ f) (hf_int : ∀ n, Integrable (f n) μ)
    [SigmaFiniteFiltration μ ℱ] : Martingale (martingalePart f ℱ μ) ℱ μ := by
  refine' ⟨adapted_martingalePart hf, fun i j hij => _⟩
  -- ⊢ μ[martingalePart f ℱ μ j | ℱ i] =ᵐ[μ] martingalePart f ℱ μ i
  have h_eq_sum : μ[martingalePart f ℱ μ j|ℱ i] =ᵐ[μ]
      f 0 + ∑ k in Finset.range j, (μ[f (k + 1) - f k|ℱ i] - μ[μ[f (k + 1) - f k|ℱ k]|ℱ i]) := by
    rw [martingalePart_eq_sum]
    refine' (condexp_add (hf_int 0) _).trans _
    · exact integrable_finset_sum' _ fun i _ => ((hf_int _).sub (hf_int _)).sub integrable_condexp
    refine' (EventuallyEq.add EventuallyEq.rfl (condexp_finset_sum fun i _ => _)).trans _
    · exact ((hf_int _).sub (hf_int _)).sub integrable_condexp
    refine' EventuallyEq.add _ _
    · rw [condexp_of_stronglyMeasurable (ℱ.le _) _ (hf_int 0)]
      · exact (hf 0).mono (ℱ.mono (zero_le i))
    · exact eventuallyEq_sum fun k _ => condexp_sub ((hf_int _).sub (hf_int _)) integrable_condexp
  refine' h_eq_sum.trans _
  

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
n : ℕ
hf : Adapted ℱ f
hf_int : ∀ (n : ℕ), Integrable (f n)
inst✝ : SigmaFiniteFiltration μ ℱ
i j : ℕ
hij : i ≤ j
h_eq_sum :
  μ[martingalePart f ℱ μ j|↑ℱ i] =ᵐ[μ]
    f 0 + ∑ k in Finset.range j, (μ[f (k + 1) - f k|↑ℱ i] - μ[μ[f (k + 1) - f k|↑ℱ k]|↑ℱ i])
⊢ f 0 + ∑ k in Finset.range j, (μ[f (k + 1) - f k|↑ℱ i] - μ[μ[f (k + 1) - f k|↑ℱ k]|↑ℱ i]) =ᵐ[μ] martingalePart f ℱ μ i

Next tactic:
have h_ge : ∀ k, i ≤ k → μ[f (k + 1) - f k|ℱ i] - μ[μ[f (k + 1) - f k|ℱ k]|ℱ i] =ᵐ[μ] 0 := by
    intro k hk
    have : μ[μ[f (k + 1) - f k|ℱ k]|ℱ i] =ᵐ[μ] μ[f (k + 1) - f k|ℱ i] :=
      condexp_condexp_of_le (ℱ.mono hk) (ℱ.le k)
    filter_upwards [this] with x hx
    rw [Pi.sub_apply, Pi.zero_apply, hx, sub_self]
theorem martingale_martingalePart (hf : Adapted ℱ f) (hf_int : ∀ n, Integrable (f n) μ)
    [SigmaFiniteFiltration μ ℱ] : Martingale (martingalePart f ℱ μ) ℱ μ := by
  refine' ⟨adapted_martingalePart hf, fun i j hij => _⟩
  -- ⊢ μ[martingalePart f ℱ μ j | ℱ i] =ᵐ[μ] martingalePart f ℱ μ i
  have h_eq_sum : μ[martingalePart f ℱ μ j|ℱ i] =ᵐ[μ]
      f 0 + ∑ k in Finset.range j, (μ[f (k + 1) - f k|ℱ i] - μ[μ[f (k + 1) - f k|ℱ k]|ℱ i]) := by
    rw [martingalePart_eq_sum]
    refine' (condexp_add (hf_int 0) _).trans _
    · exact integrable_finset_sum' _ fun i _ => ((hf_int _).sub (hf_int _)).sub integrable_condexp
    refine' (EventuallyEq.add EventuallyEq.rfl (condexp_finset_sum fun i _ => _)).trans _
    · exact ((hf_int _).sub (hf_int _)).sub integrable_condexp
    refine' EventuallyEq.add _ _
    · rw [condexp_of_stronglyMeasurable (ℱ.le _) _ (hf_int 0)]
      · exact (hf 0).mono (ℱ.mono (zero_le i))
    · exact eventuallyEq_sum fun k _ => condexp_sub ((hf_int _).sub (hf_int _)) integrable_condexp
  refine' h_eq_sum.trans _
  have h_ge : ∀ k, i ≤ k → μ[f (k + 1) - f k|ℱ i] - μ[μ[f (k + 1) - f k|ℱ k]|ℱ i] =ᵐ[μ] 0 := by
    

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
n : ℕ
hf : Adapted ℱ f
hf_int : ∀ (n : ℕ), Integrable (f n)
inst✝ : SigmaFiniteFiltration μ ℱ
i j : ℕ
hij : i ≤ j
h_eq_sum :
  μ[martingalePart f ℱ μ j|↑ℱ i] =ᵐ[μ]
    f 0 + ∑ k in Finset.range j, (μ[f (k + 1) - f k|↑ℱ i] - μ[μ[f (k + 1) - f k|↑ℱ k]|↑ℱ i])
⊢ ∀ (k : ℕ), i ≤ k → μ[f (k + 1) - f k|↑ℱ i] - μ[μ[f (k + 1) - f k|↑ℱ k]|↑ℱ i] =ᵐ[μ] 0

Next tactic:
intro k hk
theorem martingale_martingalePart (hf : Adapted ℱ f) (hf_int : ∀ n, Integrable (f n) μ)
    [SigmaFiniteFiltration μ ℱ] : Martingale (martingalePart f ℱ μ) ℱ μ := by
  refine' ⟨adapted_martingalePart hf, fun i j hij => _⟩
  -- ⊢ μ[martingalePart f ℱ μ j | ℱ i] =ᵐ[μ] martingalePart f ℱ μ i
  have h_eq_sum : μ[martingalePart f ℱ μ j|ℱ i] =ᵐ[μ]
      f 0 + ∑ k in Finset.range j, (μ[f (k + 1) - f k|ℱ i] - μ[μ[f (k + 1) - f k|ℱ k]|ℱ i]) := by
    rw [martingalePart_eq_sum]
    refine' (condexp_add (hf_int 0) _).trans _
    · exact integrable_finset_sum' _ fun i _ => ((hf_int _).sub (hf_int _)).sub integrable_condexp
    refine' (EventuallyEq.add EventuallyEq.rfl (condexp_finset_sum fun i _ => _)).trans _
    · exact ((hf_int _).sub (hf_int _)).sub integrable_condexp
    refine' EventuallyEq.add _ _
    · rw [condexp_of_stronglyMeasurable (ℱ.le _) _ (hf_int 0)]
      · exact (hf 0).mono (ℱ.mono (zero_le i))
    · exact eventuallyEq_sum fun k _ => condexp_sub ((hf_int _).sub (hf_int _)) integrable_condexp
  refine' h_eq_sum.trans _
  have h_ge : ∀ k, i ≤ k → μ[f (k + 1) - f k|ℱ i] - μ[μ[f (k + 1) - f k|ℱ k]|ℱ i] =ᵐ[μ] 0 := by
    intro k hk
    

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
n : ℕ
hf : Adapted ℱ f
hf_int : ∀ (n : ℕ), Integrable (f n)
inst✝ : SigmaFiniteFiltration μ ℱ
i j : ℕ
hij : i ≤ j
h_eq_sum :
  μ[martingalePart f ℱ μ j|↑ℱ i] =ᵐ[μ]
    f 0 + ∑ k in 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] =ᵐ[μ] 0

Next tactic:
have : μ[μ[f (k + 1) - f k|ℱ k]|ℱ i] =ᵐ[μ] μ[f (k + 1) - f k|ℱ i] :=
      condexp_condexp_of_le (ℱ.mono hk) (ℱ.le k)
theorem martingale_martingalePart (hf : Adapted ℱ f) (hf_int : ∀ n, Integrable (f n) μ)
    [SigmaFiniteFiltration μ ℱ] : Martingale (martingalePart f ℱ μ) ℱ μ := by
  refine' ⟨adapted_martingalePart hf, fun i j hij => _⟩
  -- ⊢ μ[martingalePart f ℱ μ j | ℱ i] =ᵐ[μ] martingalePart f ℱ μ i
  have h_eq_sum : μ[martingalePart f ℱ μ j|ℱ i] =ᵐ[μ]
      f 0 + ∑ k in Finset.range j, (μ[f (k + 1) - f k|ℱ i] - μ[μ[f (k + 1) - f k|ℱ k]|ℱ i]) := by
    rw [martingalePart_eq_sum]
    refine' (condexp_add (hf_int 0) _).trans _
    · exact integrable_finset_sum' _ fun i _ => ((hf_int _).sub (hf_int _)).sub integrable_condexp
    refine' (EventuallyEq.add EventuallyEq.rfl (condexp_finset_sum fun i _ => _)).trans _
    · exact ((hf_int _).sub (hf_int _)).sub integrable_condexp
    refine' EventuallyEq.add _ _
    · rw [condexp_of_stronglyMeasurable (ℱ.le _) _ (hf_int 0)]
      · exact (hf 0).mono (ℱ.mono (zero_le i))
    · exact eventuallyEq_sum fun k _ => condexp_sub ((hf_int _).sub (hf_int _)) integrable_condexp
  refine' h_eq_sum.trans _
  have h_ge : ∀ k, i ≤ k → μ[f (k + 1) - f k|ℱ i] - μ[μ[f (k + 1) - f k|ℱ k]|ℱ i] =ᵐ[μ] 0 := by
    intro k hk
    have : μ[μ[f (k + 1) - f k|ℱ k]|ℱ i] =ᵐ[μ] μ[f (k + 1) - f k|ℱ i] :=
      condexp_condexp_of_le (ℱ.mono hk) (ℱ.le 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
n : ℕ
hf : Adapted ℱ f
hf_int : ∀ (n : ℕ), Integrable (f n)
inst✝ : SigmaFiniteFiltration μ ℱ
i j : ℕ
hij : i ≤ j
h_eq_sum :
  μ[martingalePart f ℱ μ j|↑ℱ i] =ᵐ[μ]
    f 0 + ∑ k in 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] =ᵐ[μ] μ[f (k + 1) - f k|↑ℱ i]
⊢ μ[f (k + 1) - f k|↑ℱ i] - μ[μ[f (k + 1) - f k|↑ℱ k]|↑ℱ i] =ᵐ[μ] 0

Next tactic:
filter_upwards [this] with x hx
theorem martingale_martingalePart (hf : Adapted ℱ f) (hf_int : ∀ n, Integrable (f n) μ)
    [SigmaFiniteFiltration μ ℱ] : Martingale (martingalePart f ℱ μ) ℱ μ := by
  refine' ⟨adapted_martingalePart hf, fun i j hij => _⟩
  -- ⊢ μ[martingalePart f ℱ μ j | ℱ i] =ᵐ[μ] martingalePart f ℱ μ i
  have h_eq_sum : μ[martingalePart f ℱ μ j|ℱ i] =ᵐ[μ]
      f 0 + ∑ k in Finset.range j, (μ[f (k + 1) - f k|ℱ i] - μ[μ[f (k + 1) - f k|ℱ k]|ℱ i]) := by
    rw [martingalePart_eq_sum]
    refine' (condexp_add (hf_int 0) _).trans _
    · exact integrable_finset_sum' _ fun i _ => ((hf_int _).sub (hf_int _)).sub integrable_condexp
    refine' (EventuallyEq.add EventuallyEq.rfl (condexp_finset_sum fun i _ => _)).trans _
    · exact ((hf_int _).sub (hf_int _)).sub integrable_condexp
    refine' EventuallyEq.add _ _
    · rw [condexp_of_stronglyMeasurable (ℱ.le _) _ (hf_int 0)]
      · exact (hf 0).mono (ℱ.mono (zero_le i))
    · exact eventuallyEq_sum fun k _ => condexp_sub ((hf_int _).sub (hf_int _)) integrable_condexp
  refine' h_eq_sum.trans _
  have h_ge : ∀ k, i ≤ k → μ[f (k + 1) - f k|ℱ i] - μ[μ[f (k + 1) - f k|ℱ k]|ℱ i] =ᵐ[μ] 0 := by
    intro k hk
    have : μ[μ[f (k + 1) - f k|ℱ k]|ℱ i] =ᵐ[μ] μ[f (k + 1) - f k|ℱ i] :=
      condexp_condexp_of_le (ℱ.mono hk) (ℱ.le k)
    filter_upwards [this] with x hx
    

Proof state:
case h
Ω : Type u_1
E : Type u_2
m0 : MeasurableSpace Ω
μ : Measure Ω
inst✝³ : NormedAddCommGroup E
inst✝² : NormedSpace ℝ E
inst✝¹ : CompleteSpace E
f : ℕ → Ω → E
ℱ : Filtration ℕ m0
n : ℕ
hf : Adapted ℱ f
hf_int : ∀ (n : ℕ), Integrable (f n)
inst✝ : SigmaFiniteFiltration μ ℱ
i j : ℕ
hij : i ≤ j
h_eq_sum :
  μ[martingalePart f ℱ μ j|↑ℱ i] =ᵐ[μ]
    f 0 + ∑ k in 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] =ᵐ[μ] μ[f (k + 1) - f k|↑ℱ i]
x : Ω
hx : (μ[μ[f (k + 1) - f k|↑ℱ k]|↑ℱ i]) x = (μ[f (k + 1) - f k|↑ℱ i]) x
⊢ (μ[f (k + 1) - f k|↑ℱ i] - μ[μ[f (k + 1) - f k|↑ℱ k]|↑ℱ i]) x = OfNat.ofNat 0 x

Next tactic:
rw [Pi.sub_apply, Pi.zero_apply, hx, sub_self]