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
      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
    refine' aemeasurable_of_tendsto_metrizable_ae _ (fun n => _) h_tendsto_ℚ
    

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))
n : ℚ
⊢ AEMeasurable fun x => preCdf ρ n x

Next tactic:
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
    refine' aemeasurable_of_tendsto_metrizable_ae _ (fun n => _) h_tendsto_ℚ
    exact measurable_preCdf.aemeasurable
  

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))
hF_ae_meas : AEMeasurable F
⊢ ∀ᵐ (a : α) ∂Measure.fst ρ, Tendsto (fun r => preCdf ρ r a) atTop (𝓝 1)

Next tactic:
have hF_le_one : ∀ᵐ a ∂ρ.fst, F a ≤ 1 := by
    filter_upwards [h_tendsto_ℚ, h_le_one] with a ha ha_le using le_of_tendsto' ha ha_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
    · 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
    refine' aemeasurable_of_tendsto_metrizable_ae _ (fun n => _) h_tendsto_ℚ
    exact measurable_preCdf.aemeasurable
  have hF_le_one : ∀ᵐ a ∂ρ.fst, F a ≤ 1 := 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))
hF_ae_meas : AEMeasurable F
⊢ ∀ᵐ (a : α) ∂Measure.fst ρ, F a ≤ 1

Next tactic:
filter_upwards [h_tendsto_ℚ, h_le_one] with a ha ha_le using le_of_tendsto' ha ha_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
    · 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
    refine' aemeasurable_of_tendsto_metrizable_ae _ (fun n => _) h_tendsto_ℚ
    exact measurable_preCdf.aemeasurable
  have hF_le_one : ∀ᵐ a ∂ρ.fst, F a ≤ 1 := by
    filter_upwards [h_tendsto_ℚ, h_le_one] with a ha ha_le using le_of_tendsto' ha ha_le
  -- it suffices to show that the limit `F` is 1 a.e.
  

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))
hF_ae_meas : AEMeasurable F
hF_le_one : ∀ᵐ (a : α) ∂Measure.fst ρ, F a ≤ 1
⊢ ∀ᵐ (a : α) ∂Measure.fst ρ, Tendsto (fun r => preCdf ρ r a) atTop (𝓝 1)

Next tactic:
suffices ∀ᵐ a ∂ρ.fst, F a = 1 by
    filter_upwards [h_tendsto_ℚ, this] with a ha_tendsto ha_eq
    rwa [ha_eq] at ha_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.
  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
    refine' aemeasurable_of_tendsto_metrizable_ae _ (fun n => _) h_tendsto_ℚ
    exact measurable_preCdf.aemeasurable
  have hF_le_one : ∀ᵐ a ∂ρ.fst, F a ≤ 1 := by
    filter_upwards [h_tendsto_ℚ, h_le_one] with a ha ha_le using le_of_tendsto' ha ha_le
  -- it suffices to show that the limit `F` is 1 a.e.
  suffices ∀ᵐ a ∂ρ.fst, F a = 1 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))
hF_ae_meas : AEMeasurable F
hF_le_one : ∀ᵐ (a : α) ∂Measure.fst ρ, F a ≤ 1
this : ∀ᵐ (a : α) ∂Measure.fst ρ, F a = 1
⊢ ∀ᵐ (a : α) ∂Measure.fst ρ, Tendsto (fun r => preCdf ρ r a) atTop (𝓝 1)

Next tactic:
filter_upwards [h_tendsto_ℚ, this] with a ha_tendsto ha_eq
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
    refine' aemeasurable_of_tendsto_metrizable_ae _ (fun n => _) h_tendsto_ℚ
    exact measurable_preCdf.aemeasurable
  have hF_le_one : ∀ᵐ a ∂ρ.fst, F a ≤ 1 := by
    filter_upwards [h_tendsto_ℚ, h_le_one] with a ha ha_le using le_of_tendsto' ha ha_le
  -- it suffices to show that the limit `F` is 1 a.e.
  suffices ∀ᵐ a ∂ρ.fst, F a = 1 by
    filter_upwards [h_tendsto_ℚ, this] with a ha_tendsto ha_eq
    

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
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))
hF_ae_meas : AEMeasurable F
hF_le_one : ∀ᵐ (a : α) ∂Measure.fst ρ, F a ≤ 1
this : ∀ᵐ (a : α) ∂Measure.fst ρ, F a = 1
a : α
ha_tendsto : Tendsto (fun r => preCdf ρ r a) atTop (𝓝 (F a))
ha_eq : F a = 1
⊢ Tendsto (fun r => preCdf ρ r a) atTop (𝓝 1)

Next tactic:
rwa [ha_eq] at ha_tendsto
theorem tendsto_preCdf_atBot_zero (ρ : Measure (α × ℝ)) [IsFiniteMeasure ρ] :
    ∀ᵐ a ∂ρ.fst, Tendsto (fun r => preCdf ρ r a) atBot (𝓝 0) := by
  -- We show first that `preCdf` has a limit in ℝ≥0∞ almost everywhere.
  -- We then show that the integral of `pre_cdf` tends to 0, and that it also tends
  -- to the integral of the limit. Since the limit has integral 0, it is equal to 0 a.e.
  

Proof state:
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
ρ : Measure (α × ℝ)
inst✝ : IsFiniteMeasure ρ
⊢ ∀ᵐ (a : α) ∂Measure.fst ρ, Tendsto (fun r => preCdf ρ r a) atBot (𝓝 0)

Next tactic:
suffices ∀ᵐ a ∂ρ.fst, Tendsto (fun r => preCdf ρ (-r) a) atTop (𝓝 0) by
    filter_upwards [this] with a ha
    have h_eq_neg : (fun r : ℚ => preCdf ρ r a) = fun r : ℚ => preCdf ρ (- -r) a := by
      simp_rw [neg_neg]
    rw [h_eq_neg]
    exact ha.comp tendsto_neg_atBot_atTop
theorem tendsto_preCdf_atBot_zero (ρ : Measure (α × ℝ)) [IsFiniteMeasure ρ] :
    ∀ᵐ a ∂ρ.fst, Tendsto (fun r => preCdf ρ r a) atBot (𝓝 0) := by
  -- We show first that `preCdf` has a limit in ℝ≥0∞ almost everywhere.
  -- We then show that the integral of `pre_cdf` tends to 0, and that it also tends
  -- to the integral of the limit. Since the limit has integral 0, it is equal to 0 a.e.
  suffices ∀ᵐ a ∂ρ.fst, Tendsto (fun r => preCdf ρ (-r) a) atTop (𝓝 0) by
    

Proof state:
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
ρ : Measure (α × ℝ)
inst✝ : IsFiniteMeasure ρ
this : ∀ᵐ (a : α) ∂Measure.fst ρ, Tendsto (fun r => preCdf ρ (-r) a) atTop (𝓝 0)
⊢ ∀ᵐ (a : α) ∂Measure.fst ρ, Tendsto (fun r => preCdf ρ r a) atBot (𝓝 0)

Next tactic:
filter_upwards [this] with a ha
theorem tendsto_preCdf_atBot_zero (ρ : Measure (α × ℝ)) [IsFiniteMeasure ρ] :
    ∀ᵐ a ∂ρ.fst, Tendsto (fun r => preCdf ρ r a) atBot (𝓝 0) := by
  -- We show first that `preCdf` has a limit in ℝ≥0∞ almost everywhere.
  -- We then show that the integral of `pre_cdf` tends to 0, and that it also tends
  -- to the integral of the limit. Since the limit has integral 0, it is equal to 0 a.e.
  suffices ∀ᵐ a ∂ρ.fst, Tendsto (fun r => preCdf ρ (-r) a) atTop (𝓝 0) by
    filter_upwards [this] with a ha
    

Proof state:
case h
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
ρ : Measure (α × ℝ)
inst✝ : IsFiniteMeasure ρ
this : ∀ᵐ (a : α) ∂Measure.fst ρ, Tendsto (fun r => preCdf ρ (-r) a) atTop (𝓝 0)
a : α
ha : Tendsto (fun r => preCdf ρ (-r) a) atTop (𝓝 0)
⊢ Tendsto (fun r => preCdf ρ r a) atBot (𝓝 0)

Next tactic:
have h_eq_neg : (fun r : ℚ => preCdf ρ r a) = fun r : ℚ => preCdf ρ (- -r) a := by
      simp_rw [neg_neg]
theorem tendsto_preCdf_atBot_zero (ρ : Measure (α × ℝ)) [IsFiniteMeasure ρ] :
    ∀ᵐ a ∂ρ.fst, Tendsto (fun r => preCdf ρ r a) atBot (𝓝 0) := by
  -- We show first that `preCdf` has a limit in ℝ≥0∞ almost everywhere.
  -- We then show that the integral of `pre_cdf` tends to 0, and that it also tends
  -- to the integral of the limit. Since the limit has integral 0, it is equal to 0 a.e.
  suffices ∀ᵐ a ∂ρ.fst, Tendsto (fun r => preCdf ρ (-r) a) atTop (𝓝 0) by
    filter_upwards [this] with a ha
    have h_eq_neg : (fun r : ℚ => preCdf ρ r a) = fun r : ℚ => preCdf ρ (- -r) a := by
      

Proof state:
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
ρ : Measure (α × ℝ)
inst✝ : IsFiniteMeasure ρ
this : ∀ᵐ (a : α) ∂Measure.fst ρ, Tendsto (fun r => preCdf ρ (-r) a) atTop (𝓝 0)
a : α
ha : Tendsto (fun r => preCdf ρ (-r) a) atTop (𝓝 0)
⊢ (fun r => preCdf ρ r a) = fun r => preCdf ρ (- -r) a

Next tactic:
simp_rw [neg_neg]
theorem tendsto_preCdf_atBot_zero (ρ : Measure (α × ℝ)) [IsFiniteMeasure ρ] :
    ∀ᵐ a ∂ρ.fst, Tendsto (fun r => preCdf ρ r a) atBot (𝓝 0) := by
  -- We show first that `preCdf` has a limit in ℝ≥0∞ almost everywhere.
  -- We then show that the integral of `pre_cdf` tends to 0, and that it also tends
  -- to the integral of the limit. Since the limit has integral 0, it is equal to 0 a.e.
  suffices ∀ᵐ a ∂ρ.fst, Tendsto (fun r => preCdf ρ (-r) a) atTop (𝓝 0) by
    filter_upwards [this] with a ha
    have h_eq_neg : (fun r : ℚ => preCdf ρ r a) = fun r : ℚ => preCdf ρ (- -r) a := by
      simp_rw [neg_neg]
    

Proof state:
case h
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
ρ : Measure (α × ℝ)
inst✝ : IsFiniteMeasure ρ
this : ∀ᵐ (a : α) ∂Measure.fst ρ, Tendsto (fun r => preCdf ρ (-r) a) atTop (𝓝 0)
a : α
ha : Tendsto (fun r => preCdf ρ (-r) a) atTop (𝓝 0)
h_eq_neg : (fun r => preCdf ρ r a) = fun r => preCdf ρ (- -r) a
⊢ Tendsto (fun r => preCdf ρ r a) atBot (𝓝 0)

Next tactic:
rw [h_eq_neg]
theorem tendsto_preCdf_atBot_zero (ρ : Measure (α × ℝ)) [IsFiniteMeasure ρ] :
    ∀ᵐ a ∂ρ.fst, Tendsto (fun r => preCdf ρ r a) atBot (𝓝 0) := by
  -- We show first that `preCdf` has a limit in ℝ≥0∞ almost everywhere.
  -- We then show that the integral of `pre_cdf` tends to 0, and that it also tends
  -- to the integral of the limit. Since the limit has integral 0, it is equal to 0 a.e.
  suffices ∀ᵐ a ∂ρ.fst, Tendsto (fun r => preCdf ρ (-r) a) atTop (𝓝 0) by
    filter_upwards [this] with a ha
    have h_eq_neg : (fun r : ℚ => preCdf ρ r a) = fun r : ℚ => preCdf ρ (- -r) a := by
      simp_rw [neg_neg]
    rw [h_eq_neg]
    

Proof state:
case h
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
ρ : Measure (α × ℝ)
inst✝ : IsFiniteMeasure ρ
this : ∀ᵐ (a : α) ∂Measure.fst ρ, Tendsto (fun r => preCdf ρ (-r) a) atTop (𝓝 0)
a : α
ha : Tendsto (fun r => preCdf ρ (-r) a) atTop (𝓝 0)
h_eq_neg : (fun r => preCdf ρ r a) = fun r => preCdf ρ (- -r) a
⊢ Tendsto (fun r => preCdf ρ (- -r) a) atBot (𝓝 0)

Next tactic:
exact ha.comp tendsto_neg_atBot_atTop
theorem tendsto_preCdf_atBot_zero (ρ : Measure (α × ℝ)) [IsFiniteMeasure ρ] :
    ∀ᵐ a ∂ρ.fst, Tendsto (fun r => preCdf ρ r a) atBot (𝓝 0) := by
  -- We show first that `preCdf` has a limit in ℝ≥0∞ almost everywhere.
  -- We then show that the integral of `pre_cdf` tends to 0, and that it also tends
  -- to the integral of the limit. Since the limit has integral 0, it is equal to 0 a.e.
  suffices ∀ᵐ a ∂ρ.fst, Tendsto (fun r => preCdf ρ (-r) a) atTop (𝓝 0) by
    filter_upwards [this] with a ha
    have h_eq_neg : (fun r : ℚ => preCdf ρ r a) = fun r : ℚ => preCdf ρ (- -r) a := by
      simp_rw [neg_neg]
    rw [h_eq_neg]
    exact ha.comp tendsto_neg_atBot_atTop
  

Proof state:
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
ρ : Measure (α × ℝ)
inst✝ : IsFiniteMeasure ρ
⊢ ∀ᵐ (a : α) ∂Measure.fst ρ, Tendsto (fun r => preCdf ρ (-r) a) atTop (𝓝 0)

Next tactic:
have h_exists : ∀ᵐ a ∂ρ.fst, ∃ l, Tendsto (fun r => preCdf ρ (-r) a) atTop (𝓝 l) := by
    filter_upwards [monotone_preCdf ρ] with a ha
    have h_anti : Antitone fun r => preCdf ρ (-r) a := fun p q hpq => ha (neg_le_neg hpq)
    have h_tendsto :
      Tendsto (fun r => preCdf ρ (-r) a) atTop atBot ∨
        ∃ l, Tendsto (fun r => preCdf ρ (-r) a) atTop (𝓝 l) :=
      tendsto_of_antitone h_anti
    cases' h_tendsto with h_bot h_tendsto
    · exact ⟨0, Tendsto.mono_right h_bot atBot_le_nhds_bot⟩
    · exact h_tendsto