• Top
    • Documentation
    • Books
    • Recursion-and-induction
    • Boolean-reasoning
    • Debugging
    • Projects
    • 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
            • Tonelli-shanks-algorithm-is-correct
            • Tonelli-shanks-even-sqrt
            • Tonelli-shanks-odd-sqrt
            • Tonelli-shanks-lesser-sqrt
            • Tonelli-shanks-greater-sqrt
            • Tonelli-shanks-sqrt
            • Tonelli-shanks-either-sqrt
            • Tonelli-shanks-supportive-functions
              • Repeated-square
                • Q*2^s
            • Defprime
            • Defprime-alias
            • Dm::primep
            • Prime
            • 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
          • Include-an-arithmetic-book
          • Number-theory
          • Arithmetic-3
          • Arithmetic-2
          • Arithmetic-light
          • Arithmetic-5
        • Bit-vectors
        • Algebra
      • Testing-utilities
    • Tonelli-shanks-supportive-functions

    Repeated-square

    Signature
    (repeated-square base n p) → retval
    Arguments
    base — Guard (natp base).
    n — Guard (natp n).
    p — Guard (natp p).
    Returns
    retval — Type (natp retval).

    Definitions and Theorems

    Function: repeated-square

    (defun repeated-square (base n p)
      (declare (xargs :guard (and (natp base) (natp n) (natp p))))
      (declare (xargs :guard (and (natp base)
                                  (natp n)
                                  (natp p)
                                  (< 2 p))))
      (let ((acl2::__function__ 'repeated-square))
        (declare (ignorable acl2::__function__))
        (if (or (not (natp base))
                (not (natp n))
                (not (natp p))
                (< p 3))
            0
          (if (zp n)
              base
            (repeated-square (mod (* base base) p)
                             (- n 1)
                             p)))))

    Theorem: natp-of-repeated-square

    (defthm natp-of-repeated-square
      (b* ((retval (repeated-square base n p)))
        (natp retval))
      :rule-classes :rewrite)