Theorem: _private.Mathlib.GroupTheory.SpecificGroups.Cyclic.0.card_orderOf_eq_totient_aux₁
File: Mathlib/GroupTheory/SpecificGroups/Cyclic.lean

Proof steps:
state_before: α : Type u
a : α
inst✝² : Group α
inst✝¹ : DecidableEq α
inst✝ : Fintype α
hn : ∀ (n : ℕ), 0 < n → (filter (fun a => a ^ n = 1) univ).card ≤ n
⊢ ∀ {d : ℕ},
    d ∣ Fintype.card α →
      0 < (filter (fun a => orderOf a = d) univ).card → (filter (fun a => orderOf a = d) univ).card = φ d
state_after: α : Type u
a : α
inst✝² : Group α
inst✝¹ : DecidableEq α
inst✝ : Fintype α
hn : ∀ (n : ℕ), 0 < n → (filter (fun a => a ^ n = 1) univ).card ≤ n
d : ℕ
hd : d ∣ Fintype.card α
hpos : 0 < (filter (fun a => orderOf a = d) univ).card
⊢ (filter (fun a => orderOf a = d) univ).card = φ d
tactic: intro d hd hpos
state_before: α : Type u
a : α
inst✝² : Group α
inst✝¹ : DecidableEq α
inst✝ : Fintype α
hn : ∀ (n : ℕ), 0 < n → (filter (fun a => a ^ n = 1) univ).card ≤ n
d : ℕ
hd : d ∣ Fintype.card α
hpos : 0 < (filter (fun a => orderOf a = d) univ).card
⊢ (filter (fun a => orderOf a = d) univ).card = φ d
state_after: case H
α : Type u
a : α
inst✝² : Group α
inst✝¹ : DecidableEq α
inst✝ : Fintype α
hn : ∀ (n : ℕ), 0 < n → (filter (fun a => a ^ n = 1) univ).card ≤ n
d : ℕ
IH :
  ∀ m < d,
    m ∣ Fintype.card α →
      0 < (filter (fun a => orderOf a = m) univ).card → (filter (fun a => orderOf a = m) univ).card = φ m
hd : d ∣ Fintype.card α
hpos : 0 < (filter (fun a => orderOf a = d) univ).card
⊢ (filter (fun a => orderOf a = d) univ).card = φ d
tactic: induction' d using Nat.strongRec' with d IH
state_before: case H
α : Type u
a : α
inst✝² : Group α
inst✝¹ : DecidableEq α
inst✝ : Fintype α
hn : ∀ (n : ℕ), 0 < n → (filter (fun a => a ^ n = 1) univ).card ≤ n
d : ℕ
IH :
  ∀ m < d,
    m ∣ Fintype.card α →
      0 < (filter (fun a => orderOf a = m) univ).card → (filter (fun a => orderOf a = m) univ).card = φ m
hd : d ∣ Fintype.card α
hpos : 0 < (filter (fun a => orderOf a = d) univ).card
⊢ (filter (fun a => orderOf a = d) univ).card = φ d
state_after: case H.inl
α : Type u
a : α
inst✝² : Group α
inst✝¹ : DecidableEq α
inst✝ : Fintype α
hn : ∀ (n : ℕ), 0 < n → (filter (fun a => a ^ n = 1) univ).card ≤ n
IH :
  ∀ m < 0,
    m ∣ Fintype.card α →
      0 < (filter (fun a => orderOf a = m) univ).card → (filter (fun a => orderOf a = m) univ).card = φ m
hd : 0 ∣ Fintype.card α
hpos : 0 < (filter (fun a => orderOf a = 0) univ).card
⊢ (filter (fun a => orderOf a = 0) univ).card = φ 0

case H.inr
α : Type u
a : α
inst✝² : Group α
inst✝¹ : DecidableEq α
inst✝ : Fintype α
hn : ∀ (n : ℕ), 0 < n → (filter (fun a => a ^ n = 1) univ).card ≤ n
d : ℕ
IH :
  ∀ m < d,
    m ∣ Fintype.card α →
      0 < (filter (fun a => orderOf a = m) univ).card → (filter (fun a => orderOf a = m) univ).card = φ m
hd : d ∣ Fintype.card α
hpos : 0 < (filter (fun a => orderOf a = d) univ).card
hd0 : d ≠ 0
⊢ (filter (fun a => orderOf a = d) univ).card = φ d
tactic: rcases Decidable.eq_or_ne d 0 with (rfl | hd0)
state_before: case H.inr
α : Type u
a : α
inst✝² : Group α
inst✝¹ : DecidableEq α
inst✝ : Fintype α
hn : ∀ (n : ℕ), 0 < n → (filter (fun a => a ^ n = 1) univ).card ≤ n
d : ℕ
IH :
  ∀ m < d,
    m ∣ Fintype.card α →
      0 < (filter (fun a => orderOf a = m) univ).card → (filter (fun a => orderOf a = m) univ).card = φ m
hd : d ∣ Fintype.card α
hpos : 0 < (filter (fun a => orderOf a = d) univ).card
hd0 : d ≠ 0
⊢ (filter (fun a => orderOf a = d) univ).card = φ d
state_after: case H.inr.intro
α : Type u
a✝ : α
inst✝² : Group α
inst✝¹ : DecidableEq α
inst✝ : Fintype α
hn : ∀ (n : ℕ), 0 < n → (filter (fun a => a ^ n = 1) univ).card ≤ n
d : ℕ
IH :
  ∀ m < d,
    m ∣ Fintype.card α →
      0 < (filter (fun a => orderOf a = m) univ).card → (filter (fun a => orderOf a = m) univ).card = φ m
hd : d ∣ Fintype.card α
hpos : 0 < (filter (fun a => orderOf a = d) univ).card
hd0 : d ≠ 0
a : α
ha' : a ∈ filter (fun a => orderOf a = d) univ
⊢ (filter (fun a => orderOf a = d) univ).card = φ d
tactic: rcases card_pos.1 hpos with ⟨a, ha'⟩
state_before: case H.inr.intro
α : Type u
a✝ : α
inst✝² : Group α
inst✝¹ : DecidableEq α
inst✝ : Fintype α
hn : ∀ (n : ℕ), 0 < n → (filter (fun a => a ^ n = 1) univ).card ≤ n
d : ℕ
IH :
  ∀ m < d,
    m ∣ Fintype.card α →
      0 < (filter (fun a => orderOf a = m) univ).card → (filter (fun a => orderOf a = m) univ).card = φ m
hd : d ∣ Fintype.card α
hpos : 0 < (filter (fun a => orderOf a = d) univ).card
hd0 : d ≠ 0
a : α
ha' : a ∈ filter (fun a => orderOf a = d) univ
⊢ (filter (fun a => orderOf a = d) univ).card = φ d
state_after: case H.inr.intro
α : Type u
a✝ : α
inst✝² : Group α
inst✝¹ : DecidableEq α
inst✝ : Fintype α
hn : ∀ (n : ℕ), 0 < n → (filter (fun a => a ^ n = 1) univ).card ≤ n
d : ℕ
IH :
  ∀ m < d,
    m ∣ Fintype.card α →
      0 < (filter (fun a => orderOf a = m) univ).card → (filter (fun a => orderOf a = m) univ).card = φ m
hd : d ∣ Fintype.card α
hpos : 0 < (filter (fun a => orderOf a = d) univ).card
hd0 : d ≠ 0
a : α
ha' : a ∈ filter (fun a => orderOf a = d) univ
ha : orderOf a = d
⊢ (filter (fun a => orderOf a = d) univ).card = φ d
tactic: have ha : orderOf a = d := (mem_filter.1 ha').2
state_before: case H.inr.intro
α : Type u
a✝ : α
inst✝² : Group α
inst✝¹ : DecidableEq α
inst✝ : Fintype α
hn : ∀ (n : ℕ), 0 < n → (filter (fun a => a ^ n = 1) univ).card ≤ n
d : ℕ
IH :
  ∀ m < d,
    m ∣ Fintype.card α →
      0 < (filter (fun a => orderOf a = m) univ).card → (filter (fun a => orderOf a = m) univ).card = φ m
hd : d ∣ Fintype.card α
hpos : 0 < (filter (fun a => orderOf a = d) univ).card
hd0 : d ≠ 0
a : α
ha' : a ∈ filter (fun a => orderOf a = d) univ
ha : orderOf a = d
⊢ (filter (fun a => orderOf a = d) univ).card = φ d
state_after: case H.inr.intro
α : Type u
a✝ : α
inst✝² : Group α
inst✝¹ : DecidableEq α
inst✝ : Fintype α
hn : ∀ (n : ℕ), 0 < n → (filter (fun a => a ^ n = 1) univ).card ≤ n
d : ℕ
IH :
  ∀ m < d,
    m ∣ Fintype.card α →
      0 < (filter (fun a => orderOf a = m) univ).card → (filter (fun a => orderOf a = m) univ).card = φ m
hd : d ∣ Fintype.card α
hpos : 0 < (filter (fun a => orderOf a = d) univ).card
hd0 : d ≠ 0
a : α
ha' : a ∈ filter (fun a => orderOf a = d) univ
ha : orderOf a = d
h1 : ∑ m ∈ d.properDivisors, (filter (fun a => orderOf a = m) univ).card = ∑ m ∈ d.properDivisors, φ m
⊢ (filter (fun a => orderOf a = d) univ).card = φ d
tactic: have h1 :
    (∑ m ∈ d.properDivisors, (univ.filter fun a : α => orderOf a = m).card) =
      ∑ m ∈ d.properDivisors, φ m := by
    refine Finset.sum_congr rfl fun m hm => ?_
    simp only [mem_filter, mem_range, mem_properDivisors] at hm
    refine IH m hm.2 (hm.1.trans hd) (Finset.card_pos.2 ⟨a ^ (d / m), ?_⟩)
    simp only [mem_filter, mem_univ, orderOf_pow a, ha, true_and_iff,
      Nat.gcd_eq_right (div_dvd_of_dvd hm.1), Nat.div_div_self hm.1 hd0]
state_before: case H.inr.intro
α : Type u
a✝ : α
inst✝² : Group α
inst✝¹ : DecidableEq α
inst✝ : Fintype α
hn : ∀ (n : ℕ), 0 < n → (filter (fun a => a ^ n = 1) univ).card ≤ n
d : ℕ
IH :
  ∀ m < d,
    m ∣ Fintype.card α →
      0 < (filter (fun a => orderOf a = m) univ).card → (filter (fun a => orderOf a = m) univ).card = φ m
hd : d ∣ Fintype.card α
hpos : 0 < (filter (fun a => orderOf a = d) univ).card
hd0 : d ≠ 0
a : α
ha' : a ∈ filter (fun a => orderOf a = d) univ
ha : orderOf a = d
h1 : ∑ m ∈ d.properDivisors, (filter (fun a => orderOf a = m) univ).card = ∑ m ∈ d.properDivisors, φ m
⊢ (filter (fun a => orderOf a = d) univ).card = φ d
state_after: case H.inr.intro
α : Type u
a✝ : α
inst✝² : Group α
inst✝¹ : DecidableEq α
inst✝ : Fintype α
hn : ∀ (n : ℕ), 0 < n → (filter (fun a => a ^ n = 1) univ).card ≤ n
d : ℕ
IH :
  ∀ m < d,
    m ∣ Fintype.card α →
      0 < (filter (fun a => orderOf a = m) univ).card → (filter (fun a => orderOf a = m) univ).card = φ m
hd : d ∣ Fintype.card α
hpos : 0 < (filter (fun a => orderOf a = d) univ).card
hd0 : d ≠ 0
a : α
ha' : a ∈ filter (fun a => orderOf a = d) univ
ha : orderOf a = d
h1 : ∑ m ∈ d.properDivisors, (filter (fun a => orderOf a = m) univ).card = ∑ m ∈ d.properDivisors, φ m
h2 : ∑ m ∈ d.divisors, (filter (fun a => orderOf a = m) univ).card = ∑ m ∈ d.divisors, φ m
⊢ (filter (fun a => orderOf a = d) univ).card = φ d
tactic: have h2 :
    (∑ m ∈ d.divisors, (univ.filter fun a : α => orderOf a = m).card) =
      ∑ m ∈ d.divisors, φ m := by
    rw [← filter_dvd_eq_divisors hd0, sum_card_orderOf_eq_card_pow_eq_one hd0,
      filter_dvd_eq_divisors hd0, sum_totient, ← ha, card_pow_eq_one_eq_orderOf_aux hn a]
state_before: case H.inr.intro
α : Type u
a✝ : α
inst✝² : Group α
inst✝¹ : DecidableEq α
inst✝ : Fintype α
hn : ∀ (n : ℕ), 0 < n → (filter (fun a => a ^ n = 1) univ).card ≤ n
d : ℕ
IH :
  ∀ m < d,
    m ∣ Fintype.card α →
      0 < (filter (fun a => orderOf a = m) univ).card → (filter (fun a => orderOf a = m) univ).card = φ m
hd : d ∣ Fintype.card α
hpos : 0 < (filter (fun a => orderOf a = d) univ).card
hd0 : d ≠ 0
a : α
ha' : a ∈ filter (fun a => orderOf a = d) univ
ha : orderOf a = d
h1 : ∑ m ∈ d.properDivisors, (filter (fun a => orderOf a = m) univ).card = ∑ m ∈ d.properDivisors, φ m
h2 : ∑ m ∈ d.divisors, (filter (fun a => orderOf a = m) univ).card = ∑ m ∈ d.divisors, φ m
⊢ (filter (fun a => orderOf a = d) univ).card = φ d
state_after: no goals
tactic: simpa [← cons_self_properDivisors hd0, ← h1] using h2