Zulip Chat Archive

Stream: Is there code for X?

Topic: simple calculations in `ZMod q`


Moritz Firsching (Jul 31 2023 at 08:20):

When using docs#orderOf_eq_prime for something I need the lemma one_ne_two as described here:

import Mathlib.Tactic

lemma ZMod.zero_ne_one (q : ) [Fact (1 < q)] : (0 : ZMod q)  1 := by
  intro h
  have := ZMod.val_one q  (ZMod.val_eq_zero (1 : ZMod q)).mpr h.symm
  linarith

lemma ZMod.one_ne_two (q : )  [Fact (1 < q)] : (1 : ZMod q)  2 := by
  intro h1
  have h : (2 - 1 : ZMod q) = 0 := by exact (sub_eq_zero.mpr h1.symm)
  norm_num at h
  exact (ZMod.zero_ne_one q) h.symm

I feel like something like this should be in the library, is there?
Or maybe there is a tactic to deal with these kind of trivial calculations in ZMod q when q is larger than 1.

Ruben Van de Velde (Jul 31 2023 at 08:32):

Maybe there's more API assuming NeZero q? I'm not sure

Doh

Kevin Buzzard (Jul 31 2023 at 08:38):

Both lemmas also need q!=1

Eric Wieser (Jul 31 2023 at 08:58):

Both lemmas only need q ≠ 1


Last updated: Dec 20 2023 at 11:08 UTC