Module docstring
{"# Square root of integers
This file defines the square root function on integers. Int.sqrt z is the greatest integer r
such that r * r ≤ z. If z ≤ 0, then Int.sqrt z = 0.
"}
{"# Square root of integers
This file defines the square root function on integers. Int.sqrt z is the greatest integer r
such that r * r ≤ z. If z ≤ 0, then Int.sqrt z = 0.
"}
Int.sqrt
definition
(z : ℤ) : ℤ
Int.sqrt_eq
theorem
(n : ℤ) : sqrt (n * n) = n.natAbs
theorem sqrt_eq (n : ℤ) : sqrt (n * n) = n.natAbs := by
rw [sqrt, ← natAbs_mul_self, toNat_natCast, Nat.sqrt_eq]
Int.exists_mul_self
theorem
(x : ℤ) : (∃ n, n * n = x) ↔ sqrt x * sqrt x = x
Int.sqrt_nonneg
theorem
(n : ℤ) : 0 ≤ sqrt n
theorem sqrt_nonneg (n : ℤ) : 0 ≤ sqrt n :=
natCast_nonneg _
Int.sqrt_natCast
theorem
(n : ℕ) : Int.sqrt (n : ℤ) = Nat.sqrt n
@[simp, norm_cast]
theorem sqrt_natCast (n : ℕ) : Int.sqrt (n : ℤ) = Nat.sqrt n := by rw [sqrt, toNat_natCast]
Int.sqrt_ofNat
theorem
(n : ℕ) : Int.sqrt ofNat(n) = Nat.sqrt ofNat(n)
@[simp]
theorem sqrt_ofNat (n : ℕ) : Int.sqrt ofNat(n) = Nat.sqrt ofNat(n) :=
sqrt_natCast _