l3lab/ntp-mathlib huggingface dataset:
@[to_additive]
theorem infinite_not_isOfFinOrder {x : G} (h : ¬IsOfFinOrder x) :
    { y : G | ¬IsOfFinOrder y }.Infinite := by
  let s := { n | 0 < n }.image fun n : ℕ => x ^ n
  have hs : s ⊆ { y : G | ¬IsOfFinOrder y } := by
    rintro - ⟨n, hn : 0 < n, rfl⟩ (contra : IsOfFinOrder (x ^ n))
    apply h
    rw [isOfFinOrder_iff_pow_eq_one] at contra ⊢
    obtain ⟨m, hm, hm'⟩ := contra
    exact ⟨n * m, mul_pos hn hm, by rwa [pow_mul]⟩
  suffices s.Infinite by exact this.mono hs
  contrapose! h
  have : ¬Injective fun n : ℕ => x ^ n := by
    

Proof state:
G : Type u_1
H : Type u_2
A : Type u_3
α : Type u_4
β : Type u_5
inst✝ : LeftCancelMonoid G
x✝ y a : G
m n : ℕ
x : G
s : Set G := (fun n => x ^ n) '' {n | 0 < n}
hs : s ⊆ {y | ¬IsOfFinOrder y}
h : ¬Set.Infinite s
⊢ ¬Injective fun n => x ^ n

Next tactic:
have := Set.not_injOn_infinite_finite_image (Set.Ioi_infinite 0) (Set.not_infinite.mp h)
@[to_additive]
theorem infinite_not_isOfFinOrder {x : G} (h : ¬IsOfFinOrder x) :
    { y : G | ¬IsOfFinOrder y }.Infinite := by
  let s := { n | 0 < n }.image fun n : ℕ => x ^ n
  have hs : s ⊆ { y : G | ¬IsOfFinOrder y } := by
    rintro - ⟨n, hn : 0 < n, rfl⟩ (contra : IsOfFinOrder (x ^ n))
    apply h
    rw [isOfFinOrder_iff_pow_eq_one] at contra ⊢
    obtain ⟨m, hm, hm'⟩ := contra
    exact ⟨n * m, mul_pos hn hm, by rwa [pow_mul]⟩
  suffices s.Infinite by exact this.mono hs
  contrapose! h
  have : ¬Injective fun n : ℕ => x ^ n := by
    have := Set.not_injOn_infinite_finite_image (Set.Ioi_infinite 0) (Set.not_infinite.mp h)
    

Proof state:
G : Type u_1
H : Type u_2
A : Type u_3
α : Type u_4
β : Type u_5
inst✝ : LeftCancelMonoid G
x✝ y a : G
m n : ℕ
x : G
s : Set G := (fun n => x ^ n) '' {n | 0 < n}
hs : s ⊆ {y | ¬IsOfFinOrder y}
h : ¬Set.Infinite s
this : ¬Set.InjOn (fun n => x ^ n) (Set.Ioi 0)
⊢ ¬Injective fun n => x ^ n

Next tactic:
contrapose! this
@[to_additive]
theorem infinite_not_isOfFinOrder {x : G} (h : ¬IsOfFinOrder x) :
    { y : G | ¬IsOfFinOrder y }.Infinite := by
  let s := { n | 0 < n }.image fun n : ℕ => x ^ n
  have hs : s ⊆ { y : G | ¬IsOfFinOrder y } := by
    rintro - ⟨n, hn : 0 < n, rfl⟩ (contra : IsOfFinOrder (x ^ n))
    apply h
    rw [isOfFinOrder_iff_pow_eq_one] at contra ⊢
    obtain ⟨m, hm, hm'⟩ := contra
    exact ⟨n * m, mul_pos hn hm, by rwa [pow_mul]⟩
  suffices s.Infinite by exact this.mono hs
  contrapose! h
  have : ¬Injective fun n : ℕ => x ^ n := by
    have := Set.not_injOn_infinite_finite_image (Set.Ioi_infinite 0) (Set.not_infinite.mp h)
    contrapose! this
    

Proof state:
G : Type u_1
H : Type u_2
A : Type u_3
α : Type u_4
β : Type u_5
inst✝ : LeftCancelMonoid G
x✝ y a : G
m n : ℕ
x : G
s : Set G := (fun n => x ^ n) '' {n | 0 < n}
hs : s ⊆ {y | ¬IsOfFinOrder y}
h : ¬Set.Infinite s
this : Injective fun n => x ^ n
⊢ Set.InjOn (fun n => x ^ n) (Set.Ioi 0)

Next tactic:
exact Set.injOn_of_injective this _
@[to_additive]
theorem infinite_not_isOfFinOrder {x : G} (h : ¬IsOfFinOrder x) :
    { y : G | ¬IsOfFinOrder y }.Infinite := by
  let s := { n | 0 < n }.image fun n : ℕ => x ^ n
  have hs : s ⊆ { y : G | ¬IsOfFinOrder y } := by
    rintro - ⟨n, hn : 0 < n, rfl⟩ (contra : IsOfFinOrder (x ^ n))
    apply h
    rw [isOfFinOrder_iff_pow_eq_one] at contra ⊢
    obtain ⟨m, hm, hm'⟩ := contra
    exact ⟨n * m, mul_pos hn hm, by rwa [pow_mul]⟩
  suffices s.Infinite by exact this.mono hs
  contrapose! h
  have : ¬Injective fun n : ℕ => x ^ n := by
    have := Set.not_injOn_infinite_finite_image (Set.Ioi_infinite 0) (Set.not_infinite.mp h)
    contrapose! this
    exact Set.injOn_of_injective this _
  

Proof state:
G : Type u_1
H : Type u_2
A : Type u_3
α : Type u_4
β : Type u_5
inst✝ : LeftCancelMonoid G
x✝ y a : G
m n : ℕ
x : G
s : Set G := (fun n => x ^ n) '' {n | 0 < n}
hs : s ⊆ {y | ¬IsOfFinOrder y}
h : ¬Set.Infinite s
this : ¬Injective fun n => x ^ n
⊢ IsOfFinOrder x

Next tactic:
rwa [injective_pow_iff_not_isOfFinOrder, Classical.not_not] at this
@[to_additive (attr := simp) finite_multiples]
lemma finite_powers : (powers a : Set G).Finite ↔ IsOfFinOrder a := by
  

Proof state:
G : Type u_1
H : Type u_2
A : Type u_3
α : Type u_4
β : Type u_5
inst✝ : LeftCancelMonoid G
x y a : G
m n : ℕ
⊢ Set.Finite ↑(powers a) ↔ IsOfFinOrder a

Next tactic:
refine ⟨fun h ↦ ?_, IsOfFinOrder.finite_powers⟩
@[to_additive (attr := simp) finite_multiples]
lemma finite_powers : (powers a : Set G).Finite ↔ IsOfFinOrder a := by
  refine ⟨fun h ↦ ?_, IsOfFinOrder.finite_powers⟩
  

Proof state:
G : Type u_1
H : Type u_2
A : Type u_3
α : Type u_4
β : Type u_5
inst✝ : LeftCancelMonoid G
x y a : G
m n : ℕ
h : Set.Finite ↑(powers a)
⊢ IsOfFinOrder a

Next tactic:
obtain ⟨m, n, hmn, ha⟩ := h.exists_lt_map_eq_of_forall_mem (f := fun n : ℕ ↦ a ^ n)
    (fun n ↦ by simp [mem_powers_iff])
@[to_additive (attr := simp) finite_multiples]
lemma finite_powers : (powers a : Set G).Finite ↔ IsOfFinOrder a := by
  refine ⟨fun h ↦ ?_, IsOfFinOrder.finite_powers⟩
  obtain ⟨m, n, hmn, ha⟩ := h.exists_lt_map_eq_of_forall_mem (f := fun n : ℕ ↦ a ^ n)
    (fun n ↦ by 

Proof state:
G : Type u_1
H : Type u_2
A : Type u_3
α : Type u_4
β : Type u_5
inst✝ : LeftCancelMonoid G
x y a : G
m n✝ : ℕ
h : Set.Finite ↑(powers a)
n : ℕ
⊢ (fun n => a ^ n) n ∈ ↑(powers a)

Next tactic:
simp [mem_powers_iff]
@[to_additive (attr := simp) finite_multiples]
lemma finite_powers : (powers a : Set G).Finite ↔ IsOfFinOrder a := by
  refine ⟨fun h ↦ ?_, IsOfFinOrder.finite_powers⟩
  obtain ⟨m, n, hmn, ha⟩ := h.exists_lt_map_eq_of_forall_mem (f := fun n : ℕ ↦ a ^ n)
    (fun n ↦ by simp [mem_powers_iff])
  

Proof state:
case intro.intro.intro
G : Type u_1
H : Type u_2
A : Type u_3
α : Type u_4
β : Type u_5
inst✝ : LeftCancelMonoid G
x y a : G
m✝ n✝ : ℕ
h : Set.Finite ↑(powers a)
m n : ℕ
hmn : m < n
ha : a ^ m = a ^ n
⊢ IsOfFinOrder a

Next tactic:
refine isOfFinOrder_iff_pow_eq_one.2 ⟨n - m, tsub_pos_iff_lt.2 hmn, ?_⟩
@[to_additive (attr := simp) finite_multiples]
lemma finite_powers : (powers a : Set G).Finite ↔ IsOfFinOrder a := by
  refine ⟨fun h ↦ ?_, IsOfFinOrder.finite_powers⟩
  obtain ⟨m, n, hmn, ha⟩ := h.exists_lt_map_eq_of_forall_mem (f := fun n : ℕ ↦ a ^ n)
    (fun n ↦ by simp [mem_powers_iff])
  refine isOfFinOrder_iff_pow_eq_one.2 ⟨n - m, tsub_pos_iff_lt.2 hmn, ?_⟩
  

Proof state:
case intro.intro.intro
G : Type u_1
H : Type u_2
A : Type u_3
α : Type u_4
β : Type u_5
inst✝ : LeftCancelMonoid G
x y a : G
m✝ n✝ : ℕ
h : Set.Finite ↑(powers a)
m n : ℕ
hmn : m < n
ha : a ^ m = a ^ n
⊢ a ^ (n - m) = 1

Next tactic:
rw [← mul_left_cancel_iff (a := a ^ m), ← pow_add, add_tsub_cancel_of_le hmn.le, ha, mul_one]
@[to_additive (attr := simp, nolint simpNF) finEquivMultiples_symm_apply]
lemma finEquivPowers_symm_apply (x : G) (hx) (n : ℕ) {hn : ∃ m : ℕ, x ^ m = x ^ n} :
    (finEquivPowers x hx).symm ⟨x ^ n, hn⟩ = ⟨n % orderOf x, Nat.mod_lt _ hx.orderOf_pos⟩ := by
  

Proof state:
G : Type u_1
H : Type u_2
A : Type u_3
α : Type u_4
β : Type u_5
inst✝ : LeftCancelMonoid G
x✝ y a : G
m n✝ : ℕ
x : G
hx : IsOfFinOrder x
n : ℕ
hn : ∃ m, x ^ m = x ^ n
⊢ (finEquivPowers x hx).symm { val := x ^ n, property := hn } =
    { val := n % orderOf x, isLt := (_ : n % orderOf x < orderOf x) }

Next tactic:
rw [Equiv.symm_apply_eq, finEquivPowers_apply, Subtype.mk_eq_mk, ← pow_mod_orderOf, Fin.val_mk]
/-- See also `orderOf_eq_card_powers`. -/
@[to_additive Nat.card_addSubmonoidMultiples "See also `addOrder_eq_card_multiples`."]
lemma Nat.card_submonoidPowers : Nat.card (powers a) = orderOf a := by
  

Proof state:
G : Type u_1
H : Type u_2
A : Type u_3
α : Type u_4
β : Type u_5
inst✝ : LeftCancelMonoid G
x y a : G
m n : ℕ
⊢ Nat.card ↥(powers a) = orderOf a

Next tactic:
classical
  by_cases ha : IsOfFinOrder a
  · exact (Nat.card_congr (finEquivPowers _ ha).symm).trans $ by simp
  · have := (infinite_powers.2 ha).to_subtype
    rw [orderOf_eq_zero ha, Nat.card_eq_zero_of_infinite]
/-- See also `orderOf_eq_card_powers`. -/
@[to_additive Nat.card_addSubmonoidMultiples "See also `addOrder_eq_card_multiples`."]
lemma Nat.card_submonoidPowers : Nat.card (powers a) = orderOf a := by
  classical
  

Proof state:
G : Type u_1
H : Type u_2
A : Type u_3
α : Type u_4
β : Type u_5
inst✝ : LeftCancelMonoid G
x y a : G
m n : ℕ
⊢ Nat.card ↥(powers a) = orderOf a

Next tactic:
by_cases ha : IsOfFinOrder a
/-- See also `orderOf_eq_card_powers`. -/
@[to_additive Nat.card_addSubmonoidMultiples "See also `addOrder_eq_card_multiples`."]
lemma Nat.card_submonoidPowers : Nat.card (powers a) = orderOf a := by
  classical
  by_cases ha : IsOfFinOrder a
  · 

Proof state:
case pos
G : Type u_1
H : Type u_2
A : Type u_3
α : Type u_4
β : Type u_5
inst✝ : LeftCancelMonoid G
x y a : G
m n : ℕ
ha : IsOfFinOrder a
⊢ Nat.card ↥(powers a) = orderOf a

Next tactic:
exact (Nat.card_congr (finEquivPowers _ ha).symm).trans $ by simp
/-- See also `orderOf_eq_card_powers`. -/
@[to_additive Nat.card_addSubmonoidMultiples "See also `addOrder_eq_card_multiples`."]
lemma Nat.card_submonoidPowers : Nat.card (powers a) = orderOf a := by
  classical
  by_cases ha : IsOfFinOrder a
  · exact (Nat.card_congr (finEquivPowers _ ha).symm).trans $ by 

Proof state:
G : Type u_1
H : Type u_2
A : Type u_3
α : Type u_4
β : Type u_5
inst✝ : LeftCancelMonoid G
x y a : G
m n : ℕ
ha : IsOfFinOrder a
⊢ Nat.card (Fin (orderOf a)) = orderOf a

Next tactic:
simp
/-- See also `orderOf_eq_card_powers`. -/
@[to_additive Nat.card_addSubmonoidMultiples "See also `addOrder_eq_card_multiples`."]
lemma Nat.card_submonoidPowers : Nat.card (powers a) = orderOf a := by
  classical
  by_cases ha : IsOfFinOrder a
  · exact (Nat.card_congr (finEquivPowers _ ha).symm).trans $ by simp
  · 

Proof state:
case neg
G : Type u_1
H : Type u_2
A : Type u_3
α : Type u_4
β : Type u_5
inst✝ : LeftCancelMonoid G
x y a : G
m n : ℕ
ha : ¬IsOfFinOrder a
⊢ Nat.card ↥(powers a) = orderOf a

Next tactic:
have := (infinite_powers.2 ha).to_subtype
/-- See also `orderOf_eq_card_powers`. -/
@[to_additive Nat.card_addSubmonoidMultiples "See also `addOrder_eq_card_multiples`."]
lemma Nat.card_submonoidPowers : Nat.card (powers a) = orderOf a := by
  classical
  by_cases ha : IsOfFinOrder a
  · exact (Nat.card_congr (finEquivPowers _ ha).symm).trans $ by simp
  · have := (infinite_powers.2 ha).to_subtype
    

Proof state:
case neg
G : Type u_1
H : Type u_2
A : Type u_3
α : Type u_4
β : Type u_5
inst✝ : LeftCancelMonoid G
x y a : G
m n : ℕ
ha : ¬IsOfFinOrder a
this : Infinite ↑↑(powers a)
⊢ Nat.card ↥(powers a) = orderOf a

Next tactic:
rw [orderOf_eq_zero ha, Nat.card_eq_zero_of_infinite]
/-- Inverses of elements of finite order have finite order. -/
@[to_additive (attr := simp) "Inverses of elements of finite additive order
have finite additive order."]
theorem isOfFinOrder_inv_iff {x : G} : IsOfFinOrder x⁻¹ ↔ IsOfFinOrder x := by
  

Proof state:
G : Type u_1
H : Type u_2
A : Type u_3
α : Type u_4
β : Type u_5
inst✝ : Group G
x✝ y : G
i : ℤ
x : G
⊢ IsOfFinOrder x⁻¹ ↔ IsOfFinOrder x

Next tactic:
simp [isOfFinOrder_iff_pow_eq_one]
@[to_additive]
theorem orderOf_dvd_iff_zpow_eq_one : (orderOf x : ℤ) ∣ i ↔ x ^ i = 1 := by
  

Proof state:
G : Type u_1
H : Type u_2
A : Type u_3
α : Type u_4
β : Type u_5
inst✝ : Group G
x y : G
i : ℤ
⊢ ↑(orderOf x) ∣ i ↔ x ^ i = 1

Next tactic:
rcases Int.eq_nat_or_neg i with ⟨i, rfl | rfl⟩
@[to_additive]
theorem orderOf_dvd_iff_zpow_eq_one : (orderOf x : ℤ) ∣ i ↔ x ^ i = 1 := by
  rcases Int.eq_nat_or_neg i with ⟨i, rfl | rfl⟩
  · 

Proof state:
case intro.inl
G : Type u_1
H : Type u_2
A : Type u_3
α : Type u_4
β : Type u_5
inst✝ : Group G
x y : G
i : ℕ
⊢ ↑(orderOf x) ∣ ↑i ↔ x ^ ↑i = 1

Next tactic:
rw [Int.coe_nat_dvd, orderOf_dvd_iff_pow_eq_one, zpow_ofNat]
@[to_additive]
theorem orderOf_dvd_iff_zpow_eq_one : (orderOf x : ℤ) ∣ i ↔ x ^ i = 1 := by
  rcases Int.eq_nat_or_neg i with ⟨i, rfl | rfl⟩
  · rw [Int.coe_nat_dvd, orderOf_dvd_iff_pow_eq_one, zpow_ofNat]
  · 

Proof state:
case intro.inr
G : Type u_1
H : Type u_2
A : Type u_3
α : Type u_4
β : Type u_5
inst✝ : Group G
x y : G
i : ℕ
⊢ ↑(orderOf x) ∣ -↑i ↔ x ^ (-↑i) = 1

Next tactic:
rw [dvd_neg, Int.coe_nat_dvd, zpow_neg, inv_eq_one, zpow_ofNat, orderOf_dvd_iff_pow_eq_one]
@[to_additive (attr := simp)]
theorem orderOf_inv (x : G) : orderOf x⁻¹ = orderOf x := by 

Proof state:
G : Type u_1
H : Type u_2
A : Type u_3
α : Type u_4
β : Type u_5
inst✝ : Group G
x✝ y : G
i : ℤ
x : G
⊢ orderOf x⁻¹ = orderOf x

Next tactic:
simp [orderOf_eq_orderOf_iff]
@[to_additive mod_addOrderOf_zsmul]
lemma zpow_mod_orderOf (x : G) (z : ℤ) : x ^ (z % (orderOf x : ℤ)) = x ^ z :=
  calc
    x ^ (z % (orderOf x : ℤ)) = x ^ (z % orderOf x + orderOf x * (z / orderOf x) : ℤ) := by
        

Proof state:
G : Type u_1
H : Type u_2
A : Type u_3
α : Type u_4
β : Type u_5
inst✝ : Group G
x✝ y : G
i : ℤ
x : G
z : ℤ
⊢ x ^ (z % ↑(orderOf x)) = x ^ (z % ↑(orderOf x) + ↑(orderOf x) * (z / ↑(orderOf x)))

Next tactic:
simp [zpow_add, zpow_mul, pow_orderOf_eq_one]
@[to_additive mod_addOrderOf_zsmul]
lemma zpow_mod_orderOf (x : G) (z : ℤ) : x ^ (z % (orderOf x : ℤ)) = x ^ z :=
  calc
    x ^ (z % (orderOf x : ℤ)) = x ^ (z % orderOf x + orderOf x * (z / orderOf x) : ℤ) := by
        simp [zpow_add, zpow_mul, pow_orderOf_eq_one]
    _ = x ^ z := by 

Proof state:
G : Type u_1
H : Type u_2
A : Type u_3
α : Type u_4
β : Type u_5
inst✝ : Group G
x✝ y : G
i : ℤ
x : G
z : ℤ
⊢ x ^ (z % ↑(orderOf x) + ↑(orderOf x) * (z / ↑(orderOf x))) = x ^ z

Next tactic:
rw [Int.emod_add_ediv]
@[to_additive (attr := simp) zsmul_smul_addOrderOf]
theorem zpow_pow_orderOf : (x ^ i) ^ orderOf x = 1 := by
  

Proof state:
G : Type u_1
H : Type u_2
A : Type u_3
α : Type u_4
β : Type u_5
inst✝ : Group G
x y : G
i : ℤ
⊢ (x ^ i) ^ orderOf x = 1

Next tactic:
by_cases h : IsOfFinOrder x
@[to_additive (attr := simp) zsmul_smul_addOrderOf]
theorem zpow_pow_orderOf : (x ^ i) ^ orderOf x = 1 := by
  by_cases h : IsOfFinOrder x
  · 

Proof state:
case pos
G : Type u_1
H : Type u_2
A : Type u_3
α : Type u_4
β : Type u_5
inst✝ : Group G
x y : G
i : ℤ
h : IsOfFinOrder x
⊢ (x ^ i) ^ orderOf x = 1

Next tactic:
rw [← zpow_ofNat, ← zpow_mul, mul_comm, zpow_mul, zpow_ofNat, pow_orderOf_eq_one, one_zpow]
@[to_additive (attr := simp) zsmul_smul_addOrderOf]
theorem zpow_pow_orderOf : (x ^ i) ^ orderOf x = 1 := by
  by_cases h : IsOfFinOrder x
  · rw [← zpow_ofNat, ← zpow_mul, mul_comm, zpow_mul, zpow_ofNat, pow_orderOf_eq_one, one_zpow]
  · 

Proof state:
case neg
G : Type u_1
H : Type u_2
A : Type u_3
α : Type u_4
β : Type u_5
inst✝ : Group G
x y : G
i : ℤ
h : ¬IsOfFinOrder x
⊢ (x ^ i) ^ orderOf x = 1

Next tactic:
rw [orderOf_eq_zero h, _root_.pow_zero]
@[to_additive IsOfFinAddOrder.of_mem_zmultiples]
theorem IsOfFinOrder.of_mem_zpowers (h : IsOfFinOrder x) (h' : y ∈ Subgroup.zpowers x) :
    IsOfFinOrder y := by
  

Proof state:
G : Type u_1
H : Type u_2
A : Type u_3
α : Type u_4
β : Type u_5
inst✝ : Group G
x y : G
i : ℤ
h : IsOfFinOrder x
h' : y ∈ zpowers x
⊢ IsOfFinOrder y

Next tactic:
obtain ⟨k, rfl⟩ := Subgroup.mem_zpowers_iff.mp h'
@[to_additive IsOfFinAddOrder.of_mem_zmultiples]
theorem IsOfFinOrder.of_mem_zpowers (h : IsOfFinOrder x) (h' : y ∈ Subgroup.zpowers x) :
    IsOfFinOrder y := by
  obtain ⟨k, rfl⟩ := Subgroup.mem_zpowers_iff.mp h'
  

Proof state:
case intro
G : Type u_1
H : Type u_2
A : Type u_3
α : Type u_4
β : Type u_5
inst✝ : Group G
x : G
i : ℤ
h : IsOfFinOrder x
k : ℤ
h' : x ^ k ∈ zpowers x
⊢ IsOfFinOrder (x ^ k)

Next tactic:
exact h.zpow
@[to_additive addOrderOf_dvd_of_mem_zmultiples]
theorem orderOf_dvd_of_mem_zpowers (h : y ∈ Subgroup.zpowers x) : orderOf y ∣ orderOf x := by
  

Proof state:
G : Type u_1
H : Type u_2
A : Type u_3
α : Type u_4
β : Type u_5
inst✝ : Group G
x y : G
i : ℤ
h : y ∈ zpowers x
⊢ orderOf y ∣ orderOf x

Next tactic:
obtain ⟨k, rfl⟩ := Subgroup.mem_zpowers_iff.mp h
@[to_additive addOrderOf_dvd_of_mem_zmultiples]
theorem orderOf_dvd_of_mem_zpowers (h : y ∈ Subgroup.zpowers x) : orderOf y ∣ orderOf x := by
  obtain ⟨k, rfl⟩ := Subgroup.mem_zpowers_iff.mp h
  

Proof state:
case intro
G : Type u_1
H : Type u_2
A : Type u_3
α : Type u_4
β : Type u_5
inst✝ : Group G
x : G
i k : ℤ
h : x ^ k ∈ zpowers x
⊢ orderOf (x ^ k) ∣ orderOf x

Next tactic:
rw [orderOf_dvd_iff_pow_eq_one]
@[to_additive addOrderOf_dvd_of_mem_zmultiples]
theorem orderOf_dvd_of_mem_zpowers (h : y ∈ Subgroup.zpowers x) : orderOf y ∣ orderOf x := by
  obtain ⟨k, rfl⟩ := Subgroup.mem_zpowers_iff.mp h
  rw [orderOf_dvd_iff_pow_eq_one]
  

Proof state:
case intro
G : Type u_1
H : Type u_2
A : Type u_3
α : Type u_4
β : Type u_5
inst✝ : Group G
x : G
i k : ℤ
h : x ^ k ∈ zpowers x
⊢ (x ^ k) ^ orderOf x = 1

Next tactic:
exact zpow_pow_orderOf
theorem smul_eq_self_of_mem_zpowers {α : Type*} [MulAction G α] (hx : x ∈ Subgroup.zpowers y)
    {a : α} (hs : y • a = a) : x • a = a := by
  

Proof state:
G : Type u_1
H : Type u_2
A : Type u_3
α✝ : Type u_4
β : Type u_5
inst✝¹ : Group G
x y : G
i : ℤ
α : Type u_6
inst✝ : MulAction G α
hx : x ∈ zpowers y
a : α
hs : y • a = a
⊢ x • a = a

Next tactic:
obtain ⟨k, rfl⟩ := Subgroup.mem_zpowers_iff.mp hx
theorem smul_eq_self_of_mem_zpowers {α : Type*} [MulAction G α] (hx : x ∈ Subgroup.zpowers y)
    {a : α} (hs : y • a = a) : x • a = a := by
  obtain ⟨k, rfl⟩ := Subgroup.mem_zpowers_iff.mp hx
  

Proof state:
case intro
G : Type u_1
H : Type u_2
A : Type u_3
α✝ : Type u_4
β : Type u_5
inst✝¹ : Group G
y : G
i : ℤ
α : Type u_6
inst✝ : MulAction G α
a : α
hs : y • a = a
k : ℤ
hx : y ^ k ∈ zpowers y
⊢ y ^ k • a = a

Next tactic:
rw [← MulAction.toPerm_apply, ← MulAction.toPermHom_apply, MonoidHom.map_zpow _ y k,
    MulAction.toPermHom_apply]
theorem smul_eq_self_of_mem_zpowers {α : Type*} [MulAction G α] (hx : x ∈ Subgroup.zpowers y)
    {a : α} (hs : y • a = a) : x • a = a := by
  obtain ⟨k, rfl⟩ := Subgroup.mem_zpowers_iff.mp hx
  rw [← MulAction.toPerm_apply, ← MulAction.toPermHom_apply, MonoidHom.map_zpow _ y k,
    MulAction.toPermHom_apply]
  

Proof state:
case intro
G : Type u_1
H : Type u_2
A : Type u_3
α✝ : Type u_4
β : Type u_5
inst✝¹ : Group G
y : G
i : ℤ
α : Type u_6
inst✝ : MulAction G α
a : α
hs : y • a = a
k : ℤ
hx : y ^ k ∈ zpowers y
⊢ (MulAction.toPerm y ^ k) a = a

Next tactic:
exact Function.IsFixedPt.perm_zpow (by exact hs) k
theorem smul_eq_self_of_mem_zpowers {α : Type*} [MulAction G α] (hx : x ∈ Subgroup.zpowers y)
    {a : α} (hs : y • a = a) : x • a = a := by
  obtain ⟨k, rfl⟩ := Subgroup.mem_zpowers_iff.mp hx
  rw [← MulAction.toPerm_apply, ← MulAction.toPermHom_apply, MonoidHom.map_zpow _ y k,
    MulAction.toPermHom_apply]
  exact Function.IsFixedPt.perm_zpow (by 

Proof state:
G : Type u_1
H : Type u_2
A : Type u_3
α✝ : Type u_4
β : Type u_5
inst✝¹ : Group G
y : G
i : ℤ
α : Type u_6
inst✝ : MulAction G α
a : α
hs : y • a = a
k : ℤ
hx : y ^ k ∈ zpowers y
⊢ IsFixedPt (⇑(MulAction.toPerm y)) a

Next tactic:
exact hs
@[to_additive IsOfFinAddOrder.mem_multiples_iff_mem_zmultiples]
lemma IsOfFinOrder.mem_powers_iff_mem_zpowers (hx : IsOfFinOrder x) :
    y ∈ powers x ↔ y ∈ zpowers x :=
  ⟨fun ⟨n, hn⟩ ↦ ⟨n, by 

Proof state:
G : Type u_1
H : Type u_2
A : Type u_3
α : Type u_4
β : Type u_5
inst✝ : Group G
x y : G
i : ℤ
hx : IsOfFinOrder x
x✝ : y ∈ powers x
n : ℕ
hn : (fun x_1 => x ^ x_1) n = y
⊢ (fun x_1 => x ^ x_1) ↑n = y

Next tactic:
simp_all
@[to_additive IsOfFinAddOrder.mem_multiples_iff_mem_zmultiples]
lemma IsOfFinOrder.mem_powers_iff_mem_zpowers (hx : IsOfFinOrder x) :
    y ∈ powers x ↔ y ∈ zpowers x :=
  ⟨fun ⟨n, hn⟩ ↦ ⟨n, by simp_all⟩, fun ⟨i, hi⟩ ↦ ⟨(i % orderOf x).natAbs, by
    

Proof state:
G : Type u_1
H : Type u_2
A : Type u_3
α : Type u_4
β : Type u_5
inst✝ : Group G
x y : G
i✝ : ℤ
hx : IsOfFinOrder x
x✝ : y ∈ zpowers x
i : ℤ
hi : (fun x_1 => x ^ x_1) i = y
⊢ (fun x_1 => x ^ x_1) (Int.natAbs (i % ↑(orderOf x))) = y

Next tactic:
dsimp only
@[to_additive IsOfFinAddOrder.mem_multiples_iff_mem_zmultiples]
lemma IsOfFinOrder.mem_powers_iff_mem_zpowers (hx : IsOfFinOrder x) :
    y ∈ powers x ↔ y ∈ zpowers x :=
  ⟨fun ⟨n, hn⟩ ↦ ⟨n, by simp_all⟩, fun ⟨i, hi⟩ ↦ ⟨(i % orderOf x).natAbs, by
    dsimp only
    

Proof state:
G : Type u_1
H : Type u_2
A : Type u_3
α : Type u_4
β : Type u_5
inst✝ : Group G
x y : G
i✝ : ℤ
hx : IsOfFinOrder x
x✝ : y ∈ zpowers x
i : ℤ
hi : (fun x_1 => x ^ x_1) i = y
⊢ x ^ Int.natAbs (i % ↑(orderOf x)) = y

Next tactic:
rwa [← zpow_ofNat, Int.natAbs_of_nonneg $ Int.emod_nonneg _ $ Int.coe_nat_ne_zero_iff_pos.2 $
      hx.orderOf_pos, zpow_mod_orderOf]
@[to_additive (attr := simp, nolint simpNF) finEquivZMultiples_symm_apply]
lemma finEquivZPowers_symm_apply (x : G) (hx) (n : ℕ) :
    (finEquivZPowers x hx).symm ⟨x ^ n, ⟨n, by 

Proof state:
G : Type u_1
H : Type u_2
A : Type u_3
α : Type u_4
β : Type u_5
inst✝ : Group G
x✝ y : G
i : ℤ
x : G
hx : IsOfFinOrder x
n : ℕ
⊢ (fun x_1 => x ^ x_1) ↑n = x ^ n

Next tactic:
simp
@[to_additive (attr := simp, nolint simpNF) finEquivZMultiples_symm_apply]
lemma finEquivZPowers_symm_apply (x : G) (hx) (n : ℕ) :
    (finEquivZPowers x hx).symm ⟨x ^ n, ⟨n, by simp⟩⟩ =
    ⟨n % orderOf x, Nat.mod_lt _ hx.orderOf_pos⟩ := by
  

Proof state:
G : Type u_1
H : Type u_2
A : Type u_3
α : Type u_4
β : Type u_5
inst✝ : Group G
x✝ y : G
i : ℤ
x : G
hx : IsOfFinOrder x
n : ℕ
⊢ (finEquivZPowers x hx).symm { val := x ^ n, property := (_ : ∃ y, (fun x_1 => x ^ x_1) y = x ^ n) } =
    { val := n % orderOf x, isLt := (_ : n % orderOf x < orderOf x) }

Next tactic:
rw [finEquivZPowers, Equiv.symm_trans_apply]
@[to_additive (attr := simp, nolint simpNF) finEquivZMultiples_symm_apply]
lemma finEquivZPowers_symm_apply (x : G) (hx) (n : ℕ) :
    (finEquivZPowers x hx).symm ⟨x ^ n, ⟨n, by simp⟩⟩ =
    ⟨n % orderOf x, Nat.mod_lt _ hx.orderOf_pos⟩ := by
  rw [finEquivZPowers, Equiv.symm_trans_apply]; 

Proof state:
G : Type u_1
H : Type u_2
A : Type u_3
α : Type u_4
β : Type u_5
inst✝ : Group G
x✝ y : G
i : ℤ
x : G
hx : IsOfFinOrder x
n : ℕ
⊢ (finEquivPowers x hx).symm
      ((Equiv.Set.ofEq (_ : ↑(powers x) = ↑(zpowers x))).symm
        { val := x ^ n, property := (_ : ∃ y, (fun x_1 => x ^ x_1) y = x ^ n) }) =
    { val := n % orderOf x, isLt := (_ : n % orderOf x < orderOf x) }

Next tactic:
exact finEquivPowers_symm_apply x _ n
@[to_additive]
theorem sum_card_orderOf_eq_card_pow_eq_one [Fintype G] [DecidableEq G] (hn : n ≠ 0) :
    (∑ m in (Finset.range n.succ).filter (· ∣ n),
        (Finset.univ.filter fun x : G => orderOf x = m).card) =
      (Finset.univ.filter fun x : G => x ^ n = 1).card :=
  calc
    (∑ m in (Finset.range n.succ).filter (· ∣ n),
          (Finset.univ.filter fun x : G => orderOf x = m).card) = _ :=
      (Finset.card_biUnion
          (by
            

Proof state:
G : Type u_1
H : Type u_2
A : Type u_3
α : Type u_4
β : Type u_5
inst✝² : Monoid G
x : G
n : ℕ
inst✝¹ : Fintype G
inst✝ : DecidableEq G
hn : n ≠ 0
⊢ ∀ x ∈ Finset.filter (fun x => x ∣ n) (Finset.range (succ n)),
    ∀ y ∈ Finset.filter (fun x => x ∣ n) (Finset.range (succ n)),
      x ≠ y →
        Disjoint (Finset.filter (fun x_1 => orderOf x_1 = x) Finset.univ)
          (Finset.filter (fun x => orderOf x = y) Finset.univ)

Next tactic:
intros
@[to_additive]
theorem sum_card_orderOf_eq_card_pow_eq_one [Fintype G] [DecidableEq G] (hn : n ≠ 0) :
    (∑ m in (Finset.range n.succ).filter (· ∣ n),
        (Finset.univ.filter fun x : G => orderOf x = m).card) =
      (Finset.univ.filter fun x : G => x ^ n = 1).card :=
  calc
    (∑ m in (Finset.range n.succ).filter (· ∣ n),
          (Finset.univ.filter fun x : G => orderOf x = m).card) = _ :=
      (Finset.card_biUnion
          (by
            intros
            

Proof state:
G : Type u_1
H : Type u_2
A : Type u_3
α : Type u_4
β : Type u_5
inst✝² : Monoid G
x : G
n : ℕ
inst✝¹ : Fintype G
inst✝ : DecidableEq G
hn : n ≠ 0
x✝ : ℕ
a✝² : x✝ ∈ Finset.filter (fun x => x ∣ n) (Finset.range (succ n))
y✝ : ℕ
a✝¹ : y✝ ∈ Finset.filter (fun x => x ∣ n) (Finset.range (succ n))
a✝ : x✝ ≠ y✝
⊢ Disjoint (Finset.filter (fun x => orderOf x = x✝) Finset.univ) (Finset.filter (fun x => orderOf x = y✝) Finset.univ)

Next tactic:
apply Finset.disjoint_filter.2