• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
    • Debugging
    • Std
      • Std/lists
      • Std/alists
      • Obags
      • Std/util
      • Std/strings
      • Std/osets
        • 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
          • All-by-membership
          • Defset
          • In
          • Primitives
          • Subset
          • Mergesort
          • Intersect
          • Union
          • Pick-a-point-subset-strategy
          • Delete
          • Double-containment
          • Difference
          • Cardinality
          • Set
          • Intersectp
        • Std/io
        • Std/basic
        • Std/system
        • Std/typed-lists
        • Std/bitsets
        • Std/testing
        • Std/typed-alists
        • Std/stobjs
      • Proof-automation
      • Macro-libraries
      • ACL2
      • Interfacing-tools
      • Hardware-verification
      • Software-verification
      • Math
      • Testing-utilities
    • Omaps

    Restrict

    Restrict an omap to a set of keys.

    Signature
    (restrict keys map) → map1
    Arguments
    keys — Guard (setp keys).
    map — Guard (mapp map).
    Returns
    map1 — Type (mapp map1).

    This drops all the keys of the omap that are not in the given set of keys.

    Definitions and Theorems

    Function: restrict

    (defun restrict (keys map)
      (declare (xargs :guard (and (setp keys) (mapp map))))
      (let ((__function__ 'restrict))
        (declare (ignorable __function__))
        (cond ((emptyp map) nil)
              (t (mv-let (key val)
                         (head map)
                   (if (set::in key keys)
                       (update key val (restrict keys (tail map)))
                     (restrict keys (tail map))))))))

    Theorem: mapp-of-restrict

    (defthm mapp-of-restrict
      (b* ((map1 (restrict keys map)))
        (mapp map1))
      :rule-classes :rewrite)

    Theorem: restrict-when-left-emptyp

    (defthm restrict-when-left-emptyp
      (implies (set::emptyp keys)
               (equal (restrict keys map) nil))
      :rule-classes (:rewrite :type-prescription))

    Theorem: restrict-when-right-emptyp

    (defthm restrict-when-right-emptyp
      (implies (emptyp map)
               (equal (restrict keys map) nil))
      :rule-classes (:rewrite :type-prescription))

    Theorem: assoc-of-restrict

    (defthm assoc-of-restrict
      (equal (assoc key (restrict keys map))
             (and (set::in key keys)
                  (assoc key map))))

    Theorem: assoc-of-restrict-when-in-keys

    (defthm assoc-of-restrict-when-in-keys
      (implies (set::in key keys)
               (equal (assoc key (restrict keys map))
                      (assoc key map))))