Recognize the parse trees of a string, with respect to a rule name and a list of rules.
Given a list of rules, a rule name, and a string, a parse tree for the string is a tree that matches the rule name (viewed as an element) and such that the string is the one at the leaves of the tree. A parse tree describes how a string is an ``instance'' of the rule name, given the rules.
Function:
(defun parse-treep (tree string rulename rules) (declare (xargs :guard (and (stringp string) (rulenamep rulename) (rulelistp rules)))) (and (treep tree) (tree-match-element-p tree (element-rulename rulename) rules) (equal (tree->string tree) (string-fix string))))
Theorem:
(defthm booleanp-of-parse-treep (b* ((yes/no (parse-treep tree string rulename rules))) (booleanp yes/no)) :rule-classes :rewrite)
Theorem:
(defthm treep-when-parse-treep (implies (parse-treep tree string rulename rules) (treep tree)))
Theorem:
(defthm parse-treep-of-string-fix-string (equal (parse-treep tree (string-fix string) rulename rules) (parse-treep tree string rulename rules)))
Theorem:
(defthm parse-treep-string-equiv-congruence-on-string (implies (string-equiv string string-equiv) (equal (parse-treep tree string rulename rules) (parse-treep tree string-equiv rulename rules))) :rule-classes :congruence)
Theorem:
(defthm parse-treep-of-rulename-fix-rulename (equal (parse-treep tree string (rulename-fix rulename) rules) (parse-treep tree string rulename rules)))
Theorem:
(defthm parse-treep-rulename-equiv-congruence-on-rulename (implies (rulename-equiv rulename rulename-equiv) (equal (parse-treep tree string rulename rules) (parse-treep tree string rulename-equiv rules))) :rule-classes :congruence)
Theorem:
(defthm parse-treep-of-rulelist-fix-rules (equal (parse-treep tree string rulename (rulelist-fix rules)) (parse-treep tree string rulename rules)))
Theorem:
(defthm parse-treep-rulelist-equiv-congruence-on-rules (implies (rulelist-equiv rules rules-equiv) (equal (parse-treep tree string rulename rules) (parse-treep tree string rulename rules-equiv))) :rule-classes :congruence)