• 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
        • Apply$
        • Defpkg
        • 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

    Complex

    Create an ACL2 number

    Examples:
    (complex x 3) ; x + 3i, where i is the principal square root of -1
    (complex x y) ; x + yi
    (complex x 0) ; same as x, for rational numbers x

    The function complex takes two rational number arguments and returns an ACL2 number. This number will be of type (complex rational) [as defined in the Common Lisp language], except that if the second argument is zero, then complex returns its first argument. The function complex-rationalp is a recognizer for complex rational numbers, i.e. for ACL2 numbers that are not rational numbers.

    The reader macro #C (which is the same as #c) provides a convenient way for typing in complex numbers. For explicit rational numbers x and y, #C(x y) is read to the same value as (complex x y).

    The functions realpart and imagpart return the real and imaginary parts (respectively) of a complex (possibly rational) number. So for example, (realpart #C(3 4)) = 3, (imagpart #C(3 4)) = 4, (realpart 3/4) = 3/4, and (imagpart 3/4) = 0.

    The following built-in axiom may be useful for reasoning about complex numbers.

    (defaxiom complex-definition
      (implies (and (real/rationalp x)
                    (real/rationalp y))
               (equal (complex x y)
                      (+ x (* #c(0 1) y))))
      :rule-classes nil)

    A completion axiom that shows what complex returns on arguments violating its guard (which says that both arguments are rational numbers) is the following, named completion-of-complex.

    (equal (complex x y)
           (complex (if (rationalp x) x 0)
                    (if (rationalp y) y 0)))