Organize a list of symbols by their packages.
(organize-symbols-by-pkg syms) → syms-by-pkg
The result is an alist from package names (strings) to the non-empty lists of the symbols that are in the respective packages.
The alist has unique keys, and each of its values has no duplicates.
Function:
(defun organize-symbols-by-pkg-aux (syms acc) (declare (xargs :guard (and (symbol-listp syms) (string-symbollist-alistp acc)))) (let ((__function__ 'organize-symbols-by-pkg-aux)) (declare (ignorable __function__)) (b* (((when (endp syms)) acc) (sym (car syms)) (pkg (symbol-package-name sym)) (prev-syms-for-pkg (cdr (assoc-equal pkg acc)))) (organize-symbols-by-pkg-aux (cdr syms) (put-assoc-equal pkg (add-to-set-eq sym prev-syms-for-pkg) acc)))))
Theorem:
(defthm string-symbollist-alistp-of-organize-symbols-by-pkg-aux (implies (and (symbol-listp syms) (string-symbollist-alistp acc)) (b* ((syms-by-pkg (organize-symbols-by-pkg-aux syms acc))) (string-symbollist-alistp syms-by-pkg))) :rule-classes :rewrite)
Function:
(defun organize-symbols-by-pkg (syms) (declare (xargs :guard (symbol-listp syms))) (let ((__function__ 'organize-symbols-by-pkg)) (declare (ignorable __function__)) (organize-symbols-by-pkg-aux syms nil)))
Theorem:
(defthm string-symbollist-alistp-of-organize-symbols-by-pkg (implies (and (symbol-listp syms)) (b* ((syms-by-pkg (organize-symbols-by-pkg syms))) (string-symbollist-alistp syms-by-pkg))) :rule-classes :rewrite)