l3lab/ntp-mathlib huggingface dataset:
theorem tendsto_preCdf_atTop_one (ρ : Measure (α × ℝ)) [IsFiniteMeasure ρ] :
    ∀ᵐ a ∂ρ.fst, Tendsto (fun r => preCdf ρ r a) atTop (𝓝 1) := by
  -- We show first that `preCdf` has a limit almost everywhere. That limit has to be at most 1.
  -- We then show that the integral of `preCdf` tends to the integral of 1, and that it also tends
  -- to the integral of the limit. Since the limit is at most 1 and has same integral as 1, it is
  -- equal to 1 a.e.
  have h_mono := monotone_preCdf ρ
  have h_le_one := preCdf_le_one ρ
  -- `preCdf` has a limit a.e.
  have h_exists : ∀ᵐ a ∂ρ.fst, ∃ l, Tendsto (fun r => preCdf ρ r a) atTop (𝓝 l) := by
    filter_upwards [h_mono, h_le_one] with a ha_mono ha_le_one
    have h_tendsto :
      Tendsto (fun r => preCdf ρ r a) atTop atTop ∨
        ∃ l, Tendsto (fun r => preCdf ρ r a) atTop (𝓝 l) :=
      tendsto_of_monotone ha_mono
    cases' h_tendsto with h_absurd h_tendsto
    · rw [Monotone.tendsto_atTop_atTop_iff ha_mono] at h_absurd
      

Proof state:
case h.inl
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
ρ : Measure (α × ℝ)
inst✝ : IsFiniteMeasure ρ
h_mono : ∀ᵐ (a : α) ∂Measure.fst ρ, Monotone fun r => preCdf ρ r a
h_le_one : ∀ᵐ (a : α) ∂Measure.fst ρ, ∀ (r : ℚ), preCdf ρ r a ≤ 1
a : α
ha_mono : Monotone fun r => preCdf ρ r a
ha_le_one : ∀ (r : ℚ), preCdf ρ r a ≤ 1
h_absurd : ∀ (b : ℝ≥0∞), ∃ a_1, b ≤ preCdf ρ a_1 a
⊢ ∃ l, Tendsto (fun r => preCdf ρ r a) atTop (𝓝 l)

Next tactic:
obtain ⟨r, hr⟩ := h_absurd 2
theorem tendsto_preCdf_atTop_one (ρ : Measure (α × ℝ)) [IsFiniteMeasure ρ] :
    ∀ᵐ a ∂ρ.fst, Tendsto (fun r => preCdf ρ r a) atTop (𝓝 1) := by
  -- We show first that `preCdf` has a limit almost everywhere. That limit has to be at most 1.
  -- We then show that the integral of `preCdf` tends to the integral of 1, and that it also tends
  -- to the integral of the limit. Since the limit is at most 1 and has same integral as 1, it is
  -- equal to 1 a.e.
  have h_mono := monotone_preCdf ρ
  have h_le_one := preCdf_le_one ρ
  -- `preCdf` has a limit a.e.
  have h_exists : ∀ᵐ a ∂ρ.fst, ∃ l, Tendsto (fun r => preCdf ρ r a) atTop (𝓝 l) := by
    filter_upwards [h_mono, h_le_one] with a ha_mono ha_le_one
    have h_tendsto :
      Tendsto (fun r => preCdf ρ r a) atTop atTop ∨
        ∃ l, Tendsto (fun r => preCdf ρ r a) atTop (𝓝 l) :=
      tendsto_of_monotone ha_mono
    cases' h_tendsto with h_absurd h_tendsto
    · rw [Monotone.tendsto_atTop_atTop_iff ha_mono] at h_absurd
      obtain ⟨r, hr⟩ := h_absurd 2
      

Proof state:
case h.inl.intro
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
ρ : Measure (α × ℝ)
inst✝ : IsFiniteMeasure ρ
h_mono : ∀ᵐ (a : α) ∂Measure.fst ρ, Monotone fun r => preCdf ρ r a
h_le_one : ∀ᵐ (a : α) ∂Measure.fst ρ, ∀ (r : ℚ), preCdf ρ r a ≤ 1
a : α
ha_mono : Monotone fun r => preCdf ρ r a
ha_le_one : ∀ (r : ℚ), preCdf ρ r a ≤ 1
h_absurd : ∀ (b : ℝ≥0∞), ∃ a_1, b ≤ preCdf ρ a_1 a
r : ℚ
hr : 2 ≤ preCdf ρ r a
⊢ ∃ l, Tendsto (fun r => preCdf ρ r a) atTop (𝓝 l)

Next tactic:
exact absurd (hr.trans (ha_le_one r)) ENNReal.one_lt_two.not_le
theorem tendsto_preCdf_atTop_one (ρ : Measure (α × ℝ)) [IsFiniteMeasure ρ] :
    ∀ᵐ a ∂ρ.fst, Tendsto (fun r => preCdf ρ r a) atTop (𝓝 1) := by
  -- We show first that `preCdf` has a limit almost everywhere. That limit has to be at most 1.
  -- We then show that the integral of `preCdf` tends to the integral of 1, and that it also tends
  -- to the integral of the limit. Since the limit is at most 1 and has same integral as 1, it is
  -- equal to 1 a.e.
  have h_mono := monotone_preCdf ρ
  have h_le_one := preCdf_le_one ρ
  -- `preCdf` has a limit a.e.
  have h_exists : ∀ᵐ a ∂ρ.fst, ∃ l, Tendsto (fun r => preCdf ρ r a) atTop (𝓝 l) := by
    filter_upwards [h_mono, h_le_one] with a ha_mono ha_le_one
    have h_tendsto :
      Tendsto (fun r => preCdf ρ r a) atTop atTop ∨
        ∃ l, Tendsto (fun r => preCdf ρ r a) atTop (𝓝 l) :=
      tendsto_of_monotone ha_mono
    cases' h_tendsto with h_absurd h_tendsto
    · rw [Monotone.tendsto_atTop_atTop_iff ha_mono] at h_absurd
      obtain ⟨r, hr⟩ := h_absurd 2
      exact absurd (hr.trans (ha_le_one r)) ENNReal.one_lt_two.not_le
    · 

Proof state:
case h.inr
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
ρ : Measure (α × ℝ)
inst✝ : IsFiniteMeasure ρ
h_mono : ∀ᵐ (a : α) ∂Measure.fst ρ, Monotone fun r => preCdf ρ r a
h_le_one : ∀ᵐ (a : α) ∂Measure.fst ρ, ∀ (r : ℚ), preCdf ρ r a ≤ 1
a : α
ha_mono : Monotone fun r => preCdf ρ r a
ha_le_one : ∀ (r : ℚ), preCdf ρ r a ≤ 1
h_tendsto : ∃ l, Tendsto (fun r => preCdf ρ r a) atTop (𝓝 l)
⊢ ∃ l, Tendsto (fun r => preCdf ρ r a) atTop (𝓝 l)

Next tactic:
exact h_tendsto
theorem tendsto_preCdf_atTop_one (ρ : Measure (α × ℝ)) [IsFiniteMeasure ρ] :
    ∀ᵐ a ∂ρ.fst, Tendsto (fun r => preCdf ρ r a) atTop (𝓝 1) := by
  -- We show first that `preCdf` has a limit almost everywhere. That limit has to be at most 1.
  -- We then show that the integral of `preCdf` tends to the integral of 1, and that it also tends
  -- to the integral of the limit. Since the limit is at most 1 and has same integral as 1, it is
  -- equal to 1 a.e.
  have h_mono := monotone_preCdf ρ
  have h_le_one := preCdf_le_one ρ
  -- `preCdf` has a limit a.e.
  have h_exists : ∀ᵐ a ∂ρ.fst, ∃ l, Tendsto (fun r => preCdf ρ r a) atTop (𝓝 l) := by
    filter_upwards [h_mono, h_le_one] with a ha_mono ha_le_one
    have h_tendsto :
      Tendsto (fun r => preCdf ρ r a) atTop atTop ∨
        ∃ l, Tendsto (fun r => preCdf ρ r a) atTop (𝓝 l) :=
      tendsto_of_monotone ha_mono
    cases' h_tendsto with h_absurd h_tendsto
    · rw [Monotone.tendsto_atTop_atTop_iff ha_mono] at h_absurd
      obtain ⟨r, hr⟩ := h_absurd 2
      exact absurd (hr.trans (ha_le_one r)) ENNReal.one_lt_two.not_le
    · exact h_tendsto
  classical
  -- let `F` be the pointwise limit of `preCdf` where it exists, and 0 elsewhere.
  

Proof state:
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
ρ : Measure (α × ℝ)
inst✝ : IsFiniteMeasure ρ
h_mono : ∀ᵐ (a : α) ∂Measure.fst ρ, Monotone fun r => preCdf ρ r a
h_le_one : ∀ᵐ (a : α) ∂Measure.fst ρ, ∀ (r : ℚ), preCdf ρ r a ≤ 1
h_exists : ∀ᵐ (a : α) ∂Measure.fst ρ, ∃ l, Tendsto (fun r => preCdf ρ r a) atTop (𝓝 l)
⊢ ∀ᵐ (a : α) ∂Measure.fst ρ, Tendsto (fun r => preCdf ρ r a) atTop (𝓝 1)

Next tactic:
let F : α → ℝ≥0∞ := fun a =>
    if h : ∃ l, Tendsto (fun r => preCdf ρ r a) atTop (𝓝 l) then h.choose else 0
theorem tendsto_preCdf_atTop_one (ρ : Measure (α × ℝ)) [IsFiniteMeasure ρ] :
    ∀ᵐ a ∂ρ.fst, Tendsto (fun r => preCdf ρ r a) atTop (𝓝 1) := by
  -- We show first that `preCdf` has a limit almost everywhere. That limit has to be at most 1.
  -- We then show that the integral of `preCdf` tends to the integral of 1, and that it also tends
  -- to the integral of the limit. Since the limit is at most 1 and has same integral as 1, it is
  -- equal to 1 a.e.
  have h_mono := monotone_preCdf ρ
  have h_le_one := preCdf_le_one ρ
  -- `preCdf` has a limit a.e.
  have h_exists : ∀ᵐ a ∂ρ.fst, ∃ l, Tendsto (fun r => preCdf ρ r a) atTop (𝓝 l) := by
    filter_upwards [h_mono, h_le_one] with a ha_mono ha_le_one
    have h_tendsto :
      Tendsto (fun r => preCdf ρ r a) atTop atTop ∨
        ∃ l, Tendsto (fun r => preCdf ρ r a) atTop (𝓝 l) :=
      tendsto_of_monotone ha_mono
    cases' h_tendsto with h_absurd h_tendsto
    · rw [Monotone.tendsto_atTop_atTop_iff ha_mono] at h_absurd
      obtain ⟨r, hr⟩ := h_absurd 2
      exact absurd (hr.trans (ha_le_one r)) ENNReal.one_lt_two.not_le
    · exact h_tendsto
  classical
  -- let `F` be the pointwise limit of `preCdf` where it exists, and 0 elsewhere.
  let F : α → ℝ≥0∞ := fun a =>
    if h : ∃ l, Tendsto (fun r => preCdf ρ r a) atTop (𝓝 l) then h.choose else 0
  

Proof state:
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
ρ : Measure (α × ℝ)
inst✝ : IsFiniteMeasure ρ
h_mono : ∀ᵐ (a : α) ∂Measure.fst ρ, Monotone fun r => preCdf ρ r a
h_le_one : ∀ᵐ (a : α) ∂Measure.fst ρ, ∀ (r : ℚ), preCdf ρ r a ≤ 1
h_exists : ∀ᵐ (a : α) ∂Measure.fst ρ, ∃ l, Tendsto (fun r => preCdf ρ r a) atTop (𝓝 l)
F : α → ℝ≥0∞ := fun a => if h : ∃ l, Tendsto (fun r => preCdf ρ r a) atTop (𝓝 l) then Exists.choose h else 0
⊢ ∀ᵐ (a : α) ∂Measure.fst ρ, Tendsto (fun r => preCdf ρ r a) atTop (𝓝 1)

Next tactic:
have h_tendsto_ℚ : ∀ᵐ a ∂ρ.fst, Tendsto (fun r => preCdf ρ r a) atTop (𝓝 (F a)) := by
    filter_upwards [h_exists] with a ha
    simp_rw [dif_pos ha]
    exact ha.choose_spec
theorem tendsto_preCdf_atTop_one (ρ : Measure (α × ℝ)) [IsFiniteMeasure ρ] :
    ∀ᵐ a ∂ρ.fst, Tendsto (fun r => preCdf ρ r a) atTop (𝓝 1) := by
  -- We show first that `preCdf` has a limit almost everywhere. That limit has to be at most 1.
  -- We then show that the integral of `preCdf` tends to the integral of 1, and that it also tends
  -- to the integral of the limit. Since the limit is at most 1 and has same integral as 1, it is
  -- equal to 1 a.e.
  have h_mono := monotone_preCdf ρ
  have h_le_one := preCdf_le_one ρ
  -- `preCdf` has a limit a.e.
  have h_exists : ∀ᵐ a ∂ρ.fst, ∃ l, Tendsto (fun r => preCdf ρ r a) atTop (𝓝 l) := by
    filter_upwards [h_mono, h_le_one] with a ha_mono ha_le_one
    have h_tendsto :
      Tendsto (fun r => preCdf ρ r a) atTop atTop ∨
        ∃ l, Tendsto (fun r => preCdf ρ r a) atTop (𝓝 l) :=
      tendsto_of_monotone ha_mono
    cases' h_tendsto with h_absurd h_tendsto
    · rw [Monotone.tendsto_atTop_atTop_iff ha_mono] at h_absurd
      obtain ⟨r, hr⟩ := h_absurd 2
      exact absurd (hr.trans (ha_le_one r)) ENNReal.one_lt_two.not_le
    · exact h_tendsto
  classical
  -- let `F` be the pointwise limit of `preCdf` where it exists, and 0 elsewhere.
  let F : α → ℝ≥0∞ := fun a =>
    if h : ∃ l, Tendsto (fun r => preCdf ρ r a) atTop (𝓝 l) then h.choose else 0
  have h_tendsto_ℚ : ∀ᵐ a ∂ρ.fst, Tendsto (fun r => preCdf ρ r a) atTop (𝓝 (F a)) := by
    

Proof state:
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
ρ : Measure (α × ℝ)
inst✝ : IsFiniteMeasure ρ
h_mono : ∀ᵐ (a : α) ∂Measure.fst ρ, Monotone fun r => preCdf ρ r a
h_le_one : ∀ᵐ (a : α) ∂Measure.fst ρ, ∀ (r : ℚ), preCdf ρ r a ≤ 1
h_exists : ∀ᵐ (a : α) ∂Measure.fst ρ, ∃ l, Tendsto (fun r => preCdf ρ r a) atTop (𝓝 l)
F : α → ℝ≥0∞ := fun a => if h : ∃ l, Tendsto (fun r => preCdf ρ r a) atTop (𝓝 l) then Exists.choose h else 0
⊢ ∀ᵐ (a : α) ∂Measure.fst ρ, Tendsto (fun r => preCdf ρ r a) atTop (𝓝 (F a))

Next tactic:
filter_upwards [h_exists] with a ha
theorem tendsto_preCdf_atTop_one (ρ : Measure (α × ℝ)) [IsFiniteMeasure ρ] :
    ∀ᵐ a ∂ρ.fst, Tendsto (fun r => preCdf ρ r a) atTop (𝓝 1) := by
  -- We show first that `preCdf` has a limit almost everywhere. That limit has to be at most 1.
  -- We then show that the integral of `preCdf` tends to the integral of 1, and that it also tends
  -- to the integral of the limit. Since the limit is at most 1 and has same integral as 1, it is
  -- equal to 1 a.e.
  have h_mono := monotone_preCdf ρ
  have h_le_one := preCdf_le_one ρ
  -- `preCdf` has a limit a.e.
  have h_exists : ∀ᵐ a ∂ρ.fst, ∃ l, Tendsto (fun r => preCdf ρ r a) atTop (𝓝 l) := by
    filter_upwards [h_mono, h_le_one] with a ha_mono ha_le_one
    have h_tendsto :
      Tendsto (fun r => preCdf ρ r a) atTop atTop ∨
        ∃ l, Tendsto (fun r => preCdf ρ r a) atTop (𝓝 l) :=
      tendsto_of_monotone ha_mono
    cases' h_tendsto with h_absurd h_tendsto
    · rw [Monotone.tendsto_atTop_atTop_iff ha_mono] at h_absurd
      obtain ⟨r, hr⟩ := h_absurd 2
      exact absurd (hr.trans (ha_le_one r)) ENNReal.one_lt_two.not_le
    · exact h_tendsto
  classical
  -- let `F` be the pointwise limit of `preCdf` where it exists, and 0 elsewhere.
  let F : α → ℝ≥0∞ := fun a =>
    if h : ∃ l, Tendsto (fun r => preCdf ρ r a) atTop (𝓝 l) then h.choose else 0
  have h_tendsto_ℚ : ∀ᵐ a ∂ρ.fst, Tendsto (fun r => preCdf ρ r a) atTop (𝓝 (F a)) := by
    filter_upwards [h_exists] with a ha
    

Proof state:
case h
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
ρ : Measure (α × ℝ)
inst✝ : IsFiniteMeasure ρ
h_mono : ∀ᵐ (a : α) ∂Measure.fst ρ, Monotone fun r => preCdf ρ r a
h_le_one : ∀ᵐ (a : α) ∂Measure.fst ρ, ∀ (r : ℚ), preCdf ρ r a ≤ 1
h_exists : ∀ᵐ (a : α) ∂Measure.fst ρ, ∃ l, Tendsto (fun r => preCdf ρ r a) atTop (𝓝 l)
F : α → ℝ≥0∞ := fun a => if h : ∃ l, Tendsto (fun r => preCdf ρ r a) atTop (𝓝 l) then Exists.choose h else 0
a : α
ha : ∃ l, Tendsto (fun r => preCdf ρ r a) atTop (𝓝 l)
⊢ Tendsto (fun r => preCdf ρ r a) atTop (𝓝 (F a))

Next tactic:
simp_rw [dif_pos ha]
theorem tendsto_preCdf_atTop_one (ρ : Measure (α × ℝ)) [IsFiniteMeasure ρ] :
    ∀ᵐ a ∂ρ.fst, Tendsto (fun r => preCdf ρ r a) atTop (𝓝 1) := by
  -- We show first that `preCdf` has a limit almost everywhere. That limit has to be at most 1.
  -- We then show that the integral of `preCdf` tends to the integral of 1, and that it also tends
  -- to the integral of the limit. Since the limit is at most 1 and has same integral as 1, it is
  -- equal to 1 a.e.
  have h_mono := monotone_preCdf ρ
  have h_le_one := preCdf_le_one ρ
  -- `preCdf` has a limit a.e.
  have h_exists : ∀ᵐ a ∂ρ.fst, ∃ l, Tendsto (fun r => preCdf ρ r a) atTop (𝓝 l) := by
    filter_upwards [h_mono, h_le_one] with a ha_mono ha_le_one
    have h_tendsto :
      Tendsto (fun r => preCdf ρ r a) atTop atTop ∨
        ∃ l, Tendsto (fun r => preCdf ρ r a) atTop (𝓝 l) :=
      tendsto_of_monotone ha_mono
    cases' h_tendsto with h_absurd h_tendsto
    · rw [Monotone.tendsto_atTop_atTop_iff ha_mono] at h_absurd
      obtain ⟨r, hr⟩ := h_absurd 2
      exact absurd (hr.trans (ha_le_one r)) ENNReal.one_lt_two.not_le
    · exact h_tendsto
  classical
  -- let `F` be the pointwise limit of `preCdf` where it exists, and 0 elsewhere.
  let F : α → ℝ≥0∞ := fun a =>
    if h : ∃ l, Tendsto (fun r => preCdf ρ r a) atTop (𝓝 l) then h.choose else 0
  have h_tendsto_ℚ : ∀ᵐ a ∂ρ.fst, Tendsto (fun r => preCdf ρ r a) atTop (𝓝 (F a)) := by
    filter_upwards [h_exists] with a ha
    simp_rw [dif_pos ha]
    

Proof state:
case h
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
ρ : Measure (α × ℝ)
inst✝ : IsFiniteMeasure ρ
h_mono : ∀ᵐ (a : α) ∂Measure.fst ρ, Monotone fun r => preCdf ρ r a
h_le_one : ∀ᵐ (a : α) ∂Measure.fst ρ, ∀ (r : ℚ), preCdf ρ r a ≤ 1
h_exists : ∀ᵐ (a : α) ∂Measure.fst ρ, ∃ l, Tendsto (fun r => preCdf ρ r a) atTop (𝓝 l)
F : α → ℝ≥0∞ := fun a => if h : ∃ l, Tendsto (fun r => preCdf ρ r a) atTop (𝓝 l) then Exists.choose h else 0
a : α
ha : ∃ l, Tendsto (fun r => preCdf ρ r a) atTop (𝓝 l)
⊢ Tendsto (fun r => preCdf ρ r a) atTop (𝓝 (Exists.choose ha))

Next tactic:
exact ha.choose_spec
theorem tendsto_preCdf_atTop_one (ρ : Measure (α × ℝ)) [IsFiniteMeasure ρ] :
    ∀ᵐ a ∂ρ.fst, Tendsto (fun r => preCdf ρ r a) atTop (𝓝 1) := by
  -- We show first that `preCdf` has a limit almost everywhere. That limit has to be at most 1.
  -- We then show that the integral of `preCdf` tends to the integral of 1, and that it also tends
  -- to the integral of the limit. Since the limit is at most 1 and has same integral as 1, it is
  -- equal to 1 a.e.
  have h_mono := monotone_preCdf ρ
  have h_le_one := preCdf_le_one ρ
  -- `preCdf` has a limit a.e.
  have h_exists : ∀ᵐ a ∂ρ.fst, ∃ l, Tendsto (fun r => preCdf ρ r a) atTop (𝓝 l) := by
    filter_upwards [h_mono, h_le_one] with a ha_mono ha_le_one
    have h_tendsto :
      Tendsto (fun r => preCdf ρ r a) atTop atTop ∨
        ∃ l, Tendsto (fun r => preCdf ρ r a) atTop (𝓝 l) :=
      tendsto_of_monotone ha_mono
    cases' h_tendsto with h_absurd h_tendsto
    · rw [Monotone.tendsto_atTop_atTop_iff ha_mono] at h_absurd
      obtain ⟨r, hr⟩ := h_absurd 2
      exact absurd (hr.trans (ha_le_one r)) ENNReal.one_lt_two.not_le
    · exact h_tendsto
  classical
  -- let `F` be the pointwise limit of `preCdf` where it exists, and 0 elsewhere.
  let F : α → ℝ≥0∞ := fun a =>
    if h : ∃ l, Tendsto (fun r => preCdf ρ r a) atTop (𝓝 l) then h.choose else 0
  have h_tendsto_ℚ : ∀ᵐ a ∂ρ.fst, Tendsto (fun r => preCdf ρ r a) atTop (𝓝 (F a)) := by
    filter_upwards [h_exists] with a ha
    simp_rw [dif_pos ha]
    exact ha.choose_spec
  

Proof state:
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
ρ : Measure (α × ℝ)
inst✝ : IsFiniteMeasure ρ
h_mono : ∀ᵐ (a : α) ∂Measure.fst ρ, Monotone fun r => preCdf ρ r a
h_le_one : ∀ᵐ (a : α) ∂Measure.fst ρ, ∀ (r : ℚ), preCdf ρ r a ≤ 1
h_exists : ∀ᵐ (a : α) ∂Measure.fst ρ, ∃ l, Tendsto (fun r => preCdf ρ r a) atTop (𝓝 l)
F : α → ℝ≥0∞ := fun a => if h : ∃ l, Tendsto (fun r => preCdf ρ r a) atTop (𝓝 l) then Exists.choose h else 0
h_tendsto_ℚ : ∀ᵐ (a : α) ∂Measure.fst ρ, Tendsto (fun r => preCdf ρ r a) atTop (𝓝 (F a))
⊢ ∀ᵐ (a : α) ∂Measure.fst ρ, Tendsto (fun r => preCdf ρ r a) atTop (𝓝 1)

Next tactic:
have h_tendsto_ℕ : ∀ᵐ a ∂ρ.fst, Tendsto (fun n : ℕ => preCdf ρ n a) atTop (𝓝 (F a)) := by
    filter_upwards [h_tendsto_ℚ] with a ha using ha.comp tendsto_nat_cast_atTop_atTop
theorem tendsto_preCdf_atTop_one (ρ : Measure (α × ℝ)) [IsFiniteMeasure ρ] :
    ∀ᵐ a ∂ρ.fst, Tendsto (fun r => preCdf ρ r a) atTop (𝓝 1) := by
  -- We show first that `preCdf` has a limit almost everywhere. That limit has to be at most 1.
  -- We then show that the integral of `preCdf` tends to the integral of 1, and that it also tends
  -- to the integral of the limit. Since the limit is at most 1 and has same integral as 1, it is
  -- equal to 1 a.e.
  have h_mono := monotone_preCdf ρ
  have h_le_one := preCdf_le_one ρ
  -- `preCdf` has a limit a.e.
  have h_exists : ∀ᵐ a ∂ρ.fst, ∃ l, Tendsto (fun r => preCdf ρ r a) atTop (𝓝 l) := by
    filter_upwards [h_mono, h_le_one] with a ha_mono ha_le_one
    have h_tendsto :
      Tendsto (fun r => preCdf ρ r a) atTop atTop ∨
        ∃ l, Tendsto (fun r => preCdf ρ r a) atTop (𝓝 l) :=
      tendsto_of_monotone ha_mono
    cases' h_tendsto with h_absurd h_tendsto
    · rw [Monotone.tendsto_atTop_atTop_iff ha_mono] at h_absurd
      obtain ⟨r, hr⟩ := h_absurd 2
      exact absurd (hr.trans (ha_le_one r)) ENNReal.one_lt_two.not_le
    · exact h_tendsto
  classical
  -- let `F` be the pointwise limit of `preCdf` where it exists, and 0 elsewhere.
  let F : α → ℝ≥0∞ := fun a =>
    if h : ∃ l, Tendsto (fun r => preCdf ρ r a) atTop (𝓝 l) then h.choose else 0
  have h_tendsto_ℚ : ∀ᵐ a ∂ρ.fst, Tendsto (fun r => preCdf ρ r a) atTop (𝓝 (F a)) := by
    filter_upwards [h_exists] with a ha
    simp_rw [dif_pos ha]
    exact ha.choose_spec
  have h_tendsto_ℕ : ∀ᵐ a ∂ρ.fst, Tendsto (fun n : ℕ => preCdf ρ n a) atTop (𝓝 (F a)) := by
    

Proof state:
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
ρ : Measure (α × ℝ)
inst✝ : IsFiniteMeasure ρ
h_mono : ∀ᵐ (a : α) ∂Measure.fst ρ, Monotone fun r => preCdf ρ r a
h_le_one : ∀ᵐ (a : α) ∂Measure.fst ρ, ∀ (r : ℚ), preCdf ρ r a ≤ 1
h_exists : ∀ᵐ (a : α) ∂Measure.fst ρ, ∃ l, Tendsto (fun r => preCdf ρ r a) atTop (𝓝 l)
F : α → ℝ≥0∞ := fun a => if h : ∃ l, Tendsto (fun r => preCdf ρ r a) atTop (𝓝 l) then Exists.choose h else 0
h_tendsto_ℚ : ∀ᵐ (a : α) ∂Measure.fst ρ, Tendsto (fun r => preCdf ρ r a) atTop (𝓝 (F a))
⊢ ∀ᵐ (a : α) ∂Measure.fst ρ, Tendsto (fun n => preCdf ρ (↑n) a) atTop (𝓝 (F a))

Next tactic:
filter_upwards [h_tendsto_ℚ] with a ha using ha.comp tendsto_nat_cast_atTop_atTop
theorem tendsto_preCdf_atTop_one (ρ : Measure (α × ℝ)) [IsFiniteMeasure ρ] :
    ∀ᵐ a ∂ρ.fst, Tendsto (fun r => preCdf ρ r a) atTop (𝓝 1) := by
  -- We show first that `preCdf` has a limit almost everywhere. That limit has to be at most 1.
  -- We then show that the integral of `preCdf` tends to the integral of 1, and that it also tends
  -- to the integral of the limit. Since the limit is at most 1 and has same integral as 1, it is
  -- equal to 1 a.e.
  have h_mono := monotone_preCdf ρ
  have h_le_one := preCdf_le_one ρ
  -- `preCdf` has a limit a.e.
  have h_exists : ∀ᵐ a ∂ρ.fst, ∃ l, Tendsto (fun r => preCdf ρ r a) atTop (𝓝 l) := by
    filter_upwards [h_mono, h_le_one] with a ha_mono ha_le_one
    have h_tendsto :
      Tendsto (fun r => preCdf ρ r a) atTop atTop ∨
        ∃ l, Tendsto (fun r => preCdf ρ r a) atTop (𝓝 l) :=
      tendsto_of_monotone ha_mono
    cases' h_tendsto with h_absurd h_tendsto
    · rw [Monotone.tendsto_atTop_atTop_iff ha_mono] at h_absurd
      obtain ⟨r, hr⟩ := h_absurd 2
      exact absurd (hr.trans (ha_le_one r)) ENNReal.one_lt_two.not_le
    · exact h_tendsto
  classical
  -- let `F` be the pointwise limit of `preCdf` where it exists, and 0 elsewhere.
  let F : α → ℝ≥0∞ := fun a =>
    if h : ∃ l, Tendsto (fun r => preCdf ρ r a) atTop (𝓝 l) then h.choose else 0
  have h_tendsto_ℚ : ∀ᵐ a ∂ρ.fst, Tendsto (fun r => preCdf ρ r a) atTop (𝓝 (F a)) := by
    filter_upwards [h_exists] with a ha
    simp_rw [dif_pos ha]
    exact ha.choose_spec
  have h_tendsto_ℕ : ∀ᵐ a ∂ρ.fst, Tendsto (fun n : ℕ => preCdf ρ n a) atTop (𝓝 (F a)) := by
    filter_upwards [h_tendsto_ℚ] with a ha using ha.comp tendsto_nat_cast_atTop_atTop
  

Proof state:
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
ρ : Measure (α × ℝ)
inst✝ : IsFiniteMeasure ρ
h_mono : ∀ᵐ (a : α) ∂Measure.fst ρ, Monotone fun r => preCdf ρ r a
h_le_one : ∀ᵐ (a : α) ∂Measure.fst ρ, ∀ (r : ℚ), preCdf ρ r a ≤ 1
h_exists : ∀ᵐ (a : α) ∂Measure.fst ρ, ∃ l, Tendsto (fun r => preCdf ρ r a) atTop (𝓝 l)
F : α → ℝ≥0∞ := fun a => if h : ∃ l, Tendsto (fun r => preCdf ρ r a) atTop (𝓝 l) then Exists.choose h else 0
h_tendsto_ℚ : ∀ᵐ (a : α) ∂Measure.fst ρ, Tendsto (fun r => preCdf ρ r a) atTop (𝓝 (F a))
h_tendsto_ℕ : ∀ᵐ (a : α) ∂Measure.fst ρ, Tendsto (fun n => preCdf ρ (↑n) a) atTop (𝓝 (F a))
⊢ ∀ᵐ (a : α) ∂Measure.fst ρ, Tendsto (fun r => preCdf ρ r a) atTop (𝓝 1)

Next tactic:
have hF_ae_meas : AEMeasurable F ρ.fst := by
    refine' aemeasurable_of_tendsto_metrizable_ae _ (fun n => _) h_tendsto_ℚ
    exact measurable_preCdf.aemeasurable
theorem tendsto_preCdf_atTop_one (ρ : Measure (α × ℝ)) [IsFiniteMeasure ρ] :
    ∀ᵐ a ∂ρ.fst, Tendsto (fun r => preCdf ρ r a) atTop (𝓝 1) := by
  -- We show first that `preCdf` has a limit almost everywhere. That limit has to be at most 1.
  -- We then show that the integral of `preCdf` tends to the integral of 1, and that it also tends
  -- to the integral of the limit. Since the limit is at most 1 and has same integral as 1, it is
  -- equal to 1 a.e.
  have h_mono := monotone_preCdf ρ
  have h_le_one := preCdf_le_one ρ
  -- `preCdf` has a limit a.e.
  have h_exists : ∀ᵐ a ∂ρ.fst, ∃ l, Tendsto (fun r => preCdf ρ r a) atTop (𝓝 l) := by
    filter_upwards [h_mono, h_le_one] with a ha_mono ha_le_one
    have h_tendsto :
      Tendsto (fun r => preCdf ρ r a) atTop atTop ∨
        ∃ l, Tendsto (fun r => preCdf ρ r a) atTop (𝓝 l) :=
      tendsto_of_monotone ha_mono
    cases' h_tendsto with h_absurd h_tendsto
    · rw [Monotone.tendsto_atTop_atTop_iff ha_mono] at h_absurd
      obtain ⟨r, hr⟩ := h_absurd 2
      exact absurd (hr.trans (ha_le_one r)) ENNReal.one_lt_two.not_le
    · exact h_tendsto
  classical
  -- let `F` be the pointwise limit of `preCdf` where it exists, and 0 elsewhere.
  let F : α → ℝ≥0∞ := fun a =>
    if h : ∃ l, Tendsto (fun r => preCdf ρ r a) atTop (𝓝 l) then h.choose else 0
  have h_tendsto_ℚ : ∀ᵐ a ∂ρ.fst, Tendsto (fun r => preCdf ρ r a) atTop (𝓝 (F a)) := by
    filter_upwards [h_exists] with a ha
    simp_rw [dif_pos ha]
    exact ha.choose_spec
  have h_tendsto_ℕ : ∀ᵐ a ∂ρ.fst, Tendsto (fun n : ℕ => preCdf ρ n a) atTop (𝓝 (F a)) := by
    filter_upwards [h_tendsto_ℚ] with a ha using ha.comp tendsto_nat_cast_atTop_atTop
  have hF_ae_meas : AEMeasurable F ρ.fst := by
    

Proof state:
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
ρ : Measure (α × ℝ)
inst✝ : IsFiniteMeasure ρ
h_mono : ∀ᵐ (a : α) ∂Measure.fst ρ, Monotone fun r => preCdf ρ r a
h_le_one : ∀ᵐ (a : α) ∂Measure.fst ρ, ∀ (r : ℚ), preCdf ρ r a ≤ 1
h_exists : ∀ᵐ (a : α) ∂Measure.fst ρ, ∃ l, Tendsto (fun r => preCdf ρ r a) atTop (𝓝 l)
F : α → ℝ≥0∞ := fun a => if h : ∃ l, Tendsto (fun r => preCdf ρ r a) atTop (𝓝 l) then Exists.choose h else 0
h_tendsto_ℚ : ∀ᵐ (a : α) ∂Measure.fst ρ, Tendsto (fun r => preCdf ρ r a) atTop (𝓝 (F a))
h_tendsto_ℕ : ∀ᵐ (a : α) ∂Measure.fst ρ, Tendsto (fun n => preCdf ρ (↑n) a) atTop (𝓝 (F a))
⊢ AEMeasurable F

Next tactic:
refine' aemeasurable_of_tendsto_metrizable_ae _ (fun n => _) h_tendsto_ℚ