I want to define a mutable dictionary that can return all of its keys in its domain. Keys don't have to be ordered. I searched in the coq library doc on the internet and didn't seem to find anything useful for this purpose. I don't want to write it as a list of pairs because it feels too ad hoc. Is there a standard way to do this?
As an example, how can I define a dictionary d := {a -> 1; b -> 2; c -> 3}
, and a function "keys", such that keys d = [a; b; c]
?
Edit: I forgot to mention that I also want to use datatypes that I defined myself as keys. For example something like:
Inductive a := cons_a : string -> a.
Inductive b := cons_b : string -> b.
Inductive c :=
| cons_c : int -> cons_c
| c1
| c2.
Inductive d :=
| cons_d1 : string -> d
| cons_d2 : string -> d
and I want to define a map for each of a b c d
as keys. Like d1 := {cons_a "a" -> 1; cons_a "b" -> 2}
, d2 := {cons_d1 "a" -> 1; cons_d2 "a" -> 2}
, d3 := {cons_c 1 -> 1; c1 -> 0}
, etc.