Zulip Chat Archive
Stream: new members
Topic: Rule of thumb: `cases`, `cases'`, `rcases` vs. `rintro`
Isak Colboubrani (Mar 30 2025 at 21:49):
For those teaching Lean/Mathlib (or others with relevant insights): do you have any practical rules of thumb that can reduce students’ cognitive load when deciding between intro/cases, intro/cases', intro/rcases, or rintro in situations where any of them would work, or more generally?
Examples:
-- Option 1.
intro h
cases h with
| … => …
| … => …
-- Option 2.
intro h
cases' h with … …
-- Option 3.
intro h
rcases h with … | …
-- Option 4.
rintro (… | … | …)
Bolton Bailey (Mar 31 2025 at 00:03):
I think the tactic cheatsheet is perhaps what you're looking for?
Ilmārs Cīrulis (Mar 31 2025 at 00:04):
Somehow I still haven't learned about cases', rcases or rintro, because the 1st option is completely sufficient for me. This is my way of 'reducing cognitive load', probably.
Bolton Bailey (Mar 31 2025 at 00:05):
Hmm, seems the cheatsheet doesn't actually cover rintro or cases
Jon Eugster (Apr 02 2025 at 14:04):
So far my take on this was to just introduce two tactics: intro and obtain and say that all the cases-variations are just different stylistic choices to use instead of obtain. So concretely I've just settled on Option 3 above but with obtain:
- I introduced
introas the tactic to make progress onA → B.rintroseemed mostly superfluous as one can writeintro ⟨a, b⟩, too. Onlyrintro a | bseems not to work withintrobut then I'd say to just useintrofollowed byobtain. obtain ⟨a, b⟩ := handobtain a | b := h(or a blankobtain ⟨⟩ := hfor both) is used to split an existing assumption.- Afaik
rcasesis literally the same asobtainjust a different syntax. cases'I see as a backwards-compatibility syntax forobtain(aka Lean3-style syntax) which shouldn't be used too much, but it's here if you like it.casesI see as a more verbose version ofobtainwhich might be nice if the students are familiar with term mode andmatchstatements, but otherwise I'd preferobtaindue to it's similarity tohave _ := _
- Afaik
Jireh Loreaux (Apr 02 2025 at 15:20):
The one nice thing about cases over obtain is that the match arms have names as opposed to a focusing dot ·. However, we recently had a discussion about extended the pattern syntax to allow naming of the arms.
Last updated: May 02 2025 at 03:31 UTC