Write an element to an array of type
(schar-array-write array index element) → new-array
Function:
(defun schar-array-write (array index element) (declare (xargs :guard (and (schar-arrayp array) (cintegerp index) (scharp element)))) (declare (xargs :guard (schar-array-index-okp array index))) (let ((__function__ 'schar-array-write)) (declare (ignorable __function__)) (if (mbt (schar-array-index-okp array index)) (schar-array-of (update-nth (integer-from-cinteger index) (schar-fix element) (schar-array->elements array))) (schar-array-fix array))))
Theorem:
(defthm schar-arrayp-of-schar-array-write (b* ((new-array (schar-array-write array index element))) (schar-arrayp new-array)) :rule-classes :rewrite)
Theorem:
(defthm len-of-schar-array->elements-of-schar-array-write (equal (len (schar-array->elements (schar-array-write array index element))) (len (schar-array->elements array))))
Theorem:
(defthm schar-array-length-of-schar-array-write (equal (schar-array-length (schar-array-write array index element)) (schar-array-length array)))
Theorem:
(defthm schar-array-write-to-integer-write (equal (schar-array-write array index val) (schar-array-integer-write array (integer-from-cinteger index) val)))
Theorem:
(defthm schar-array-write-alt-def (implies (and (schar-arrayp array) (cintegerp index) (scharp elem) (schar-array-index-okp array index)) (equal (schar-array-write array index elem) (value-array-write (integer-from-cinteger index) elem array))))
Theorem:
(defthm schar-array-write-of-schar-array-fix-array (equal (schar-array-write (schar-array-fix array) index element) (schar-array-write array index element)))
Theorem:
(defthm schar-array-write-schar-array-equiv-congruence-on-array (implies (schar-array-equiv array array-equiv) (equal (schar-array-write array index element) (schar-array-write array-equiv index element))) :rule-classes :congruence)
Theorem:
(defthm schar-array-write-of-cinteger-fix-index (equal (schar-array-write array (cinteger-fix index) element) (schar-array-write array index element)))
Theorem:
(defthm schar-array-write-cinteger-equiv-congruence-on-index (implies (cinteger-equiv index index-equiv) (equal (schar-array-write array index element) (schar-array-write array index-equiv element))) :rule-classes :congruence)
Theorem:
(defthm schar-array-write-of-schar-fix-element (equal (schar-array-write array index (schar-fix element)) (schar-array-write array index element)))
Theorem:
(defthm schar-array-write-schar-equiv-congruence-on-element (implies (schar-equiv element element-equiv) (equal (schar-array-write array index element) (schar-array-write array index element-equiv))) :rule-classes :congruence)