l3lab/ntp-mathlib huggingface dataset:
@[to_additive]
instance (priority := 100) isCyclic : IsCyclic α := by
  cases' subsingleton_or_nontrivial α with hi hi <;> haveI := hi
  · apply isCyclic_of_subsingleton
  · obtain ⟨g, hg⟩ := exists_ne (1 : α)
    refine' ⟨⟨g, fun x => _⟩⟩
    cases' IsSimpleOrder.eq_bot_or_eq_top (Subgroup.zpowers g) with hb ht
    · exfalso
      apply hg
      

Proof state:
case inr.intro.inl.h
α : Type u
a : α
inst✝¹ : CommGroup α
inst✝ : IsSimpleGroup α
hi this : Nontrivial α
g : α
hg : g ≠ 1
x : α
hb : Subgroup.zpowers g = ⊥
⊢ g = 1

Next tactic:
rw [← Subgroup.mem_bot, ← hb]
@[to_additive]
instance (priority := 100) isCyclic : IsCyclic α := by
  cases' subsingleton_or_nontrivial α with hi hi <;> haveI := hi
  · apply isCyclic_of_subsingleton
  · obtain ⟨g, hg⟩ := exists_ne (1 : α)
    refine' ⟨⟨g, fun x => _⟩⟩
    cases' IsSimpleOrder.eq_bot_or_eq_top (Subgroup.zpowers g) with hb ht
    · exfalso
      apply hg
      rw [← Subgroup.mem_bot, ← hb]
      

Proof state:
case inr.intro.inl.h
α : Type u
a : α
inst✝¹ : CommGroup α
inst✝ : IsSimpleGroup α
hi this : Nontrivial α
g : α
hg : g ≠ 1
x : α
hb : Subgroup.zpowers g = ⊥
⊢ g ∈ Subgroup.zpowers g

Next tactic:
apply Subgroup.mem_zpowers
@[to_additive]
instance (priority := 100) isCyclic : IsCyclic α := by
  cases' subsingleton_or_nontrivial α with hi hi <;> haveI := hi
  · apply isCyclic_of_subsingleton
  · obtain ⟨g, hg⟩ := exists_ne (1 : α)
    refine' ⟨⟨g, fun x => _⟩⟩
    cases' IsSimpleOrder.eq_bot_or_eq_top (Subgroup.zpowers g) with hb ht
    · exfalso
      apply hg
      rw [← Subgroup.mem_bot, ← hb]
      apply Subgroup.mem_zpowers
    · 

Proof state:
case inr.intro.inr
α : Type u
a : α
inst✝¹ : CommGroup α
inst✝ : IsSimpleGroup α
hi this : Nontrivial α
g : α
hg : g ≠ 1
x : α
ht : Subgroup.zpowers g = ⊤
⊢ x ∈ Subgroup.zpowers g

Next tactic:
rw [ht]
@[to_additive]
instance (priority := 100) isCyclic : IsCyclic α := by
  cases' subsingleton_or_nontrivial α with hi hi <;> haveI := hi
  · apply isCyclic_of_subsingleton
  · obtain ⟨g, hg⟩ := exists_ne (1 : α)
    refine' ⟨⟨g, fun x => _⟩⟩
    cases' IsSimpleOrder.eq_bot_or_eq_top (Subgroup.zpowers g) with hb ht
    · exfalso
      apply hg
      rw [← Subgroup.mem_bot, ← hb]
      apply Subgroup.mem_zpowers
    · rw [ht]
      

Proof state:
case inr.intro.inr
α : Type u
a : α
inst✝¹ : CommGroup α
inst✝ : IsSimpleGroup α
hi this : Nontrivial α
g : α
hg : g ≠ 1
x : α
ht : Subgroup.zpowers g = ⊤
⊢ x ∈ ⊤

Next tactic:
apply Subgroup.mem_top
@[to_additive]
theorem prime_card [Fintype α] : (Fintype.card α).Prime := by
  

Proof state:
α : Type u
a : α
inst✝² : CommGroup α
inst✝¹ : IsSimpleGroup α
inst✝ : Fintype α
⊢ Nat.Prime (Fintype.card α)

Next tactic:
have h0 : 0 < Fintype.card α := Fintype.card_pos_iff.2 (by infer_instance)
@[to_additive]
theorem prime_card [Fintype α] : (Fintype.card α).Prime := by
  have h0 : 0 < Fintype.card α := Fintype.card_pos_iff.2 (by 

Proof state:
α : Type u
a : α
inst✝² : CommGroup α
inst✝¹ : IsSimpleGroup α
inst✝ : Fintype α
⊢ Nonempty α

Next tactic:
infer_instance
@[to_additive]
theorem prime_card [Fintype α] : (Fintype.card α).Prime := by
  have h0 : 0 < Fintype.card α := Fintype.card_pos_iff.2 (by infer_instance)
  

Proof state:
α : Type u
a : α
inst✝² : CommGroup α
inst✝¹ : IsSimpleGroup α
inst✝ : Fintype α
h0 : 0 < Fintype.card α
⊢ Nat.Prime (Fintype.card α)

Next tactic:
obtain ⟨g, hg⟩ := IsCyclic.exists_generator (α := α)
@[to_additive]
theorem prime_card [Fintype α] : (Fintype.card α).Prime := by
  have h0 : 0 < Fintype.card α := Fintype.card_pos_iff.2 (by infer_instance)
  obtain ⟨g, hg⟩ := IsCyclic.exists_generator (α := α)
  

Proof state:
case intro
α : Type u
a : α
inst✝² : CommGroup α
inst✝¹ : IsSimpleGroup α
inst✝ : Fintype α
h0 : 0 < Fintype.card α
g : α
hg : ∀ (x : α), x ∈ Subgroup.zpowers g
⊢ Nat.Prime (Fintype.card α)

Next tactic:
rw [Nat.prime_def_lt'']
@[to_additive]
theorem prime_card [Fintype α] : (Fintype.card α).Prime := by
  have h0 : 0 < Fintype.card α := Fintype.card_pos_iff.2 (by infer_instance)
  obtain ⟨g, hg⟩ := IsCyclic.exists_generator (α := α)
  rw [Nat.prime_def_lt'']
  

Proof state:
case intro
α : Type u
a : α
inst✝² : CommGroup α
inst✝¹ : IsSimpleGroup α
inst✝ : Fintype α
h0 : 0 < Fintype.card α
g : α
hg : ∀ (x : α), x ∈ Subgroup.zpowers g
⊢ 2 ≤ Fintype.card α ∧ ∀ (m : ℕ), m ∣ Fintype.card α → m = 1 ∨ m = Fintype.card α

Next tactic:
refine' ⟨Fintype.one_lt_card_iff_nontrivial.2 inferInstance, fun n hn => _⟩
@[to_additive]
theorem prime_card [Fintype α] : (Fintype.card α).Prime := by
  have h0 : 0 < Fintype.card α := Fintype.card_pos_iff.2 (by infer_instance)
  obtain ⟨g, hg⟩ := IsCyclic.exists_generator (α := α)
  rw [Nat.prime_def_lt'']
  refine' ⟨Fintype.one_lt_card_iff_nontrivial.2 inferInstance, fun n hn => _⟩
  

Proof state:
case intro
α : Type u
a : α
inst✝² : CommGroup α
inst✝¹ : IsSimpleGroup α
inst✝ : Fintype α
h0 : 0 < Fintype.card α
g : α
hg : ∀ (x : α), x ∈ Subgroup.zpowers g
n : ℕ
hn : n ∣ Fintype.card α
⊢ n = 1 ∨ n = Fintype.card α

Next tactic:
refine' (IsSimpleOrder.eq_bot_or_eq_top (Subgroup.zpowers (g ^ n))).symm.imp _ _
@[to_additive]
theorem prime_card [Fintype α] : (Fintype.card α).Prime := by
  have h0 : 0 < Fintype.card α := Fintype.card_pos_iff.2 (by infer_instance)
  obtain ⟨g, hg⟩ := IsCyclic.exists_generator (α := α)
  rw [Nat.prime_def_lt'']
  refine' ⟨Fintype.one_lt_card_iff_nontrivial.2 inferInstance, fun n hn => _⟩
  refine' (IsSimpleOrder.eq_bot_or_eq_top (Subgroup.zpowers (g ^ n))).symm.imp _ _
  · 

Proof state:
case intro.refine'_1
α : Type u
a : α
inst✝² : CommGroup α
inst✝¹ : IsSimpleGroup α
inst✝ : Fintype α
h0 : 0 < Fintype.card α
g : α
hg : ∀ (x : α), x ∈ Subgroup.zpowers g
n : ℕ
hn : n ∣ Fintype.card α
⊢ Subgroup.zpowers (g ^ n) = ⊤ → n = 1

Next tactic:
intro h
@[to_additive]
theorem prime_card [Fintype α] : (Fintype.card α).Prime := by
  have h0 : 0 < Fintype.card α := Fintype.card_pos_iff.2 (by infer_instance)
  obtain ⟨g, hg⟩ := IsCyclic.exists_generator (α := α)
  rw [Nat.prime_def_lt'']
  refine' ⟨Fintype.one_lt_card_iff_nontrivial.2 inferInstance, fun n hn => _⟩
  refine' (IsSimpleOrder.eq_bot_or_eq_top (Subgroup.zpowers (g ^ n))).symm.imp _ _
  · intro h
    

Proof state:
case intro.refine'_1
α : Type u
a : α
inst✝² : CommGroup α
inst✝¹ : IsSimpleGroup α
inst✝ : Fintype α
h0 : 0 < Fintype.card α
g : α
hg : ∀ (x : α), x ∈ Subgroup.zpowers g
n : ℕ
hn : n ∣ Fintype.card α
h : Subgroup.zpowers (g ^ n) = ⊤
⊢ n = 1

Next tactic:
have hgo := orderOf_pow (n := n) g
@[to_additive]
theorem prime_card [Fintype α] : (Fintype.card α).Prime := by
  have h0 : 0 < Fintype.card α := Fintype.card_pos_iff.2 (by infer_instance)
  obtain ⟨g, hg⟩ := IsCyclic.exists_generator (α := α)
  rw [Nat.prime_def_lt'']
  refine' ⟨Fintype.one_lt_card_iff_nontrivial.2 inferInstance, fun n hn => _⟩
  refine' (IsSimpleOrder.eq_bot_or_eq_top (Subgroup.zpowers (g ^ n))).symm.imp _ _
  · intro h
    have hgo := orderOf_pow (n := n) g
    

Proof state:
case intro.refine'_1
α : Type u
a : α
inst✝² : CommGroup α
inst✝¹ : IsSimpleGroup α
inst✝ : Fintype α
h0 : 0 < Fintype.card α
g : α
hg : ∀ (x : α), x ∈ Subgroup.zpowers g
n : ℕ
hn : n ∣ Fintype.card α
h : Subgroup.zpowers (g ^ n) = ⊤
hgo : orderOf (g ^ n) = orderOf g / Nat.gcd (orderOf g) n
⊢ n = 1

Next tactic:
rw [orderOf_eq_card_of_forall_mem_zpowers hg, Nat.gcd_eq_right_iff_dvd.1 hn,
      orderOf_eq_card_of_forall_mem_zpowers, eq_comm,
      Nat.div_eq_iff_eq_mul_left (Nat.pos_of_dvd_of_pos hn h0) hn] at hgo
@[to_additive]
theorem prime_card [Fintype α] : (Fintype.card α).Prime := by
  have h0 : 0 < Fintype.card α := Fintype.card_pos_iff.2 (by infer_instance)
  obtain ⟨g, hg⟩ := IsCyclic.exists_generator (α := α)
  rw [Nat.prime_def_lt'']
  refine' ⟨Fintype.one_lt_card_iff_nontrivial.2 inferInstance, fun n hn => _⟩
  refine' (IsSimpleOrder.eq_bot_or_eq_top (Subgroup.zpowers (g ^ n))).symm.imp _ _
  · intro h
    have hgo := orderOf_pow (n := n) g
    rw [orderOf_eq_card_of_forall_mem_zpowers hg, Nat.gcd_eq_right_iff_dvd.1 hn,
      orderOf_eq_card_of_forall_mem_zpowers, eq_comm,
      Nat.div_eq_iff_eq_mul_left (Nat.pos_of_dvd_of_pos hn h0) hn] at hgo
    · 

Proof state:
case intro.refine'_1
α : Type u
a : α
inst✝² : CommGroup α
inst✝¹ : IsSimpleGroup α
inst✝ : Fintype α
h0 : 0 < Fintype.card α
g : α
hg : ∀ (x : α), x ∈ Subgroup.zpowers g
n : ℕ
hn : n ∣ Fintype.card α
h : Subgroup.zpowers (g ^ n) = ⊤
hgo : Fintype.card α = Fintype.card α * n
⊢ n = 1

Next tactic:
exact (mul_left_cancel₀ (ne_of_gt h0) ((mul_one (Fintype.card α)).trans hgo)).symm
@[to_additive]
theorem prime_card [Fintype α] : (Fintype.card α).Prime := by
  have h0 : 0 < Fintype.card α := Fintype.card_pos_iff.2 (by infer_instance)
  obtain ⟨g, hg⟩ := IsCyclic.exists_generator (α := α)
  rw [Nat.prime_def_lt'']
  refine' ⟨Fintype.one_lt_card_iff_nontrivial.2 inferInstance, fun n hn => _⟩
  refine' (IsSimpleOrder.eq_bot_or_eq_top (Subgroup.zpowers (g ^ n))).symm.imp _ _
  · intro h
    have hgo := orderOf_pow (n := n) g
    rw [orderOf_eq_card_of_forall_mem_zpowers hg, Nat.gcd_eq_right_iff_dvd.1 hn,
      orderOf_eq_card_of_forall_mem_zpowers, eq_comm,
      Nat.div_eq_iff_eq_mul_left (Nat.pos_of_dvd_of_pos hn h0) hn] at hgo
    · exact (mul_left_cancel₀ (ne_of_gt h0) ((mul_one (Fintype.card α)).trans hgo)).symm
    · 

Proof state:
case intro.refine'_1
α : Type u
a : α
inst✝² : CommGroup α
inst✝¹ : IsSimpleGroup α
inst✝ : Fintype α
h0 : 0 < Fintype.card α
g : α
hg : ∀ (x : α), x ∈ Subgroup.zpowers g
n : ℕ
hn : n ∣ Fintype.card α
h : Subgroup.zpowers (g ^ n) = ⊤
hgo : orderOf (g ^ n) = Fintype.card α / n
⊢ ∀ (x : α), x ∈ Subgroup.zpowers (g ^ n)

Next tactic:
intro x
@[to_additive]
theorem prime_card [Fintype α] : (Fintype.card α).Prime := by
  have h0 : 0 < Fintype.card α := Fintype.card_pos_iff.2 (by infer_instance)
  obtain ⟨g, hg⟩ := IsCyclic.exists_generator (α := α)
  rw [Nat.prime_def_lt'']
  refine' ⟨Fintype.one_lt_card_iff_nontrivial.2 inferInstance, fun n hn => _⟩
  refine' (IsSimpleOrder.eq_bot_or_eq_top (Subgroup.zpowers (g ^ n))).symm.imp _ _
  · intro h
    have hgo := orderOf_pow (n := n) g
    rw [orderOf_eq_card_of_forall_mem_zpowers hg, Nat.gcd_eq_right_iff_dvd.1 hn,
      orderOf_eq_card_of_forall_mem_zpowers, eq_comm,
      Nat.div_eq_iff_eq_mul_left (Nat.pos_of_dvd_of_pos hn h0) hn] at hgo
    · exact (mul_left_cancel₀ (ne_of_gt h0) ((mul_one (Fintype.card α)).trans hgo)).symm
    · intro x
      

Proof state:
case intro.refine'_1
α : Type u
a : α
inst✝² : CommGroup α
inst✝¹ : IsSimpleGroup α
inst✝ : Fintype α
h0 : 0 < Fintype.card α
g : α
hg : ∀ (x : α), x ∈ Subgroup.zpowers g
n : ℕ
hn : n ∣ Fintype.card α
h : Subgroup.zpowers (g ^ n) = ⊤
hgo : orderOf (g ^ n) = Fintype.card α / n
x : α
⊢ x ∈ Subgroup.zpowers (g ^ n)

Next tactic:
rw [h]
@[to_additive]
theorem prime_card [Fintype α] : (Fintype.card α).Prime := by
  have h0 : 0 < Fintype.card α := Fintype.card_pos_iff.2 (by infer_instance)
  obtain ⟨g, hg⟩ := IsCyclic.exists_generator (α := α)
  rw [Nat.prime_def_lt'']
  refine' ⟨Fintype.one_lt_card_iff_nontrivial.2 inferInstance, fun n hn => _⟩
  refine' (IsSimpleOrder.eq_bot_or_eq_top (Subgroup.zpowers (g ^ n))).symm.imp _ _
  · intro h
    have hgo := orderOf_pow (n := n) g
    rw [orderOf_eq_card_of_forall_mem_zpowers hg, Nat.gcd_eq_right_iff_dvd.1 hn,
      orderOf_eq_card_of_forall_mem_zpowers, eq_comm,
      Nat.div_eq_iff_eq_mul_left (Nat.pos_of_dvd_of_pos hn h0) hn] at hgo
    · exact (mul_left_cancel₀ (ne_of_gt h0) ((mul_one (Fintype.card α)).trans hgo)).symm
    · intro x
      rw [h]
      

Proof state:
case intro.refine'_1
α : Type u
a : α
inst✝² : CommGroup α
inst✝¹ : IsSimpleGroup α
inst✝ : Fintype α
h0 : 0 < Fintype.card α
g : α
hg : ∀ (x : α), x ∈ Subgroup.zpowers g
n : ℕ
hn : n ∣ Fintype.card α
h : Subgroup.zpowers (g ^ n) = ⊤
hgo : orderOf (g ^ n) = Fintype.card α / n
x : α
⊢ x ∈ ⊤

Next tactic:
exact Subgroup.mem_top _
@[to_additive]
theorem prime_card [Fintype α] : (Fintype.card α).Prime := by
  have h0 : 0 < Fintype.card α := Fintype.card_pos_iff.2 (by infer_instance)
  obtain ⟨g, hg⟩ := IsCyclic.exists_generator (α := α)
  rw [Nat.prime_def_lt'']
  refine' ⟨Fintype.one_lt_card_iff_nontrivial.2 inferInstance, fun n hn => _⟩
  refine' (IsSimpleOrder.eq_bot_or_eq_top (Subgroup.zpowers (g ^ n))).symm.imp _ _
  · intro h
    have hgo := orderOf_pow (n := n) g
    rw [orderOf_eq_card_of_forall_mem_zpowers hg, Nat.gcd_eq_right_iff_dvd.1 hn,
      orderOf_eq_card_of_forall_mem_zpowers, eq_comm,
      Nat.div_eq_iff_eq_mul_left (Nat.pos_of_dvd_of_pos hn h0) hn] at hgo
    · exact (mul_left_cancel₀ (ne_of_gt h0) ((mul_one (Fintype.card α)).trans hgo)).symm
    · intro x
      rw [h]
      exact Subgroup.mem_top _
  · 

Proof state:
case intro.refine'_2
α : Type u
a : α
inst✝² : CommGroup α
inst✝¹ : IsSimpleGroup α
inst✝ : Fintype α
h0 : 0 < Fintype.card α
g : α
hg : ∀ (x : α), x ∈ Subgroup.zpowers g
n : ℕ
hn : n ∣ Fintype.card α
⊢ Subgroup.zpowers (g ^ n) = ⊥ → n = Fintype.card α

Next tactic:
intro h
@[to_additive]
theorem prime_card [Fintype α] : (Fintype.card α).Prime := by
  have h0 : 0 < Fintype.card α := Fintype.card_pos_iff.2 (by infer_instance)
  obtain ⟨g, hg⟩ := IsCyclic.exists_generator (α := α)
  rw [Nat.prime_def_lt'']
  refine' ⟨Fintype.one_lt_card_iff_nontrivial.2 inferInstance, fun n hn => _⟩
  refine' (IsSimpleOrder.eq_bot_or_eq_top (Subgroup.zpowers (g ^ n))).symm.imp _ _
  · intro h
    have hgo := orderOf_pow (n := n) g
    rw [orderOf_eq_card_of_forall_mem_zpowers hg, Nat.gcd_eq_right_iff_dvd.1 hn,
      orderOf_eq_card_of_forall_mem_zpowers, eq_comm,
      Nat.div_eq_iff_eq_mul_left (Nat.pos_of_dvd_of_pos hn h0) hn] at hgo
    · exact (mul_left_cancel₀ (ne_of_gt h0) ((mul_one (Fintype.card α)).trans hgo)).symm
    · intro x
      rw [h]
      exact Subgroup.mem_top _
  · intro h
    

Proof state:
case intro.refine'_2
α : Type u
a : α
inst✝² : CommGroup α
inst✝¹ : IsSimpleGroup α
inst✝ : Fintype α
h0 : 0 < Fintype.card α
g : α
hg : ∀ (x : α), x ∈ Subgroup.zpowers g
n : ℕ
hn : n ∣ Fintype.card α
h : Subgroup.zpowers (g ^ n) = ⊥
⊢ n = Fintype.card α

Next tactic:
apply le_antisymm (Nat.le_of_dvd h0 hn)
@[to_additive]
theorem prime_card [Fintype α] : (Fintype.card α).Prime := by
  have h0 : 0 < Fintype.card α := Fintype.card_pos_iff.2 (by infer_instance)
  obtain ⟨g, hg⟩ := IsCyclic.exists_generator (α := α)
  rw [Nat.prime_def_lt'']
  refine' ⟨Fintype.one_lt_card_iff_nontrivial.2 inferInstance, fun n hn => _⟩
  refine' (IsSimpleOrder.eq_bot_or_eq_top (Subgroup.zpowers (g ^ n))).symm.imp _ _
  · intro h
    have hgo := orderOf_pow (n := n) g
    rw [orderOf_eq_card_of_forall_mem_zpowers hg, Nat.gcd_eq_right_iff_dvd.1 hn,
      orderOf_eq_card_of_forall_mem_zpowers, eq_comm,
      Nat.div_eq_iff_eq_mul_left (Nat.pos_of_dvd_of_pos hn h0) hn] at hgo
    · exact (mul_left_cancel₀ (ne_of_gt h0) ((mul_one (Fintype.card α)).trans hgo)).symm
    · intro x
      rw [h]
      exact Subgroup.mem_top _
  · intro h
    apply le_antisymm (Nat.le_of_dvd h0 hn)
    

Proof state:
case intro.refine'_2
α : Type u
a : α
inst✝² : CommGroup α
inst✝¹ : IsSimpleGroup α
inst✝ : Fintype α
h0 : 0 < Fintype.card α
g : α
hg : ∀ (x : α), x ∈ Subgroup.zpowers g
n : ℕ
hn : n ∣ Fintype.card α
h : Subgroup.zpowers (g ^ n) = ⊥
⊢ Fintype.card α ≤ n

Next tactic:
rw [← orderOf_eq_card_of_forall_mem_zpowers hg]
@[to_additive]
theorem prime_card [Fintype α] : (Fintype.card α).Prime := by
  have h0 : 0 < Fintype.card α := Fintype.card_pos_iff.2 (by infer_instance)
  obtain ⟨g, hg⟩ := IsCyclic.exists_generator (α := α)
  rw [Nat.prime_def_lt'']
  refine' ⟨Fintype.one_lt_card_iff_nontrivial.2 inferInstance, fun n hn => _⟩
  refine' (IsSimpleOrder.eq_bot_or_eq_top (Subgroup.zpowers (g ^ n))).symm.imp _ _
  · intro h
    have hgo := orderOf_pow (n := n) g
    rw [orderOf_eq_card_of_forall_mem_zpowers hg, Nat.gcd_eq_right_iff_dvd.1 hn,
      orderOf_eq_card_of_forall_mem_zpowers, eq_comm,
      Nat.div_eq_iff_eq_mul_left (Nat.pos_of_dvd_of_pos hn h0) hn] at hgo
    · exact (mul_left_cancel₀ (ne_of_gt h0) ((mul_one (Fintype.card α)).trans hgo)).symm
    · intro x
      rw [h]
      exact Subgroup.mem_top _
  · intro h
    apply le_antisymm (Nat.le_of_dvd h0 hn)
    rw [← orderOf_eq_card_of_forall_mem_zpowers hg]
    

Proof state:
case intro.refine'_2
α : Type u
a : α
inst✝² : CommGroup α
inst✝¹ : IsSimpleGroup α
inst✝ : Fintype α
h0 : 0 < Fintype.card α
g : α
hg : ∀ (x : α), x ∈ Subgroup.zpowers g
n : ℕ
hn : n ∣ Fintype.card α
h : Subgroup.zpowers (g ^ n) = ⊥
⊢ orderOf g ≤ n

Next tactic:
apply orderOf_le_of_pow_eq_one (Nat.pos_of_dvd_of_pos hn h0)
@[to_additive]
theorem prime_card [Fintype α] : (Fintype.card α).Prime := by
  have h0 : 0 < Fintype.card α := Fintype.card_pos_iff.2 (by infer_instance)
  obtain ⟨g, hg⟩ := IsCyclic.exists_generator (α := α)
  rw [Nat.prime_def_lt'']
  refine' ⟨Fintype.one_lt_card_iff_nontrivial.2 inferInstance, fun n hn => _⟩
  refine' (IsSimpleOrder.eq_bot_or_eq_top (Subgroup.zpowers (g ^ n))).symm.imp _ _
  · intro h
    have hgo := orderOf_pow (n := n) g
    rw [orderOf_eq_card_of_forall_mem_zpowers hg, Nat.gcd_eq_right_iff_dvd.1 hn,
      orderOf_eq_card_of_forall_mem_zpowers, eq_comm,
      Nat.div_eq_iff_eq_mul_left (Nat.pos_of_dvd_of_pos hn h0) hn] at hgo
    · exact (mul_left_cancel₀ (ne_of_gt h0) ((mul_one (Fintype.card α)).trans hgo)).symm
    · intro x
      rw [h]
      exact Subgroup.mem_top _
  · intro h
    apply le_antisymm (Nat.le_of_dvd h0 hn)
    rw [← orderOf_eq_card_of_forall_mem_zpowers hg]
    apply orderOf_le_of_pow_eq_one (Nat.pos_of_dvd_of_pos hn h0)
    

Proof state:
case intro.refine'_2
α : Type u
a : α
inst✝² : CommGroup α
inst✝¹ : IsSimpleGroup α
inst✝ : Fintype α
h0 : 0 < Fintype.card α
g : α
hg : ∀ (x : α), x ∈ Subgroup.zpowers g
n : ℕ
hn : n ∣ Fintype.card α
h : Subgroup.zpowers (g ^ n) = ⊥
⊢ g ^ n = 1

Next tactic:
rw [← Subgroup.mem_bot, ← h]
@[to_additive]
theorem prime_card [Fintype α] : (Fintype.card α).Prime := by
  have h0 : 0 < Fintype.card α := Fintype.card_pos_iff.2 (by infer_instance)
  obtain ⟨g, hg⟩ := IsCyclic.exists_generator (α := α)
  rw [Nat.prime_def_lt'']
  refine' ⟨Fintype.one_lt_card_iff_nontrivial.2 inferInstance, fun n hn => _⟩
  refine' (IsSimpleOrder.eq_bot_or_eq_top (Subgroup.zpowers (g ^ n))).symm.imp _ _
  · intro h
    have hgo := orderOf_pow (n := n) g
    rw [orderOf_eq_card_of_forall_mem_zpowers hg, Nat.gcd_eq_right_iff_dvd.1 hn,
      orderOf_eq_card_of_forall_mem_zpowers, eq_comm,
      Nat.div_eq_iff_eq_mul_left (Nat.pos_of_dvd_of_pos hn h0) hn] at hgo
    · exact (mul_left_cancel₀ (ne_of_gt h0) ((mul_one (Fintype.card α)).trans hgo)).symm
    · intro x
      rw [h]
      exact Subgroup.mem_top _
  · intro h
    apply le_antisymm (Nat.le_of_dvd h0 hn)
    rw [← orderOf_eq_card_of_forall_mem_zpowers hg]
    apply orderOf_le_of_pow_eq_one (Nat.pos_of_dvd_of_pos hn h0)
    rw [← Subgroup.mem_bot, ← h]
    

Proof state:
case intro.refine'_2
α : Type u
a : α
inst✝² : CommGroup α
inst✝¹ : IsSimpleGroup α
inst✝ : Fintype α
h0 : 0 < Fintype.card α
g : α
hg : ∀ (x : α), x ∈ Subgroup.zpowers g
n : ℕ
hn : n ∣ Fintype.card α
h : Subgroup.zpowers (g ^ n) = ⊥
⊢ g ^ n ∈ Subgroup.zpowers (g ^ n)

Next tactic:
exact Subgroup.mem_zpowers _
@[to_additive]
theorem CommGroup.is_simple_iff_isCyclic_and_prime_card [Fintype α] [CommGroup α] :
    IsSimpleGroup α ↔ IsCyclic α ∧ (Fintype.card α).Prime := by
  

Proof state:
α : Type u
a : α
inst✝¹ : Fintype α
inst✝ : CommGroup α
⊢ IsSimpleGroup α ↔ IsCyclic α ∧ Nat.Prime (Fintype.card α)

Next tactic:
constructor
@[to_additive]
theorem CommGroup.is_simple_iff_isCyclic_and_prime_card [Fintype α] [CommGroup α] :
    IsSimpleGroup α ↔ IsCyclic α ∧ (Fintype.card α).Prime := by
  constructor
  · 

Proof state:
case mp
α : Type u
a : α
inst✝¹ : Fintype α
inst✝ : CommGroup α
⊢ IsSimpleGroup α → IsCyclic α ∧ Nat.Prime (Fintype.card α)

Next tactic:
intro h
@[to_additive]
theorem CommGroup.is_simple_iff_isCyclic_and_prime_card [Fintype α] [CommGroup α] :
    IsSimpleGroup α ↔ IsCyclic α ∧ (Fintype.card α).Prime := by
  constructor
  · intro h
    

Proof state:
case mp
α : Type u
a : α
inst✝¹ : Fintype α
inst✝ : CommGroup α
h : IsSimpleGroup α
⊢ IsCyclic α ∧ Nat.Prime (Fintype.card α)

Next tactic:
exact ⟨IsSimpleGroup.isCyclic, IsSimpleGroup.prime_card⟩
@[to_additive]
theorem CommGroup.is_simple_iff_isCyclic_and_prime_card [Fintype α] [CommGroup α] :
    IsSimpleGroup α ↔ IsCyclic α ∧ (Fintype.card α).Prime := by
  constructor
  · intro h
    exact ⟨IsSimpleGroup.isCyclic, IsSimpleGroup.prime_card⟩
  · 

Proof state:
case mpr
α : Type u
a : α
inst✝¹ : Fintype α
inst✝ : CommGroup α
⊢ IsCyclic α ∧ Nat.Prime (Fintype.card α) → IsSimpleGroup α

Next tactic:
rintro ⟨_, hp⟩
@[to_additive]
theorem CommGroup.is_simple_iff_isCyclic_and_prime_card [Fintype α] [CommGroup α] :
    IsSimpleGroup α ↔ IsCyclic α ∧ (Fintype.card α).Prime := by
  constructor
  · intro h
    exact ⟨IsSimpleGroup.isCyclic, IsSimpleGroup.prime_card⟩
  · rintro ⟨_, hp⟩
    

Proof state:
case mpr.intro
α : Type u
a : α
inst✝¹ : Fintype α
inst✝ : CommGroup α
left✝ : IsCyclic α
hp : Nat.Prime (Fintype.card α)
⊢ IsSimpleGroup α

Next tactic:
haveI : Fact (Fintype.card α).Prime := ⟨hp⟩
@[to_additive]
theorem CommGroup.is_simple_iff_isCyclic_and_prime_card [Fintype α] [CommGroup α] :
    IsSimpleGroup α ↔ IsCyclic α ∧ (Fintype.card α).Prime := by
  constructor
  · intro h
    exact ⟨IsSimpleGroup.isCyclic, IsSimpleGroup.prime_card⟩
  · rintro ⟨_, hp⟩
    haveI : Fact (Fintype.card α).Prime := ⟨hp⟩
    

Proof state:
case mpr.intro
α : Type u
a : α
inst✝¹ : Fintype α
inst✝ : CommGroup α
left✝ : IsCyclic α
hp : Nat.Prime (Fintype.card α)
this : Fact (Nat.Prime (Fintype.card α))
⊢ IsSimpleGroup α

Next tactic:
exact isSimpleGroup_of_prime_card rfl
instance : IsAddCyclic ℤ := ⟨1, fun n ↦ ⟨n, by 

Proof state:
α : Type u
a : α
n : ℤ
⊢ (fun x => x • 1) n = n

Next tactic:
simp only [smul_eq_mul, mul_one]
instance ZMod.instIsSimpleAddGroup {p : ℕ} [Fact p.Prime] : IsSimpleAddGroup (ZMod p) :=
  AddCommGroup.is_simple_iff_isAddCyclic_and_prime_card.2
    ⟨inferInstance, by 

Proof state:
α : Type u
a : α
p : ℕ
inst✝ : Fact (Nat.Prime p)
⊢ Nat.Prime (Fintype.card (ZMod p))

Next tactic:
simpa using (Fact.out : p.Prime)
@[to_additive]
theorem IsCyclic.exponent_eq_card [Group α] [IsCyclic α] [Fintype α] :
    exponent α = Fintype.card α := by
  

Proof state:
α : Type u
a : α
inst✝² : Group α
inst✝¹ : IsCyclic α
inst✝ : Fintype α
⊢ exponent α = Fintype.card α

Next tactic:
obtain ⟨g, hg⟩ := IsCyclic.exists_generator (α := α)
@[to_additive]
theorem IsCyclic.exponent_eq_card [Group α] [IsCyclic α] [Fintype α] :
    exponent α = Fintype.card α := by
  obtain ⟨g, hg⟩ := IsCyclic.exists_generator (α := α)
  

Proof state:
case intro
α : Type u
a : α
inst✝² : Group α
inst✝¹ : IsCyclic α
inst✝ : Fintype α
g : α
hg : ∀ (x : α), x ∈ Subgroup.zpowers g
⊢ exponent α = Fintype.card α

Next tactic:
apply Nat.dvd_antisymm
@[to_additive]
theorem IsCyclic.exponent_eq_card [Group α] [IsCyclic α] [Fintype α] :
    exponent α = Fintype.card α := by
  obtain ⟨g, hg⟩ := IsCyclic.exists_generator (α := α)
  apply Nat.dvd_antisymm
  · 

Proof state:
case intro.a
α : Type u
a : α
inst✝² : Group α
inst✝¹ : IsCyclic α
inst✝ : Fintype α
g : α
hg : ∀ (x : α), x ∈ Subgroup.zpowers g
⊢ exponent α ∣ Fintype.card α

Next tactic:
rw [← lcm_order_eq_exponent, Finset.lcm_dvd_iff]
@[to_additive]
theorem IsCyclic.exponent_eq_card [Group α] [IsCyclic α] [Fintype α] :
    exponent α = Fintype.card α := by
  obtain ⟨g, hg⟩ := IsCyclic.exists_generator (α := α)
  apply Nat.dvd_antisymm
  · rw [← lcm_order_eq_exponent, Finset.lcm_dvd_iff]
    

Proof state:
case intro.a
α : Type u
a : α
inst✝² : Group α
inst✝¹ : IsCyclic α
inst✝ : Fintype α
g : α
hg : ∀ (x : α), x ∈ Subgroup.zpowers g
⊢ ∀ b ∈ Finset.univ, orderOf b ∣ Fintype.card α

Next tactic:
exact fun b _ => orderOf_dvd_card
@[to_additive]
theorem IsCyclic.exponent_eq_card [Group α] [IsCyclic α] [Fintype α] :
    exponent α = Fintype.card α := by
  obtain ⟨g, hg⟩ := IsCyclic.exists_generator (α := α)
  apply Nat.dvd_antisymm
  · rw [← lcm_order_eq_exponent, Finset.lcm_dvd_iff]
    exact fun b _ => orderOf_dvd_card
  

Proof state:
case intro.a
α : Type u
a : α
inst✝² : Group α
inst✝¹ : IsCyclic α
inst✝ : Fintype α
g : α
hg : ∀ (x : α), x ∈ Subgroup.zpowers g
⊢ Fintype.card α ∣ exponent α

Next tactic:
rw [← orderOf_eq_card_of_forall_mem_zpowers hg]