Function:
(defun index-perm-rev (n perm x numvars) (declare (xargs :guard (and (natp n) (nat-listp perm) (natp x) (natp numvars)))) (declare (xargs :guard (and (<= n numvars) (eql (len perm) numvars)))) (let ((__function__ 'index-perm-rev)) (declare (ignorable __function__)) (b* (((when (mbe :logic (zp (- (nfix numvars) (nfix n))) :exec (eql n numvars))) (lnfix x)) (x (index-perm-rev (1+ (lnfix n)) perm x numvars))) (index-swap n (nth n perm) x))))
Theorem:
(defthm natp-of-index-perm-rev (b* ((perm-idx (index-perm-rev n perm x numvars))) (natp perm-idx)) :rule-classes :type-prescription)
Theorem:
(defthm index-perm-of-index-perm-rev (equal (index-perm n perm (index-perm-rev n perm x numvars) numvars) (nfix x)))
Theorem:
(defthm index-perm-rev-of-index-perm (equal (index-perm-rev n perm (index-perm n perm x numvars) numvars) (nfix x)))
Theorem:
(defthm bound-of-index-perm-rev (b* ((?perm-idx (index-perm-rev n perm x numvars))) (implies (and (< (nfix x) (nfix numvars)) (index-listp perm numvars)) (< perm-idx (nfix numvars)))) :rule-classes :linear)
Theorem:
(defthm index-perm-rev-unique (iff (equal (index-perm-rev n perm x numvars) (index-perm-rev n perm y numvars)) (equal (nfix x) (nfix y))))
Theorem:
(defthm index-perm-rev-of-nfix-n (equal (index-perm-rev (nfix n) perm x numvars) (index-perm-rev n perm x numvars)))
Theorem:
(defthm index-perm-rev-nat-equiv-congruence-on-n (implies (nat-equiv n n-equiv) (equal (index-perm-rev n perm x numvars) (index-perm-rev n-equiv perm x numvars))) :rule-classes :congruence)
Theorem:
(defthm index-perm-rev-of-nfix-x (equal (index-perm-rev n perm (nfix x) numvars) (index-perm-rev n perm x numvars)))
Theorem:
(defthm index-perm-rev-nat-equiv-congruence-on-x (implies (nat-equiv x x-equiv) (equal (index-perm-rev n perm x numvars) (index-perm-rev n perm x-equiv numvars))) :rule-classes :congruence)
Theorem:
(defthm index-perm-rev-of-nfix-numvars (equal (index-perm-rev n perm x (nfix numvars)) (index-perm-rev n perm x numvars)))
Theorem:
(defthm index-perm-rev-nat-equiv-congruence-on-numvars (implies (nat-equiv numvars numvars-equiv) (equal (index-perm-rev n perm x numvars) (index-perm-rev n perm x numvars-equiv))) :rule-classes :congruence)