Theorem: IsPGroup.iff_card
File: Mathlib/GroupTheory/PGroup.lean

tactic: have hG : card G ≠ 0 := card_ne_zero
state_before: p : ℕ
G : Type u_1
inst✝² : Group G
inst✝¹ : Fact (Nat.Prime p)
inst✝ : Fintype G
⊢ IsPGroup p G ↔ ∃ n, card G = p ^ n
state_after: p : ℕ
G : Type u_1
inst✝² : Group G
inst✝¹ : Fact (Nat.Prime p)
inst✝ : Fintype G
hG : card G ≠ 0
⊢ IsPGroup p G ↔ ∃ n, card G = p ^ n

tactic: refine ⟨fun h => ?_, fun ⟨n, hn⟩ => of_card hn⟩
state_before: p : ℕ
G : Type u_1
inst✝² : Group G
inst✝¹ : Fact (Nat.Prime p)
inst✝ : Fintype G
hG : card G ≠ 0
⊢ IsPGroup p G ↔ ∃ n, card G = p ^ n
state_after: p : ℕ
G : Type u_1
inst✝² : Group G
inst✝¹ : Fact (Nat.Prime p)
inst✝ : Fintype G
hG : card G ≠ 0
h : IsPGroup p G
⊢ ∃ n, card G = p ^ n

tactic: suffices ∀ q ∈ Nat.factors (card G), q = p by
  use (card G).factors.length
  rw [← List.prod_replicate, ← List.eq_replicate_of_mem this, Nat.prod_factors hG]
state_before: p : ℕ
G : Type u_1
inst✝² : Group G
inst✝¹ : Fact (Nat.Prime p)
inst✝ : Fintype G
hG : card G ≠ 0
h : IsPGroup p G
⊢ ∃ n, card G = p ^ n
state_after: p : ℕ
G : Type u_1
inst✝² : Group G
inst✝¹ : Fact (Nat.Prime p)
inst✝ : Fintype G
hG : card G ≠ 0
h : IsPGroup p G
⊢ ∀ q ∈ (card G).factors, q = p

tactic: intro q hq
state_before: p : ℕ
G : Type u_1
inst✝² : Group G
inst✝¹ : Fact (Nat.Prime p)
inst✝ : Fintype G
hG : card G ≠ 0
h : IsPGroup p G
⊢ ∀ q ∈ (card G).factors, q = p
state_after: p : ℕ
G : Type u_1
inst✝² : Group G
inst✝¹ : Fact (Nat.Prime p)
inst✝ : Fintype G
hG : card G ≠ 0
h : IsPGroup p G
q : ℕ
hq : q ∈ (card G).factors
⊢ q = p

tactic: obtain ⟨hq1, hq2⟩ := (Nat.mem_factors hG).mp hq
state_before: p : ℕ
G : Type u_1
inst✝² : Group G
inst✝¹ : Fact (Nat.Prime p)
inst✝ : Fintype G
hG : card G ≠ 0
h : IsPGroup p G
q : ℕ
hq : q ∈ (card G).factors
⊢ q = p
state_after: case intro
p : ℕ
G : Type u_1
inst✝² : Group G
inst✝¹ : Fact (Nat.Prime p)
inst✝ : Fintype G
hG : card G ≠ 0
h : IsPGroup p G
q : ℕ
hq : q ∈ (card G).factors
hq1 : Nat.Prime q
hq2 : q ∣ card G
⊢ q = p

tactic: haveI : Fact q.Prime := ⟨hq1⟩
state_before: case intro
p : ℕ
G : Type u_1
inst✝² : Group G
inst✝¹ : Fact (Nat.Prime p)
inst✝ : Fintype G
hG : card G ≠ 0
h : IsPGroup p G
q : ℕ
hq : q ∈ (card G).factors
hq1 : Nat.Prime q
hq2 : q ∣ card G
⊢ q = p
state_after: case intro
p : ℕ
G : Type u_1
inst✝² : Group G
inst✝¹ : Fact (Nat.Prime p)
inst✝ : Fintype G
hG : card G ≠ 0
h : IsPGroup p G
q : ℕ
hq : q ∈ (card G).factors
hq1 : Nat.Prime q
hq2 : q ∣ card G
this : Fact (Nat.Prime q)
⊢ q = p

tactic: obtain ⟨g, hg⟩ := exists_prime_orderOf_dvd_card q hq2
state_before: case intro
p : ℕ
G : Type u_1
inst✝² : Group G
inst✝¹ : Fact (Nat.Prime p)
inst✝ : Fintype G
hG : card G ≠ 0
h : IsPGroup p G
q : ℕ
hq : q ∈ (card G).factors
hq1 : Nat.Prime q
hq2 : q ∣ card G
this : Fact (Nat.Prime q)
⊢ q = p
state_after: case intro.intro
p : ℕ
G : Type u_1
inst✝² : Group G
inst✝¹ : Fact (Nat.Prime p)
inst✝ : Fintype G
hG : card G ≠ 0
h : IsPGroup p G
q : ℕ
hq : q ∈ (card G).factors
hq1 : Nat.Prime q
hq2 : q ∣ card G
this : Fact (Nat.Prime q)
g : G
hg : orderOf g = q
⊢ q = p

tactic: obtain ⟨k, hk⟩ := (iff_orderOf.mp h) g
state_before: case intro.intro
p : ℕ
G : Type u_1
inst✝² : Group G
inst✝¹ : Fact (Nat.Prime p)
inst✝ : Fintype G
hG : card G ≠ 0
h : IsPGroup p G
q : ℕ
hq : q ∈ (card G).factors
hq1 : Nat.Prime q
hq2 : q ∣ card G
this : Fact (Nat.Prime q)
g : G
hg : orderOf g = q
⊢ q = p
state_after: case intro.intro.intro
p : ℕ
G : Type u_1
inst✝² : Group G
inst✝¹ : Fact (Nat.Prime p)
inst✝ : Fintype G
hG : card G ≠ 0
h : IsPGroup p G
q : ℕ
hq : q ∈ (card G).factors
hq1 : Nat.Prime q
hq2 : q ∣ card G
this : Fact (Nat.Prime q)
g : G
hg : orderOf g = q
k : ℕ
hk : orderOf g = p ^ k
⊢ q = p

tactic: exact (hq1.pow_eq_iff.mp (hg.symm.trans hk).symm).1.symm
state_before: case intro.intro.intro
p : ℕ
G : Type u_1
inst✝² : Group G
inst✝¹ : Fact (Nat.Prime p)
inst✝ : Fintype G
hG : card G ≠ 0
h : IsPGroup p G
q : ℕ
hq : q ∈ (card G).factors
hq1 : Nat.Prime q
hq2 : q ∣ card G
this : Fact (Nat.Prime q)
g : G
hg : orderOf g = q
k : ℕ
hk : orderOf g = p ^ k
⊢ q = p
state_after: no goals

tactic: use (card G).factors.length
state_before: p : ℕ
G : Type u_1
inst✝² : Group G
inst✝¹ : Fact (Nat.Prime p)
inst✝ : Fintype G
hG : card G ≠ 0
h : IsPGroup p G
this : ∀ q ∈ (card G).factors, q = p
⊢ ∃ n, card G = p ^ n
state_after: case h
p : ℕ
G : Type u_1
inst✝² : Group G
inst✝¹ : Fact (Nat.Prime p)
inst✝ : Fintype G
hG : card G ≠ 0
h : IsPGroup p G
this : ∀ q ∈ (card G).factors, q = p
⊢ card G = p ^ (card G).factors.length

tactic: rw [← List.prod_replicate, ← List.eq_replicate_of_mem this, Nat.prod_factors hG]
state_before: case h
p : ℕ
G : Type u_1
inst✝² : Group G
inst✝¹ : Fact (Nat.Prime p)
inst✝ : Fintype G
hG : card G ≠ 0
h : IsPGroup p G
this : ∀ q ∈ (card G).factors, q = p
⊢ card G = p ^ (card G).factors.length
state_after: no goals