Function:
(defun env-swap-vars (n m env) (declare (xargs :guard (and (natp n) (natp m) (natp env)))) (let ((__function__ 'env-swap-vars)) (declare (ignorable __function__)) (b* ((env (lnfix env)) (n (lnfix n)) (m (lnfix m))) (env-update n (env-lookup m env) (env-update m (env-lookup n env) env)))))
Theorem:
(defthm natp-of-env-swap-vars (b* ((swap-env (env-swap-vars n m env))) (natp swap-env)) :rule-classes :type-prescription)
Theorem:
(defthm env-swap-vars-commute (equal (env-swap-vars m n x) (env-swap-vars n m x)) :rule-classes ((:rewrite :loop-stopper ((n m)))))
Theorem:
(defthm lookup-in-env-swap-vars (b* ((?swap-env (env-swap-vars n m env))) (equal (env-lookup k swap-env) (env-lookup (index-swap n m k) env))))
Theorem:
(defthm env-swap-vars-inverse (equal (env-swap-vars n m (env-swap-vars n m env)) (nfix env)))
Theorem:
(defthm env-swap-vars-self (equal (env-swap-vars n n env) (nfix env)))
Theorem:
(defthm env-swap-vars-of-nfix-n (equal (env-swap-vars (nfix n) m env) (env-swap-vars n m env)))
Theorem:
(defthm env-swap-vars-nat-equiv-congruence-on-n (implies (nat-equiv n n-equiv) (equal (env-swap-vars n m env) (env-swap-vars n-equiv m env))) :rule-classes :congruence)
Theorem:
(defthm env-swap-vars-of-nfix-m (equal (env-swap-vars n (nfix m) env) (env-swap-vars n m env)))
Theorem:
(defthm env-swap-vars-nat-equiv-congruence-on-m (implies (nat-equiv m m-equiv) (equal (env-swap-vars n m env) (env-swap-vars n m-equiv env))) :rule-classes :congruence)
Theorem:
(defthm env-swap-vars-of-nfix-env (equal (env-swap-vars n m (nfix env)) (env-swap-vars n m env)))
Theorem:
(defthm env-swap-vars-nat-equiv-congruence-on-env (implies (nat-equiv env env-equiv) (equal (env-swap-vars n m env) (env-swap-vars n m env-equiv))) :rule-classes :congruence)