Type of a value.
This is straightforward, as values carry type information. For an array value, we always return an array type with a size, which is the length of the array, which is always positive.
Function:
(defun type-of-value (val) (declare (xargs :guard (valuep val))) (let ((__function__ 'type-of-value)) (declare (ignorable __function__)) (value-case val :uchar (type-uchar) :schar (type-schar) :ushort (type-ushort) :sshort (type-sshort) :uint (type-uint) :sint (type-sint) :ulong (type-ulong) :slong (type-slong) :ullong (type-ullong) :sllong (type-sllong) :pointer (type-pointer val.reftype) :array (make-type-array :of val.elemtype :size (len val.elements)) :struct (type-struct val.tag))))
Theorem:
(defthm typep-of-type-of-value (b* ((type (type-of-value val))) (typep type)) :rule-classes :rewrite)
Theorem:
(defthm type-kind-of-type-of-value (equal (type-kind (type-of-value val)) (value-kind val)))
Theorem:
(defthm type-signed-integerp-of-type-of-value (equal (type-signed-integerp (type-of-value val)) (value-signed-integerp val)))
Theorem:
(defthm type-unsigned-integerp-of-type-of-value (equal (type-unsigned-integerp (type-of-value val)) (value-unsigned-integerp val)))
Theorem:
(defthm type-integerp-of-type-of-value (equal (type-integerp (type-of-value val)) (value-integerp val)))
Theorem:
(defthm type-realp-of-type-of-value (equal (type-realp (type-of-value val)) (value-realp val)))
Theorem:
(defthm type-arithmeticp-of-type-of-value (equal (type-arithmeticp (type-of-value val)) (value-arithmeticp val)))
Theorem:
(defthm type-scalarp-of-type-of-value (equal (type-scalarp (type-of-value val)) (value-scalarp val)))
Theorem:
(defthm type-promoted-arithmeticp-of-type-of-value (equal (type-promoted-arithmeticp (type-of-value val)) (value-promoted-arithmeticp val)))
Theorem:
(defthm type-nonchar-integerp-of-type-of-value (equal (type-nonchar-integerp (type-of-value val)) (value-integerp val)))
Theorem:
(defthm type-of-value-of-value-fix-val (equal (type-of-value (value-fix val)) (type-of-value val)))
Theorem:
(defthm type-of-value-value-equiv-congruence-on-val (implies (value-equiv val val-equiv) (equal (type-of-value val) (type-of-value val-equiv))) :rule-classes :congruence)