• 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
      • Sidekick
      • Leftist-trees
      • Java
      • Riscv
      • Taspi
      • Bitcoin
      • 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
      • Aleo
        • Aleobft
        • Aleovm
        • Leo
          • Grammar
          • Early-version
            • Json2ast
            • Testing
            • Definition
              • Flattening
              • Abstract-syntax
              • Dynamic-semantics
                • Execution
                • Values
                • Dynamic-environments
                • Arithmetic-operations
                  • Integer-arithmetic-operations
                    • Op-int-rem-wrapped
                    • Op-int-div-wrapped
                    • Op-int-div
                    • Op-int-sub-wrapped
                    • Op-int-sub
                      • Op-int-mul-wrapped
                      • Op-int-mul
                      • Op-int-add-wrapped
                      • Op-int-add
                      • Op-int-rem
                      • Op-int-pow-wrapped
                      • Op-int-pow
                      • Op-int-abs-wrapped
                      • Op-int-neg
                      • Op-int-abs
                    • Field-arithmetic-operations
                    • Scalar-field-arithmetic-operations
                    • Group-arithmetic-operations
                    • Op-mul
                    • Op-add
                    • Op-sub-wrapped
                    • Op-sub
                    • Op-rem-wrapped
                    • Op-pow-wrapped
                    • Op-pow
                    • Op-mul-wrapped
                    • Op-div-wrapped
                    • Op-div
                    • Op-add-wrapped
                    • Op-rem
                    • Op-square-root
                    • Op-square
                    • Op-neg
                    • Op-inv
                    • Op-double
                    • Op-abs-wrapped
                    • Op-abs
                  • Curve-parameterization
                  • Shift-operations
                  • Errors
                  • Value-expressions
                  • Locations
                  • Input-execution
                  • Edwards-bls12-generator
                  • Equality-operations
                  • Logical-operations
                  • Program-execution
                  • Ordering-operations
                  • Bitwise-operations
                  • Literal-evaluation
                  • Type-maps-for-struct-components
                  • Output-execution
                  • Tuple-operations
                  • Struct-operations
                • Compilation
                • Static-semantics
                • Concrete-syntax
        • Bigmems
        • Builtins
        • Execloader
        • Solidity
        • Paco
        • Concurrent-programs
        • Bls12-377-curves
      • Debugging
      • Community
      • Std
      • Proof-automation
      • Macro-libraries
      • ACL2
      • Interfacing-tools
      • Hardware-verification
      • Software-verification
      • Math
      • Testing-utilities
    • Integer-arithmetic-operations

    Op-int-sub

    Leo integer subtraction operation.

    Signature
    (op-int-sub left right) → result
    Arguments
    left — Guard (int-valuep left).
    right — Guard (int-valuep right).
    Returns
    result — Type (value-resultp result).

    Definitions and Theorems

    Function: op-int-sub

    (defun op-int-sub (left right)
      (declare (xargs :guard (and (int-valuep left)
                                  (int-valuep right))))
      (let ((__function__ 'op-int-sub))
        (declare (ignorable __function__))
        (b* ((err (reserrf (list :op-int-sub (value-fix left)
                                 (value-fix right)))))
          (cond ((and (value-case left :u8)
                      (value-case right :u8))
                 (b* ((res (- (value-u8->get left)
                              (value-u8->get right))))
                   (if (ubyte8p res) (value-u8 res) err)))
                ((and (value-case left :u16)
                      (value-case right :u16))
                 (b* ((res (- (value-u16->get left)
                              (value-u16->get right))))
                   (if (ubyte16p res)
                       (value-u16 res)
                     err)))
                ((and (value-case left :u32)
                      (value-case right :u32))
                 (b* ((res (- (value-u32->get left)
                              (value-u32->get right))))
                   (if (ubyte32p res)
                       (value-u32 res)
                     err)))
                ((and (value-case left :u64)
                      (value-case right :u64))
                 (b* ((res (- (value-u64->get left)
                              (value-u64->get right))))
                   (if (ubyte64p res)
                       (value-u64 res)
                     err)))
                ((and (value-case left :u128)
                      (value-case right :u128))
                 (b* ((res (- (value-u128->get left)
                              (value-u128->get right))))
                   (if (ubyte128p res)
                       (value-u128 res)
                     err)))
                ((and (value-case left :i8)
                      (value-case right :i8))
                 (b* ((res (- (value-i8->get left)
                              (value-i8->get right))))
                   (if (sbyte8p res) (value-i8 res) err)))
                ((and (value-case left :i16)
                      (value-case right :i16))
                 (b* ((res (- (value-i16->get left)
                              (value-i16->get right))))
                   (if (sbyte16p res)
                       (value-i16 res)
                     err)))
                ((and (value-case left :i32)
                      (value-case right :i32))
                 (b* ((res (- (value-i32->get left)
                              (value-i32->get right))))
                   (if (sbyte32p res)
                       (value-i32 res)
                     err)))
                ((and (value-case left :i64)
                      (value-case right :i64))
                 (b* ((res (- (value-i64->get left)
                              (value-i64->get right))))
                   (if (sbyte64p res)
                       (value-i64 res)
                     err)))
                ((and (value-case left :i128)
                      (value-case right :i128))
                 (b* ((res (- (value-i128->get left)
                              (value-i128->get right))))
                   (if (sbyte128p res)
                       (value-i128 res)
                     err)))
                (t err)))))

    Theorem: value-resultp-of-op-int-sub

    (defthm value-resultp-of-op-int-sub
      (b* ((result (op-int-sub left right)))
        (value-resultp result))
      :rule-classes :rewrite)

    Theorem: op-int-sub-of-value-fix-left

    (defthm op-int-sub-of-value-fix-left
      (equal (op-int-sub (value-fix left) right)
             (op-int-sub left right)))

    Theorem: op-int-sub-value-equiv-congruence-on-left

    (defthm op-int-sub-value-equiv-congruence-on-left
      (implies (value-equiv left left-equiv)
               (equal (op-int-sub left right)
                      (op-int-sub left-equiv right)))
      :rule-classes :congruence)

    Theorem: op-int-sub-of-value-fix-right

    (defthm op-int-sub-of-value-fix-right
      (equal (op-int-sub left (value-fix right))
             (op-int-sub left right)))

    Theorem: op-int-sub-value-equiv-congruence-on-right

    (defthm op-int-sub-value-equiv-congruence-on-right
      (implies (value-equiv right right-equiv)
               (equal (op-int-sub left right)
                      (op-int-sub left right-equiv)))
      :rule-classes :congruence)