Function:
(defun swap-vars (n m truth numvars) (declare (xargs :guard (and (natp n) (natp m) (integerp truth) (natp numvars)))) (declare (xargs :guard (and (< n numvars) (< m numvars)))) (let ((__function__ 'swap-vars)) (declare (ignorable __function__)) (cond ((< (lnfix n) (lnfix m)) (swap-vars-aux m n truth numvars)) ((< (lnfix m) (lnfix n)) (swap-vars-aux n m truth numvars)) (t (truth-norm truth numvars)))))
Theorem:
(defthm integerp-of-swap-vars (b* ((swapped-truth (swap-vars n m truth numvars))) (integerp swapped-truth)) :rule-classes :type-prescription)
Theorem:
(defthm swap-vars-commute (b* nil (equal (swap-vars m n truth numvars) (swap-vars n m truth numvars))) :rule-classes ((:rewrite :loop-stopper ((n m)))))
Theorem:
(defthm eval-of-swap-vars (b* ((?swapped-truth (swap-vars n m truth numvars))) (implies (and (< (nfix n) (nfix numvars)) (< (nfix m) (nfix numvars))) (equal (truth-eval swapped-truth env numvars) (truth-eval truth (env-swap-vars n m env) numvars)))))
Theorem:
(defthm size-of-swap-vars (b* ((?swapped-truth (swap-vars n m truth numvars))) (implies (and (< (nfix n) (nfix numvars)) (< (nfix m) (nfix numvars)) (natp size) (<= (ash 1 numvars) size)) (unsigned-byte-p size swapped-truth))))
Theorem:
(defthm swap-vars-self (b* nil (equal (swap-vars n n truth numvars) (truth-norm truth numvars))))
Theorem:
(defthm truth-norm-of-swap-vars (b* ((?swapped-truth (swap-vars n m truth numvars))) (implies (and (< (nfix n) (nfix numvars)) (< (nfix m) (nfix numvars))) (equal (truth-norm swapped-truth numvars) swapped-truth))))
Theorem:
(defthm swap-vars-of-truth-norm (equal (swap-vars n m (truth-norm truth numvars) numvars) (swap-vars n m truth numvars)))
Theorem:
(defthm swap-vars-of-nfix-n (equal (swap-vars (nfix n) m truth numvars) (swap-vars n m truth numvars)))
Theorem:
(defthm swap-vars-nat-equiv-congruence-on-n (implies (nat-equiv n n-equiv) (equal (swap-vars n m truth numvars) (swap-vars n-equiv m truth numvars))) :rule-classes :congruence)
Theorem:
(defthm swap-vars-of-nfix-m (equal (swap-vars n (nfix m) truth numvars) (swap-vars n m truth numvars)))
Theorem:
(defthm swap-vars-nat-equiv-congruence-on-m (implies (nat-equiv m m-equiv) (equal (swap-vars n m truth numvars) (swap-vars n m-equiv truth numvars))) :rule-classes :congruence)
Theorem:
(defthm swap-vars-of-ifix-truth (equal (swap-vars n m (ifix truth) numvars) (swap-vars n m truth numvars)))
Theorem:
(defthm swap-vars-int-equiv-congruence-on-truth (implies (int-equiv truth truth-equiv) (equal (swap-vars n m truth numvars) (swap-vars n m truth-equiv numvars))) :rule-classes :congruence)
Theorem:
(defthm swap-vars-of-nfix-numvars (equal (swap-vars n m truth (nfix numvars)) (swap-vars n m truth numvars)))
Theorem:
(defthm swap-vars-nat-equiv-congruence-on-numvars (implies (nat-equiv numvars numvars-equiv) (equal (swap-vars n m truth numvars) (swap-vars n m truth numvars-equiv))) :rule-classes :congruence)