Reorder the alternatives of an alternation.
(defdefparse-reorder-alternation alt order) → new-alt
The
This serves to try an alternative before another one, in order to satisfy extra-grammatical requirements.
Function:
(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:
(defthm alternationp-of-defdefparse-reorder-alternation (b* ((new-alt (defdefparse-reorder-alternation alt order))) (alternationp new-alt)) :rule-classes :rewrite)