Theorem: Nat.Prime.exists_orderOf_eq_pow_factorization_exponent
File: Mathlib/GroupTheory/Exponent.lean

tactic: haveI := Fact.mk hp
state_before: G : Type u
inst✝ : Monoid G
p : ℕ
hp : Nat.Prime p
⊢ ∃ g, orderOf g = p ^ ↑(Nat.factorization (exponent G)) p

tactic: rcases eq_or_ne ((exponent G).factorization p) 0 with (h | h)
state_before: G : Type u
inst✝ : Monoid G
p : ℕ
hp : Nat.Prime p
this : Fact (Nat.Prime p)
⊢ ∃ g, orderOf g = p ^ ↑(Nat.factorization (exponent G)) p

tactic: have he : 0 < exponent G :=
  Ne.bot_lt fun ht => by
    rw [ht] at h
    apply h
    rw [bot_eq_zero, Nat.factorization_zero, Finsupp.zero_apply]
state_before: case inr
G : Type u
inst✝ : Monoid G
p : ℕ
hp : Nat.Prime p
this : Fact (Nat.Prime p)
h : ↑(Nat.factorization (exponent G)) p ≠ 0
⊢ ∃ g, orderOf g = p ^ ↑(Nat.factorization (exponent G)) p

tactic: rw [← Finsupp.mem_support_iff] at h
state_before: case inr
G : Type u
inst✝ : Monoid G
p : ℕ
hp : Nat.Prime p
this : Fact (Nat.Prime p)
h : ↑(Nat.factorization (exponent G)) p ≠ 0
he : 0 < exponent G
⊢ ∃ g, orderOf g = p ^ ↑(Nat.factorization (exponent G)) p

tactic: obtain ⟨k, hk : exponent G = p ^ _ * k⟩ := Nat.ord_proj_dvd _ _
state_before: case inr.intro
G : Type u
inst✝ : Monoid G
p : ℕ
hp : Nat.Prime p
this : Fact (Nat.Prime p)
h : p ∈ (Nat.factorization (exponent G)).support
he : 0 < exponent G
g : G
hg : g ^ (exponent G / p) ≠ 1
⊢ ∃ g, orderOf g = p ^ ↑(Nat.factorization (exponent G)) p

tactic: obtain ⟨t, ht⟩ := Nat.exists_eq_succ_of_ne_zero (Finsupp.mem_support_iff.mp h)
state_before: case inr.intro.intro
G : Type u
inst✝ : Monoid G
p : ℕ
hp : Nat.Prime p
this : Fact (Nat.Prime p)
h : p ∈ (Nat.factorization (exponent G)).support
he : 0 < exponent G
g : G
hg : g ^ (exponent G / p) ≠ 1
k : ℕ
hk : exponent G = p ^ ↑(Nat.factorization (exponent G)) p * k
⊢ ∃ g, orderOf g = p ^ ↑(Nat.factorization (exponent G)) p

tactic: refine' ⟨g ^ k, _⟩
state_before: case inr.intro.intro.intro
G : Type u
inst✝ : Monoid G
p : ℕ
hp : Nat.Prime p
this : Fact (Nat.Prime p)
h : p ∈ (Nat.factorization (exponent G)).support
he : 0 < exponent G
g : G
hg : g ^ (exponent G / p) ≠ 1
k : ℕ
hk : exponent G = p ^ ↑(Nat.factorization (exponent G)) p * k
t : ℕ
ht : ↑(Nat.factorization (exponent G)) p = Nat.succ t
⊢ ∃ g, orderOf g = p ^ ↑(Nat.factorization (exponent G)) p

tactic: rw [ht]
state_before: case inr.intro.intro.intro
G : Type u
inst✝ : Monoid G
p : ℕ
hp : Nat.Prime p
this : Fact (Nat.Prime p)
h : p ∈ (Nat.factorization (exponent G)).support
he : 0 < exponent G
g : G
hg : g ^ (exponent G / p) ≠ 1
k : ℕ
hk : exponent G = p ^ ↑(Nat.factorization (exponent G)) p * k
t : ℕ
ht : ↑(Nat.factorization (exponent G)) p = Nat.succ t
⊢ orderOf (g ^ k) = p ^ ↑(Nat.factorization (exponent G)) p

tactic: apply orderOf_eq_prime_pow
state_before: case inr.intro.intro.intro
G : Type u
inst✝ : Monoid G
p : ℕ
hp : Nat.Prime p
this : Fact (Nat.Prime p)
h : p ∈ (Nat.factorization (exponent G)).support
he : 0 < exponent G
g : G
hg : g ^ (exponent G / p) ≠ 1
k : ℕ
hk : exponent G = p ^ ↑(Nat.factorization (exponent G)) p * k
t : ℕ
ht : ↑(Nat.factorization (exponent G)) p = Nat.succ t
⊢ orderOf (g ^ k) = p ^ Nat.succ t

tactic: refine' ⟨1, by rw [h, pow_zero, orderOf_one]⟩
state_before: case inl
G : Type u
inst✝ : Monoid G
p : ℕ
hp : Nat.Prime p
this : Fact (Nat.Prime p)
h : ↑(Nat.factorization (exponent G)) p = 0
⊢ ∃ g, orderOf g = p ^ ↑(Nat.factorization (exponent G)) p

tactic: rw [h, pow_zero, orderOf_one]
state_before: G : Type u
inst✝ : Monoid G
p : ℕ
hp : Nat.Prime p
this : Fact (Nat.Prime p)
h : ↑(Nat.factorization (exponent G)) p = 0
⊢ orderOf 1 = p ^ ↑(Nat.factorization (exponent G)) p

tactic: rw [ht] at h
state_before: G : Type u
inst✝ : Monoid G
p : ℕ
hp : Nat.Prime p
this : Fact (Nat.Prime p)
h : ↑(Nat.factorization (exponent G)) p ≠ 0
ht : exponent G = ⊥
⊢ False

tactic: apply h
state_before: G : Type u
inst✝ : Monoid G
p : ℕ
hp : Nat.Prime p
this : Fact (Nat.Prime p)
h : ↑(Nat.factorization ⊥) p ≠ 0
ht : exponent G = ⊥
⊢ False

tactic: rw [bot_eq_zero, Nat.factorization_zero, Finsupp.zero_apply]
state_before: G : Type u
inst✝ : Monoid G
p : ℕ
hp : Nat.Prime p
this : Fact (Nat.Prime p)
h : ↑(Nat.factorization ⊥) p ≠ 0
ht : exponent G = ⊥
⊢ ↑(Nat.factorization ⊥) p = 0

tactic: suffices key : ¬exponent G ∣ exponent G / p
state_before: G : Type u
inst✝ : Monoid G
p : ℕ
hp : Nat.Prime p
this : Fact (Nat.Prime p)
h : p ∈ (Nat.factorization (exponent G)).support
he : 0 < exponent G
⊢ ∃ g, g ^ (exponent G / p) ≠ 1

tactic: exact fun hd =>
  hp.one_lt.not_le
    ((mul_le_iff_le_one_left he).mp <|
      Nat.le_of_dvd he <| Nat.mul_dvd_of_dvd_div (Nat.dvd_of_mem_factorization h) hd)
state_before: case key
G : Type u
inst✝ : Monoid G
p : ℕ
hp : Nat.Prime p
this : Fact (Nat.Prime p)
h : p ∈ (Nat.factorization (exponent G)).support
he : 0 < exponent G
⊢ ¬exponent G ∣ exponent G / p

tactic: simpa using mt (exponent_dvd_of_forall_pow_eq_one G (exponent G / p)) key
state_before: G : Type u
inst✝ : Monoid G
p : ℕ
hp : Nat.Prime p
this : Fact (Nat.Prime p)
h : p ∈ (Nat.factorization (exponent G)).support
he : 0 < exponent G
key : ¬exponent G ∣ exponent G / p
⊢ ∃ g, g ^ (exponent G / p) ≠ 1

tactic: rwa [hk, mul_comm, ht, pow_succ', ← mul_assoc, Nat.mul_div_cancel _ hp.pos, pow_mul] at hg
state_before: case inr.intro.intro.intro.hnot
G : Type u
inst✝ : Monoid G
p : ℕ
hp : Nat.Prime p
this : Fact (Nat.Prime p)
h : p ∈ (Nat.factorization (exponent G)).support
he : 0 < exponent G
g : G
hg : g ^ (exponent G / p) ≠ 1
k : ℕ
hk : exponent G = p ^ ↑(Nat.factorization (exponent G)) p * k
t : ℕ
ht : ↑(Nat.factorization (exponent G)) p = Nat.succ t
⊢ ¬(g ^ k) ^ p ^ t = 1

tactic: rw [← Nat.succ_eq_add_one, ← ht, ← pow_mul, mul_comm, ← hk]
state_before: case inr.intro.intro.intro.hfin
G : Type u
inst✝ : Monoid G
p : ℕ
hp : Nat.Prime p
this : Fact (Nat.Prime p)
h : p ∈ (Nat.factorization (exponent G)).support
he : 0 < exponent G
g : G
hg : g ^ (exponent G / p) ≠ 1
k : ℕ
hk : exponent G = p ^ ↑(Nat.factorization (exponent G)) p * k
t : ℕ
ht : ↑(Nat.factorization (exponent G)) p = Nat.succ t
⊢ (g ^ k) ^ p ^ (t + 1) = 1

tactic: exact pow_exponent_eq_one g
state_before: case inr.intro.intro.intro.hfin
G : Type u
inst✝ : Monoid G
p : ℕ
hp : Nat.Prime p
this : Fact (Nat.Prime p)
h : p ∈ (Nat.factorization (exponent G)).support
he : 0 < exponent G
g : G
hg : g ^ (exponent G / p) ≠ 1
k : ℕ
hk : exponent G = p ^ ↑(Nat.factorization (exponent G)) p * k
t : ℕ
ht : ↑(Nat.factorization (exponent G)) p = Nat.succ t
⊢ g ^ exponent G = 1