Entropy values.
The entropy is a sequence of bits whose size is one of the allowed ones (see bip39-entropy-size-p).
We introduce a fixtype for the possible values of the entropy.
Function:
(defun bip39-entropyp (x) (declare (xargs :guard t)) (and (bit-listp x) (bip39-entropy-size-p (len x)) t))
Theorem:
(defthm booleanp-of-bip39-entropyp (b* ((yes/no (bip39-entropyp x))) (booleanp yes/no)) :rule-classes :rewrite)
Function:
(defun bip39-entropy-fix (x) (declare (xargs :guard (bip39-entropyp x))) (mbe :logic (if (bip39-entropyp x) x (repeat 128 0)) :exec x))
Theorem:
(defthm bip39-entropyp-of-bip39-entropy-fix (b* ((fixed-x (bip39-entropy-fix x))) (bip39-entropyp fixed-x)) :rule-classes :rewrite)
Theorem:
(defthm bip39-entropy-fix-when-bip39-entropyp (implies (bip39-entropyp x) (equal (bip39-entropy-fix x) x)))
Function:
(defun bip39-entropy-equiv$inline (acl2::x acl2::y) (declare (xargs :guard (and (bip39-entropyp acl2::x) (bip39-entropyp acl2::y)))) (equal (bip39-entropy-fix acl2::x) (bip39-entropy-fix acl2::y)))
Theorem:
(defthm bip39-entropy-equiv-is-an-equivalence (and (booleanp (bip39-entropy-equiv x y)) (bip39-entropy-equiv x x) (implies (bip39-entropy-equiv x y) (bip39-entropy-equiv y x)) (implies (and (bip39-entropy-equiv x y) (bip39-entropy-equiv y z)) (bip39-entropy-equiv x z))) :rule-classes (:equivalence))
Theorem:
(defthm bip39-entropy-equiv-implies-equal-bip39-entropy-fix-1 (implies (bip39-entropy-equiv acl2::x x-equiv) (equal (bip39-entropy-fix acl2::x) (bip39-entropy-fix x-equiv))) :rule-classes (:congruence))
Theorem:
(defthm bip39-entropy-fix-under-bip39-entropy-equiv (bip39-entropy-equiv (bip39-entropy-fix acl2::x) acl2::x) :rule-classes (:rewrite :rewrite-quoted-constant))
Theorem:
(defthm equal-of-bip39-entropy-fix-1-forward-to-bip39-entropy-equiv (implies (equal (bip39-entropy-fix acl2::x) acl2::y) (bip39-entropy-equiv acl2::x acl2::y)) :rule-classes :forward-chaining)
Theorem:
(defthm equal-of-bip39-entropy-fix-2-forward-to-bip39-entropy-equiv (implies (equal acl2::x (bip39-entropy-fix acl2::y)) (bip39-entropy-equiv acl2::x acl2::y)) :rule-classes :forward-chaining)
Theorem:
(defthm bip39-entropy-equiv-of-bip39-entropy-fix-1-forward (implies (bip39-entropy-equiv (bip39-entropy-fix acl2::x) acl2::y) (bip39-entropy-equiv acl2::x acl2::y)) :rule-classes :forward-chaining)
Theorem:
(defthm bip39-entropy-equiv-of-bip39-entropy-fix-2-forward (implies (bip39-entropy-equiv acl2::x (bip39-entropy-fix acl2::y)) (bip39-entropy-equiv acl2::x acl2::y)) :rule-classes :forward-chaining)