• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
    • Debugging
    • 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$
        • Defmacro
        • Loop$-primer
        • Fast-alists
        • Defconst
        • 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
          • Omaps
            • Defomap
            • Update
            • Mapp
            • Assoc
            • Update*
              • Size
              • Keys
              • From-lists
              • Update-induction-on-maps
              • Compatiblep
              • Tail
              • Head
              • Restrict
              • Submap
              • Map
              • Rlookup
              • Emptyp
              • Rlookup*
              • Lookup*
              • Delete*
              • Values
              • In*
              • Lookup
              • Delete
              • Mfix
              • Head-val
              • Head-key
              • Omap-induction2
              • Omap-order-rules
            • Std/alists
            • 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
            • 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
        • Debugging
        • Miscellaneous
        • Output-controls
        • Macros
        • Interfacing-tools
      • Interfacing-tools
      • Hardware-verification
      • Software-verification
      • Math
      • Testing-utilities
    • Omaps

    Update*

    Update a map with another map.

    Signature
    (update* new old) → map
    Arguments
    new — Guard (mapp new).
    old — Guard (mapp old).
    Returns
    map — Type (mapp map).

    This lifts update from a single key and value to a set of key-value pairs, passed as the first argument map. If a key is in the second but not in the first map, the key is present in the result, with the same value as in the second map. If a key is in the first but not in the second map, the key is present in the result, with the same value as in the first map. If a key is present in both maps, it is present in the result, with the same value as in the first map; i.e. the first map ``wins''. There are no other keys in the result.

    Definitions and Theorems

    Function: update*

    (defun update* (new old)
      (declare (xargs :guard (and (mapp new) (mapp old))))
      (let ((__function__ 'update*))
        (declare (ignorable __function__))
        (cond ((emptyp new) (mfix old))
              (t (mv-let (new-key new-val)
                         (head new)
                   (update new-key
                           new-val (update* (tail new) old)))))))

    Theorem: mapp-of-update*

    (defthm mapp-of-update*
      (b* ((map (update* new old)))
        (mapp map))
      :rule-classes :rewrite)

    Theorem: update*-when-left-emptyp

    (defthm update*-when-left-emptyp
      (implies (emptyp new)
               (equal (update* new old) (mfix old))))

    Theorem: update*-when-right-emptyp

    (defthm update*-when-right-emptyp
      (implies (emptyp old)
               (equal (update* new old) (mfix new))))