Zulip Chat Archive

Stream: lean4

Topic: Tactics for splitting if statements


Jeremy Salwen (Dec 21 2022 at 17:59):

Suppose I am proving a theorem like

theorem splitme (i:) (P: if i = 0 then Q else R): Q  R

How would I "split the if statement" in P into two cases? The split tactic seems to only be for the goal, not hypotheses. The cases tactic refuses to split on i=0. I have figured out a workaround of usingcases heq: i==0 and then using (i==0) = true to prove i=0 and simplify away the if, but this seems overly convoluted.

David Renshaw (Dec 21 2022 at 18:01):

does split at P work?

Jeremy Salwen (Dec 21 2022 at 18:02):

Ah, that does work! It is not mentioned by the split docs!

Kevin Buzzard (Dec 21 2022 at 18:16):

Nice catch! Docs PRs are always welcome!

Kevin Buzzard (Dec 21 2022 at 18:17):

docs4#split

Kevin Buzzard (Dec 21 2022 at 18:17):

tactic4#split

Kevin Buzzard (Dec 21 2022 at 18:17):

hmm, I don't know how to summon links to tactic docstrings in Lean 4.

Jeremy Salwen (Dec 23 2022 at 04:15):

Created this PR to improve the docs! https://github.com/leanprover/lean4/pull/1988


Last updated: Dec 20 2023 at 11:08 UTC