• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
      • Apt
      • Zfc
      • Acre
      • Milawa
      • Smtlink
      • Abnf
      • Vwsim
      • Isar
      • Pfcs
      • Wp-gen
      • Dimacs-reader
      • Legacy-defrstobj
      • Proof-checker-array
      • Soft
      • C
      • Farray
      • Rp-rewriter
      • Instant-runoff-voting
      • Imp-language
      • Sidekick
      • Leftist-trees
      • Java
      • Taspi
      • Riscv
      • Bitcoin
      • 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
        • Aleo
        • Bigmems
        • Builtins
        • Execloader
        • Solidity
        • Paco
        • Concurrent-programs
        • Bls12-377-curves
      • Debugging
      • Std
      • Community
      • Proof-automation
      • ACL2
      • Macro-libraries
      • Interfacing-tools
      • Hardware-verification
      • Software-verification
      • Math
      • Testing-utilities
    • Rlp-error

    Rlp-error-count

    Measure for recurring over rlp-error structures.

    Signature
    (rlp-error-count x) → count
    Arguments
    x — Guard (rlp-error-p x).
    Returns
    count — Type (natp count).

    Definitions and Theorems

    Function: rlp-error-count

    (defun rlp-error-count (x)
      (declare (xargs :guard (rlp-error-p x)))
      (let ((__function__ 'rlp-error-count))
        (declare (ignorable __function__))
        (case (rlp-error-kind x)
          (:no-bytes 1)
          (:fewer-bytes-than-short-length 1)
          (:fewer-bytes-than-length-of-length 1)
          (:fewer-bytes-than-long-length 1)
          (:leading-zeros-in-long-length 1)
          (:non-optimal-short-length 1)
          (:non-optimal-long-length 1)
          (:subtree (+ 2
                       (rlp-error-count (rlp-error-subtree->error x))))
          (:extra-bytes 1)
          (:branch-tree 1)
          (:leading-zeros-in-scalar 1))))

    Theorem: natp-of-rlp-error-count

    (defthm natp-of-rlp-error-count
      (b* ((count (rlp-error-count x)))
        (natp count))
      :rule-classes :type-prescription)

    Theorem: rlp-error-count-of-rlp-error-fix-x

    (defthm rlp-error-count-of-rlp-error-fix-x
      (equal (rlp-error-count (rlp-error-fix x))
             (rlp-error-count x)))

    Theorem: rlp-error-count-rlp-error-equiv-congruence-on-x

    (defthm rlp-error-count-rlp-error-equiv-congruence-on-x
      (implies (rlp-error-equiv x x-equiv)
               (equal (rlp-error-count x)
                      (rlp-error-count x-equiv)))
      :rule-classes :congruence)

    Theorem: rlp-error-count-of-rlp-error-subtree

    (defthm rlp-error-count-of-rlp-error-subtree
      (implies t
               (< (+ (rlp-error-count error))
                  (rlp-error-count (rlp-error-subtree error))))
      :rule-classes :linear)

    Theorem: rlp-error-count-of-rlp-error-subtree->error

    (defthm rlp-error-count-of-rlp-error-subtree->error
      (implies (equal (rlp-error-kind x) :subtree)
               (< (rlp-error-count (rlp-error-subtree->error x))
                  (rlp-error-count x)))
      :rule-classes :linear)