Wrap an ABNF tree into a nest of ABNF trees with the given rule names as roots.
Macro:
(defmacro abnf-tree-wrap (tree &rest rulenames) (cons 'abnf-tree-wrap-fn (cons tree (cons (cons 'list rulenames) 'nil))))
Function:
(defun abnf-tree-wrap-fn (tree rulenames) (declare (xargs :guard (and (abnf::treep tree) (string-listp rulenames)))) (let ((__function__ 'abnf-tree-wrap-fn)) (declare (ignorable __function__)) (cond ((endp rulenames) (abnf::tree-fix tree)) (t (abnf-tree-wrap-fn (abnf::make-tree-nonleaf :rulename? (abnf::rulename (car rulenames)) :branches (list (list tree))) (cdr rulenames))))))
Theorem:
(defthm treep-of-abnf-tree-wrap-fn (b* ((wrapped-tree (abnf-tree-wrap-fn tree rulenames))) (abnf::treep wrapped-tree)) :rule-classes :rewrite)
Theorem:
(defthm abnf-tree-wrap-fn-of-tree-fix-tree (equal (abnf-tree-wrap-fn (abnf::tree-fix tree) rulenames) (abnf-tree-wrap-fn tree rulenames)))
Theorem:
(defthm abnf-tree-wrap-fn-tree-equiv-congruence-on-tree (implies (abnf::tree-equiv tree tree-equiv) (equal (abnf-tree-wrap-fn tree rulenames) (abnf-tree-wrap-fn tree-equiv rulenames))) :rule-classes :congruence)
Theorem:
(defthm abnf-tree-wrap-fn-of-string-list-fix-rulenames (equal (abnf-tree-wrap-fn tree (str::string-list-fix rulenames)) (abnf-tree-wrap-fn tree rulenames)))
Theorem:
(defthm abnf-tree-wrap-fn-string-list-equiv-congruence-on-rulenames (implies (str::string-list-equiv rulenames rulenames-equiv) (equal (abnf-tree-wrap-fn tree rulenames) (abnf-tree-wrap-fn tree rulenames-equiv))) :rule-classes :congruence)