Zulip Chat Archive
Stream: new members
Topic: Proof by cases on Nat
Jesse Slater (Jan 03 2023 at 01:16):
I want to prove something by cases on a Nat n. the cases should be n = 0, n = 1, n > 1. How do I do this?
Riccardo Brasca (Jan 03 2023 at 01:22):
rcases n with (rfl | rfl | n)
should produce three goals, one for 0
, one for 1
and one for n.succ.succ
. Proving that 1 < n.succ.succ
should be easy.
Riccardo Brasca (Jan 03 2023 at 01:30):
You can also use a preliminary result (that is maybe in mathlib, I didn't search) to literally obtain the three cases.
lemma foo (n : ℕ) : n = 0 ∨ n = 1 ∨ 1 < n :=
by rcases n with (rfl | rfl | n); simp
lemma bar (n : ℕ) : true :=
begin
rcases foo n with (rfl | rfl | n),
...
end
Jesse Slater (Jan 03 2023 at 01:46):
Thanks!
Last updated: Dec 20 2023 at 11:08 UTC