Zulip Chat Archive

Stream: Is there code for X?

Topic: v % 2 ≠ (v + 1) % 2


Iván Renison (Oct 25 2023 at 12:25):

Is there any theorem that says this?

theorem aux (n : ) : n % 2  (n + 1) % 2 := by
  sorry

Ruben Van de Velde (Oct 25 2023 at 12:33):

A bit annoying:

theorem aux (n : ) : n % 2  (n + 1) % 2 := by
  rw [Nat.add_mod]
  have := Nat.mod_lt n two_pos
  interval_cases n % 2 <;> simp

Ruben Van de Velde (Oct 25 2023 at 12:36):

Maybe more conceptual? Not sure

theorem aux' (n : ) : n % 2 = if Even n then 0 else 1 := by
  simp_rw [Nat.even_iff]
  have := Nat.mod_lt n two_pos
  interval_cases n % 2 <;> simp

theorem aux (n : ) : n % 2  (n + 1) % 2 := by
  rw [aux', aux']
  simp_rw [Nat.even_add_one]
  split_ifs <;> simp

Eric Wieser (Oct 25 2023 at 12:42):

theorem aux (n : ) : n % 2  (n + 1) % 2 := by
  refine (ZMod.eq_iff_modEq_nat 2).not.mp ?_
  simp

Iván Renison (Oct 27 2023 at 18:54):

Thanks


Last updated: Dec 20 2023 at 11:08 UTC