Automatically define necessary redundant definitions from after a specified event
When local include-book forms are used in support of
definitions and theorems, the resulting book or encapsulate event may
be ill-formed because of missing definitions. The macro,
See with-supporters for a related utility. (However,
General form:
(with-supporters-after name event-1 ... event-k)
where
((encapsulate () EXTRA event-1 ... event-k)
where
(in-package "ACL2") (include-book "tools/with-supporters" :dir :system) (deflabel my-label) (local (include-book "std/lists/duplicity" :dir :system)) (with-supporters-after my-label (defthm duplicity-append (equal (duplicity a (append x y)) (+ (duplicity a x) (duplicity a y)))))
The form above is equivalent to the following. Again, see with-supporters for relevant background. Note that the present macro, like that one, is also implemented using the macro std::defredundant.
(progn (encapsulate () (set-enforce-redundancy t) (logic) (defun duplicity-exec (a x n) (declare (xargs :mode :logic :verify-guards t)) (declare (xargs :measure (:? x))) (declare (xargs :guard (natp n))) (if (atom x) n (duplicity-exec a (cdr x) (if (equal (car x) a) (+ 1 n) n)))) (in-theory (e/d ((:type-prescription duplicity-exec) (:executable-counterpart duplicity-exec)) ((:induction duplicity-exec) (:definition duplicity-exec)))) (defun duplicity (a x) (declare (xargs :mode :logic :verify-guards t)) (declare (xargs :measure (:? x))) (declare (xargs :guard t)) (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))) (in-theory (e/d ((:type-prescription duplicity) (:executable-counterpart duplicity)) ((:induction duplicity) (:definition duplicity))))) (defthm duplicity-append (equal (duplicity a (append x y)) (+ (duplicity a x) (duplicity a y)))))