-- Mathlib/Probability/Kernel/Disintegration/MeasurableStieltjes.lean
lemma IsMeasurableRatCDF.tendsto_stieltjesFunction_atBot (a : α) :
    Tendsto (hf.stieltjesFunction a) atBot (𝓝 0)

Proof state:
α : Type u_1
f : α → ℚ → ℝ
inst✝ : MeasurableSpace α
hf : IsMeasurableRatCDF f
a : α
h_exists : ∀ (x : ℝ), ∃ q, x < ↑q ∧ ↑q < x + 1
qs : ℝ → ℚ := fun x => ⋯.choose
q : ℚ
y : ℝ
hy : y ≤ ↑q - 1
h_le : ↑(qs y) ≤ ↑q
⊢ qs y ≤ q

Tactic:
exact mod_cast h_le

Result:
no goals

Proof state:
α : Type u_1
f : α → ℚ → ℝ
inst✝ : MeasurableSpace α
hf : IsMeasurableRatCDF f
a : α
h_exists : ∀ (x : ℝ), ∃ q, x < ↑q ∧ ↑q < x + 1
qs : ℝ → ℚ := fun x => ⋯.choose
hqs_tendsto : Tendsto qs atBot atBot
x : ℝ
⊢ ↑(hf.stieltjesFunction a) x ≤ (f a ∘ qs) x

Tactic:
rw [Function.comp_apply, ← stieltjesFunction_eq hf]

Result:
α : Type u_1
f : α → ℚ → ℝ
inst✝ : MeasurableSpace α
hf : IsMeasurableRatCDF f
a : α
h_exists : ∀ (x : ℝ), ∃ q, x < ↑q ∧ ↑q < x + 1
qs : ℝ → ℚ := fun x => ⋯.choose
hqs_tendsto : Tendsto qs atBot atBot
x : ℝ
⊢ ↑(hf.stieltjesFunction a) x ≤ ↑(hf.stieltjesFunction a) ↑(qs x)

Proof state:
α : Type u_1
f : α → ℚ → ℝ
inst✝ : MeasurableSpace α
hf : IsMeasurableRatCDF f
a : α
h_exists : ∀ (x : ℝ), ∃ q, x < ↑q ∧ ↑q < x + 1
qs : ℝ → ℚ := fun x => ⋯.choose
⊢ Tendsto qs atBot atBot

Tactic:
rw [tendsto_atBot_atBot]

Result:
α : Type u_1
f : α → ℚ → ℝ
inst✝ : MeasurableSpace α
hf : IsMeasurableRatCDF f
a : α
h_exists : ∀ (x : ℝ), ∃ q, x < ↑q ∧ ↑q < x + 1
qs : ℝ → ℚ := fun x => ⋯.choose
⊢ ∀ (b : ℚ), ∃ i, ∀ a ≤ i, qs a ≤ b

Proof state:
α : Type u_1
f : α → ℚ → ℝ
inst✝ : MeasurableSpace α
hf : IsMeasurableRatCDF f
a : α
h_exists : ∀ (x : ℝ), ∃ q, x < ↑q ∧ ↑q < x + 1
qs : ℝ → ℚ := fun x => ⋯.choose
⊢ Tendsto (↑(hf.stieltjesFunction a)) atBot (𝓝 0)

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

Result:
α : Type u_1
f : α → ℚ → ℝ
inst✝ : MeasurableSpace α
hf : IsMeasurableRatCDF f
a : α
h_exists : ∀ (x : ℝ), ∃ q, x < ↑q ∧ ↑q < x + 1
qs : ℝ → ℚ := fun x => ⋯.choose
hqs_tendsto : Tendsto qs atBot atBot
⊢ Tendsto (↑(hf.stieltjesFunction a)) atBot (𝓝 0)

Proof state:
α : Type u_1
f : α → ℚ → ℝ
inst✝ : MeasurableSpace α
hf : IsMeasurableRatCDF f
a : α
⊢ Tendsto (↑(hf.stieltjesFunction a)) atBot (𝓝 0)

Tactic:
have h_exists : ∀ x : ℝ, ∃ q : ℚ, x < q ∧ ↑q < x + 1 := fun x ↦ exists_rat_btwn (lt_add_one x)

Result:
α : Type u_1
f : α → ℚ → ℝ
inst✝ : MeasurableSpace α
hf : IsMeasurableRatCDF f
a : α
h_exists : ∀ (x : ℝ), ∃ q, x < ↑q ∧ ↑q < x + 1
⊢ Tendsto (↑(hf.stieltjesFunction a)) atBot (𝓝 0)

Proof state:
α : Type u_1
f : α → ℚ → ℝ
inst✝ : MeasurableSpace α
hf : IsMeasurableRatCDF f
a : α
h_exists : ∀ (x : ℝ), ∃ q, x < ↑q ∧ ↑q < x + 1
⊢ Tendsto (↑(hf.stieltjesFunction a)) atBot (𝓝 0)

Tactic:
let qs : ℝ → ℚ := fun x ↦ (h_exists x).choose

Result:
α : Type u_1
f : α → ℚ → ℝ
inst✝ : MeasurableSpace α
hf : IsMeasurableRatCDF f
a : α
h_exists : ∀ (x : ℝ), ∃ q, x < ↑q ∧ ↑q < x + 1
qs : ℝ → ℚ := fun x => ⋯.choose
⊢ Tendsto (↑(hf.stieltjesFunction a)) atBot (𝓝 0)

Proof state:
α : Type u_1
f : α → ℚ → ℝ
inst✝ : MeasurableSpace α
hf : IsMeasurableRatCDF f
a : α
h_exists : ∀ (x : ℝ), ∃ q, x < ↑q ∧ ↑q < x + 1
qs : ℝ → ℚ := fun x => ⋯.choose
hqs_tendsto : Tendsto qs atBot atBot
x : ℝ
⊢ ↑(hf.stieltjesFunction a) x ≤ ↑(hf.stieltjesFunction a) ↑(qs x)

Tactic:
exact (hf.stieltjesFunction a).mono (h_exists x).choose_spec.1.le

Result:
no goals

Proof state:
α : Type u_1
f : α → ℚ → ℝ
inst✝ : MeasurableSpace α
hf : IsMeasurableRatCDF f
a : α
h_exists : ∀ (x : ℝ), ∃ q, x < ↑q ∧ ↑q < x + 1
qs : ℝ → ℚ := fun x => ⋯.choose
⊢ ∀ (b : ℚ), ∃ i, ∀ a ≤ i, qs a ≤ b

Tactic:
refine fun q ↦ ⟨q - 1, fun y hy ↦ ?_⟩

Result:
α : Type u_1
f : α → ℚ → ℝ
inst✝ : MeasurableSpace α
hf : IsMeasurableRatCDF f
a : α
h_exists : ∀ (x : ℝ), ∃ q, x < ↑q ∧ ↑q < x + 1
qs : ℝ → ℚ := fun x => ⋯.choose
q : ℚ
y : ℝ
hy : y ≤ ↑q - 1
⊢ qs y ≤ q

Proof state:
α : Type u_1
f : α → ℚ → ℝ
inst✝ : MeasurableSpace α
hf : IsMeasurableRatCDF f
a : α
h_exists : ∀ (x : ℝ), ∃ q, x < ↑q ∧ ↑q < x + 1
qs : ℝ → ℚ := fun x => ⋯.choose
q : ℚ
y : ℝ
hy : y ≤ ↑q - 1
⊢ qs y ≤ q

Tactic:
have h_le : ↑(qs y) ≤ (q : ℝ) - 1 + 1 :=
  (h_exists y).choose_spec.2.le.trans (add_le_add hy le_rfl)

Result:
α : Type u_1
f : α → ℚ → ℝ
inst✝ : MeasurableSpace α
hf : IsMeasurableRatCDF f
a : α
h_exists : ∀ (x : ℝ), ∃ q, x < ↑q ∧ ↑q < x + 1
qs : ℝ → ℚ := fun x => ⋯.choose
q : ℚ
y : ℝ
hy : y ≤ ↑q - 1
h_le : ↑(qs y) ≤ ↑q - 1 + 1
⊢ qs y ≤ q

Proof state:
α : Type u_1
f : α → ℚ → ℝ
inst✝ : MeasurableSpace α
hf : IsMeasurableRatCDF f
a : α
h_exists : ∀ (x : ℝ), ∃ q, x < ↑q ∧ ↑q < x + 1
qs : ℝ → ℚ := fun x => ⋯.choose
q : ℚ
y : ℝ
hy : y ≤ ↑q - 1
h_le : ↑(qs y) ≤ ↑q - 1 + 1
⊢ qs y ≤ q

Tactic:
rw [sub_add_cancel] at h_le

Result:
α : Type u_1
f : α → ℚ → ℝ
inst✝ : MeasurableSpace α
hf : IsMeasurableRatCDF f
a : α
h_exists : ∀ (x : ℝ), ∃ q, x < ↑q ∧ ↑q < x + 1
qs : ℝ → ℚ := fun x => ⋯.choose
q : ℚ
y : ℝ
hy : y ≤ ↑q - 1
h_le : ↑(qs y) ≤ ↑q
⊢ qs y ≤ q

Proof state:
α : Type u_1
f : α → ℚ → ℝ
inst✝ : MeasurableSpace α
hf : IsMeasurableRatCDF f
a : α
h_exists : ∀ (x : ℝ), ∃ q, x < ↑q ∧ ↑q < x + 1
qs : ℝ → ℚ := fun x => ⋯.choose
hqs_tendsto : Tendsto qs atBot atBot
⊢ Tendsto (↑(hf.stieltjesFunction a)) atBot (𝓝 0)

Tactic:
refine tendsto_of_tendsto_of_tendsto_of_le_of_le tendsto_const_nhds
  ((hf.tendsto_atBot_zero a).comp hqs_tendsto) (stieltjesFunction_nonneg hf a) fun x ↦ ?_

Result:
α : Type u_1
f : α → ℚ → ℝ
inst✝ : MeasurableSpace α
hf : IsMeasurableRatCDF f
a : α
h_exists : ∀ (x : ℝ), ∃ q, x < ↑q ∧ ↑q < x + 1
qs : ℝ → ℚ := fun x => ⋯.choose
hqs_tendsto : Tendsto qs atBot atBot
x : ℝ
⊢ ↑(hf.stieltjesFunction a) x ≤ (f a ∘ qs) x