Zulip Chat Archive

Stream: mathlib4

Topic: casesm / constructorm on no match: error or not?


David Renshaw (Jan 12 2023 at 21:36):

casesm and constructor_matching/constructorm in mathlib4 are more forgiving when there is no match:

mathlib3:

example : true  true :=
begin
  constructor_matching [_  _], -- error here. no match
  sorry
end

mathlib4:

example : True  True := by
  constructorm (_  _) -- no error!
  constructorm (_  _) <;> exact True.intro

Is this what we want? I was tripped up by it while implementing tauto.

Floris van Doorn (Jan 12 2023 at 21:41):

No, tactics should generally not succeed if they didn't do anything.

David Renshaw (Jan 12 2023 at 21:43):

What about the * version of these tactics?
In mathlib3:

example : true  true := begin
  constructor_matching* [_  _], -- no error
  constructor_matching [_  _]; exact true.intro,
end

David Renshaw (Jan 12 2023 at 21:44):

This makes sense to me -- the * means "zero or more times".

Floris van Doorn (Jan 12 2023 at 21:47):

No strong opinion here. We generally want a "one or more times" tactic inside a begin-end block. But a "zero or more times" tactic is useful to define other tactics.

James Gallicchio (Jan 12 2023 at 21:54):

Lean4 has the try tactic for 0 or 1 times, and repeat for zero or more times. Not sure if those existed in lean3 but they seem to cover most use cases nicely.

Floris van Doorn (Jan 12 2023 at 22:04):

yes, they also exist in Lean 3

Kevin Buzzard (Jan 12 2023 at 23:30):

It's confusing that simp in lean 4 succeeds if it does nothing

David Renshaw (Jan 13 2023 at 18:37):

casesm/constructorm issue fixed in https://github.com/leanprover-community/mathlib4/pull/1552

Floris van Doorn (Jan 13 2023 at 23:48):

just to clarify (because I was confused myself): this fixes the constructorm/casesm issue succeeding without progress, not simp succeeding without progress.


Last updated: Dec 20 2023 at 11:08 UTC