Skip to content

feat: require indented tactic sequence after top-level by#13217

Closed
nomeata wants to merge 1 commit intomasterfrom
joachim/by-indent
Closed

feat: require indented tactic sequence after top-level by#13217
nomeata wants to merge 1 commit intomasterfrom
joachim/by-indent

Conversation

@nomeata
Copy link
Copy Markdown
Collaborator

@nomeata nomeata commented Mar 31, 2026

This PR makes two changes to tacticSeqIndentGt (used by by, decreasing_by, ·, and
finally):

  1. Strict indentation at the top level. Adds checkColPosGt, a variant of checkColGt that
    defaults to checking against column 0 when no position has been saved via withPosition.
    Previously, checkColGt was a no-op at the top level, allowing by blocks to have
    un-indented tactic sequences:

    theorem foo (h : True) : True := by
    exact h  -- was accepted, now requires indentation
  2. Empty tactic sequence fallback. When no appropriately indented content follows,
    tacticSeqIndentGt falls back to an empty tactic sequence (like by {}) instead of a parse
    error. This produces an elaboration error (unsolved goals) rather than a syntax error, which
    gives better IDE support (goal display, completions) in incomplete tactic blocks.

This can be subsumed later by a more principled approach of wrapping topLevelCommandParserFn
with withPosition (cf. #3215).

Related: #3215, #9524. Implements parts of #3555.

🤖 Generated with Claude Code

@nomeata nomeata added the changelog-language Language features and metaprograms label Mar 31, 2026
@nomeata nomeata changed the base branch from nightly-with-mathlib to master March 31, 2026 16:41
@nomeata nomeata force-pushed the joachim/by-indent branch 2 times, most recently from a67090f to 52d1286 Compare March 31, 2026 17:38
@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 Mar 31, 2026
@leanprover-bot
Copy link
Copy Markdown
Collaborator

Reference manual CI status:

  • ❗ Reference manual CI can not be attempted yet, as the nightly-testing-2026-03-25 tag does not exist there yet. We will retry when you push more commits. If you rebase your branch onto nightly-with-manual, reference manual CI should run now. You can force reference manual CI using the force-manual-ci label. (2026-03-31 17:49:25)

mathlib-nightly-testing bot pushed a commit to leanprover-community/batteries that referenced this pull request Mar 31, 2026
@github-actions github-actions bot added the mathlib4-nightly-available A branch for this PR exists at leanprover-community/mathlib4-nightly-testing:lean-pr-testing-NNNN label Mar 31, 2026
mathlib-nightly-testing bot pushed a commit to leanprover-community/mathlib4-nightly-testing that referenced this pull request Mar 31, 2026
This PR adds `checkColGtDefault`, a variant of `checkColGt` that defaults
to checking against column 0 when no position has been saved via
`withPosition`. Previously, `checkColGt` was a no-op at the top level,
allowing `by` blocks to have un-indented tactic sequences:

```lean
theorem foo (h : True) : True := by
exact h  -- was accepted, now requires indentation
```

`tacticSeqIndentGt` now uses `checkColGtDefault` instead of `checkColGt`,
so `by`, `decreasing_by`, and `·` consistently require indented tactics
at all levels.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@nomeata nomeata force-pushed the joachim/by-indent branch from 52d1286 to 4635a66 Compare March 31, 2026 17:57
@mathlib-lean-pr-testing mathlib-lean-pr-testing bot added the breaks-mathlib This is not necessarily a blocker for merging: but there needs to be a plan label Mar 31, 2026
@mathlib-lean-pr-testing
Copy link
Copy Markdown

Mathlib CI status (docs):

mathlib-nightly-testing bot pushed a commit to leanprover-community/batteries that referenced this pull request Mar 31, 2026
mathlib-nightly-testing bot pushed a commit to leanprover-community/mathlib4-nightly-testing that referenced this pull request Mar 31, 2026
@mathlib-lean-pr-testing
Copy link
Copy Markdown

Mathlib CI status (docs):

nomeata added a commit to leanprover-community/mathlib4-nightly-testing that referenced this pull request Mar 31, 2026
Adapt to leanprover/lean4#13217 which requires indented tactic sequences
after `by` and `decreasing_by`.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@mathlib-lean-pr-testing
Copy link
Copy Markdown

Mathlib CI status (docs):

nomeata added a commit to leanprover-community/mathlib4-nightly-testing that referenced this pull request Mar 31, 2026
Adapt to leanprover/lean4#13217.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@mathlib-lean-pr-testing mathlib-lean-pr-testing bot added builds-mathlib CI has verified that Mathlib builds against this PR and removed breaks-mathlib This is not necessarily a blocker for merging: but there needs to be a plan labels Mar 31, 2026
@mathlib-lean-pr-testing
Copy link
Copy Markdown

Mathlib CI status (docs):

nomeata added a commit that referenced this pull request Apr 1, 2026
…approach)

This uses `withPosition commandParser` at the top level to enforce
indentation in `by` blocks, combined with an empty-by fallback for
better error messages. Compare with checkColPosGt approach in #13217.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
nomeata added a commit to leanprover-community/mathlib4-nightly-testing that referenced this pull request Apr 1, 2026
Adapt to leanprover/lean4#13217 which requires indented tactic sequences
after `by` and `decreasing_by`.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
nomeata added a commit to leanprover-community/mathlib4-nightly-testing that referenced this pull request Apr 1, 2026
Adapt to leanprover/lean4#13217.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
nomeata added a commit that referenced this pull request Apr 2, 2026
…approach)

This uses `withPosition commandParser` at the top level to enforce
indentation in `by` blocks, combined with an empty-by fallback for
better error messages. Compare with checkColPosGt approach in #13217.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@nomeata
Copy link
Copy Markdown
Collaborator Author

nomeata commented Apr 2, 2026

This is not good, but #13229 is promising.

@nomeata nomeata closed this Apr 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

builds-mathlib CI has verified that Mathlib builds against this PR changelog-language Language features and metaprograms mathlib4-nightly-available A branch for this PR exists at leanprover-community/mathlib4-nightly-testing:lean-pr-testing-NNNN 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.

2 participants