Documentation

HexArith.Nat.Sqrt

The floor of the square root of n.

Equations
Instances For

    The least natural number whose square is at least n.

    Equations
    Instances For
      @[simp]

      Base case of floorSqrt: the n = 0 guard fires before the Newton iteration, so floorSqrt 0 normalizes to 0.

      The square of floorSqrt n is at most n: it is a lower square root.

      theorem HexArith.Nat.lt_floorSqrt_succ (n : Nat) :
      n < (floorSqrt n + 1) ^ 2

      The successor of the floor square root has square strictly above n.

      The Newton implementation agrees with Lean's natural square root.

      @[simp]

      Base case of ceilSqrt: since floorSqrt 0 = 0 is a perfect square, ceilSqrt returns its floor branch, normalizing ceilSqrt 0 to 0.

      The square of HexArith.Nat.ceilSqrt applied to n is at least n. This is the executable upper-square bound used by the Mignotte coefficient norm chain: in the perfect-square branch of the ceiling square root, equality holds; in the non-perfect-square branch, the bound follows from the Newton iterator invariant.

      theorem HexArith.Nat.ceilSqrt_le {n b : Nat} (h : n ≤ b ^ 2) :

      A natural square upper bound also bounds the ceiling square root.