• 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
        • 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
        • Sidekick
        • Leftist-trees
        • Java
        • Taspi
        • Bitcoin
        • Riscv
        • Des
        • Ethereum
        • 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
    • 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)