Skip to content

fix: let simp arguments elaborate with error recovery - #5863

Merged
kmill merged 5 commits into
leanprover:masterfrom
kmill:simp_list_elab_ix
Oct 28, 2024
Merged

kmill merged 5 commits into
leanprover:masterfrom
kmill:simp_list_elab_ix

Conversation

@kmill

@kmill kmill commented Oct 28, 2024 •

Copy link
Copy Markdown
Collaborator

Modifies simp to elaborate all simp arguments without disabling error recovery. Like in #4177, simp arguments with elaboration errors are not added to the simp set. Error recovery is still disabled when simp is used in combinators such as first.

This enables better term info and features like tab completion when there are elaboration errors.

Also included is a fix to the all_goals and <;> tactic combinators. Recall that try/catch for the Tactic monad restores the state on failure. This meant that all messages were being cleared on tactic failure. The fix is to use Tactic.tryCatch instead, which doesn't restore state.

Part of addressing #3831

Closes #4888

Modifies `simp` to elaborate all simp arguments, and *then* failing if any had any elaboration issues, rather than failing on the first simp argument.

This enables better term info and things like tab completion.

Part of addressing leanprover#3831

Closes leanprover#4888
@kmill
kmill requested a review from kim-em as a code owner October 28, 2024 07:17
@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 Oct 28, 2024
ghost pushed a commit to leanprover-community/batteries that referenced this pull request Oct 28, 2024
ghost pushed a commit to leanprover-community/mathlib4 that referenced this pull request Oct 28, 2024
@ghost ghost added the breaks-mathlib This is not necessarily a blocker for merging: but there needs to be a plan label Oct 28, 2024
@ghost

ghost commented Oct 28, 2024 •

Copy link
Copy Markdown

Mathlib CI status (docs):

@nomeata

nomeata commented Oct 28, 2024

Copy link
Copy Markdown
Collaborator

Recall that try/catch for the Tactic monad restores the state on failure. This meant that all messages were being cleared on tactic failure. The fix is to use Tactic.tryCatch instead, which doesn't restore state.

That's quite a foot gun, it seems. Should we remove the try-catch instance for TacticM and force every user to think about which one they want where? Or is that too tedious? Or is the other one the better default?

@kmill

kmill commented Oct 28, 2024

Copy link
Copy Markdown
Collaborator Author

@nomeata I've shot both of my feet with this one, and it's why I added this Tactic.tryCatch escape hatch recently. I really want try/catch to be non-backtracking, but it's going to be a lot of work to evaluate every tactic...

@kmill kmill changed the title fix: let simp arguments elaborate without disabling error recovery fix: let simp arguments elaborate with error recovery Oct 28, 2024
ghost pushed a commit to leanprover-community/batteries that referenced this pull request Oct 28, 2024
ghost pushed a commit to leanprover-community/mathlib4 that referenced this pull request Oct 28, 2024
@ghost ghost 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 Oct 28, 2024
Comment thread tests/lean/run/4888.lean Resolved
@kmill
kmill enabled auto-merge October 28, 2024 21:25
@kmill
kmill added this pull request to the merge queue Oct 28, 2024
ghost pushed a commit to leanprover-community/batteries that referenced this pull request Oct 28, 2024
ghost pushed a commit to leanprover-community/mathlib4 that referenced this pull request Oct 28, 2024
Merged via the queue into leanprover:master with commit b308f2b Oct 28, 2024
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 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.

all_goals + apply elaboration = lost errors

2 participants