Function:
(defun index-move-down (m n x) (declare (xargs :guard (and (natp m) (natp n) (natp x)))) (declare (xargs :guard (<= m n))) (let ((__function__ 'index-move-down)) (declare (ignorable __function__)) (b* (((when (mbe :logic (zp (- (nfix n) (nfix m))) :exec (eql n m))) (lnfix x)) (next (1+ (lnfix m))) (x (lnfix x)) (x (index-move-down next n x))) (index-swap next m x))))
Theorem:
(defthm natp-of-index-move-down (b* ((perm-idx (index-move-down m n x))) (natp perm-idx)) :rule-classes :type-prescription)
Theorem:
(defthm index-move-down-redef (equal (index-move-down m n x) (b* ((x (nfix x)) (m (nfix m)) (n (nfix n))) (cond ((<= n m) x) ((< x m) x) ((< x n) (1+ x)) ((eql x n) m) (t x)))))
Theorem:
(defthm index-move-up-of-index-move-down (equal (index-move-up n m (index-move-down n m x)) (nfix x)))
Theorem:
(defthm index-move-down-of-index-move-up (equal (index-move-down n m (index-move-up n m x)) (nfix x)))
Theorem:
(defthm index-move-down-of-nfix-m (equal (index-move-down (nfix m) n x) (index-move-down m n x)))
Theorem:
(defthm index-move-down-nat-equiv-congruence-on-m (implies (nat-equiv m m-equiv) (equal (index-move-down m n x) (index-move-down m-equiv n x))) :rule-classes :congruence)
Theorem:
(defthm index-move-down-of-nfix-n (equal (index-move-down m (nfix n) x) (index-move-down m n x)))
Theorem:
(defthm index-move-down-nat-equiv-congruence-on-n (implies (nat-equiv n n-equiv) (equal (index-move-down m n x) (index-move-down m n-equiv x))) :rule-classes :congruence)
Theorem:
(defthm index-move-down-of-nfix-x (equal (index-move-down m n (nfix x)) (index-move-down m n x)))
Theorem:
(defthm index-move-down-nat-equiv-congruence-on-x (implies (nat-equiv x x-equiv) (equal (index-move-down m n x) (index-move-down m n x-equiv))) :rule-classes :congruence)