Fixing function for bip32-key-tree structures.
(bip32-key-tree-fix x) → new-x
Function:
(defun bip32-key-tree-fix$inline (x) (declare (xargs :guard (bip32-key-treep x))) (let ((__function__ 'bip32-key-tree-fix)) (declare (ignorable __function__)) (mbe :logic (b* ((root-key (bip32-ext-key-fix (std::da-nth 0 x))) (root-depth (byte-fix (std::da-nth 1 x))) (root-index (ubyte32-fix (std::da-nth 2 x))) (root-parent (byte-list-fix (std::da-nth 3 x))) (index-tree (bip32-index-tree-fix (std::da-nth 4 x)))) (let ((root-index (if (equal root-depth 0) 0 root-index)) (root-parent (if (or (equal root-depth 0) (not (equal (len root-parent) 4))) (list 0 0 0 0) root-parent)) (index-tree (if (and (bip32-valid-keys-p root-key index-tree) (bip32-valid-depths-p root-depth index-tree)) index-tree (list nil)))) (list root-key root-depth root-index root-parent index-tree))) :exec x)))
Theorem:
(defthm bip32-key-treep-of-bip32-key-tree-fix (b* ((new-x (bip32-key-tree-fix$inline x))) (bip32-key-treep new-x)) :rule-classes :rewrite)
Theorem:
(defthm bip32-key-tree-fix-when-bip32-key-treep (implies (bip32-key-treep x) (equal (bip32-key-tree-fix x) x)))
Function:
(defun bip32-key-tree-equiv$inline (acl2::x acl2::y) (declare (xargs :guard (and (bip32-key-treep acl2::x) (bip32-key-treep acl2::y)))) (equal (bip32-key-tree-fix acl2::x) (bip32-key-tree-fix acl2::y)))
Theorem:
(defthm bip32-key-tree-equiv-is-an-equivalence (and (booleanp (bip32-key-tree-equiv x y)) (bip32-key-tree-equiv x x) (implies (bip32-key-tree-equiv x y) (bip32-key-tree-equiv y x)) (implies (and (bip32-key-tree-equiv x y) (bip32-key-tree-equiv y z)) (bip32-key-tree-equiv x z))) :rule-classes (:equivalence))
Theorem:
(defthm bip32-key-tree-equiv-implies-equal-bip32-key-tree-fix-1 (implies (bip32-key-tree-equiv acl2::x x-equiv) (equal (bip32-key-tree-fix acl2::x) (bip32-key-tree-fix x-equiv))) :rule-classes (:congruence))
Theorem:
(defthm bip32-key-tree-fix-under-bip32-key-tree-equiv (bip32-key-tree-equiv (bip32-key-tree-fix acl2::x) acl2::x) :rule-classes (:rewrite :rewrite-quoted-constant))
Theorem:
(defthm equal-of-bip32-key-tree-fix-1-forward-to-bip32-key-tree-equiv (implies (equal (bip32-key-tree-fix acl2::x) acl2::y) (bip32-key-tree-equiv acl2::x acl2::y)) :rule-classes :forward-chaining)
Theorem:
(defthm equal-of-bip32-key-tree-fix-2-forward-to-bip32-key-tree-equiv (implies (equal acl2::x (bip32-key-tree-fix acl2::y)) (bip32-key-tree-equiv acl2::x acl2::y)) :rule-classes :forward-chaining)
Theorem:
(defthm bip32-key-tree-equiv-of-bip32-key-tree-fix-1-forward (implies (bip32-key-tree-equiv (bip32-key-tree-fix acl2::x) acl2::y) (bip32-key-tree-equiv acl2::x acl2::y)) :rule-classes :forward-chaining)
Theorem:
(defthm bip32-key-tree-equiv-of-bip32-key-tree-fix-2-forward (implies (bip32-key-tree-equiv acl2::x (bip32-key-tree-fix acl2::y)) (bip32-key-tree-equiv acl2::x acl2::y)) :rule-classes :forward-chaining)