• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
    • Debugging
    • Std
    • Proof-automation
    • Macro-libraries
    • ACL2
    • Interfacing-tools
    • Hardware-verification
    • Software-verification
      • Kestrel-books
        • Crypto-hdwallet
        • Apt
        • Error-checking
        • Fty-extensions
        • Isar
        • Kestrel-utilities
        • Set
        • Soft
        • C
        • Bv
        • Imp-language
          • Semantics
          • Abstract-syntax
            • Aexp
            • Bexp
              • Bexp-case
              • Bexp-fix
              • Bexpp
              • Bexp-count
                • Bexp-equiv
                • Bexp-less
                • Bexp-equal
                • Bexp-and
                • Bexp-const
                • Bexp-not
                • Bexp-kind
              • Comm
              • Comm-list
              • Command-fixtypes
            • Interpreter
          • Event-macros
          • Java
          • Bitcoin
          • Ethereum
          • Yul
          • Zcash
          • ACL2-programming-language
          • Prime-fields
          • Json
          • Syntheto
          • File-io-light
          • Cryptography
          • Number-theory
          • Lists-light
          • Axe
          • Builtins
          • Solidity
          • Helpers
          • Htclient
          • Typed-lists-light
          • Arithmetic-light
        • X86isa
        • Axe
        • Execloader
      • Math
      • Testing-utilities
    • Bexp

    Bexp-count

    Measure for recurring over bexp structures.

    Signature
    (bexp-count x) → count
    Arguments
    x — Guard (bexpp x).
    Returns
    count — Type (natp count).

    Definitions and Theorems

    Function: bexp-count

    (defun bexp-count (x)
      (declare (xargs :guard (bexpp x)))
      (let ((__function__ 'bexp-count))
        (declare (ignorable __function__))
        (case (bexp-kind x)
          (:const 1)
          (:equal 1)
          (:less 1)
          (:not (+ 2 (bexp-count (bexp-not->arg x))))
          (:and (+ 3 (bexp-count (bexp-and->left x))
                   (bexp-count (bexp-and->right x)))))))

    Theorem: natp-of-bexp-count

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

    Theorem: bexp-count-of-bexp-fix-x

    (defthm bexp-count-of-bexp-fix-x
      (equal (bexp-count (bexp-fix x))
             (bexp-count x)))

    Theorem: bexp-count-bexp-equiv-congruence-on-x

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

    Theorem: bexp-count-of-bexp-not

    (defthm bexp-count-of-bexp-not
      (implies t
               (< (+ (bexp-count arg))
                  (bexp-count (bexp-not arg))))
      :rule-classes :linear)

    Theorem: bexp-count-of-bexp-not->arg

    (defthm bexp-count-of-bexp-not->arg
      (implies (equal (bexp-kind x) :not)
               (< (bexp-count (bexp-not->arg x))
                  (bexp-count x)))
      :rule-classes :linear)

    Theorem: bexp-count-of-bexp-and

    (defthm bexp-count-of-bexp-and
      (implies t
               (< (+ (bexp-count left) (bexp-count right))
                  (bexp-count (bexp-and left right))))
      :rule-classes :linear)

    Theorem: bexp-count-of-bexp-and->left

    (defthm bexp-count-of-bexp-and->left
      (implies (equal (bexp-kind x) :and)
               (< (bexp-count (bexp-and->left x))
                  (bexp-count x)))
      :rule-classes :linear)

    Theorem: bexp-count-of-bexp-and->right

    (defthm bexp-count-of-bexp-and->right
      (implies (equal (bexp-kind x) :and)
               (< (bexp-count (bexp-and->right x))
                  (bexp-count x)))
      :rule-classes :linear)