Repository navigation
feat: allow omission of => ?_ in induction/cases tactics - #7830
Merged
Merged
Conversation
ghost
pushed a commit
to leanprover-community/batteries
that referenced
this pull request
Apr 5, 2025
ghost
pushed a commit
to leanprover-community/mathlib4
that referenced
this pull request
Apr 5, 2025
|
Mathlib CI status (docs):
|
ghost
pushed a commit
to leanprover-community/batteries
that referenced
this pull request
Apr 6, 2025
ghost
pushed a commit
to leanprover-community/mathlib4
that referenced
this pull request
Apr 6, 2025
kmill
added a commit
to kmill/lean4
that referenced
this pull request
Apr 14, 2025
This PR adds the tactic implementation for leanprover#7830, before changing the syntax after a stage0 update. It will allow optional RHSs in induction cases.
kmill
force-pushed
the
kmill_induction_no_arrow
branch
from
April 14, 2025 21:29
5faa9cd to
0a35c43
Compare
feat: allow omission of `=> ?_` in `induction`/`cases` This PR modifies the syntax of `induction`, `cases`, and other tactics that use `Lean.Parser.Tactic.inductionAlts`. If a case omits `=> ...` then it is assumed to be `=> ?_`. For example, ``` example (p : Nat × Nat) : p.1 = p.1 := by cases p with | _ p1 p2 /- case mk p1 p2 : Nat ⊢ (p1, p2).fst = (p1, p2).fst -/ ``` This works with multiple cases as well. For example, `induction n with | zero | succ n ih` is short for `induction n with | zero | succ n ih => ?_` is short for `induction n with | zero => ?_ | succ n ih => ?_`. Note that the grammar makes it so that only the last alternative can omit `=>`. Any `=>`-free alternatives before an alternative with `=>` will take that `=>`. fix macro expansion loop
kmill
force-pushed
the
kmill_induction_no_arrow
branch
from
April 15, 2025 17:54
0a35c43 to
d8be4c7
Compare
ghost
pushed a commit
to leanprover-community/batteries
that referenced
this pull request
Apr 15, 2025
ghost
pushed a commit
to leanprover-community/mathlib4
that referenced
this pull request
Apr 15, 2025
3 tasks done
kmill
added a commit
to kmill/lean4
that referenced
this pull request
Jul 25, 2025
This PR fixes a bug introduced in leanprover#7830 where if the cursor is at the indicated position ```lean example (as bs : List Nat) : (as.append bs).length = as.length + bs.length := by induction as with | nil => -- cursor | cons b bs ih => ``` then the Infoview would show "no goals".
github-merge-queue Bot
pushed a commit
that referenced
this pull request
Jul 26, 2025
… and other tactic info improvements (#9553) This PR fixes a bug introduced in #7830 where if the cursor is at the indicated position ```lean example (as bs : List Nat) : (as.append bs).length = as.length + bs.length := by induction as with | nil => -- cursor | cons b bs ih => ``` then the Infoview would show "no goals" rather than the `nil` goal. The PR also fixes a separate bug where placing the cursor on the next line after the `induction`/`cases` tactics like in ```lean induction as with | nil => sorry | cons b bs ih => sorry I -- < cursor ``` would report the original goal in the goal list. Furthermore, there are numerous improvements to error recovery (including `allGoals`-type logic for pre-tactics) and the visible tactic states when there are errors. Adds `Tactic.throwOrLogErrorAt`/`Tactic.throwOrLogError` for throwing or logging errors depending on the recovery state.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR modifies the syntax of
induction,cases, and other tactics that useLean.Parser.Tactic.inductionAlts. If a case omits=> ...then it is assumed to be=> ?_. Example:This works with multiple cases as well. Example:
The
induction n with | zero | succ n ihis short forinduction n with | zero | succ n ih => ?_, which is short forinduction n with | zero => ?_ | succ n ih => ?_. Note that a consequence of parsing is that only the last alternative can omit=>. Any=>-free alternatives before an alternative with=>will be a part of that alternative.Rationale:
tacticSeqto be indented. For one-constructor types, this lets the rest of the tactic sequence not need indentation.cases'/induction'tactics in mathlib.