• 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
              • Aexp-case
              • Aexp-fix
              • Aexpp
              • Aexp-count
                • Aexp-equiv
                • Aexp-mul
                • Aexp-add
                • Aexp-var
                • Aexp-const
                • Aexp-kind
              • Bexp
              • 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
    • Aexp

    Aexp-count

    Measure for recurring over aexp structures.

    Signature
    (aexp-count x) → count
    Arguments
    x — Guard (aexpp x).
    Returns
    count — Type (natp count).

    Definitions and Theorems

    Function: aexp-count

    (defun aexp-count (x)
      (declare (xargs :guard (aexpp x)))
      (let ((__function__ 'aexp-count))
        (declare (ignorable __function__))
        (case (aexp-kind x)
          (:const 1)
          (:var 1)
          (:add (+ 3 (aexp-count (aexp-add->left x))
                   (aexp-count (aexp-add->right x))))
          (:mul (+ 3 (aexp-count (aexp-mul->left x))
                   (aexp-count (aexp-mul->right x)))))))

    Theorem: natp-of-aexp-count

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

    Theorem: aexp-count-of-aexp-fix-x

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

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

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

    Theorem: aexp-count-of-aexp-add

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

    Theorem: aexp-count-of-aexp-add->left

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

    Theorem: aexp-count-of-aexp-add->right

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

    Theorem: aexp-count-of-aexp-mul

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

    Theorem: aexp-count-of-aexp-mul->left

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

    Theorem: aexp-count-of-aexp-mul->right

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