update-nth for svexlists, with proper fty-discipline.
(svex-update-nth n v x) → new-x
Function:
(defun svex-update-nth (n v x) (declare (xargs :guard (and (natp n) (svex-p v) (svexlist-p x)))) (let ((__function__ 'svex-update-nth)) (declare (ignorable __function__)) (mbe :logic (svexlist-fix (update-nth n v x)) :exec (if (<= n (len x)) (update-nth n v x) (append x (replicate (- n (len x)) (svex-quote (4vec-x))) (list v))))))
Theorem:
(defthm svexlist-p-of-svex-update-nth (b* ((new-x (svex-update-nth n v x))) (svexlist-p new-x)) :rule-classes :rewrite)
Theorem:
(defthm svex-update-nth-of-nfix-n (equal (svex-update-nth (nfix n) v x) (svex-update-nth n v x)))
Theorem:
(defthm svex-update-nth-nat-equiv-congruence-on-n (implies (nat-equiv n n-equiv) (equal (svex-update-nth n v x) (svex-update-nth n-equiv v x))) :rule-classes :congruence)
Theorem:
(defthm svex-update-nth-of-svex-fix-v (equal (svex-update-nth n (svex-fix v) x) (svex-update-nth n v x)))
Theorem:
(defthm svex-update-nth-svex-equiv-congruence-on-v (implies (svex-equiv v v-equiv) (equal (svex-update-nth n v x) (svex-update-nth n v-equiv x))) :rule-classes :congruence)
Theorem:
(defthm svex-update-nth-of-svexlist-fix-x (equal (svex-update-nth n v (svexlist-fix x)) (svex-update-nth n v x)))
Theorem:
(defthm svex-update-nth-svexlist-equiv-congruence-on-x (implies (svexlist-equiv x x-equiv) (equal (svex-update-nth n v x) (svex-update-nth n v x-equiv))) :rule-classes :congruence)