Zulip Chat Archive
Stream: lean4
Topic: Get environment entries in the order they were added
Eric Wieser (Apr 10 2025 at 16:51):
Is there a mechanism to determine which of two definitions within the same (current) module was "defined first"? Presumably for the purpose of kernel checking there can be no back-references, and so the olean file ultimately serializes them in order?
Damiano Testa (Apr 10 2025 at 16:54):
Is looking at the DeclRangeExt
too hacky?
Eric Wieser (Apr 10 2025 at 16:55):
What does that do for auto-generated declarations?
Damiano Testa (Apr 10 2025 at 16:56):
Auto-generated declarations often have a reference to the syntax that defines them, but I am not sure whether always.
Damiano Testa (Apr 10 2025 at 16:56):
E.g., if I remember correctly, to_additive
is the range of the additive declaration.
Eric Wieser (Apr 10 2025 at 16:56):
I'm thinking things like _proof_1
etc
Damiano Testa (Apr 10 2025 at 16:57):
Ah, those may have the same range of their "parent".
Damiano Testa (Apr 10 2025 at 16:59):
Do you need to know the actual order, or would an order that is "allowed" be good enough?
Eric Wieser (Apr 10 2025 at 16:59):
Any allowed order is fine
Eric Wieser (Apr 10 2025 at 16:59):
I want to be certain that the earlier ones cannot depend on the later ones
Damiano Testa (Apr 10 2025 at 16:59):
So you could inspect whether one constant appears in the other?
Eric Wieser (Apr 10 2025 at 16:59):
I'd need to do that transitively, which sounds expensive
Damiano Testa (Apr 10 2025 at 17:00):
Well, if you first use the range and then that, it may not be too much, maybe.
Damiano Testa (Apr 10 2025 at 17:09):
This was a previous discussion #lean4 > last declaration added to `Environment` and it links to an earlier discussion, although they do not seem to give much more detail.
Jannis Limperg (Apr 14 2025 at 12:55):
I've also wanted this recently (in my case, to determine the last declaration in a file -- this is surprisingly tricky). Maybe all these threads indicate enough interest that the FRO would take a PR that adds information about the declaration order to the Environment
.
Last updated: May 02 2025 at 03:31 UTC