Function:
(defun index-move-up (m n x) (declare (xargs :guard (and (natp m) (natp n) (natp x)))) (declare (xargs :guard (<= m n))) (let ((__function__ 'index-move-up)) (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-swap next m x))) (index-move-up next n x))))
Theorem:
(defthm natp-of-index-move-up (b* ((perm-idx (index-move-up m n x))) (natp perm-idx)) :rule-classes :type-prescription)
Theorem:
(defthm index-move-up-redef (equal (index-move-up m n x) (b* ((x (nfix x)) (m (nfix m)) (n (nfix n))) (cond ((<= n m) x) ((< x m) x) ((eql x m) n) ((<= x n) (1- x)) (t x)))))
Theorem:
(defthm index-move-up-of-nfix-m (equal (index-move-up (nfix m) n x) (index-move-up m n x)))
Theorem:
(defthm index-move-up-nat-equiv-congruence-on-m (implies (nat-equiv m m-equiv) (equal (index-move-up m n x) (index-move-up m-equiv n x))) :rule-classes :congruence)
Theorem:
(defthm index-move-up-of-nfix-n (equal (index-move-up m (nfix n) x) (index-move-up m n x)))
Theorem:
(defthm index-move-up-nat-equiv-congruence-on-n (implies (nat-equiv n n-equiv) (equal (index-move-up m n x) (index-move-up m n-equiv x))) :rule-classes :congruence)
Theorem:
(defthm index-move-up-of-nfix-x (equal (index-move-up m n (nfix x)) (index-move-up m n x)))
Theorem:
(defthm index-move-up-nat-equiv-congruence-on-x (implies (nat-equiv x x-equiv) (equal (index-move-up m n x) (index-move-up m n x-equiv))) :rule-classes :congruence)