l3lab/ntp-mathlib huggingface dataset:
theorem memℒp_stoppedProcess_of_mem_finset (hτ : IsStoppingTime ℱ τ) (hu : ∀ n, Memℒp (u n) p μ)
    (n : ι) {s : Finset ι} (hbdd : ∀ ω, τ ω < n → τ ω ∈ s) : Memℒp (stoppedProcess u τ n) p μ := by
  rw [stoppedProcess_eq_of_mem_finset n hbdd]
  refine' Memℒp.add _ _
  · exact Memℒp.indicator (ℱ.le n {a : Ω | n ≤ τ a} (hτ.measurableSet_ge n)) (hu n)
  · suffices Memℒp (fun ω => ∑ i in s.filter (· < n), {a : Ω | τ a = i}.indicator (u i) ω) p μ by
      

Proof state:
Ω : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace Ω
μ : Measure Ω
τ σ : Ω → ι
E : Type u_4
p : ℝ≥0∞
u : ι → Ω → E
inst✝⁴ : LinearOrder ι
inst✝³ : TopologicalSpace ι
inst✝² : OrderTopology ι
inst✝¹ : FirstCountableTopology ι
ℱ : Filtration ι m
inst✝ : NormedAddCommGroup E
hτ : IsStoppingTime ℱ τ
hu : ∀ (n : ι), Memℒp (u n) p
n : ι
s : Finset ι
hbdd : ∀ (ω : Ω), τ ω < n → τ ω ∈ s
this : Memℒp (fun ω => ∑ i in Finset.filter (fun x => x < n) s, Set.indicator {a | τ a = i} (u i) ω) p
⊢ Memℒp (∑ i in Finset.filter (fun x => x < n) s, Set.indicator {ω | τ ω = i} (u i)) p

Next tactic:
convert this using 1
theorem memℒp_stoppedProcess_of_mem_finset (hτ : IsStoppingTime ℱ τ) (hu : ∀ n, Memℒp (u n) p μ)
    (n : ι) {s : Finset ι} (hbdd : ∀ ω, τ ω < n → τ ω ∈ s) : Memℒp (stoppedProcess u τ n) p μ := by
  rw [stoppedProcess_eq_of_mem_finset n hbdd]
  refine' Memℒp.add _ _
  · exact Memℒp.indicator (ℱ.le n {a : Ω | n ≤ τ a} (hτ.measurableSet_ge n)) (hu n)
  · suffices Memℒp (fun ω => ∑ i in s.filter (· < n), {a : Ω | τ a = i}.indicator (u i) ω) p μ by
      convert this using 1; 

Proof state:
case h.e'_5
Ω : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace Ω
μ : Measure Ω
τ σ : Ω → ι
E : Type u_4
p : ℝ≥0∞
u : ι → Ω → E
inst✝⁴ : LinearOrder ι
inst✝³ : TopologicalSpace ι
inst✝² : OrderTopology ι
inst✝¹ : FirstCountableTopology ι
ℱ : Filtration ι m
inst✝ : NormedAddCommGroup E
hτ : IsStoppingTime ℱ τ
hu : ∀ (n : ι), Memℒp (u n) p
n : ι
s : Finset ι
hbdd : ∀ (ω : Ω), τ ω < n → τ ω ∈ s
this : Memℒp (fun ω => ∑ i in Finset.filter (fun x => x < n) s, Set.indicator {a | τ a = i} (u i) ω) p
⊢ ∑ i in Finset.filter (fun x => x < n) s, Set.indicator {ω | τ ω = i} (u i) = fun ω =>
    ∑ i in Finset.filter (fun x => x < n) s, Set.indicator {a | τ a = i} (u i) ω

Next tactic:
ext1 ω
theorem memℒp_stoppedProcess_of_mem_finset (hτ : IsStoppingTime ℱ τ) (hu : ∀ n, Memℒp (u n) p μ)
    (n : ι) {s : Finset ι} (hbdd : ∀ ω, τ ω < n → τ ω ∈ s) : Memℒp (stoppedProcess u τ n) p μ := by
  rw [stoppedProcess_eq_of_mem_finset n hbdd]
  refine' Memℒp.add _ _
  · exact Memℒp.indicator (ℱ.le n {a : Ω | n ≤ τ a} (hτ.measurableSet_ge n)) (hu n)
  · suffices Memℒp (fun ω => ∑ i in s.filter (· < n), {a : Ω | τ a = i}.indicator (u i) ω) p μ by
      convert this using 1; ext1 ω; 

Proof state:
case h.e'_5.h
Ω : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace Ω
μ : Measure Ω
τ σ : Ω → ι
E : Type u_4
p : ℝ≥0∞
u : ι → Ω → E
inst✝⁴ : LinearOrder ι
inst✝³ : TopologicalSpace ι
inst✝² : OrderTopology ι
inst✝¹ : FirstCountableTopology ι
ℱ : Filtration ι m
inst✝ : NormedAddCommGroup E
hτ : IsStoppingTime ℱ τ
hu : ∀ (n : ι), Memℒp (u n) p
n : ι
s : Finset ι
hbdd : ∀ (ω : Ω), τ ω < n → τ ω ∈ s
this : Memℒp (fun ω => ∑ i in Finset.filter (fun x => x < n) s, Set.indicator {a | τ a = i} (u i) ω) p
ω : Ω
⊢ Finset.sum (Finset.filter (fun x => x < n) s) (fun i => Set.indicator {ω | τ ω = i} (u i)) ω =
    ∑ i in Finset.filter (fun x => x < n) s, Set.indicator {a | τ a = i} (u i) ω

Next tactic:
simp only [Finset.sum_apply]
theorem memℒp_stoppedProcess_of_mem_finset (hτ : IsStoppingTime ℱ τ) (hu : ∀ n, Memℒp (u n) p μ)
    (n : ι) {s : Finset ι} (hbdd : ∀ ω, τ ω < n → τ ω ∈ s) : Memℒp (stoppedProcess u τ n) p μ := by
  rw [stoppedProcess_eq_of_mem_finset n hbdd]
  refine' Memℒp.add _ _
  · exact Memℒp.indicator (ℱ.le n {a : Ω | n ≤ τ a} (hτ.measurableSet_ge n)) (hu n)
  · suffices Memℒp (fun ω => ∑ i in s.filter (· < n), {a : Ω | τ a = i}.indicator (u i) ω) p μ by
      convert this using 1; ext1 ω; simp only [Finset.sum_apply]
    

Proof state:
case refine'_2
Ω : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace Ω
μ : Measure Ω
τ σ : Ω → ι
E : Type u_4
p : ℝ≥0∞
u : ι → Ω → E
inst✝⁴ : LinearOrder ι
inst✝³ : TopologicalSpace ι
inst✝² : OrderTopology ι
inst✝¹ : FirstCountableTopology ι
ℱ : Filtration ι m
inst✝ : NormedAddCommGroup E
hτ : IsStoppingTime ℱ τ
hu : ∀ (n : ι), Memℒp (u n) p
n : ι
s : Finset ι
hbdd : ∀ (ω : Ω), τ ω < n → τ ω ∈ s
⊢ Memℒp (fun ω => ∑ i in Finset.filter (fun x => x < n) s, Set.indicator {a | τ a = i} (u i) ω) p

Next tactic:
refine' memℒp_finset_sum _ fun i _ => Memℒp.indicator _ (hu i)
theorem memℒp_stoppedProcess_of_mem_finset (hτ : IsStoppingTime ℱ τ) (hu : ∀ n, Memℒp (u n) p μ)
    (n : ι) {s : Finset ι} (hbdd : ∀ ω, τ ω < n → τ ω ∈ s) : Memℒp (stoppedProcess u τ n) p μ := by
  rw [stoppedProcess_eq_of_mem_finset n hbdd]
  refine' Memℒp.add _ _
  · exact Memℒp.indicator (ℱ.le n {a : Ω | n ≤ τ a} (hτ.measurableSet_ge n)) (hu n)
  · suffices Memℒp (fun ω => ∑ i in s.filter (· < n), {a : Ω | τ a = i}.indicator (u i) ω) p μ by
      convert this using 1; ext1 ω; simp only [Finset.sum_apply]
    refine' memℒp_finset_sum _ fun i _ => Memℒp.indicator _ (hu i)
    

Proof state:
case refine'_2
Ω : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace Ω
μ : Measure Ω
τ σ : Ω → ι
E : Type u_4
p : ℝ≥0∞
u : ι → Ω → E
inst✝⁴ : LinearOrder ι
inst✝³ : TopologicalSpace ι
inst✝² : OrderTopology ι
inst✝¹ : FirstCountableTopology ι
ℱ : Filtration ι m
inst✝ : NormedAddCommGroup E
hτ : IsStoppingTime ℱ τ
hu : ∀ (n : ι), Memℒp (u n) p
n : ι
s : Finset ι
hbdd : ∀ (ω : Ω), τ ω < n → τ ω ∈ s
i : ι
x✝ : i ∈ Finset.filter (fun x => x < n) s
⊢ MeasurableSet {a | τ a = i}

Next tactic:
exact ℱ.le i {a : Ω | τ a = i} (hτ.measurableSet_eq i)
theorem integrable_stoppedProcess_of_mem_finset (hτ : IsStoppingTime ℱ τ)
    (hu : ∀ n, Integrable (u n) μ) (n : ι) {s : Finset ι} (hbdd : ∀ ω, τ ω < n → τ ω ∈ s) :
    Integrable (stoppedProcess u τ n) μ := by
  

Proof state:
Ω : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace Ω
μ : Measure Ω
τ σ : Ω → ι
E : Type u_4
p : ℝ≥0∞
u : ι → Ω → E
inst✝⁴ : LinearOrder ι
inst✝³ : TopologicalSpace ι
inst✝² : OrderTopology ι
inst✝¹ : FirstCountableTopology ι
ℱ : Filtration ι m
inst✝ : NormedAddCommGroup E
hτ : IsStoppingTime ℱ τ
hu : ∀ (n : ι), Integrable (u n)
n : ι
s : Finset ι
hbdd : ∀ (ω : Ω), τ ω < n → τ ω ∈ s
⊢ Integrable (stoppedProcess u τ n)

Next tactic:
simp_rw [← memℒp_one_iff_integrable] at hu ⊢
theorem integrable_stoppedProcess_of_mem_finset (hτ : IsStoppingTime ℱ τ)
    (hu : ∀ n, Integrable (u n) μ) (n : ι) {s : Finset ι} (hbdd : ∀ ω, τ ω < n → τ ω ∈ s) :
    Integrable (stoppedProcess u τ n) μ := by
  simp_rw [← memℒp_one_iff_integrable] at hu ⊢
  

Proof state:
Ω : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace Ω
μ : Measure Ω
τ σ : Ω → ι
E : Type u_4
p : ℝ≥0∞
u : ι → Ω → E
inst✝⁴ : LinearOrder ι
inst✝³ : TopologicalSpace ι
inst✝² : OrderTopology ι
inst✝¹ : FirstCountableTopology ι
ℱ : Filtration ι m
inst✝ : NormedAddCommGroup E
hτ : IsStoppingTime ℱ τ
n : ι
s : Finset ι
hbdd : ∀ (ω : Ω), τ ω < n → τ ω ∈ s
hu : ∀ (n : ι), Memℒp (u n) 1
⊢ Memℒp (stoppedProcess u τ n) 1

Next tactic:
exact memℒp_stoppedProcess_of_mem_finset hτ hu n hbdd
theorem stoppedValue_sub_eq_sum [AddCommGroup β] (hle : τ ≤ π) :
    stoppedValue u π - stoppedValue u τ = fun ω =>
      (∑ i in Finset.Ico (τ ω) (π ω), (u (i + 1) - u i)) ω := by
  

Proof state:
Ω : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace Ω
f : Filtration ℕ m
u : ℕ → Ω → β
τ π : Ω → ℕ
inst✝ : AddCommGroup β
hle : τ ≤ π
⊢ stoppedValue u π - stoppedValue u τ = fun ω => Finset.sum (Finset.Ico (τ ω) (π ω)) (fun i => u (i + 1) - u i) ω

Next tactic:
ext ω
theorem stoppedValue_sub_eq_sum [AddCommGroup β] (hle : τ ≤ π) :
    stoppedValue u π - stoppedValue u τ = fun ω =>
      (∑ i in Finset.Ico (τ ω) (π ω), (u (i + 1) - u i)) ω := by
  ext ω
  

Proof state:
case h
Ω : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace Ω
f : Filtration ℕ m
u : ℕ → Ω → β
τ π : Ω → ℕ
inst✝ : AddCommGroup β
hle : τ ≤ π
ω : Ω
⊢ (stoppedValue u π - stoppedValue u τ) ω = Finset.sum (Finset.Ico (τ ω) (π ω)) (fun i => u (i + 1) - u i) ω

Next tactic:
rw [Finset.sum_Ico_eq_sub _ (hle ω), Finset.sum_range_sub, Finset.sum_range_sub]
theorem stoppedValue_sub_eq_sum [AddCommGroup β] (hle : τ ≤ π) :
    stoppedValue u π - stoppedValue u τ = fun ω =>
      (∑ i in Finset.Ico (τ ω) (π ω), (u (i + 1) - u i)) ω := by
  ext ω
  rw [Finset.sum_Ico_eq_sub _ (hle ω), Finset.sum_range_sub, Finset.sum_range_sub]
  

Proof state:
case h
Ω : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace Ω
f : Filtration ℕ m
u : ℕ → Ω → β
τ π : Ω → ℕ
inst✝ : AddCommGroup β
hle : τ ≤ π
ω : Ω
⊢ (stoppedValue u π - stoppedValue u τ) ω = (u (π ω) - u 0 - (u (τ ω) - u 0)) ω

Next tactic:
simp [stoppedValue]
theorem stoppedValue_sub_eq_sum' [AddCommGroup β] (hle : τ ≤ π) {N : ℕ} (hbdd : ∀ ω, π ω ≤ N) :
    stoppedValue u π - stoppedValue u τ = fun ω =>
      (∑ i in Finset.range (N + 1), Set.indicator {ω | τ ω ≤ i ∧ i < π ω} (u (i + 1) - u i)) ω := by
  

Proof state:
Ω : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace Ω
f : Filtration ℕ m
u : ℕ → Ω → β
τ π : Ω → ℕ
inst✝ : AddCommGroup β
hle : τ ≤ π
N : ℕ
hbdd : ∀ (ω : Ω), π ω ≤ N
⊢ stoppedValue u π - stoppedValue u τ = fun ω =>
    Finset.sum (Finset.range (N + 1)) (fun i => Set.indicator {ω | τ ω ≤ i ∧ i < π ω} (u (i + 1) - u i)) ω

Next tactic:
rw [stoppedValue_sub_eq_sum hle]
theorem stoppedValue_sub_eq_sum' [AddCommGroup β] (hle : τ ≤ π) {N : ℕ} (hbdd : ∀ ω, π ω ≤ N) :
    stoppedValue u π - stoppedValue u τ = fun ω =>
      (∑ i in Finset.range (N + 1), Set.indicator {ω | τ ω ≤ i ∧ i < π ω} (u (i + 1) - u i)) ω := by
  rw [stoppedValue_sub_eq_sum hle]
  

Proof state:
Ω : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace Ω
f : Filtration ℕ m
u : ℕ → Ω → β
τ π : Ω → ℕ
inst✝ : AddCommGroup β
hle : τ ≤ π
N : ℕ
hbdd : ∀ (ω : Ω), π ω ≤ N
⊢ (fun ω => Finset.sum (Finset.Ico (τ ω) (π ω)) (fun i => u (i + 1) - u i) ω) = fun ω =>
    Finset.sum (Finset.range (N + 1)) (fun i => Set.indicator {ω | τ ω ≤ i ∧ i < π ω} (u (i + 1) - u i)) ω

Next tactic:
ext ω
theorem stoppedValue_sub_eq_sum' [AddCommGroup β] (hle : τ ≤ π) {N : ℕ} (hbdd : ∀ ω, π ω ≤ N) :
    stoppedValue u π - stoppedValue u τ = fun ω =>
      (∑ i in Finset.range (N + 1), Set.indicator {ω | τ ω ≤ i ∧ i < π ω} (u (i + 1) - u i)) ω := by
  rw [stoppedValue_sub_eq_sum hle]
  ext ω
  

Proof state:
case h
Ω : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace Ω
f : Filtration ℕ m
u : ℕ → Ω → β
τ π : Ω → ℕ
inst✝ : AddCommGroup β
hle : τ ≤ π
N : ℕ
hbdd : ∀ (ω : Ω), π ω ≤ N
ω : Ω
⊢ Finset.sum (Finset.Ico (τ ω) (π ω)) (fun i => u (i + 1) - u i) ω =
    Finset.sum (Finset.range (N + 1)) (fun i => Set.indicator {ω | τ ω ≤ i ∧ i < π ω} (u (i + 1) - u i)) ω

Next tactic:
simp only [Finset.sum_apply, Finset.sum_indicator_eq_sum_filter]
theorem stoppedValue_sub_eq_sum' [AddCommGroup β] (hle : τ ≤ π) {N : ℕ} (hbdd : ∀ ω, π ω ≤ N) :
    stoppedValue u π - stoppedValue u τ = fun ω =>
      (∑ i in Finset.range (N + 1), Set.indicator {ω | τ ω ≤ i ∧ i < π ω} (u (i + 1) - u i)) ω := by
  rw [stoppedValue_sub_eq_sum hle]
  ext ω
  simp only [Finset.sum_apply, Finset.sum_indicator_eq_sum_filter]
  

Proof state:
case h
Ω : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace Ω
f : Filtration ℕ m
u : ℕ → Ω → β
τ π : Ω → ℕ
inst✝ : AddCommGroup β
hle : τ ≤ π
N : ℕ
hbdd : ∀ (ω : Ω), π ω ≤ N
ω : Ω
⊢ ∑ c in Finset.Ico (τ ω) (π ω), (u (c + 1) - u c) ω =
    ∑ c in Finset.filter (fun i => ω ∈ {ω | τ ω ≤ i ∧ i < π ω}) (Finset.range (N + 1)), (u (c + 1) - u c) ω

Next tactic:
refine' Finset.sum_congr _ fun _ _ => rfl
theorem stoppedValue_sub_eq_sum' [AddCommGroup β] (hle : τ ≤ π) {N : ℕ} (hbdd : ∀ ω, π ω ≤ N) :
    stoppedValue u π - stoppedValue u τ = fun ω =>
      (∑ i in Finset.range (N + 1), Set.indicator {ω | τ ω ≤ i ∧ i < π ω} (u (i + 1) - u i)) ω := by
  rw [stoppedValue_sub_eq_sum hle]
  ext ω
  simp only [Finset.sum_apply, Finset.sum_indicator_eq_sum_filter]
  refine' Finset.sum_congr _ fun _ _ => rfl
  

Proof state:
case h
Ω : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace Ω
f : Filtration ℕ m
u : ℕ → Ω → β
τ π : Ω → ℕ
inst✝ : AddCommGroup β
hle : τ ≤ π
N : ℕ
hbdd : ∀ (ω : Ω), π ω ≤ N
ω : Ω
⊢ Finset.Ico (τ ω) (π ω) = Finset.filter (fun i => ω ∈ {ω | τ ω ≤ i ∧ i < π ω}) (Finset.range (N + 1))

Next tactic:
ext i
theorem stoppedValue_sub_eq_sum' [AddCommGroup β] (hle : τ ≤ π) {N : ℕ} (hbdd : ∀ ω, π ω ≤ N) :
    stoppedValue u π - stoppedValue u τ = fun ω =>
      (∑ i in Finset.range (N + 1), Set.indicator {ω | τ ω ≤ i ∧ i < π ω} (u (i + 1) - u i)) ω := by
  rw [stoppedValue_sub_eq_sum hle]
  ext ω
  simp only [Finset.sum_apply, Finset.sum_indicator_eq_sum_filter]
  refine' Finset.sum_congr _ fun _ _ => rfl
  ext i
  

Proof state:
case h.a
Ω : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace Ω
f : Filtration ℕ m
u : ℕ → Ω → β
τ π : Ω → ℕ
inst✝ : AddCommGroup β
hle : τ ≤ π
N : ℕ
hbdd : ∀ (ω : Ω), π ω ≤ N
ω : Ω
i : ℕ
⊢ i ∈ Finset.Ico (τ ω) (π ω) ↔ i ∈ Finset.filter (fun i => ω ∈ {ω | τ ω ≤ i ∧ i < π ω}) (Finset.range (N + 1))

Next tactic:
simp only [Finset.mem_filter, Set.mem_setOf_eq, Finset.mem_range, Finset.mem_Ico]
theorem stoppedValue_sub_eq_sum' [AddCommGroup β] (hle : τ ≤ π) {N : ℕ} (hbdd : ∀ ω, π ω ≤ N) :
    stoppedValue u π - stoppedValue u τ = fun ω =>
      (∑ i in Finset.range (N + 1), Set.indicator {ω | τ ω ≤ i ∧ i < π ω} (u (i + 1) - u i)) ω := by
  rw [stoppedValue_sub_eq_sum hle]
  ext ω
  simp only [Finset.sum_apply, Finset.sum_indicator_eq_sum_filter]
  refine' Finset.sum_congr _ fun _ _ => rfl
  ext i
  simp only [Finset.mem_filter, Set.mem_setOf_eq, Finset.mem_range, Finset.mem_Ico]
  

Proof state:
case h.a
Ω : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace Ω
f : Filtration ℕ m
u : ℕ → Ω → β
τ π : Ω → ℕ
inst✝ : AddCommGroup β
hle : τ ≤ π
N : ℕ
hbdd : ∀ (ω : Ω), π ω ≤ N
ω : Ω
i : ℕ
⊢ τ ω ≤ i ∧ i < π ω ↔ i < N + 1 ∧ τ ω ≤ i ∧ i < π ω

Next tactic:
exact ⟨fun h => ⟨lt_trans h.2 (Nat.lt_succ_iff.2 <| hbdd _), h⟩, fun h => h.2⟩
theorem stoppedProcess_eq (n : ℕ) : stoppedProcess u τ n = Set.indicator {a | n ≤ τ a} (u n) +
    ∑ i in Finset.range n, Set.indicator {ω | τ ω = i} (u i) := by
  

Proof state:
Ω : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace Ω
f : Filtration ℕ m
u : ℕ → Ω → β
τ π : Ω → ℕ
inst✝ : AddCommMonoid β
n : ℕ
⊢ stoppedProcess u τ n = Set.indicator {a | n ≤ τ a} (u n) + ∑ i in Finset.range n, Set.indicator {ω | τ ω = i} (u i)

Next tactic:
rw [stoppedProcess_eq'' n]
theorem stoppedProcess_eq (n : ℕ) : stoppedProcess u τ n = Set.indicator {a | n ≤ τ a} (u n) +
    ∑ i in Finset.range n, Set.indicator {ω | τ ω = i} (u i) := by
  rw [stoppedProcess_eq'' n]
  

Proof state:
Ω : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace Ω
f : Filtration ℕ m
u : ℕ → Ω → β
τ π : Ω → ℕ
inst✝ : AddCommMonoid β
n : ℕ
⊢ Set.indicator {a | n ≤ τ a} (u n) + ∑ i in Finset.Iio n, Set.indicator {ω | τ ω = i} (u i) =
    Set.indicator {a | n ≤ τ a} (u n) + ∑ i in Finset.range n, Set.indicator {ω | τ ω = i} (u i)

Next tactic:
congr with i
theorem stoppedProcess_eq (n : ℕ) : stoppedProcess u τ n = Set.indicator {a | n ≤ τ a} (u n) +
    ∑ i in Finset.range n, Set.indicator {ω | τ ω = i} (u i) := by
  rw [stoppedProcess_eq'' n]
  congr with i
  

Proof state:
case e_a.e_s.a
Ω : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace Ω
f : Filtration ℕ m
u : ℕ → Ω → β
τ π : Ω → ℕ
inst✝ : AddCommMonoid β
n i : ℕ
⊢ i ∈ Finset.Iio n ↔ i ∈ Finset.range n

Next tactic:
rw [Finset.mem_Iio, Finset.mem_range]
theorem stoppedProcess_eq' (n : ℕ) : stoppedProcess u τ n = Set.indicator {a | n + 1 ≤ τ a} (u n) +
    ∑ i in Finset.range (n + 1), Set.indicator {a | τ a = i} (u i) := by
  

Proof state:
Ω : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace Ω
f : Filtration ℕ m
u : ℕ → Ω → β
τ π : Ω → ℕ
inst✝ : AddCommMonoid β
n : ℕ
⊢ stoppedProcess u τ n =
    Set.indicator {a | n + 1 ≤ τ a} (u n) + ∑ i in Finset.range (n + 1), Set.indicator {a | τ a = i} (u i)

Next tactic:
have : {a | n ≤ τ a}.indicator (u n) =
      {a | n + 1 ≤ τ a}.indicator (u n) + {a | τ a = n}.indicator (u n) := by
    ext x
    rw [add_comm, Pi.add_apply, ← Set.indicator_union_of_not_mem_inter]
    · simp_rw [@eq_comm _ _ n, @le_iff_eq_or_lt _ _ n, Nat.succ_le_iff]
      rfl
    · rintro ⟨h₁, h₂⟩
      exact (Nat.succ_le_iff.1 h₂).ne h₁.symm
theorem stoppedProcess_eq' (n : ℕ) : stoppedProcess u τ n = Set.indicator {a | n + 1 ≤ τ a} (u n) +
    ∑ i in Finset.range (n + 1), Set.indicator {a | τ a = i} (u i) := by
  have : {a | n ≤ τ a}.indicator (u n) =
      {a | n + 1 ≤ τ a}.indicator (u n) + {a | τ a = n}.indicator (u n) := by
    

Proof state:
Ω : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace Ω
f : Filtration ℕ m
u : ℕ → Ω → β
τ π : Ω → ℕ
inst✝ : AddCommMonoid β
n : ℕ
⊢ Set.indicator {a | n ≤ τ a} (u n) = Set.indicator {a | n + 1 ≤ τ a} (u n) + Set.indicator {a | τ a = n} (u n)

Next tactic:
ext x
theorem stoppedProcess_eq' (n : ℕ) : stoppedProcess u τ n = Set.indicator {a | n + 1 ≤ τ a} (u n) +
    ∑ i in Finset.range (n + 1), Set.indicator {a | τ a = i} (u i) := by
  have : {a | n ≤ τ a}.indicator (u n) =
      {a | n + 1 ≤ τ a}.indicator (u n) + {a | τ a = n}.indicator (u n) := by
    ext x
    

Proof state:
case h
Ω : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace Ω
f : Filtration ℕ m
u : ℕ → Ω → β
τ π : Ω → ℕ
inst✝ : AddCommMonoid β
n : ℕ
x : Ω
⊢ Set.indicator {a | n ≤ τ a} (u n) x = (Set.indicator {a | n + 1 ≤ τ a} (u n) + Set.indicator {a | τ a = n} (u n)) x

Next tactic:
rw [add_comm, Pi.add_apply, ← Set.indicator_union_of_not_mem_inter]
theorem stoppedProcess_eq' (n : ℕ) : stoppedProcess u τ n = Set.indicator {a | n + 1 ≤ τ a} (u n) +
    ∑ i in Finset.range (n + 1), Set.indicator {a | τ a = i} (u i) := by
  have : {a | n ≤ τ a}.indicator (u n) =
      {a | n + 1 ≤ τ a}.indicator (u n) + {a | τ a = n}.indicator (u n) := by
    ext x
    rw [add_comm, Pi.add_apply, ← Set.indicator_union_of_not_mem_inter]
    · 

Proof state:
case h
Ω : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace Ω
f : Filtration ℕ m
u : ℕ → Ω → β
τ π : Ω → ℕ
inst✝ : AddCommMonoid β
n : ℕ
x : Ω
⊢ Set.indicator {a | n ≤ τ a} (u n) x = Set.indicator ({a | τ a = n} ∪ {a | n + 1 ≤ τ a}) (u n) x

Next tactic:
simp_rw [@eq_comm _ _ n, @le_iff_eq_or_lt _ _ n, Nat.succ_le_iff]
theorem stoppedProcess_eq' (n : ℕ) : stoppedProcess u τ n = Set.indicator {a | n + 1 ≤ τ a} (u n) +
    ∑ i in Finset.range (n + 1), Set.indicator {a | τ a = i} (u i) := by
  have : {a | n ≤ τ a}.indicator (u n) =
      {a | n + 1 ≤ τ a}.indicator (u n) + {a | τ a = n}.indicator (u n) := by
    ext x
    rw [add_comm, Pi.add_apply, ← Set.indicator_union_of_not_mem_inter]
    · simp_rw [@eq_comm _ _ n, @le_iff_eq_or_lt _ _ n, Nat.succ_le_iff]
      

Proof state:
case h
Ω : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace Ω
f : Filtration ℕ m
u : ℕ → Ω → β
τ π : Ω → ℕ
inst✝ : AddCommMonoid β
n : ℕ
x : Ω
⊢ Set.indicator {a | n = τ a ∨ n < τ a} (u n) x = Set.indicator ({a | n = τ a} ∪ {a | n < τ a}) (u n) x

Next tactic:
rfl
theorem stoppedProcess_eq' (n : ℕ) : stoppedProcess u τ n = Set.indicator {a | n + 1 ≤ τ a} (u n) +
    ∑ i in Finset.range (n + 1), Set.indicator {a | τ a = i} (u i) := by
  have : {a | n ≤ τ a}.indicator (u n) =
      {a | n + 1 ≤ τ a}.indicator (u n) + {a | τ a = n}.indicator (u n) := by
    ext x
    rw [add_comm, Pi.add_apply, ← Set.indicator_union_of_not_mem_inter]
    · simp_rw [@eq_comm _ _ n, @le_iff_eq_or_lt _ _ n, Nat.succ_le_iff]
      rfl
    · 

Proof state:
case h.h
Ω : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace Ω
f : Filtration ℕ m
u : ℕ → Ω → β
τ π : Ω → ℕ
inst✝ : AddCommMonoid β
n : ℕ
x : Ω
⊢ x ∉ {a | τ a = n} ∩ {a | n + 1 ≤ τ a}

Next tactic:
rintro ⟨h₁, h₂⟩
theorem stoppedProcess_eq' (n : ℕ) : stoppedProcess u τ n = Set.indicator {a | n + 1 ≤ τ a} (u n) +
    ∑ i in Finset.range (n + 1), Set.indicator {a | τ a = i} (u i) := by
  have : {a | n ≤ τ a}.indicator (u n) =
      {a | n + 1 ≤ τ a}.indicator (u n) + {a | τ a = n}.indicator (u n) := by
    ext x
    rw [add_comm, Pi.add_apply, ← Set.indicator_union_of_not_mem_inter]
    · simp_rw [@eq_comm _ _ n, @le_iff_eq_or_lt _ _ n, Nat.succ_le_iff]
      rfl
    · rintro ⟨h₁, h₂⟩
      

Proof state:
case h.h.intro
Ω : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace Ω
f : Filtration ℕ m
u : ℕ → Ω → β
τ π : Ω → ℕ
inst✝ : AddCommMonoid β
n : ℕ
x : Ω
h₁ : x ∈ {a | τ a = n}
h₂ : x ∈ {a | n + 1 ≤ τ a}
⊢ False

Next tactic:
exact (Nat.succ_le_iff.1 h₂).ne h₁.symm
theorem stoppedProcess_eq' (n : ℕ) : stoppedProcess u τ n = Set.indicator {a | n + 1 ≤ τ a} (u n) +
    ∑ i in Finset.range (n + 1), Set.indicator {a | τ a = i} (u i) := by
  have : {a | n ≤ τ a}.indicator (u n) =
      {a | n + 1 ≤ τ a}.indicator (u n) + {a | τ a = n}.indicator (u n) := by
    ext x
    rw [add_comm, Pi.add_apply, ← Set.indicator_union_of_not_mem_inter]
    · simp_rw [@eq_comm _ _ n, @le_iff_eq_or_lt _ _ n, Nat.succ_le_iff]
      rfl
    · rintro ⟨h₁, h₂⟩
      exact (Nat.succ_le_iff.1 h₂).ne h₁.symm
  

Proof state:
Ω : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace Ω
f : Filtration ℕ m
u : ℕ → Ω → β
τ π : Ω → ℕ
inst✝ : AddCommMonoid β
n : ℕ
this : Set.indicator {a | n ≤ τ a} (u n) = Set.indicator {a | n + 1 ≤ τ a} (u n) + Set.indicator {a | τ a = n} (u n)
⊢ stoppedProcess u τ n =
    Set.indicator {a | n + 1 ≤ τ a} (u n) + ∑ i in Finset.range (n + 1), Set.indicator {a | τ a = i} (u i)

Next tactic:
rw [stoppedProcess_eq, this, Finset.sum_range_succ_comm, ← add_assoc]
/-- Given stopping times `τ` and `η` which are bounded below, `Set.piecewise s τ η` is also
a stopping time with respect to the same filtration. -/
theorem IsStoppingTime.piecewise_of_le (hτ_st : IsStoppingTime 𝒢 τ) (hη_st : IsStoppingTime 𝒢 η)
    (hτ : ∀ ω, i ≤ τ ω) (hη : ∀ ω, i ≤ η ω) (hs : MeasurableSet[𝒢 i] s) :
    IsStoppingTime 𝒢 (s.piecewise τ η) := by
  

Proof state:
Ω : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace Ω
inst✝¹ : Preorder ι
𝒢 : Filtration ι m
τ η : Ω → ι
i j : ι
s : Set Ω
inst✝ : DecidablePred fun x => x ∈ s
hτ_st : IsStoppingTime 𝒢 τ
hη_st : IsStoppingTime 𝒢 η
hτ : ∀ (ω : Ω), i ≤ τ ω
hη : ∀ (ω : Ω), i ≤ η ω
hs : MeasurableSet s
⊢ IsStoppingTime 𝒢 (Set.piecewise s τ η)

Next tactic:
intro n
/-- Given stopping times `τ` and `η` which are bounded below, `Set.piecewise s τ η` is also
a stopping time with respect to the same filtration. -/
theorem IsStoppingTime.piecewise_of_le (hτ_st : IsStoppingTime 𝒢 τ) (hη_st : IsStoppingTime 𝒢 η)
    (hτ : ∀ ω, i ≤ τ ω) (hη : ∀ ω, i ≤ η ω) (hs : MeasurableSet[𝒢 i] s) :
    IsStoppingTime 𝒢 (s.piecewise τ η) := by
  intro n
  

Proof state:
Ω : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace Ω
inst✝¹ : Preorder ι
𝒢 : Filtration ι m
τ η : Ω → ι
i j : ι
s : Set Ω
inst✝ : DecidablePred fun x => x ∈ s
hτ_st : IsStoppingTime 𝒢 τ
hη_st : IsStoppingTime 𝒢 η
hτ : ∀ (ω : Ω), i ≤ τ ω
hη : ∀ (ω : Ω), i ≤ η ω
hs : MeasurableSet s
n : ι
⊢ MeasurableSet {ω | Set.piecewise s τ η ω ≤ n}

Next tactic:
have : {ω | s.piecewise τ η ω ≤ n} = s ∩ {ω | τ ω ≤ n} ∪ sᶜ ∩ {ω | η ω ≤ n} := by
    ext1 ω
    simp only [Set.piecewise, Set.mem_inter_iff, Set.mem_setOf_eq, and_congr_right_iff]
    by_cases hx : ω ∈ s <;> simp [hx]
/-- Given stopping times `τ` and `η` which are bounded below, `Set.piecewise s τ η` is also
a stopping time with respect to the same filtration. -/
theorem IsStoppingTime.piecewise_of_le (hτ_st : IsStoppingTime 𝒢 τ) (hη_st : IsStoppingTime 𝒢 η)
    (hτ : ∀ ω, i ≤ τ ω) (hη : ∀ ω, i ≤ η ω) (hs : MeasurableSet[𝒢 i] s) :
    IsStoppingTime 𝒢 (s.piecewise τ η) := by
  intro n
  have : {ω | s.piecewise τ η ω ≤ n} = s ∩ {ω | τ ω ≤ n} ∪ sᶜ ∩ {ω | η ω ≤ n} := by
    

Proof state:
Ω : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace Ω
inst✝¹ : Preorder ι
𝒢 : Filtration ι m
τ η : Ω → ι
i j : ι
s : Set Ω
inst✝ : DecidablePred fun x => x ∈ s
hτ_st : IsStoppingTime 𝒢 τ
hη_st : IsStoppingTime 𝒢 η
hτ : ∀ (ω : Ω), i ≤ τ ω
hη : ∀ (ω : Ω), i ≤ η ω
hs : MeasurableSet s
n : ι
⊢ {ω | Set.piecewise s τ η ω ≤ n} = s ∩ {ω | τ ω ≤ n} ∪ sᶜ ∩ {ω | η ω ≤ n}

Next tactic:
ext1 ω