• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
    • Debugging
    • Community
    • Std
    • Proof-automation
    • Macro-libraries
    • ACL2
      • Theories
      • Rule-classes
      • Proof-builder
      • Recursion-and-induction
      • Hons-and-memoization
      • Events
      • Parallelism
      • History
      • Programming
      • Operational-semantics
      • Real
      • Start-here
      • Miscellaneous
      • Output-controls
      • Bdd
      • Macros
        • Make-event
          • Make-event-details
          • Make-event-example-2
          • Make-event-example-1
          • Make-event-example-3
            • Make-event-terse
          • Defmacro
          • Untranslate-patterns
          • Tc
          • Trans*
          • Macro-aliases-table
          • Macro-args
          • Defabbrev
          • Trans
          • User-defined-functions-table
          • Untranslate-for-execution
          • Macro-libraries
          • Add-macro-fn
          • Check-vars-not-free
          • Safe-mode
          • 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
        • Installation
        • Mailing-lists
      • Interfacing-tools
      • Hardware-verification
      • Software-verification
      • Math
      • Testing-utilities
    • Make-event

    Make-event-example-3

    Using make-event to define thm

    The definition of thm provides a simple, yet informative, example use of make-event. Formerly (through ACL2 Version 8.1), this was the definition of thm, where thm-fn provides an interface to the prover.

    (defmacro thm (term &key hints otf-flg)
      (list 'thm-fn
            (list 'quote term)
            'state
            (list 'quote hints)
            (list 'quote otf-flg)))

    However, this version of thm did not permit calls of thm in books or encapsulate forms. To remedy that deficiency, the definition was changed to the following; below we explain components of this definition. (It has since been updated further, but that is not relevant here so we don't comment here on further updates.)

    (defmacro thm (&whole event-form
                          term &key hints otf-flg)
      `(with-output :off summary :stack :push
         (make-event (er-progn (with-output :stack :pop
                                 (thm-fn ',term
                                         state
                                         ',hints
                                         ',otf-flg
                                         ',event-form))
                               (value '(value-triple :invisible)))
                     :expansion? (value-triple :invisible)
                     :on-behalf-of :quiet!
                     :save-event-data t)))

    The use of with-output avoids printing anything about make-event in the summary (by using :off summary). But we do want a summary for the prover call itself, to see the rules used, time elapsed, and so on. By using the keyword argument :stack :push, but then calling with-output again with argument :stack :pop before calling thm-fn, we remove the effect of :off summary before calling thm-fn.

    By ignoring the with-output wrapper, we may view the body of the make-event form as follows.

    (er-progn (thm-fn ...)
              (value '(value-triple :invisible)))

    Evaluation of this call of er-progn causes thm-fn to be run and, if there is no error and the proof succeeds, to return the event (value-triple :invisible). That event is a no-op, and it generally doesn't even cause a value to be printed; see ld-post-eval-print.

    Since an error-free expansion is always (value-triple :invisible), that event is specified with the :expansion? keyword so that the expansion is not stored, in particular in a book's certificate file. See make-event.

    The use of :on-behalf-of :quiet! avoids a needless, distracting error message from make-event when the proof fails.

    The :save-event-data keyword argument is a low-level implementation detail that we ignore here.