Function:
(defun permute-polarity (n mask truth numvars) (declare (xargs :guard (and (natp n) (integerp mask) (integerp truth) (natp numvars)))) (declare (xargs :guard (<= n numvars))) (let ((__function__ 'permute-polarity)) (declare (ignorable __function__)) (b* (((when (mbe :logic (zp (- (nfix numvars) (nfix n))) :exec (eql n numvars))) (truth-norm truth numvars)) (truth (if (logbitp n mask) (swap-polarity n truth numvars) truth))) (permute-polarity (1+ (lnfix n)) mask truth numvars))))
Theorem:
(defthm integerp-of-permute-polarity (b* ((new-truth (permute-polarity n mask truth numvars))) (integerp new-truth)) :rule-classes :type-prescription)
Theorem:
(defthm eval-of-permute-polarity-with-env-permute-polarity (b* ((?new-truth (permute-polarity n mask truth numvars))) (equal (truth-eval new-truth (env-permute-polarity n mask env numvars) numvars) (truth-eval truth env numvars))))
Theorem:
(defthm eval-of-permute-polarity (b* ((?new-truth (permute-polarity n mask truth numvars))) (equal (truth-eval new-truth env numvars) (truth-eval truth (env-permute-polarity n mask env numvars) numvars))))
Theorem:
(defthm permute-polarity-size-basic (b* ((?new-truth (permute-polarity n mask truth numvars))) (unsigned-byte-p (ash 1 (nfix numvars)) new-truth)))
Theorem:
(defthm permute-polarity-size (b* ((?new-truth (permute-polarity n mask truth numvars))) (implies (and (natp size) (<= (ash 1 (nfix numvars)) size)) (unsigned-byte-p size new-truth))))
Theorem:
(defthm permute-polarity-identity (b* nil (equal (permute-polarity n 0 truth numvars) (truth-norm truth numvars))))
Theorem:
(defthm permute-polarity-of-truth-norm (equal (permute-polarity n mask (truth-norm truth numvars) numvars) (permute-polarity n mask truth numvars)))
Theorem:
(defthm permute-polarity-of-nfix-n (equal (permute-polarity (nfix n) mask truth numvars) (permute-polarity n mask truth numvars)))
Theorem:
(defthm permute-polarity-nat-equiv-congruence-on-n (implies (nat-equiv n n-equiv) (equal (permute-polarity n mask truth numvars) (permute-polarity n-equiv mask truth numvars))) :rule-classes :congruence)
Theorem:
(defthm permute-polarity-of-ifix-mask (equal (permute-polarity n (ifix mask) truth numvars) (permute-polarity n mask truth numvars)))
Theorem:
(defthm permute-polarity-int-equiv-congruence-on-mask (implies (int-equiv mask mask-equiv) (equal (permute-polarity n mask truth numvars) (permute-polarity n mask-equiv truth numvars))) :rule-classes :congruence)
Theorem:
(defthm permute-polarity-of-ifix-truth (equal (permute-polarity n mask (ifix truth) numvars) (permute-polarity n mask truth numvars)))
Theorem:
(defthm permute-polarity-int-equiv-congruence-on-truth (implies (int-equiv truth truth-equiv) (equal (permute-polarity n mask truth numvars) (permute-polarity n mask truth-equiv numvars))) :rule-classes :congruence)
Theorem:
(defthm permute-polarity-of-nfix-numvars (equal (permute-polarity n mask truth (nfix numvars)) (permute-polarity n mask truth numvars)))
Theorem:
(defthm permute-polarity-nat-equiv-congruence-on-numvars (implies (nat-equiv numvars numvars-equiv) (equal (permute-polarity n mask truth numvars) (permute-polarity n mask truth numvars-equiv))) :rule-classes :congruence)