Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/Lean/Mathlib/Mathlib/RingTheory/ZMod/     Datei vom 15.10.2026 mit Größe 17 kB image not shown  

Quelle  UnitsCyclic.lean   Sprache: Lean

 

/-
Copyright (c) 2025 Antoine Chambert-Loir. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Antoine Chambert-Loir, Junyan Xu
-/

module

public import Mathlib.Algebra.Order.Star.Basic
public import Mathlib.Analysis.Normed.Ring.Lemmas
public import Mathlib.Data.ZMod.Units
public import Mathlib.FieldTheory.Finite.Basic
public import Mathlib.GroupTheory.Complement

import Mathlib.Data.Nat.Choose.Dvd

/-! # Cyclicity of the units of `ZMod n`

`ZMod.isCyclic_units_iff` : `(ZMod n)ˣ` is cyclic iff
one of the following mutually exclusive cases happens:
  - `n = 0` (then `ZMod 0 ≃+* ℤ` and the group of units is cyclic of order 2);
  - `n = 1`, `2` or `4`
  - `n` is a power `p ^ e` of an odd prime number, or twice such a power
    (with `1 ≤ e`).

The individual cases are proved by `inferInstance` and are
also directly provided by :

* `ZMod.isCyclic_units_zero`
* `ZMod.isCyclic_units_one`
* `ZMod.isCyclic_units_two`
* `ZMod.isCyclic_units_four`

The case of prime numbers is also an instance:

* `ZMod.isCyclic_units_prime`

* `ZMod.not_isCyclic_units_eight`: `(ZMod 8)ˣ` is not cyclic

* `ZMod.orderOf_one_add_mul_prime`: the order of `1 + a * p`
  modulo `p ^ (n + 1)` is `p ^ n` when `p` does not divide `a`.

* `ZMod.orderOf_five` : the order of `5` modulo `2 ^ (n + 2)` is `2 ^ n`.

* `ZMod.isCyclic_units_of_prime_pow` : the case of odd prime powers

* `ZMod.isCyclic_units_two_pow_iff` : `(ZMod (2 ^ n))ˣ` is cyclic iff `n ≤ 2`.

* `ZMod.isComplement'_zpowers_unitFive_neg_one` : the subgroups generated by `5` and by `-1` are
  complements in `(ZMod (2 ^ n))ˣ`.

* `ZMod.zpowers_mk_unitFive_eq_top` : the class of `5` generates the quotient of
  `(ZMod (2 ^ n))ˣ` by `⟨-1⟩`, which is thus cyclic
  (`ZMod.isCyclic_units_two_pow_quotient_neg_one`).

The proofs mostly follow [Ireland and Rosen,
  *A classical introduction to modern number theory*, chapter 4]
  [IrelandRosen1990].
-/


public section

open scoped Nat

namespace ZMod

section EasyCases

theorem isCyclic_units_zero :
    IsCyclic (ZMod 0)ˣ := inferInstance

theorem isCyclic_units_one :
    IsCyclic (ZMod 1)ˣ := inferInstance

theorem isCyclic_units_two :
    IsCyclic (ZMod 2)ˣ := inferInstance

theorem isCyclic_units_four :
    IsCyclic (ZMod 4)ˣ := by
  apply isCyclic_of_prime_card (p := 2)
  simp only [Nat.card_eq_fintype_card, card_units_eq_totient]
  decide

/-- The multiplicative group of `ZMod p` is cyclic. -/
theorem isCyclic_units_prime {p : ℕ} (hp : p.Prime) :
    IsCyclic (ZMod p)ˣ :=
  have : Fact (p.Prime) := ⟨hp⟩
  inferInstance

theorem not_isCyclic_units_eight :
    ¬ IsCyclic (ZMod 8)ˣ := by
  rw [IsCyclic.iff_exponent_eq_card, Nat.card_eq_fintype_card, card_units_eq_totient]
  have h : Monoid.exponent (ZMod 8)ˣ ∣ 2 := Monoid.exponent_dvd_of_forall_pow_eq_one (by decide)
  intro (h' : Monoid.exponent (ZMod 8)ˣ = 4)
  simp [h'] at h

end EasyCases

section Divisibility

variable {R : Type*} [CommSemiring R] {u v : R} {p : ℕ}

lemma exists_one_add_mul_pow_prime_eq
    (hp : p.Prime) (hvu : v ∣ u) (hpuv : p * u * v ∣ u ^ p) (x : R) :
    ∃ y, (1 + u * x) ^ p = 1 + p * u * (x + v * y) := by
  rw [add_comm, add_pow]
  rw [← Finset.add_sum_erase (a := 0) _ _ (by simp)]
  simp_rw [one_pow, pow_zero, Nat.choose_zero_right, Nat.cast_one, mul_one]
  rw [← Finset.add_sum_erase (a := 1) _ _ (by simp [hp.pos])]
  rw [← Finset.sum_erase_add (a := p) _ _ (by -- aesop works but is slow
      simp only [Finset.mem_erase]
      rw [← and_assoc, and_comm (a := ¬ _), ← Nat.two_le_iff]
      simp [hp.two_le])]
  obtain ⟨a, ha⟩ := hvu
  obtain ⟨b, hb⟩ := hpuv
  use a * x ^ 2 * ∑ i ∈ (((Finset.range (p + 1)).erase 0).erase 1).erase p,
    (u * x) ^ (i - 2) * (p.choose i / p : ℕ) + b * x ^ p
  rw [mul_add]
  congr 2
  · rw [Nat.choose_one_right]; ring
  simp only [mul_add, Finset.mul_sum]
  congr 1
  · congr! 1 with i hi
    simp only [Finset.mem_erase, ne_eq, Finset.mem_range] at hi
    have hi' : 2 ≤ i := by lia
    calc
      (u * x) ^ i * p.choose i =
        (u * x) ^ (2 + (i - 2)) * p.choose i := by rw [Nat.add_sub_of_le hi']
      _ = u ^ 2 * x ^ 2 * (u * x) ^ (i - 2) * p.choose i := by ring_nf
      _ = u ^ 2 * x ^ 2 * (u * x) ^ (i - 2) * (p * (p.choose i / p) : ℕ) := by
        rw [Nat.mul_div_cancel' (hp.dvd_choose_self hi.2.2.1 <| by lia)]
      _ = u ^ 2 * x ^ 2 * (u * x) ^ (i - 2) * p * (p.choose i / p : ℕ) := by
        simp only [Nat.cast_mul]; ring_nf
      _ = p * u * (v * (a * x ^ 2 * ((u * x) ^ (i - 2) * (p.choose i / p : ℕ)))) := by
        rw [ha]; ring
  · calc
      (u * x) ^ p * (p.choose p) = u ^ p * x ^ p := by simp [Nat.choose_self, mul_pow]
    _ = p * u * v * b * x ^ p := by rw [hb]
    _ = p * u * (v * (b * x ^ p)) := by ring_nf

lemma exists_one_add_mul_pow_prime_pow_eq {u v : R}
    (hp : p.Prime) (hvu : v ∣ u) (hpuv : p * u * v ∣ u ^ p) (x : R) (m : ℕ) :
    ∃ y, (1 + u * x) ^ (p ^ m) = 1 + p ^ m * u * (x + v * y) :=
  match m with
  | 0 => ⟨0, by simp⟩
  | m + 1 => by
    rw [pow_succ', pow_mul]
    obtain ⟨y, hy⟩ := exists_one_add_mul_pow_prime_eq hp hvu hpuv x
    rw [hy]
    obtain ⟨z, hz⟩ :=
      exists_one_add_mul_pow_prime_pow_eq (u := p * u) (v := p * v) hp
      (mul_dvd_mul_left _ hvu)
      (by
        rw [mul_pow]
        simp only [← mul_assoc]
        rw [mul_assoc, mul_assoc, ← mul_assoc u, mul_comm u]
        apply mul_dvd_mul _ hpuv
        rw [← pow_two]
        exact pow_dvd_pow _ hp.two_le)
      (x + v * y) m
    use y + p * z
    rw [hz]
    ring

end Divisibility

section PrimePow

theorem orderOf_one_add_mul_prime_pow {p : ℕ} (hp : p.Prime) (m : ℕ)
    (hpm : m + 2 ≤ p * m) (a : ℤ) (ha : ¬ (p : ℤ) ∣ a) (n : ℕ) :
    orderOf (1 + p ^ m * a : ZMod (p ^ (n + m))) = p ^ n := by
  have hm0 : m ≠ 0 := by
    rintro rfl
    simp at hpm
  match n with
  | 0 => rw [← Nat.cast_pow, zero_add m, ZMod.natCast_self]; simp
  | n + 1 =>
    have := Fact.mk hp
    have := exists_one_add_mul_pow_prime_pow_eq
      (R := ZMod (p ^ (n + 1 + m))) (u := p ^ m) (v := p) hp (dvd_pow_self _ hm0) ?_ a
    · apply orderOf_eq_prime_pow
      · obtain ⟨y, hy⟩ := this n
        rw [hy, ← pow_add, add_eq_left, mul_add, ← mul_assoc, ← pow_succ]
        simp_rw [add_right_comm n _ 1, ← Nat.cast_pow, ZMod.natCast_self, zero_mul, add_zero]
        rwa [← Int.cast_natCast, ← Int.cast_mul, ZMod.intCast_zmod_eq_zero_iff_dvd, add_right_comm,
          pow_succ, Nat.cast_mul, Int.mul_dvd_mul_iff_left (by simp [hp.ne_zero])]
      · obtain ⟨y, hy⟩ := this (n + 1)
        rw [hy, ← pow_add, ← Nat.cast_pow]
        simp
    · rw [← pow_succ', ← pow_succ, ← pow_mul, mul_comm]
      exact pow_dvd_pow _ hpm

theorem orderOf_one_add_mul_prime {p : ℕ} (hp : p.Prime) (hp2 : p ≠ 2) (a : ℤ)
    (ha : ¬ (p : ℤ) ∣ a) (n : ℕ) :
    orderOf (1 + p * a : ZMod (p ^ (n + 1))) = p ^ n := by
  convert orderOf_one_add_mul_prime_pow hp 1 _ a ha n using 1
  · rw [pow_one]
  · have := hp.two_le; lia

theorem orderOf_one_add_prime {p : ℕ} (hp : p.Prime) (hp2 : p ≠ 2) (n : ℕ) :
    orderOf (1 + p : ZMod (p ^ (n + 1))) = p ^ n := by
  convert orderOf_one_add_mul_prime hp hp2 1 _ n
  · simp
  · intro H
    apply hp.ne_one
    simpa using Int.eq_one_of_dvd_one (Int.natCast_nonneg p) H

/-- If `p` is an odd prime, then `(ZMod (p ^ n))ˣ` is cyclic for all n -/
theorem isCyclic_units_of_prime_pow (p : ℕ) (hp : p.Prime) (hp2 : p ≠ 2) (n : ℕ) :
    IsCyclic (ZMod (p ^ n))ˣ := by
  have := Fact.mk hp
  rcases n with _ | n
  · rw [pow_zero]; infer_instance
  -- We first consider the element `1 + p` of order `p ^ n`
  set a := (1 + p : ZMod (p ^ (n + 1))) with ha_def
  have ha : IsUnit a := by
    rw [ha_def, ← Nat.cast_one (R := ZMod _), ← Nat.cast_add, ZMod.isUnit_iff_coprime]
    apply Nat.Coprime.pow_right
    simp only [Nat.coprime_add_self_left, Nat.coprime_one_left_eq_true]
  have ha' : orderOf ha.unit = p ^ n := by
    rw [← orderOf_injective _ Units.coeHom_injective ha.unit, Units.coeHom_apply, IsUnit.unit_spec]
    exact orderOf_one_add_prime hp hp2 n
  -- We lift a primitive root of unity mod `p`, an adequate power of which has order `p - 1`.
  obtain ⟨c, hc⟩ := isCyclic_iff_exists_orderOf_eq_natCard.mp (isCyclic_units_prime hp)
  rw [Nat.card_eq_fintype_card, ZMod.card_units] at hc
  obtain ⟨(b : (ZMod (p ^ (n + 1)))ˣ), rfl⟩ :=
    ZMod.unitsMap_surjective (Dvd.intro_left (p ^ n) rfl) c
  have : p - 1 ∣ orderOf b := hc ▸ orderOf_map_dvd _ b
  let k := orderOf b / (p - 1)
  have : orderOf (b ^ k) = p - 1 := orderOf_pow_orderOf_div (orderOf_pos b).ne' this
  rw [isCyclic_iff_exists_orderOf_eq_natCard]
  -- The product of `ha.unit` and `b ^ k` has the required order
  use ha.unit * b ^ k
  rw [(Commute.all _ _).orderOf_mul_eq_mul_orderOf_of_coprime, this, Nat.card_eq_fintype_card,
    ZMod.card_units_eq_totient, Nat.totient_prime_pow_succ hp, ← ha']
  rw [ha', this]
  apply Nat.Coprime.pow_left
  rw [Nat.coprime_self_sub_right hp.pos]
  simp

theorem isCyclic_units_two_pow_iff (n : ℕ) :
    IsCyclic (ZMod (2 ^ n))ˣ ↔ n ≤ 2 := by
  match n with
  | 0 => simp [isCyclic_units_one]
  | 1 => simp [isCyclic_units_prime Nat.prime_two]
  | 2 => simp [isCyclic_units_four]
  | n + 3 =>
    simp only [Nat.reduceLeDiff, iff_false]
    intro H
    apply not_isCyclic_units_eight
    have h : 2 ^ 3 ∣ 2 ^ (n + 3) := pow_dvd_pow _ (by lia)
    exact isCyclic_of_surjective _ (unitsMap_surjective h)

lemma orderOf_one_add_four_mul (a : ℤ) (ha : Odd a) (n : ℕ) :
    orderOf (1 + 4 * a : ZMod (2 ^ (n + 2))) = 2 ^ n := by
  convert orderOf_one_add_mul_prime_pow Nat.prime_two 2 le_rfl a ?_ n using 1
  · norm_num
  · rwa [← Int.not_even_iff_odd, even_iff_two_dvd] at ha

theorem orderOf_five (n : ℕ) :
    orderOf (5 : ZMod (2 ^ (n + 2))) = 2 ^ n := by
  convert orderOf_one_add_four_mul 1 (by simp) n
  norm_num

end PrimePow

section Products

theorem isCyclic_units_four_mul_iff (n : ℕ) :
    IsCyclic (ZMod (4 * n))ˣ ↔ n = 0 ∨ n = 1 := by
  obtain rfl | hn0 := eq_or_ne n 0
  · simp [isCyclic_units_zero]
  obtain rfl | hn1 := eq_or_ne n 1
  · simp [isCyclic_units_four]
  refine iff_of_false ?_ (by simp [hn0, hn1])
  obtain ⟨n, rfl⟩ | h2n := em (2 ∣ n)
  · rw [← mul_assoc]
    have : NeZero n := ⟨by simpa using hn0⟩
    refine mt (fun _ ↦ ?_) not_isCyclic_units_eight
    exact isCyclic_of_surjective _ (ZMod.unitsMap_surjective (m := 4 * 2 * n) (dvd_mul_right 8 _))
  have : Nat.Coprime 4 n := (Nat.prime_two.coprime_iff_not_dvd.mpr h2n).pow_left 2
  rw [((Units.mapEquiv (chineseRemainder this).toMulEquiv).trans .prodUnits).isCyclic,
    Group.isCyclic_prod_iff]
  rintro ⟨-, -, h⟩
  have : NeZero n := ⟨hn0⟩
  have : Odd (φ n) := by simpa [show φ 4 = 2 from rfl] using h
  rw [Nat.odd_totient_iff] at this
  lia

theorem isCyclic_units_two_mul_iff_of_odd (n : ℕ) (hn : Odd n) :
    IsCyclic (ZMod (2 * n))ˣ ↔ IsCyclic (ZMod n)ˣ := by
  simp [((Units.mapEquiv (chineseRemainder <| Nat.coprime_two_left.mpr hn).toMulEquiv).trans
    .prodUnits).isCyclic, Group.isCyclic_prod_iff, isCyclic_units_two]

theorem not_isCyclic_units_of_mul_coprime (m n : ℕ)
    (hm : Odd m) (hm1 : m ≠ 1) (hn : Odd n) (hn1 : n ≠ 1) (hmn : m.Coprime n) :
    ¬ IsCyclic (ZMod (m * n))ˣ := by
  have _ : NeZero m := ⟨Nat.ne_of_odd_add hm⟩
  have _ : NeZero n := ⟨Nat.ne_of_odd_add hn⟩
  let e := (Units.mapEquiv (chineseRemainder hmn).toMulEquiv).trans .prodUnits
  rw [e.isCyclic, Group.isCyclic_prod_iff]
  rintro ⟨-, -, h⟩
  simp_rw [Nat.card_eq_fintype_card, card_units_eq_totient,
    Nat.totient_coprime_totient_iff, hm1, hn1, false_or] at h
  rcases h with (rfl | rfl)
  · simp [← Nat.not_even_iff_odd] at hm
  · simp [← Nat.not_even_iff_odd] at hn

theorem isCyclic_units_iff_of_odd {n : ℕ} (hn : Odd n) :
    IsCyclic (ZMod n)ˣ ↔ ∃ (p m : ℕ), p.Prime ∧ Odd p ∧ n = p ^ m := by
  have hn0 : n ≠ 0 := by rintro rfl; exact Nat.not_odd_zero hn
  obtain rfl | h1 := eq_or_ne n 1
  · simp_rw [isCyclic_units_one, true_iff]
    exact ⟨3, 0, Nat.prime_three, by simp [Nat.odd_iff], by rw [pow_zero]⟩
  have ⟨p, hp, dvd⟩ := n.exists_prime_and_dvd h1
  have odd := hn.of_dvd_nat dvd
  by_cases hnp : n = p ^ n.factorization p
  · exact hnp ▸ iff_of_true (isCyclic_units_of_prime_pow p hp (odd.ne_two_of_dvd_nat dvd_rfl) _)
      ⟨p, _, hp, odd, rfl⟩
  refine iff_of_false ?_ (mt ?_ hnp)
  · have := n.ordProj_dvd p
    rw [← Nat.mul_div_cancel' this]
    refine not_isCyclic_units_of_mul_coprime _ _ (hn.of_dvd_nat this) ?_
      (hn.of_dvd_nat (Nat.div_dvd_of_dvd this)) ?_ ((Nat.coprime_ordCompl hp hn0).pow_left ..)
    · simpa [(hp.factorization_pos_of_dvd hn0 dvd).ne'] using hp.ne_one
    · contrapose hnp
      conv_lhs => rw [← Nat.div_mul_cancel this, hnp, one_mul]
  rintro ⟨q, m, hq, -, rfl⟩
  cases (Nat.prime_dvd_prime_iff_eq hp hq).mp (hp.dvd_of_dvd_pow dvd)
  simp [hp.factorization_self] at hnp

end Products

/-- `(ZMod n)ˣ` is cyclic iff `n` is of the form
`0`, `1`, `2`, `4`, `p ^ m`, or `2 * p ^ m`,
where `p` is an odd prime and `1 ≤ m`. -/

theorem isCyclic_units_iff (n : ℕ) :
    IsCyclic (ZMod n)ˣ ↔ n = 0 ∨ n = 1 ∨ n = 2 ∨ n = 4 ∨
      ∃ (p m : ℕ), p.Prime ∧ Odd p ∧ 1 ≤ m ∧ (n = p ^ m ∨ n = 2 * p ^ m) := by
  by_cases h0 : n = 0
  · rw [h0]; simp [isCyclic_units_zero]
  by_cases h1 : n = 1
  · rw [h1]; simp [isCyclic_units_one]
  by_cases h2 : n = 2
  · rw [h2]; simp [isCyclic_units_two]
  by_cases h4 : n = 4
  · rw [h4]; simp [isCyclic_units_four]
  simp only [h0, h1, h2, h4, false_or, and_or_left, exists_or]
  rcases (n.even_or_odd).symm with hn | hn
  · rw [isCyclic_units_iff_of_odd hn, or_iff_left]
    · congr! with p m
      rw [and_iff_right_of_imp]
      rintro rfl
      contrapose! h1
      cases Nat.lt_one_iff.mp h1
      apply pow_zero
    · rintro ⟨p, m, -, -, -, rfl⟩
      simp [← Nat.not_even_iff_odd] at hn
  obtain ⟨n, rfl⟩ := hn.two_dvd
  rcases (n.even_or_odd).symm with hn | hn
  · rw [isCyclic_units_two_mul_iff_of_odd _ hn, isCyclic_units_iff_of_odd hn, or_iff_right]
    · congr! with p m
      rw [Nat.mul_left_cancel_iff zero_lt_two, and_iff_right_of_imp]
      rintro rfl
      contrapose! h2
      cases Nat.lt_one_iff.mp h2
      rw [pow_zero, mul_one]
    · rintro ⟨p, m, -, odd, -, eq⟩
      have := eq ▸ odd.pow
      simp [← Nat.not_even_iff_odd] at this
  obtain ⟨n, rfl⟩ := hn.two_dvd
  apply iff_of_false
  · rw [← mul_assoc, show 2 * 2 = 4 from rfl, isCyclic_units_four_mul_iff]
    lia
  grind

section TwoPow

/-- The unit `5` of `ZMod (2 ^ n)`. -/
def unitFive {n : ℕ} : (ZMod (2 ^ n))ˣ :=
  unitOfCoprime 5 <| by cases n <;> norm_num

/-- The value of `unitFive` is `5`. -/
@[simp]
theorem coe_unitFive {n : ℕ} : ((unitFive : (ZMod (2 ^ n))ˣ) : ZMod (2 ^ n)) = 5 := by rfl

/-- The unit `5` of `ZMod (2 ^ n)` is `1` when `n ≤ 2`. -/
theorem unitFive_eq_one {n : ℕ} (hn : n ≤ 2) :
    (unitFive : (ZMod (2 ^ n))ˣ) = 1 := by
  interval_cases n <;> decide

/-- The order of `unitFive` in `(ZMod (2 ^ n))ˣ` is `2 ^ (n - 2)`. -/
theorem orderOf_unitFive (n : ℕ) : orderOf (unitFive : (ZMod (2 ^ n))ˣ) = 2 ^ (n - 2) := by
  match n with
  | 0 | 1 => simp [unitFive_eq_one]
  | n + 2 => rw [← orderOf_units, coe_unitFive, orderOf_five, Nat.add_sub_cancel_right]

/-- The unit `5` of `ZMod (2 ^ n)` maps to the unit `5` of `ZMod (2 ^ m)`. -/
theorem unitsMap_unitFive {m n : ℕ} (h : 2 ^ m ∣ 2 ^ n) : unitsMap h unitFive = unitFive := by
  ext
  rw [unitsMap_def, Units.coe_map, MonoidHom.coe_ofClass, coe_unitFive, coe_unitFive, map_ofNat]

/-- The subgroups generated by `5` and by `-1` in `(ZMod (2 ^ n))ˣ` are disjoint. -/
theorem disjoint_zpowers_unitFive_neg_one (n : ℕ) :
    Disjoint (Subgroup.zpowers unitFive) (Subgroup.zpowers (-1 : (ZMod (2 ^ n))ˣ)) := by
  match n with
  | 0 | 1 => simp
  | n + 2 =>
    have : Nontrivial (ZMod 4) := ZMod.nontrivial_iff.mpr <| by norm_num
    refine Subgroup.disjoint_def.mpr ?_
    rintro x ⟨k, rfl⟩ ⟨l, hl⟩
    suffices Even l by simp [← hl, neg_one_zpow_eq_ite, ite_eq_left this]
    have := congr_arg (unitsMap (pow_dvd_pow 2 (Nat.le_add_left 2 n))) hl
    rw [map_zpow, map_zpow, unitsMap_unitFive, unitFive_eq_one le_rfl, one_zpow,
      ← orderOf_dvd_iff_zpow_eq_one, unitsMap_def, Units.map_neg_one, Units.orderOf_neg_one,
      ringChar_zmod_n] at this
    exact even_iff_two_dvd.mpr (mod_cast this)

/-- The subgroups generated by `5` and by `-1` are complements in `(ZMod (2 ^ n))ˣ`. -/
theorem isComplement'_zpowers_unitFive_neg_one (n : ℕ) :
    (Subgroup.zpowers unitFive).IsComplement'
      (Subgroup.zpowers (-1 : (ZMod (2 ^ n))ˣ)) := by
  refine Subgroup.isComplement'_of_card_mul_and_disjoint ?_ (disjoint_zpowers_unitFive_neg_one _)
  match n with
  | 0 => simp only [Nat.pow_zero, Nat.card_unique]
  | 1 =>
    have : Subsingleton (ZMod (2 ^ 1))ˣ := by
      rw [pow_one]
      infer_instance
    simp only [Nat.card_unique]
  | n + 2 =>
    have : Nontrivial (ZMod (2 ^ (n + 2))) := ZMod.nontrivial_iff.mpr (by grind)
    rw [Nat.card_zpowers, Nat.card_zpowers, orderOf_unitFive, Units.orderOf_neg_one,
      ringChar_zmod_n, ite_eq_right (by grind), Nat.card_eq_fintype_card, card_units_eq_totient,
      Nat.totient_prime_pow_succ Nat.prime_two, Nat.add_sub_cancel_right]
    ring

/-- The class of `5` generates the quotient of `(ZMod (2 ^ n))ˣ` by `⟨-1⟩`. -/
theorem zpowers_mk_unitFive_eq_top (n : ℕ) :
    Subgroup.zpowers (QuotientGroup.mk unitFive : (ZMod (2 ^ n))ˣ ⧸ Subgroup.zpowers (-1)) = ⊤ := by
  rw [← QuotientGroup.mk'_apply, ← MonoidHom.map_zpowers]
  apply Subgroup.comap_injective (QuotientGroup.mk'_surjective _)
  rw [QuotientGroup.comap_map_mk', sup_comm, (isComplement'_zpowers_unitFive_neg_one n).sup_eq_top,
    Subgroup.comap_top]

/-- The quotient of `(ZMod (2 ^ n))ˣ` by `⟨-1⟩` is cyclic. -/
instance isCyclic_units_two_pow_quotient_neg_one (n : ℕ) :
    IsCyclic ((ZMod (2 ^ n))ˣ ⧸ Subgroup.zpowers (-1)) :=
  isCyclic_iff_exists_zpowers_eq_top.mpr ⟨_, zpowers_mk_unitFive_eq_top n⟩

end TwoPow

end ZMod

Messung
CHZG
9210010097

¤ Dauer der Verarbeitung: 0.3 Sekunden  (vorverarbeitet am  2026-11-24) ¤

*© Formatika GbR, Deutschland