Function:
(defun env-permute-polarity (n mask env numvars) (declare (xargs :guard (and (natp n) (integerp mask) (natp env) (natp numvars)))) (declare (xargs :guard (<= n numvars))) (let ((__function__ 'env-permute-polarity)) (declare (ignorable __function__)) (b* (((when (mbe :logic (zp (- (nfix numvars) (nfix n))) :exec (eql n numvars))) (lnfix env)) (env (if (logbitp n mask) (env-swap-polarity n env) env))) (env-permute-polarity (1+ (lnfix n)) mask env numvars))))
Theorem:
(defthm natp-of-env-permute-polarity (b* ((new-env (env-permute-polarity n mask env numvars))) (natp new-env)) :rule-classes :type-prescription)
Theorem:
(defthm lookup-in-env-permute-polarity-split (b* ((?new-env (env-permute-polarity n mask env numvars))) (equal (env-lookup m new-env) (if (and (<= (nfix n) (nfix m)) (< (nfix m) (nfix numvars))) (xor (env-lookup m env) (logbitp m mask)) (env-lookup m env)))))
Theorem:
(defthm lookup-in-env-permute-polarity-set (b* nil (implies (and (logbitp m mask) (< (nfix m) (nfix numvars))) (equal (env-lookup m (env-permute-polarity 0 mask env numvars)) (not (env-lookup m env))))))
Theorem:
(defthm lookup-in-env-permute-polarity-unset (b* nil (implies (and (not (logbitp m mask)) (< (nfix m) (nfix numvars))) (equal (env-lookup m (env-permute-polarity n mask env numvars)) (env-lookup m env)))))
Theorem:
(defthm env-permute-polarity-of-swap-polarity (b* nil (equal (env-permute-polarity n mask (env-swap-polarity m env) numvars) (env-swap-polarity m (env-permute-polarity n mask env numvars)))))
Theorem:
(defthm env-permute-polarity-reverse (b* ((?new-env (env-permute-polarity n mask env numvars))) (equal (env-permute-polarity n mask new-env numvars) (nfix env))))
Theorem:
(defthm env-permute-polarity-of-nfix-n (equal (env-permute-polarity (nfix n) mask env numvars) (env-permute-polarity n mask env numvars)))
Theorem:
(defthm env-permute-polarity-nat-equiv-congruence-on-n (implies (nat-equiv n n-equiv) (equal (env-permute-polarity n mask env numvars) (env-permute-polarity n-equiv mask env numvars))) :rule-classes :congruence)
Theorem:
(defthm env-permute-polarity-of-ifix-mask (equal (env-permute-polarity n (ifix mask) env numvars) (env-permute-polarity n mask env numvars)))
Theorem:
(defthm env-permute-polarity-int-equiv-congruence-on-mask (implies (int-equiv mask mask-equiv) (equal (env-permute-polarity n mask env numvars) (env-permute-polarity n mask-equiv env numvars))) :rule-classes :congruence)
Theorem:
(defthm env-permute-polarity-of-nfix-env (equal (env-permute-polarity n mask (nfix env) numvars) (env-permute-polarity n mask env numvars)))
Theorem:
(defthm env-permute-polarity-nat-equiv-congruence-on-env (implies (nat-equiv env env-equiv) (equal (env-permute-polarity n mask env numvars) (env-permute-polarity n mask env-equiv numvars))) :rule-classes :congruence)
Theorem:
(defthm env-permute-polarity-of-nfix-numvars (equal (env-permute-polarity n mask env (nfix numvars)) (env-permute-polarity n mask env numvars)))
Theorem:
(defthm env-permute-polarity-nat-equiv-congruence-on-numvars (implies (nat-equiv numvars numvars-equiv) (equal (env-permute-polarity n mask env numvars) (env-permute-polarity n mask env numvars-equiv))) :rule-classes :congruence)