• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
    • Debugging
    • 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
                • Add-meta-rule
                • Enable-meta-rules
                • Disable-meta-rules
                • Def-rp-rule
                • Rp-pr
                • Enable-exc-counterpart
                • Disable-exc-counterpart
                • Bump-rules
                • Bump-rule
                • Bump-down-rule
                • Bump-all-meta-rules
                • Enable-rules
                • Enable-preprocessor
                • Enable-postprocessor
                • Disable-rules
                • Disable-preprocessor
                • Disable-postprocessor
                • Disable-all-rules
              • Defthmrp
              • Rp-rewriter/meta-rules
              • 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
        • Guard-holders
        • Refinement
        • Type-set-inverter
        • Generalize
        • Corollary
        • Induction-heuristics
        • Backchaining
        • Default-backchain-limit
      • Proof-builder
      • Recursion-and-induction
      • Hons-and-memoization
      • Events
      • Parallelism
      • History
      • Programming
      • Operational-semantics
      • Real
      • Start-here
      • Debugging
      • Miscellaneous
      • Output-controls
      • Macros
      • Interfacing-tools
    • Interfacing-tools
    • Hardware-verification
    • Software-verification
    • Math
    • Testing-utilities
  • Rp-rewriter

Rp-ruleset

Functions to manage RP-Rewriter's ruleset

Users can use the functions below to register rules to RP-Rewriter's ruleset:

ADD-RP-RULE


(rp::add-rp-rule <rule-name>
                 ;; optional args:
                 :disabled <t-or-nil> ;; default: nil
                 :lambda-opt <...>    ;; default: nil
                 :hints <...>         ;; default: nil
                 :rw-direction <...>  ;; default: :inside-out
                 :ruleset <...>       ;; default: rp-rules
                 )
 

This macro submits a table event that saves the given rule in the RP-Rewriter's ruleset to be used later. Application priority of the rule will depend on when this event is submitted rather than when the rule is originally defined.

:disabled key, when set, leaves the added rule disabled for RP-Rewriter.

:lambda-opt key checks if the rule has any lambda expressions. If that is the case, then it performs lambda-optimization to create a new rule and save that instead. The name of the new rule will be printed, and it will be disabled for ACL2. RP-Rewriter will know to use that rule when you refer to the original rule name, such as when enabling/disabling it.

:hints key will likely never be used but maybe necessary in some unforeseen cases when :lambda-opt is enabled.

:rw-direction key can be set to :inside-out, :both, or :outside-in. This determines the rewrite direction when applying a rule. If the key is set to :outside-in, then the rule will be tried on a term before rewriting the subterms. If it is set to :inside-out, then the rule will be considered only an inside-out rule and the subterms will be rewritten first before applying the rewrite rule. If it is set to :both, then it is treated as both inside-out and outside-in.

:ruleset key select which table the rule should be saved in. By default, it is set to rp-rules. Should users choose to collect their rules in some other table to manage a different rewriting scheme and don't want the possible interference from the existing set of rules, then they may choose to use a custom table to store and read the rule names.

DEF-RP-RULE


(rp::def-rp-rule  <rule-name>
  <conjecture>
  ;;optional arguments:
  :rule-classes <...>      ;; default: :rewrite, passed to defthm
  :hints <...>             ;; default: nil. Passed to defthm
  :otf-flg <t-or-nil>      ;; default: nil. Passed to defthm
  :instructions <t-or-nil> ;; default: nil. Passed to defthm.

  :disabled <t-or-nil> ;; default: nil. Disable the rule for both ACL2 and RP
  :disabled-for-rp <t-or-nil>   ;; default: nil. Disable the rule for RP
  :disabled-for-ACL2 <t-or-nil> ;; default: nil. Disable the rule for ACL2

  :rw-direction <...> ;; default: :inside-out. Passed to add-rp-rule
  :lambda-opt <...>   ;; default: t. Passed to add-rp-rule.
  :rule-set <...>     ;; default: rp-rules. Passed to add-rp-rule
  ) 

This macro simply expands to consecutive calls of defthm and add-rp-rule. It provides a compact way to add rewrite rules intended to be used by RP-Rewriter. Note that the :lambda-opt argument is set to t by default.

PRINTING RULES

A given rule may be parsed differently in RP-Rewriter than how ACL2 processes rules. Therefore, using pr to understand rhs, lhs, hyp etc. of a rule may be misleading. So RP-Rewriter has its of version of pr:

(rp-pr rule-name)

This will show relevant information about a given rule.

ENABLING/DISABLING RULES

To enable rewrite, definition or meta rules:

(rp::enable-rules <rules>) 

The argument should be a quoted list of rules/runes. For example: (rp::enable-rules '(implies (:rewrite append-of-nil))). To enable meta rules, their trigger function should be passed as well. For example: (rp::enable-rules '((:meta mv-nth-meta . mv-nth))).

To disable them:

(rp::disable-rules <rules>) 

To disable all:

(rp::disable-all-rules)

Alternatively, meta rules can be enabled/disabled without passing their trigger functions using rp::enable-meta-rules and rp::disable-meta-rules. These macros have a different signature than rp::enable-rules. For example: (rp::enable-meta-rules mv-nth-meta hons-acons-meta hons-get-meta). These macros will enable/disable the meta rules for the given meta function names each of which may have multiple trigger functions.

(rp::enable-meta-rules meta-fnc1 meta-fnc2 ...) 

and

(rp::disable-meta-rules meta-fnc1 meta-fnc2 ...) 

All executable counterparts are enabled by default even if the user does not add the functions to RP-Rewriter's ruleset. They can be disabled and enabled with the macro calls below. The given function name should be unquoted.

 (rp::disable-exc-counterpart <fnc-name>) 

and

 (rp::enable-exc-counterpart <fnc-name>) 

Alternatively, passing the rune for executable counterpart to enable-rules/disable-rules can also work. For example:

 (rp::enable-rules '((:executable-counterpart mv-nth))) 

Preprocessors and postprocessors can be enabled/disabled with the macros below.

 (rp::enable-preprocessor <fnc-name>) 
 (rp::disable-preprocessor <fnc-name>) 
 (rp::enable-postprocessor <fnc-name>) 
 (rp::disable-postprocessor <fnc-name>) 

CHANGING RULE PRIORITIES

Users can 'bump' or 'bump down' rules, effectively changing their application priority. For example, (bump-rp-rule (:definition implies)) (alternatively: (bump-rp-rule implies)) will prioritize the definition rule of implies over any rewrite rule that might have been added prior to that point. This simply moves the name of this rules at the top of the list in the table that the rules are stored. So if another rule about implies is added after this point, that that newer rule will have higher priority.

(rp::bump-rule <rule-name/rune>) 

Reversely, bump-down-rule pushes down a rule at the end of the rule list, making it the least prioritized rule.

(rp::bump-down-rule <rule-name/rune>) 

Users can bump multiple rules with a single event:

 (rp::bump-rules rule-name/rune1 rule-name/rune2 ...) 

Users can bump all the meta rules with the macro below:

 (rp::bump-all-meta-rules) 

Subtopics

Add-meta-rule
A macro to add created meta rules to RP-Rewriter
Enable-meta-rules
Enable meta rules with given meta function name list.
Disable-meta-rules
Disable meta rules with given meta function name list.
Def-rp-rule
A defthm macro that calls add-rp-rule after its defthm event.
Rp-pr
Print the rules for RP-Rewriter (similar to pr)
Enable-exc-counterpart
Enable executable-counterpart of a function for RP-Rewriter
Disable-exc-counterpart
Disable executable-counterpart of a function for RP-Rewriter
Bump-rules
Put given rules at the top of the stack to prioritize them for RP-Rewriter
Bump-rule
Put the given rule at the top of the stack to prioritize them for RP-Rewriter
Bump-down-rule
Push the given rule to the bottom of the stack to de-prioritize them for RP-Rewriter
Bump-all-meta-rules
Put all the meta rules at the top of the stack to prioritize them for RP-Rewriter
Enable-rules
Enable rules for RP-Rewriter
Enable-preprocessor
Enable a preprocessor for RP-Rewriter
Enable-postprocessor
Enable a postprocessor for RP-Rewriter
Disable-rules
Disable rules for RP-Rewriter
Disable-preprocessor
Disable a preprocessor for RP-Rewriter
Disable-postprocessor
Disable a postprocessor for RP-Rewriter
Disable-all-rules
Disable all rules for RP-Rewriter