You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
rfl not working for pattern matching on indexed inductive types #837
Reduced the issue to a self-contained, reproducible test case.
Description
Unless I'm doing something very wrong, rfl does not seem to be working properly for functions defined by pattern matching on indexed inductive types, even for every simple functions
inductiveWk: Nat -> Nat -> Type0 where
| id: Wk n n
| step: Wk m n -> Wk (Nat.succ m) n
| lift: Wk m n -> Wk (Nat.succ m) (Nat.succ n)
defwk_comp {n m l: Nat} (ρ: Wk n m) (σ: Wk m l): Wk n l :=
match n, m, l, ρ, σ with
| _, _, _, Wk.id, σ => σ
| _, _, _, Wk.step ρ, σ => Wk.step (wk_comp ρ σ)
| _, _, _, Wk.lift ρ, Wk.id => Wk.lift ρ
| _, _, _, Wk.lift ρ, Wk.step σ => Wk.step (wk_comp ρ σ)
| _, _, _, Wk.lift ρ, Wk.lift σ => Wk.lift (wk_comp ρ σ)
theoremwk_comp_id_id {ρ: Wk m n}: wk_comp Wk.id ρ = ρ := rfl
I get an error
Expected behavior: this should type-check (it works in Agda)
Actual behavior: I get the error
(kernel) declaration type mismatch, 'wk_comp_id_id' has type
∀ {m n : Nat} {ρ : Wk m n}, wk_comp Wk.id ρ = wk_comp Wk.id ρ
but it is expected to have type
∀ {m n : Nat} {ρ : Wk m n}, wk_comp Wk.id ρ = ρ
Reproduces how often: Always
Versions
Lean (version 4.0.0-nightly-2021-12-01, commit 4aab42f, Release)
on Ubuntu 20.04
inductiveWk: Nat -> Nat -> Type0 where
| id: Wk n n
| step: Wk m n -> Wk (Nat.succ m) n
defwk_comp : Wk n m → Wk m l → Wk n l
| Wk.id, σ => σ
| Wk.step ρ, σ => Wk.step (wk_comp ρ σ)
theoremwk_comp_id_id {ρ: Wk m n}: wk_comp Wk.id ρ = ρ := rfl
/-(kernel) declaration type mismatch, 'wk_comp_id_id' has type ∀ {m n : Nat} {ρ : Wk m n}, wk_comp Wk.id ρ = wk_comp Wk.id ρbut it is expected to have type ∀ {m n : Nat} {ρ : Wk m n}, wk_comp Wk.id ρ = ρ-/
inductiveWk: Nat -> Nat -> Type0 where
| id: Wk n n
| step: Wk m n -> Wk m n -- (Nat.succ m) ndefwk_comp : Wk n m → Wk m l → Wk n l
| Wk.id, σ => σ
| Wk.step ρ, σ => Wk.step (wk_comp ρ σ)
theoremwk_comp_id_id {ρ: Wk m n}: wk_comp Wk.id ρ = ρ := rfl
Activity
kmill commentedon Dec 1, 2021
Here's a smaller example with the same error:
arthurpaulino commentedon Dec 1, 2021
For some reason this is accepted:
leodemoura commentedon Dec 2, 2021
Thanks for all the useful feedback. It helped to diagnose and fix the issue.