• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
    • Debugging
    • Std
    • Proof-automation
    • Macro-libraries
    • ACL2
      • Theories
      • Rule-classes
      • Proof-builder
      • Recursion-and-induction
      • Hons-and-memoization
      • Events
      • Parallelism
      • History
      • Programming
        • Defun
        • Declare
        • System-utilities
        • Stobj
        • State
        • Mutual-recursion
        • Memoize
        • Mbe
        • Io
        • Defpkg
        • Apply$
        • Loop$
        • Programming-with-state
          • Error-triple
            • Cbd
            • State-global-let*
            • Last-prover-steps
            • @
            • Assign
            • Read-run-time
            • Canonical-pathname
            • F-put-global
            • Unsound-eval
            • Setenv$
            • Er-progn
            • Read-ACL2-oracle
            • With-live-state
            • F-get-global
            • Getenv$
            • Pprogn
            • Get-real-time
            • Makunbound-global
            • Get-cpu-time
            • F-boundp-global
            • Probe-file
          • Arrays
          • Characters
          • Time$
          • Defmacro
          • Loop$-primer
          • Fast-alists
          • Defconst
          • Evaluation
          • Guard
          • Equality-variants
          • Compilation
          • Hons
          • ACL2-built-ins
          • Developers-guide
          • System-attachments
          • Advanced-features
          • Set-check-invariant-risk
          • Numbers
          • Efficiency
          • Irrelevant-formals
          • 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
          • Oracle-eval
          • Defmacro-untouchable
          • <<
          • Primitive
          • Revert-world
          • Unmemoize
          • Set-duplicate-keys-action
          • Symbols
          • Def-list-constructor
          • Easy-simplify-term
          • Defiteration
          • Fake-oracle-eval
          • Defopen
          • Sleep
        • Operational-semantics
        • Real
        • Start-here
        • Debugging
        • Miscellaneous
        • Output-controls
        • Macros
        • Interfacing-tools
      • Interfacing-tools
      • Hardware-verification
      • Software-verification
      • Math
      • Testing-utilities
    • Errors
    • Programming-with-state

    Error-triple

    A common ACL2 programming idiom

    When evaluation returns three values, where the first two are ordinary (non-stobj) objects and the third is the ACL2 state, the result may be called an ``error triple'' or ``error-triple''. If an error triple is (mv erp val state), we think of erp as an error flag and val as the returned value. By default, if the result of evaluating a top-level form is an error triple (mv erp val state), then that result is not printed if erp is non-nil or if val is the keyword :INVISIBLE, and otherwise val is printed with a preceding space. For example:

    ACL2 !>(+ 3 4) ; ordinary value
    7
    ACL2 !>(mv nil (+ 3 4) state) ; error triple, error component of nil
     7
    ACL2 !>(mv t (+ 3 4) state) ; error triple, non-nil error component
    ACL2 !>(mv nil :invisible state) ; special case for :INVISIBLE
    ACL2 !>

    In certain settings, notably when printing evaluation results, multiple values (mv erp val state) may be considered an error triple even when val is a df rather than an ordinary object. Here is an example; see df for more about how floating-point numbers are simulated in ACL2.

    ACL2 !>(mv nil (to-df 3) state)
     #d3.0
    ACL2 !>

    See programming-with-state for a discussion of error triples and how to program with them. Also see ld-error-triples and see ld for a discussion of the value :COMMAND-CONVENTIONS for keyword :LD-POST-EVAL-PRINT.