Zulip Chat Archive
Stream: lean4
Topic: Tree/Map/HashMap in Inductive Data Type
Atticus Kuhn (Nov 03 2025 at 12:57):
I'm trying to put a tree/dictionary/hashmap in an inductive data type
import Std
inductive T : Type where
| c : Std.TreeMap Int T → T
I get the confusing error:
test.lean:3:0
(kernel) application type mismatch
Std.DTreeMap.Internal.Impl.WF inner
argument has type
_nested.Std.DTreeMap.Internal.Impl_3
but function has type
(Std.DTreeMap.Internal.Impl Int fun x ↦ T) → Prop
What does this error mean? Where do these internal symbols come from? Can I put a tree/map/hashmap in an inductive data structure?
Aaron Liu (Nov 03 2025 at 12:58):
from docs#Std.DHashMap:
These hash maps contain a bundled well-formedness invariant, which means that they cannot be used in nested inductive types. For these use cases,
Std.DHashMap.RawandStd.DHashMap.Raw.WFunbundle the invariant from the hash map. When in doubt, preferDHashMapoverDHashMap.Raw.
Atticus Kuhn (Nov 03 2025 at 13:03):
Thank you, using Std.TreeMap.Raw solved the issue.
Jovan Gerbscheid (Nov 04 2025 at 18:17):
A quote from the year 3 roadmap of the FRO:
Nesting induction through collections such as
HashMapandTreeMapwill be supported.
Last updated: Dec 20 2025 at 21:32 UTC