Check if a byte array is an RLP encoding of a transaction.
This is a declarative, non-executable definition,
which essentially characterizes the image of rlp-encode-transaction
(over transaction that can be encoded,
i.e. such that rlp-encode-transaction
returns a
By definition, the witness function is right inverse of the encoding function, over the valid encodings.
Theorem:
(defthm rlp-transaction-encoding-p-suff (implies (and (transactionp transaction) (b* (((mv error? encoding1) (rlp-encode-transaction transaction))) (and (not error?) (equal encoding1 (byte-list-fix encoding))))) (rlp-transaction-encoding-p encoding)))
Theorem:
(defthm booleanp-of-rlp-transaction-encoding-p (b* ((yes/no (rlp-transaction-encoding-p encoding))) (booleanp yes/no)) :rule-classes :rewrite)
Theorem:
(defthm rlp-transaction-encoding-p-of-byte-list-fix-encoding (equal (rlp-transaction-encoding-p (byte-list-fix encoding)) (rlp-transaction-encoding-p encoding)))
Theorem:
(defthm rlp-transaction-encoding-p-byte-list-equiv-congruence-on-encoding (implies (byte-list-equiv encoding encoding-equiv) (equal (rlp-transaction-encoding-p encoding) (rlp-transaction-encoding-p encoding-equiv))) :rule-classes :congruence)
Theorem:
(defthm rlp-transactionp-of-rlp-transaction-encoding-witness (implies (rlp-transaction-encoding-p encoding) (transactionp (rlp-transaction-encoding-witness encoding))))
Theorem:
(defthm rlp-encode-transaction-of-rlp-transaction-encoding-witness (implies (rlp-transaction-encoding-p encoding) (b* (((mv error? encoding1) (rlp-encode-transaction (rlp-transaction-encoding-witness encoding)))) (and (not error?) (equal encoding1 (byte-list-fix encoding))))))
Theorem:
(defthm rlp-transaction-encoding-p-of-rlp-transaction-encode-when-no-error (implies (not (mv-nth 0 (rlp-encode-transaction transaction))) (rlp-transaction-encoding-p (mv-nth 1 (rlp-encode-transaction transaction)))))