Check if a type is complete [C:6.2.5].
A type is complete when its size is determined, otherwise it is incomplete. While [C:6.2.5] cautions that the same type may be complete or incomplete in different parts of a program, for now we capture the completeness of a type independently from where it occurs: this is adequate for our C subset and for our use of this predicate.
The
Function:
(defun type-completep (type) (declare (xargs :guard (typep type))) (let ((__function__ 'type-completep)) (declare (ignorable __function__)) (cond ((type-case type :void) nil) ((type-integerp type) t) ((type-case type :struct) t) ((type-case type :pointer) t) ((type-case type :array) (not (eq (type-array->size type) nil))) (t (impossible)))))
Theorem:
(defthm booleanp-of-type-completep (b* ((yes/no (type-completep type))) (booleanp yes/no)) :rule-classes :rewrite)
Theorem:
(defthm type-completep-of-type-fix-type (equal (type-completep (type-fix type)) (type-completep type)))
Theorem:
(defthm type-completep-type-equiv-congruence-on-type (implies (type-equiv type type-equiv) (equal (type-completep type) (type-completep type-equiv))) :rule-classes :congruence)