Zulip Chat Archive

Stream: mathlib4

Topic: ZMod 0


Michael Stoll (Nov 11 2023 at 19:27):

Are there objections to adding

instance : CanLift (ZMod 0)  () (fun _  True) where
  prf x _ := x.valMinAbs, rfl

lemma ZMod.isUnit_zMod_zero_iff (m : ZMod 0) : IsUnit m  m = 1  m = -1 := by
  refine fun h  ?_, fun h  ?_
  · lift m to  using trivial
    obtain x, hx := isUnit_iff_exists_inv.mp h
    lift x to  using trivial
    exact_mod_cast Int.isUnit_iff.mp <| isUnit_iff_exists_inv.mpr x, hx
  · rcases h with rfl | rfl
    · exact isUnit_one
    · exact isUnit_neg_one

to Data.ZMod.Basic? (Golf welcome) @Floris van Doorn (who seems to have written the lift tactic originally)

Ruben Van de Velde (Nov 11 2023 at 19:28):

Using lift for this seems quite surprising

Michael Stoll (Nov 11 2023 at 19:29):

How would you do it?

Michael Stoll (Nov 11 2023 at 19:29):

If we had a ring isomorphism with the integers, one could transport stuff, I assume.

Ruben Van de Velde (Nov 11 2023 at 19:32):

lemma ZMod.isUnit_zMod_zero_iff (m : ZMod 0) : IsUnit m  m = 1  m = -1 :=
  Int.isUnit_iff

Michael Stoll (Nov 11 2023 at 19:33):

This is way too simple :smile:
Is this defeq abuse?

Ruben Van de Velde (Nov 11 2023 at 19:33):

It's defeq use. Up to you whether it's abuse :)

Michael Stoll (Nov 11 2023 at 19:33):

But thanks for pointing this out!

Yaël Dillies (Nov 11 2023 at 19:37):

I am pretty sure docs#ZMod is defined the way it is precisely so that one may look through the definition.

Ruben Van de Velde (Nov 11 2023 at 19:37):

I guess the other question is why you're using ZMod 0

Michael Stoll (Nov 11 2023 at 19:38):

The reason I need this is that I want to prove something for ZMod n without assumptions on n.

Yaël Dillies (Nov 11 2023 at 19:38):

Yeah then look through as much as you want.


Last updated: Dec 20 2023 at 11:08 UTC