• Top
    • Documentation
    • Books
    • Recursion-and-induction
    • Boolean-reasoning
    • Debugging
    • Projects
    • 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
        • System-attachments
        • Developers-guide
        • 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
          • Let
          • Return-last
          • Mv-let
          • Or
            • Flet
            • Mv
            • And
            • Booleanp
            • If
            • Not
            • Equal
            • Implies
            • Iff
            • Quote
            • Macrolet
            • Let*
            • Case-match
            • ACL2-count
            • Good-bye
            • Case
            • Cond
            • Null
            • Progn$
            • Identity
            • Xor
          • 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
    • Basics
    • ACL2-built-ins

    Or

    Disjunction

    Or is the macro for disjunctions. Or takes any number of arguments and returns the first that is non-nil, or nil if there is no non-nil element.

    (Note: If you are seeking documentation for the :or hint, see hints.)

    In the ACL2 logic, the macroexpansion of (or x y) is an IF term that appears to cause x to be evaluated twice:

    ACL2 !>:trans (or x y)
    
    (IF X X Y)
    
    => *
    
    ACL2 !>

    If x were replaced by an expression whose evaluation takes a long time, then such an expansion would be inefficient. However, don't be fooled: you can expect Common Lisp implementations to avoid this problem, say by generating a new variable, for example:

    ACL2 !>:q ; Exit the ACL2 loop and go into raw Common Lisp
    
    Exiting the ACL2 read-eval-print loop.  To re-enter, execute (LP).
    ACL2>(macroexpand '(or x y))
    
    (LET ((#:G5374 X)) (IF #:G5374 #:G5374 Y))
    T
    
    ACL2>

    Or is a Common Lisp macro. See any Common Lisp documentation for more information.

    Macro: or

    (defmacro or (&rest args)
              (or-macro args))

    Function: or-macro

    (defun or-macro (lst)
           (declare (xargs :guard t))
           (if (consp lst)
               (if (consp (cdr lst))
                   (list 'if
                         (car lst)
                         (car lst)
                         (or-macro (cdr lst)))
                   (car lst))
               nil))