• Top
    • Documentation
    • Books
    • Recursion-and-induction
    • Boolean-reasoning
    • Projects
      • Apt
      • Acre
      • Milawa
      • Smtlink
      • Abnf
      • Vwsim
      • Isar
      • Wp-gen
      • Dimacs-reader
      • Legacy-defrstobj
      • Prime-field-constraint-systems
      • Proof-checker-array
      • Soft
      • 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
      • Farray
      • Instant-runoff-voting
      • Imp-language
      • Sidekick
      • Leftist-trees
      • Taspi
      • Bitcoin
      • Des
      • Ethereum
      • Sha-2
      • Yul
      • Zcash
      • Proof-checker-itp13
      • Bigmem
      • Regex
      • ACL2-programming-language
      • Java
      • C
      • Jfkr
      • X86isa
      • Equational
      • Cryptography
      • Where-do-i-place-my-book
      • Json
      • Built-ins
      • Execloader
      • Solidity
      • Paco
      • Concurrent-programs
    • Debugging
    • Std
    • Proof-automation
    • Macro-libraries
    • ACL2
    • Interfacing-tools
    • Hardware-verification
    • Software-verification
    • Testing-utilities
    • Math
  • 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'