• 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

    Rlookup

    Set of keys to which a value is associated.

    Signature
    (rlookup val map) → keys
    Arguments
    map — Guard (mapp map).
    Returns
    keys — Type (setp keys).

    The resulting set is empty if the value is not in the omap. The resulting set is a singleton if the value is associated to exactly one key. Otherwise, the resulting set contains two or more keys.

    This is the ``reverse'' of lookup, which motivates the r in the name.

    Definitions and Theorems

    Function: rlookup

    (defun rlookup (val map)
      (declare (xargs :guard (mapp map)))
      (let ((__function__ 'rlookup))
        (declare (ignorable __function__))
        (cond ((emptyp map) nil)
              (t (mv-let (key0 val0)
                         (head map)
                   (if (equal val val0)
                       (insert key0 (rlookup val (tail map)))
                     (rlookup val (tail map))))))))

    Theorem: setp-of-rlookup

    (defthm setp-of-rlookup
      (b* ((keys (rlookup val map)))
        (setp keys))
      :rule-classes :rewrite)

    Theorem: rlookup-when-emptyp

    (defthm rlookup-when-emptyp
      (implies (emptyp map)
               (equal (rlookup val map) nil))
      :rule-classes (:rewrite :type-prescription))