leanprover / leanprover/lean4

`rcases` doesn't clear original variable for `Quot`

Open
#12,891 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Prerequisites
Description

When using rcases with quotients, the variable is not cleared. This contrasts the behavior for inductive types, where the discriminant is always cleared.

Context

Proving things about a quotient type

Steps to Reproduce
/--
error: unsolved goals
case mk
x✝ : Quot fun x x_1 => True
x : Nat
⊢ True
-/
#guard_msgs in
example (x : Quot fun _ _ : Nat => True) : True := by
  rcases x with ⟨x⟩

Expected behavior: Only one x variable remains, which should be x : Nat.

Actual behavior: The original variable is not cleared, keeping x✝ unnecessarily in the local context.

Versions

Lean 4.30.0-nightly-2026-03-11

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

Start with the minimal rcases reproducer in the issue and run it against the specified Lean nightly version. Trace the rcases handling for quotient types, comparing it with inductive-type handling. Done means the original Quot variable is cleared and only the expected x : Nat remains in the local context.

Written by the indexing model from the issue text.

Assessment

Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.