-- Mathlib/Computability/AkraBazzi/GrowsPolynomially.lean
protected lemma GrowsPolynomially.mul {f g : ℝ → ℝ} (hf : GrowsPolynomially f)
    (hg : GrowsPolynomially g) : GrowsPolynomially fun x => f x * g x

Proof state:
f g : ℝ → ℝ
hf : GrowsPolynomially f
hg : GrowsPolynomially g
⊢ GrowsPolynomially fun x => f x * g x

Tactic:
suffices GrowsPolynomially fun x => |f x| * |g x| by
  cases eventually_atTop_nonneg_or_nonpos hf with
  | inl hf' =>
    cases eventually_atTop_nonneg_or_nonpos hg with
    | inl hg' =>
      have hmain : (fun x => f x * g x) =ᶠ[atTop] fun x => |f x| * |g x| := by
        filter_upwards [hf', hg'] with x hx₁ hx₂
        rw [abs_of_nonneg hx₁, abs_of_nonneg hx₂]
      rwa [iff_eventuallyEq hmain]
    | inr hg' =>
      have hmain : (fun x => f x * g x) =ᶠ[atTop] fun x => -|f x| * |g x| := by
        filter_upwards [hf', hg'] with x hx₁ hx₂
        simp [abs_of_nonneg hx₁, abs_of_nonpos hx₂]
      simp only [iff_eventuallyEq hmain, neg_mul]
      exact this.neg
  | inr hf' =>
    cases eventually_atTop_nonneg_or_nonpos hg with
    | inl hg' =>
      have hmain : (fun x => f x * g x) =ᶠ[atTop] fun x => -|f x| * |g x| := by
        filter_upwards [hf', hg'] with x hx₁ hx₂
        rw [abs_of_nonpos hx₁, abs_of_nonneg hx₂, neg_neg]
      simp only [iff_eventuallyEq hmain, neg_mul]
      exact this.neg
    | inr hg' =>
      have hmain : (fun x => f x * g x) =ᶠ[atTop] fun x => |f x| * |g x| := by
        filter_upwards [hf', hg'] with x hx₁ hx₂
        simp [abs_of_nonpos hx₁, abs_of_nonpos hx₂]
      simp only [iff_eventuallyEq hmain, neg_mul]
      exact this

Result:
f g : ℝ → ℝ
hf : GrowsPolynomially f
hg : GrowsPolynomially g
⊢ GrowsPolynomially fun x => |f x| * |g x|

Proof state:
case inl.inr
f g : ℝ → ℝ
hf : GrowsPolynomially f
hg : GrowsPolynomially g
this : GrowsPolynomially fun x => |f x| * |g x|
hf' : ∀ᶠ (x : ℝ) in atTop, 0 ≤ f x
hg' : ∀ᶠ (x : ℝ) in atTop, g x ≤ 0
hmain : (fun x => f x * g x) =ᶠ[atTop] fun x => -|f x| * |g x|
⊢ GrowsPolynomially fun x => -(|f x| * |g x|)

Tactic:
exact this.neg

Result:
no goals

Proof state:
f g : ℝ → ℝ
hf : GrowsPolynomially f
hg : GrowsPolynomially g
⊢ GrowsPolynomially fun x => |f x| * |g x|

Tactic:
intro b hb

Result:
f g : ℝ → ℝ
hf : GrowsPolynomially f
hg : GrowsPolynomially g
b : ℝ
hb : b ∈ Set.Ioo 0 1
⊢ ∃ c₁ > 0,
    ∃ c₂ > 0,
      ∀ᶠ (x : ℝ) in atTop,
        ∀ u ∈ Set.Icc (b * x) x,
          (fun x => |f x| * |g x|) u ∈ Set.Icc (c₁ * (fun x => |f x| * |g x|) x) (c₂ * (fun x => |f x| * |g x|) x)

Proof state:
f g : ℝ → ℝ
hf✝¹ : GrowsPolynomially f
hg✝¹ : GrowsPolynomially g
b : ℝ
hb : b ∈ Set.Ioo 0 1
c₁ : ℝ
hc₁_mem : c₁ > 0
c₂ : ℝ
hc₂_mem : c₂ > 0
hf✝ :
  ∀ᶠ (x : ℝ) in atTop,
    ∀ u ∈ Set.Icc (b * x) x, (fun x => |f x|) u ∈ Set.Icc (c₁ * (fun x => |f x|) x) (c₂ * (fun x => |f x|) x)
c₃ : ℝ
hc₃_mem : c₃ > 0
c₄ : ℝ
hc₄_mem : c₄ > 0
hg✝ :
  ∀ᶠ (x : ℝ) in atTop,
    ∀ u ∈ Set.Icc (b * x) x, (fun x => |g x|) u ∈ Set.Icc (c₃ * (fun x => |g x|) x) (c₄ * (fun x => |g x|) x)
x : ℝ
hf : ∀ u ∈ Set.Icc (b * x) x, |f u| ∈ Set.Icc (c₁ * |f x|) (c₂ * |f x|)
hg : ∀ u ∈ Set.Icc (b * x) x, |g u| ∈ Set.Icc (c₃ * |g x|) (c₄ * |g x|)
u : ℝ
hu : u ∈ Set.Icc (b * x) x
⊢ c₁ * c₃ * (|f x| * |g x|) = c₁ * |f x| * (c₃ * |g x|)

Tactic:
ring

Result:
no goals

Proof state:
case h₂
f g : ℝ → ℝ
hf✝¹ : GrowsPolynomially f
hg✝¹ : GrowsPolynomially g
b : ℝ
hb : b ∈ Set.Ioo 0 1
c₁ : ℝ
hc₁_mem : c₁ > 0
c₂ : ℝ
hc₂_mem : c₂ > 0
hf✝ :
  ∀ᶠ (x : ℝ) in atTop,
    ∀ u ∈ Set.Icc (b * x) x, (fun x => |f x|) u ∈ Set.Icc (c₁ * (fun x => |f x|) x) (c₂ * (fun x => |f x|) x)
c₃ : ℝ
hc₃_mem : c₃ > 0
c₄ : ℝ
hc₄_mem : c₄ > 0
hg✝ :
  ∀ᶠ (x : ℝ) in atTop,
    ∀ u ∈ Set.Icc (b * x) x, (fun x => |g x|) u ∈ Set.Icc (c₃ * (fun x => |g x|) x) (c₄ * (fun x => |g x|) x)
x : ℝ
hf : ∀ u ∈ Set.Icc (b * x) x, |f u| ∈ Set.Icc (c₁ * |f x|) (c₂ * |f x|)
hg : ∀ u ∈ Set.Icc (b * x) x, |g u| ∈ Set.Icc (c₃ * |g x|) (c₄ * |g x|)
u : ℝ
hu : u ∈ Set.Icc (b * x) x
⊢ |g u| ≤ c₄ * |g x|

Tactic:
exact (hg u hu).2

Result:
no goals

Proof state:
case inr.inl
f g : ℝ → ℝ
hf : GrowsPolynomially f
hg : GrowsPolynomially g
this : GrowsPolynomially fun x => |f x| * |g x|
hf' : ∀ᶠ (x : ℝ) in atTop, f x ≤ 0
hg' : ∀ᶠ (x : ℝ) in atTop, 0 ≤ g x
hmain : (fun x => f x * g x) =ᶠ[atTop] fun x => -|f x| * |g x|
⊢ GrowsPolynomially fun x => f x * g x

Tactic:
simp only [iff_eventuallyEq hmain, neg_mul]

Result:
case inr.inl
f g : ℝ → ℝ
hf : GrowsPolynomially f
hg : GrowsPolynomially g
this : GrowsPolynomially fun x => |f x| * |g x|
hf' : ∀ᶠ (x : ℝ) in atTop, f x ≤ 0
hg' : ∀ᶠ (x : ℝ) in atTop, 0 ≤ g x
hmain : (fun x => f x * g x) =ᶠ[atTop] fun x => -|f x| * |g x|
⊢ GrowsPolynomially fun x => -(|f x| * |g x|)

Proof state:
case h₁
f g : ℝ → ℝ
hf✝¹ : GrowsPolynomially f
hg✝¹ : GrowsPolynomially g
b : ℝ
hb : b ∈ Set.Ioo 0 1
c₁ : ℝ
hc₁_mem : c₁ > 0
c₂ : ℝ
hc₂_mem : c₂ > 0
hf✝ :
  ∀ᶠ (x : ℝ) in atTop,
    ∀ u ∈ Set.Icc (b * x) x, (fun x => |f x|) u ∈ Set.Icc (c₁ * (fun x => |f x|) x) (c₂ * (fun x => |f x|) x)
c₃ : ℝ
hc₃_mem : c₃ > 0
c₄ : ℝ
hc₄_mem : c₄ > 0
hg✝ :
  ∀ᶠ (x : ℝ) in atTop,
    ∀ u ∈ Set.Icc (b * x) x, (fun x => |g x|) u ∈ Set.Icc (c₃ * (fun x => |g x|) x) (c₄ * (fun x => |g x|) x)
x : ℝ
hf : ∀ u ∈ Set.Icc (b * x) x, |f u| ∈ Set.Icc (c₁ * |f x|) (c₂ * |f x|)
hg : ∀ u ∈ Set.Icc (b * x) x, |g u| ∈ Set.Icc (c₃ * |g x|) (c₄ * |g x|)
u : ℝ
hu : u ∈ Set.Icc (b * x) x
⊢ |f u| ≤ c₂ * |f x|

Tactic:
exact (hf u hu).2

Result:
no goals

Proof state:
case inr.inr
f g : ℝ → ℝ
hf : GrowsPolynomially f
hg : GrowsPolynomially g
this : GrowsPolynomially fun x => |f x| * |g x|
hf' : ∀ᶠ (x : ℝ) in atTop, f x ≤ 0
hg' : ∀ᶠ (x : ℝ) in atTop, g x ≤ 0
hmain : (fun x => f x * g x) =ᶠ[atTop] fun x => |f x| * |g x|
⊢ GrowsPolynomially fun x => f x * g x

Tactic:
simp only [iff_eventuallyEq hmain, neg_mul]

Result:
case inr.inr
f g : ℝ → ℝ
hf : GrowsPolynomially f
hg : GrowsPolynomially g
this : GrowsPolynomially fun x => |f x| * |g x|
hf' : ∀ᶠ (x : ℝ) in atTop, f x ≤ 0
hg' : ∀ᶠ (x : ℝ) in atTop, g x ≤ 0
hmain : (fun x => f x * g x) =ᶠ[atTop] fun x => |f x| * |g x|
⊢ GrowsPolynomially fun x => |f x| * |g x|

Proof state:
case inr.inr
f g : ℝ → ℝ
hf : GrowsPolynomially f
hg : GrowsPolynomially g
this : GrowsPolynomially fun x => |f x| * |g x|
hf' : ∀ᶠ (x : ℝ) in atTop, f x ≤ 0
hg' : ∀ᶠ (x : ℝ) in atTop, g x ≤ 0
hmain : (fun x => f x * g x) =ᶠ[atTop] fun x => |f x| * |g x|
⊢ GrowsPolynomially fun x => |f x| * |g x|

Tactic:
exact this

Result:
no goals

Proof state:
f g : ℝ → ℝ
hf : GrowsPolynomially f
hg : GrowsPolynomially g
this : GrowsPolynomially fun x => |f x| * |g x|
hf' : ∀ᶠ (x : ℝ) in atTop, f x ≤ 0
hg' : ∀ᶠ (x : ℝ) in atTop, g x ≤ 0
⊢ (fun x => f x * g x) =ᶠ[atTop] fun x => |f x| * |g x|

Tactic:
filter_upwards [hf', hg'] with x hx₁ hx₂

Result:
case h
f g : ℝ → ℝ
hf : GrowsPolynomially f
hg : GrowsPolynomially g
this : GrowsPolynomially fun x => |f x| * |g x|
hf' : ∀ᶠ (x : ℝ) in atTop, f x ≤ 0
hg' : ∀ᶠ (x : ℝ) in atTop, g x ≤ 0
x : ℝ
hx₁ : f x ≤ 0
hx₂ : g x ≤ 0
⊢ f x * g x = |f x| * |g x|