Fixing function for token structures.
Function:
(defun token-fix$inline (x) (declare (xargs :guard (tokenp x))) (mbe :logic (case (token-kind x) (:keyword (b* ((unwrap (acl2::str-fix (cdr x)))) (cons :keyword unwrap))) (:ident (b* ((unwrap (ident-fix (cdr x)))) (cons :ident unwrap))) (:const (b* ((unwrap (const-fix (cdr x)))) (cons :const unwrap))) (:string (b* ((unwrap (stringlit-fix (cdr x)))) (cons :string unwrap))) (:punctuator (b* ((unwrap (acl2::str-fix (cdr x)))) (cons :punctuator 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)
Theorem:
(defthm token-fix$inline-of-token-fix-x (equal (token-fix$inline (token-fix x)) (token-fix$inline x)))
Theorem:
(defthm token-fix$inline-token-equiv-congruence-on-x (implies (token-equiv x x-equiv) (equal (token-fix$inline x) (token-fix$inline x-equiv))) :rule-classes :congruence)