Automatically include specified definitions from a specified book
When local include-book forms are used in support of definitions and theorems, the enclosing book or encapsulate event may be ill-formed because of missing definitions. Consider the following example.
(encapsulate () (local (include-book "bk")) ; defines function f ; (defun g (x) (f x)))
In this example, the definition of
General forms:
(with-supporters (local ev) ; a local event [optional keyword arguments, including perhaps:] :names (name-1 ... name-m) ; optional keyword argument [other optional keyword arguments] event-1 ... event-k)
where the optional keyword arguments are not evaluated and are described
below, and each
(encapsulate () (local ev) EXTRA event-1 ... event-k)
where
Each keyword argument must appear immediately after the initial local
event, before the supplied
We now illustrate with examples, starting with one that does not use the
Consider the following event.
(encapsulate () (local (include-book "std/lists/duplicity" :dir :system)) (defthm duplicity-append (equal (duplicity a (append x y)) (+ (duplicity a x) (duplicity a y)))))
This event fails because the function
One solution is to move the
A more suitable solution may thus be to use the macro,
(with-supporters (local (include-book "std/lists/duplicity" :dir :system)) (defthm duplicity-append (equal (duplicity a (append x y)) (+ (duplicity a x) (duplicity a y)))))
That macro determines automatically that the function
ACL2 !>(with-supporters (local (include-book "std/lists/duplicity" :dir :system)) :show :only (defthm duplicity-append (equal (duplicity a (append x y)) (+ (duplicity a x) (duplicity a y))))) Summary Form: ( MAKE-EVENT (WITH-OUTPUT! :OFF ...)) Rules: NIL Time: 0.13 seconds (prove: 0.00, print: 0.00, other: 0.13) Prover steps counted: 154 (WITH-OUTPUT :OFF :ALL :ON ERROR (ENCAPSULATE NIL (LOCAL (INCLUDE-BOOK "std/lists/duplicity" :DIR :SYSTEM)) (SET-ENFORCE-REDUNDANCY T) (SET-BOGUS-DEFUN-HINTS-OK T) (SET-BOGUS-MUTUAL-RECURSION-OK T) (SET-IRRELEVANT-FORMALS-OK T) (SET-IGNORE-OK T) (PROGN (DEFUN DUPLICITY-EXEC (A X N) (DECLARE (XARGS :GUARD (NATP N))) (IF (ATOM X) N (DUPLICITY-EXEC A (CDR X) (IF (EQUAL (CAR X) A) (+ 1 N) N)))) (VERIFY-GUARDS DUPLICITY-EXEC)) (PROGN (DEFUN DUPLICITY (A X) (DECLARE (XARGS :GUARD T :VERIFY-GUARDS NIL)) (MBE :LOGIC (COND ((ATOM X) 0) ((EQUAL (CAR X) A) (+ 1 (DUPLICITY A (CDR X)))) (T (DUPLICITY A (CDR X)))) :EXEC (DUPLICITY-EXEC A X 0))) (VERIFY-GUARDS DUPLICITY)) (IN-THEORY (DISABLE (:DEFINITION DUPLICITY-EXEC) (:INDUCTION DUPLICITY-EXEC) (:DEFINITION DUPLICITY) (:INDUCTION DUPLICITY) (:DEFINITION DUPLICITY-EXEC) (:INDUCTION DUPLICITY-EXEC) (:DEFINITION DUPLICITY) (:INDUCTION DUPLICITY) (:DEFINITION DUPLICITY-EXEC) (:INDUCTION DUPLICITY-EXEC))) (SET-ENFORCE-REDUNDANCY NIL) (DEFTHM DUPLICITY-APPEND (EQUAL (DUPLICITY A (APPEND X Y)) (+ (DUPLICITY A X) (DUPLICITY A Y)))))) ACL2 !>
Notice that care is taken to preserve the
For more examples, see community-books file