l3lab/ntp-mathlib huggingface dataset:
theorem measurable_limit_of_tendsto_metrizable_ae {ι} [Countable ι] [Nonempty ι] {μ : Measure α}
    {f : ι → α → β} {L : Filter ι} [L.IsCountablyGenerated] (hf : ∀ n, AEMeasurable (f n) μ)
    (h_ae_tendsto : ∀ᵐ x ∂μ, ∃ l : β, Tendsto (fun n => f n x) L (𝓝 l)) :
    ∃ f_lim : α → β, Measurable f_lim ∧ ∀ᵐ x ∂μ, Tendsto (fun n => f n x) L (𝓝 (f_lim x)) := by
  inhabit ι
  rcases eq_or_neBot L with (rfl | hL)
  · exact ⟨(hf default).mk _, (hf default).measurable_mk, eventually_of_forall fun x => tendsto_bot⟩
  let p : α → (ι → β) → Prop := fun x f' => ∃ l : β, Tendsto (fun n => f' n) L (𝓝 l)
  have hp_mem : ∀ x ∈ aeSeqSet hf p, p x fun n => f n x := fun x hx =>
    aeSeq.fun_prop_of_mem_aeSeqSet hf hx
  have h_ae_eq : ∀ᵐ x ∂μ, ∀ n, aeSeq hf p n x = f n x := aeSeq.aeSeq_eq_fun_ae hf h_ae_tendsto
  

Proof state:
case inr
α : Type u_1
β : Type u_2
inst✝⁷ : MeasurableSpace α
inst✝⁶ : TopologicalSpace β
inst✝⁵ : PseudoMetrizableSpace β
inst✝⁴ : MeasurableSpace β
inst✝³ : BorelSpace β
ι : Type u_3
inst✝² : Countable ι
inst✝¹ : Nonempty ι
μ : Measure α
f : ι → α → β
L : Filter ι
inst✝ : IsCountablyGenerated L
hf : ∀ (n : ι), AEMeasurable (f n)
h_ae_tendsto : ∀ᵐ (x : α) ∂μ, ∃ l, Tendsto (fun n => f n x) L (𝓝 l)
inhabited_h : Inhabited ι
hL : NeBot L
p : α → (ι → β) → Prop := fun x f' => ∃ l, Tendsto (fun n => f' n) L (𝓝 l)
hp_mem : ∀ x ∈ aeSeqSet hf p, p x fun n => f n x
h_ae_eq : ∀ᵐ (x : α) ∂μ, ∀ (n : ι), aeSeq hf p n x = f n x
⊢ ∃ f_lim, Measurable f_lim ∧ ∀ᵐ (x : α) ∂μ, Tendsto (fun n => f n x) L (𝓝 (f_lim x))

Next tactic:
set f_lim : α → β := fun x => dite (x ∈ aeSeqSet hf p) (fun h => (hp_mem x h).choose)
    fun _ => (⟨f default x⟩ : Nonempty β).some
theorem measurable_limit_of_tendsto_metrizable_ae {ι} [Countable ι] [Nonempty ι] {μ : Measure α}
    {f : ι → α → β} {L : Filter ι} [L.IsCountablyGenerated] (hf : ∀ n, AEMeasurable (f n) μ)
    (h_ae_tendsto : ∀ᵐ x ∂μ, ∃ l : β, Tendsto (fun n => f n x) L (𝓝 l)) :
    ∃ f_lim : α → β, Measurable f_lim ∧ ∀ᵐ x ∂μ, Tendsto (fun n => f n x) L (𝓝 (f_lim x)) := by
  inhabit ι
  rcases eq_or_neBot L with (rfl | hL)
  · exact ⟨(hf default).mk _, (hf default).measurable_mk, eventually_of_forall fun x => tendsto_bot⟩
  let p : α → (ι → β) → Prop := fun x f' => ∃ l : β, Tendsto (fun n => f' n) L (𝓝 l)
  have hp_mem : ∀ x ∈ aeSeqSet hf p, p x fun n => f n x := fun x hx =>
    aeSeq.fun_prop_of_mem_aeSeqSet hf hx
  have h_ae_eq : ∀ᵐ x ∂μ, ∀ n, aeSeq hf p n x = f n x := aeSeq.aeSeq_eq_fun_ae hf h_ae_tendsto
  set f_lim : α → β := fun x => dite (x ∈ aeSeqSet hf p) (fun h => (hp_mem x h).choose)
    fun _ => (⟨f default x⟩ : Nonempty β).some
  

Proof state:
case inr
α : Type u_1
β : Type u_2
inst✝⁷ : MeasurableSpace α
inst✝⁶ : TopologicalSpace β
inst✝⁵ : PseudoMetrizableSpace β
inst✝⁴ : MeasurableSpace β
inst✝³ : BorelSpace β
ι : Type u_3
inst✝² : Countable ι
inst✝¹ : Nonempty ι
μ : Measure α
f : ι → α → β
L : Filter ι
inst✝ : IsCountablyGenerated L
hf : ∀ (n : ι), AEMeasurable (f n)
h_ae_tendsto : ∀ᵐ (x : α) ∂μ, ∃ l, Tendsto (fun n => f n x) L (𝓝 l)
inhabited_h : Inhabited ι
hL : NeBot L
p : α → (ι → β) → Prop := fun x f' => ∃ l, Tendsto (fun n => f' n) L (𝓝 l)
hp_mem : ∀ x ∈ aeSeqSet hf p, p x fun n => f n x
h_ae_eq : ∀ᵐ (x : α) ∂μ, ∀ (n : ι), aeSeq hf p n x = f n x
f_lim : α → β :=
  fun x => if h : x ∈ aeSeqSet hf p then Exists.choose (_ : p x fun n => f n x) else Nonempty.some (_ : Nonempty β)
⊢ ∃ f_lim, Measurable f_lim ∧ ∀ᵐ (x : α) ∂μ, Tendsto (fun n => f n x) L (𝓝 (f_lim x))

Next tactic:
have hf_lim : ∀ x, Tendsto (fun n => aeSeq hf p n x) L (𝓝 (f_lim x)) := by
    intro x
    simp only [aeSeq]
    split_ifs with h
    · refine' (hp_mem x h).choose_spec.congr fun n => _
      exact (aeSeq.mk_eq_fun_of_mem_aeSeqSet hf h n).symm
    · exact tendsto_const_nhds
theorem measurable_limit_of_tendsto_metrizable_ae {ι} [Countable ι] [Nonempty ι] {μ : Measure α}
    {f : ι → α → β} {L : Filter ι} [L.IsCountablyGenerated] (hf : ∀ n, AEMeasurable (f n) μ)
    (h_ae_tendsto : ∀ᵐ x ∂μ, ∃ l : β, Tendsto (fun n => f n x) L (𝓝 l)) :
    ∃ f_lim : α → β, Measurable f_lim ∧ ∀ᵐ x ∂μ, Tendsto (fun n => f n x) L (𝓝 (f_lim x)) := by
  inhabit ι
  rcases eq_or_neBot L with (rfl | hL)
  · exact ⟨(hf default).mk _, (hf default).measurable_mk, eventually_of_forall fun x => tendsto_bot⟩
  let p : α → (ι → β) → Prop := fun x f' => ∃ l : β, Tendsto (fun n => f' n) L (𝓝 l)
  have hp_mem : ∀ x ∈ aeSeqSet hf p, p x fun n => f n x := fun x hx =>
    aeSeq.fun_prop_of_mem_aeSeqSet hf hx
  have h_ae_eq : ∀ᵐ x ∂μ, ∀ n, aeSeq hf p n x = f n x := aeSeq.aeSeq_eq_fun_ae hf h_ae_tendsto
  set f_lim : α → β := fun x => dite (x ∈ aeSeqSet hf p) (fun h => (hp_mem x h).choose)
    fun _ => (⟨f default x⟩ : Nonempty β).some
  have hf_lim : ∀ x, Tendsto (fun n => aeSeq hf p n x) L (𝓝 (f_lim x)) := by
    

Proof state:
α : Type u_1
β : Type u_2
inst✝⁷ : MeasurableSpace α
inst✝⁶ : TopologicalSpace β
inst✝⁵ : PseudoMetrizableSpace β
inst✝⁴ : MeasurableSpace β
inst✝³ : BorelSpace β
ι : Type u_3
inst✝² : Countable ι
inst✝¹ : Nonempty ι
μ : Measure α
f : ι → α → β
L : Filter ι
inst✝ : IsCountablyGenerated L
hf : ∀ (n : ι), AEMeasurable (f n)
h_ae_tendsto : ∀ᵐ (x : α) ∂μ, ∃ l, Tendsto (fun n => f n x) L (𝓝 l)
inhabited_h : Inhabited ι
hL : NeBot L
p : α → (ι → β) → Prop := fun x f' => ∃ l, Tendsto (fun n => f' n) L (𝓝 l)
hp_mem : ∀ x ∈ aeSeqSet hf p, p x fun n => f n x
h_ae_eq : ∀ᵐ (x : α) ∂μ, ∀ (n : ι), aeSeq hf p n x = f n x
f_lim : α → β :=
  fun x => if h : x ∈ aeSeqSet hf p then Exists.choose (_ : p x fun n => f n x) else Nonempty.some (_ : Nonempty β)
⊢ ∀ (x : α), Tendsto (fun n => aeSeq hf p n x) L (𝓝 (f_lim x))

Next tactic:
intro x
theorem measurable_limit_of_tendsto_metrizable_ae {ι} [Countable ι] [Nonempty ι] {μ : Measure α}
    {f : ι → α → β} {L : Filter ι} [L.IsCountablyGenerated] (hf : ∀ n, AEMeasurable (f n) μ)
    (h_ae_tendsto : ∀ᵐ x ∂μ, ∃ l : β, Tendsto (fun n => f n x) L (𝓝 l)) :
    ∃ f_lim : α → β, Measurable f_lim ∧ ∀ᵐ x ∂μ, Tendsto (fun n => f n x) L (𝓝 (f_lim x)) := by
  inhabit ι
  rcases eq_or_neBot L with (rfl | hL)
  · exact ⟨(hf default).mk _, (hf default).measurable_mk, eventually_of_forall fun x => tendsto_bot⟩
  let p : α → (ι → β) → Prop := fun x f' => ∃ l : β, Tendsto (fun n => f' n) L (𝓝 l)
  have hp_mem : ∀ x ∈ aeSeqSet hf p, p x fun n => f n x := fun x hx =>
    aeSeq.fun_prop_of_mem_aeSeqSet hf hx
  have h_ae_eq : ∀ᵐ x ∂μ, ∀ n, aeSeq hf p n x = f n x := aeSeq.aeSeq_eq_fun_ae hf h_ae_tendsto
  set f_lim : α → β := fun x => dite (x ∈ aeSeqSet hf p) (fun h => (hp_mem x h).choose)
    fun _ => (⟨f default x⟩ : Nonempty β).some
  have hf_lim : ∀ x, Tendsto (fun n => aeSeq hf p n x) L (𝓝 (f_lim x)) := by
    intro x
    

Proof state:
α : Type u_1
β : Type u_2
inst✝⁷ : MeasurableSpace α
inst✝⁶ : TopologicalSpace β
inst✝⁵ : PseudoMetrizableSpace β
inst✝⁴ : MeasurableSpace β
inst✝³ : BorelSpace β
ι : Type u_3
inst✝² : Countable ι
inst✝¹ : Nonempty ι
μ : Measure α
f : ι → α → β
L : Filter ι
inst✝ : IsCountablyGenerated L
hf : ∀ (n : ι), AEMeasurable (f n)
h_ae_tendsto : ∀ᵐ (x : α) ∂μ, ∃ l, Tendsto (fun n => f n x) L (𝓝 l)
inhabited_h : Inhabited ι
hL : NeBot L
p : α → (ι → β) → Prop := fun x f' => ∃ l, Tendsto (fun n => f' n) L (𝓝 l)
hp_mem : ∀ x ∈ aeSeqSet hf p, p x fun n => f n x
h_ae_eq : ∀ᵐ (x : α) ∂μ, ∀ (n : ι), aeSeq hf p n x = f n x
f_lim : α → β :=
  fun x => if h : x ∈ aeSeqSet hf p then Exists.choose (_ : p x fun n => f n x) else Nonempty.some (_ : Nonempty β)
x : α
⊢ Tendsto (fun n => aeSeq hf p n x) L (𝓝 (f_lim x))

Next tactic:
simp only [aeSeq]
theorem measurable_limit_of_tendsto_metrizable_ae {ι} [Countable ι] [Nonempty ι] {μ : Measure α}
    {f : ι → α → β} {L : Filter ι} [L.IsCountablyGenerated] (hf : ∀ n, AEMeasurable (f n) μ)
    (h_ae_tendsto : ∀ᵐ x ∂μ, ∃ l : β, Tendsto (fun n => f n x) L (𝓝 l)) :
    ∃ f_lim : α → β, Measurable f_lim ∧ ∀ᵐ x ∂μ, Tendsto (fun n => f n x) L (𝓝 (f_lim x)) := by
  inhabit ι
  rcases eq_or_neBot L with (rfl | hL)
  · exact ⟨(hf default).mk _, (hf default).measurable_mk, eventually_of_forall fun x => tendsto_bot⟩
  let p : α → (ι → β) → Prop := fun x f' => ∃ l : β, Tendsto (fun n => f' n) L (𝓝 l)
  have hp_mem : ∀ x ∈ aeSeqSet hf p, p x fun n => f n x := fun x hx =>
    aeSeq.fun_prop_of_mem_aeSeqSet hf hx
  have h_ae_eq : ∀ᵐ x ∂μ, ∀ n, aeSeq hf p n x = f n x := aeSeq.aeSeq_eq_fun_ae hf h_ae_tendsto
  set f_lim : α → β := fun x => dite (x ∈ aeSeqSet hf p) (fun h => (hp_mem x h).choose)
    fun _ => (⟨f default x⟩ : Nonempty β).some
  have hf_lim : ∀ x, Tendsto (fun n => aeSeq hf p n x) L (𝓝 (f_lim x)) := by
    intro x
    simp only [aeSeq]
    

Proof state:
α : Type u_1
β : Type u_2
inst✝⁷ : MeasurableSpace α
inst✝⁶ : TopologicalSpace β
inst✝⁵ : PseudoMetrizableSpace β
inst✝⁴ : MeasurableSpace β
inst✝³ : BorelSpace β
ι : Type u_3
inst✝² : Countable ι
inst✝¹ : Nonempty ι
μ : Measure α
f : ι → α → β
L : Filter ι
inst✝ : IsCountablyGenerated L
hf : ∀ (n : ι), AEMeasurable (f n)
h_ae_tendsto : ∀ᵐ (x : α) ∂μ, ∃ l, Tendsto (fun n => f n x) L (𝓝 l)
inhabited_h : Inhabited ι
hL : NeBot L
p : α → (ι → β) → Prop := fun x f' => ∃ l, Tendsto (fun n => f' n) L (𝓝 l)
hp_mem : ∀ x ∈ aeSeqSet hf p, p x fun n => f n x
h_ae_eq : ∀ᵐ (x : α) ∂μ, ∀ (n : ι), aeSeq hf p n x = f n x
f_lim : α → β :=
  fun x => if h : x ∈ aeSeqSet hf p then Exists.choose (_ : p x fun n => f n x) else Nonempty.some (_ : Nonempty β)
x : α
⊢ Tendsto
    (fun n =>
      if x ∈ aeSeqSet hf fun x f' => ∃ l, Tendsto (fun n => f' n) L (𝓝 l) then
        AEMeasurable.mk (f n) (_ : AEMeasurable (f n)) x
      else Nonempty.some (_ : Nonempty β))
    L
    (𝓝
      (if h : x ∈ aeSeqSet hf fun x f' => ∃ l, Tendsto (fun n => f' n) L (𝓝 l) then
        Exists.choose (_ : p x fun n => f n x)
      else Nonempty.some (_ : Nonempty β)))

Next tactic:
split_ifs with h
theorem measurable_limit_of_tendsto_metrizable_ae {ι} [Countable ι] [Nonempty ι] {μ : Measure α}
    {f : ι → α → β} {L : Filter ι} [L.IsCountablyGenerated] (hf : ∀ n, AEMeasurable (f n) μ)
    (h_ae_tendsto : ∀ᵐ x ∂μ, ∃ l : β, Tendsto (fun n => f n x) L (𝓝 l)) :
    ∃ f_lim : α → β, Measurable f_lim ∧ ∀ᵐ x ∂μ, Tendsto (fun n => f n x) L (𝓝 (f_lim x)) := by
  inhabit ι
  rcases eq_or_neBot L with (rfl | hL)
  · exact ⟨(hf default).mk _, (hf default).measurable_mk, eventually_of_forall fun x => tendsto_bot⟩
  let p : α → (ι → β) → Prop := fun x f' => ∃ l : β, Tendsto (fun n => f' n) L (𝓝 l)
  have hp_mem : ∀ x ∈ aeSeqSet hf p, p x fun n => f n x := fun x hx =>
    aeSeq.fun_prop_of_mem_aeSeqSet hf hx
  have h_ae_eq : ∀ᵐ x ∂μ, ∀ n, aeSeq hf p n x = f n x := aeSeq.aeSeq_eq_fun_ae hf h_ae_tendsto
  set f_lim : α → β := fun x => dite (x ∈ aeSeqSet hf p) (fun h => (hp_mem x h).choose)
    fun _ => (⟨f default x⟩ : Nonempty β).some
  have hf_lim : ∀ x, Tendsto (fun n => aeSeq hf p n x) L (𝓝 (f_lim x)) := by
    intro x
    simp only [aeSeq]
    split_ifs with h
    · 

Proof state:
case pos
α : Type u_1
β : Type u_2
inst✝⁷ : MeasurableSpace α
inst✝⁶ : TopologicalSpace β
inst✝⁵ : PseudoMetrizableSpace β
inst✝⁴ : MeasurableSpace β
inst✝³ : BorelSpace β
ι : Type u_3
inst✝² : Countable ι
inst✝¹ : Nonempty ι
μ : Measure α
f : ι → α → β
L : Filter ι
inst✝ : IsCountablyGenerated L
hf : ∀ (n : ι), AEMeasurable (f n)
h_ae_tendsto : ∀ᵐ (x : α) ∂μ, ∃ l, Tendsto (fun n => f n x) L (𝓝 l)
inhabited_h : Inhabited ι
hL : NeBot L
p : α → (ι → β) → Prop := fun x f' => ∃ l, Tendsto (fun n => f' n) L (𝓝 l)
hp_mem : ∀ x ∈ aeSeqSet hf p, p x fun n => f n x
h_ae_eq : ∀ᵐ (x : α) ∂μ, ∀ (n : ι), aeSeq hf p n x = f n x
f_lim : α → β :=
  fun x => if h : x ∈ aeSeqSet hf p then Exists.choose (_ : p x fun n => f n x) else Nonempty.some (_ : Nonempty β)
x : α
h : x ∈ aeSeqSet hf fun x f' => ∃ l, Tendsto (fun n => f' n) L (𝓝 l)
⊢ Tendsto (fun n => AEMeasurable.mk (f n) (_ : AEMeasurable (f n)) x) L (𝓝 (Exists.choose (_ : p x fun n => f n x)))

Next tactic:
refine' (hp_mem x h).choose_spec.congr fun n => _
theorem measurable_limit_of_tendsto_metrizable_ae {ι} [Countable ι] [Nonempty ι] {μ : Measure α}
    {f : ι → α → β} {L : Filter ι} [L.IsCountablyGenerated] (hf : ∀ n, AEMeasurable (f n) μ)
    (h_ae_tendsto : ∀ᵐ x ∂μ, ∃ l : β, Tendsto (fun n => f n x) L (𝓝 l)) :
    ∃ f_lim : α → β, Measurable f_lim ∧ ∀ᵐ x ∂μ, Tendsto (fun n => f n x) L (𝓝 (f_lim x)) := by
  inhabit ι
  rcases eq_or_neBot L with (rfl | hL)
  · exact ⟨(hf default).mk _, (hf default).measurable_mk, eventually_of_forall fun x => tendsto_bot⟩
  let p : α → (ι → β) → Prop := fun x f' => ∃ l : β, Tendsto (fun n => f' n) L (𝓝 l)
  have hp_mem : ∀ x ∈ aeSeqSet hf p, p x fun n => f n x := fun x hx =>
    aeSeq.fun_prop_of_mem_aeSeqSet hf hx
  have h_ae_eq : ∀ᵐ x ∂μ, ∀ n, aeSeq hf p n x = f n x := aeSeq.aeSeq_eq_fun_ae hf h_ae_tendsto
  set f_lim : α → β := fun x => dite (x ∈ aeSeqSet hf p) (fun h => (hp_mem x h).choose)
    fun _ => (⟨f default x⟩ : Nonempty β).some
  have hf_lim : ∀ x, Tendsto (fun n => aeSeq hf p n x) L (𝓝 (f_lim x)) := by
    intro x
    simp only [aeSeq]
    split_ifs with h
    · refine' (hp_mem x h).choose_spec.congr fun n => _
      

Proof state:
case pos
α : Type u_1
β : Type u_2
inst✝⁷ : MeasurableSpace α
inst✝⁶ : TopologicalSpace β
inst✝⁵ : PseudoMetrizableSpace β
inst✝⁴ : MeasurableSpace β
inst✝³ : BorelSpace β
ι : Type u_3
inst✝² : Countable ι
inst✝¹ : Nonempty ι
μ : Measure α
f : ι → α → β
L : Filter ι
inst✝ : IsCountablyGenerated L
hf : ∀ (n : ι), AEMeasurable (f n)
h_ae_tendsto : ∀ᵐ (x : α) ∂μ, ∃ l, Tendsto (fun n => f n x) L (𝓝 l)
inhabited_h : Inhabited ι
hL : NeBot L
p : α → (ι → β) → Prop := fun x f' => ∃ l, Tendsto (fun n => f' n) L (𝓝 l)
hp_mem : ∀ x ∈ aeSeqSet hf p, p x fun n => f n x
h_ae_eq : ∀ᵐ (x : α) ∂μ, ∀ (n : ι), aeSeq hf p n x = f n x
f_lim : α → β :=
  fun x => if h : x ∈ aeSeqSet hf p then Exists.choose (_ : p x fun n => f n x) else Nonempty.some (_ : Nonempty β)
x : α
h : x ∈ aeSeqSet hf fun x f' => ∃ l, Tendsto (fun n => f' n) L (𝓝 l)
n : ι
⊢ (fun n => f n x) n = AEMeasurable.mk (f n) (_ : AEMeasurable (f n)) x

Next tactic:
exact (aeSeq.mk_eq_fun_of_mem_aeSeqSet hf h n).symm
theorem measurable_limit_of_tendsto_metrizable_ae {ι} [Countable ι] [Nonempty ι] {μ : Measure α}
    {f : ι → α → β} {L : Filter ι} [L.IsCountablyGenerated] (hf : ∀ n, AEMeasurable (f n) μ)
    (h_ae_tendsto : ∀ᵐ x ∂μ, ∃ l : β, Tendsto (fun n => f n x) L (𝓝 l)) :
    ∃ f_lim : α → β, Measurable f_lim ∧ ∀ᵐ x ∂μ, Tendsto (fun n => f n x) L (𝓝 (f_lim x)) := by
  inhabit ι
  rcases eq_or_neBot L with (rfl | hL)
  · exact ⟨(hf default).mk _, (hf default).measurable_mk, eventually_of_forall fun x => tendsto_bot⟩
  let p : α → (ι → β) → Prop := fun x f' => ∃ l : β, Tendsto (fun n => f' n) L (𝓝 l)
  have hp_mem : ∀ x ∈ aeSeqSet hf p, p x fun n => f n x := fun x hx =>
    aeSeq.fun_prop_of_mem_aeSeqSet hf hx
  have h_ae_eq : ∀ᵐ x ∂μ, ∀ n, aeSeq hf p n x = f n x := aeSeq.aeSeq_eq_fun_ae hf h_ae_tendsto
  set f_lim : α → β := fun x => dite (x ∈ aeSeqSet hf p) (fun h => (hp_mem x h).choose)
    fun _ => (⟨f default x⟩ : Nonempty β).some
  have hf_lim : ∀ x, Tendsto (fun n => aeSeq hf p n x) L (𝓝 (f_lim x)) := by
    intro x
    simp only [aeSeq]
    split_ifs with h
    · refine' (hp_mem x h).choose_spec.congr fun n => _
      exact (aeSeq.mk_eq_fun_of_mem_aeSeqSet hf h n).symm
    · 

Proof state:
case neg
α : Type u_1
β : Type u_2
inst✝⁷ : MeasurableSpace α
inst✝⁶ : TopologicalSpace β
inst✝⁵ : PseudoMetrizableSpace β
inst✝⁴ : MeasurableSpace β
inst✝³ : BorelSpace β
ι : Type u_3
inst✝² : Countable ι
inst✝¹ : Nonempty ι
μ : Measure α
f : ι → α → β
L : Filter ι
inst✝ : IsCountablyGenerated L
hf : ∀ (n : ι), AEMeasurable (f n)
h_ae_tendsto : ∀ᵐ (x : α) ∂μ, ∃ l, Tendsto (fun n => f n x) L (𝓝 l)
inhabited_h : Inhabited ι
hL : NeBot L
p : α → (ι → β) → Prop := fun x f' => ∃ l, Tendsto (fun n => f' n) L (𝓝 l)
hp_mem : ∀ x ∈ aeSeqSet hf p, p x fun n => f n x
h_ae_eq : ∀ᵐ (x : α) ∂μ, ∀ (n : ι), aeSeq hf p n x = f n x
f_lim : α → β :=
  fun x => if h : x ∈ aeSeqSet hf p then Exists.choose (_ : p x fun n => f n x) else Nonempty.some (_ : Nonempty β)
x : α
h : x ∉ aeSeqSet hf fun x f' => ∃ l, Tendsto (fun n => f' n) L (𝓝 l)
⊢ Tendsto (fun n => Nonempty.some (_ : Nonempty β)) L (𝓝 (Nonempty.some (_ : Nonempty β)))

Next tactic:
exact tendsto_const_nhds
theorem measurable_limit_of_tendsto_metrizable_ae {ι} [Countable ι] [Nonempty ι] {μ : Measure α}
    {f : ι → α → β} {L : Filter ι} [L.IsCountablyGenerated] (hf : ∀ n, AEMeasurable (f n) μ)
    (h_ae_tendsto : ∀ᵐ x ∂μ, ∃ l : β, Tendsto (fun n => f n x) L (𝓝 l)) :
    ∃ f_lim : α → β, Measurable f_lim ∧ ∀ᵐ x ∂μ, Tendsto (fun n => f n x) L (𝓝 (f_lim x)) := by
  inhabit ι
  rcases eq_or_neBot L with (rfl | hL)
  · exact ⟨(hf default).mk _, (hf default).measurable_mk, eventually_of_forall fun x => tendsto_bot⟩
  let p : α → (ι → β) → Prop := fun x f' => ∃ l : β, Tendsto (fun n => f' n) L (𝓝 l)
  have hp_mem : ∀ x ∈ aeSeqSet hf p, p x fun n => f n x := fun x hx =>
    aeSeq.fun_prop_of_mem_aeSeqSet hf hx
  have h_ae_eq : ∀ᵐ x ∂μ, ∀ n, aeSeq hf p n x = f n x := aeSeq.aeSeq_eq_fun_ae hf h_ae_tendsto
  set f_lim : α → β := fun x => dite (x ∈ aeSeqSet hf p) (fun h => (hp_mem x h).choose)
    fun _ => (⟨f default x⟩ : Nonempty β).some
  have hf_lim : ∀ x, Tendsto (fun n => aeSeq hf p n x) L (𝓝 (f_lim x)) := by
    intro x
    simp only [aeSeq]
    split_ifs with h
    · refine' (hp_mem x h).choose_spec.congr fun n => _
      exact (aeSeq.mk_eq_fun_of_mem_aeSeqSet hf h n).symm
    · exact tendsto_const_nhds
  

Proof state:
case inr
α : Type u_1
β : Type u_2
inst✝⁷ : MeasurableSpace α
inst✝⁶ : TopologicalSpace β
inst✝⁵ : PseudoMetrizableSpace β
inst✝⁴ : MeasurableSpace β
inst✝³ : BorelSpace β
ι : Type u_3
inst✝² : Countable ι
inst✝¹ : Nonempty ι
μ : Measure α
f : ι → α → β
L : Filter ι
inst✝ : IsCountablyGenerated L
hf : ∀ (n : ι), AEMeasurable (f n)
h_ae_tendsto : ∀ᵐ (x : α) ∂μ, ∃ l, Tendsto (fun n => f n x) L (𝓝 l)
inhabited_h : Inhabited ι
hL : NeBot L
p : α → (ι → β) → Prop := fun x f' => ∃ l, Tendsto (fun n => f' n) L (𝓝 l)
hp_mem : ∀ x ∈ aeSeqSet hf p, p x fun n => f n x
h_ae_eq : ∀ᵐ (x : α) ∂μ, ∀ (n : ι), aeSeq hf p n x = f n x
f_lim : α → β :=
  fun x => if h : x ∈ aeSeqSet hf p then Exists.choose (_ : p x fun n => f n x) else Nonempty.some (_ : Nonempty β)
hf_lim : ∀ (x : α), Tendsto (fun n => aeSeq hf p n x) L (𝓝 (f_lim x))
⊢ ∃ f_lim, Measurable f_lim ∧ ∀ᵐ (x : α) ∂μ, Tendsto (fun n => f n x) L (𝓝 (f_lim x))

Next tactic:
have h_ae_tendsto_f_lim : ∀ᵐ x ∂μ, Tendsto (fun n => f n x) L (𝓝 (f_lim x)) :=
    h_ae_eq.mono fun x hx => (hf_lim x).congr hx
theorem measurable_limit_of_tendsto_metrizable_ae {ι} [Countable ι] [Nonempty ι] {μ : Measure α}
    {f : ι → α → β} {L : Filter ι} [L.IsCountablyGenerated] (hf : ∀ n, AEMeasurable (f n) μ)
    (h_ae_tendsto : ∀ᵐ x ∂μ, ∃ l : β, Tendsto (fun n => f n x) L (𝓝 l)) :
    ∃ f_lim : α → β, Measurable f_lim ∧ ∀ᵐ x ∂μ, Tendsto (fun n => f n x) L (𝓝 (f_lim x)) := by
  inhabit ι
  rcases eq_or_neBot L with (rfl | hL)
  · exact ⟨(hf default).mk _, (hf default).measurable_mk, eventually_of_forall fun x => tendsto_bot⟩
  let p : α → (ι → β) → Prop := fun x f' => ∃ l : β, Tendsto (fun n => f' n) L (𝓝 l)
  have hp_mem : ∀ x ∈ aeSeqSet hf p, p x fun n => f n x := fun x hx =>
    aeSeq.fun_prop_of_mem_aeSeqSet hf hx
  have h_ae_eq : ∀ᵐ x ∂μ, ∀ n, aeSeq hf p n x = f n x := aeSeq.aeSeq_eq_fun_ae hf h_ae_tendsto
  set f_lim : α → β := fun x => dite (x ∈ aeSeqSet hf p) (fun h => (hp_mem x h).choose)
    fun _ => (⟨f default x⟩ : Nonempty β).some
  have hf_lim : ∀ x, Tendsto (fun n => aeSeq hf p n x) L (𝓝 (f_lim x)) := by
    intro x
    simp only [aeSeq]
    split_ifs with h
    · refine' (hp_mem x h).choose_spec.congr fun n => _
      exact (aeSeq.mk_eq_fun_of_mem_aeSeqSet hf h n).symm
    · exact tendsto_const_nhds
  have h_ae_tendsto_f_lim : ∀ᵐ x ∂μ, Tendsto (fun n => f n x) L (𝓝 (f_lim x)) :=
    h_ae_eq.mono fun x hx => (hf_lim x).congr hx
  

Proof state:
case inr
α : Type u_1
β : Type u_2
inst✝⁷ : MeasurableSpace α
inst✝⁶ : TopologicalSpace β
inst✝⁵ : PseudoMetrizableSpace β
inst✝⁴ : MeasurableSpace β
inst✝³ : BorelSpace β
ι : Type u_3
inst✝² : Countable ι
inst✝¹ : Nonempty ι
μ : Measure α
f : ι → α → β
L : Filter ι
inst✝ : IsCountablyGenerated L
hf : ∀ (n : ι), AEMeasurable (f n)
h_ae_tendsto : ∀ᵐ (x : α) ∂μ, ∃ l, Tendsto (fun n => f n x) L (𝓝 l)
inhabited_h : Inhabited ι
hL : NeBot L
p : α → (ι → β) → Prop := fun x f' => ∃ l, Tendsto (fun n => f' n) L (𝓝 l)
hp_mem : ∀ x ∈ aeSeqSet hf p, p x fun n => f n x
h_ae_eq : ∀ᵐ (x : α) ∂μ, ∀ (n : ι), aeSeq hf p n x = f n x
f_lim : α → β :=
  fun x => if h : x ∈ aeSeqSet hf p then Exists.choose (_ : p x fun n => f n x) else Nonempty.some (_ : Nonempty β)
hf_lim : ∀ (x : α), Tendsto (fun n => aeSeq hf p n x) L (𝓝 (f_lim x))
h_ae_tendsto_f_lim : ∀ᵐ (x : α) ∂μ, Tendsto (fun n => f n x) L (𝓝 (f_lim x))
⊢ ∃ f_lim, Measurable f_lim ∧ ∀ᵐ (x : α) ∂μ, Tendsto (fun n => f n x) L (𝓝 (f_lim x))

Next tactic:
have h_f_lim_meas : Measurable f_lim :=
    measurable_of_tendsto_metrizable' L (aeSeq.measurable hf p)
      (tendsto_pi_nhds.mpr fun x => hf_lim x)
theorem measurable_limit_of_tendsto_metrizable_ae {ι} [Countable ι] [Nonempty ι] {μ : Measure α}
    {f : ι → α → β} {L : Filter ι} [L.IsCountablyGenerated] (hf : ∀ n, AEMeasurable (f n) μ)
    (h_ae_tendsto : ∀ᵐ x ∂μ, ∃ l : β, Tendsto (fun n => f n x) L (𝓝 l)) :
    ∃ f_lim : α → β, Measurable f_lim ∧ ∀ᵐ x ∂μ, Tendsto (fun n => f n x) L (𝓝 (f_lim x)) := by
  inhabit ι
  rcases eq_or_neBot L with (rfl | hL)
  · exact ⟨(hf default).mk _, (hf default).measurable_mk, eventually_of_forall fun x => tendsto_bot⟩
  let p : α → (ι → β) → Prop := fun x f' => ∃ l : β, Tendsto (fun n => f' n) L (𝓝 l)
  have hp_mem : ∀ x ∈ aeSeqSet hf p, p x fun n => f n x := fun x hx =>
    aeSeq.fun_prop_of_mem_aeSeqSet hf hx
  have h_ae_eq : ∀ᵐ x ∂μ, ∀ n, aeSeq hf p n x = f n x := aeSeq.aeSeq_eq_fun_ae hf h_ae_tendsto
  set f_lim : α → β := fun x => dite (x ∈ aeSeqSet hf p) (fun h => (hp_mem x h).choose)
    fun _ => (⟨f default x⟩ : Nonempty β).some
  have hf_lim : ∀ x, Tendsto (fun n => aeSeq hf p n x) L (𝓝 (f_lim x)) := by
    intro x
    simp only [aeSeq]
    split_ifs with h
    · refine' (hp_mem x h).choose_spec.congr fun n => _
      exact (aeSeq.mk_eq_fun_of_mem_aeSeqSet hf h n).symm
    · exact tendsto_const_nhds
  have h_ae_tendsto_f_lim : ∀ᵐ x ∂μ, Tendsto (fun n => f n x) L (𝓝 (f_lim x)) :=
    h_ae_eq.mono fun x hx => (hf_lim x).congr hx
  have h_f_lim_meas : Measurable f_lim :=
    measurable_of_tendsto_metrizable' L (aeSeq.measurable hf p)
      (tendsto_pi_nhds.mpr fun x => hf_lim x)
  

Proof state:
case inr
α : Type u_1
β : Type u_2
inst✝⁷ : MeasurableSpace α
inst✝⁶ : TopologicalSpace β
inst✝⁵ : PseudoMetrizableSpace β
inst✝⁴ : MeasurableSpace β
inst✝³ : BorelSpace β
ι : Type u_3
inst✝² : Countable ι
inst✝¹ : Nonempty ι
μ : Measure α
f : ι → α → β
L : Filter ι
inst✝ : IsCountablyGenerated L
hf : ∀ (n : ι), AEMeasurable (f n)
h_ae_tendsto : ∀ᵐ (x : α) ∂μ, ∃ l, Tendsto (fun n => f n x) L (𝓝 l)
inhabited_h : Inhabited ι
hL : NeBot L
p : α → (ι → β) → Prop := fun x f' => ∃ l, Tendsto (fun n => f' n) L (𝓝 l)
hp_mem : ∀ x ∈ aeSeqSet hf p, p x fun n => f n x
h_ae_eq : ∀ᵐ (x : α) ∂μ, ∀ (n : ι), aeSeq hf p n x = f n x
f_lim : α → β :=
  fun x => if h : x ∈ aeSeqSet hf p then Exists.choose (_ : p x fun n => f n x) else Nonempty.some (_ : Nonempty β)
hf_lim : ∀ (x : α), Tendsto (fun n => aeSeq hf p n x) L (𝓝 (f_lim x))
h_ae_tendsto_f_lim : ∀ᵐ (x : α) ∂μ, Tendsto (fun n => f n x) L (𝓝 (f_lim x))
h_f_lim_meas : Measurable f_lim
⊢ ∃ f_lim, Measurable f_lim ∧ ∀ᵐ (x : α) ∂μ, Tendsto (fun n => f n x) L (𝓝 (f_lim x))

Next tactic:
exact ⟨f_lim, h_f_lim_meas, h_ae_tendsto_f_lim⟩
/-- If the indicator functions of measurable sets `Aᵢ` converge to the indicator function of
a set `A` along a nontrivial countably generated filter, then `A` is also measurable. -/
lemma measurableSet_of_tendsto_indicator [NeBot L] (As_mble : ∀ i, MeasurableSet (As i))
    (h_lim : ∀ x, ∀ᶠ i in L, x ∈ As i ↔ x ∈ A) :
    MeasurableSet A := by
  

Proof state:
α✝ : Type u_1
β : Type u_2
inst✝³ : MeasurableSpace α✝
α : Type u_3
inst✝² : MeasurableSpace α
A : Set α
ι : Type u_4
L : Filter ι
inst✝¹ : IsCountablyGenerated L
As : ι → Set α
inst✝ : NeBot L
As_mble : ∀ (i : ι), MeasurableSet (As i)
h_lim : ∀ (x : α), ∀ᶠ (i : ι) in L, x ∈ As i ↔ x ∈ A
⊢ MeasurableSet A

Next tactic:
simp_rw [← measurable_indicator_const_iff (1 : ℝ≥0∞)] at As_mble ⊢