l3lab/ntp-mathlib huggingface dataset:
/-- An auxiliary lemma that can be used to prove that coercion `Mˣ → M` is a topological embedding.
Use `Units.embedding_val₀`, `Units.embedding_val`, or `toUnits_homeomorph` instead. -/
@[to_additive "An auxiliary lemma that can be used to prove that coercion `AddUnits M → M` is a
topological embedding. Use `AddUnits.embedding_val` or `toAddUnits_homeomorph` instead."]
lemma embedding_val_mk' {M : Type*} [Monoid M] [TopologicalSpace M] {f : M → M}
    (hc : ContinuousOn f {x : M | IsUnit x}) (hf : ∀ u : Mˣ, f u.1 = ↑u⁻¹) :
    Embedding (val : Mˣ → M) := by
  

Proof state:
M✝ : Type u_1
X : Type u_2
inst✝⁴ : TopologicalSpace M✝
inst✝³ : Monoid M✝
inst✝² : TopologicalSpace X
M : Type u_3
inst✝¹ : Monoid M
inst✝ : TopologicalSpace M
f : M → M
hc : ContinuousOn f {x | IsUnit x}
hf : ∀ (u : Mˣ), f ↑u = ↑u⁻¹
⊢ Embedding val

Next tactic:
refine ⟨⟨?_⟩, ext⟩
/-- An auxiliary lemma that can be used to prove that coercion `Mˣ → M` is a topological embedding.
Use `Units.embedding_val₀`, `Units.embedding_val`, or `toUnits_homeomorph` instead. -/
@[to_additive "An auxiliary lemma that can be used to prove that coercion `AddUnits M → M` is a
topological embedding. Use `AddUnits.embedding_val` or `toAddUnits_homeomorph` instead."]
lemma embedding_val_mk' {M : Type*} [Monoid M] [TopologicalSpace M] {f : M → M}
    (hc : ContinuousOn f {x : M | IsUnit x}) (hf : ∀ u : Mˣ, f u.1 = ↑u⁻¹) :
    Embedding (val : Mˣ → M) := by
  refine ⟨⟨?_⟩, ext⟩
  

Proof state:
M✝ : Type u_1
X : Type u_2
inst✝⁴ : TopologicalSpace M✝
inst✝³ : Monoid M✝
inst✝² : TopologicalSpace X
M : Type u_3
inst✝¹ : Monoid M
inst✝ : TopologicalSpace M
f : M → M
hc : ContinuousOn f {x | IsUnit x}
hf : ∀ (u : Mˣ), f ↑u = ↑u⁻¹
⊢ instTopologicalSpaceUnits = TopologicalSpace.induced val inst✝

Next tactic:
rw [topology_eq_inf, inf_eq_left, ← continuous_iff_le_induced,
    @continuous_iff_continuousAt _ _ (.induced _ _)]
/-- An auxiliary lemma that can be used to prove that coercion `Mˣ → M` is a topological embedding.
Use `Units.embedding_val₀`, `Units.embedding_val`, or `toUnits_homeomorph` instead. -/
@[to_additive "An auxiliary lemma that can be used to prove that coercion `AddUnits M → M` is a
topological embedding. Use `AddUnits.embedding_val` or `toAddUnits_homeomorph` instead."]
lemma embedding_val_mk' {M : Type*} [Monoid M] [TopologicalSpace M] {f : M → M}
    (hc : ContinuousOn f {x : M | IsUnit x}) (hf : ∀ u : Mˣ, f u.1 = ↑u⁻¹) :
    Embedding (val : Mˣ → M) := by
  refine ⟨⟨?_⟩, ext⟩
  rw [topology_eq_inf, inf_eq_left, ← continuous_iff_le_induced,
    @continuous_iff_continuousAt _ _ (.induced _ _)]
  

Proof state:
M✝ : Type u_1
X : Type u_2
inst✝⁴ : TopologicalSpace M✝
inst✝³ : Monoid M✝
inst✝² : TopologicalSpace X
M : Type u_3
inst✝¹ : Monoid M
inst✝ : TopologicalSpace M
f : M → M
hc : ContinuousOn f {x | IsUnit x}
hf : ∀ (u : Mˣ), f ↑u = ↑u⁻¹
⊢ ∀ (x : Mˣ), ContinuousAt (fun u => ↑u⁻¹) x

Next tactic:
intros u s hs
/-- An auxiliary lemma that can be used to prove that coercion `Mˣ → M` is a topological embedding.
Use `Units.embedding_val₀`, `Units.embedding_val`, or `toUnits_homeomorph` instead. -/
@[to_additive "An auxiliary lemma that can be used to prove that coercion `AddUnits M → M` is a
topological embedding. Use `AddUnits.embedding_val` or `toAddUnits_homeomorph` instead."]
lemma embedding_val_mk' {M : Type*} [Monoid M] [TopologicalSpace M] {f : M → M}
    (hc : ContinuousOn f {x : M | IsUnit x}) (hf : ∀ u : Mˣ, f u.1 = ↑u⁻¹) :
    Embedding (val : Mˣ → M) := by
  refine ⟨⟨?_⟩, ext⟩
  rw [topology_eq_inf, inf_eq_left, ← continuous_iff_le_induced,
    @continuous_iff_continuousAt _ _ (.induced _ _)]
  intros u s hs
  

Proof state:
M✝ : Type u_1
X : Type u_2
inst✝⁴ : TopologicalSpace M✝
inst✝³ : Monoid M✝
inst✝² : TopologicalSpace X
M : Type u_3
inst✝¹ : Monoid M
inst✝ : TopologicalSpace M
f : M → M
hc : ContinuousOn f {x | IsUnit x}
hf : ∀ (u : Mˣ), f ↑u = ↑u⁻¹
u : Mˣ
s : Set M
hs : s ∈ 𝓝 ((fun u => ↑u⁻¹) u)
⊢ s ∈ Filter.map (fun u => ↑u⁻¹) (𝓝 u)

Next tactic:
simp only [← hf, nhds_induced, Filter.mem_map] at hs ⊢
/-- An auxiliary lemma that can be used to prove that coercion `Mˣ → M` is a topological embedding.
Use `Units.embedding_val₀`, `Units.embedding_val`, or `toUnits_homeomorph` instead. -/
@[to_additive "An auxiliary lemma that can be used to prove that coercion `AddUnits M → M` is a
topological embedding. Use `AddUnits.embedding_val` or `toAddUnits_homeomorph` instead."]
lemma embedding_val_mk' {M : Type*} [Monoid M] [TopologicalSpace M] {f : M → M}
    (hc : ContinuousOn f {x : M | IsUnit x}) (hf : ∀ u : Mˣ, f u.1 = ↑u⁻¹) :
    Embedding (val : Mˣ → M) := by
  refine ⟨⟨?_⟩, ext⟩
  rw [topology_eq_inf, inf_eq_left, ← continuous_iff_le_induced,
    @continuous_iff_continuousAt _ _ (.induced _ _)]
  intros u s hs
  simp only [← hf, nhds_induced, Filter.mem_map] at hs ⊢
  

Proof state:
M✝ : Type u_1
X : Type u_2
inst✝⁴ : TopologicalSpace M✝
inst✝³ : Monoid M✝
inst✝² : TopologicalSpace X
M : Type u_3
inst✝¹ : Monoid M
inst✝ : TopologicalSpace M
f : M → M
hc : ContinuousOn f {x | IsUnit x}
hf : ∀ (u : Mˣ), f ↑u = ↑u⁻¹
u : Mˣ
s : Set M
hs : s ∈ 𝓝 (f ↑u)
⊢ (fun u => f ↑u) ⁻¹' s ∈ comap val (𝓝 ↑u)

Next tactic:
exact ⟨_, mem_inf_principal.1 (hc u u.isUnit hs), fun u' hu' ↦ hu' u'.isUnit⟩
@[to_additive]
protected theorem continuous_iff {f : X → Mˣ} :
    Continuous f ↔ Continuous (val ∘ f) ∧ Continuous (fun x => ↑(f x)⁻¹ : X → M) := by
  

Proof state:
M : Type u_1
X : Type u_2
inst✝² : TopologicalSpace M
inst✝¹ : Monoid M
inst✝ : TopologicalSpace X
f : X → Mˣ
⊢ Continuous f ↔ Continuous (val ∘ f) ∧ Continuous fun x => ↑(f x)⁻¹

Next tactic:
simp only [inducing_embedProduct.continuous_iff, embedProduct_apply, (· ∘ ·),
    continuous_prod_mk, opHomeomorph.symm.inducing.continuous_iff, opHomeomorph_symm_apply,
    unop_op]
lemma dist_r_b' : ∀ᶠ n in atTop, ∀ i, ‖(r i n : ℝ) - b i * n‖ ≤ n / log n ^ 2 := by
  

Proof state:
α : Type u_1
inst✝¹ : Fintype α
inst✝ : Nonempty α
T : ℕ → ℝ
g : ℝ → ℝ
a b : α → ℝ
r : α → ℕ → ℕ
R : AkraBazziRecurrence T g a b r
⊢ ∀ᶠ (n : ℕ) in atTop, ∀ (i : α), ‖↑(r i n) - b i * ↑n‖ ≤ ↑n / log ↑n ^ 2

Next tactic:
rw [Filter.eventually_all]
lemma dist_r_b' : ∀ᶠ n in atTop, ∀ i, ‖(r i n : ℝ) - b i * n‖ ≤ n / log n ^ 2 := by
  rw [Filter.eventually_all]
  

Proof state:
α : Type u_1
inst✝¹ : Fintype α
inst✝ : Nonempty α
T : ℕ → ℝ
g : ℝ → ℝ
a b : α → ℝ
r : α → ℕ → ℕ
R : AkraBazziRecurrence T g a b r
⊢ ∀ (i : α), ∀ᶠ (x : ℕ) in atTop, ‖↑(r i x) - b i * ↑x‖ ≤ ↑x / log ↑x ^ 2

Next tactic:
intro i
lemma dist_r_b' : ∀ᶠ n in atTop, ∀ i, ‖(r i n : ℝ) - b i * n‖ ≤ n / log n ^ 2 := by
  rw [Filter.eventually_all]
  intro i
  

Proof state:
α : Type u_1
inst✝¹ : Fintype α
inst✝ : Nonempty α
T : ℕ → ℝ
g : ℝ → ℝ
a b : α → ℝ
r : α → ℕ → ℕ
R : AkraBazziRecurrence T g a b r
i : α
⊢ ∀ᶠ (x : ℕ) in atTop, ‖↑(r i x) - b i * ↑x‖ ≤ ↑x / log ↑x ^ 2

Next tactic:
simpa using IsLittleO.eventuallyLE (R.dist_r_b i)
lemma isLittleO_self_div_log_id : (fun (n:ℕ) => n / log n ^ 2) =o[atTop] (fun (n:ℕ) => (n:ℝ)) := by
  

Proof state:
α : Type u_1
inst✝¹ : Fintype α
inst✝ : Nonempty α
T : ℕ → ℝ
g : ℝ → ℝ
a b : α → ℝ
r : α → ℕ → ℕ
R : AkraBazziRecurrence T g a b r
⊢ (fun n => ↑n / log ↑n ^ 2) =o[atTop] fun n => ↑n

Next tactic:
calc (fun (n:ℕ) => (n:ℝ) / log n ^ 2) = fun (n:ℕ) => (n:ℝ) * ((log n) ^ 2)⁻¹ := by
                  simp_rw [div_eq_mul_inv]
         _ =o[atTop] fun (n:ℕ) => (n:ℝ) * 1⁻¹    := by
                  refine IsBigO.mul_isLittleO (isBigO_refl _ _) ?_
                  refine IsLittleO.inv_rev ?main ?zero
                  case zero => simp
                  case main => calc
                    _ = (fun (_:ℕ) => ((1:ℝ) ^ 2))        := by simp
                    _ =o[atTop] (fun (n:ℕ) => (log n)^2)  :=
                          IsLittleO.pow (IsLittleO.nat_cast_atTop
                            <| isLittleO_const_log_atTop) (by norm_num)
         _ = (fun (n:ℕ) => (n:ℝ)) := by ext; simp
lemma isLittleO_self_div_log_id : (fun (n:ℕ) => n / log n ^ 2) =o[atTop] (fun (n:ℕ) => (n:ℝ)) := by
  calc (fun (n:ℕ) => (n:ℝ) / log n ^ 2) = fun (n:ℕ) => (n:ℝ) * ((log n) ^ 2)⁻¹ := by
                  

Proof state:
α : Type u_1
inst✝¹ : Fintype α
inst✝ : Nonempty α
T : ℕ → ℝ
g : ℝ → ℝ
a b : α → ℝ
r : α → ℕ → ℕ
R : AkraBazziRecurrence T g a b r
⊢ (fun n => ↑n / log ↑n ^ 2) = fun n => ↑n * (log ↑n ^ 2)⁻¹

Next tactic:
simp_rw [div_eq_mul_inv]
lemma isLittleO_self_div_log_id : (fun (n:ℕ) => n / log n ^ 2) =o[atTop] (fun (n:ℕ) => (n:ℝ)) := by
  calc (fun (n:ℕ) => (n:ℝ) / log n ^ 2) = fun (n:ℕ) => (n:ℝ) * ((log n) ^ 2)⁻¹ := by
                  simp_rw [div_eq_mul_inv]
         _ =o[atTop] fun (n:ℕ) => (n:ℝ) * 1⁻¹    := by
                  

Proof state:
α : Type u_1
inst✝¹ : Fintype α
inst✝ : Nonempty α
T : ℕ → ℝ
g : ℝ → ℝ
a b : α → ℝ
r : α → ℕ → ℕ
R : AkraBazziRecurrence T g a b r
⊢ (fun n => ↑n * (log ↑n ^ 2)⁻¹) =o[atTop] fun n => ↑n * 1⁻¹

Next tactic:
refine IsBigO.mul_isLittleO (isBigO_refl _ _) ?_
lemma isLittleO_self_div_log_id : (fun (n:ℕ) => n / log n ^ 2) =o[atTop] (fun (n:ℕ) => (n:ℝ)) := by
  calc (fun (n:ℕ) => (n:ℝ) / log n ^ 2) = fun (n:ℕ) => (n:ℝ) * ((log n) ^ 2)⁻¹ := by
                  simp_rw [div_eq_mul_inv]
         _ =o[atTop] fun (n:ℕ) => (n:ℝ) * 1⁻¹    := by
                  refine IsBigO.mul_isLittleO (isBigO_refl _ _) ?_
                  

Proof state:
α : Type u_1
inst✝¹ : Fintype α
inst✝ : Nonempty α
T : ℕ → ℝ
g : ℝ → ℝ
a b : α → ℝ
r : α → ℕ → ℕ
R : AkraBazziRecurrence T g a b r
⊢ (fun n => (log ↑n ^ 2)⁻¹) =o[atTop] fun n => 1⁻¹

Next tactic:
refine IsLittleO.inv_rev ?main ?zero
lemma isLittleO_self_div_log_id : (fun (n:ℕ) => n / log n ^ 2) =o[atTop] (fun (n:ℕ) => (n:ℝ)) := by
  calc (fun (n:ℕ) => (n:ℝ) / log n ^ 2) = fun (n:ℕ) => (n:ℝ) * ((log n) ^ 2)⁻¹ := by
                  simp_rw [div_eq_mul_inv]
         _ =o[atTop] fun (n:ℕ) => (n:ℝ) * 1⁻¹    := by
                  refine IsBigO.mul_isLittleO (isBigO_refl _ _) ?_
                  refine IsLittleO.inv_rev ?main ?zero
                  

Proof state:
case main
α : Type u_1
inst✝¹ : Fintype α
inst✝ : Nonempty α
T : ℕ → ℝ
g : ℝ → ℝ
a b : α → ℝ
r : α → ℕ → ℕ
R : AkraBazziRecurrence T g a b r
⊢ (fun n => 1) =o[atTop] fun n => log ↑n ^ 2
case zero
α : Type u_1
inst✝¹ : Fintype α
inst✝ : Nonempty α
T : ℕ → ℝ
g : ℝ → ℝ
a b : α → ℝ
r : α → ℕ → ℕ
R : AkraBazziRecurrence T g a b r
⊢ ∀ᶠ (x : ℕ) in atTop, 1 = 0 → log ↑x ^ 2 = 0

Next tactic:
case zero => simp
lemma isLittleO_self_div_log_id : (fun (n:ℕ) => n / log n ^ 2) =o[atTop] (fun (n:ℕ) => (n:ℝ)) := by
  calc (fun (n:ℕ) => (n:ℝ) / log n ^ 2) = fun (n:ℕ) => (n:ℝ) * ((log n) ^ 2)⁻¹ := by
                  simp_rw [div_eq_mul_inv]
         _ =o[atTop] fun (n:ℕ) => (n:ℝ) * 1⁻¹    := by
                  refine IsBigO.mul_isLittleO (isBigO_refl _ _) ?_
                  refine IsLittleO.inv_rev ?main ?zero
                  

Proof state:
α : Type u_1
inst✝¹ : Fintype α
inst✝ : Nonempty α
T : ℕ → ℝ
g : ℝ → ℝ
a b : α → ℝ
r : α → ℕ → ℕ
R : AkraBazziRecurrence T g a b r
⊢ ∀ᶠ (x : ℕ) in atTop, 1 = 0 → log ↑x ^ 2 = 0

Next tactic:
case zero => simp
lemma isLittleO_self_div_log_id : (fun (n:ℕ) => n / log n ^ 2) =o[atTop] (fun (n:ℕ) => (n:ℝ)) := by
  calc (fun (n:ℕ) => (n:ℝ) / log n ^ 2) = fun (n:ℕ) => (n:ℝ) * ((log n) ^ 2)⁻¹ := by
                  simp_rw [div_eq_mul_inv]
         _ =o[atTop] fun (n:ℕ) => (n:ℝ) * 1⁻¹    := by
                  refine IsBigO.mul_isLittleO (isBigO_refl _ _) ?_
                  refine IsLittleO.inv_rev ?main ?zero
                  case zero => 

Proof state:
α : Type u_1
inst✝¹ : Fintype α
inst✝ : Nonempty α
T : ℕ → ℝ
g : ℝ → ℝ
a b : α → ℝ
r : α → ℕ → ℕ
R : AkraBazziRecurrence T g a b r
⊢ ∀ᶠ (x : ℕ) in atTop, 1 = 0 → log ↑x ^ 2 = 0

Next tactic:
simp
lemma isLittleO_self_div_log_id : (fun (n:ℕ) => n / log n ^ 2) =o[atTop] (fun (n:ℕ) => (n:ℝ)) := by
  calc (fun (n:ℕ) => (n:ℝ) / log n ^ 2) = fun (n:ℕ) => (n:ℝ) * ((log n) ^ 2)⁻¹ := by
                  simp_rw [div_eq_mul_inv]
         _ =o[atTop] fun (n:ℕ) => (n:ℝ) * 1⁻¹    := by
                  refine IsBigO.mul_isLittleO (isBigO_refl _ _) ?_
                  refine IsLittleO.inv_rev ?main ?zero
                  case zero => simp
                  

Proof state:
case main
α : Type u_1
inst✝¹ : Fintype α
inst✝ : Nonempty α
T : ℕ → ℝ
g : ℝ → ℝ
a b : α → ℝ
r : α → ℕ → ℕ
R : AkraBazziRecurrence T g a b r
⊢ (fun n => 1) =o[atTop] fun n => log ↑n ^ 2

Next tactic:
case main => calc
                    _ = (fun (_:ℕ) => ((1:ℝ) ^ 2))        := by simp
                    _ =o[atTop] (fun (n:ℕ) => (log n)^2)  :=
                          IsLittleO.pow (IsLittleO.nat_cast_atTop
                            <| isLittleO_const_log_atTop) (by norm_num)
lemma isLittleO_self_div_log_id : (fun (n:ℕ) => n / log n ^ 2) =o[atTop] (fun (n:ℕ) => (n:ℝ)) := by
  calc (fun (n:ℕ) => (n:ℝ) / log n ^ 2) = fun (n:ℕ) => (n:ℝ) * ((log n) ^ 2)⁻¹ := by
                  simp_rw [div_eq_mul_inv]
         _ =o[atTop] fun (n:ℕ) => (n:ℝ) * 1⁻¹    := by
                  refine IsBigO.mul_isLittleO (isBigO_refl _ _) ?_
                  refine IsLittleO.inv_rev ?main ?zero
                  case zero => simp
                  

Proof state:
α : Type u_1
inst✝¹ : Fintype α
inst✝ : Nonempty α
T : ℕ → ℝ
g : ℝ → ℝ
a b : α → ℝ
r : α → ℕ → ℕ
R : AkraBazziRecurrence T g a b r
⊢ (fun n => 1) =o[atTop] fun n => log ↑n ^ 2

Next tactic:
case main => calc
                    _ = (fun (_:ℕ) => ((1:ℝ) ^ 2))        := by simp
                    _ =o[atTop] (fun (n:ℕ) => (log n)^2)  :=
                          IsLittleO.pow (IsLittleO.nat_cast_atTop
                            <| isLittleO_const_log_atTop) (by norm_num)
lemma isLittleO_self_div_log_id : (fun (n:ℕ) => n / log n ^ 2) =o[atTop] (fun (n:ℕ) => (n:ℝ)) := by
  calc (fun (n:ℕ) => (n:ℝ) / log n ^ 2) = fun (n:ℕ) => (n:ℝ) * ((log n) ^ 2)⁻¹ := by
                  simp_rw [div_eq_mul_inv]
         _ =o[atTop] fun (n:ℕ) => (n:ℝ) * 1⁻¹    := by
                  refine IsBigO.mul_isLittleO (isBigO_refl _ _) ?_
                  refine IsLittleO.inv_rev ?main ?zero
                  case zero => simp
                  case main => 

Proof state:
α : Type u_1
inst✝¹ : Fintype α
inst✝ : Nonempty α
T : ℕ → ℝ
g : ℝ → ℝ
a b : α → ℝ
r : α → ℕ → ℕ
R : AkraBazziRecurrence T g a b r
⊢ (fun n => 1) =o[atTop] fun n => log ↑n ^ 2

Next tactic:
calc
                    _ = (fun (_:ℕ) => ((1:ℝ) ^ 2))        := by simp
                    _ =o[atTop] (fun (n:ℕ) => (log n)^2)  :=
                          IsLittleO.pow (IsLittleO.nat_cast_atTop
                            <| isLittleO_const_log_atTop) (by norm_num)
lemma isLittleO_self_div_log_id : (fun (n:ℕ) => n / log n ^ 2) =o[atTop] (fun (n:ℕ) => (n:ℝ)) := by
  calc (fun (n:ℕ) => (n:ℝ) / log n ^ 2) = fun (n:ℕ) => (n:ℝ) * ((log n) ^ 2)⁻¹ := by
                  simp_rw [div_eq_mul_inv]
         _ =o[atTop] fun (n:ℕ) => (n:ℝ) * 1⁻¹    := by
                  refine IsBigO.mul_isLittleO (isBigO_refl _ _) ?_
                  refine IsLittleO.inv_rev ?main ?zero
                  case zero => simp
                  case main => calc
                    _ = (fun (_:ℕ) => ((1:ℝ) ^ 2))        := by 

Proof state:
α : Type u_1
inst✝¹ : Fintype α
inst✝ : Nonempty α
T : ℕ → ℝ
g : ℝ → ℝ
a b : α → ℝ
r : α → ℕ → ℕ
R : AkraBazziRecurrence T g a b r
⊢ (fun n => 1) = fun x => 1 ^ 2

Next tactic:
simp
lemma isLittleO_self_div_log_id : (fun (n:ℕ) => n / log n ^ 2) =o[atTop] (fun (n:ℕ) => (n:ℝ)) := by
  calc (fun (n:ℕ) => (n:ℝ) / log n ^ 2) = fun (n:ℕ) => (n:ℝ) * ((log n) ^ 2)⁻¹ := by
                  simp_rw [div_eq_mul_inv]
         _ =o[atTop] fun (n:ℕ) => (n:ℝ) * 1⁻¹    := by
                  refine IsBigO.mul_isLittleO (isBigO_refl _ _) ?_
                  refine IsLittleO.inv_rev ?main ?zero
                  case zero => simp
                  case main => calc
                    _ = (fun (_:ℕ) => ((1:ℝ) ^ 2))        := by simp
                    _ =o[atTop] (fun (n:ℕ) => (log n)^2)  :=
                          IsLittleO.pow (IsLittleO.nat_cast_atTop
                            <| isLittleO_const_log_atTop) (by 

Proof state:
α : Type u_1
inst✝¹ : Fintype α
inst✝ : Nonempty α
T : ℕ → ℝ
g : ℝ → ℝ
a b : α → ℝ
r : α → ℕ → ℕ
R : AkraBazziRecurrence T g a b r
⊢ 0 < 2

Next tactic:
norm_num
lemma isLittleO_self_div_log_id : (fun (n:ℕ) => n / log n ^ 2) =o[atTop] (fun (n:ℕ) => (n:ℝ)) := by
  calc (fun (n:ℕ) => (n:ℝ) / log n ^ 2) = fun (n:ℕ) => (n:ℝ) * ((log n) ^ 2)⁻¹ := by
                  simp_rw [div_eq_mul_inv]
         _ =o[atTop] fun (n:ℕ) => (n:ℝ) * 1⁻¹    := by
                  refine IsBigO.mul_isLittleO (isBigO_refl _ _) ?_
                  refine IsLittleO.inv_rev ?main ?zero
                  case zero => simp
                  case main => calc
                    _ = (fun (_:ℕ) => ((1:ℝ) ^ 2))        := by simp
                    _ =o[atTop] (fun (n:ℕ) => (log n)^2)  :=
                          IsLittleO.pow (IsLittleO.nat_cast_atTop
                            <| isLittleO_const_log_atTop) (by norm_num)
         _ = (fun (n:ℕ) => (n:ℝ)) := by 

Proof state:
α : Type u_1
inst✝¹ : Fintype α
inst✝ : Nonempty α
T : ℕ → ℝ
g : ℝ → ℝ
a b : α → ℝ
r : α → ℕ → ℕ
R : AkraBazziRecurrence T g a b r
⊢ (fun n => ↑n * 1⁻¹) = fun n => ↑n

Next tactic:
ext
lemma isLittleO_self_div_log_id : (fun (n:ℕ) => n / log n ^ 2) =o[atTop] (fun (n:ℕ) => (n:ℝ)) := by
  calc (fun (n:ℕ) => (n:ℝ) / log n ^ 2) = fun (n:ℕ) => (n:ℝ) * ((log n) ^ 2)⁻¹ := by
                  simp_rw [div_eq_mul_inv]
         _ =o[atTop] fun (n:ℕ) => (n:ℝ) * 1⁻¹    := by
                  refine IsBigO.mul_isLittleO (isBigO_refl _ _) ?_
                  refine IsLittleO.inv_rev ?main ?zero
                  case zero => simp
                  case main => calc
                    _ = (fun (_:ℕ) => ((1:ℝ) ^ 2))        := by simp
                    _ =o[atTop] (fun (n:ℕ) => (log n)^2)  :=
                          IsLittleO.pow (IsLittleO.nat_cast_atTop
                            <| isLittleO_const_log_atTop) (by norm_num)
         _ = (fun (n:ℕ) => (n:ℝ)) := by ext; 

Proof state:
case h
α : Type u_1
inst✝¹ : Fintype α
inst✝ : Nonempty α
T : ℕ → ℝ
g : ℝ → ℝ
a b : α → ℝ
r : α → ℕ → ℕ
R : AkraBazziRecurrence T g a b r
x✝ : ℕ
⊢ ↑x✝ * 1⁻¹ = ↑x✝

Next tactic:
simp
lemma eventually_b_le_r : ∀ᶠ (n:ℕ) in atTop, ∀ i, (b i : ℝ) * n - (n / log n ^ 2) ≤ r i n := by
  

Proof state:
α : Type u_1
inst✝¹ : Fintype α
inst✝ : Nonempty α
T : ℕ → ℝ
g : ℝ → ℝ
a b : α → ℝ
r : α → ℕ → ℕ
R : AkraBazziRecurrence T g a b r
⊢ ∀ᶠ (n : ℕ) in atTop, ∀ (i : α), b i * ↑n - ↑n / log ↑n ^ 2 ≤ ↑(r i n)

Next tactic:
filter_upwards [R.dist_r_b'] with n hn
lemma eventually_b_le_r : ∀ᶠ (n:ℕ) in atTop, ∀ i, (b i : ℝ) * n - (n / log n ^ 2) ≤ r i n := by
  filter_upwards [R.dist_r_b'] with n hn
  

Proof state:
case h
α : Type u_1
inst✝¹ : Fintype α
inst✝ : Nonempty α
T : ℕ → ℝ
g : ℝ → ℝ
a b : α → ℝ
r : α → ℕ → ℕ
R : AkraBazziRecurrence T g a b r
n : ℕ
hn : ∀ (i : α), ‖↑(r i n) - b i * ↑n‖ ≤ ↑n / log ↑n ^ 2
⊢ ∀ (i : α), b i * ↑n - ↑n / log ↑n ^ 2 ≤ ↑(r i n)

Next tactic:
intro i
lemma eventually_b_le_r : ∀ᶠ (n:ℕ) in atTop, ∀ i, (b i : ℝ) * n - (n / log n ^ 2) ≤ r i n := by
  filter_upwards [R.dist_r_b'] with n hn
  intro i
  

Proof state:
case h
α : Type u_1
inst✝¹ : Fintype α
inst✝ : Nonempty α
T : ℕ → ℝ
g : ℝ → ℝ
a b : α → ℝ
r : α → ℕ → ℕ
R : AkraBazziRecurrence T g a b r
n : ℕ
hn : ∀ (i : α), ‖↑(r i n) - b i * ↑n‖ ≤ ↑n / log ↑n ^ 2
i : α
⊢ b i * ↑n - ↑n / log ↑n ^ 2 ≤ ↑(r i n)

Next tactic:
have h₁ : 0 ≤ b i := le_of_lt <| R.b_pos _
lemma eventually_b_le_r : ∀ᶠ (n:ℕ) in atTop, ∀ i, (b i : ℝ) * n - (n / log n ^ 2) ≤ r i n := by
  filter_upwards [R.dist_r_b'] with n hn
  intro i
  have h₁ : 0 ≤ b i := le_of_lt <| R.b_pos _
  

Proof state:
case h
α : Type u_1
inst✝¹ : Fintype α
inst✝ : Nonempty α
T : ℕ → ℝ
g : ℝ → ℝ
a b : α → ℝ
r : α → ℕ → ℕ
R : AkraBazziRecurrence T g a b r
n : ℕ
hn : ∀ (i : α), ‖↑(r i n) - b i * ↑n‖ ≤ ↑n / log ↑n ^ 2
i : α
h₁ : 0 ≤ b i
⊢ b i * ↑n - ↑n / log ↑n ^ 2 ≤ ↑(r i n)

Next tactic:
rw [sub_le_iff_le_add, add_comm, ← sub_le_iff_le_add]
lemma eventually_b_le_r : ∀ᶠ (n:ℕ) in atTop, ∀ i, (b i : ℝ) * n - (n / log n ^ 2) ≤ r i n := by
  filter_upwards [R.dist_r_b'] with n hn
  intro i
  have h₁ : 0 ≤ b i := le_of_lt <| R.b_pos _
  rw [sub_le_iff_le_add, add_comm, ← sub_le_iff_le_add]
  

Proof state:
case h
α : Type u_1
inst✝¹ : Fintype α
inst✝ : Nonempty α
T : ℕ → ℝ
g : ℝ → ℝ
a b : α → ℝ
r : α → ℕ → ℕ
R : AkraBazziRecurrence T g a b r
n : ℕ
hn : ∀ (i : α), ‖↑(r i n) - b i * ↑n‖ ≤ ↑n / log ↑n ^ 2
i : α
h₁ : 0 ≤ b i
⊢ b i * ↑n - ↑(r i n) ≤ ↑n / log ↑n ^ 2

Next tactic:
calc (b i : ℝ) * n - r i n = ‖b i * n‖ - ‖(r i n : ℝ)‖ := by
                            simp only [norm_mul, IsROrC.norm_natCast, sub_left_inj,
                                       Nat.cast_eq_zero, Real.norm_of_nonneg h₁]
                         _ ≤ ‖(b i * n : ℝ) - r i n‖ := norm_sub_norm_le _ _
                         _ = ‖(r i n : ℝ) - b i * n‖ := norm_sub_rev _ _
                         _ ≤ n / log n ^ 2 := hn i
lemma eventually_b_le_r : ∀ᶠ (n:ℕ) in atTop, ∀ i, (b i : ℝ) * n - (n / log n ^ 2) ≤ r i n := by
  filter_upwards [R.dist_r_b'] with n hn
  intro i
  have h₁ : 0 ≤ b i := le_of_lt <| R.b_pos _
  rw [sub_le_iff_le_add, add_comm, ← sub_le_iff_le_add]
  calc (b i : ℝ) * n - r i n = ‖b i * n‖ - ‖(r i n : ℝ)‖ := by
                            

Proof state:
α : Type u_1
inst✝¹ : Fintype α
inst✝ : Nonempty α
T : ℕ → ℝ
g : ℝ → ℝ
a b : α → ℝ
r : α → ℕ → ℕ
R : AkraBazziRecurrence T g a b r
n : ℕ
hn : ∀ (i : α), ‖↑(r i n) - b i * ↑n‖ ≤ ↑n / log ↑n ^ 2
i : α
h₁ : 0 ≤ b i
⊢ b i * ↑n - ↑(r i n) = ‖b i * ↑n‖ - ‖↑(r i n)‖

Next tactic:
simp only [norm_mul, IsROrC.norm_natCast, sub_left_inj,
                                       Nat.cast_eq_zero, Real.norm_of_nonneg h₁]
lemma eventually_r_le_b : ∀ᶠ (n:ℕ) in atTop, ∀ i, r i n ≤ (b i : ℝ) * n + (n / log n ^ 2) := by
  

Proof state:
α : Type u_1
inst✝¹ : Fintype α
inst✝ : Nonempty α
T : ℕ → ℝ
g : ℝ → ℝ
a b : α → ℝ
r : α → ℕ → ℕ
R : AkraBazziRecurrence T g a b r
⊢ ∀ᶠ (n : ℕ) in atTop, ∀ (i : α), ↑(r i n) ≤ b i * ↑n + ↑n / log ↑n ^ 2

Next tactic:
filter_upwards [R.dist_r_b'] with n hn
lemma eventually_r_le_b : ∀ᶠ (n:ℕ) in atTop, ∀ i, r i n ≤ (b i : ℝ) * n + (n / log n ^ 2) := by
  filter_upwards [R.dist_r_b'] with n hn
  

Proof state:
case h
α : Type u_1
inst✝¹ : Fintype α
inst✝ : Nonempty α
T : ℕ → ℝ
g : ℝ → ℝ
a b : α → ℝ
r : α → ℕ → ℕ
R : AkraBazziRecurrence T g a b r
n : ℕ
hn : ∀ (i : α), ‖↑(r i n) - b i * ↑n‖ ≤ ↑n / log ↑n ^ 2
⊢ ∀ (i : α), ↑(r i n) ≤ b i * ↑n + ↑n / log ↑n ^ 2

Next tactic:
intro i
lemma eventually_r_le_b : ∀ᶠ (n:ℕ) in atTop, ∀ i, r i n ≤ (b i : ℝ) * n + (n / log n ^ 2) := by
  filter_upwards [R.dist_r_b'] with n hn
  intro i
  

Proof state:
case h
α : Type u_1
inst✝¹ : Fintype α
inst✝ : Nonempty α
T : ℕ → ℝ
g : ℝ → ℝ
a b : α → ℝ
r : α → ℕ → ℕ
R : AkraBazziRecurrence T g a b r
n : ℕ
hn : ∀ (i : α), ‖↑(r i n) - b i * ↑n‖ ≤ ↑n / log ↑n ^ 2
i : α
⊢ ↑(r i n) ≤ b i * ↑n + ↑n / log ↑n ^ 2

Next tactic:
calc r i n = b i * n + (r i n - b i * n) := by ring
             _ ≤ b i * n + ‖r i n - b i * n‖ := by gcongr; exact Real.le_norm_self _
             _ ≤ b i * n + n / log n ^ 2 := by gcongr; exact hn i
lemma eventually_r_le_b : ∀ᶠ (n:ℕ) in atTop, ∀ i, r i n ≤ (b i : ℝ) * n + (n / log n ^ 2) := by
  filter_upwards [R.dist_r_b'] with n hn
  intro i
  calc r i n = b i * n + (r i n - b i * n) := by 

Proof state:
α : Type u_1
inst✝¹ : Fintype α
inst✝ : Nonempty α
T : ℕ → ℝ
g : ℝ → ℝ
a b : α → ℝ
r : α → ℕ → ℕ
R : AkraBazziRecurrence T g a b r
n : ℕ
hn : ∀ (i : α), ‖↑(r i n) - b i * ↑n‖ ≤ ↑n / log ↑n ^ 2
i : α
⊢ ↑(r i n) = b i * ↑n + (↑(r i n) - b i * ↑n)

Next tactic:
ring
lemma eventually_r_le_b : ∀ᶠ (n:ℕ) in atTop, ∀ i, r i n ≤ (b i : ℝ) * n + (n / log n ^ 2) := by
  filter_upwards [R.dist_r_b'] with n hn
  intro i
  calc r i n = b i * n + (r i n - b i * n) := by ring
             _ ≤ b i * n + ‖r i n - b i * n‖ := by 

Proof state:
α : Type u_1
inst✝¹ : Fintype α
inst✝ : Nonempty α
T : ℕ → ℝ
g : ℝ → ℝ
a b : α → ℝ
r : α → ℕ → ℕ
R : AkraBazziRecurrence T g a b r
n : ℕ
hn : ∀ (i : α), ‖↑(r i n) - b i * ↑n‖ ≤ ↑n / log ↑n ^ 2
i : α
⊢ b i * ↑n + (↑(r i n) - b i * ↑n) ≤ b i * ↑n + ‖↑(r i n) - b i * ↑n‖

Next tactic:
gcongr