Function:
(defun index-permute-stretch (n count mask x numvars) (declare (xargs :guard (and (natp n) (natp mask) (natp x) (natp numvars)))) (declare (xargs :guard (and (<= n numvars) (eql count (logcount (loghead n mask)))))) (let ((__function__ 'index-permute-stretch)) (declare (ignorable __function__)) (b* (((when (mbe :logic (zp (- (nfix numvars) (nfix n))) :exec (eql n numvars))) (lnfix x)) (n (lnfix n)) (count (mbe :logic (logcount (loghead n (lnfix mask))) :exec count)) (bit (logbit n (lnfix mask))) (x (index-permute-stretch (1+ n) (+ bit count) mask x numvars))) (if (eql bit 1) (index-move-up count n x) x))))
Theorem:
(defthm natp-of-index-permute-stretch (b* ((perm-index (index-permute-stretch n count mask x numvars))) (natp perm-index)) :rule-classes :type-prescription)
Theorem:
(defthm index-permute-stretch-bound (b* ((?perm-index (index-permute-stretch n count mask x numvars))) (implies (< (nfix x) (nfix numvars)) (< perm-index (nfix numvars)))) :rule-classes :linear)
Theorem:
(defthm index-permute-stretch-normalize-count (implies (syntaxp (not (equal count ''nil))) (equal (index-permute-stretch n count mask x numvars) (index-permute-stretch n nil mask x numvars))))
Theorem:
(defthm index-permute-stretch-of-nfix-n (equal (index-permute-stretch (nfix n) count mask x numvars) (index-permute-stretch n count mask x numvars)))
Theorem:
(defthm index-permute-stretch-nat-equiv-congruence-on-n (implies (nat-equiv n n-equiv) (equal (index-permute-stretch n count mask x numvars) (index-permute-stretch n-equiv count mask x numvars))) :rule-classes :congruence)
Theorem:
(defthm index-permute-stretch-of-nfix-mask (equal (index-permute-stretch n count (nfix mask) x numvars) (index-permute-stretch n count mask x numvars)))
Theorem:
(defthm index-permute-stretch-nat-equiv-congruence-on-mask (implies (nat-equiv mask mask-equiv) (equal (index-permute-stretch n count mask x numvars) (index-permute-stretch n count mask-equiv x numvars))) :rule-classes :congruence)
Theorem:
(defthm index-permute-stretch-of-nfix-x (equal (index-permute-stretch n count mask (nfix x) numvars) (index-permute-stretch n count mask x numvars)))
Theorem:
(defthm index-permute-stretch-nat-equiv-congruence-on-x (implies (nat-equiv x x-equiv) (equal (index-permute-stretch n count mask x numvars) (index-permute-stretch n count mask x-equiv numvars))) :rule-classes :congruence)
Theorem:
(defthm index-permute-stretch-of-nfix-numvars (equal (index-permute-stretch n count mask x (nfix numvars)) (index-permute-stretch n count mask x numvars)))
Theorem:
(defthm index-permute-stretch-nat-equiv-congruence-on-numvars (implies (nat-equiv numvars numvars-equiv) (equal (index-permute-stretch n count mask x numvars) (index-permute-stretch n count mask x numvars-equiv))) :rule-classes :congruence)