File: Mathlib/GroupTheory/SpecificGroups/Dihedral.lean

full_name: DihedralGroup.r
code: /-- For `n ≠ 0`, `DihedralGroup n` represents the symmetry group of the regular `n`-gon.
`r i` represents the rotations of the `n`-gon by `2πi/n`, and `sr i` represents the reflections of
the `n`-gon. `DihedralGroup 0` corresponds to the infinite dihedral group.
-/
inductive DihedralGroup (n : ℕ) : Type
  | r : ZMod n → DihedralGroup n
  | sr : ZMod n → DihedralGroup n
  deriving DecidableEq
goal: ZMod n → DihedralGroup n

full_name: DihedralGroup
code: /-- For `n ≠ 0`, `DihedralGroup n` represents the symmetry group of the regular `n`-gon.
`r i` represents the rotations of the `n`-gon by `2πi/n`, and `sr i` represents the reflections of
the `n`-gon. `DihedralGroup 0` corresponds to the infinite dihedral group.
-/
inductive DihedralGroup (n : ℕ) : Type
  | r : ZMod n → DihedralGroup n
  | sr : ZMod n → DihedralGroup n
  deriving DecidableEq
goal: Type

full_name: DihedralGroup.sr
code: /-- For `n ≠ 0`, `DihedralGroup n` represents the symmetry group of the regular `n`-gon.
`r i` represents the rotations of the `n`-gon by `2πi/n`, and `sr i` represents the reflections of
the `n`-gon. `DihedralGroup 0` corresponds to the infinite dihedral group.
-/
inductive DihedralGroup (n : ℕ) : Type
  | r : ZMod n → DihedralGroup n
  | sr : ZMod n → DihedralGroup n
  deriving DecidableEq
goal: ZMod n → DihedralGroup n

full_name: _private.Mathlib.GroupTheory.SpecificGroups.Dihedral.0.DihedralGroup.mul
code: /-- Multiplication of the dihedral group.
-/
private def mul : DihedralGroup n → DihedralGroup n → DihedralGroup n
  
goal: DihedralGroup n → DihedralGroup n → DihedralGroup n

full_name: _private.Mathlib.GroupTheory.SpecificGroups.Dihedral.0.DihedralGroup.one
code: /-- The identity `1` is the rotation by `0`.
-/
private def one : DihedralGroup n 
goal: DihedralGroup n

full_name: DihedralGroup.instInhabited
code: instance : Inhabited (DihedralGroup n) 
goal: Inhabited (DihedralGroup n)

full_name: _private.Mathlib.GroupTheory.SpecificGroups.Dihedral.0.DihedralGroup.inv
code: /-- The inverse of an element of the dihedral group.
-/
private def inv : DihedralGroup n → DihedralGroup n
  
goal: DihedralGroup n → DihedralGroup n

full_name: DihedralGroup.instGroup
code: /-- The group structure on `DihedralGroup n`.
-/
instance : Group (DihedralGroup n) 
goal: Group (DihedralGroup n)

full_name: DihedralGroup.r_mul_r
code: @[simp]
theorem r_mul_r (i j : ZMod n) : r i * r j = r (i + j) 
goal: DihedralGroup.r i * DihedralGroup.r j = DihedralGroup.r (i + j)

full_name: DihedralGroup.r_mul_sr
code: @[simp]
theorem r_mul_sr (i j : ZMod n) : r i * sr j = sr (j - i) 
goal: DihedralGroup.r i * DihedralGroup.sr j = DihedralGroup.sr (j - i)

full_name: DihedralGroup.sr_mul_r
code: @[simp]
theorem sr_mul_r (i j : ZMod n) : sr i * r j = sr (i + j) 
goal: DihedralGroup.sr i * DihedralGroup.r j = DihedralGroup.sr (i + j)

full_name: DihedralGroup.sr_mul_sr
code: @[simp]
theorem sr_mul_sr (i j : ZMod n) : sr i * sr j = r (j - i) 
goal: DihedralGroup.sr i * DihedralGroup.sr j = DihedralGroup.r (j - i)

full_name: DihedralGroup.one_def
code: theorem one_def : (1 : DihedralGroup n) = r 0 
goal: 1 = DihedralGroup.r 0

full_name: _private.Mathlib.GroupTheory.SpecificGroups.Dihedral.0.DihedralGroup.fintypeHelper
code: private def fintypeHelper : (ZMod n) ⊕ (ZMod n) ≃ DihedralGroup n 
goal: ZMod n ⊕ ZMod n ≃ DihedralGroup n

full_name: DihedralGroup.instFintypeOfNeZeroNat
code: /-- If `0 < n`, then `DihedralGroup n` is a finite group.
-/
instance [NeZero n] : Fintype (DihedralGroup n) 
goal: Fintype (DihedralGroup n)

full_name: DihedralGroup.instInfiniteOfNatNat
code: instance : Infinite (DihedralGroup 0) 
goal: Infinite (DihedralGroup 0)

full_name: DihedralGroup.instNontrivial
code: instance : Nontrivial (DihedralGroup n) 
goal: Nontrivial (DihedralGroup n)

full_name: DihedralGroup.card
code: /-- If `0 < n`, then `DihedralGroup n` has `2n` elements.
-/
theorem card [NeZero n] : Fintype.card (DihedralGroup n) = 2 * n 
goal: Fintype.card (DihedralGroup n) = 2 * n

full_name: DihedralGroup.nat_card
code: theorem nat_card : Nat.card (DihedralGroup n) = 2 * n 
goal: Nat.card (DihedralGroup n) = 2 * n

full_name: DihedralGroup.r_one_pow
code: @[simp]
theorem r_one_pow (k : ℕ) : (r 1 : DihedralGroup n) ^ k = r k 
goal: DihedralGroup.r 1 ^ k = DihedralGroup.r ↑k

full_name: DihedralGroup.r_one_pow_n
code: theorem r_one_pow_n : r (1 : ZMod n) ^ n = 1 
goal: DihedralGroup.r 1 ^ n = 1

full_name: DihedralGroup.sr_mul_self
code: theorem sr_mul_self (i : ZMod n) : sr i * sr i = 1 
goal: DihedralGroup.sr i * DihedralGroup.sr i = 1

full_name: DihedralGroup.orderOf_sr
code: /-- If `0 < n`, then `sr i` has order 2.
-/
@[simp]
theorem orderOf_sr (i : ZMod n) : orderOf (sr i) = 2 
goal: orderOf (DihedralGroup.sr i) = 2

full_name: DihedralGroup.orderOf_r_one
code: /-- If `0 < n`, then `r 1` has order `n`.
-/
@[simp]
theorem orderOf_r_one : orderOf (r 1 : DihedralGroup n) = n 
goal: orderOf (DihedralGroup.r 1) = n

full_name: DihedralGroup.orderOf_r
code: /-- If `0 < n`, then `i : ZMod n` has order `n / gcd n i`.
-/
theorem orderOf_r [NeZero n] (i : ZMod n) : orderOf (r i) = n / Nat.gcd n i.val 
goal: orderOf (DihedralGroup.r i) = n / n.gcd i.val

full_name: DihedralGroup.exponent
code: theorem exponent : Monoid.exponent (DihedralGroup n) = lcm n 2 
goal: Monoid.exponent (DihedralGroup n) = lcm n 2

full_name: DihedralGroup.OddCommuteEquiv
code: /-- If n is odd, then the Dihedral group of order $2n$ has $n(n+3)$ pairs (represented as
$n + n + n + n*n$) of commuting elements. -/
@[simps]
def OddCommuteEquiv (hn : Odd n) : { p : DihedralGroup n × DihedralGroup n // Commute p.1 p.2 } ≃
    ZMod n ⊕ ZMod n ⊕ ZMod n ⊕ ZMod n × ZMod n 
goal: { p // Commute p.1 p.2 } ≃ ZMod n ⊕ ZMod n ⊕ ZMod n ⊕ ZMod n × ZMod n

full_name: DihedralGroup.OddCommuteEquiv_apply
code: /-- If n is odd, then the Dihedral group of order $2n$ has $n(n+3)$ pairs (represented as
$n + n + n + n*n$) of commuting elements. -/
@[simps]
def OddCommuteEquiv (hn : Odd n) : { p : DihedralGroup n × DihedralGroup n // Commute p.1 p.2 } ≃
    ZMod n ⊕ ZMod n ⊕ ZMod n ⊕ ZMod n × ZMod n 
goal: ∀ (x : { p // Commute p.1 p.2 }),
  (DihedralGroup.OddCommuteEquiv hn) x =
    match x with
    | ⟨(DihedralGroup.sr i, DihedralGroup.r a), property⟩ => Sum.inl i
    | ⟨(DihedralGroup.r a, DihedralGroup.sr j), property⟩ => Sum.inr (Sum.inl j)
    | ⟨(DihedralGroup.sr i, DihedralGroup.sr j), property⟩ => Sum.inr (Sum.inr (Sum.inl (i + j)))
    | ⟨(DihedralGroup.r i, DihedralGroup.r j), property⟩ => Sum.inr (Sum.inr (Sum.inr (i, j)))

full_name: DihedralGroup.OddCommuteEquiv_symm_apply
code: /-- If n is odd, then the Dihedral group of order $2n$ has $n(n+3)$ pairs (represented as
$n + n + n + n*n$) of commuting elements. -/
@[simps]
def OddCommuteEquiv (hn : Odd n) : { p : DihedralGroup n × DihedralGroup n // Commute p.1 p.2 } ≃
    ZMod n ⊕ ZMod n ⊕ ZMod n ⊕ ZMod n × ZMod n 
goal: ∀ (x : ZMod n ⊕ ZMod n ⊕ ZMod n ⊕ ZMod n × ZMod n),
  (DihedralGroup.OddCommuteEquiv hn).symm x =
    match x with
    | Sum.inl i => ⟨(DihedralGroup.sr i, DihedralGroup.r 0), ⋯⟩
    | Sum.inr (Sum.inl j) => ⟨(DihedralGroup.r 0, DihedralGroup.sr j), ⋯⟩
    | Sum.inr (Sum.inr (Sum.inl k)) =>
      ⟨(DihedralGroup.sr (↑(ZMod.unitOfCoprime 2 ⋯)⁻¹ * k), DihedralGroup.sr (↑(ZMod.unitOfCoprime 2 ⋯)⁻¹ * k)), ⋯⟩
    | Sum.inr (Sum.inr (Sum.inr (i, j))) => ⟨(DihedralGroup.r i, DihedralGroup.r j), ⋯⟩

full_name: DihedralGroup.card_commute_odd
code: /-- If n is odd, then the Dihedral group of order $2n$ has $n(n+3)$ pairs of commuting elements. -/
lemma card_commute_odd (hn : Odd n) :
    Nat.card { p : DihedralGroup n × DihedralGroup n // Commute p.1 p.2 } = n * (n + 3) 
goal: Nat.card { p // Commute p.1 p.2 } = n * (n + 3)

full_name: DihedralGroup.card_conjClasses_odd
code: lemma card_conjClasses_odd (hn : Odd n) :
    Nat.card (ConjClasses (DihedralGroup n)) = (n + 3) / 2 
goal: Nat.card (ConjClasses (DihedralGroup n)) = (n + 3) / 2