Zulip Chat Archive

Stream: mathlib4

Topic: induction, case, rcases


Yury G. Kudryashov (Jan 21 2023 at 01:53):

@Gabriel Ebner @Mario Carneiro , what do you think about making case _ after induction support rcases syntax? Or it's hard to change because rcases is in std, not in core?

Gabriel Ebner (Jan 21 2023 at 01:58):

To be honest, I really dislike the proliferation of rcases syntax in mathlib4. rcases was absolutely amazing in Lean 3, because we didn't have anything else and because it was a strict superset of the built-in pattern matching syntax. In Lean 4, the rcases syntax conflicts heavily with and doesn't support half of the built-in syntax.

Gabriel Ebner (Jan 21 2023 at 01:59):

import Std.Tactic.Ext

example (p q : Nat × Nat  Nat) : p = q := by
  ext (x, y) -- syntax error (uses rcases)

example (p q : Nat × Nat  Nat) : p = q := by
  funext (x, y) -- works (uses normal pattern-matching syntax)

Gabriel Ebner (Jan 21 2023 at 02:00):

In an ideal world, the built-in pattern matching would support nested or-patterns and we wouldn't have a separate rcases. (Although I believe this would be a tad less powerful than the current rcases, because it doesn't work as amazingly with rfl.)

Yury G. Kudryashov (Jan 21 2023 at 02:04):

Can I use these built-in features in https://github.com/leanprover-community/mathlib4/blob/port/Order.Filter.Basic/Mathlib/Order/Filter/Basic.lean#L371 ?

Gabriel Ebner (Jan 21 2023 at 02:07):

To get back to your original question, we could add an rcase tactic that accepts rcases patterns. The built-in case tactic doesn't support patterns. (Neither does induction x with | ctor .. =>.)

Kevin Buzzard (Jan 22 2023 at 18:21):

rintro (h1 | h2) beats lean 4 lambda, right?

Mario Carneiro (Jan 22 2023 at 18:54):

Yeah, I'm not holding my breath for a grand unification of rcases patterns and regular lean patterns. Lean patterns are literally just term which ties our hands on a bunch of things. I'm more hopeful that we can make rcases patterns subsume term patterns, but you would have to be really careful to avoid ambiguities since there are so many things that could be legal in a term expression (including notations defined after rcases and its pattern grammar is defined)


Last updated: Dec 20 2023 at 11:08 UTC