Function:
(defun env-swap-polarity (n env) (declare (xargs :guard (and (natp n) (natp env)))) (let ((__function__ 'env-swap-polarity)) (declare (ignorable __function__)) (env-update n (not (env-lookup n env)) env)))
Theorem:
(defthm natp-of-env-swap-polarity (b* ((new-env (env-swap-polarity n env))) (natp new-env)) :rule-classes :type-prescription)
Theorem:
(defthm lookup-in-env-swap-polarity-same (b* ((?new-env (env-swap-polarity n env))) (equal (env-lookup n new-env) (not (env-lookup n env)))))
Theorem:
(defthm lookup-in-env-swap-polarity-diff (b* ((?new-env (env-swap-polarity n env))) (implies (not (nat-equiv n m)) (equal (env-lookup m new-env) (env-lookup m env)))))
Theorem:
(defthm lookup-in-env-swap-polarity-split (b* ((?new-env (env-swap-polarity n env))) (equal (env-lookup m new-env) (if (nat-equiv n m) (not (env-lookup n env)) (env-lookup m env)))))
Theorem:
(defthm env-swap-polarity-reverse (b* ((?new-env (env-swap-polarity n env))) (equal (env-swap-polarity n new-env) (nfix env))))
Theorem:
(defthm env-swap-polarity-commute (b* nil (equal (env-swap-polarity n (env-swap-polarity m env)) (env-swap-polarity m (env-swap-polarity n env)))) :rule-classes ((:rewrite :loop-stopper ((n m)))))
Theorem:
(defthm env-swap-polarity-of-nfix-n (equal (env-swap-polarity (nfix n) env) (env-swap-polarity n env)))
Theorem:
(defthm env-swap-polarity-nat-equiv-congruence-on-n (implies (nat-equiv n n-equiv) (equal (env-swap-polarity n env) (env-swap-polarity n-equiv env))) :rule-classes :congruence)
Theorem:
(defthm env-swap-polarity-of-nfix-env (equal (env-swap-polarity n (nfix env)) (env-swap-polarity n env)))
Theorem:
(defthm env-swap-polarity-nat-equiv-congruence-on-env (implies (nat-equiv env env-equiv) (equal (env-swap-polarity n env) (env-swap-polarity n env-equiv))) :rule-classes :congruence)