All the input/output constraints for the Unicode escape parser.
(uniescape-parse-constraints-p unicodes trees) → yes/no
The Unicode escape parser
takes as input a list of Unicode characters
and returns as output a list of parsed
As motivated in the overview, the parser omits the check that some-uniescape-candidate-invalid-p does not hold, which does not involve the output anyhow. This check in the top-level function that formalizes Unicode escape processing, of which he parser is a component.
Here we express the constraints of the output with respect to the input. The string at the leaves of the trees must be the input string: this is the grammatical constraint. The other constraints are the necessary and sufficient conditions for parsed Unicode escape trees:
These constraints should uniquely characterize the output for every possible input, but this remains to be proved formally.
Function:
(defun uniescape-parse-constraints-p (unicodes trees) (declare (xargs :guard (and (unicode-listp unicodes) (abnf-tree-list-with-root-p trees "unicode-input-character")))) (and (equal (abnf::tree-list->string trees) unicodes) (even-backslashes-tree-constraints-p trees) (uniescape-tree-constraints-p trees)))
Theorem:
(defthm booleanp-of-uniescape-parse-constraints-p (b* ((yes/no (uniescape-parse-constraints-p unicodes trees))) (booleanp yes/no)) :rule-classes :rewrite)