• Top
    • Documentation
    • Books
    • Recursion-and-induction
    • Boolean-reasoning
    • Projects
    • Debugging
    • Std
    • Proof-automation
    • Macro-libraries
    • ACL2
    • Interfacing-tools
    • Hardware-verification
    • Software-verification
      • Kestrel-books
        • Crypto-hdwallet
        • Error-checking
        • Apt
        • Abnf
        • Fty-extensions
        • Isar
        • Kestrel-utilities
        • Prime-field-constraint-systems
        • Soft
        • Bv
        • Imp-language
        • Event-macros
        • Bitcoin
        • Ethereum
        • Yul
        • Zcash
        • ACL2-programming-language
        • Prime-fields
        • Java
        • C
        • Syntheto
        • Number-theory
        • Cryptography
          • R1cs
          • Interfaces
          • Sha-2
          • Keccak
          • Kdf
          • Mimc
          • Padding
          • Hmac
          • Elliptic-curves
            • Secp256k1-attachment
            • Twisted-edwards
            • Montgomery
            • Edwards-bls12
            • Short-weierstrass-curves
            • Birational-montgomery-twisted-edwards
            • Has-square-root?-satisfies-pfield-squarep
              • Secp256k1
              • Secp256k1-domain-parameters
              • Secp256k1-types
              • Pfield-squarep
              • Secp256k1-interface
              • Bls12-377-domain-parameters
              • Prime-field-extra-rules
              • Points
            • Attachments
            • Elliptic-curve-digital-signature-algorithm
          • Lists-light
          • File-io-light
          • Json
          • Built-ins
          • Solidity
          • Axe
          • Std-extensions
          • Htclient
          • Typed-lists-light
          • Arithmetic-light
        • X86isa
        • Execloader
        • Axe
      • Testing-utilities
      • Math
    • Elliptic-curves

    Has-square-root?-satisfies-pfield-squarep

    Show how pfield-squarep can be refined into has-square-root?

    @see('pfield-squarep') is a nonexecutable specification of what it means to check that a field element is a square of another field element.
    @see('primes::has-square-root?') is an executable specification that uses Euler's Criterion to determine if the field element has a square root.
    In order to use apt::simplify to refine a use of pfield-squarep to has-square-root?, we must show that they are equivalent under appropriate hypotheses that limit the domain. That is the purpose of this definition.

    Implementation notes:

    Use residue-meaning-backwards to turn has-square-root? into dm::residue,open it up to expose dm::find-root, use the theorem about dm::find-root to obtainthat the square of dm::find-root is a, and finally use that as witness toconclude pfield-squarep.

    There is a case split on whether a is 0 or not,due to the definition of dm::residue. The enablement of mul is so thatpfield-squarep is phrased as (mod (* ... ...) p), and enablement offep because some of the theorems used have natp and < p as hyps.

    Definitions and Theorems

    Theorem: has-square-root?-satisfies-pfield-squarep

    (defthm has-square-root?-satisfies-pfield-squarep
            (implies (and (dm::primep p)
                          (not (equal p 2))
                          (fep a p)
                          (primes::has-square-root? a p))
                     (pfield-squarep a p)))