-
Notifications
You must be signed in to change notification settings - Fork 810
type error in example, sensitive to simp attribute #1829
Copy link
Copy link
Closed
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
A type error that comes and goes depending on whether we use simp [attribute] X in ... on an earlier declaration.
Steps to Reproduce
theorem eq_iff_true_of_subsingleton [Subsingleton α] (x y : α) : x = y ↔ True :=
⟨fun _ => ⟨⟩, fun _ => (Subsingleton.elim ..)⟩
/- comment out following `attribute [simp]` to make the example below work -/
attribute [simp] eq_iff_true_of_subsingleton in
example : True := trivial
structure Func' (α : Sort _) (β : Sort _) :=
(toFun : α → β)
def r : Func' α α := ⟨id⟩
@[simp] theorem r_toFun {α : Sort u_1} (a : α) : Func'.toFun r a = id a := rfl
example (x y : α) (h : x = y) : r.toFun x = y := by simp <;> rw [h]
/-
in the presence of `attribute [simp] eq_iff_true_of_subsingleton in`, one gets
application type mismatch
Eq
argument has type
Sort u_1
but function has type
{α : Prop} → α → α → Prop
-/
-- If we change `example` to `theorem`, it doesn't care about the `attribute [simp]`.
theorem noissue (x y : α) (h : x = y) : r.toFun x = y := by simp <;> rw [h]
With the attribute [simp] eq_iff_true_of_subsingleton in line, we get an error on the later example. Without the attribute, the error goes away.
Expected behavior: [What you expect to happen]
No errors!
Versions
leanprover/lean4:nightly-2022-11-10
Other information
(Minimised slightly from Yakov Pechersky's minimisation at https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/application.20type.20mismatch.20in.20example/near/309533447. We're seeing this in the mathlib4 port, e.g. https://github.com/leanprover-community/mathlib4/actions/runs/3460347374/jobs/5776794830.)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels