• Top
    • Documentation
    • Books
    • Recursion-and-induction
    • Boolean-reasoning
    • Projects
    • Debugging
    • Std
    • Proof-automation
    • Macro-libraries
    • ACL2
      • Theories
      • Rule-classes
      • Proof-builder
      • Hons-and-memoization
      • Events
      • History
      • Parallelism
      • Programming
        • Defun
        • Declare
        • System-utilities
        • Stobj
        • State
        • Memoize
        • Mbe
        • Io
        • Apply$
        • Defpkg
        • Mutual-recursion
        • Loop$
        • Programming-with-state
        • Arrays
        • Characters
        • Time$
        • Loop$-primer
        • Fast-alists
          • Slow-alist-warning
          • Hons-acons
          • Fast-alist-fork
          • Hons-acons!
          • With-fast-alist
          • Fast-alist-clean
          • Fast-alist-pop
            • Fast-alist-free
            • Fast-alist-pop*
            • Hons-get
            • Hons-assoc-equal
            • Make-fast-alist
            • Make-fal
            • Fast-alist-free-on-exit
            • With-stolen-alist
            • Fast-alist-fork!
            • Fast-alist-summary
            • Fast-alist-clean!
            • Fast-alist-len
            • With-stolen-alists
            • Fast-alists-free-on-exit
            • Cons-subtrees
            • With-fast-alists
            • Hons-dups-p1
            • Ansfl
            • Hons-revappend
            • Hons-member-equal
            • Hons-make-list
            • Hons-reverse
            • Hons-list*
            • Hons-list
            • Hons-append
          • Defmacro
          • Defconst
          • Evaluation
          • Guard
          • Equality-variants
          • Compilation
          • Hons
          • ACL2-built-ins
          • Developers-guide
          • System-attachments
          • Advanced-features
          • Set-check-invariant-risk
          • Numbers
          • Irrelevant-formals
          • Efficiency
          • Introduction-to-programming-in-ACL2-for-those-who-know-lisp
          • Redefining-programs
          • Lists
          • Invariant-risk
          • Errors
          • Defabbrev
          • Conses
          • Alists
            • Std/alists
            • Omaps
            • Fast-alists
              • Slow-alist-warning
              • Hons-acons
              • Fast-alist-fork
              • Hons-acons!
              • With-fast-alist
              • Fast-alist-clean
              • Fast-alist-pop
                • Fast-alist-free
                • Fast-alist-pop*
                • Hons-get
                • Hons-assoc-equal
                • Make-fast-alist
                • Make-fal
                • Fast-alist-free-on-exit
                • With-stolen-alist
                • Fast-alist-fork!
                • Fast-alist-summary
                • Fast-alist-clean!
                • Fast-alist-len
                • With-stolen-alists
                • Fast-alists-free-on-exit
                • Cons-subtrees
                • With-fast-alists
                • Hons-dups-p1
                • Ansfl
                • Hons-revappend
                • Hons-member-equal
                • Hons-make-list
                • Hons-reverse
                • Hons-list*
                • Hons-list
                • Hons-append
              • Alistp
              • Misc/records
              • Remove-assocs
              • Assoc
              • Symbol-alistp
              • Rassoc
              • Remove-assoc
              • Remove1-assoc
              • Alist-map-vals
              • Depgraph
              • Alist-map-keys
              • Put-assoc
              • Strip-cars
              • Pairlis$
              • Strip-cdrs
              • Sublis
              • Acons
              • Eqlable-alistp
              • Assoc-string-equal
              • Standard-string-alistp
              • Alist-to-doublets
              • Character-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
            • Defmacro-untouchable
            • Primitive
            • <<
            • Revert-world
            • Set-duplicate-keys-action
            • Unmemoize
            • Symbols
            • Def-list-constructor
            • Easy-simplify-term
            • Defiteration
            • Defopen
            • Sleep
          • Start-here
          • Real
          • Debugging
          • Miscellaneous
          • Output-controls
          • Macros
          • Interfacing-tools
        • Interfacing-tools
        • Hardware-verification
        • Software-verification
        • Testing-utilities
        • Math
      • Fast-alists

      Fast-alist-pop

      fast-alist-pop removes the first key-value pair from a fast alist, provided that the key is not bound in the remainder of the alist.

      This is a user extension to the ACL2 (in particular, ACL2H) system. It may eventually be added to acl2h proper, but until then it requires a trust tag since it hasn't been thoroughly vetted for soundness.

      Logically, fast-alist-pop is just CDR. However, it has a special side-effect when called on a fast alist (see hons-acons). A fast alist has a backing hash table mapping its keys to their corresponding (unshadowed) pairs, which supports constant-time alist lookup. Hons-acons adds key/value pairs to the alist and its backing hash table, and hons-get performs constant-time lookup by finding the backing hash table and looking up the key in the table. However, logically, hons-get is just hons-assoc-equal, a more traditional alist lookup function that traverses the alist until it finds the matching key. Correspondingly, fast-alist-pop is logically just CDR, but it removes the key/value pair corresponding to the CAR of the alist from its backing hash table.

      To maintain both the consistency of the alist with the backing hash table and constant-time performance, fast-alist-pop has a guard requiring that the key of that first pair not be bound in the cdr of the alist. Otherwise, simply removing that pair from the hash table would not be correct, since the key would remain in the alist bound to some value, which could only be discovered by linearly traversing the alist.

      Note this is just a special case of fast-alist-pop*.