Major Section: ACL2 Documentation
General Form: a true list of rule class objects as defined belowACL2 provides users with the ability to create a number of different kinds of rules, including (conditional) rewrite rules but also including others. Don't be put off by the long description to follow; usually, you'll probably want to use rewrite rules. More on this below.
Special Cases: a symbol abbreviating a single rule class object
A rule class object is either one of the
:class keywords or else is
a list of the form shown below. Those fields marked with ``(!)''
are required when the
:class is as indicated.
(:class :COROLLARY term :TRIGGER-FNS (fn1 ... fnk) ; provided :class = :META (!) :TRIGGER-TERMS (t1 ... tk) ; provided :class = :FORWARD-CHAINING ; or :class = :LINEAR :TYPE-SET n ; provided :class = :TYPE-SET-INVERTER :TYPED-TERM term ; provided :class = :TYPE-PRESCRIPTION :CLIQUE (fn1 ... fnk) ; provided :class = :DEFINITION (!) :CONTROLLER-ALIST alist ; provided :class = :DEFINITION (!) :LOOP-STOPPER alist ; provided :class = :REWRITE :PATTERN term ; provided :class = :INDUCTION (!) :CONDITION term ; provided :class = :INDUCTION :SCHEME term ; provided :class = :INDUCTION (!) :MATCH-FREE all-or-once ; provided :class = :REWRITE or :class = :LINEAR or :class = :FORWARD-CHAINING :BACKCHAIN-LIMIT-LST limit ; provided :class = :REWRITE or :class = :META or :class = :LINEAR :HINTS hints ; provided instrs = nil :INSTRUCTIONS instrs ; provided hints = nil :OTF-FLG flg)When rule class objects are provided by the user, most of the fields are optional and their values are computed in a context sensitive way. When a
:classkeyword is used as a rule class object, all relevant fields are determined contextually. Each rule class object in
:rule-classescauses one or more rules to be added to the data base. The
:classkeywords are documented individually under the following names. Note that when one of these names is used as a
:class, it is expected to be in the keyword package (i.e., the names below should be preceded by a colon but the ACL2 documentation facilities do not permit us to use keywords below).
:metarule (a hand-written simplifier)
:rewriterules (possibly conditional ones)
forward-chainingrules for ``type-theoretic'' rules, especially ones whose top-level function symbol is a common one like
consp; see type-prescription and see forward-chaining. However, the rest of the rule classes are really not intended for widespread use, but rather are mainly for experts.
We expect that we will write more about the question of which kind
of rule to use. For now: when in doubt, use a
:Rule-classes is an optional keyword argument of the
defaxiom) event. In the following, let
name be the name of the
event and let
thm be the formula to be proved or added as an axiom.
:rule-classes is not specified in a
it is as though
((:rewrite)) had been used. Use
nil to specify that no rules are to be generated.
:rule-classes class is specified, where class is a non-
symbol, it is as though
((class)) had been used.
forward-chaining is equivalent to
We therefore now consider
:rule-classes as a true list. If any
element of that list is a keyword, replace it by the singleton list
containing that keyword. Thus,
(:rewrite :elim) is
the same as
Each element of the expanded value of
:rule-classes must be a true
car is one of the rule class keyword tokens listed above,
elim, etc., and whose
cdr is a ``keyword alist''
alternately listing keywords and values. The keywords in this alist
must be taken from those shown below. They may be listed in any
order and most may be omitted, as specified below.
Corollary-- its value,
term, must be a term. If omitted, this field defaults to
corollaryof a rule class object is the formula actually used to justify the rule created and thus determines the form of the rule. Nqthm provided no similar capability: each rule was determined by
thm, the theorem or axiom added. ACL2 permits
thmto be stated ``elegantly'' and then allows the
corollaryof a rule class object to specify how that elegant statement is to be interpreted as a rule. For the rule class object to be well-formed, its (defaulted)
term, must follow from
termis trivially implied by
thm, using little more than propositional logic, the formula
(implies thm term)is submitted to the theorem prover and the proof attempt must be successful. During that proof attempt the values of
otf-flg, as provided in the rule class object, are provided as arguments to the prover. Such auxiliary proofs give the sort of output that one expects from the prover. However, as noted above, corollaries that follow trivially are not submitted to the prover; thus, such corollaries cause no prover output.
Note that before
termis stored, all calls of macros in it are expanded away. See trans.
otf-flg-- the values of these fields must satisfy the same restrictions placed on the fields of the same names in
defthm. These values are passed to the recursive call of the prover used to establish that the
corollaryof the rule class object follows from the theorem or axiom
Type-set-- this field may be supplied only if the
type-set-inverter. When provided, the value must be a type-set, an integer in a certain range. If not provided, an attempt is made to compute it from the corollary. See type-set-inverter.
:Typed-term-- this field may be supplied only if the
type-prescription. When provided, the value is the term for which the
corollaryis a type-prescription lemma. If no
:typed-termis provided in a
type-prescriptionrule class object, we try to compute heuristically an acceptable term. See type-prescription.
:Trigger-terms-- this field may be supplied only if the
linear. When provided, the value is a list of terms, each of which is to trigger the attempted application of the rule. If no
:trigger-termsis provided, we attempt to compute heuristically an appropriate set of triggers. See forward-chaining or see linear.
:Trigger-fns-- this field must (and may only) be supplied if the
meta. Its value must be a list of function symbols. Terms with these symbols trigger the application of the rule. See meta.
:controller-alist-- these two fields may only be supplied if the
definition. If they are omitted, then ACL2 will attempt to guess them. Suppose the
corollaryof the rule is
(implies hyp (equiv (fn a1 ... an) body)). The value of the
:cliquefield should be a true list of function symbols, and if non-
fn. These symbols are all the members of the mutually recursive clique containing this definition of
fn. That is, a call of any function in
:cliqueis considered a ``recursive call'' for purposes of the expansion heuristics. The value of the
:controller-alistfield should be an alist that maps each function symbol in the
:cliqueto a list of
nil's of length equal to the arity of the function. For example, if
:cliqueconsists of just two symbols,
fn2, of arities
((fn1 t nil) (fn2 nil t t))is a legal value of
:controller-alist. The value associated with a function symbol in this alist is a ``mask'' specifying which argument slots of the function ``control'' the recursion for heuristic purposes. Sloppy choice of
:controller-alistcan result in infinite expansion and stack overflow.
loop-stopper-- this field may only be supplied if the class is
rewrite. Its value must be a list of entries each consisting of two variables followed by a (possibly empty) list of functions, for example
((x y binary-+) (u v foo bar)). It will be used to restrict application of rewrite rules by requiring that the list of instances of the second variables must be ``smaller'' than the list of instances of the first variables in a sense related to the corresponding functions listed; see loop-stopper. The list as a whole is allowed to be
nil, indicating that no such restriction shall be made. Note that any such entry that contains a variable not being instantiated, i.e., not occurring on the left side of the rewrite rule, will be ignored. However, for simplicity we merely require that every variable mentioned should appear somewhere in the corresponding
:scheme-- the first and last of these fields must (and may only) be supplied if the class is
:Conditionis optional but may only be supplied if the class is
induction. The values must all be terms and indicate, respectively, the pattern to which a new induction scheme is to be attached, the condition under which the suggestion is to be made, and a term which suggests the new scheme. See induction.
match-free-- this field must be
:onceand may be supplied only if the
forward-chaining. See free-variables for a description of this field. Note: Although this field is intended to be used for controlling retries of matching free variables in hypotheses, it is legal to supply it even if there are no such free variables. This can simplify the automated generation of rules, but note that when
:match-freeis supplied, the warning otherwise provided for the presence of free variables in hypotheses will be suppressed.
backchain-limit-lst-- this field may be supplied only if the
linearand only one rule is generated from the formula. Its value must be
nil; a non-negative integer; or, except in the case of
metarules, a true list each element of which is either
nilor a non-negative integer. If it is a list, its length must be equal to the number of hypotheses of the rule and each item in the list is the ``backchain limit'' associated with the corresponding hypothesis. If
backchain-limit-lstis a non-negative integer, it is defaulted to a list of the appropriate number of repetions of that integer. The backchain limit of a hypothesis is used to limit the effort that ACL2 will expend when relieving the hypothesis. If it is
NIL, no new limits are imposed; if it is an integer, the hypothesis will be limited to backchaining at most that many times. Note that backchaining may be further limited by a global
backchain-limit; see backchain-limit for details. For a different way to reign in the rewriter, see rewrite-stack-limit.
thmhas been proved (in the case of
defthm) and each rule class object has been checked for well-formedness (which might require additional proofs), we consider each rule class object in turn to generate and add rules. Let
:classbe the class keyword token of the
ith class object (counting from left to right). Generate the rune
(:class name . x), where
nilif there is only one class and otherwise
i. Then, from the
corollaryof that object, generate one or more rules, each of which has the name
(:class name . x). See the
docentry for each rule class to see how formulas determine rules. Note that it is in principle possible for several rules to share the same name; it happens whenever a
corollarydetermines more than one rule. This in fact only occurs for
forward-chainingclass rules and only then if the
corollaryis essentially a conjunction. (See the documentation for rewrite, linear, or forward-chaining for details.)