l3lab/ntp-mathlib huggingface dataset:
@[to_additive]
theorem orderOf_dvd_card : orderOf x ∣ Fintype.card G := by
  classical
    have ft_prod : Fintype ((G ⧸ zpowers x) × zpowers x) :=
      Fintype.ofEquiv G groupEquivQuotientProdSubgroup
    have ft_s : Fintype (zpowers x) := @Fintype.prodRight _ _ _ ft_prod _
    have ft_cosets : Fintype (G ⧸ zpowers x) :=
      @Fintype.prodLeft _ _ _ ft_prod ⟨⟨1, (zpowers x).one_mem⟩⟩
    have eq₁ : Fintype.card G = @Fintype.card _ ft_cosets * @Fintype.card _ ft_s :=
      calc
        Fintype.card G = @Fintype.card _ ft_prod :=
          @Fintype.card_congr _ _ _ ft_prod groupEquivQuotientProdSubgroup
        _ = @Fintype.card _ (@instFintypeProd _ _ ft_cosets ft_s) :=
          congr_arg (@Fintype.card _) <| Subsingleton.elim _ _
        _ = @Fintype.card _ ft_cosets * @Fintype.card _ ft_s :=
          @Fintype.card_prod _ _ ft_cosets ft_s

    have eq₂ : orderOf x = @Fintype.card _ ft_s :=
      calc
        orderOf x = _ := Fintype.card_zpowers.symm
        _ = _ := congr_arg (@Fintype.card _) <| Subsingleton.elim _ _

    

Proof state:
G : Type u_1
H : Type u_2
A : Type u_3
α : Type u_4
β : Type u_5
inst✝¹ : Group G
inst✝ : Fintype G
x : G
n : ℕ
ft_prod : Fintype ((G ⧸ zpowers x) × ↥(zpowers x))
ft_s : Fintype ↥(zpowers x)
ft_cosets : Fintype (G ⧸ zpowers x)
eq₁ : Fintype.card G = Fintype.card (G ⧸ zpowers x) * Fintype.card ↥(zpowers x)
eq₂ : orderOf x = Fintype.card ↥(zpowers x)
⊢ orderOf x ∣ Fintype.card G

Next tactic:
exact Dvd.intro (@Fintype.card (G ⧸ Subgroup.zpowers x) ft_cosets) (by rw [eq₁, eq₂, mul_comm])
@[to_additive]
theorem orderOf_dvd_card : orderOf x ∣ Fintype.card G := by
  classical
    have ft_prod : Fintype ((G ⧸ zpowers x) × zpowers x) :=
      Fintype.ofEquiv G groupEquivQuotientProdSubgroup
    have ft_s : Fintype (zpowers x) := @Fintype.prodRight _ _ _ ft_prod _
    have ft_cosets : Fintype (G ⧸ zpowers x) :=
      @Fintype.prodLeft _ _ _ ft_prod ⟨⟨1, (zpowers x).one_mem⟩⟩
    have eq₁ : Fintype.card G = @Fintype.card _ ft_cosets * @Fintype.card _ ft_s :=
      calc
        Fintype.card G = @Fintype.card _ ft_prod :=
          @Fintype.card_congr _ _ _ ft_prod groupEquivQuotientProdSubgroup
        _ = @Fintype.card _ (@instFintypeProd _ _ ft_cosets ft_s) :=
          congr_arg (@Fintype.card _) <| Subsingleton.elim _ _
        _ = @Fintype.card _ ft_cosets * @Fintype.card _ ft_s :=
          @Fintype.card_prod _ _ ft_cosets ft_s

    have eq₂ : orderOf x = @Fintype.card _ ft_s :=
      calc
        orderOf x = _ := Fintype.card_zpowers.symm
        _ = _ := congr_arg (@Fintype.card _) <| Subsingleton.elim _ _

    exact Dvd.intro (@Fintype.card (G ⧸ Subgroup.zpowers x) ft_cosets) (by 

Proof state:
G : Type u_1
H : Type u_2
A : Type u_3
α : Type u_4
β : Type u_5
inst✝¹ : Group G
inst✝ : Fintype G
x : G
n : ℕ
ft_prod : Fintype ((G ⧸ zpowers x) × ↥(zpowers x))
ft_s : Fintype ↥(zpowers x)
ft_cosets : Fintype (G ⧸ zpowers x)
eq₁ : Fintype.card G = Fintype.card (G ⧸ zpowers x) * Fintype.card ↥(zpowers x)
eq₂ : orderOf x = Fintype.card ↥(zpowers x)
⊢ orderOf x * Fintype.card (G ⧸ zpowers x) = Fintype.card G

Next tactic:
rw [eq₁, eq₂, mul_comm]
@[to_additive]
theorem orderOf_dvd_natCard {G : Type*} [Group G] (x : G) : orderOf x ∣ Nat.card G := by
  

Proof state:
G✝ : Type u_1
H : Type u_2
A : Type u_3
α : Type u_4
β : Type u_5
inst✝² : Group G✝
inst✝¹ : Fintype G✝
x✝ : G✝
n : ℕ
G : Type u_6
inst✝ : Group G
x : G
⊢ orderOf x ∣ Nat.card G

Next tactic:
cases' fintypeOrInfinite G with h h
@[to_additive]
theorem orderOf_dvd_natCard {G : Type*} [Group G] (x : G) : orderOf x ∣ Nat.card G := by
  cases' fintypeOrInfinite G with h h
  · 

Proof state:
case inl
G✝ : Type u_1
H : Type u_2
A : Type u_3
α : Type u_4
β : Type u_5
inst✝² : Group G✝
inst✝¹ : Fintype G✝
x✝ : G✝
n : ℕ
G : Type u_6
inst✝ : Group G
x : G
h : Fintype G
⊢ orderOf x ∣ Nat.card G

Next tactic:
simp only [Nat.card_eq_fintype_card, orderOf_dvd_card]
@[to_additive]
theorem orderOf_dvd_natCard {G : Type*} [Group G] (x : G) : orderOf x ∣ Nat.card G := by
  cases' fintypeOrInfinite G with h h
  · simp only [Nat.card_eq_fintype_card, orderOf_dvd_card]
  · 

Proof state:
case inr
G✝ : Type u_1
H : Type u_2
A : Type u_3
α : Type u_4
β : Type u_5
inst✝² : Group G✝
inst✝¹ : Fintype G✝
x✝ : G✝
n : ℕ
G : Type u_6
inst✝ : Group G
x : G
h : Infinite G
⊢ orderOf x ∣ Nat.card G

Next tactic:
simp only [card_eq_zero_of_infinite, dvd_zero]
@[to_additive]
nonrec lemma Subgroup.orderOf_dvd_natCard (s : Subgroup G) (hx : x ∈ s) :
  orderOf x ∣ Nat.card s := by 

Proof state:
G : Type u_1
H : Type u_2
A : Type u_3
α : Type u_4
β : Type u_5
inst✝¹ : Group G
inst✝ : Fintype G
x : G
n : ℕ
s : Subgroup G
hx : x ∈ s
⊢ orderOf x ∣ Nat.card ↥s

Next tactic:
simpa using orderOf_dvd_natCard (⟨x, hx⟩ : s)
@[to_additive]
lemma Submonoid.orderOf_le_card (s : Submonoid G) (hs : (s : Set G).Finite) (hx : x ∈ s) :
    orderOf x ≤ Nat.card s := by
  

Proof state:
G : Type u_1
H : Type u_2
A : Type u_3
α : Type u_4
β : Type u_5
inst✝¹ : Group G
inst✝ : Fintype G
x : G
n : ℕ
s : Submonoid G
hs : Set.Finite ↑s
hx : x ∈ s
⊢ orderOf x ≤ Nat.card ↥s

Next tactic:
rw [← Nat.card_submonoidPowers]
@[to_additive]
lemma Submonoid.orderOf_le_card (s : Submonoid G) (hs : (s : Set G).Finite) (hx : x ∈ s) :
    orderOf x ≤ Nat.card s := by
  rw [← Nat.card_submonoidPowers]; 

Proof state:
G : Type u_1
H : Type u_2
A : Type u_3
α : Type u_4
β : Type u_5
inst✝¹ : Group G
inst✝ : Fintype G
x : G
n : ℕ
s : Submonoid G
hs : Set.Finite ↑s
hx : x ∈ s
⊢ Nat.card ↥(powers x) ≤ Nat.card ↥s

Next tactic:
exact Nat.card_mono hs $ powers_le.2 hx
@[to_additive (attr := simp) card_nsmul_eq_zero]
theorem pow_card_eq_one : x ^ Fintype.card G = 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
inst✝ : Fintype G
x : G
n : ℕ
⊢ x ^ Fintype.card G = 1

Next tactic:
rw [← Nat.card_eq_fintype_card, pow_card_eq_one']
@[to_additive]
theorem Subgroup.pow_index_mem {G : Type*} [Group G] (H : Subgroup G) [Normal H] (g : G) :
    g ^ index H ∈ H := by 

Proof state:
G✝ : Type u_1
H✝ : Type u_2
A : Type u_3
α : Type u_4
β : Type u_5
inst✝³ : Group G✝
inst✝² : Fintype G✝
x : G✝
n : ℕ
G : Type u_6
inst✝¹ : Group G
H : Subgroup G
inst✝ : Normal H
g : G
⊢ g ^ index H ∈ H

Next tactic:
rw [← eq_one_iff, QuotientGroup.mk_pow H, index, pow_card_eq_one']
@[to_additive]
theorem pow_eq_mod_card (n : ℕ) : x ^ n = x ^ (n % Fintype.card G) := by
  

Proof state:
G : Type u_1
H : Type u_2
A : Type u_3
α : Type u_4
β : Type u_5
inst✝¹ : Group G
inst✝ : Fintype G
x : G
n✝ n : ℕ
⊢ x ^ n = x ^ (n % Fintype.card G)

Next tactic:
rw [← pow_mod_orderOf, ← Nat.mod_mod_of_dvd n orderOf_dvd_card, pow_mod_orderOf]
@[to_additive]
theorem zpow_eq_mod_card (n : ℤ) : x ^ n = x ^ (n % Fintype.card G : ℤ) := by
  

Proof state:
G : Type u_1
H : Type u_2
A : Type u_3
α : Type u_4
β : Type u_5
inst✝¹ : Group G
inst✝ : Fintype G
x : G
n✝ : ℕ
n : ℤ
⊢ x ^ n = x ^ (n % ↑(Fintype.card G))

Next tactic:
rw [← zpow_mod_orderOf, ← Int.emod_emod_of_dvd n (Int.coe_nat_dvd.2 orderOf_dvd_card),
    zpow_mod_orderOf]
/-- If `gcd(|G|,n)=1` then the `n`th power map is a bijection -/
@[to_additive (attr := simps) "If `gcd(|G|,n)=1` then the smul by `n` is a bijection"]
noncomputable def powCoprime {G : Type*} [Group G] (h : (Nat.card G).Coprime n) : G ≃ G
    where
  toFun g := g ^ n
  invFun g := g ^ (Nat.card G).gcdB n
  left_inv g := by
    

Proof state:
G✝ : Type u_1
H : Type u_2
A : Type u_3
α : Type u_4
β : Type u_5
inst✝² : Group G✝
inst✝¹ : Fintype G✝
x : G✝
n : ℕ
G : Type u_6
inst✝ : Group G
h : Coprime (Nat.card G) n
g : G
⊢ (fun g => g ^ gcdB (Nat.card G) n) ((fun g => g ^ n) g) = g

Next tactic:
have key := congr_arg (g ^ ·) ((Nat.card G).gcd_eq_gcd_ab n)
/-- If `gcd(|G|,n)=1` then the `n`th power map is a bijection -/
@[to_additive (attr := simps) "If `gcd(|G|,n)=1` then the smul by `n` is a bijection"]
noncomputable def powCoprime {G : Type*} [Group G] (h : (Nat.card G).Coprime n) : G ≃ G
    where
  toFun g := g ^ n
  invFun g := g ^ (Nat.card G).gcdB n
  left_inv g := by
    have key := congr_arg (g ^ ·) ((Nat.card G).gcd_eq_gcd_ab n)
    

Proof state:
G✝ : Type u_1
H : Type u_2
A : Type u_3
α : Type u_4
β : Type u_5
inst✝² : Group G✝
inst✝¹ : Fintype G✝
x : G✝
n : ℕ
G : Type u_6
inst✝ : Group G
h : Coprime (Nat.card G) n
g : G
key :
  (fun x => g ^ x) ↑(gcd (Nat.card G) n) =
    (fun x => g ^ x) (↑(Nat.card G) * gcdA (Nat.card G) n + ↑n * gcdB (Nat.card G) n)
⊢ (fun g => g ^ gcdB (Nat.card G) n) ((fun g => g ^ n) g) = g

Next tactic:
dsimp only at key
/-- If `gcd(|G|,n)=1` then the `n`th power map is a bijection -/
@[to_additive (attr := simps) "If `gcd(|G|,n)=1` then the smul by `n` is a bijection"]
noncomputable def powCoprime {G : Type*} [Group G] (h : (Nat.card G).Coprime n) : G ≃ G
    where
  toFun g := g ^ n
  invFun g := g ^ (Nat.card G).gcdB n
  left_inv g := by
    have key := congr_arg (g ^ ·) ((Nat.card G).gcd_eq_gcd_ab n)
    dsimp only at key
    

Proof state:
G✝ : Type u_1
H : Type u_2
A : Type u_3
α : Type u_4
β : Type u_5
inst✝² : Group G✝
inst✝¹ : Fintype G✝
x : G✝
n : ℕ
G : Type u_6
inst✝ : Group G
h : Coprime (Nat.card G) n
g : G
key : g ^ ↑(gcd (Nat.card G) n) = g ^ (↑(Nat.card G) * gcdA (Nat.card G) n + ↑n * gcdB (Nat.card G) n)
⊢ (fun g => g ^ gcdB (Nat.card G) n) ((fun g => g ^ n) g) = g

Next tactic:
rwa [zpow_add, zpow_mul, zpow_mul, zpow_ofNat, zpow_ofNat, zpow_ofNat, h.gcd_eq_one, pow_one,
      pow_card_eq_one', one_zpow, one_mul, eq_comm] at key
/-- If `gcd(|G|,n)=1` then the `n`th power map is a bijection -/
@[to_additive (attr := simps) "If `gcd(|G|,n)=1` then the smul by `n` is a bijection"]
noncomputable def powCoprime {G : Type*} [Group G] (h : (Nat.card G).Coprime n) : G ≃ G
    where
  toFun g := g ^ n
  invFun g := g ^ (Nat.card G).gcdB n
  left_inv g := by
    have key := congr_arg (g ^ ·) ((Nat.card G).gcd_eq_gcd_ab n)
    dsimp only at key
    rwa [zpow_add, zpow_mul, zpow_mul, zpow_ofNat, zpow_ofNat, zpow_ofNat, h.gcd_eq_one, pow_one,
      pow_card_eq_one', one_zpow, one_mul, eq_comm] at key
  right_inv g := by
    

Proof state:
G✝ : Type u_1
H : Type u_2
A : Type u_3
α : Type u_4
β : Type u_5
inst✝² : Group G✝
inst✝¹ : Fintype G✝
x : G✝
n : ℕ
G : Type u_6
inst✝ : Group G
h : Coprime (Nat.card G) n
g : G
⊢ (fun g => g ^ n) ((fun g => g ^ gcdB (Nat.card G) n) g) = g

Next tactic:
have key := congr_arg (g ^ ·) ((Nat.card G).gcd_eq_gcd_ab n)
/-- If `gcd(|G|,n)=1` then the `n`th power map is a bijection -/
@[to_additive (attr := simps) "If `gcd(|G|,n)=1` then the smul by `n` is a bijection"]
noncomputable def powCoprime {G : Type*} [Group G] (h : (Nat.card G).Coprime n) : G ≃ G
    where
  toFun g := g ^ n
  invFun g := g ^ (Nat.card G).gcdB n
  left_inv g := by
    have key := congr_arg (g ^ ·) ((Nat.card G).gcd_eq_gcd_ab n)
    dsimp only at key
    rwa [zpow_add, zpow_mul, zpow_mul, zpow_ofNat, zpow_ofNat, zpow_ofNat, h.gcd_eq_one, pow_one,
      pow_card_eq_one', one_zpow, one_mul, eq_comm] at key
  right_inv g := by
    have key := congr_arg (g ^ ·) ((Nat.card G).gcd_eq_gcd_ab n)
    

Proof state:
G✝ : Type u_1
H : Type u_2
A : Type u_3
α : Type u_4
β : Type u_5
inst✝² : Group G✝
inst✝¹ : Fintype G✝
x : G✝
n : ℕ
G : Type u_6
inst✝ : Group G
h : Coprime (Nat.card G) n
g : G
key :
  (fun x => g ^ x) ↑(gcd (Nat.card G) n) =
    (fun x => g ^ x) (↑(Nat.card G) * gcdA (Nat.card G) n + ↑n * gcdB (Nat.card G) n)
⊢ (fun g => g ^ n) ((fun g => g ^ gcdB (Nat.card G) n) g) = g

Next tactic:
dsimp only at key
/-- If `gcd(|G|,n)=1` then the `n`th power map is a bijection -/
@[to_additive (attr := simps) "If `gcd(|G|,n)=1` then the smul by `n` is a bijection"]
noncomputable def powCoprime {G : Type*} [Group G] (h : (Nat.card G).Coprime n) : G ≃ G
    where
  toFun g := g ^ n
  invFun g := g ^ (Nat.card G).gcdB n
  left_inv g := by
    have key := congr_arg (g ^ ·) ((Nat.card G).gcd_eq_gcd_ab n)
    dsimp only at key
    rwa [zpow_add, zpow_mul, zpow_mul, zpow_ofNat, zpow_ofNat, zpow_ofNat, h.gcd_eq_one, pow_one,
      pow_card_eq_one', one_zpow, one_mul, eq_comm] at key
  right_inv g := by
    have key := congr_arg (g ^ ·) ((Nat.card G).gcd_eq_gcd_ab n)
    dsimp only at key
    

Proof state:
G✝ : Type u_1
H : Type u_2
A : Type u_3
α : Type u_4
β : Type u_5
inst✝² : Group G✝
inst✝¹ : Fintype G✝
x : G✝
n : ℕ
G : Type u_6
inst✝ : Group G
h : Coprime (Nat.card G) n
g : G
key : g ^ ↑(gcd (Nat.card G) n) = g ^ (↑(Nat.card G) * gcdA (Nat.card G) n + ↑n * gcdB (Nat.card G) n)
⊢ (fun g => g ^ n) ((fun g => g ^ gcdB (Nat.card G) n) g) = g

Next tactic:
rwa [zpow_add, zpow_mul, zpow_mul', zpow_ofNat, zpow_ofNat, zpow_ofNat, h.gcd_eq_one, pow_one,
      pow_card_eq_one', one_zpow, one_mul, eq_comm] at key
@[to_additive add_inf_eq_bot_of_coprime]
theorem inf_eq_bot_of_coprime {G : Type*} [Group G] {H K : Subgroup G} [Fintype H] [Fintype K]
    (h : Nat.Coprime (Fintype.card H) (Fintype.card K)) : H ⊓ K = ⊥ := by
  

Proof state:
G✝ : Type u_1
H✝ : Type u_2
A : Type u_3
α : Type u_4
β : Type u_5
inst✝⁴ : Group G✝
inst✝³ : Fintype G✝
x : G✝
n : ℕ
G : Type u_6
inst✝² : Group G
H K : Subgroup G
inst✝¹ : Fintype ↥H
inst✝ : Fintype ↥K
h : Coprime (Fintype.card ↥H) (Fintype.card ↥K)
⊢ H ⊓ K = ⊥

Next tactic:
refine' (H ⊓ K).eq_bot_iff_forall.mpr fun x hx => _
@[to_additive add_inf_eq_bot_of_coprime]
theorem inf_eq_bot_of_coprime {G : Type*} [Group G] {H K : Subgroup G} [Fintype H] [Fintype K]
    (h : Nat.Coprime (Fintype.card H) (Fintype.card K)) : H ⊓ K = ⊥ := by
  refine' (H ⊓ K).eq_bot_iff_forall.mpr fun x hx => _
  

Proof state:
G✝ : Type u_1
H✝ : Type u_2
A : Type u_3
α : Type u_4
β : Type u_5
inst✝⁴ : Group G✝
inst✝³ : Fintype G✝
x✝ : G✝
n : ℕ
G : Type u_6
inst✝² : Group G
H K : Subgroup G
inst✝¹ : Fintype ↥H
inst✝ : Fintype ↥K
h : Coprime (Fintype.card ↥H) (Fintype.card ↥K)
x : G
hx : x ∈ H ⊓ K
⊢ x = 1

Next tactic:
rw [← orderOf_eq_one_iff, ← Nat.dvd_one, ← h.gcd_eq_one, Nat.dvd_gcd_iff]
@[to_additive add_inf_eq_bot_of_coprime]
theorem inf_eq_bot_of_coprime {G : Type*} [Group G] {H K : Subgroup G} [Fintype H] [Fintype K]
    (h : Nat.Coprime (Fintype.card H) (Fintype.card K)) : H ⊓ K = ⊥ := by
  refine' (H ⊓ K).eq_bot_iff_forall.mpr fun x hx => _
  rw [← orderOf_eq_one_iff, ← Nat.dvd_one, ← h.gcd_eq_one, Nat.dvd_gcd_iff]
  

Proof state:
G✝ : Type u_1
H✝ : Type u_2
A : Type u_3
α : Type u_4
β : Type u_5
inst✝⁴ : Group G✝
inst✝³ : Fintype G✝
x✝ : G✝
n : ℕ
G : Type u_6
inst✝² : Group G
H K : Subgroup G
inst✝¹ : Fintype ↥H
inst✝ : Fintype ↥K
h : Coprime (Fintype.card ↥H) (Fintype.card ↥K)
x : G
hx : x ∈ H ⊓ K
⊢ orderOf x ∣ Fintype.card ↥H ∧ orderOf x ∣ Fintype.card ↥K

Next tactic:
exact
    ⟨(congr_arg (· ∣ Fintype.card H) (orderOf_coe ⟨x, hx.1⟩)).mpr orderOf_dvd_card,
      (congr_arg (· ∣ Fintype.card K) (orderOf_coe ⟨x, hx.2⟩)).mpr orderOf_dvd_card⟩
@[to_additive]
theorem image_range_orderOf [DecidableEq G] :
    Finset.image (fun i => x ^ i) (Finset.range (orderOf x)) = (zpowers x : Set G).toFinset := by
  

Proof state:
G : Type u_1
H : Type u_2
A : Type u_3
α : Type u_4
β : Type u_5
inst✝² : Group G
inst✝¹ : Fintype G
x : G
n : ℕ
inst✝ : DecidableEq G
⊢ Finset.image (fun i => x ^ i) (Finset.range (orderOf x)) = Set.toFinset ↑(zpowers x)

Next tactic:
ext x
@[to_additive]
theorem image_range_orderOf [DecidableEq G] :
    Finset.image (fun i => x ^ i) (Finset.range (orderOf x)) = (zpowers x : Set G).toFinset := by
  ext x
  

Proof state:
case a
G : Type u_1
H : Type u_2
A : Type u_3
α : Type u_4
β : Type u_5
inst✝² : Group G
inst✝¹ : Fintype G
x✝ : G
n : ℕ
inst✝ : DecidableEq G
x : G
⊢ x ∈ Finset.image (fun i => x✝ ^ i) (Finset.range (orderOf x✝)) ↔ x ∈ Set.toFinset ↑(zpowers x✝)

Next tactic:
rw [Set.mem_toFinset, SetLike.mem_coe, mem_zpowers_iff_mem_range_orderOf]
@[to_additive gcd_nsmul_card_eq_zero_iff]
theorem pow_gcd_card_eq_one_iff : x ^ n = 1 ↔ x ^ gcd n (Fintype.card G) = 1 :=
  ⟨fun h => pow_gcd_eq_one _ h <| pow_card_eq_one, fun h => by
    

Proof state:
G : Type u_1
H : Type u_2
A : Type u_3
α : Type u_4
β : Type u_5
inst✝¹ : Group G
inst✝ : Fintype G
x : G
n : ℕ
h : x ^ gcd n (Fintype.card G) = 1
⊢ x ^ n = 1

Next tactic:
let ⟨m, hm⟩ := gcd_dvd_left n (Fintype.card G)
@[to_additive gcd_nsmul_card_eq_zero_iff]
theorem pow_gcd_card_eq_one_iff : x ^ n = 1 ↔ x ^ gcd n (Fintype.card G) = 1 :=
  ⟨fun h => pow_gcd_eq_one _ h <| pow_card_eq_one, fun h => by
    let ⟨m, hm⟩ := gcd_dvd_left n (Fintype.card G)
    

Proof state:
G : Type u_1
H : Type u_2
A : Type u_3
α : Type u_4
β : Type u_5
inst✝¹ : Group G
inst✝ : Fintype G
x : G
n : ℕ
h : x ^ gcd n (Fintype.card G) = 1
m : ℕ
hm : n = gcd n (Fintype.card G) * m
⊢ x ^ n = 1

Next tactic:
rw [hm, pow_mul, h, one_pow]
/-- A nonempty idempotent subset of a finite cancellative monoid is a submonoid -/
@[to_additive "A nonempty idempotent subset of a finite cancellative add monoid is a submonoid"]
def submonoidOfIdempotent {M : Type*} [LeftCancelMonoid M] [Fintype M] (S : Set M)
    (hS1 : S.Nonempty) (hS2 : S * S = S) : Submonoid M :=
  have pow_mem : ∀ a : M, a ∈ S → ∀ n : ℕ, a ^ (n + 1) ∈ S := fun a ha =>
    Nat.rec (by 

Proof state:
G : Type u_1
H : Type u_2
A : Type u_3
α : Type u_4
β : Type u_5
M : Type u_6
inst✝¹ : LeftCancelMonoid M
inst✝ : Fintype M
S : Set M
hS1 : Set.Nonempty S
hS2 : S * S = S
a : M
ha : a ∈ S
⊢ a ^ (zero + 1) ∈ S

Next tactic:
rwa [Nat.zero_eq, zero_add, pow_one]
/-- A nonempty idempotent subset of a finite cancellative monoid is a submonoid -/
@[to_additive "A nonempty idempotent subset of a finite cancellative add monoid is a submonoid"]
def submonoidOfIdempotent {M : Type*} [LeftCancelMonoid M] [Fintype M] (S : Set M)
    (hS1 : S.Nonempty) (hS2 : S * S = S) : Submonoid M :=
  have pow_mem : ∀ a : M, a ∈ S → ∀ n : ℕ, a ^ (n + 1) ∈ S := fun a ha =>
    Nat.rec (by rwa [Nat.zero_eq, zero_add, pow_one]) fun n ih =>
      (congr_arg₂ (· ∈ ·) (pow_succ a (n + 1)).symm hS2).mp (Set.mul_mem_mul ha ih)
  { carrier := S
    one_mem' := by
      

Proof state:
G : Type u_1
H : Type u_2
A : Type u_3
α : Type u_4
β : Type u_5
M : Type u_6
inst✝¹ : LeftCancelMonoid M
inst✝ : Fintype M
S : Set M
hS1 : Set.Nonempty S
hS2 : S * S = S
pow_mem : ∀ a ∈ S, ∀ (n : ℕ), a ^ (n + 1) ∈ S
⊢ 1 ∈ { carrier := S, mul_mem' := (_ : ∀ {a b : M}, a ∈ S → b ∈ S → a * b ∈ S) }.carrier

Next tactic:
obtain ⟨a, ha⟩ := hS1
/-- A nonempty idempotent subset of a finite cancellative monoid is a submonoid -/
@[to_additive "A nonempty idempotent subset of a finite cancellative add monoid is a submonoid"]
def submonoidOfIdempotent {M : Type*} [LeftCancelMonoid M] [Fintype M] (S : Set M)
    (hS1 : S.Nonempty) (hS2 : S * S = S) : Submonoid M :=
  have pow_mem : ∀ a : M, a ∈ S → ∀ n : ℕ, a ^ (n + 1) ∈ S := fun a ha =>
    Nat.rec (by rwa [Nat.zero_eq, zero_add, pow_one]) fun n ih =>
      (congr_arg₂ (· ∈ ·) (pow_succ a (n + 1)).symm hS2).mp (Set.mul_mem_mul ha ih)
  { carrier := S
    one_mem' := by
      obtain ⟨a, ha⟩ := hS1
      

Proof state:
case intro
G : Type u_1
H : Type u_2
A : Type u_3
α : Type u_4
β : Type u_5
M : Type u_6
inst✝¹ : LeftCancelMonoid M
inst✝ : Fintype M
S : Set M
hS2 : S * S = S
pow_mem : ∀ a ∈ S, ∀ (n : ℕ), a ^ (n + 1) ∈ S
a : M
ha : a ∈ S
⊢ 1 ∈ { carrier := S, mul_mem' := (_ : ∀ {a b : M}, a ∈ S → b ∈ S → a * b ∈ S) }.carrier

Next tactic:
rw [← pow_orderOf_eq_one a, ← tsub_add_cancel_of_le (succ_le_of_lt (orderOf_pos a))]
/-- A nonempty idempotent subset of a finite cancellative monoid is a submonoid -/
@[to_additive "A nonempty idempotent subset of a finite cancellative add monoid is a submonoid"]
def submonoidOfIdempotent {M : Type*} [LeftCancelMonoid M] [Fintype M] (S : Set M)
    (hS1 : S.Nonempty) (hS2 : S * S = S) : Submonoid M :=
  have pow_mem : ∀ a : M, a ∈ S → ∀ n : ℕ, a ^ (n + 1) ∈ S := fun a ha =>
    Nat.rec (by rwa [Nat.zero_eq, zero_add, pow_one]) fun n ih =>
      (congr_arg₂ (· ∈ ·) (pow_succ a (n + 1)).symm hS2).mp (Set.mul_mem_mul ha ih)
  { carrier := S
    one_mem' := by
      obtain ⟨a, ha⟩ := hS1
      rw [← pow_orderOf_eq_one a, ← tsub_add_cancel_of_le (succ_le_of_lt (orderOf_pos a))]
      

Proof state:
case intro
G : Type u_1
H : Type u_2
A : Type u_3
α : Type u_4
β : Type u_5
M : Type u_6
inst✝¹ : LeftCancelMonoid M
inst✝ : Fintype M
S : Set M
hS2 : S * S = S
pow_mem : ∀ a ∈ S, ∀ (n : ℕ), a ^ (n + 1) ∈ S
a : M
ha : a ∈ S
⊢ a ^ (orderOf a - succ 0 + succ 0) ∈ { carrier := S, mul_mem' := (_ : ∀ {a b : M}, a ∈ S → b ∈ S → a * b ∈ S) }.carrier

Next tactic:
exact pow_mem a ha (orderOf a - 1)
/-- A nonempty idempotent subset of a finite group is a subgroup -/
@[to_additive "A nonempty idempotent subset of a finite add group is a subgroup"]
def subgroupOfIdempotent {G : Type*} [Group G] [Fintype G] (S : Set G) (hS1 : S.Nonempty)
    (hS2 : S * S = S) : Subgroup G :=
  { submonoidOfIdempotent S hS1 hS2 with
    carrier := S
    inv_mem' := fun {a} ha => show a⁻¹ ∈ submonoidOfIdempotent S hS1 hS2 by
      

Proof state:
G✝ : Type u_1
H : Type u_2
A : Type u_3
α : Type u_4
β : Type u_5
G : Type u_6
inst✝¹ : Group G
inst✝ : Fintype G
S : Set G
hS1 : Set.Nonempty S
hS2 : S * S = S
src✝ : Submonoid G := submonoidOfIdempotent S hS1 hS2
a : G
ha :
  a ∈
    {
          toSubsemigroup :=
            { carrier := S, mul_mem' := (_ : ∀ {a b : G}, a ∈ src✝.carrier → b ∈ src✝.carrier → a * b ∈ src✝.carrier) },
          one_mem' := (_ : 1 ∈ src✝.carrier) }.toSubsemigroup.carrier
⊢ a⁻¹ ∈ submonoidOfIdempotent S hS1 hS2

Next tactic:
rw [← one_mul a⁻¹, ← pow_one a, ← pow_orderOf_eq_one a, ← pow_sub a (orderOf_pos a)]
/-- A nonempty idempotent subset of a finite group is a subgroup -/
@[to_additive "A nonempty idempotent subset of a finite add group is a subgroup"]
def subgroupOfIdempotent {G : Type*} [Group G] [Fintype G] (S : Set G) (hS1 : S.Nonempty)
    (hS2 : S * S = S) : Subgroup G :=
  { submonoidOfIdempotent S hS1 hS2 with
    carrier := S
    inv_mem' := fun {a} ha => show a⁻¹ ∈ submonoidOfIdempotent S hS1 hS2 by
      rw [← one_mul a⁻¹, ← pow_one a, ← pow_orderOf_eq_one a, ← pow_sub a (orderOf_pos a)]
      

Proof state:
G✝ : Type u_1
H : Type u_2
A : Type u_3
α : Type u_4
β : Type u_5
G : Type u_6
inst✝¹ : Group G
inst✝ : Fintype G
S : Set G
hS1 : Set.Nonempty S
hS2 : S * S = S
src✝ : Submonoid G := submonoidOfIdempotent S hS1 hS2
a : G
ha :
  a ∈
    {
          toSubsemigroup :=
            { carrier := S, mul_mem' := (_ : ∀ {a b : G}, a ∈ src✝.carrier → b ∈ src✝.carrier → a * b ∈ src✝.carrier) },
          one_mem' := (_ : 1 ∈ src✝.carrier) }.toSubsemigroup.carrier
⊢ a ^ (orderOf a - succ 0) ∈ submonoidOfIdempotent S hS1 hS2

Next tactic:
exact pow_mem ha (orderOf a - 1)
/-- If `S` is a nonempty subset of a finite group `G`, then `S ^ |G|` is a subgroup -/
@[to_additive (attr := simps!) smulCardAddSubgroup
  "If `S` is a nonempty subset of a finite add group `G`, then `|G| • S` is a subgroup"]
def powCardSubgroup {G : Type*} [Group G] [Fintype G] (S : Set G) (hS : S.Nonempty) : Subgroup G :=
  have one_mem : (1 : G) ∈ S ^ Fintype.card G := by
    

Proof state:
G✝ : Type u_1
H : Type u_2
A : Type u_3
α : Type u_4
β : Type u_5
G : Type u_6
inst✝¹ : Group G
inst✝ : Fintype G
S : Set G
hS : Set.Nonempty S
⊢ 1 ∈ S ^ Fintype.card G

Next tactic:
obtain ⟨a, ha⟩ := hS
/-- If `S` is a nonempty subset of a finite group `G`, then `S ^ |G|` is a subgroup -/
@[to_additive (attr := simps!) smulCardAddSubgroup
  "If `S` is a nonempty subset of a finite add group `G`, then `|G| • S` is a subgroup"]
def powCardSubgroup {G : Type*} [Group G] [Fintype G] (S : Set G) (hS : S.Nonempty) : Subgroup G :=
  have one_mem : (1 : G) ∈ S ^ Fintype.card G := by
    obtain ⟨a, ha⟩ := hS
    

Proof state:
case intro
G✝ : Type u_1
H : Type u_2
A : Type u_3
α : Type u_4
β : Type u_5
G : Type u_6
inst✝¹ : Group G
inst✝ : Fintype G
S : Set G
a : G
ha : a ∈ S
⊢ 1 ∈ S ^ Fintype.card G

Next tactic:
rw [← pow_card_eq_one]