Skip to content

feat: elaboration with empty tactic sequences #9524

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

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

kmill
Copy link
Collaborator

@kmill kmill commented Jul 25, 2025

This PR changes the parsing of empty tactic sequences so that they report a parse error but still elaborate. For example, in

example (as bs : List Nat) : (as.append bs).length = as.length + bs.length := by
  induction as
  case nil =>
  case cons b bs ih =>

there are parse errors after each => for not having complete tactic sequences, but both show the tactic state for that particular case. The syntaxes for many tactics have also been changed to require that the tactic sequence be strictly indented. The motivation for this is that, without strict indentation, the above example would parse with the second case nested under the first one. The induction and cases tactics were modified in #7830 in anticipation of this change; one can write induction p with | _ x y without the => if the succeeding tactics stay at the same indentation level.

Implementation note: The orelse parser needed some additional logic to handle error recovery. Recall that in p <|> q, if p parses an antiquotation, then q is tentatively parsed as well to see if it parses a longer antiquotation. Now, if q does error recovery and p parses an antiquotation, p is preferred.

Todo: add else if to the if tactic.

This works toward issue #3555. This PR is an experiment to see if having parse errors is more useful than distracting, given that they do not keep the tactic proof from elaborating.

@kmill kmill added the changelog-language Language features, tactics, and metaprograms label Jul 25, 2025
@github-actions github-actions bot added the toolchain-available A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN label Jul 27, 2025
@leanprover-community-bot
Copy link
Collaborator

Mathlib CI status (docs):

  • ❗ Batteries/Mathlib CI will not be attempted unless your PR branches off the nightly-with-mathlib branch. Try git rebase bdd1918cd81c9a09e1b2005af5f3d934e812b8d5 --onto 73422d52fd61c3d5bce6f5edb53c6bd698b1b7ba. You can force Mathlib CI using the force-mathlib-ci label. (2025-07-27 14:45:02)

@leanprover-bot
Copy link
Collaborator

Reference manual CI status:

  • ❗ Reference manual CI will not be attempted unless your PR branches off the nightly-with-manual branch. Try git rebase bdd1918cd81c9a09e1b2005af5f3d934e812b8d5 --onto d3dda9f6d4428a906c096067ecb75e432afc4615. You can force reference manual CI using the force-manual-ci label. (2025-07-27 14:45:04)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog-language Language features, tactics, and metaprograms toolchain-available A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants