Zulip Chat Archive
Stream: general
Topic: universe polymorphism
Fernando Chu (Aug 02 2022 at 21:42):
Hello, I'm new to lean but I have some experience on agda. Since there's universe polymorphism, is there a Type ω
such that all other types Type n
are in there? (for n
natural)
Anatole Dedecker (Aug 02 2022 at 22:04):
No we only have one tower of universes. However you can declare universe variables or use Type*
to get polymorphism
Anatole Dedecker (Aug 02 2022 at 22:06):
But it really is « copy paste polymorphism » in the sense that the « same definition » at two different universe levels are really two different definitions from the point of view of the type theory
Anatole Dedecker (Aug 02 2022 at 22:07):
Also in Lean each term has a unique type so we couldn’t really have such a definition
Fernando Chu (Aug 02 2022 at 22:34):
Thanks! I'm new to this « copy paste polymorphism » . From the book, I have
universe u
def F (α : Type u) : Type u := Prod α α
Not that it's useful, but is it possible to get define make F
particular to a universe? def G' (α : Type 1) : Type 1 := F α
works because lean correctly unifies, but I'm wondering if there's a more explicit way to point out the universe level
Kevin Buzzard (Aug 02 2022 at 22:36):
You can use F.{u}
Fernando Chu (Aug 02 2022 at 22:51):
I see, thank you, I didn't know that worked for "application" too. Just to be super sure, terms like Type 10
are simple terms, right? I.e. there is no function application in it, the space is just part of the syntax for the term.
Kyle Miller (Aug 02 2022 at 23:05):
Yes, Type 10
is not function application. It's a "sort expression," where 10 is a level expression (not a nat
).
Fernando Chu (Aug 02 2022 at 23:06):
great, thank you all!
Kyle Miller (Aug 02 2022 at 23:06):
By the way, to explicitly quantify the universes in a definition the syntax is
def {u} F (α : Type u) : Type u := Prod α α
Kyle Miller (Aug 02 2022 at 23:07):
The universes
declaration causes the universe level variables that you actually use in a definition to automatically be added there.
Fernando Chu (Aug 02 2022 at 23:12):
ohh that's interesting, that notation only works for level expressions, right? They seem to be treated in a very special way with their own syntax
Kyle Miller (Aug 02 2022 at 23:20):
https://leanprover.github.io/reference/expressions.html#universes (that's not a complete specification; you can write things like Type (max u v w)
)
Fernando Chu (Aug 02 2022 at 23:45):
thank you, I hadn't found that reference, was checking https://leanprover.github.io/lean4/doc/whatIsLean.html instead. I suppose that reference is for Lean3 but probably most applies for Lean4
Kevin Buzzard (Aug 03 2022 at 07:46):
This is a lean 3 stream -- questions about lean 4 go in the lean4 stream but as far as I know nothing changed here
Last updated: Dec 20 2023 at 11:08 UTC