• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
      • Apt
      • Zfc
      • Acre
      • Milawa
      • Smtlink
      • Abnf
        • Deftreeops
        • Defdefparse
        • Defgrammar
        • Tree-utilities
        • Notation
        • Grammar-parser
        • Meta-circular-validation
        • Parsing-primitives-defresult
        • Parsing-primitives-seq
        • Operations
          • In-terminal-set
          • Well-formedness
          • Closure
          • Plugging
            • Plug-rules
              • Remove-prose-rules
              • Rule-prosep
            • Ambiguity
            • Renaming
            • Numeric-range-retrieval
            • Rule-utilities
            • Removal
            • Character-value-retrieval
          • Examples
          • Differences-with-paper
          • Constructor-utilities
          • Grammar-printer
          • Parsing-tools
        • Vwsim
        • Isar
        • Wp-gen
        • Dimacs-reader
        • Pfcs
        • Legacy-defrstobj
        • Proof-checker-array
        • Soft
        • C
        • Farray
        • Rp-rewriter
        • Instant-runoff-voting
        • Imp-language
        • Sidekick
        • Leftist-trees
        • Java
        • Taspi
        • Bitcoin
        • Riscv
        • Des
        • Ethereum
        • X86isa
        • Sha-2
        • Yul
        • Zcash
        • Proof-checker-itp13
        • Regex
        • ACL2-programming-language
        • Json
        • Jfkr
        • Equational
        • Cryptography
        • Poseidon
        • Where-do-i-place-my-book
        • Axe
        • Bigmems
        • Builtins
        • Execloader
        • Aleo
        • Solidity
        • Paco
        • Concurrent-programs
        • Bls12-377-curves
      • Debugging
      • Std
      • Proof-automation
      • Macro-libraries
      • ACL2
      • Interfacing-tools
      • Hardware-verification
      • Software-verification
      • Math
      • Testing-utilities
    • Plugging

    Plug-rules

    Plug a list of rules into another list of rules.

    Signature
    (plug-rules rules1 rules2) → rules
    Arguments
    rules1 — Guard (rulelistp rules1).
    rules2 — Guard (rulelistp rules2).
    Returns
    rules — Type (rulelistp rules).

    This plugs rules2 into rules1, not vice versa. This choice is motivated by the fact that grammar rules are usually presented in a top-down manner, and so it seems more natural to have the ``plugged'' rules (e.g. HTTP) appear before the ``plugging'' rules (e.g. URI).

    After removing from rules1 the prose rules whose names have definitions in rules2, we find the rules in rules2 that transitively define rule names referenced but not defined in the remaining rules of rules1. We append the rules found after the remaining rules of rules1.

    Thus, prose rules in rules1 are effectively replaced by corresponding rules in rules (assuming that each prose rule removed from rules1 is the only rule in rules1 that defines its rule name). Besides replacing prose-rules like this, the plugging operation may also provide definitions for rule names that are only referenced in rules1.

    Prose rules in rules1 whose names do not have definitions in rules2 are not removed from rules1 and thus appear in the resulting rules. Similarly, rules referenced in rules1 but defined neither in rules1 nor in rules2 remain referenced but not defined in the resulting rules. These features allow multi-step plugging, i.e. rules2 is plugged into rules1, then rules3 is plugged into the result of the previous operation, and so on.

    Definitions and Theorems

    Function: plug-rules

    (defun plug-rules (rules1 rules2)
      (declare (xargs :guard (and (rulelistp rules1)
                                  (rulelistp rules2))))
      (b* ((rules1 (remove-prose-rules rules1 rules2))
           (rules2 (trans-rules-of-names
                        (difference (rulelist-called-rules rules1)
                                    (rulelist-defined-rules rules1))
                        rules2)))
        (append rules1 rules2)))

    Theorem: rulelistp-of-plug-rules

    (defthm rulelistp-of-plug-rules
      (b* ((rules (plug-rules rules1 rules2)))
        (rulelistp rules))
      :rule-classes :rewrite)