• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
    • Debugging
    • Std
    • Proof-automation
    • Macro-libraries
    • ACL2
    • Interfacing-tools
    • Hardware-verification
    • Software-verification
    • Math
      • 100-theorems
      • Arithmetic
        • Lispfloat
        • Arithmetic-1
        • Number-theory
          • Tonelli-shanks-modular-sqrt-algorithm
          • Defprime
          • Dm::primep
            • Defprime-alias
            • Prime
            • Has-square-root?
            • Prime-fix
            • Secp256k1-group-prime
            • Secp256k1-field-prime
            • Jubjub-subgroup-prime
            • Bn-254-group-prime
            • Bls12-381-scalar-field-prime
            • Baby-jubjub-subgroup-prime
            • Goldilocks-prime
          • Proof-by-arith
          • Arith-equivs
          • Include-an-arithmetic-book
          • Number-theory
          • Arithmetic-3
          • Arithmetic-2
          • Arithmetic-light
          • Arithmetic-5
        • Bit-vectors
        • Algebra
      • Testing-utilities
    • Number-theory

    Dm::primep

    Recognizer of prime numbers.

    This is taken from the RTL library.

    Function: primep

    (defun dm::primep (n)
      (declare (xargs :guard t))
      (and (integerp n)
           (>= n 2)
           (equal (dm::least-divisor 2 n) n)))

    Function: least-divisor

    (defun dm::least-divisor (k n)
      (declare (xargs :guard t))
      (if (and (integerp n)
               (integerp k)
               (< 1 k)
               (<= k n))
          (if (dm::divides k n)
              k
            (dm::least-divisor (1+ k) n))
        nil))

    Function: divides

    (defun dm::divides (x y)
      (declare (xargs :guard t))
      (and (acl2-numberp x)
           (not (= x 0))
           (acl2-numberp y)
           (integerp (/ y x))))