leanprover / leanprover/lean4

`autoTry.onSorry` suggests using the current theorem to solve the goal

Open
#14,792 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug P-medium
Dominant language
Lean
Stars
9.2k
Forks
990
Avg merge
1d 17h
Merged PRs (30d)
175

Description

Prerequisites
Description

Setting the option autoTry.onSorry to true makes sorries suggest using the theorem they're in to solve itself.

Context

#lean4 > autoTry suggests recursion

Steps to Reproduce
set_option autoTry.onSorry true

/--
warning: declaration uses `sorry`
---
info: Try this:
  [apply] exact _root_.foo1
-/
#guard_msgs in
theorem foo1 : False := by
  sorry

/--
warning: declaration uses `sorry`
---
info: Try this:
  [apply] exact _root_.foo2 a b
-/
#guard_msgs in
theorem foo2 (a b : Nat) : a = b := by
  sorry

Expected behavior: The first sorry should suggest impossible by simp as would happen if we replace the sorry with try?, and the second sorry should not output anything as try? in its place says Tactic `try?` failed.

Actual behavior: As the #guard_msgs show, autoTry.onSorry always suggests using the current theorem to solve itself. Applying the Try this suggestions produces an Unknown identifier error. Removing the _root_ changes the error to fail to show termination.

Versions
Lean 4.35.0-nightly-2026-08-14
Target: x86_64-unknown-linux-gnu Linux
Additional Information

N/A

Impact

Add 👍 to issues you consider important. If others are impacted by this issue, please ask them to add 👍 to it.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Run the supplied minimal reproducer with autoTry.onSorry enabled and compare its output with replacing each sorry by try?. Trace the autoTry.onSorry and try? entry points to see why the current theorem is included in suggestions. Done means the first case suggests impossible by simp, while the second produces no misleading self-application suggestion.

Written by the indexing model from the issue text.

Assessment

Domain
compilers
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.