• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
    • Debugging
    • Community
    • Std
    • Proof-automation
    • Macro-libraries
    • ACL2
      • Theories
      • Rule-classes
      • Proof-builder
      • Recursion-and-induction
      • Hons-and-memoization
      • Events
      • Parallelism
      • History
      • Programming
        • Defun
        • Declare
        • System-utilities
        • Stobj
        • State
        • Mutual-recursion
        • Memoize
        • Mbe
        • Io
        • Defpkg
        • Apply$
        • Loop$
        • Programming-with-state
        • Arrays
        • Characters
        • Time$
        • Defconst
        • Fast-alists
        • Defmacro
        • Loop$-primer
        • Evaluation
        • Guard
        • Equality-variants
        • Compilation
        • Hons
        • ACL2-built-ins
        • Developers-guide
        • System-attachments
        • Advanced-features
        • Set-check-invariant-risk
        • Numbers
        • Efficiency
        • Irrelevant-formals
        • Introduction-to-programming-in-ACL2-for-those-who-know-lisp
        • Redefining-programs
        • Lists
        • Invariant-risk
        • Errors
        • Defabbrev
        • Conses
        • Alists
          • Std/alists
            • Alist-keys
            • Remove-assocs
            • Alist-vals
            • Alist-map-vals
            • Alist-map-keys
            • Std/alists/strip-cdrs
            • Hons-rassoc-equal
            • Std/alists/hons-assoc-equal
            • Std/alists/strip-cars
            • Fal-find-any
            • Fal-extract
            • Std/alists/abstract
            • Fal-extract-vals
            • Fal-all-boundp
            • Std/alists/alistp
            • Append-alist-vals
            • Append-alist-keys
              • Append-alist-keys-exec
            • Alist-equiv
            • Hons-remove-assoc
            • Std/alists/pairlis$
            • Worth-hashing
            • Alists-agree
            • Sub-alistp
            • Alist-fix
            • Std/alists/remove-assoc-equal
            • Std/alists/assoc-equal
          • Fast-alists
          • Alistp
          • Misc/records
          • Assoc
          • Remove-assocs
          • Symbol-alistp
          • Rassoc
          • Remove-assoc
          • Depgraph
          • Remove1-assoc
          • Alist-map-vals
          • Alist-map-keys
          • Put-assoc
          • Strip-cars
          • Pairlis$
          • Strip-cdrs
          • Sublis
          • Acons
          • Eqlable-alistp
          • Assoc-string-equal
          • Alist-to-doublets
          • Character-alistp
          • String-alistp
          • Alist-keys-subsetp
          • R-symbol-alistp
          • R-eqlable-alistp
          • Pairlis
          • Pairlis-x2
          • Pairlis-x1
          • Delete-assoc
        • Set-register-invariant-risk
        • Strings
        • Program-wrapper
        • Get-internal-time
        • Basics
        • Packages
        • Oracle-eval
        • Defmacro-untouchable
        • <<
        • Primitive
        • Revert-world
        • Unmemoize
        • Set-duplicate-keys-action
        • Symbols
        • Def-list-constructor
        • Easy-simplify-term
        • Defiteration
        • Fake-oracle-eval
        • Defopen
        • Sleep
      • Operational-semantics
      • Real
      • Start-here
      • Miscellaneous
      • Output-controls
      • Bdd
      • Macros
      • Installation
      • Mailing-lists
    • Interfacing-tools
    • Hardware-verification
    • Software-verification
    • Math
    • Testing-utilities
  • Std/alists

Append-alist-keys

(append-alist-keys x) appends all of the values from the alist x into a single list.

Our guard is merely t, but typically x should be an alist of (key . value) pairs where every value is a list of elements. We walk through the alist, appending together all of the elements of each value into a single, flat list.

Note that we do not really treat x as an association list. That is, we will include the values from any "shadowed pairs" in the list.

Definitions and Theorems

Function: append-alist-keys

(defun append-alist-keys (x)
  (declare (xargs :guard t))
  (mbe :logic
       (if (atom x)
           nil
         (append (caar x)
                 (append-alist-keys (cdr x))))
       :exec (reverse (append-alist-keys-exec x nil))))

Theorem: append-alist-keys-exec-removal

(defthm append-alist-keys-exec-removal
  (equal (append-alist-keys-exec x acc)
         (revappend (append-alist-keys x) acc)))

Theorem: append-alist-keys-when-atom

(defthm append-alist-keys-when-atom
  (implies (atom x)
           (equal (append-alist-keys x) nil)))

Theorem: append-alist-keys-of-cons

(defthm append-alist-keys-of-cons
  (equal (append-alist-keys (cons a x))
         (append (car a) (append-alist-keys x))))

Theorem: true-listp-of-append-alist-keys

(defthm true-listp-of-append-alist-keys
  (true-listp (append-alist-keys x))
  :rule-classes :type-prescription)

Theorem: append-alist-keys-of-append

(defthm append-alist-keys-of-append
  (equal (append-alist-keys (append x y))
         (append (append-alist-keys x)
                 (append-alist-keys y))))

Theorem: list-equiv-implies-equal-append-alist-keys-1

(defthm list-equiv-implies-equal-append-alist-keys-1
  (implies (list-equiv x x-equiv)
           (equal (append-alist-keys x)
                  (append-alist-keys x-equiv)))
  :rule-classes (:congruence))

Subtopics

Append-alist-keys-exec
Tail-recursive implementation of append-alist-keys.