• 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
          • Syntax-for-tools
          • Atc
          • Language
            • Abstract-syntax
            • Integer-ranges
            • Implementation-environments
            • Dynamic-semantics
            • Static-semantics
            • Grammar
            • Integer-formats
            • Types
            • Portable-ascii-identifiers
            • Values
            • Integer-operations
            • Computation-states
            • Object-designators
            • Operations
            • Errors
            • Tag-environments
            • Function-environments
            • Character-sets
            • Flexible-array-member-removal
            • Arithmetic-operations
              • Sub-arithmetic-values
                • Rem-arithmetic-values
                • Ne-arithmetic-values
                • Mul-arithmetic-values
                • Eq-arithmetic-values
                • Div-arithmetic-values
                • Add-arithmetic-values
                • Plus-arithmetic-value
                • Minus-arithmetic-value
              • Pointer-operations
              • Bytes
              • Keywords
              • Real-operations
              • Array-operations
              • Scalar-operations
              • Structure-operations
            • Representation
            • Transformation-tools
            • Insertion-sort
            • Pack
          • Bv
          • Imp-language
          • 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
    • Arithmetic-operations

    Sub-arithmetic-values

    Apply binary - to arithmetic values [C17:6.5.6/4] [C17:6.5.6/6].

    Signature
    (sub-arithmetic-values val1 val2) → resval
    Arguments
    val1 — Guard (valuep val1).
    val2 — Guard (valuep val2).
    Returns
    resval — Type (value-resultp resval).

    We perform the usual arithmetic conversions and then we apply the operation on the integers. In our current formalization, integers are the only arithmetic values. This ACL2 function will be extended with more cases if/when we extend our model with non-integer arithmetic values.

    Definitions and Theorems

    Function: sub-arithmetic-values

    (defun sub-arithmetic-values (val1 val2)
      (declare (xargs :guard (and (valuep val1) (valuep val2))))
      (declare (xargs :guard (and (value-arithmeticp val1)
                                  (value-arithmeticp val2))))
      (let ((__function__ 'sub-arithmetic-values))
        (declare (ignorable __function__))
        (b* (((mv val1 val2)
              (uaconvert-values val1 val2)))
          (sub-integer-values val1 val2))))

    Theorem: value-resultp-of-sub-arithmetic-values

    (defthm value-resultp-of-sub-arithmetic-values
      (b* ((resval (sub-arithmetic-values val1 val2)))
        (value-resultp resval))
      :rule-classes :rewrite)

    Theorem: sub-arithmetic-values-of-value-fix-val1

    (defthm sub-arithmetic-values-of-value-fix-val1
      (equal (sub-arithmetic-values (value-fix val1)
                                    val2)
             (sub-arithmetic-values val1 val2)))

    Theorem: sub-arithmetic-values-value-equiv-congruence-on-val1

    (defthm sub-arithmetic-values-value-equiv-congruence-on-val1
      (implies (value-equiv val1 val1-equiv)
               (equal (sub-arithmetic-values val1 val2)
                      (sub-arithmetic-values val1-equiv val2)))
      :rule-classes :congruence)

    Theorem: sub-arithmetic-values-of-value-fix-val2

    (defthm sub-arithmetic-values-of-value-fix-val2
      (equal (sub-arithmetic-values val1 (value-fix val2))
             (sub-arithmetic-values val1 val2)))

    Theorem: sub-arithmetic-values-value-equiv-congruence-on-val2

    (defthm sub-arithmetic-values-value-equiv-congruence-on-val2
      (implies (value-equiv val2 val2-equiv)
               (equal (sub-arithmetic-values val1 val2)
                      (sub-arithmetic-values val1 val2-equiv)))
      :rule-classes :congruence)