Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Translate local notation with (priority := high) #162

Open
gebner opened this issue Aug 18, 2022 · 3 comments
Open

Translate local notation with (priority := high) #162

gebner opened this issue Aug 18, 2022 · 3 comments

Comments

@gebner
Copy link
Member

gebner commented Aug 18, 2022

This is closer to the Lean 3 semantics.

@digama0
Copy link
Member

digama0 commented Aug 18, 2022

Is it possible to predict when we need this? I would guess that in most cases it's not needed since even if there is an overlapping notation the local notation comes last. It's only if there is another (priority := high) global notation that this would make a difference AFAICT.

I really want to avoid adding "backward compatibility" flags on generated syntax by default, because the generated syntax should be as close as possible to the final "native-looking" result as possible. If we can't correctly make the determination of whether it is needed or not I would err on the side of nice looking results rather than technically correct results.

Alternatively, if we find that we almost always want local notations to be priority high, we should probably change the default in lean 4 core instead.

@gebner
Copy link
Member Author

gebner commented Aug 18, 2022

I think the Lean 4 default is the right one, I wouldn't change that.

I would guess that in most cases it's not needed since even if there is an overlapping notation the local notation comes last.

No, it's needed because otherwise you get a choice node. This can easily be ambiguous e.g. if you override +. We have a whole lot of local infixr ^ etc. in mathlib.

@digama0
Copy link
Member

digama0 commented Aug 18, 2022

Oh yeah that's bad. It should be possible to write a function which determines if a syntax already exists, essentially by translating syntax term " + " term : term into $_:term + $_:term and then seeing if this parses. Synport keeps an up to date syntactic environment, so it should be fine to just do that in the current environment and if it looks like there is a duplicate, only then add the (priority := high).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants