• 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
            • 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
        • 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
    • 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)