Fixing function for token structures.
Function:
(defun token-fix$inline (x) (declare (xargs :guard (tokenp x))) (let ((__function__ 'token-fix)) (declare (ignorable __function__)) (mbe :logic (case (token-kind x) (:keyword (b* ((unwrap (acl2::str-fix (std::da-nth 0 (cdr x))))) (cons :keyword (list unwrap)))) (:ident (b* ((unwrap (ident-fix (std::da-nth 0 (cdr x))))) (cons :ident (list unwrap)))) (:const (b* ((unwrap (const-fix (std::da-nth 0 (cdr x))))) (cons :const (list unwrap)))) (:string (b* ((unwrap (stringlit-fix (std::da-nth 0 (cdr x))))) (cons :string (list unwrap)))) (:punctuator (b* ((unwrap (acl2::str-fix (std::da-nth 0 (cdr x))))) (cons :punctuator (list unwrap))))) :exec x)))
Theorem:
(defthm tokenp-of-token-fix (b* ((new-x (token-fix$inline x))) (tokenp new-x)) :rule-classes :rewrite)
Theorem:
(defthm token-fix-when-tokenp (implies (tokenp x) (equal (token-fix x) x)))
Function:
(defun token-equiv$inline (acl2::x acl2::y) (declare (xargs :guard (and (tokenp acl2::x) (tokenp acl2::y)))) (equal (token-fix acl2::x) (token-fix acl2::y)))
Theorem:
(defthm token-equiv-is-an-equivalence (and (booleanp (token-equiv x y)) (token-equiv x x) (implies (token-equiv x y) (token-equiv y x)) (implies (and (token-equiv x y) (token-equiv y z)) (token-equiv x z))) :rule-classes (:equivalence))
Theorem:
(defthm token-equiv-implies-equal-token-fix-1 (implies (token-equiv acl2::x x-equiv) (equal (token-fix acl2::x) (token-fix x-equiv))) :rule-classes (:congruence))
Theorem:
(defthm token-fix-under-token-equiv (token-equiv (token-fix acl2::x) acl2::x) :rule-classes (:rewrite :rewrite-quoted-constant))
Theorem:
(defthm equal-of-token-fix-1-forward-to-token-equiv (implies (equal (token-fix acl2::x) acl2::y) (token-equiv acl2::x acl2::y)) :rule-classes :forward-chaining)
Theorem:
(defthm equal-of-token-fix-2-forward-to-token-equiv (implies (equal acl2::x (token-fix acl2::y)) (token-equiv acl2::x acl2::y)) :rule-classes :forward-chaining)
Theorem:
(defthm token-equiv-of-token-fix-1-forward (implies (token-equiv (token-fix acl2::x) acl2::y) (token-equiv acl2::x acl2::y)) :rule-classes :forward-chaining)
Theorem:
(defthm token-equiv-of-token-fix-2-forward (implies (token-equiv acl2::x (token-fix acl2::y)) (token-equiv acl2::x acl2::y)) :rule-classes :forward-chaining)
Theorem:
(defthm token-kind$inline-of-token-fix-x (equal (token-kind$inline (token-fix x)) (token-kind$inline x)))
Theorem:
(defthm token-kind$inline-token-equiv-congruence-on-x (implies (token-equiv x x-equiv) (equal (token-kind$inline x) (token-kind$inline x-equiv))) :rule-classes :congruence)
Theorem:
(defthm consp-of-token-fix (consp (token-fix x)) :rule-classes :type-prescription)