Forms that may be embedded in other events
Examples: (defun hd (x) (if (consp x) (car x) 0)) (local (defthm lemma23 ...)) (progn (defun fn1 ...) (local (defun fn2 ...)) ...) General Form: An embedded event form is a term, x, such that:
However, we add the following restrictions for local contexts.
(local (table acl2-defaults-table :defun-mode :program))is not an embedded event form, nor is the form
Only embedded event forms are allowed in a book after its initial in-package form. See books. However, you may find that make-event allows you to get the effect you want for a form that is not an
embedded event form. For example, you can put the following into a book,
which assigns the value 17 to state global variable
(make-event (er-progn (assign x 17) (value '(value-triple nil))) :check-expansion t)
For another use of
When an embedded event is executed while ld-skip-proofsp is
(progn (defun f1 () 1) (local (defun f2 () 2)) (defun f3 () 3))
will define
Discussion:
Encapsulate, progn, and include-book place
restrictions on the kinds of forms that may be processed. These restrictions
ensure that the non-local events are indeed admissible provided that
the sequence of local and non-local events is admissible when
proofs are done, i.e., when
Local permits the hiding of an event or group of events in
the sense that local events are processed when we are trying to
establish the admissibility of a sequence of events embedded in encapsulate forms or in books, but are ignored when we are
constructing the world produced by assuming that sequence. Thus, for
example, a particularly ugly and inefficient
To see why we can't allow just anything as an embedded event, consider allowing the form
(if (ld-skip-proofsp state) (defun foo () 2) (defun foo () 1))
followed by
(defthm foo-is-1 (equal (foo) 1)).
When we process the events with ld-skip-proofsp is
If you encounter a situation where these restrictions seem to prevent you
from doing what you want to do, then you may find
Defpkg is not allowed because it affects how things are read after it is executed. But all the forms embedded in an event are read before any are executed. That is,
(encapsulate nil (defpkg "MY-PKG" nil) (defun foo () 'my-pkg::bar))
makes no sense since
Finally, let us elaborate on the restriction mentioned earlier related to the ACL2-defaults-table. Consider the following form.
(encapsulate () (local (program)) (defun foo (x) (if (equal 0 x) 0 (1+ (foo (- x))))))
See local-incompatibility for a discussion of how encapsulate processes event forms. Briefly, on the first pass through the
events the definition of