Zulip Chat Archive

Stream: mathlib4

Topic: same level as


Matthew Ballard (Aug 07 2023 at 21:45):

I've found myself wanting to write Y: Type (Same level as X). I haven't seen an elaborator along those lines. Does this or something similar exist?

Eric Wieser (Aug 07 2023 at 22:21):

I guess it would make sense to have level_of% given we have type_of%

Eric Wieser (Aug 07 2023 at 22:21):

Then again, you could also just use Y : type_of% X instead of Y : Type (level_of% X)

Eric Wieser (Aug 07 2023 at 22:26):

My naive attempt was:

open Lean Lean.Parser in
@[term_parser] def levelOf := leading_parser
  "level_of% " >> termParser maxPrec

open Lean.Meta Lean.Elab.Term in
@[term_elab levelOf] def elabLevelOf : TermElab := fun stx _ => do
  let e  inferType ( elabTerm stx[1] none)
  getLevel e  -- fails

but I realize now that Level is not a "term" so this probably can't be fixed

Eric Wieser (Aug 07 2023 at 22:29):

Maybe

builtin_initialize Lean.Parser.registerBuiltinDynamicParserAttribute `level_parser `level

in a separate file is enough to help thing move

Mario Carneiro (Aug 07 2023 at 22:37):

Eric Wieser said:

I guess it would make sense to have level_of% given we have type_of%

there are no macros in the level category

Scott Morrison (Aug 07 2023 at 23:03):

Could you give an example of what you mean that isn't (X : Type u) (Y : Type u)?

Matthew Ballard (Aug 08 2023 at 00:23):

Eg (X : Type*) and (Y : type_of% X)

Eric Wieser (Aug 08 2023 at 00:28):

I think probably explicit universes are best there

Matthew Ballard (Aug 08 2023 at 00:40):

How about (X1 X2 X3 ... Xn : Type*) and (Y : type_of% X37)?

Matthew Ballard (Aug 08 2023 at 00:41):

I had n=6 or so in "real life"

Eric Wieser (Aug 08 2023 at 00:43):

Is making Type* unhygienic by generating a uX37 universe variable possible and/or sane?

Matthew Ballard (Aug 08 2023 at 00:47):

Eh, you have kinda convinced me that it should be still be broken out


Last updated: Dec 20 2023 at 11:08 UTC