• 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
        • Defpkg
        • Apply$
        • Mutual-recursion
        • Loop$
        • Programming-with-state
        • Arrays
        • Characters
        • Time$
        • Loop$-primer
        • Fast-alists
        • 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
          • 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
    • Alists
    • ACL2-built-ins

    Remove1-assoc

    Remove the first pair with a given key from an association list

    General Forms:
    (remove1-assoc key alist)
    (remove1-assoc key alist :test 'eql)   ; same as above (eql as equality test)
    (remove1-assoc key alist :test 'eq)    ; same, but eq is equality test
    (remove1-assoc key alist :test 'equal) ; same, but equal is equality test

    (Remove1-assoc key alist) returns an alist that is the same as the list alist, except that the first pair in alist with a car of key is deleted, if there is one; otherwise alist is returned. Note that the order of the elements of alist is unchanged (though one may be deleted).

    Also see remove-assoc for a similar utility that deletes all pairs in an alist with a given key, rather than only the first such pair.

    The guard for a call of remove1-assoc depends on the test. In all cases, the second argument must satisfy alistp. If the test is eql, then either the first argument must be suitable for eql (see eqlablep) or the second argument must satisfy eqlable-alistp. If the test is eq, then either the first argument must be a symbol or the second argument must satisfy symbol-alistp.

    See equality-variants for a discussion of the relation between remove1-assoc and its variants:

    (remove1-assoc-eq key alist) is equivalent to (remove1-assoc key alist :test 'eq);

    (remove1-assoc-equal key alist) is equivalent to (remove1-assoc key alist :test 'equal).

    In particular, reasoning about any of these primitives reduces to reasoning about the function remove1-assoc-equal.

    Function: remove1-assoc-equal

    (defun remove1-assoc-equal (key alist)
           (declare (xargs :guard (alistp alist)))
           (cond ((endp alist) nil)
                 ((equal key (caar alist)) (cdr alist))
                 (t (cons (car alist)
                          (remove1-assoc-equal key (cdr alist))))))