Zulip Chat Archive
Stream: Is there code for X?
Topic: example (x : Int) : x % 2 = 0 ∨ x % 2 = 1 := by sorry
Scott Morrison (Nov 11 2023 at 02:32):
I need to prove
example (x : Int) : x % 2 = 0 ∨ x % 2 = 1 := by sorry
but only using Std. Any hints?
Timo Carlin-Burns (Nov 11 2023 at 02:51):
One way would be to have
docs#Nat.mod_lt and then do cases x % 2
twice
Scott Morrison (Nov 11 2023 at 03:21):
That would work nicely for Nat
, but not for Int
.
Scott Morrison (Nov 11 2023 at 03:23):
Ah, but
example (x : Int) : x % 2 = 0 ∨ x % 2 = 1 := by
have h₁ := Int.emod_nonneg x (b := 2) (by decide)
have h₂ := Int.emod_lt_of_pos x (b := 2) (by decide)
match x % 2, h₁, h₂ with
| 0, _, _ => simp
| 1, _, _ => simp
does it.
Scott Morrison (Nov 11 2023 at 03:23):
Thanks.
Last updated: Dec 20 2023 at 11:08 UTC