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

    Dm::primep

    Recognizer of prime numbers.

    This is taken from the RTL library.

    Function: primep

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

    Function: least-divisor

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

    Function: divides

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