Theorem: Monoid.exponent_ne_zero_iff_range_orderOf_finite
File: Mathlib/GroupTheory/Exponent.lean

tactic: refine' ⟨fun he => _, fun he => _⟩
state_before: G : Type u
inst✝ : Monoid G
h : ∀ (g : G), 0 < orderOf g
⊢ exponent G ≠ 0 ↔ Set.Finite (Set.range orderOf)

tactic: by_contra h
state_before: case refine'_1
G : Type u
inst✝ : Monoid G
h : ∀ (g : G), 0 < orderOf g
he : exponent G ≠ 0
⊢ Set.Finite (Set.range orderOf)

tactic: obtain ⟨m, ⟨t, rfl⟩, het⟩ := Set.Infinite.exists_gt h (exponent G)
state_before: case refine'_1
G : Type u
inst✝ : Monoid G
h✝ : ∀ (g : G), 0 < orderOf g
he : exponent G ≠ 0
h : ¬Set.Finite (Set.range orderOf)
⊢ False

tactic: exact pow_ne_one_of_lt_orderOf' he het (pow_exponent_eq_one t)
state_before: case refine'_1.intro.intro.intro
G : Type u
inst✝ : Monoid G
h✝ : ∀ (g : G), 0 < orderOf g
he : exponent G ≠ 0
h : ¬Set.Finite (Set.range orderOf)
t : G
het : exponent G < orderOf t
⊢ False

tactic: lift Set.range (orderOf (G := G)) to Finset ℕ using he with t ht
state_before: case refine'_2
G : Type u
inst✝ : Monoid G
h : ∀ (g : G), 0 < orderOf g
he : Set.Finite (Set.range orderOf)
⊢ exponent G ≠ 0

tactic: have htpos : 0 < t.prod id := by
  refine' Finset.prod_pos fun a ha => _
  rw [← Finset.mem_coe, ht] at ha
  obtain ⟨k, rfl⟩ := ha
  exact h k
state_before: case refine'_2.intro
G : Type u
inst✝ : Monoid G
h : ∀ (g : G), 0 < orderOf g
t : Finset ℕ
ht : ↑t = Set.range orderOf
exponent_ne_zero_iff_range_orderOf_finite✝ exponent_ne_zero_iff_range_orderOf_finite :
  (∀ (g : G), 0 < orderOf g) → (exponent G ≠ 0 ↔ Set.Finite ↑t)
⊢ exponent G ≠ 0

tactic: suffices exponent G ∣ t.prod id by
  intro h
  rw [h, zero_dvd_iff] at this
  exact htpos.ne' this
state_before: case refine'_2.intro
G : Type u
inst✝ : Monoid G
h : ∀ (g : G), 0 < orderOf g
t : Finset ℕ
ht : ↑t = Set.range orderOf
exponent_ne_zero_iff_range_orderOf_finite✝ exponent_ne_zero_iff_range_orderOf_finite :
  (∀ (g : G), 0 < orderOf g) → (exponent G ≠ 0 ↔ Set.Finite ↑t)
htpos : 0 < Finset.prod t id
⊢ exponent G ≠ 0

tactic: refine' exponent_dvd_of_forall_pow_eq_one _ _ fun g => _
state_before: case refine'_2.intro
G : Type u
inst✝ : Monoid G
h : ∀ (g : G), 0 < orderOf g
t : Finset ℕ
ht : ↑t = Set.range orderOf
exponent_ne_zero_iff_range_orderOf_finite✝ exponent_ne_zero_iff_range_orderOf_finite :
  (∀ (g : G), 0 < orderOf g) → (exponent G ≠ 0 ↔ Set.Finite ↑t)
htpos : 0 < Finset.prod t id
⊢ exponent G ∣ Finset.prod t id

tactic: rw [pow_eq_mod_orderOf, Nat.mod_eq_zero_of_dvd, pow_zero g]
state_before: case refine'_2.intro
G : Type u
inst✝ : Monoid G
h : ∀ (g : G), 0 < orderOf g
t : Finset ℕ
ht : ↑t = Set.range orderOf
exponent_ne_zero_iff_range_orderOf_finite✝ exponent_ne_zero_iff_range_orderOf_finite :
  (∀ (g : G), 0 < orderOf g) → (exponent G ≠ 0 ↔ Set.Finite ↑t)
htpos : 0 < Finset.prod t id
g : G
⊢ g ^ Finset.prod t id = 1

tactic: apply Finset.dvd_prod_of_mem
state_before: case refine'_2.intro
G : Type u
inst✝ : Monoid G
h : ∀ (g : G), 0 < orderOf g
t : Finset ℕ
ht : ↑t = Set.range orderOf
exponent_ne_zero_iff_range_orderOf_finite✝ exponent_ne_zero_iff_range_orderOf_finite :
  (∀ (g : G), 0 < orderOf g) → (exponent G ≠ 0 ↔ Set.Finite ↑t)
htpos : 0 < Finset.prod t id
g : G
⊢ orderOf g ∣ Finset.prod t id

tactic: rw [← Finset.mem_coe, ht]
state_before: case refine'_2.intro.ha
G : Type u
inst✝ : Monoid G
h : ∀ (g : G), 0 < orderOf g
t : Finset ℕ
ht : ↑t = Set.range orderOf
exponent_ne_zero_iff_range_orderOf_finite✝ exponent_ne_zero_iff_range_orderOf_finite :
  (∀ (g : G), 0 < orderOf g) → (exponent G ≠ 0 ↔ Set.Finite ↑t)
htpos : 0 < Finset.prod t id
g : G
⊢ Function.minimalPeriod (fun x => g * x) 1 ∈ t

tactic: exact Set.mem_range_self g
state_before: case refine'_2.intro.ha
G : Type u
inst✝ : Monoid G
h : ∀ (g : G), 0 < orderOf g
t : Finset ℕ
ht : ↑t = Set.range orderOf
exponent_ne_zero_iff_range_orderOf_finite✝ exponent_ne_zero_iff_range_orderOf_finite :
  (∀ (g : G), 0 < orderOf g) → (exponent G ≠ 0 ↔ Set.Finite ↑t)
htpos : 0 < Finset.prod t id
g : G
⊢ Function.minimalPeriod (fun x => g * x) 1 ∈ Set.range orderOf

tactic: refine' Finset.prod_pos fun a ha => _
state_before: G : Type u
inst✝ : Monoid G
h : ∀ (g : G), 0 < orderOf g
t : Finset ℕ
ht : ↑t = Set.range orderOf
exponent_ne_zero_iff_range_orderOf_finite✝ exponent_ne_zero_iff_range_orderOf_finite :
  (∀ (g : G), 0 < orderOf g) → (exponent G ≠ 0 ↔ Set.Finite ↑t)
⊢ 0 < Finset.prod t id

tactic: rw [← Finset.mem_coe, ht] at ha
state_before: G : Type u
inst✝ : Monoid G
h : ∀ (g : G), 0 < orderOf g
t : Finset ℕ
ht : ↑t = Set.range orderOf
exponent_ne_zero_iff_range_orderOf_finite✝ exponent_ne_zero_iff_range_orderOf_finite :
  (∀ (g : G), 0 < orderOf g) → (exponent G ≠ 0 ↔ Set.Finite ↑t)
a : ℕ
ha : a ∈ t
⊢ 0 < id a

tactic: obtain ⟨k, rfl⟩ := ha
state_before: G : Type u
inst✝ : Monoid G
h : ∀ (g : G), 0 < orderOf g
t : Finset ℕ
ht : ↑t = Set.range orderOf
exponent_ne_zero_iff_range_orderOf_finite✝ exponent_ne_zero_iff_range_orderOf_finite :
  (∀ (g : G), 0 < orderOf g) → (exponent G ≠ 0 ↔ Set.Finite ↑t)
a : ℕ
ha : a ∈ Set.range orderOf
⊢ 0 < id a

tactic: exact h k
state_before: case intro
G : Type u
inst✝ : Monoid G
h : ∀ (g : G), 0 < orderOf g
t : Finset ℕ
ht : ↑t = Set.range orderOf
exponent_ne_zero_iff_range_orderOf_finite✝ exponent_ne_zero_iff_range_orderOf_finite :
  (∀ (g : G), 0 < orderOf g) → (exponent G ≠ 0 ↔ Set.Finite ↑t)
k : G
⊢ 0 < id (orderOf k)

tactic: intro h
state_before: G : Type u
inst✝ : Monoid G
h : ∀ (g : G), 0 < orderOf g
t : Finset ℕ
ht : ↑t = Set.range orderOf
exponent_ne_zero_iff_range_orderOf_finite✝ exponent_ne_zero_iff_range_orderOf_finite :
  (∀ (g : G), 0 < orderOf g) → (exponent G ≠ 0 ↔ Set.Finite ↑t)
htpos : 0 < Finset.prod t id
this : exponent G ∣ Finset.prod t id
⊢ exponent G ≠ 0

tactic: rw [h, zero_dvd_iff] at this
state_before: G : Type u
inst✝ : Monoid G
h✝ : ∀ (g : G), 0 < orderOf g
t : Finset ℕ
ht : ↑t = Set.range orderOf
exponent_ne_zero_iff_range_orderOf_finite✝ exponent_ne_zero_iff_range_orderOf_finite :
  (∀ (g : G), 0 < orderOf g) → (exponent G ≠ 0 ↔ Set.Finite ↑t)
htpos : 0 < Finset.prod t id
this : exponent G ∣ Finset.prod t id
h : exponent G = 0
⊢ False

tactic: exact htpos.ne' this
state_before: G : Type u
inst✝ : Monoid G
h✝ : ∀ (g : G), 0 < orderOf g
t : Finset ℕ
ht : ↑t = Set.range orderOf
exponent_ne_zero_iff_range_orderOf_finite✝ exponent_ne_zero_iff_range_orderOf_finite :
  (∀ (g : G), 0 < orderOf g) → (exponent G ≠ 0 ↔ Set.Finite ↑t)
htpos : 0 < Finset.prod t id
this : Finset.prod t id = 0
h : exponent G = 0
⊢ False