Leo tuple reading operation.
(op-tuple-read tupval index) → result
This takes a value and a natural number index; the latter must be a numeral in the syntax. The value must be a tuple, otherwise it is an error. Furthermore, the index must be below the tuple length; tuples are zero-indexed.
Function:
(defun op-tuple-read (tupval index) (declare (xargs :guard (and (valuep tupval) (natp index)))) (let ((__function__ 'op-tuple-read)) (declare (ignorable __function__)) (if (and (value-case tupval :tuple) (< (nfix index) (len (value-tuple->components tupval)))) (nth (nfix index) (value-tuple->components tupval)) (reserrf (list :op-tuple-read (value-fix tupval) (nfix index))))))
Theorem:
(defthm value-resultp-of-op-tuple-read (b* ((result (op-tuple-read tupval index))) (value-resultp result)) :rule-classes :rewrite)
Theorem:
(defthm op-tuple-read-of-value-fix-tupval (equal (op-tuple-read (value-fix tupval) index) (op-tuple-read tupval index)))
Theorem:
(defthm op-tuple-read-value-equiv-congruence-on-tupval (implies (value-equiv tupval tupval-equiv) (equal (op-tuple-read tupval index) (op-tuple-read tupval-equiv index))) :rule-classes :congruence)
Theorem:
(defthm op-tuple-read-of-nfix-index (equal (op-tuple-read tupval (nfix index)) (op-tuple-read tupval index)))
Theorem:
(defthm op-tuple-read-nat-equiv-congruence-on-index (implies (acl2::nat-equiv index index-equiv) (equal (op-tuple-read tupval index) (op-tuple-read tupval index-equiv))) :rule-classes :congruence)