• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
    • Debugging
    • Std
    • Proof-automation
    • Macro-libraries
    • ACL2
    • Interfacing-tools
    • Hardware-verification
    • Software-verification
      • Kestrel-books
        • Crypto-hdwallet
        • Apt
        • Error-checking
        • Fty-extensions
        • Isar
        • Kestrel-utilities
        • Set
        • Soft
        • C
        • Bv
        • Imp-language
        • Event-macros
        • Java
        • Bitcoin
        • Ethereum
        • Yul
        • Zcash
        • ACL2-programming-language
        • Prime-fields
        • Json
        • Syntheto
        • File-io-light
        • Cryptography
        • 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
          • Lists-light
          • Axe
          • Builtins
          • Solidity
          • Helpers
          • Htclient
          • Typed-lists-light
          • Arithmetic-light
        • X86isa
        • Axe
        • Execloader
      • Math
      • 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))))