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

Support at ⊢ h as a Location #2278

Open
1 task done
kim-em opened this issue Jun 20, 2023 · 5 comments · May be fixed by #6992
Open
1 task done

Support at ⊢ h as a Location #2278

kim-em opened this issue Jun 20, 2023 · 5 comments · May be fixed by #6992
Labels
P-medium We may work on this issue if we find the time

Comments

@kim-em
Copy link
Collaborator

kim-em commented Jun 20, 2023

Prerequisites

  • Put an X between the brackets on this line if you have done all of the following:
    • Checked that your issue isn't already filed.
    • Reduced the issue to a self-contained, reproducible test case.

Description

It would be nice if at ⊢ h₁ h₂ was supported as a Location, as well as at h₁ h₂ ⊢. Users seem to type it often, and only get the error message expected '*' or term.

Steps to Reproduce

theorem foo : 1 = 2 := sorry

theorem bar (h : 1 = 7) : 7 = 1 := by
  rw [foo] at ⊢ h
  exact h.symm

Desired behavior:

Either success, or an error message along the lines of "To rewrite at hypotheses and the goal simultaneously, the symbol should appear at the end of location specification."

Actual behavior: expected '*' or term on .

Versions

Lean (version 4.0.0-nightly-2023-06-10, commit bff612e, Release)

@digama0
Copy link
Collaborator

digama0 commented Jun 20, 2023

I think it is better to keep the more restrictive grammar for a more uniform look, although it might be reasonable to parse the alternative if only to give a better error message. (Note that lean 3 allowed you to put |- anywhere and even repeat it, and although I don't know for sure I think the grammar simplification was deliberate.)

@kim-em
Copy link
Collaborator Author

kim-em commented Jun 23, 2023

I agree; just a more informative error message would be fine.

@nomeata
Copy link
Collaborator

nomeata commented Feb 4, 2025

We just discussed this. I think being more liberal (turnstile anywhere in the list) is desirable from a UX stand-point. I certainly have tried it, it failed, and I gave up (rather than figuring out that the turnstyle has to come last). I think we’d do our users a favor of being more liberal here. (Forcing the turnstyle last could be a style linter if people care.)

Hopefully allowing something like (term <|> turnstyle)* as the parser is fine.

@leanprover-bot leanprover-bot added the P-medium We may work on this issue if we find the time label Feb 4, 2025
@jrr6
Copy link
Contributor

jrr6 commented Feb 4, 2025

Hopefully allowing something like (term <|> turnstyle)* as the parser is fine.

This was indeed the case. One thing I was wondering about: do we want to reimplement the Lean 3 behavior exactly and defer any stylistic preferences to linters down the line? Or are there any constraints we want to enforce or warn about within the elaborator itself?

As was mentioned above, under the Lean 3 approach, rw [foo] at ⊢ and rw [foo] at ⊢ h ⊢ are permissible. The latter is consistent with the current situation in Lean 4 for rewriting at hypotheses, which allows things like rw [foo] at h h h without any warnings. Aside from its stylistic suboptimality, I suppose there's a chance that this could be misinterpreted as repeatedly performing the given tactic at the hypothesis (edit: apparently this is tactic-dependent: rw will repeatedly rewrite, whereas simp generates new inaccessible local declarations)—though I don't think this has been reported as an actual source of confusion anywhere that I've seen.

@nomeata
Copy link
Collaborator

nomeata commented Feb 5, 2025

I'd kick that can down the road. Nobody complained about at h h, and it seems even less likely that people will accidentally use the turnstile twice. So doesn't seem to matter either way.

That said, if it's simple to detect and complain about duplicates while you are touching the code anyways maybe do it, before people discover this “feature” and use it to do repeated rewrites :-)

@jrr6 jrr6 linked a pull request Feb 7, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P-medium We may work on this issue if we find the time
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants