bug: `specialize` tactic is missing an occurs check
Nobody has claimed this yet.
- Dominant language
- Lean
- Stars
- 9.2k
- Forks
- 990
- Avg merge
- 1d 17h
- Merged PRs (30d)
- 175
Description
Prerequisites
- Put an X between the brackets on this line if you have done all of the following:
- Checked that your issue isn't already filed.
- Reduced the issue to a self-contained, reproducible test case.
Description
The tactic specialize does not check to see if the main goal occurs in the value that to which it assigns the main goal. This causes a stack overflow:
open Lean Meta Elab Tactic in
/-- `rename_main_goal a` renames the main goal to `a`. -/
elab "rename_main_goal " n:ident : tactic => do
let g ← getMainGoal
g.setUserName n.getId
example (h : True → True) : True := by
rename_main_goal a
specialize h ?a -- stack overflow
Steps to Reproduce
- Obtain a goal and a hypothesis in that goal's context which has an argument of the same type as the goal.
- With that goal as the main goal,
specializethe hypothesis applied to that goal.
Expected behavior: An error pointing out that the goal occurs in the specialized value.
Actual behavior: Stack overflow
Reproduces how often: Always
Versions
4.0.0-rc4; macOS Ventura 13.4.1 (Intel-based)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the self-contained reproducer in the issue and inspect the specialize tactic entry point and its goal-assignment path. Confirm that applying the main goal produces an error about the goal occurring in the specialized value rather than a stack overflow, then add or run a regression test for the example.
Written by the indexing model from the issue text.
Assessment
- Domain
- compilers, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 42/100