Look up a member by name in a list of member types.
(member-type-lookup name members) → type
We search from the beginning and stop at the first hit;
since the names are unique in well-formed lists,
the exact search strategy makes no difference
We return the type of the member if the search is successful.
We return
Function:
(defun member-type-lookup (name members) (declare (xargs :guard (and (identp name) (member-type-listp members)))) (let ((__function__ 'member-type-lookup)) (declare (ignorable __function__)) (b* (((when (endp members)) nil) ((when (equal (ident-fix name) (member-type->name (car members)))) (member-type->type (car members)))) (member-type-lookup name (cdr members)))))
Theorem:
(defthm type-optionp-of-member-type-lookup (b* ((type (member-type-lookup name members))) (type-optionp type)) :rule-classes :rewrite)
Theorem:
(defthm member-type-lookup-of-ident-fix-name (equal (member-type-lookup (ident-fix name) members) (member-type-lookup name members)))
Theorem:
(defthm member-type-lookup-ident-equiv-congruence-on-name (implies (ident-equiv name name-equiv) (equal (member-type-lookup name members) (member-type-lookup name-equiv members))) :rule-classes :congruence)
Theorem:
(defthm member-type-lookup-of-member-type-list-fix-members (equal (member-type-lookup name (member-type-list-fix members)) (member-type-lookup name members)))
Theorem:
(defthm member-type-lookup-member-type-list-equiv-congruence-on-members (implies (member-type-list-equiv members members-equiv) (equal (member-type-lookup name members) (member-type-lookup name members-equiv))) :rule-classes :congruence)