• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
    • Debugging
    • Std
      • Std/lists
      • Std/alists
      • Obags
      • Std/util
      • Std/strings
      • Std/osets
      • Std/io
      • Std/basic
        • Maybe-stringp
        • Maybe-natp
        • Two-nats-measure
        • Impossible
        • Bytep
        • Nat-list-measure
        • Maybe-posp
        • Nibblep
        • Organize-symbols-by-pkg
        • Organize-symbols-by-name
          • Lnfix
          • Good-valuep
          • Streqv
          • Chareqv
          • Symbol-package-name-non-cl
          • Arith-equivs
          • Induction-schemes
          • Maybe-integerp
          • Char-fix
          • Pos-fix
          • Symbol-package-name-lst
          • Mbt$
          • Maybe-bitp
          • Good-pseudo-termp
          • Str-fix
          • Maybe-string-fix
          • Nonkeyword-listp
          • Lifix
          • Bfix
          • Std/basic/if*
          • Impliez
          • Tuplep
          • Std/basic/intern-in-package-of-symbol
          • Lbfix
          • Std/basic/symbol-name-lst
          • True
          • Std/basic/rfix
          • Std/basic/realfix
          • Std/basic/member-symbol-name
          • Std/basic/fix
          • False
          • Std/basic/nfix
          • Std/basic/ifix
        • Std/system
        • Std/typed-lists
        • Std/bitsets
        • Std/testing
        • Std/typed-alists
        • Std/stobjs
      • Community
      • Proof-automation
      • Macro-libraries
      • ACL2
      • Interfacing-tools
      • Hardware-verification
      • Software-verification
      • Math
      • Testing-utilities
    • Std/basic

    Organize-symbols-by-name

    Organize a list of symbols by their names.

    Signature
    (organize-symbols-by-name syms) → syms-by-name
    Arguments
    syms — Guard (symbol-listp syms).
    Returns
    syms-by-name — Type (string-symbollist-alistp syms-by-name), given the guard.

    The result is an alist from symbol names (strings) to the non-empty lists of the symbols that have the respective names.

    The alist has unique keys, and each of its values has no duplicates.

    Definitions and Theorems

    Function: organize-symbols-by-name-aux

    (defun organize-symbols-by-name-aux (syms acc)
      (declare (xargs :guard (and (symbol-listp syms)
                                  (string-symbollist-alistp acc))))
      (let ((__function__ 'organize-symbols-by-name-aux))
        (declare (ignorable __function__))
        (b* (((when (endp syms)) acc)
             (sym (car syms))
             (name (symbol-name sym))
             (prev-syms-for-name (cdr (assoc-equal name acc))))
          (organize-symbols-by-name-aux
               (cdr syms)
               (put-assoc-equal name
                                (add-to-set-eq sym prev-syms-for-name)
                                acc)))))

    Theorem: string-symbollist-alistp-of-organize-symbols-by-name-aux

    (defthm string-symbollist-alistp-of-organize-symbols-by-name-aux
      (implies
           (and (symbol-listp syms)
                (string-symbollist-alistp acc))
           (b* ((syms-by-name (organize-symbols-by-name-aux syms acc)))
             (string-symbollist-alistp syms-by-name)))
      :rule-classes :rewrite)

    Function: organize-symbols-by-name

    (defun organize-symbols-by-name (syms)
      (declare (xargs :guard (symbol-listp syms)))
      (let ((__function__ 'organize-symbols-by-name))
        (declare (ignorable __function__))
        (organize-symbols-by-name-aux syms nil)))

    Theorem: string-symbollist-alistp-of-organize-symbols-by-name

    (defthm string-symbollist-alistp-of-organize-symbols-by-name
      (implies (and (symbol-listp syms))
               (b* ((syms-by-name (organize-symbols-by-name syms)))
                 (string-symbollist-alistp syms-by-name)))
      :rule-classes :rewrite)