leanprover-community / leanprover-community/mathlib4
simps sometimes gets types confused
Open
Nobody has claimed this yet.
bug
- Dominant language
- Lean
- Stars
- 4.2k
- Forks
- 1.7k
- PR merge metrics
- No merged PRs in 30d
Description
mwe:
import Mathlib.Tactic
import Mathlib.Logic.Equiv.Basic
@[simps]
def univRefl : (Set.univ : Set ℕ) ≃ (Set.univ : Set ℕ) where
toFun x := x
invFun x := x
left_inv _ := rfl
right_inv _ := rfl
@[simps!]
def subtypeTrueRefl : Subtype (⊤ : ℕ → Prop) ≃ Subtype (⊤ : ℕ → Prop) where
__ := univRefl
#check subtypeTrueRefl_apply
/-
subtypeTrueRefl_apply (a✝ : ↑Set.univ) : ↑subtypeTrueRefl a✝ = a✝
-/
The result has a binder a : Set.univ, but this is poorly-typed and should be a : Subtype ⊤
EDIT by Floris: Zulip
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 with the provided minimal Lean example and inspect the simps and simps! behavior around subtypeTrueRefl_apply. The fix is complete when the generated declaration's binder is typed as Subtype ⊤ rather than Set.univ, while the example still elaborates and #check subtypeTrueRefl_apply reports the corrected type.
Written by the indexing model from the issue text.
Assessment
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100