Build an omap from a list of keys and a list of corresponding values.
(from-lists keys vals) → map
If there are duplicate keys in the first list, the leftmost key, and the corresponding value, will be in the resulting omap.
Function:
(defun from-lists (keys vals) (declare (xargs :guard (and (true-listp keys) (true-listp vals)))) (declare (xargs :guard (= (len keys) (len vals)))) (let ((__function__ 'from-lists)) (declare (ignorable __function__)) (cond ((endp keys) nil) (t (update (car keys) (car vals) (from-lists (cdr keys) (cdr vals)))))))
Theorem:
(defthm mapp-of-from-lists (b* ((map (from-lists keys vals))) (mapp map)) :rule-classes :rewrite)
Theorem:
(defthm from-lists-of-list-fix-keys (equal (from-lists (list-fix keys) vals) (from-lists keys vals)))
Theorem:
(defthm from-lists-list-equiv-congruence-on-keys (implies (list-equiv keys keys-equiv) (equal (from-lists keys vals) (from-lists keys-equiv vals))) :rule-classes :congruence)
Theorem:
(defthm from-lists-of-list-fix-vals (equal (from-lists keys (list-fix vals)) (from-lists keys vals)))
Theorem:
(defthm from-lists-list-equiv-congruence-on-vals (implies (list-equiv vals vals-equiv) (equal (from-lists keys vals) (from-lists keys vals-equiv))) :rule-classes :congruence)