• 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
        • 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
        • <<
          • Alphorder
          • Lexorder
          • Fast-<<
          • 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
    • <<

    Fast-<<

    Probably faster alternative to <<.

    (fast-<< x y) is logically the same as (<< x y). However, it is probably faster because:

    1. it rearranges the check as in fast-lexorder, and
    2. it folds in the not-equal check.

    Definitions and Theorems

    Function: fast-<<

    (defun
     fast-<< (x y)
     (declare (xargs :guard t))
     (cond
        ((atom x)
         (if (atom y)
             (cond ((integerp x)
                    (cond ((integerp y) (< x y))
                          ((real/rationalp y) (< x y))
                          (t t)))
                   ((symbolp x)
                    (if (symbolp y)
                        (and (not (eq x y)) (symbol< x y) t)
                        (not (or (integerp y)
                                 (stringp y)
                                 (characterp y)
                                 (real/rationalp y)
                                 (complex/complex-rationalp y)))))
                   ((stringp x)
                    (cond ((stringp y) (and (string< x y) t))
                          ((integerp y) nil)
                          ((symbolp y) t)
                          (t (not (or (characterp y)
                                      (real/rationalp y)
                                      (complex/complex-rationalp y))))))
                   ((characterp x)
                    (cond ((characterp y)
                           (< (char-code x) (char-code y)))
                          (t (not (or (integerp y)
                                      (real/rationalp y)
                                      (complex/complex-rationalp y))))))
                   ((real/rationalp x)
                    (cond ((integerp y) (< x y))
                          ((real/rationalp y) (< x y))
                          (t t)))
                   ((real/rationalp y) nil)
                   ((complex/complex-rationalp x)
                    (cond ((complex/complex-rationalp y)
                           (or (< (realpart x) (realpart y))
                               (and (= (realpart x) (realpart y))
                                    (< (imagpart x) (imagpart y)))))
                          (t t)))
                   ((or (symbolp y)
                        (stringp y)
                        (characterp y)
                        (complex/complex-rationalp y))
                    nil)
                   (t (and (bad-atom<= x y)
                           (not (equal x y)))))
             t))
        ((atom y) nil)
        ((equal (car x) (car y))
         (fast-<< (cdr x) (cdr y)))
        (t (fast-<< (car x) (car y)))))

    Theorem: fast-<<-is-<<

    (defthm fast-<<-is-<<
            (equal (fast-<< x y) (<< x y)))