• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
    • Debugging
    • Community
    • Std
    • Proof-automation
    • Macro-libraries
    • ACL2
      • Theories
      • Rule-classes
        • Type-prescription
        • Rewrite
        • Meta
        • Linear
        • Definition
        • Clause-processor
          • Meta-extract
          • Set-skip-meta-termp-checks
          • Make-summary-data
          • Clause-processor-tools
            • Rp-rewriter
              • Rp-ruleset
              • Defthmrp
              • Rp-rewriter/meta-rules
                • Add-meta-rule
                • Dont-rw
                • Attach-meta-fncs
                • Is-rp-clause-processor-up-to-date
              • Rp-utilities
              • Rp-rewriter-demo
              • Rp-rewriter/debugging
              • Rp-rewriter/applications
          • Set-skip-meta-termp-checks!
        • Tau-system
        • Forward-chaining
        • Equivalence
        • Congruence
        • Free-variables
        • Executable-counterpart
        • Induction
        • Type-reasoning
        • Compound-recognizer
        • Rewrite-quoted-constant
        • Elim
        • Well-founded-relation-rule
        • Built-in-clause
        • Well-formedness-guarantee
        • Patterned-congruence
        • Rule-classes-introduction
        • Refinement
        • Guard-holders
        • Type-set-inverter
        • Generalize
        • Corollary
        • Induction-heuristics
        • Well-founded-relation
        • Backchaining
        • Default-backchain-limit
      • Proof-builder
      • Recursion-and-induction
      • Hons-and-memoization
      • Events
      • Parallelism
      • History
      • Programming
      • Operational-semantics
      • Real
      • Start-here
      • Miscellaneous
      • Output-controls
      • Bdd
      • Macros
      • Installation
      • Mailing-lists
    • Interfacing-tools
    • Hardware-verification
    • Software-verification
    • Math
    • Testing-utilities
  • Rp-rewriter

Rp-rewriter/meta-rules

The steps necessary to add meta rules to RP-Rewriter

Below are the steps users need to follow, and information they may use:

1. Create your meta function.

(define <meta-fnc> (term)
     :returns (mv term dont-rw) OR (term)
     ...) 
Your meta function can return either two values:term and dont-rw; or only term. For best performance, it is recommended that you return dont-rw structure as well. If you do not want the returned term to be rewritten at all, you can return 't' for dont-rw.

2. Create formula-checks function.

(def-formula-checks <formula-check-name>
       (<list-of-function-names>)) 
This event submits a function with signature (<formula-check-name> state). When you add this function to your correctness theorem for this meta function, the evaluator of RP-Rewriter will recognize the functions you list.

3. Prove that evaluation of the function returns an equivalent term under the evaluator.

(defthm rp-evlt-of-meta-fnc
    (implies (and (valid-sc term a) ;;optional
                  (rp-termp term) ;;optional
                  (rp-evl-meta-extract-global-facts)
                  (<formula-check-name> state))
             (equal (rp-evlt (<meta-fnc> term) a)
                    (rp-evlt term a)))) 
This is the correctness theorem of the meta rule. Optionally, you may have (valid-sc term a), which states that the side-conditions in RP-Rewriter are correct; and (rp-termp term), which states that some of the syntactic invariances hold and the term is syntactically compatible with RP-Rewriter. See discussions for valid-sc and rp-termp.

If the meta function returns dont-rw, then you need to prove this lemma for (mv-nth 0 (<meta-fnc> term)) instead.

4. Prove that meta-function retains the correctness of side-conditions.

(defthm valid-sc-of-meta-fnc
   (implies (and (valid-sc term a)
                 (rp-termp term) ;;optional
                 (rp-evl-meta-extract-global-facts) ;;optional
                 (<formula-check-name> state)) ;;optional
            (valid-sc (<meta-fnc> term) a))) 
Meta functions can introduce or change side-conditions by manipulating 'rp' instances. Therefore users need to prove that the invariance about side conditions are maintained.

If the meta function returns dont-rw, then you need to prove this lemma for (mv-nth 0 (<meta-fnc> term)) instead.

5. Optionally, prove that the meta function returns a valid syntax.

(defthm rp-termp-of-meta-fnc
    (implies (rp-termp term)
             (rp-termp (<meta-fnc> term)))) 
Even though it is optional, it is recommended that you prove such a lemma for your meta function. It prevents syntactic check on every term returned from meta function.

If the meta function returns dont-rw, then you need to prove this lemma for (mv-nth 0 (<meta-fnc> term)) instead.

6. Save the meta rule in the rule-set of RP-Rewriter for meta rules.


(rp::add-meta-rule
 :meta-fnc <meta-fnc>
 :trig-fnc <trig-fnc>
 :returns <return-signature>
 :rw-direction <:inside-out, :outside-in, or :both>
 :valid-syntaxp <t-if-rp-termp-of-meta-fnc-is-proved>)
 
See add-meta-rule for further discussion of the options.

7. Attach these newly created meta functions.

(rp::attach-meta-fncs <a-unique-name-for-updated-clause-processor>) 
If you are going to include this book later when other meta rules for RP-Rewriter is present, you may want to call this function when all the meta rules are included.

You may look at examples of RP-Rewriter meta rules under /books/projects/RP-Rewriter/meta/*. implies-meta.lisp is a very simple example of an outside-in meta rule.

Some books under /books/projects/RP-Rewriter/proofs/* might be useful when proving when proving meta rules correct, especially aux-function-lemmas and eval-functions-lemmas.

Subtopics

Add-meta-rule
A macro to add created meta rules to RP-Rewriter
Dont-rw
A special data structure that RP-Rewriter meta rules may return to control rewriting of returned terms.
Attach-meta-fncs
Creates and attaches a new meta-rule caller function to register added meta rules.
Is-rp-clause-processor-up-to-date
Checks if all the added meta-rules are 'registered'