• Top
    • Documentation
    • Books
    • Recursion-and-induction
    • Boolean-reasoning
    • Projects
    • Debugging
    • Std
    • Proof-automation
    • Macro-libraries
    • ACL2
      • Theories
      • Rule-classes
      • Proof-builder
      • Hons-and-memoization
      • Events
      • History
      • Parallelism
      • Programming
        • Defun
        • Declare
        • System-utilities
        • Stobj
        • State
        • Memoize
        • Mbe
        • Io
        • Defpkg
        • Apply$
        • Mutual-recursion
        • Loop$
        • Programming-with-state
        • Arrays
        • Characters
        • Time$
        • Loop$-primer
        • Fast-alists
        • Defmacro
        • Defconst
        • Evaluation
        • Guard
        • Equality-variants
        • Compilation
        • Hons
        • ACL2-built-ins
        • Developers-guide
        • System-attachments
        • Advanced-features
        • Set-check-invariant-risk
        • Numbers
          • Natp
          • Unsigned-byte-p
          • Posp
          • +
          • Bitp
          • Zero-test-idioms
          • Nat-listp
          • Integerp
          • <
          • *
          • Zp
          • -
            • Signed-byte-p
            • Logbitp
            • Expt
            • Ash
            • Rationalp
            • Sharp-f-reader
            • Logand
            • =
            • <=
            • Floor
            • Random$
            • Nfix
            • Truncate
            • Complex
            • Numbers-introduction
            • Code-char
            • Integer-length
            • Zip
            • Logior
            • Sharp-u-reader
            • Char-code
            • Unary--
            • Integer-listp
            • Boole$
            • /
            • Mod
            • Logxor
            • Lognot
            • Integer-range-p
            • Ifix
            • ACL2-numberp
            • Ceiling
            • Mod-expt
            • Round
            • Logeqv
            • Explode-nonnegative-integer
            • Max
            • Evenp
            • Nonnegative-integer-quotient
            • Zerop
            • Abs
            • Fix
            • Allocate-fixnum-range
            • Rem
            • 1+
            • Pos-listp
            • Signum
            • Real/rationalp
            • Rational-listp
            • Rfix
            • >=
            • >
            • Logcount
            • ACL2-number-listp
            • /=
            • Unary-/
            • Complex/complex-rationalp
            • Logtest
            • Logandc1
            • Logorc1
            • Logandc2
            • 1-
            • Numerator
            • Logorc2
            • Denominator
            • The-number
            • Realfix
            • Complex-rationalp
            • Min
            • Lognor
            • Zpf
            • Oddp
            • Minusp
            • Lognand
            • Imagpart
            • Conjugate
            • Int=
            • Realpart
            • Plusp
          • Irrelevant-formals
          • Efficiency
          • Introduction-to-programming-in-ACL2-for-those-who-know-lisp
          • Redefining-programs
          • Lists
          • Invariant-risk
          • Errors
          • Defabbrev
          • Conses
          • Alists
          • Set-register-invariant-risk
          • Strings
          • Program-wrapper
          • Get-internal-time
          • Basics
          • Packages
          • Defmacro-untouchable
          • Primitive
          • <<
          • Revert-world
          • Set-duplicate-keys-action
          • Unmemoize
          • Symbols
          • Def-list-constructor
          • Easy-simplify-term
          • Defiteration
          • Defopen
          • Sleep
        • Start-here
        • Real
        • Debugging
        • Miscellaneous
        • Output-controls
        • Macros
        • Interfacing-tools
      • Interfacing-tools
      • Hardware-verification
      • Software-verification
      • Testing-utilities
      • Math
    • Numbers
    • ACL2-built-ins

    -

    Macro for subtraction and negation

    See binary-+ for addition and see unary-- for negation.

    Note that - represents subtraction as follows:

    (- x y)

    represents the same term as

    (+ x (- y))

    which is really

    (binary-+ x (unary-- y)).

    Also note that - represents arithmetic negation as follows:

    (- x)

    expands to

    (unary-- x).

    Macro: -

    (defmacro
         - (x &optional (y 'nil binary-casep))
         (if binary-casep
             (let ((y (if (and (consp y)
                               (eq (car y) 'quote)
                               (consp (cdr y))
                               (acl2-numberp (car (cdr y)))
                               (eq (cdr (cdr y)) nil))
                          (car (cdr y))
                          y)))
                  (if (acl2-numberp y)
                      (cons 'binary-+
                            (cons (unary-- y) (cons x nil)))
                      (cons 'binary-+
                            (cons x
                                  (cons (cons 'unary-- (cons y nil))
                                        nil)))))
             (let ((x (if (and (consp x)
                               (eq (car x) 'quote)
                               (consp (cdr x))
                               (acl2-numberp (car (cdr x)))
                               (eq (cdr (cdr x)) nil))
                          (car (cdr x))
                          x)))
                  (if (acl2-numberp x)
                      (unary-- x)
                      (cons 'unary-- (cons x nil))))))