Parse a string.
If the string has a finite number of parse trees,
return the finite set of its parse trees.
Otherwise, return
Function:
(defun parse (string rulename rules) (declare (xargs :guard (and (stringp string) (rulenamep rulename) (rulelistp rules)))) (if (string-has-finite-parse-trees-p string rulename rules) (string-has-finite-parse-trees-p-witness string rulename rules) :infinite))
Theorem:
(defthm return-type-of-parse (b* ((result (parse string rulename rules))) (or (tree-setp result) (equal result :infinite))) :rule-classes :rewrite)
Theorem:
(defthm distinguish-infinite-from-trees (not (tree-setp :infinite)))
Theorem:
(defthm parse-when-not-string-parsablep (implies (not (string-parsablep string rulename rules)) (equal (parse string rulename rules) nil)))
Theorem:
(defthm parse-when-string-unambiguousp (implies (string-unambiguousp string rulename rules) (equal (parse string rulename rules) (insert (string-parsablep-witness string rulename rules) nil))))
Theorem:
(defthm not-string-parsablep-when-parse-nil (implies (equal (parse string rulename rules) nil) (not (string-parsablep string rulename rules))))
Theorem:
(defthm string-unambiguousp-when-parse-one (implies (equal (parse string rulename rules) (insert (string-parsablep-witness string rulename rules) nil)) (string-unambiguousp string rulename rules)))