mathlib documentation

data.​nat.​sqrt

data.​nat.​sqrt

theorem nat.​sqrt_aux_dec {b : ℕ} :
b ≠ 0 → b.shiftr 2 < b

def nat.​sqrt_aux  :
ℕ → ℕ → ℕ → ℕ

Equations
def nat.​sqrt  :
ℕ → ℕ

sqrt n is the square root of a natural number n. If n is not a perfect square, it returns the largest k:ℕ such that k*k ≤ n.

Equations
theorem nat.​sqrt_aux_0 (r n : ℕ) :
0.sqrt_aux r n = r

theorem nat.​sqrt_aux_1 {r n b : ℕ} (h : b ≠ 0) {n' : ℕ} :
r + b + n' = n → b.sqrt_aux r n = (b.shiftr 2).sqrt_aux (r.div2 + b) n'

theorem nat.​sqrt_aux_2 {r n b : ℕ} :
b ≠ 0 → n < r + b → b.sqrt_aux r n = (b.shiftr 2).sqrt_aux r.div2 n

theorem nat.​sqrt_le (n : ℕ) :

theorem nat.​lt_succ_sqrt (n : ℕ) :

theorem nat.​le_sqrt {m n : ℕ} :
m ≤ nat.sqrt n ↔ m * m ≤ n

theorem nat.​sqrt_lt {m n : ℕ} :
nat.sqrt m < n ↔ m < n * n

theorem nat.​sqrt_le_self (n : ℕ) :

theorem nat.​sqrt_le_sqrt {m n : ℕ} :
m ≤ n → nat.sqrt m ≤ nat.sqrt n

theorem nat.​sqrt_eq_zero {n : ℕ} :
nat.sqrt n = 0 ↔ n = 0

theorem nat.​eq_sqrt {n q : ℕ} :
q = nat.sqrt n ↔ q * q ≤ n ∧ n < (q + 1) * (q + 1)

theorem nat.​le_three_of_sqrt_eq_one {n : ℕ} :
nat.sqrt n = 1 → n ≤ 3

theorem nat.​sqrt_lt_self {n : ℕ} :
1 < n → nat.sqrt n < n

theorem nat.​sqrt_pos {n : ℕ} :
0 < nat.sqrt n ↔ 0 < n

theorem nat.​sqrt_add_eq (n : ℕ) {a : ℕ} :
a ≤ n + n → nat.sqrt (n * n + a) = n

theorem nat.​sqrt_eq (n : ℕ) :
nat.sqrt (n * n) = n

theorem nat.​exists_mul_self (x : ℕ) :
(∃ (n : ℕ), n * n = x) ↔ nat.sqrt x * nat.sqrt x = x