• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
      • Apt
      • Zfc
      • Acre
      • Milawa
      • Smtlink
      • Abnf
        • Deftreeops
        • Defdefparse
          • Defdefparse-implementation
            • Defdefparse-event-generation
              • Defdefparse-gen-function-for-rulename
              • Defdefparse-gen-code-for-alternation
              • Defdefparse-gen-code-for-repetition
              • Defdefparse-gen-function-for-group
              • Defdefparse-function-spec
              • Defdefparse-gen-code-for-element
              • Defdefparse-gen-*-group-macro
              • Defdefparse-gen-function-for-option
              • Defdefparse-gen-option-macro
              • Defdefparse-gen-group-macro
              • Defdefparse-gen-code-for-concatenation
              • Defdefparse-gen-function-for-repetition
              • Defdefparse-gen-*-rulename-macro
              • Defdefparse-gen-rulename-macro
              • Defdefparse-gen-repetition-alist
              • Defdefparse-gen-option-alist
              • Defdefparse-gen-group-alist
              • Defdefparse-gen-everything
              • Defdefparse-gen-repetition-table-macro
              • Defdefparse-gen-option-table-macro
              • Defdefparse-gen-group-table-macro
              • Defdefparse-gen-function-for-spec
              • Defdefparse-gen-repetition-table
              • Defdefparse-gen-option-table
              • Defdefparse-gen-group-table
              • Defdefparse-reorder-alternation
                • Defdefparse-order-permutationp
                • Defdefparse-gen-repetition-table-name
                • Defdefparse-gen-option-table-name
                • Defdefparse-gen-group-table-name
                • Defdefparse-alt-symbol-alist
                • Defdefparse-rep-symbol-alist
              • Defdefparse-fn
              • Defdefparse-input-processing
              • Defdefparse-table
              • Defdefparse-macro-definition
          • Defgrammar
          • Tree-utilities
          • Notation
          • Grammar-parser
          • Meta-circular-validation
          • Parsing-primitives-defresult
          • Parsing-primitives-seq
          • Operations
          • 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
    • Defdefparse-event-generation

    Defdefparse-reorder-alternation

    Reorder the alternatives of an alternation.

    Signature
    (defdefparse-reorder-alternation alt order) → new-alt
    Arguments
    alt — Guard (alternationp alt).
    order — Guard (pos-listp order).
    Returns
    new-alt — Type (alternationp new-alt).

    The order list must be a permutation of the list (1 ... n), where n is the number of alternatives in alt. We return the alternative, permuted according to the list.

    This serves to try an alternative before another one, in order to satisfy extra-grammatical requirements.

    Definitions and Theorems

    Function: defdefparse-reorder-alternation

    (defun defdefparse-reorder-alternation (alt order)
      (declare (xargs :guard (and (alternationp alt)
                                  (pos-listp order))))
      (let ((__function__ 'defdefparse-reorder-alternation))
        (declare (ignorable __function__))
        (b* (((when (endp order)) nil)
             (index (1- (car order)))
             ((unless (< index (len alt)))
              (raise "Bad position ~x0 in ~x1." (car order)
                     alt)))
          (cons (concatenation-fix (nth index alt))
                (defdefparse-reorder-alternation alt (cdr order))))))

    Theorem: alternationp-of-defdefparse-reorder-alternation

    (defthm alternationp-of-defdefparse-reorder-alternation
      (b* ((new-alt (defdefparse-reorder-alternation alt order)))
        (alternationp new-alt))
      :rule-classes :rewrite)