• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
    • Debugging
    • Std
    • Community
    • Proof-automation
    • Macro-libraries
    • ACL2
      • Theories
      • Rule-classes
      • Proof-builder
      • Recursion-and-induction
      • Hons-and-memoization
      • Events
        • Defun
        • Verify-guards
        • Table
        • Mutual-recursion
        • Memoize
        • Make-event
        • Include-book
        • Encapsulate
          • Signature
          • Constraint
          • Partial-encapsulate
          • Redundant-encapsulate
          • Infected-constraints
          • Functional-instantiation
            • Lemma-instance
              • Termination-theorem-example
              • Guard-theorem-example
                • Guard-theorem
                  • ACL2-pc::prove-guard
                  • Guard-theorem-example
                  • Termination-theorem
                • Functional-instantiation-example
                • Def-functional-instance
                • Functional-instantiation-in-ACL2r
            • Defun-sk
            • Defttag
            • Defstobj
            • Defpkg
            • Defattach
            • Defabsstobj
            • Defchoose
            • Progn
            • Verify-termination
            • Redundant-events
            • Defconst
            • Defmacro
            • Skip-proofs
            • In-theory
            • Embedded-event-form
            • Value-triple
            • Comp
            • Local
            • Defthm
            • Progn!
            • Defevaluator
            • Theory-invariant
            • Assert-event
            • Defun-inline
            • Project-dir-alist
            • Partial-encapsulate
            • Define-trusted-clause-processor
            • Defproxy
            • Defexec
            • Defun-nx
            • Defthmg
            • Defpun
            • Defabbrev
            • Set-table-guard
            • Name
            • Defrec
            • Add-custom-keyword-hint
            • Regenerate-tau-database
            • Defcong
            • Deftheory
            • Defaxiom
            • Deftheory-static
            • Defund
            • Evisc-table
            • Verify-guards+
            • Logical-name
            • Profile
            • Defequiv
            • Defmacro-untouchable
            • Add-global-stobj
            • Defthmr
            • Defstub
            • Defrefinement
            • Deflabel
            • In-arithmetic-theory
            • Unmemoize
            • Defabsstobj-missing-events
            • Defthmd
            • Fake-event
            • Set-body
            • Defun-notinline
            • Functions-after
            • Macros-after
            • Dump-events
            • Defund-nx
            • Defun$
            • Remove-global-stobj
            • Remove-custom-keyword-hint
            • Dft
            • Defthy
            • Defund-notinline
            • Defnd
            • Defn
            • Defund-inline
            • Defmacro-last
          • Parallelism
          • History
          • Programming
          • Operational-semantics
          • Real
          • Start-here
          • Debugging
          • Miscellaneous
          • Output-controls
          • Macros
          • Interfacing-tools
        • Interfacing-tools
        • Hardware-verification
        • Software-verification
        • Math
        • Testing-utilities
      • Lemma-instance
      • Guard
      • Hints
      • Guard-theorem
      • Guard-formula-utilities

      Guard-theorem-example

      How to use a previously-proved guard theorem

      See lemma-instance for a discussion of :guard-theorem lemma instances, and see gthm for a related user-level query utility. In this topic, we illustrate the use of such lemma instances to take advantage of a guard theorem already proved for an existing definition, when attempting to admit a new definition.

      The following example is contrived but should get the idea across. Suppose that the event displayed just below was previously executed, for example when including a book. The mbe call generates a guard proof obligation, but there is only one thing to know about that for this example: without the local lemma shown, the guard proof fails for f1.

      (encapsulate
        ()
        (local (defthm append-revappend
                 (equal (append (revappend x y) z)
                        (revappend x (append y z)))))
      
        (defun f1 (x y)
          (declare (xargs :guard (and (true-listp x)
                                      (true-listp y))))
          (mbe :logic (append (reverse x) y)
               :exec (revappend x y))))

      Now suppose that later, we wish to admit a function with the same guard and body. Since the lemma append-revappend above is local, guard verification will likely fail. However, we can tell the prover to use the guard theorem already proved for f1, as follows; then the guard verification proof succeeds.

      (defun f2 (x y)
        (declare (xargs :guard (and (true-listp x)
                                    (true-listp y))
                        :guard-hints (("Goal" :use ((:guard-theorem f1))))))
        (mbe :logic (append (reverse x) y)
             :exec (revappend x y)))

      See termination-theorem-example for an example use of the analogous lemma instance type, :termination-theorem. That topic also includes discussion of the use of event names in prover output.