(* This file is distributed under the terms of the BSD license. *)(** Finite maps associate data to keys. This file defines an interface forfinite maps and collects some theory on it. Most importantly, it proves useful

course limits the space of finite map implementations, but since we are mainlyinterested in finite maps with numbers as indexes, we do not consider this tobe a serious limitation. The main application of finite maps is to implementthe memory, where extensionality of Leibniz equality is very important for aconvenient use in the assertions of our axiomatic semantics. *)

(** The union of two finite maps only has a meaningful definition for mapsthat are disjoint. However, as working with partial functions is inconvenientin Coq, we define the union as a total function. In case both finite mapshave a value at the same index, we take the value of the first map. *)

(* The zip operation on maps combines two maps key-wise. The keys of resultingmap correspond to the keys that are in both maps. *)Definitionmap_zip_with`{MergeM}{ABC}(f:A→B→C):MA→MB→MC:=merge(λmxmy,matchmx,mywithSomex,Somey=>Some(fxy)|_,_=>Noneend).Notationmap_zip:=(map_zip_withpair).