Function:
(defun index-swap (n m x) (declare (xargs :guard (and (natp n) (natp m) (natp x)))) (let ((__function__ 'index-swap)) (declare (ignorable __function__)) (b* ((x (lnfix x)) (n (lnfix n)) (m (lnfix m))) (cond ((eql x n) m) ((eql x m) n) (t x)))))
Theorem:
(defthm natp-of-index-swap (b* ((swap (index-swap n m x))) (natp swap)) :rule-classes :type-prescription)
Theorem:
(defthm index-swap-commute (equal (index-swap m n x) (index-swap n m x)) :rule-classes ((:rewrite :loop-stopper ((n m)))))
Theorem:
(defthm index-swap-inverse (equal (index-swap n m (index-swap n m x)) (nfix x)))
Theorem:
(defthm index-swap-n (equal (index-swap n m n) (nfix m)))
Theorem:
(defthm index-swap-m (equal (index-swap n m m) (nfix n)))
Theorem:
(defthm index-swap-unaffected (implies (and (not (nat-equiv n x)) (not (nat-equiv m x))) (equal (index-swap n m x) (nfix x))))
Theorem:
(defthm index-swap-self (equal (index-swap n n x) (nfix x)))
Theorem:
(defthm index-swap-unique (iff (equal (index-swap n m x) (index-swap n m y)) (equal (nfix x) (nfix y))))
Theorem:
(defthm index-swap-of-nfix-n (equal (index-swap (nfix n) m x) (index-swap n m x)))
Theorem:
(defthm index-swap-nat-equiv-congruence-on-n (implies (nat-equiv n n-equiv) (equal (index-swap n m x) (index-swap n-equiv m x))) :rule-classes :congruence)
Theorem:
(defthm index-swap-of-nfix-m (equal (index-swap n (nfix m) x) (index-swap n m x)))
Theorem:
(defthm index-swap-nat-equiv-congruence-on-m (implies (nat-equiv m m-equiv) (equal (index-swap n m x) (index-swap n m-equiv x))) :rule-classes :congruence)
Theorem:
(defthm index-swap-of-nfix-x (equal (index-swap n m (nfix x)) (index-swap n m x)))
Theorem:
(defthm index-swap-nat-equiv-congruence-on-x (implies (nat-equiv x x-equiv) (equal (index-swap n m x) (index-swap n m x-equiv))) :rule-classes :congruence)