Look up a definition in a list of definitions.
(lookup-definition name defs) → def?
If the list has a definition for the given name,
return that definition.
Otherwise return
We return the first definition found for that name. In a well-formed lists of definitions, there is at most a definition for each name, and thus the first one found (if any) is also the only one.
Function:
(defun lookup-definition (name defs) (declare (xargs :guard (and (stringp name) (definition-listp defs)))) (let ((__function__ 'lookup-definition)) (declare (ignorable __function__)) (b* (((when (endp defs)) nil) (def (car defs)) ((when (equal (definition->name def) (str-fix name))) (definition-fix def))) (lookup-definition name (cdr defs)))))
Theorem:
(defthm definition-optionp-of-lookup-definition (b* ((def? (lookup-definition name defs))) (definition-optionp def?)) :rule-classes :rewrite)
Theorem:
(defthm lookup-definition-of-str-fix-name (equal (lookup-definition (str-fix name) defs) (lookup-definition name defs)))
Theorem:
(defthm lookup-definition-streqv-congruence-on-name (implies (acl2::streqv name name-equiv) (equal (lookup-definition name defs) (lookup-definition name-equiv defs))) :rule-classes :congruence)
Theorem:
(defthm lookup-definition-of-definition-list-fix-defs (equal (lookup-definition name (definition-list-fix defs)) (lookup-definition name defs)))
Theorem:
(defthm lookup-definition-definition-list-equiv-congruence-on-defs (implies (definition-list-equiv defs defs-equiv) (equal (lookup-definition name defs) (lookup-definition name defs-equiv))) :rule-classes :congruence)