• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
      • Apt
      • Zfc
      • Acre
      • Milawa
      • Smtlink
      • Abnf
      • Vwsim
      • Isar
      • Wp-gen
      • Dimacs-reader
      • Pfcs
      • Legacy-defrstobj
      • Proof-checker-array
      • Soft
      • C
      • Farray
      • Rp-rewriter
      • Instant-runoff-voting
      • Imp-language
      • Sidekick
      • Leftist-trees
      • Java
      • Taspi
      • Bitcoin
      • Riscv
      • Des
      • Ethereum
      • X86isa
      • Sha-2
      • Yul
      • Zcash
      • Proof-checker-itp13
      • Regex
      • ACL2-programming-language
      • Json
      • Jfkr
      • Equational
      • Cryptography
        • R1cs
        • Interfaces
        • Sha-2
        • Keccak
        • Kdf
        • Mimc
        • Padding
        • Hmac
        • Elliptic-curves
          • Secp256k1-attachment
          • Twisted-edwards
          • Montgomery
          • Short-weierstrass-curves
            • Short-weierstrass
              • Short-weierstrass-fix
                • Short-weierstrass-equiv
                • Make-short-weierstrass
                • Curve-scalar-*
                • Short-weierstrass->p
                • Short-weierstrass->b
                • Short-weierstrass->a
                • Curve-group-+
                • Change-short-weierstrass
                • Short-weierstrass-p
                • Point-on-weierstrass-elliptic-curve-p
                • Curve-negate
                • Weierstrass-elliptic-curve-p
              • Short-weierstrass-primep
            • Birational-montgomery-twisted-edwards
            • Has-square-root?-satisfies-pfield-squarep
            • Secp256k1
            • Secp256k1-domain-parameters
            • Secp256k1-types
            • Pfield-squarep
            • Secp256k1-interface
            • Prime-field-extra-rules
            • Points
          • Attachments
          • Elliptic-curve-digital-signature-algorithm
        • Poseidon
        • Where-do-i-place-my-book
        • Axe
        • Bigmems
        • Builtins
        • Execloader
        • Aleo
        • Solidity
        • Paco
        • Concurrent-programs
        • Bls12-377-curves
      • Debugging
      • Std
      • Proof-automation
      • Macro-libraries
      • ACL2
      • Interfacing-tools
      • Hardware-verification
      • Software-verification
      • Math
      • Testing-utilities
    • Short-weierstrass

    Short-weierstrass-fix

    Fixing function for short-weierstrass structures.

    Signature
    (short-weierstrass-fix x) → new-x
    Arguments
    x — Guard (short-weierstrass-p x).
    Returns
    new-x — Type (short-weierstrass-p new-x).

    Definitions and Theorems

    Function: short-weierstrass-fix$inline

    (defun short-weierstrass-fix$inline (x)
     (declare (xargs :guard (short-weierstrass-p x)))
     (let ((acl2::__function__ 'short-weierstrass-fix))
      (declare (ignorable acl2::__function__))
      (mbe
          :logic
          (b* ((p (nfix (cdr (std::da-nth 0 x))))
               (a (nfix (cdr (std::da-nth 1 x))))
               (b (nfix (cdr (std::da-nth 2 x)))))
            (let ((p (if (and (> p 3)
                              (fep a p)
                              (fep b p)
                              (posp (mod (+ (* 4 a a a) (* 27 b b)) p)))
                         p
                       5))
                  (a (if (and (> p 3)
                              (fep a p)
                              (fep b p)
                              (posp (mod (+ (* 4 a a a) (* 27 b b)) p)))
                         a
                       0))
                  (b (if (and (> p 3)
                              (fep a p)
                              (fep b p)
                              (posp (mod (+ (* 4 a a a) (* 27 b b)) p)))
                         b
                       1)))
              (list (cons 'p p)
                    (cons 'a a)
                    (cons 'b b))))
          :exec x)))

    Theorem: short-weierstrass-p-of-short-weierstrass-fix

    (defthm short-weierstrass-p-of-short-weierstrass-fix
      (b* ((new-x (short-weierstrass-fix$inline x)))
        (short-weierstrass-p new-x))
      :rule-classes :rewrite)

    Theorem: short-weierstrass-fix-when-short-weierstrass-p

    (defthm short-weierstrass-fix-when-short-weierstrass-p
      (implies (short-weierstrass-p x)
               (equal (short-weierstrass-fix x) x)))

    Function: short-weierstrass-equiv$inline

    (defun short-weierstrass-equiv$inline (acl2::x acl2::y)
      (declare (xargs :guard (and (short-weierstrass-p acl2::x)
                                  (short-weierstrass-p acl2::y))))
      (equal (short-weierstrass-fix acl2::x)
             (short-weierstrass-fix acl2::y)))

    Theorem: short-weierstrass-equiv-is-an-equivalence

    (defthm short-weierstrass-equiv-is-an-equivalence
      (and (booleanp (short-weierstrass-equiv x y))
           (short-weierstrass-equiv x x)
           (implies (short-weierstrass-equiv x y)
                    (short-weierstrass-equiv y x))
           (implies (and (short-weierstrass-equiv x y)
                         (short-weierstrass-equiv y z))
                    (short-weierstrass-equiv x z)))
      :rule-classes (:equivalence))

    Theorem: short-weierstrass-equiv-implies-equal-short-weierstrass-fix-1

    (defthm
          short-weierstrass-equiv-implies-equal-short-weierstrass-fix-1
      (implies (short-weierstrass-equiv acl2::x x-equiv)
               (equal (short-weierstrass-fix acl2::x)
                      (short-weierstrass-fix x-equiv)))
      :rule-classes (:congruence))

    Theorem: short-weierstrass-fix-under-short-weierstrass-equiv

    (defthm short-weierstrass-fix-under-short-weierstrass-equiv
      (short-weierstrass-equiv (short-weierstrass-fix acl2::x)
                               acl2::x)
      :rule-classes (:rewrite :rewrite-quoted-constant))

    Theorem: equal-of-short-weierstrass-fix-1-forward-to-short-weierstrass-equiv

    (defthm
     equal-of-short-weierstrass-fix-1-forward-to-short-weierstrass-equiv
     (implies (equal (short-weierstrass-fix acl2::x)
                     acl2::y)
              (short-weierstrass-equiv acl2::x acl2::y))
     :rule-classes :forward-chaining)

    Theorem: equal-of-short-weierstrass-fix-2-forward-to-short-weierstrass-equiv

    (defthm
     equal-of-short-weierstrass-fix-2-forward-to-short-weierstrass-equiv
     (implies (equal acl2::x (short-weierstrass-fix acl2::y))
              (short-weierstrass-equiv acl2::x acl2::y))
     :rule-classes :forward-chaining)

    Theorem: short-weierstrass-equiv-of-short-weierstrass-fix-1-forward

    (defthm short-weierstrass-equiv-of-short-weierstrass-fix-1-forward
      (implies (short-weierstrass-equiv (short-weierstrass-fix acl2::x)
                                        acl2::y)
               (short-weierstrass-equiv acl2::x acl2::y))
      :rule-classes :forward-chaining)

    Theorem: short-weierstrass-equiv-of-short-weierstrass-fix-2-forward

    (defthm short-weierstrass-equiv-of-short-weierstrass-fix-2-forward
     (implies
       (short-weierstrass-equiv acl2::x (short-weierstrass-fix acl2::y))
       (short-weierstrass-equiv acl2::x acl2::y))
     :rule-classes :forward-chaining)