Zulip Chat Archive

Stream: mathlib4

Topic: scoped[NS]


Jireh Loreaux (Nov 22 2022 at 04:44):

I tried to use the scoped[namespace] syntax for localized notation but I got the error: elaboration function for 'Mathlib.Tactic.scopedNS' has not been implemented @Mario Carneiro

Mario Carneiro (Nov 22 2022 at 05:01):

did you import Mathlib.Tactic.ScopedNS? It works for me in a basic test

Jireh Loreaux (Nov 22 2022 at 05:06):

yeah, I did. I'll play around and ask again tomorrow with a #mwe if it's still broken.

Jireh Loreaux (Nov 22 2022 at 05:15):

I think the problem is the notation I was trying to declare was infixl:

import Mathlib.Tactic.ScopedNS

def Foo :    := id

-- scoped[Bar] infixl:40 " ⟹ " => Foo -- fails
scoped[Bar] notation " ⟹ " => Foo -- succeeds

Jireh Loreaux (Nov 22 2022 at 05:17):

I understand. I guess it just needs another macro rule. I'll try to add it.

Jireh Loreaux (Nov 22 2022 at 05:20):

Oh, actually, it looks to me like it should be supported by the second rule. :thinking: And the docstring says it should support infix.

Jireh Loreaux (Nov 22 2022 at 05:27):

The type on $mixfixKind:prefix looks wrong. I thought it should be $mixfixKind:mixfix, but that doesn't work.

Mario Carneiro (Nov 22 2022 at 05:41):

yeah, the notation wasn't designed in a way that facilitates matching on it

Mario Carneiro (Nov 22 2022 at 05:45):

mathlib4#676

Jireh Loreaux (Nov 23 2022 at 04:17):

Now infixl works but notation is broken (same error as before):

import Mathlib.Tactic.ScopedNS

def Foo :    := id

scoped[Bar] infixl:40 " ⟹ " => Foo -- succeeds
scoped[Bar] notation " ⟹ " => Foo -- fails

Jireh Loreaux (Nov 23 2022 at 04:30):

I think it's just that the precedence changed from being optional to mandatory. I'll push a fix. (Note: it works if you include the precedence.)

Jireh Loreaux (Nov 23 2022 at 04:32):

Or is the mandatory precedence intentional?

Mario Carneiro (Nov 23 2022 at 04:40):

I pushed a fix

Jireh Loreaux (Nov 23 2022 at 04:42):

Thanks. You beat me to it, I had just made the PR.

Mario Carneiro (Nov 23 2022 at 04:43):

I also added support for doc comments and attributes

Jireh Loreaux (Nov 23 2022 at 04:44):

Nice, thanks!

Winston Yin (Dec 15 2022 at 22:11):

The scoped notation [a, b] for Set.interval a b doesn't work in mathlib4#1062. Lean4 thinks it's still a List. Any clue how to fix it?

Mario Carneiro (Dec 15 2022 at 22:43):

does that notation work "normally", without scopes?

Mario Carneiro (Dec 15 2022 at 22:43):

I expect it to be just as dreadfully ambiguous as it always has been

Kevin Buzzard (Dec 15 2022 at 23:55):

It's not ambiguous if you're a mathematician and are considering what the type is. Is that asking too much of lean?

Mario Carneiro (Dec 15 2022 at 23:56):

no, lean supports this kind of thing in principle, I've just never found choice nodes to be reliable

Mario Carneiro (Dec 15 2022 at 23:57):

since you quite often have these expressions in a context with no expected type

Winston Yin (Dec 16 2022 at 00:28):

Removing the scope gives

ambiguous, possible interpretations
  [toDual a, toDual b] : Set ((fun x  αᵒᵈ) a)

  [toDual a, toDual b] : List ((fun x  αᵒᵈ) a)

Mario Carneiro (Dec 16 2022 at 02:22):

wait, so what does working look like?

Winston Yin (Dec 16 2022 at 08:11):

In mathlib4#1062 I temporarily removed scoped and used [[a, b]] instead of [a, b]


Last updated: Dec 20 2023 at 11:08 UTC