Zulip Chat Archive

Stream: lean4

Topic: Change in pattern matching; expected behaviour?


Scott Morrison (Oct 26 2021 at 07:10):

While bumping mathlib4 I had to change

protected lemma add_comm :  a b : , a + b = b + a
| (n : ), (m : ) => by simp [Nat.add_comm]
| (_ : ), -[1+ _] => rfl
| -[1+ _], (_ : ) => rfl
| -[1+ _], -[1+ _] => by simp [Nat.add_comm]

to

protected lemma add_comm :  a b : , a + b = b + a
| (n : ), (m : ) => by simp [Nat.add_comm]
| (n : ), -[1+ _] => rfl
| -[1+ _], (m : ) => rfl
| -[1+ _], -[1+ _] => by simp [Nat.add_comm]

as the (_ : ℕ) patterns are now causing errors:

type mismatch
  ?m.11643
has type
   : Type
but is expected to have type
   : Type

I don't think this is a particularly bad regression, but just wanted to check in case it was an unintentional side-effect.

Leonardo de Moura (Oct 26 2021 at 13:17):

@Scott Morrison Thanks for reporting this issue. Do you know which commit triggered the issue?

Mario Carneiro (Oct 26 2021 at 13:39):

I don't know which commit it is, but here is a #mwe that can be used to bisect:

example : Int  Nat
| (_ : Nat) => 0
| Int.negSucc n => 0

Scott Morrison (Oct 26 2021 at 22:09):

bisected and reported as https://github.com/leanprover/lean4/issues/742.

Leonardo de Moura (Oct 26 2021 at 22:20):

@Scott Morrison @Mario Carneiro Thanks for the feedback (mwe and exact commit), it is very useful.

Leonardo de Moura (Oct 27 2021 at 17:33):

Fixed this issue.


Last updated: Dec 20 2023 at 11:08 UTC