Zulip Chat Archive
Stream: Is there code for X?
Topic: Map structure where the values are strictly positive
Mai (Feb 18 2026 at 17:29):
Is there a Map/Dictionary structure where the values are in strictly positive positions, such that you could use it inductively, like so?
inductive Foo
| mk : Map Key Foo -> Foo
Arthur Adjedj (Feb 18 2026 at 17:38):
Not that I'm aware of, although you could reimplement Rocq's gmap, which can be used in nested types.
Mai (Feb 18 2026 at 17:40):
Hmm, might take a shot at that
Mai (Feb 18 2026 at 17:50):
Is there a reason the standard HashMap/TreeMap can't be used this way?
Mai (Feb 18 2026 at 17:51):
I guess it's because the underlying structures are Dependent
Robin Arnez (Feb 18 2026 at 20:38):
The Raw versions (i.e. docs#Std.HashMap.Raw, docs#Std.TreeMap.Raw, etc.) work here but their wellformedness is unbundled in e.g. docs#Std.HashMap.Raw.WF
Mai (Feb 18 2026 at 20:53):
What's the implication of the wellformedness being unbundled?
Robin Arnez (Feb 18 2026 at 21:33):
Well it's a little more inconvenient for proofs since you need to get the wellformedness from somewhere else
Robin Arnez (Feb 18 2026 at 21:33):
And you'll most likely want a wellformedness predicate for Foo to get those recursively
Violeta Hernández (Feb 18 2026 at 22:37):
You could make your inductive type take both an unbundled map and a proof of well-foundedness, and then make the public accessor return the bundled version.
Mai (Feb 18 2026 at 23:24):
@Violeta Hernández no? because WF will indirectly depend on the type being defined
Markus Himmel (Feb 19 2026 at 06:58):
The reference manual has a worked example of using docs#Std.HashMap.Raw in a nested inductive: https://lean-lang.org/doc/reference/latest/Basic-Types/Maps-and-Sets/#raw-data
Last updated: Feb 28 2026 at 14:05 UTC