Zulip Chat Archive
Stream: Is there code for X?
Topic: Infinite cyclic group isomorphic to Z
Edison Xie (Aug 12 2025 at 15:37):
import Mathlib
noncomputable def infiniteCyclicIsoZ (A : Type*) [AddCommGroup A] [Infinite A] (i : A)
(h : ∀ x : A, x ∈ AddSubgroup.zmultiples i) : A ≃+ ℤ where
toFun x := h x|>.choose
map_add' x y := by
have := h (x + y) |>.choose_spec.trans (by simp [(h x).choose_spec, (h y).choose_spec] :
_ = (h x).choose • i + (h y).choose • i)
rw [← add_smul, ← sub_eq_zero, ← sub_smul, ← addOrderOf_dvd_iff_zsmul_eq_zero,
Infinite.addOrderOf_eq_zero_of_forall_mem_zmultiples h] at this
simpa [sub_eq_zero] using this
invFun m := m • i
left_inv x := by simp; exact h x|>.choose_spec
right_inv m := by
have := h (m • i)|>.choose_spec
rw [← sub_eq_zero, ← sub_smul, ← addOrderOf_dvd_iff_zsmul_eq_zero,
Infinite.addOrderOf_eq_zero_of_forall_mem_zmultiples h] at this
simpa [sub_eq_zero] using this
Do we have this in mathlib?
Aaron Liu (Aug 12 2025 at 15:38):
you probably want to state that with docs#IsAddCyclic
Aaron Liu (Aug 12 2025 at 15:40):
you can get an equivalence with ZMod 0 by using docs#zmodAddCyclicAddEquiv and docs#Nat.card_eq_zero_of_infinite
Yakov Pechersky (Aug 12 2025 at 15:40):
docs#LinearOrderedAddCommGroup.int_orderAddMonoidIso_of_isLeast_pos and other things in that file
Aaron Liu (Aug 12 2025 at 15:41):
Yakov Pechersky said:
docs#LinearOrderedAddCommGroup.int_orderAddMonoidIso_of_isLeast_pos and other things in that file
It's not ordered
Yakov Pechersky (Aug 12 2025 at 15:43):
True, but it actually has one by the zpower necessary to hit reach it
Yakov Pechersky (Aug 12 2025 at 15:43):
And really the hypothesis is that closure {i} = \top
Aaron Liu (Aug 12 2025 at 15:44):
going from ZMod 0 to Int is surprisingly tricky but I think you can get there with docs#Int.quotientSpanNatEquivZMod, docs#Ideal.span_zero, docs#Ideal.quotEquivOfEq, docs#RingEquiv.quotientBot
Edison Xie (Aug 12 2025 at 15:44):
def ZModZero : ZMod 0 ≃+ ℤ := AddEquiv.refl _
I found that this would just work
Aaron Liu (Aug 12 2025 at 15:44):
yeah but that's defeq abuse
Aaron Liu (Aug 12 2025 at 15:45):
..probably
Edison Xie (Aug 12 2025 at 15:46):
isn't ZMod 0 literaly defined as Int? :joy:
Aaron Liu (Aug 12 2025 at 15:46):
yes
Kenny Lau (Aug 12 2025 at 16:47):
Aaron Liu said:
yeah but that's defeq abuse
what if you state it and use it, so it's no longer defeq abuse but the "canonical map"
Aaron Liu (Aug 12 2025 at 16:48):
it stops being defeq abuse once you start relying on it
Kenny Lau (Aug 12 2025 at 16:49):
Aaron Liu said:
you probably want to state that with docs#IsAddCyclic
the key difference here (as Buzzard would likely happily announce to you) is that there are actually two isomorphisms from A to Z, and it depends on the choice of the generator which is i here. If you use IsAddCyclic then you lose the freedom to depend on a generator.
Aaron Liu (Aug 12 2025 at 16:59):
then add DecidableEq A to make it computable too
Kenny Lau (Aug 12 2025 at 17:03):
i'm saying that you need to be able to feed in a generator in the input
Last updated: Dec 20 2025 at 21:32 UTC