• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
      • Apt
      • Zfc
      • Acre
      • Milawa
      • Smtlink
      • Abnf
      • Vwsim
      • Isar
      • Wp-gen
      • Dimacs-reader
      • Pfcs
      • Legacy-defrstobj
      • Proof-checker-array
      • Soft
      • C
      • Farray
      • Rp-rewriter
      • Instant-runoff-voting
      • Imp-language
      • Sidekick
      • Leftist-trees
      • Java
      • Taspi
      • Bitcoin
      • Riscv
      • Des
      • Ethereum
        • Mmp-trees
        • Semaphore
        • Database
        • Cryptography
        • Rlp
          • Rlp-tree
          • Rlp-decoding-executable
            • Rlp-error
              • Rlp-error-fix
                • Rlp-error-p
                • Rlp-error-case
                • Rlp-error-equiv
                • Rlp-error-count
                • Rlp-error-fewer-bytes-than-short-length
                • Rlp-error-fewer-bytes-than-long-length
                • Rlp-error-fewer-bytes-than-length-of-length
                • Rlp-error-kind
                • Rlp-error-subtree
                • Rlp-error-non-optimal-short-length
                • Rlp-error-non-optimal-long-length
                • Rlp-error-leading-zeros-in-scalar
                • Rlp-error-leading-zeros-in-long-length
                • Rlp-error-extra-bytes
                • Rlp-error-branch-tree
                • Rlp-error-no-bytes
              • Rlp-parse-tree
              • Rlp-decodex-tree
              • Maybe-rlp-error
              • Rlp-decodex-bytes
              • Rlp-decodex-scalar
            • Rlp-decodability
            • Rlp-encoding
            • Rlp-decoding-declarative
            • Rlp-big-endian-representations
          • Transactions
          • Hex-prefix
          • Basics
          • Addresses
        • X86isa
        • Sha-2
        • Yul
        • Zcash
        • Proof-checker-itp13
        • Regex
        • ACL2-programming-language
        • Json
        • Jfkr
        • Equational
        • Cryptography
        • Poseidon
        • Where-do-i-place-my-book
        • Axe
        • Bigmems
        • Builtins
        • Execloader
        • Aleo
        • Solidity
        • Paco
        • Concurrent-programs
        • Bls12-377-curves
      • Debugging
      • Std
      • Proof-automation
      • Macro-libraries
      • ACL2
      • Interfacing-tools
      • Hardware-verification
      • Software-verification
      • Math
      • Testing-utilities
    • Rlp-error

    Rlp-error-fix

    Fixing function for rlp-error structures.

    Signature
    (rlp-error-fix x) → new-x
    Arguments
    x — Guard (rlp-error-p x).
    Returns
    new-x — Type (rlp-error-p new-x).

    Definitions and Theorems

    Function: rlp-error-fix$inline

    (defun rlp-error-fix$inline (x)
     (declare (xargs :guard (rlp-error-p x)))
     (let ((__function__ 'rlp-error-fix))
      (declare (ignorable __function__))
      (mbe
       :logic
       (case (rlp-error-kind x)
         (:no-bytes (cons :no-bytes (list)))
         (:fewer-bytes-than-short-length
              (b* ((fragment (byte-list-fix (std::da-nth 0 (cdr x))))
                   (required (nfix (std::da-nth 1 (cdr x))))
                   (available (nfix (std::da-nth 2 (cdr x)))))
                (cons :fewer-bytes-than-short-length
                      (list fragment required available))))
         (:fewer-bytes-than-length-of-length
              (b* ((fragment (byte-list-fix (std::da-nth 0 (cdr x))))
                   (required (nfix (std::da-nth 1 (cdr x))))
                   (available (nfix (std::da-nth 2 (cdr x)))))
                (cons :fewer-bytes-than-length-of-length
                      (list fragment required available))))
         (:fewer-bytes-than-long-length
              (b* ((fragment (byte-list-fix (std::da-nth 0 (cdr x))))
                   (required (nfix (std::da-nth 1 (cdr x))))
                   (available (nfix (std::da-nth 2 (cdr x)))))
                (cons :fewer-bytes-than-long-length
                      (list fragment required available))))
         (:leading-zeros-in-long-length
              (b* ((fragment (byte-list-fix (std::da-nth 0 (cdr x)))))
                (cons :leading-zeros-in-long-length (list fragment))))
         (:non-optimal-short-length
              (b* ((fragment (byte-list-fix (std::da-nth 0 (cdr x)))))
                (cons :non-optimal-short-length (list fragment))))
         (:non-optimal-long-length
              (b* ((fragment (byte-list-fix (std::da-nth 0 (cdr x)))))
                (cons :non-optimal-long-length (list fragment))))
         (:subtree (b* ((error (rlp-error-fix (std::da-nth 0 (cdr x)))))
                     (cons :subtree (list error))))
         (:extra-bytes
              (b* ((bytes (byte-list-fix (std::da-nth 0 (cdr x)))))
                (cons :extra-bytes (list bytes))))
         (:branch-tree
              (b* ((fragment (byte-list-fix (std::da-nth 0 (cdr x)))))
                (cons :branch-tree (list fragment))))
         (:leading-zeros-in-scalar
              (b* ((bytes (byte-list-fix (std::da-nth 0 (cdr x)))))
                (cons :leading-zeros-in-scalar (list bytes)))))
       :exec x)))

    Theorem: rlp-error-p-of-rlp-error-fix

    (defthm rlp-error-p-of-rlp-error-fix
      (b* ((new-x (rlp-error-fix$inline x)))
        (rlp-error-p new-x))
      :rule-classes :rewrite)

    Theorem: rlp-error-fix-when-rlp-error-p

    (defthm rlp-error-fix-when-rlp-error-p
      (implies (rlp-error-p x)
               (equal (rlp-error-fix x) x)))

    Function: rlp-error-equiv$inline

    (defun rlp-error-equiv$inline (acl2::x acl2::y)
      (declare (xargs :guard (and (rlp-error-p acl2::x)
                                  (rlp-error-p acl2::y))))
      (equal (rlp-error-fix acl2::x)
             (rlp-error-fix acl2::y)))

    Theorem: rlp-error-equiv-is-an-equivalence

    (defthm rlp-error-equiv-is-an-equivalence
      (and (booleanp (rlp-error-equiv x y))
           (rlp-error-equiv x x)
           (implies (rlp-error-equiv x y)
                    (rlp-error-equiv y x))
           (implies (and (rlp-error-equiv x y)
                         (rlp-error-equiv y z))
                    (rlp-error-equiv x z)))
      :rule-classes (:equivalence))

    Theorem: rlp-error-equiv-implies-equal-rlp-error-fix-1

    (defthm rlp-error-equiv-implies-equal-rlp-error-fix-1
      (implies (rlp-error-equiv acl2::x x-equiv)
               (equal (rlp-error-fix acl2::x)
                      (rlp-error-fix x-equiv)))
      :rule-classes (:congruence))

    Theorem: rlp-error-fix-under-rlp-error-equiv

    (defthm rlp-error-fix-under-rlp-error-equiv
      (rlp-error-equiv (rlp-error-fix acl2::x)
                       acl2::x)
      :rule-classes (:rewrite :rewrite-quoted-constant))

    Theorem: equal-of-rlp-error-fix-1-forward-to-rlp-error-equiv

    (defthm equal-of-rlp-error-fix-1-forward-to-rlp-error-equiv
      (implies (equal (rlp-error-fix acl2::x) acl2::y)
               (rlp-error-equiv acl2::x acl2::y))
      :rule-classes :forward-chaining)

    Theorem: equal-of-rlp-error-fix-2-forward-to-rlp-error-equiv

    (defthm equal-of-rlp-error-fix-2-forward-to-rlp-error-equiv
      (implies (equal acl2::x (rlp-error-fix acl2::y))
               (rlp-error-equiv acl2::x acl2::y))
      :rule-classes :forward-chaining)

    Theorem: rlp-error-equiv-of-rlp-error-fix-1-forward

    (defthm rlp-error-equiv-of-rlp-error-fix-1-forward
      (implies (rlp-error-equiv (rlp-error-fix acl2::x)
                                acl2::y)
               (rlp-error-equiv acl2::x acl2::y))
      :rule-classes :forward-chaining)

    Theorem: rlp-error-equiv-of-rlp-error-fix-2-forward

    (defthm rlp-error-equiv-of-rlp-error-fix-2-forward
      (implies (rlp-error-equiv acl2::x (rlp-error-fix acl2::y))
               (rlp-error-equiv acl2::x acl2::y))
      :rule-classes :forward-chaining)

    Theorem: rlp-error-kind$inline-of-rlp-error-fix-x

    (defthm rlp-error-kind$inline-of-rlp-error-fix-x
      (equal (rlp-error-kind$inline (rlp-error-fix x))
             (rlp-error-kind$inline x)))

    Theorem: rlp-error-kind$inline-rlp-error-equiv-congruence-on-x

    (defthm rlp-error-kind$inline-rlp-error-equiv-congruence-on-x
      (implies (rlp-error-equiv x x-equiv)
               (equal (rlp-error-kind$inline x)
                      (rlp-error-kind$inline x-equiv)))
      :rule-classes :congruence)

    Theorem: consp-of-rlp-error-fix

    (defthm consp-of-rlp-error-fix
      (consp (rlp-error-fix x))
      :rule-classes :type-prescription)