• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
    • Debugging
    • Std
    • Proof-automation
    • Macro-libraries
    • ACL2
    • Interfacing-tools
    • Hardware-verification
    • Software-verification
      • Kestrel-books
        • Crypto-hdwallet
        • Apt
        • Error-checking
        • Fty-extensions
        • Isar
        • Kestrel-utilities
          • 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
          • Directed-untranslate
          • Include-book-paths
          • Ubi
          • Numbered-names
          • Digits-any-base
          • Context-message-pair
          • With-auto-termination
          • Make-termination-theorem
          • Theorems-about-true-list-lists
          • Checkpoint-list
          • Sublis-expr+
          • Integers-from-to
          • Prove$
          • Defthm<w
          • System-utilities-non-built-in
          • Integer-range-fix
          • Minimize-ruler-extenders
          • Add-const-to-untranslate-preprocess
          • Unsigned-byte-fix
          • Signed-byte-fix
          • Defthmr
          • Paired-names
          • Unsigned-byte-list-fix
          • Signed-byte-list-fix
          • Show-books
          • Skip-in-book
          • Typed-tuplep
          • List-utilities
          • Checkpoint-list-pretty
          • Defunt
          • Keyword-value-list-to-alist
          • Magic-macroexpand
          • Top-command-number-fn
          • Bits-as-digits-in-base-2
          • Show-checkpoint-list
          • Ubyte11s-as-digits-in-base-2048
          • Named-formulas
          • Bytes-as-digits-in-base-256
          • String-utilities
          • Make-keyword-value-list-from-keys-and-value
          • Defmacroq
          • Integer-range-listp
          • Apply-fn-if-known
          • Trans-eval-error-triple
          • Checkpoint-info-list
          • Previous-subsumer-hints
          • Fms!-lst
          • Zp-listp
          • Trans-eval-state
          • Injections
          • Doublets-to-alist
          • Theorems-about-osets
          • Typed-list-utilities
          • Book-runes-alist
          • User-interface
          • Bits/ubyte11s-digit-grouping
          • Bits/bytes-digit-grouping
          • Message-utilities
          • Subsetp-eq-linear
          • Oset-utilities
          • Strict-merge-sort-<
          • Miscellaneous-enumerations
          • Maybe-unquote
          • Thm<w
          • Defthmd<w
          • Io-utilities
        • Set
        • Soft
        • C
        • Bv
        • Imp-language
        • Event-macros
        • Java
        • Bitcoin
        • Ethereum
        • Yul
        • Zcash
        • ACL2-programming-language
        • Prime-fields
        • Json
        • Syntheto
        • File-io-light
        • Cryptography
        • Number-theory
        • Lists-light
        • Axe
        • Builtins
        • Solidity
        • Helpers
        • Htclient
        • Typed-lists-light
        • Arithmetic-light
      • X86isa
      • Axe
      • Execloader
    • Math
    • Testing-utilities
  • Kestrel-utilities
  • Std/osets
  • Alists

Omaps

A library of omaps (ordered maps), i.e. finite maps represented as strictly ordered alists.

This is related to the library of osets (ordered sets), i.e. finite sets represented as strictly ordered lists. Like osets capture (up to isomorphism) the mathematical notion of finite sets (over ACL2 objects), omaps capture (up to isomorphism) the mathematical notion of finite maps (over ACL2 objects). In particular, omap equality is equal.

Since the total order on ACL2 values is lexicographic on cons pairs, an omap is an oset of cons pairs; furthermore, an omap is an alist. While then, in principle, some oset and alist operations could be used on omaps, this library provides versions of those oset and alist operations that have stronger guards (i.e. requiring omaps instead of just osets or alists) and that treat non-omaps as the empty omap. That is, the omap operations respect a `non-map convention' analogous to the non-set convention respected by the oset operations; some of the latter are, analogously, versions of list operations (e.g. set::head for car), motivated by the fact that the list operations do not respect the non-set convention.

The omap operations mapp, mfix, emptyp, head, tail, and update are ``primitive'' in the same sense as the oset primitives: their logical definitions depend on the underlying representation as alists, and provide replacements of alist operations that respect the `non-map convention'. The logical definitions of the other omap operations are in terms of the primitive operations, without reference to the underlying alist representation.

There are different logically equivalent ways to define omap operations. The current definitions (as well as their names) are preliminary and could be improved if needed; these definitions favor ease of reasoning over efficiency of execution, but, as done in osets, mbe could be used to provide provably equivalent efficient definitions for execution. As it is often possible to reason about osets abstractly (i.e. without regard to their underlying list representation), it should be often possible to reason about omaps abstractly (i.e. without regard to their underlying alist representation), using the theorems provided by this library. The current theorems are preliminary and could be improved and extended if needed. The empty omap is nil, like the empty oset; there is no separate operation for the empty omap, as there is none for the empty oset.

Since osets are in the "SET" package, it would be natural to use a "MAP package for omaps. However, a package with this name is already defined in coi/maps/package.lsp (see below). So, we use "OMAP" for omaps to allow interoperability with this coi map library, in the sense that an application can use both coi maps and omaps. Perhaps the "SET" package for osets could be renamed to "OSET" at some point, for consistency. (A similar issue applies to the library of obags, i.e. ordered bags, and the coi/bags library, which defines a "BAG" package.)

This omap library could become a new std/omaps library, part of Std, parallel to ACL2::std/osets.

Compared to using the built-in ACL2::alists to represent maps, omaps are closer to the mathematical notion of maps, at the cost of maintaining their strict order. These tradeoffs are analogous to the ones between using osets and using the built-in ACL2::lists to represent sets. The map library in coi/maps/ operates on possibly unordered alists.

Compared to the records in misc/records.lisp and coi/records/, omaps allow any value to be associated to keys, without having to exclude nil or some other fixed value. Furthermore, as noted in the comments in coi/maps/maps.lisp, the `get' operation on those records does not always yield a value smaller than the map. On the other hand, theorems about omaps have generally more hypotheses than the theorems about records.

Subtopics

Defomap
Generate a fixtype of omaps whose keys and values have specified fixtypes.
Update
Set a key to a value in an omap.
Mapp
Recognize omaps.
Assoc
Find the pair in the omap with a given key.
Update*
Update a map with another map.
Size
Size of an omap.
Keys
Oset of the keys of an omap.
From-lists
Build an omap from a list of keys and a list of corresponding values.
Update-induction-on-maps
Induction on omaps based on abstract characterization of update.
Compatiblep
Check if two omaps are compatible, in the sense that they map their common keys to the same values.
Tail
Rest of a non-empty omap after removing its smallest pair.
Head
Smallest key, and associated value, of a non-empty omap.
Restrict
Restrict an omap to a set of keys.
Submap
Check if an omap is a submap of another omap.
Map
A fixtype of omaps.
Rlookup
Set of keys to which a value is associated.
Emptyp
Check if an omap is empty.
Rlookup*
Set of keys to which any value in a set is associated.
Lookup*
Set of values associated to a set of keys in an omap.
Delete*
Remove keys, and associated values, from an omap.
Values
Oset of the values of an omap.
In*
Check if every key in a set is in an omap.
Lookup
Value associated to a key in an omap.
Delete
Remove a key, and associated value, from an omap.
Mfix
Fixing function for omaps.
Head-val
Value associated to the smallest key of a non-empty omap.
Head-key
Smallest key of a non-empty omap.
Omap-induction2
Induction on two omaps, applying tail to both.
Omap-order-rules
Some rules involving the ordering in omaps.