import Mathlib

open Real

variable
  {x : ℝ} {y : ℝ}

-- Definition: Function (f : ℝ → ℝ) is continuous at (x₀ : ℝ)
def continuous_at (f : ℝ → ℝ) (x₀ : ℝ) :=
  ∀ ε > 0, ∃ δ > 0, ∀ x, |x - x₀| < δ → |f x - f x₀| < ε

-- Three lemmas from the lean mathematical library
example : 0 < x  →  0 < √x := sqrt_pos.2

example : x ^ 2 < y  ↔  (-√y < x) ∧ (x < √y) := sq_lt

example : |x| < y  ↔  -y < x ∧ x < y := abs_lt

-- The square function
def squareFct : ℝ → ℝ := fun x ↦ x ^ 2


theorem continuous_at_squareFct :
    continuous_at squareFct 0 := by
  unfold continuous_at
  intro e he
  use √e
  constructor
  · apply sqrt_pos.2
    exact he
  · intro x hx
    simp_all [squareFct]
    apply sq_lt.2
    apply abs_lt.1
    exact hx
