Fixing function for expression structures.
(expression-fix x) → new-x
Function:
(defun expression-fix$inline (x) (declare (xargs :guard (expressionp x))) (let ((__function__ 'expression-fix)) (declare (ignorable __function__)) (mbe :logic (case (expression-kind x) (:const (b* ((value (ifix (std::da-nth 0 (cdr x))))) (cons :const (list value)))) (:var (b* ((name (str-fix (std::da-nth 0 (cdr x))))) (cons :var (list name)))) (:add (b* ((arg1 (expression-fix (std::da-nth 0 (cdr x)))) (arg2 (expression-fix (std::da-nth 1 (cdr x))))) (cons :add (list arg1 arg2)))) (:mul (b* ((arg1 (expression-fix (std::da-nth 0 (cdr x)))) (arg2 (expression-fix (std::da-nth 1 (cdr x))))) (cons :mul (list arg1 arg2))))) :exec x)))
Theorem:
(defthm expressionp-of-expression-fix (b* ((new-x (expression-fix$inline x))) (expressionp new-x)) :rule-classes :rewrite)
Theorem:
(defthm expression-fix-when-expressionp (implies (expressionp x) (equal (expression-fix x) x)))
Function:
(defun expression-equiv$inline (acl2::x acl2::y) (declare (xargs :guard (and (expressionp acl2::x) (expressionp acl2::y)))) (equal (expression-fix acl2::x) (expression-fix acl2::y)))
Theorem:
(defthm expression-equiv-is-an-equivalence (and (booleanp (expression-equiv x y)) (expression-equiv x x) (implies (expression-equiv x y) (expression-equiv y x)) (implies (and (expression-equiv x y) (expression-equiv y z)) (expression-equiv x z))) :rule-classes (:equivalence))
Theorem:
(defthm expression-equiv-implies-equal-expression-fix-1 (implies (expression-equiv acl2::x x-equiv) (equal (expression-fix acl2::x) (expression-fix x-equiv))) :rule-classes (:congruence))
Theorem:
(defthm expression-fix-under-expression-equiv (expression-equiv (expression-fix acl2::x) acl2::x) :rule-classes (:rewrite :rewrite-quoted-constant))
Theorem:
(defthm equal-of-expression-fix-1-forward-to-expression-equiv (implies (equal (expression-fix acl2::x) acl2::y) (expression-equiv acl2::x acl2::y)) :rule-classes :forward-chaining)
Theorem:
(defthm equal-of-expression-fix-2-forward-to-expression-equiv (implies (equal acl2::x (expression-fix acl2::y)) (expression-equiv acl2::x acl2::y)) :rule-classes :forward-chaining)
Theorem:
(defthm expression-equiv-of-expression-fix-1-forward (implies (expression-equiv (expression-fix acl2::x) acl2::y) (expression-equiv acl2::x acl2::y)) :rule-classes :forward-chaining)
Theorem:
(defthm expression-equiv-of-expression-fix-2-forward (implies (expression-equiv acl2::x (expression-fix acl2::y)) (expression-equiv acl2::x acl2::y)) :rule-classes :forward-chaining)
Theorem:
(defthm expression-kind$inline-of-expression-fix-x (equal (expression-kind$inline (expression-fix x)) (expression-kind$inline x)))
Theorem:
(defthm expression-kind$inline-expression-equiv-congruence-on-x (implies (expression-equiv x x-equiv) (equal (expression-kind$inline x) (expression-kind$inline x-equiv))) :rule-classes :congruence)
Theorem:
(defthm consp-of-expression-fix (consp (expression-fix x)) :rule-classes :type-prescription)