Zulip Chat Archive

Stream: lean4

Topic: Appending indices to Names


Thomas Murrills (Nov 10 2022 at 05:13):

Sometimes you'd like to take an existing Name and append a number to it. What's the best way of doing this? Using numerical names doesn't seem to work well, at least not in the context I'm interested in:

elab "newMVar" : term => mkFreshExprMVar none .synthetic (userName := .num `x 1)
example : Nat := by refine newMVar; case x.1 =>    -- error: "expected =>"

Is this a problem with case, or (I'm guessing) because numerical names aren't meant to be used this way?

If the latter, how would one turn a Name and a Nat into an indexed name, e.g. with a separating underscore?

Tomas Skrivan (Nov 10 2022 at 07:45):

Use Name.appendAfter function for this.

Jannis Limperg (Nov 10 2022 at 10:26):

And indeed the Name.num constructor is only used for internal names afaik.


Last updated: Dec 20 2023 at 11:08 UTC