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