• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
    • Debugging
    • Std
    • Proof-automation
    • Macro-libraries
      • B*
      • Defunc
      • Fty
      • Apt
      • Std/util
      • Defdata
      • Defrstobj
      • Seq
      • Match-tree
      • Defrstobj
      • With-supporters
      • Def-partial-measure
      • Template-subst
      • Soft
      • Defthm-domain
      • Event-macros
        • Evmac-input-hints-p
        • Evmac-input-print-p
        • Function-definedness
        • Event-macro-input-processing
        • Event-macro-screen-printing
        • Make-event-terse
        • Event-macro-applicability-conditions
        • Event-macro-results
        • Template-generators
        • Event-macro-event-generators
        • Event-macro-proof-preparation
        • Try-event
          • Restore-output?
          • Restore-output
          • Fail-event
          • Cw-event
          • Event-macro-xdoc-constructors
          • Event-macro-intro-macros
        • Def-universal-equiv
        • Def-saved-obligs
        • With-supporters-after
        • Definec
        • Sig
        • Outer-local
        • Data-structures
      • ACL2
        • Theories
        • Rule-classes
        • Proof-builder
        • Recursion-and-induction
        • Hons-and-memoization
        • Events
        • Parallelism
        • History
        • Programming
        • Operational-semantics
        • Real
        • Start-here
        • Debugging
        • Miscellaneous
        • Output-controls
        • Macros
          • Make-event
          • Defmacro
          • Untranslate-patterns
          • Tc
          • Trans*
          • Macro-aliases-table
          • Macro-args
          • Defabbrev
          • User-defined-functions-table
          • Trans
          • Untranslate-for-execution
          • Add-macro-fn
          • Check-vars-not-free
          • Safe-mode
          • Macro-libraries
            • B*
            • Defunc
            • Fty
            • Apt
            • Std/util
            • Defdata
            • Defrstobj
            • Seq
            • Match-tree
            • Defrstobj
            • With-supporters
            • Def-partial-measure
            • Template-subst
            • Soft
            • Defthm-domain
            • Event-macros
              • Evmac-input-hints-p
              • Evmac-input-print-p
              • Function-definedness
              • Event-macro-input-processing
              • Event-macro-screen-printing
              • Make-event-terse
              • Event-macro-applicability-conditions
              • Event-macro-results
              • Template-generators
              • Event-macro-event-generators
              • Event-macro-proof-preparation
              • Try-event
                • Restore-output?
                • Restore-output
                • Fail-event
                • Cw-event
                • Event-macro-xdoc-constructors
                • Event-macro-intro-macros
              • Def-universal-equiv
              • Def-saved-obligs
              • With-supporters-after
              • Definec
              • Sig
              • Outer-local
              • Data-structures
            • Trans1
            • Defmacro-untouchable
            • Set-duplicate-keys-action
            • Add-macro-alias
            • Magic-macroexpand
            • Defmacroq
            • Trans!
            • Remove-macro-fn
            • Remove-macro-alias
            • Add-binop
            • Untrans-table
            • Trans*-
            • Remove-binop
            • Tcp
            • Tca
          • Interfacing-tools
        • Interfacing-tools
        • Hardware-verification
        • Software-verification
        • Math
        • Testing-utilities
      • Event-macros

      Try-event

      Try to submit an event, generating a customized error if the submission fails.

      Signature
      (try-event form ctx erp val msg) → event
      Arguments
      msg — Guard (msgp msg).
      Returns
      event — Type (pseudo-event-formp event).

      This is useful to “replace” the error generated by an event (e.g. a defun or a defthm) with a customized soft error. The event is submitted with all output off (including error output), so there is no output if the submission succeeds. If the submission fails, orelse is used to submit a fail-event to cause an error with the specified context, flag, value, and message.

      Definitions and Theorems

      Function: try-event

      (defun try-event (form ctx erp val msg)
       (declare (xargs :guard (msgp msg)))
       (let ((__function__ 'try-event))
        (declare (ignorable __function__))
        (cons
           'orelse
           (cons (cons 'with-output
                       (cons ':gag-mode
                             (cons 'nil
                                   (cons ':off
                                         (cons ':all (cons form 'nil))))))
                 (cons (cons 'fail-event
                             (cons ctx
                                   (cons erp (cons val (cons msg 'nil)))))
                       'nil)))))

      Theorem: pseudo-event-formp-of-try-event

      (defthm pseudo-event-formp-of-try-event
        (b* ((event (try-event form ctx erp val msg)))
          (pseudo-event-formp event))
        :rule-classes :rewrite)