Zulip Chat Archive
Stream: lean4
Topic: universe with dot notation
Kenny Lau (Jun 12 2025 at 14:47):
def Foo : Type u := sorry
def Foo.inv : Foo -> Foo := sorry
variable (x : Foo.{u})
#check x.inv.{u} -- invalid use of explicit universe parameters, 'x' is a local variable
#check x.inv -- succeeds
Kenny Lau (Jun 12 2025 at 14:47):
Is it intentional that .{u} notation cannot be used with dot notation?
Edward van de Meent (Jun 12 2025 at 14:53):
it can, just not when x is a variable:
def Foo : Type u := sorry
def Foo.inv : Foo -> Foo := sorry
def x : Foo := sorry
universe u in
#check x.inv.{u}
Kenny Lau (Jun 12 2025 at 14:55):
sure, but it could still be useful when x is a variable
Kyle Miller (Jun 12 2025 at 14:55):
There's no syntax for dot notation (you can check that (x).inv.{u} is a syntax error).
True dot notation is (x).inv, and when you write x.inv, what happens is that the elaborator sees that x.inv isn't a constant, so it automatically splits the last name component off and tries (x).inv. This is why x.inv.{u} parses at all.
I think it's clear you've found a bug. I'm not sure it was intentional that x.inv.{u} even attempts to elaborate. Could you file a Lean 4 issue? I think it's reasonable to ask for this new feature in that issue as well.
Edward van de Meent (Jun 12 2025 at 14:56):
i suspect this tries to apply the universe level to x?
Edward van de Meent (Jun 12 2025 at 14:56):
but when it's a variable, it already has a universe level, so it complains
Kyle Miller (Jun 12 2025 at 14:57):
Edward van de Meent said:
i suspect this tries to apply the universe level to
x?
Yes, that's what the error is indicating.
Edward van de Meent said:
but when it's a variable, it already has a universe level, so it complains
No, given that it's apparently interpreting x.inv.{u} as (x.{u}).inv, the issue is that only Expr.const has universe levels. This x is a local variable (an Expr.fvar).
Edward van de Meent (Jun 12 2025 at 14:58):
Kyle Miller said:
Edward van de Meent said:
but when it's a variable, it already has a universe level, so it complains
No, the issue is that only
Expr.consthas universe levels. Thisxis a local variable (anExpr.fvar).
i feel like we're saying the same thing here?
Eric Wieser (Jun 12 2025 at 15:00):
This came up in a PR as P.Obj.{v} for docs#PFunctor.Obj, which wasn't legal and we had to write Obj.{v} P instead.
Kenny Lau (Jun 12 2025 at 15:00):
Created lean4#8743
Kyle Miller (Jun 12 2025 at 15:01):
Edward van de Meent said:
i feel like we're saying the same thing here?
(It doesn't make sense to say x already has a universe level. Local variables don't have universe levels at all.)
Edward van de Meent (Jun 12 2025 at 15:05):
right, i guess the way to phrase it is "there are no free universe variables to fill in the type"?
Kyle Miller (Jun 12 2025 at 15:09):
That's still inaccurate — it's about filling in the universe levels of a constant; constants need to be instantiated with particular universe levels. The types of expressions doesn't come into this.
Last updated: Dec 20 2025 at 21:32 UTC