l3lab/ntp-mathlib huggingface dataset:
theorem continuousWithinAt_condCdf'_Ici (ρ : Measure (α × ℝ)) (a : α) (x : ℝ) :
    ContinuousWithinAt (condCdf' ρ a) (Ici x) x := by
  rw [← continuousWithinAt_Ioi_iff_Ici]
  convert Monotone.tendsto_nhdsWithin_Ioi (monotone_condCdf' ρ a) x
  rw [sInf_image']
  have h' : ⨅ r : Ioi x, condCdf' ρ a r = ⨅ r : { r' : ℚ // x < r' }, condCdf' ρ a r := by
    refine' Real.iInf_Ioi_eq_iInf_rat_gt x _ (monotone_condCdf' ρ a)
    refine' ⟨0, fun z => _⟩
    rintro ⟨u, -, rfl⟩
    exact condCdf'_nonneg ρ a u
  have h'' :
    ⨅ r : { r' : ℚ // x < r' }, condCdf' ρ a r =
      ⨅ r : { r' : ℚ // x < r' }, condCdfRat ρ a r := by
    congr with r
    exact condCdf'_eq_condCdfRat ρ a r
  rw [h', h'', ContinuousWithinAt]
  

Proof state:
case a
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
ρ : Measure (α × ℝ)
a : α
x : ℝ
h' : ⨅ r, condCdf' ρ a ↑r = ⨅ r, condCdf' ρ a ↑↑r
h'' : ⨅ r, condCdf' ρ a ↑↑r = ⨅ r, condCdfRat ρ a ↑r
⊢ Tendsto (condCdf' ρ a) (𝓝[>] x) (𝓝 (condCdf' ρ a x)) ↔ Tendsto (condCdf' ρ a) (𝓝[>] x) (𝓝 (⨅ r, condCdfRat ρ a ↑r))

Next tactic:
congr!
theorem continuousWithinAt_condCdf'_Ici (ρ : Measure (α × ℝ)) (a : α) (x : ℝ) :
    ContinuousWithinAt (condCdf' ρ a) (Ici x) x := by
  rw [← continuousWithinAt_Ioi_iff_Ici]
  convert Monotone.tendsto_nhdsWithin_Ioi (monotone_condCdf' ρ a) x
  rw [sInf_image']
  have h' : ⨅ r : Ioi x, condCdf' ρ a r = ⨅ r : { r' : ℚ // x < r' }, condCdf' ρ a r := by
    refine' Real.iInf_Ioi_eq_iInf_rat_gt x _ (monotone_condCdf' ρ a)
    refine' ⟨0, fun z => _⟩
    rintro ⟨u, -, rfl⟩
    exact condCdf'_nonneg ρ a u
  have h'' :
    ⨅ r : { r' : ℚ // x < r' }, condCdf' ρ a r =
      ⨅ r : { r' : ℚ // x < r' }, condCdfRat ρ a r := by
    congr with r
    exact condCdf'_eq_condCdfRat ρ a r
  rw [h', h'', ContinuousWithinAt]
  congr!
  

Proof state:
case a.a.h.e'_5.h.e'_3
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
ρ : Measure (α × ℝ)
a : α
x : ℝ
h' : ⨅ r, condCdf' ρ a ↑r = ⨅ r, condCdf' ρ a ↑↑r
h'' : ⨅ r, condCdf' ρ a ↑↑r = ⨅ r, condCdfRat ρ a ↑r
⊢ condCdf' ρ a x = ⨅ r, condCdfRat ρ a ↑r

Next tactic:
exact condCdf'_def'
/-- The conditional cdf is lower or equal to 1 for all `a : α`. -/
theorem condCdf_le_one (ρ : Measure (α × ℝ)) (a : α) (x : ℝ) : condCdf ρ a x ≤ 1 := by
  

Proof state:
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
ρ : Measure (α × ℝ)
a : α
x : ℝ
⊢ ↑(condCdf ρ a) x ≤ 1

Next tactic:
obtain ⟨r, hrx⟩ := exists_rat_gt x
/-- The conditional cdf is lower or equal to 1 for all `a : α`. -/
theorem condCdf_le_one (ρ : Measure (α × ℝ)) (a : α) (x : ℝ) : condCdf ρ a x ≤ 1 := by
  obtain ⟨r, hrx⟩ := exists_rat_gt x
  

Proof state:
case intro
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
ρ : Measure (α × ℝ)
a : α
x : ℝ
r : ℚ
hrx : x < ↑r
⊢ ↑(condCdf ρ a) x ≤ 1

Next tactic:
rw [← StieltjesFunction.iInf_rat_gt_eq]
/-- The conditional cdf is lower or equal to 1 for all `a : α`. -/
theorem condCdf_le_one (ρ : Measure (α × ℝ)) (a : α) (x : ℝ) : condCdf ρ a x ≤ 1 := by
  obtain ⟨r, hrx⟩ := exists_rat_gt x
  rw [← StieltjesFunction.iInf_rat_gt_eq]
  

Proof state:
case intro
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
ρ : Measure (α × ℝ)
a : α
x : ℝ
r : ℚ
hrx : x < ↑r
⊢ ⨅ r, ↑(condCdf ρ a) ↑↑r ≤ 1

Next tactic:
simp_rw [condCdf_eq_condCdfRat]
/-- The conditional cdf is lower or equal to 1 for all `a : α`. -/
theorem condCdf_le_one (ρ : Measure (α × ℝ)) (a : α) (x : ℝ) : condCdf ρ a x ≤ 1 := by
  obtain ⟨r, hrx⟩ := exists_rat_gt x
  rw [← StieltjesFunction.iInf_rat_gt_eq]
  simp_rw [condCdf_eq_condCdfRat]
  

Proof state:
case intro
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
ρ : Measure (α × ℝ)
a : α
x : ℝ
r : ℚ
hrx : x < ↑r
⊢ ⨅ r, condCdfRat ρ a ↑r ≤ 1

Next tactic:
refine' ciInf_le_of_le (bddBelow_range_condCdfRat_gt ρ a x) _ (condCdfRat_le_one _ _ _)
/-- The conditional cdf is lower or equal to 1 for all `a : α`. -/
theorem condCdf_le_one (ρ : Measure (α × ℝ)) (a : α) (x : ℝ) : condCdf ρ a x ≤ 1 := by
  obtain ⟨r, hrx⟩ := exists_rat_gt x
  rw [← StieltjesFunction.iInf_rat_gt_eq]
  simp_rw [condCdf_eq_condCdfRat]
  refine' ciInf_le_of_le (bddBelow_range_condCdfRat_gt ρ a x) _ (condCdfRat_le_one _ _ _)
  

Proof state:
case intro
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
ρ : Measure (α × ℝ)
a : α
x : ℝ
r : ℚ
hrx : x < ↑r
⊢ { r' // x < ↑r' }

Next tactic:
exact ⟨r, hrx⟩
/-- The conditional cdf tends to 0 at -∞ for all `a : α`. -/
theorem tendsto_condCdf_atBot (ρ : Measure (α × ℝ)) (a : α) :
    Tendsto (condCdf ρ a) atBot (𝓝 0) := by
  

Proof state:
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
ρ : Measure (α × ℝ)
a : α
⊢ Tendsto (↑(condCdf ρ a)) atBot (𝓝 0)

Next tactic:
have h_exists : ∀ x : ℝ, ∃ q : ℚ, x < q ∧ ↑q < x + 1 := fun x => exists_rat_btwn (lt_add_one x)
/-- The conditional cdf tends to 0 at -∞ for all `a : α`. -/
theorem tendsto_condCdf_atBot (ρ : Measure (α × ℝ)) (a : α) :
    Tendsto (condCdf ρ a) atBot (𝓝 0) := by
  have h_exists : ∀ x : ℝ, ∃ q : ℚ, x < q ∧ ↑q < x + 1 := fun x => exists_rat_btwn (lt_add_one x)
  

Proof state:
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
ρ : Measure (α × ℝ)
a : α
h_exists : ∀ (x : ℝ), ∃ q, x < ↑q ∧ ↑q < x + 1
⊢ Tendsto (↑(condCdf ρ a)) atBot (𝓝 0)

Next tactic:
let qs : ℝ → ℚ := fun x => (h_exists x).choose
/-- The conditional cdf tends to 0 at -∞ for all `a : α`. -/
theorem tendsto_condCdf_atBot (ρ : Measure (α × ℝ)) (a : α) :
    Tendsto (condCdf ρ a) atBot (𝓝 0) := by
  have h_exists : ∀ x : ℝ, ∃ q : ℚ, x < q ∧ ↑q < x + 1 := fun x => exists_rat_btwn (lt_add_one x)
  let qs : ℝ → ℚ := fun x => (h_exists x).choose
  

Proof state:
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
ρ : Measure (α × ℝ)
a : α
h_exists : ∀ (x : ℝ), ∃ q, x < ↑q ∧ ↑q < x + 1
qs : ℝ → ℚ := fun x => Exists.choose (_ : ∃ q, x < ↑q ∧ ↑q < x + 1)
⊢ Tendsto (↑(condCdf ρ a)) atBot (𝓝 0)

Next tactic:
have hqs_tendsto : Tendsto qs atBot atBot := by
    rw [tendsto_atBot_atBot]
    refine' fun q => ⟨q - 1, fun y hy => _⟩
    have h_le : ↑(qs y) ≤ (q : ℝ) - 1 + 1 :=
      (h_exists y).choose_spec.2.le.trans (add_le_add hy le_rfl)
    rw [sub_add_cancel] at h_le
    exact mod_cast h_le
/-- The conditional cdf tends to 0 at -∞ for all `a : α`. -/
theorem tendsto_condCdf_atBot (ρ : Measure (α × ℝ)) (a : α) :
    Tendsto (condCdf ρ a) atBot (𝓝 0) := by
  have h_exists : ∀ x : ℝ, ∃ q : ℚ, x < q ∧ ↑q < x + 1 := fun x => exists_rat_btwn (lt_add_one x)
  let qs : ℝ → ℚ := fun x => (h_exists x).choose
  have hqs_tendsto : Tendsto qs atBot atBot := by
    

Proof state:
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
ρ : Measure (α × ℝ)
a : α
h_exists : ∀ (x : ℝ), ∃ q, x < ↑q ∧ ↑q < x + 1
qs : ℝ → ℚ := fun x => Exists.choose (_ : ∃ q, x < ↑q ∧ ↑q < x + 1)
⊢ Tendsto qs atBot atBot

Next tactic:
rw [tendsto_atBot_atBot]
/-- The conditional cdf tends to 0 at -∞ for all `a : α`. -/
theorem tendsto_condCdf_atBot (ρ : Measure (α × ℝ)) (a : α) :
    Tendsto (condCdf ρ a) atBot (𝓝 0) := by
  have h_exists : ∀ x : ℝ, ∃ q : ℚ, x < q ∧ ↑q < x + 1 := fun x => exists_rat_btwn (lt_add_one x)
  let qs : ℝ → ℚ := fun x => (h_exists x).choose
  have hqs_tendsto : Tendsto qs atBot atBot := by
    rw [tendsto_atBot_atBot]
    

Proof state:
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
ρ : Measure (α × ℝ)
a : α
h_exists : ∀ (x : ℝ), ∃ q, x < ↑q ∧ ↑q < x + 1
qs : ℝ → ℚ := fun x => Exists.choose (_ : ∃ q, x < ↑q ∧ ↑q < x + 1)
⊢ ∀ (b : ℚ), ∃ i, ∀ a ≤ i, qs a ≤ b

Next tactic:
refine' fun q => ⟨q - 1, fun y hy => _⟩
/-- The conditional cdf tends to 0 at -∞ for all `a : α`. -/
theorem tendsto_condCdf_atBot (ρ : Measure (α × ℝ)) (a : α) :
    Tendsto (condCdf ρ a) atBot (𝓝 0) := by
  have h_exists : ∀ x : ℝ, ∃ q : ℚ, x < q ∧ ↑q < x + 1 := fun x => exists_rat_btwn (lt_add_one x)
  let qs : ℝ → ℚ := fun x => (h_exists x).choose
  have hqs_tendsto : Tendsto qs atBot atBot := by
    rw [tendsto_atBot_atBot]
    refine' fun q => ⟨q - 1, fun y hy => _⟩
    

Proof state:
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
ρ : Measure (α × ℝ)
a : α
h_exists : ∀ (x : ℝ), ∃ q, x < ↑q ∧ ↑q < x + 1
qs : ℝ → ℚ := fun x => Exists.choose (_ : ∃ q, x < ↑q ∧ ↑q < x + 1)
q : ℚ
y : ℝ
hy : y ≤ ↑q - 1
⊢ qs y ≤ q

Next tactic:
have h_le : ↑(qs y) ≤ (q : ℝ) - 1 + 1 :=
      (h_exists y).choose_spec.2.le.trans (add_le_add hy le_rfl)
/-- The conditional cdf tends to 0 at -∞ for all `a : α`. -/
theorem tendsto_condCdf_atBot (ρ : Measure (α × ℝ)) (a : α) :
    Tendsto (condCdf ρ a) atBot (𝓝 0) := by
  have h_exists : ∀ x : ℝ, ∃ q : ℚ, x < q ∧ ↑q < x + 1 := fun x => exists_rat_btwn (lt_add_one x)
  let qs : ℝ → ℚ := fun x => (h_exists x).choose
  have hqs_tendsto : Tendsto qs atBot atBot := by
    rw [tendsto_atBot_atBot]
    refine' fun q => ⟨q - 1, fun y hy => _⟩
    have h_le : ↑(qs y) ≤ (q : ℝ) - 1 + 1 :=
      (h_exists y).choose_spec.2.le.trans (add_le_add hy le_rfl)
    

Proof state:
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
ρ : Measure (α × ℝ)
a : α
h_exists : ∀ (x : ℝ), ∃ q, x < ↑q ∧ ↑q < x + 1
qs : ℝ → ℚ := fun x => Exists.choose (_ : ∃ q, x < ↑q ∧ ↑q < x + 1)
q : ℚ
y : ℝ
hy : y ≤ ↑q - 1
h_le : ↑(qs y) ≤ ↑q - 1 + 1
⊢ qs y ≤ q

Next tactic:
rw [sub_add_cancel] at h_le
/-- The conditional cdf tends to 0 at -∞ for all `a : α`. -/
theorem tendsto_condCdf_atBot (ρ : Measure (α × ℝ)) (a : α) :
    Tendsto (condCdf ρ a) atBot (𝓝 0) := by
  have h_exists : ∀ x : ℝ, ∃ q : ℚ, x < q ∧ ↑q < x + 1 := fun x => exists_rat_btwn (lt_add_one x)
  let qs : ℝ → ℚ := fun x => (h_exists x).choose
  have hqs_tendsto : Tendsto qs atBot atBot := by
    rw [tendsto_atBot_atBot]
    refine' fun q => ⟨q - 1, fun y hy => _⟩
    have h_le : ↑(qs y) ≤ (q : ℝ) - 1 + 1 :=
      (h_exists y).choose_spec.2.le.trans (add_le_add hy le_rfl)
    rw [sub_add_cancel] at h_le
    

Proof state:
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
ρ : Measure (α × ℝ)
a : α
h_exists : ∀ (x : ℝ), ∃ q, x < ↑q ∧ ↑q < x + 1
qs : ℝ → ℚ := fun x => Exists.choose (_ : ∃ q, x < ↑q ∧ ↑q < x + 1)
q : ℚ
y : ℝ
hy : y ≤ ↑q - 1
h_le : ↑(qs y) ≤ ↑q
⊢ qs y ≤ q

Next tactic:
exact mod_cast h_le
/-- The conditional cdf tends to 0 at -∞ for all `a : α`. -/
theorem tendsto_condCdf_atBot (ρ : Measure (α × ℝ)) (a : α) :
    Tendsto (condCdf ρ a) atBot (𝓝 0) := by
  have h_exists : ∀ x : ℝ, ∃ q : ℚ, x < q ∧ ↑q < x + 1 := fun x => exists_rat_btwn (lt_add_one x)
  let qs : ℝ → ℚ := fun x => (h_exists x).choose
  have hqs_tendsto : Tendsto qs atBot atBot := by
    rw [tendsto_atBot_atBot]
    refine' fun q => ⟨q - 1, fun y hy => _⟩
    have h_le : ↑(qs y) ≤ (q : ℝ) - 1 + 1 :=
      (h_exists y).choose_spec.2.le.trans (add_le_add hy le_rfl)
    rw [sub_add_cancel] at h_le
    exact mod_cast h_le
  

Proof state:
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
ρ : Measure (α × ℝ)
a : α
h_exists : ∀ (x : ℝ), ∃ q, x < ↑q ∧ ↑q < x + 1
qs : ℝ → ℚ := fun x => Exists.choose (_ : ∃ q, x < ↑q ∧ ↑q < x + 1)
hqs_tendsto : Tendsto qs atBot atBot
⊢ Tendsto (↑(condCdf ρ a)) atBot (𝓝 0)

Next tactic:
refine'
    tendsto_of_tendsto_of_tendsto_of_le_of_le tendsto_const_nhds
      ((tendsto_condCdfRat_atBot ρ a).comp hqs_tendsto) (condCdf_nonneg ρ a) fun x => _
/-- The conditional cdf tends to 0 at -∞ for all `a : α`. -/
theorem tendsto_condCdf_atBot (ρ : Measure (α × ℝ)) (a : α) :
    Tendsto (condCdf ρ a) atBot (𝓝 0) := by
  have h_exists : ∀ x : ℝ, ∃ q : ℚ, x < q ∧ ↑q < x + 1 := fun x => exists_rat_btwn (lt_add_one x)
  let qs : ℝ → ℚ := fun x => (h_exists x).choose
  have hqs_tendsto : Tendsto qs atBot atBot := by
    rw [tendsto_atBot_atBot]
    refine' fun q => ⟨q - 1, fun y hy => _⟩
    have h_le : ↑(qs y) ≤ (q : ℝ) - 1 + 1 :=
      (h_exists y).choose_spec.2.le.trans (add_le_add hy le_rfl)
    rw [sub_add_cancel] at h_le
    exact mod_cast h_le
  refine'
    tendsto_of_tendsto_of_tendsto_of_le_of_le tendsto_const_nhds
      ((tendsto_condCdfRat_atBot ρ a).comp hqs_tendsto) (condCdf_nonneg ρ a) fun x => _
  

Proof state:
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
ρ : Measure (α × ℝ)
a : α
h_exists : ∀ (x : ℝ), ∃ q, x < ↑q ∧ ↑q < x + 1
qs : ℝ → ℚ := fun x => Exists.choose (_ : ∃ q, x < ↑q ∧ ↑q < x + 1)
hqs_tendsto : Tendsto qs atBot atBot
x : ℝ
⊢ ↑(condCdf ρ a) x ≤ (condCdfRat ρ a ∘ qs) x

Next tactic:
rw [Function.comp_apply, ← condCdf_eq_condCdfRat]
/-- The conditional cdf tends to 0 at -∞ for all `a : α`. -/
theorem tendsto_condCdf_atBot (ρ : Measure (α × ℝ)) (a : α) :
    Tendsto (condCdf ρ a) atBot (𝓝 0) := by
  have h_exists : ∀ x : ℝ, ∃ q : ℚ, x < q ∧ ↑q < x + 1 := fun x => exists_rat_btwn (lt_add_one x)
  let qs : ℝ → ℚ := fun x => (h_exists x).choose
  have hqs_tendsto : Tendsto qs atBot atBot := by
    rw [tendsto_atBot_atBot]
    refine' fun q => ⟨q - 1, fun y hy => _⟩
    have h_le : ↑(qs y) ≤ (q : ℝ) - 1 + 1 :=
      (h_exists y).choose_spec.2.le.trans (add_le_add hy le_rfl)
    rw [sub_add_cancel] at h_le
    exact mod_cast h_le
  refine'
    tendsto_of_tendsto_of_tendsto_of_le_of_le tendsto_const_nhds
      ((tendsto_condCdfRat_atBot ρ a).comp hqs_tendsto) (condCdf_nonneg ρ a) fun x => _
  rw [Function.comp_apply, ← condCdf_eq_condCdfRat]
  

Proof state:
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
ρ : Measure (α × ℝ)
a : α
h_exists : ∀ (x : ℝ), ∃ q, x < ↑q ∧ ↑q < x + 1
qs : ℝ → ℚ := fun x => Exists.choose (_ : ∃ q, x < ↑q ∧ ↑q < x + 1)
hqs_tendsto : Tendsto qs atBot atBot
x : ℝ
⊢ ↑(condCdf ρ a) x ≤ ↑(condCdf ρ a) ↑(qs x)

Next tactic:
exact (condCdf ρ a).mono (h_exists x).choose_spec.1.le
/-- The conditional cdf tends to 1 at +∞ for all `a : α`. -/
theorem tendsto_condCdf_atTop (ρ : Measure (α × ℝ)) (a : α) :
    Tendsto (condCdf ρ a) atTop (𝓝 1) := by
  

Proof state:
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
ρ : Measure (α × ℝ)
a : α
⊢ Tendsto (↑(condCdf ρ a)) atTop (𝓝 1)

Next tactic:
have h_exists : ∀ x : ℝ, ∃ q : ℚ, x - 1 < q ∧ ↑q < x := fun x => exists_rat_btwn (sub_one_lt x)
/-- The conditional cdf tends to 1 at +∞ for all `a : α`. -/
theorem tendsto_condCdf_atTop (ρ : Measure (α × ℝ)) (a : α) :
    Tendsto (condCdf ρ a) atTop (𝓝 1) := by
  have h_exists : ∀ x : ℝ, ∃ q : ℚ, x - 1 < q ∧ ↑q < x := fun x => exists_rat_btwn (sub_one_lt x)
  

Proof state:
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
ρ : Measure (α × ℝ)
a : α
h_exists : ∀ (x : ℝ), ∃ q, x - 1 < ↑q ∧ ↑q < x
⊢ Tendsto (↑(condCdf ρ a)) atTop (𝓝 1)

Next tactic:
let qs : ℝ → ℚ := fun x => (h_exists x).choose
/-- The conditional cdf tends to 1 at +∞ for all `a : α`. -/
theorem tendsto_condCdf_atTop (ρ : Measure (α × ℝ)) (a : α) :
    Tendsto (condCdf ρ a) atTop (𝓝 1) := by
  have h_exists : ∀ x : ℝ, ∃ q : ℚ, x - 1 < q ∧ ↑q < x := fun x => exists_rat_btwn (sub_one_lt x)
  let qs : ℝ → ℚ := fun x => (h_exists x).choose
  

Proof state:
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
ρ : Measure (α × ℝ)
a : α
h_exists : ∀ (x : ℝ), ∃ q, x - 1 < ↑q ∧ ↑q < x
qs : ℝ → ℚ := fun x => Exists.choose (_ : ∃ q, x - 1 < ↑q ∧ ↑q < x)
⊢ Tendsto (↑(condCdf ρ a)) atTop (𝓝 1)

Next tactic:
have hqs_tendsto : Tendsto qs atTop atTop := by
    rw [tendsto_atTop_atTop]
    refine' fun q => ⟨q + 1, fun y hy => _⟩
    have h_le : y - 1 ≤ qs y := (h_exists y).choose_spec.1.le
    rw [sub_le_iff_le_add] at h_le
    exact_mod_cast le_of_add_le_add_right (hy.trans h_le)
/-- The conditional cdf tends to 1 at +∞ for all `a : α`. -/
theorem tendsto_condCdf_atTop (ρ : Measure (α × ℝ)) (a : α) :
    Tendsto (condCdf ρ a) atTop (𝓝 1) := by
  have h_exists : ∀ x : ℝ, ∃ q : ℚ, x - 1 < q ∧ ↑q < x := fun x => exists_rat_btwn (sub_one_lt x)
  let qs : ℝ → ℚ := fun x => (h_exists x).choose
  have hqs_tendsto : Tendsto qs atTop atTop := by
    

Proof state:
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
ρ : Measure (α × ℝ)
a : α
h_exists : ∀ (x : ℝ), ∃ q, x - 1 < ↑q ∧ ↑q < x
qs : ℝ → ℚ := fun x => Exists.choose (_ : ∃ q, x - 1 < ↑q ∧ ↑q < x)
⊢ Tendsto qs atTop atTop

Next tactic:
rw [tendsto_atTop_atTop]
/-- The conditional cdf tends to 1 at +∞ for all `a : α`. -/
theorem tendsto_condCdf_atTop (ρ : Measure (α × ℝ)) (a : α) :
    Tendsto (condCdf ρ a) atTop (𝓝 1) := by
  have h_exists : ∀ x : ℝ, ∃ q : ℚ, x - 1 < q ∧ ↑q < x := fun x => exists_rat_btwn (sub_one_lt x)
  let qs : ℝ → ℚ := fun x => (h_exists x).choose
  have hqs_tendsto : Tendsto qs atTop atTop := by
    rw [tendsto_atTop_atTop]
    

Proof state:
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
ρ : Measure (α × ℝ)
a : α
h_exists : ∀ (x : ℝ), ∃ q, x - 1 < ↑q ∧ ↑q < x
qs : ℝ → ℚ := fun x => Exists.choose (_ : ∃ q, x - 1 < ↑q ∧ ↑q < x)
⊢ ∀ (b : ℚ), ∃ i, ∀ (a : ℝ), i ≤ a → b ≤ qs a

Next tactic:
refine' fun q => ⟨q + 1, fun y hy => _⟩
/-- The conditional cdf tends to 1 at +∞ for all `a : α`. -/
theorem tendsto_condCdf_atTop (ρ : Measure (α × ℝ)) (a : α) :
    Tendsto (condCdf ρ a) atTop (𝓝 1) := by
  have h_exists : ∀ x : ℝ, ∃ q : ℚ, x - 1 < q ∧ ↑q < x := fun x => exists_rat_btwn (sub_one_lt x)
  let qs : ℝ → ℚ := fun x => (h_exists x).choose
  have hqs_tendsto : Tendsto qs atTop atTop := by
    rw [tendsto_atTop_atTop]
    refine' fun q => ⟨q + 1, fun y hy => _⟩
    

Proof state:
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
ρ : Measure (α × ℝ)
a : α
h_exists : ∀ (x : ℝ), ∃ q, x - 1 < ↑q ∧ ↑q < x
qs : ℝ → ℚ := fun x => Exists.choose (_ : ∃ q, x - 1 < ↑q ∧ ↑q < x)
q : ℚ
y : ℝ
hy : ↑q + 1 ≤ y
⊢ q ≤ qs y

Next tactic:
have h_le : y - 1 ≤ qs y := (h_exists y).choose_spec.1.le
/-- The conditional cdf tends to 1 at +∞ for all `a : α`. -/
theorem tendsto_condCdf_atTop (ρ : Measure (α × ℝ)) (a : α) :
    Tendsto (condCdf ρ a) atTop (𝓝 1) := by
  have h_exists : ∀ x : ℝ, ∃ q : ℚ, x - 1 < q ∧ ↑q < x := fun x => exists_rat_btwn (sub_one_lt x)
  let qs : ℝ → ℚ := fun x => (h_exists x).choose
  have hqs_tendsto : Tendsto qs atTop atTop := by
    rw [tendsto_atTop_atTop]
    refine' fun q => ⟨q + 1, fun y hy => _⟩
    have h_le : y - 1 ≤ qs y := (h_exists y).choose_spec.1.le
    

Proof state:
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
ρ : Measure (α × ℝ)
a : α
h_exists : ∀ (x : ℝ), ∃ q, x - 1 < ↑q ∧ ↑q < x
qs : ℝ → ℚ := fun x => Exists.choose (_ : ∃ q, x - 1 < ↑q ∧ ↑q < x)
q : ℚ
y : ℝ
hy : ↑q + 1 ≤ y
h_le : y - 1 ≤ ↑(qs y)
⊢ q ≤ qs y

Next tactic:
rw [sub_le_iff_le_add] at h_le
/-- The conditional cdf tends to 1 at +∞ for all `a : α`. -/
theorem tendsto_condCdf_atTop (ρ : Measure (α × ℝ)) (a : α) :
    Tendsto (condCdf ρ a) atTop (𝓝 1) := by
  have h_exists : ∀ x : ℝ, ∃ q : ℚ, x - 1 < q ∧ ↑q < x := fun x => exists_rat_btwn (sub_one_lt x)
  let qs : ℝ → ℚ := fun x => (h_exists x).choose
  have hqs_tendsto : Tendsto qs atTop atTop := by
    rw [tendsto_atTop_atTop]
    refine' fun q => ⟨q + 1, fun y hy => _⟩
    have h_le : y - 1 ≤ qs y := (h_exists y).choose_spec.1.le
    rw [sub_le_iff_le_add] at h_le
    

Proof state:
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
ρ : Measure (α × ℝ)
a : α
h_exists : ∀ (x : ℝ), ∃ q, x - 1 < ↑q ∧ ↑q < x
qs : ℝ → ℚ := fun x => Exists.choose (_ : ∃ q, x - 1 < ↑q ∧ ↑q < x)
q : ℚ
y : ℝ
hy : ↑q + 1 ≤ y
h_le : y ≤ ↑(qs y) + 1
⊢ q ≤ qs y

Next tactic:
exact_mod_cast le_of_add_le_add_right (hy.trans h_le)
/-- The conditional cdf tends to 1 at +∞ for all `a : α`. -/
theorem tendsto_condCdf_atTop (ρ : Measure (α × ℝ)) (a : α) :
    Tendsto (condCdf ρ a) atTop (𝓝 1) := by
  have h_exists : ∀ x : ℝ, ∃ q : ℚ, x - 1 < q ∧ ↑q < x := fun x => exists_rat_btwn (sub_one_lt x)
  let qs : ℝ → ℚ := fun x => (h_exists x).choose
  have hqs_tendsto : Tendsto qs atTop atTop := by
    rw [tendsto_atTop_atTop]
    refine' fun q => ⟨q + 1, fun y hy => _⟩
    have h_le : y - 1 ≤ qs y := (h_exists y).choose_spec.1.le
    rw [sub_le_iff_le_add] at h_le
    exact_mod_cast le_of_add_le_add_right (hy.trans h_le)
  

Proof state:
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
ρ : Measure (α × ℝ)
a : α
h_exists : ∀ (x : ℝ), ∃ q, x - 1 < ↑q ∧ ↑q < x
qs : ℝ → ℚ := fun x => Exists.choose (_ : ∃ q, x - 1 < ↑q ∧ ↑q < x)
hqs_tendsto : Tendsto qs atTop atTop
⊢ Tendsto (↑(condCdf ρ a)) atTop (𝓝 1)

Next tactic:
refine'
    tendsto_of_tendsto_of_tendsto_of_le_of_le ((tendsto_condCdfRat_atTop ρ a).comp hqs_tendsto)
      tendsto_const_nhds _ (condCdf_le_one ρ a)
/-- The conditional cdf tends to 1 at +∞ for all `a : α`. -/
theorem tendsto_condCdf_atTop (ρ : Measure (α × ℝ)) (a : α) :
    Tendsto (condCdf ρ a) atTop (𝓝 1) := by
  have h_exists : ∀ x : ℝ, ∃ q : ℚ, x - 1 < q ∧ ↑q < x := fun x => exists_rat_btwn (sub_one_lt x)
  let qs : ℝ → ℚ := fun x => (h_exists x).choose
  have hqs_tendsto : Tendsto qs atTop atTop := by
    rw [tendsto_atTop_atTop]
    refine' fun q => ⟨q + 1, fun y hy => _⟩
    have h_le : y - 1 ≤ qs y := (h_exists y).choose_spec.1.le
    rw [sub_le_iff_le_add] at h_le
    exact_mod_cast le_of_add_le_add_right (hy.trans h_le)
  refine'
    tendsto_of_tendsto_of_tendsto_of_le_of_le ((tendsto_condCdfRat_atTop ρ a).comp hqs_tendsto)
      tendsto_const_nhds _ (condCdf_le_one ρ a)
  

Proof state:
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
ρ : Measure (α × ℝ)
a : α
h_exists : ∀ (x : ℝ), ∃ q, x - 1 < ↑q ∧ ↑q < x
qs : ℝ → ℚ := fun x => Exists.choose (_ : ∃ q, x - 1 < ↑q ∧ ↑q < x)
hqs_tendsto : Tendsto qs atTop atTop
⊢ condCdfRat ρ a ∘ qs ≤ ↑(condCdf ρ a)

Next tactic:
intro x
/-- The conditional cdf tends to 1 at +∞ for all `a : α`. -/
theorem tendsto_condCdf_atTop (ρ : Measure (α × ℝ)) (a : α) :
    Tendsto (condCdf ρ a) atTop (𝓝 1) := by
  have h_exists : ∀ x : ℝ, ∃ q : ℚ, x - 1 < q ∧ ↑q < x := fun x => exists_rat_btwn (sub_one_lt x)
  let qs : ℝ → ℚ := fun x => (h_exists x).choose
  have hqs_tendsto : Tendsto qs atTop atTop := by
    rw [tendsto_atTop_atTop]
    refine' fun q => ⟨q + 1, fun y hy => _⟩
    have h_le : y - 1 ≤ qs y := (h_exists y).choose_spec.1.le
    rw [sub_le_iff_le_add] at h_le
    exact_mod_cast le_of_add_le_add_right (hy.trans h_le)
  refine'
    tendsto_of_tendsto_of_tendsto_of_le_of_le ((tendsto_condCdfRat_atTop ρ a).comp hqs_tendsto)
      tendsto_const_nhds _ (condCdf_le_one ρ a)
  intro x
  

Proof state:
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
ρ : Measure (α × ℝ)
a : α
h_exists : ∀ (x : ℝ), ∃ q, x - 1 < ↑q ∧ ↑q < x
qs : ℝ → ℚ := fun x => Exists.choose (_ : ∃ q, x - 1 < ↑q ∧ ↑q < x)
hqs_tendsto : Tendsto qs atTop atTop
x : ℝ
⊢ (condCdfRat ρ a ∘ qs) x ≤ ↑(condCdf ρ a) x

Next tactic:
rw [Function.comp_apply, ← condCdf_eq_condCdfRat]
/-- The conditional cdf tends to 1 at +∞ for all `a : α`. -/
theorem tendsto_condCdf_atTop (ρ : Measure (α × ℝ)) (a : α) :
    Tendsto (condCdf ρ a) atTop (𝓝 1) := by
  have h_exists : ∀ x : ℝ, ∃ q : ℚ, x - 1 < q ∧ ↑q < x := fun x => exists_rat_btwn (sub_one_lt x)
  let qs : ℝ → ℚ := fun x => (h_exists x).choose
  have hqs_tendsto : Tendsto qs atTop atTop := by
    rw [tendsto_atTop_atTop]
    refine' fun q => ⟨q + 1, fun y hy => _⟩
    have h_le : y - 1 ≤ qs y := (h_exists y).choose_spec.1.le
    rw [sub_le_iff_le_add] at h_le
    exact_mod_cast le_of_add_le_add_right (hy.trans h_le)
  refine'
    tendsto_of_tendsto_of_tendsto_of_le_of_le ((tendsto_condCdfRat_atTop ρ a).comp hqs_tendsto)
      tendsto_const_nhds _ (condCdf_le_one ρ a)
  intro x
  rw [Function.comp_apply, ← condCdf_eq_condCdfRat]
  

Proof state:
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
ρ : Measure (α × ℝ)
a : α
h_exists : ∀ (x : ℝ), ∃ q, x - 1 < ↑q ∧ ↑q < x
qs : ℝ → ℚ := fun x => Exists.choose (_ : ∃ q, x - 1 < ↑q ∧ ↑q < x)
hqs_tendsto : Tendsto qs atTop atTop
x : ℝ
⊢ ↑(condCdf ρ a) ↑(qs x) ≤ ↑(condCdf ρ a) x

Next tactic:
exact (condCdf ρ a).mono (le_of_lt (h_exists x).choose_spec.2)
theorem condCdf_ae_eq (ρ : Measure (α × ℝ)) [IsFiniteMeasure ρ] (r : ℚ) :
    (fun a => condCdf ρ a r) =ᵐ[ρ.fst] fun a => (preCdf ρ r a).toReal := by
  

Proof state:
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
ρ : Measure (α × ℝ)
inst✝ : IsFiniteMeasure ρ
r : ℚ
⊢ (fun a => ↑(condCdf ρ a) ↑r) =ᵐ[Measure.fst ρ] fun a => ENNReal.toReal (preCdf ρ r a)

Next tactic:
filter_upwards [mem_condCdfSet_ae ρ] with a ha using
    (condCdf_eq_condCdfRat ρ a r).trans (condCdfRat_of_mem ρ a ha r)