Recognize XDOC trees.
These are the trees produced by the XDOC constructors.
These trees have strings at the leaves. A non-leaf node consists of one of the following:
In some sense, the semantics of XDOC trees is defined by their conversion to flat strings. See tree-to-string.
Function:
(defun treep (x) (or (stringp x) (and (true-listp x) (consp x) (or (keywordp (car x)) (tree-tagp (car x))) (tree-listp (cdr x)))))
Function:
(defun tree-listp (x) (cond ((atom x) (eq x nil)) (t (and (treep (car x)) (tree-listp (cdr x))))))
Function:
(defun tree-tagp (x) (and (consp x) (keywordp (car x)) (keyword-tree-alistp (cdr x))))
Function:
(defun keyword-tree-alistp (x) (cond ((atom x) (eq x nil)) (t (and (consp (car x)) (keywordp (car (car x))) (treep (cdr (car x))) (keyword-tree-alistp (cdr x))))))
Theorem:
(defthm treep-when-stringp (implies (stringp x) (treep x)))
Theorem:
(defthm tree-listp-when-string-listp (implies (string-listp x) (tree-listp x)))
Theorem:
(defthm true-listp-when-tree-listp (implies (tree-listp x) (true-listp x)) :rule-classes :forward-chaining)
Theorem:
(defthm treep-of-cons (equal (treep (cons x y)) (and (or (keywordp x) (tree-tagp x)) (tree-listp y))))
Theorem:
(defthm tree-listp-of-cons (equal (tree-listp (cons x y)) (and (treep x) (tree-listp y))))
Theorem:
(defthm tagp-of-cons (equal (tree-tagp (cons x y)) (and (keywordp x) (keyword-tree-alistp y))))
Theorem:
(defthm keyword-tree-alistp-of-cons (equal (keyword-tree-alistp (cons x y)) (and (consp x) (keywordp (car x)) (treep (cdr x)) (keyword-tree-alistp y))))