Fixing function for montgomery-curve structures.
(montgomery-curve-fix x) → new-x
Function:
(defun montgomery-curve-fix$inline (x) (declare (xargs :guard (montgomery-curvep x))) (let ((acl2::__function__ 'montgomery-curve-fix)) (declare (ignorable acl2::__function__)) (mbe :logic (b* ((p (cdr (std::da-nth 0 x))) (a (cdr (std::da-nth 1 x))) (b (cdr (std::da-nth 2 x)))) (let ((p (if (and (dm::primep p) (> p 2)) p 3)) (a (if (and (dm::primep p) (> p 2) (fep a p) (not (equal a 2)) (not (equal a (mod -2 p)))) a 0)) (b (if (and (dm::primep p) (fep b p) (not (equal b 0))) b 1))) (list (cons 'p p) (cons 'a a) (cons 'b b)))) :exec x)))
Theorem:
(defthm montgomery-curvep-of-montgomery-curve-fix (b* ((new-x (montgomery-curve-fix$inline x))) (montgomery-curvep new-x)) :rule-classes :rewrite)
Theorem:
(defthm montgomery-curve-fix-when-montgomery-curvep (implies (montgomery-curvep x) (equal (montgomery-curve-fix x) x)))
Function:
(defun montgomery-curve-equiv$inline (acl2::x acl2::y) (declare (xargs :guard (and (montgomery-curvep acl2::x) (montgomery-curvep acl2::y)))) (equal (montgomery-curve-fix acl2::x) (montgomery-curve-fix acl2::y)))
Theorem:
(defthm montgomery-curve-equiv-is-an-equivalence (and (booleanp (montgomery-curve-equiv x y)) (montgomery-curve-equiv x x) (implies (montgomery-curve-equiv x y) (montgomery-curve-equiv y x)) (implies (and (montgomery-curve-equiv x y) (montgomery-curve-equiv y z)) (montgomery-curve-equiv x z))) :rule-classes (:equivalence))
Theorem:
(defthm montgomery-curve-equiv-implies-equal-montgomery-curve-fix-1 (implies (montgomery-curve-equiv acl2::x x-equiv) (equal (montgomery-curve-fix acl2::x) (montgomery-curve-fix x-equiv))) :rule-classes (:congruence))
Theorem:
(defthm montgomery-curve-fix-under-montgomery-curve-equiv (montgomery-curve-equiv (montgomery-curve-fix acl2::x) acl2::x) :rule-classes (:rewrite :rewrite-quoted-constant))
Theorem:
(defthm equal-of-montgomery-curve-fix-1-forward-to-montgomery-curve-equiv (implies (equal (montgomery-curve-fix acl2::x) acl2::y) (montgomery-curve-equiv acl2::x acl2::y)) :rule-classes :forward-chaining)
Theorem:
(defthm equal-of-montgomery-curve-fix-2-forward-to-montgomery-curve-equiv (implies (equal acl2::x (montgomery-curve-fix acl2::y)) (montgomery-curve-equiv acl2::x acl2::y)) :rule-classes :forward-chaining)
Theorem:
(defthm montgomery-curve-equiv-of-montgomery-curve-fix-1-forward (implies (montgomery-curve-equiv (montgomery-curve-fix acl2::x) acl2::y) (montgomery-curve-equiv acl2::x acl2::y)) :rule-classes :forward-chaining)
Theorem:
(defthm montgomery-curve-equiv-of-montgomery-curve-fix-2-forward (implies (montgomery-curve-equiv acl2::x (montgomery-curve-fix acl2::y)) (montgomery-curve-equiv acl2::x acl2::y)) :rule-classes :forward-chaining)