Zulip Chat Archive
Stream: new members
Topic: Programmatically determining a constant’s "canonical name"?
Louis Cabarion (May 06 2025 at 19:21):
If I’ve got this right, a single definition can sometimes be referenced by multiple constant names. For example:
Bool.orandorpoint to the same definition.Lean.Syntax.StrLitandLean.StrLitpoint to the same definition.«Prop».forall_iff.match_1andProp.forall_iff.match_1point to the same definition._root_.imp_iff_right_iff,Classical.imp_iff_right_iffandimp_iff_right_iffpoint to the same definition.Prefunctor.idand𝟭qpoint to the same definition.
How can I, given any name, programmatically obtain the "canonical" (i.e. non-alias) name?
Concretely:
- Input:
"or"→ Output:"Bool.or" - Input:
"Lean.StrLit"→ Output:"Lean.Syntax.StrLit" - Input:
"Prop.forall_iff.match_1"→ Output:"«Prop».forall_iff.match_1" - Input:
"_root_.imp_iff_right_iff"or"imp_iff_right_iff"→ Output:"Classical.imp_iff_right_iff" - Input:
"𝟭q"→ Output:"Prefunctor.id" - …and so on.
Louis Cabarion (May 06 2025 at 21:48):
This #mwe shows how the different constant names refer to the same definition:
import Mathlib
#check Bool.or
#check or
#check Lean.Syntax.StrLit
#check Lean.StrLit
#check «Prop».forall_iff.match_1
#check Prop.forall_iff.match_1
#check _root_.imp_iff_right_iff
#check Classical.imp_iff_right_iff
#check imp_iff_right_iff
#check Prefunctor.id
#check 𝟭q
Aaron Liu (May 06 2025 at 22:00):
Some notes
𝟭qseems to be just notation. It is not a name, and is not processed like a name.«Prop».forall_iff.match_1andProp.forall_iff.match_1generate the same name.
Last updated: Dec 20 2025 at 21:32 UTC