• 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
        • 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
          • Er
          • Value-triple
          • Error-checking
          • Error-triple
          • Assert-event
          • Set-warnings-as-errors
          • Hard-error
          • Set-inhibit-er
          • Must-fail
          • Assert!-stobj
          • Breaks
          • Must-eval-to
          • Ctx
          • Assert!
          • Must-succeed
            • Must-succeed*
          • Assert$
          • Ctxp
          • Illegal
          • Er-progn
          • Error1
          • Er-hard
          • Must-succeed*
          • Toggle-inhibit-er
          • Break$
          • Assert*
          • Assert?
          • Er-soft+
          • Er-hard?
          • Must-fail-with-soft-error
          • Must-fail-with-hard-error
          • Must-fail-with-error
          • Must-eval-to-t
          • Er-soft-logic
          • Er-soft
          • Convert-soft-error
          • Toggle-inhibit-er!
          • Set-inhibit-er!
          • Must-prove
          • Must-not-prove
          • Must-fail!
          • Must-be-redundant
          • Must-succeed!
          • Must-fail-local
          • Assert-equal
        • 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
  • Std/testing
  • Errors

Must-succeed

A top-level assert$-like command. Ensures that a command which returns an error-triple—e.g., a defun or defthm—will return successfully.

This can be useful for adding simple unit tests of macros, theories, etc. to your books. Basic examples:

(must-succeed                  ;; works fine
  (defun f (x) (consp x)))     ;;   (NOTE: F not defined afterwards!)

(must-succeed                  ;; causes an error
  (defthm bad-theorem nil))    ;;   (unless we can prove NIL!)

(must-succeed                  ;; causes an error
  (set-cbd 17))                ;;   (because 17 isn't a string)

See also must-fail.

General form:
(must-succeed form
              [:with-output-off items]  ;; default:  :all
              [:check-expansion bool]
              )

The form should evaluate to an error-triple, which is true for most top-level ACL2 events and other high level commands.

The form is submitted in a make-event, which has a number of consequences. Most importantly, when form is an event like a defun, or defthm, it doesn't persist after the must-succeed form. Other state updates do persist, e.g.,

(must-succeed (assign foo 5))   ;; works fine
(@ foo)                         ;; 5

See the make-event documentation for details.

Options

with-output-off. By default, all output from form is suppressed, but you can customize this. Typical example:

(must-succeed
  (defun f (x) (consp x))
  :with-output-off nil)    ;; don't suppress anything

check-expansion. By default the form won't be re-run and re-checked at include-book time. But you can use :check-expansion to customize this, as in make-event.

Also see must-succeed!.

Subtopics

Must-succeed*
A variant of must-succeed that accepts multiple forms.