Zulip Chat Archive

Stream: new members

Topic: How to elaborate local notation?


Jakub Nowak (Dec 21 2025 at 12:24):

How can I elaborate terms in the context of local variables?

import Lean

variable (n : Nat)

local notation "ι" => n

/-- error: Unknown constant `n✝` -/
#guard_msgs in
open Lean Elab.Term in
run_elab
  elabTerm ( `(ι)) none

Jakub Nowak (Dec 21 2025 at 12:27):

Although, maybe the issue is not with elabTerm, but the fact that the syntax in `(ι) is not parsed in the context of local variables?

Jakub Nowak (Dec 21 2025 at 16:17):

I still don't know how to make this code work though. .-.

Kyle Miller (Dec 21 2025 at 18:37):

Local variables are a command elaborator concept. You can use docs#Lean.Elab.Command.runTermElabM to elaborate the local variables and get into a context where they exist.


Last updated: Feb 28 2026 at 14:05 UTC