Check if a string has a finite number of parse trees.
If this is not true, the string is ambiguous, because it has an infinite number of parse trees.
Theorem:
(defthm string-has-finite-parse-trees-p-suff (implies (and (tree-setp trees) (parse-trees-of-string-p trees string rulename rules)) (string-has-finite-parse-trees-p string rulename rules)))
Theorem:
(defthm booleanp-of-string-has-finite-parse-trees-p (b* ((yes/no (string-has-finite-parse-trees-p string rulename rules))) (booleanp yes/no)) :rule-classes :rewrite)
Theorem:
(defthm string-has-finite-parse-trees-p-of-string-fix-string (equal (string-has-finite-parse-trees-p (string-fix string) rulename rules) (string-has-finite-parse-trees-p string rulename rules)))
Theorem:
(defthm string-has-finite-parse-trees-p-string-equiv-congruence-on-string (implies (string-equiv string string-equiv) (equal (string-has-finite-parse-trees-p string rulename rules) (string-has-finite-parse-trees-p string-equiv rulename rules))) :rule-classes :congruence)
Theorem:
(defthm string-has-finite-parse-trees-p-of-rulename-fix-rulename (equal (string-has-finite-parse-trees-p string (rulename-fix rulename) rules) (string-has-finite-parse-trees-p string rulename rules)))
Theorem:
(defthm string-has-finite-parse-trees-p-rulename-equiv-congruence-on-rulename (implies (rulename-equiv rulename rulename-equiv) (equal (string-has-finite-parse-trees-p string rulename rules) (string-has-finite-parse-trees-p string rulename-equiv rules))) :rule-classes :congruence)
Theorem:
(defthm string-has-finite-parse-trees-p-of-rulelist-fix-rules (equal (string-has-finite-parse-trees-p string rulename (rulelist-fix rules)) (string-has-finite-parse-trees-p string rulename rules)))
Theorem:
(defthm string-has-finite-parse-trees-p-rulelist-equiv-congruence-on-rules (implies (rulelist-equiv rules rules-equiv) (equal (string-has-finite-parse-trees-p string rulename rules) (string-has-finite-parse-trees-p string rulename rules-equiv))) :rule-classes :congruence)
Theorem:
(defthm tree-setp-of-witness-when-string-has-finite-parse-trees-p (implies (string-has-finite-parse-trees-p string rulename rules) (tree-setp (string-has-finite-parse-trees-p-witness string rulename rules))))
Theorem:
(defthm string-has-finite-parse-trees-p-when-not-string-parsablep (implies (not (string-parsablep string rulename rules)) (string-has-finite-parse-trees-p string rulename rules)))
Theorem:
(defthm string-has-finite-parse-trees-p-when-string-unambiguousp (implies (string-unambiguousp string rulename rules) (string-has-finite-parse-trees-p string rulename rules)))
Theorem:
(defthm string-has-finite-parse-trees-p-witness-when-not-string-parsablep (implies (not (string-parsablep string rulename rules)) (equal (string-has-finite-parse-trees-p-witness string rulename rules) nil)))
Theorem:
(defthm string-has-finite-parse-trees-p-witness-when-string-unambiguousp (implies (string-unambiguousp string rulename rules) (equal (string-has-finite-parse-trees-p-witness string rulename rules) (insert (string-parsablep-witness string rulename rules) nil))))
Theorem:
(defthm not-string-parsablep-when-string-has-finite-parse-trees-p-nil (implies (and (string-has-finite-parse-trees-p string rulename rules) (equal (string-has-finite-parse-trees-p-witness string rulename rules) nil)) (not (string-parsablep string rulename rules))))
Theorem:
(defthm string-unambiguousp-when-string-has-finite-parse-trees-p-one (implies (and (string-has-finite-parse-trees-p string rulename rules) (equal (string-has-finite-parse-trees-p-witness string rulename rules) (insert (string-parsablep-witness string rulename rules) nil))) (string-unambiguousp string rulename rules)))
Theorem:
(defthm string-ambiguousp-when-infinite-parse-trees (implies (not (string-has-finite-parse-trees-p string rulename rules)) (string-ambiguousp string rulename rules)))