Zulip Chat Archive

Stream: lean4

Topic: yet another namespace/open issue


Kenny Lau (Oct 26 2025 at 10:37):

namespace A

def foo : Nat := 67

scoped notation "foo%" => foo

theorem bar₁ : foo = 67 := rfl
theorem bar₂ : foo% = 67 := rfl

end A

theorem A.bar₃ : foo = 67 := rfl
theorem A.bar₄ : foo% = 67 := rfl -- error

Kenny Lau (Oct 26 2025 at 10:37):

I don't know if I've reported this bug before, but basically the feature-bug "putting dot in theorem name acts as open namespace" is yet again inconsistent when it comes to scoped notation

Kenny Lau (Oct 26 2025 at 10:38):

at this point can we clarify whether "putting dot in theorem name acts as open namespace" is a feature or a bug?

Kevin Buzzard (Oct 26 2025 at 10:38):

That is definitely a feature! It was even suggested and requested by users.

Aaron Liu (Oct 26 2025 at 10:39):

feature since it's documented

Kenny Lau (Oct 26 2025 at 10:39):

where?

Aaron Liu (Oct 26 2025 at 10:39):

I think it's documented

Aaron Liu (Oct 26 2025 at 10:40):

I hope it's documented

Robin Arnez (Oct 26 2025 at 10:51):

theorem A.bar₄ : foo% = 67 := rfl

expands to

namespace A

theorem bar₄ : foo% = 67 := rfl

end A

but only in the elaboration phase. In the parsing phase "A.bar₄" is just treated like a regular identifier/declId and doesn't affect later parsing.
If we wanted to be able to use scoped stuff, we'd need something like:

def definition     := leading_parser
  "def " >> recover declId skipUntilWsOrDelim >> withDeclId (ppIndent optDeclSig >> declVal >> optDefDeriving)

Last updated: Dec 20 2025 at 21:32 UTC