Lex an
(lex-identifier/keyword/boolean/address input) → (mv tree rest-input)
Lexically, these are all identifiers, in the sense that
they are instances of the
Note that keywords, boolean literals, and address literals are all disjoint.
Function:
(defun lex-identifier/keyword/boolean/address (input) (declare (xargs :guard (nat-listp input))) (let ((__function__ 'lex-identifier/keyword/boolean/address)) (declare (ignorable __function__)) (b* (((mv tree input1) (lex-identifier input)) ((when (reserrp tree)) (mv (reserrf-push tree) input1)) (nats (abnf::tree->string tree)) ((unless (unsigned-byte-listp 8 nats)) (mv (reserrf :impossible) input1)) (str (nats=>string nats)) ((when (member-equal str *keywords*)) (mv (abnf-tree-wrap (abnf::tree-leafterm nats) "keyword") input1)) ((when (member-equal str (list "true" "false"))) (mv (abnf-tree-wrap (abnf::tree-leafterm nats) "boolean-literal") input1)) ((when (address-string-p str)) (b* (((mv tree input) (lex-address-literal input)) ((when (reserrp tree)) (mv (reserrf :impossible) input))) (mv tree input))) ((when (and (>= (length str) 5) (equal (subseq str 0 5) "aleo1"))) (mv (reserrf (list :found str)) input1))) (mv tree input1))))
Theorem:
(defthm tree-resultp-of-lex-identifier/keyword/boolean/address.tree (b* (((mv ?tree ?rest-input) (lex-identifier/keyword/boolean/address input))) (abnf::tree-resultp tree)) :rule-classes :rewrite)
Theorem:
(defthm nat-listp-of-lex-identifier/keyword/boolean/address.rest-input (b* (((mv ?tree ?rest-input) (lex-identifier/keyword/boolean/address input))) (nat-listp rest-input)) :rule-classes :rewrite)
Theorem:
(defthm len-of-lex-identifier/keyword/boolean/address-<= (b* (((mv ?tree ?rest-input) (lex-identifier/keyword/boolean/address input))) (<= (len rest-input) (len input))) :rule-classes :linear)
Theorem:
(defthm len-of-lex-identifier/keyword/boolean/address-< (b* (((mv ?tree ?rest-input) (lex-identifier/keyword/boolean/address input))) (implies (not (reserrp tree)) (< (len rest-input) (len input)))) :rule-classes :linear)
Theorem:
(defthm lex-identifier/keyword/boolean/address-of-nat-list-fix-input (equal (lex-identifier/keyword/boolean/address (nat-list-fix input)) (lex-identifier/keyword/boolean/address input)))
Theorem:
(defthm lex-identifier/keyword/boolean/address-nat-list-equiv-congruence-on-input (implies (acl2::nat-list-equiv input input-equiv) (equal (lex-identifier/keyword/boolean/address input) (lex-identifier/keyword/boolean/address input-equiv))) :rule-classes :congruence)