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

tactic: classical
  calc
    card α = card (Σy : Quotient (orbitRel G α), { x // Quotient.mk'' x = y }) :=
      card_congr (Equiv.sigmaFiberEquiv (@Quotient.mk'' _ (orbitRel G α))).symm
    _ = ∑ a : Quotient (orbitRel G α), card { x // Quotient.mk'' x = a } := card_sigma
    _ ≡ ∑ _a : fixedPoints G α, 1 [MOD p] := ?_
    _ = _ := by simp
  rw [← ZMod.eq_iff_modEq_nat p, Nat.cast_sum, Nat.cast_sum]
  have key :
    ∀ x,
      card { y // (Quotient.mk'' y : Quotient (orbitRel G α)) = Quotient.mk'' x } =
        card (orbit G x) :=
    fun x => by simp only [Quotient.eq'']; congr
  refine
    Eq.symm
      (Finset.sum_bij_ne_zero (fun a _ _ => Quotient.mk'' a.1) (fun _ _ _ => Finset.mem_univ _)
        (fun a₁ _ _ a₂ _ _ h =>
          Subtype.eq (mem_fixedPoints'.mp a₂.2 a₁.1 (Quotient.exact' h)))
        (fun b => Quotient.inductionOn' b fun b _ hb => ?_) fun a ha _ => by
        rw [key, mem_fixedPoints_iff_card_orbit_eq_one.mp a.2])
  obtain ⟨k, hk⟩ := hG.card_orbit b
  have : k = 0 :=
    Nat.le_zero.1
      (Nat.le_of_lt_succ
        (lt_of_not_ge
          (mt (pow_dvd_pow p)
            (by
              rwa [pow_one, ← hk, ← Nat.modEq_zero_iff_dvd, ← ZMod.eq_iff_modEq_nat, ← key,
                Nat.cast_zero]))))
  exact
    ⟨⟨b, mem_fixedPoints_iff_card_orbit_eq_one.2 <| by rw [hk, this, pow_zero]⟩,
      Finset.mem_univ _, ne_of_eq_of_ne Nat.cast_one one_ne_zero, rfl⟩
state_before: p : ℕ
G : Type u_1
inst✝³ : Group G
hG : IsPGroup p G
hp : Fact (Nat.Prime p)
α : Type u_2
inst✝² : MulAction G α
inst✝¹ : Fintype α
inst✝ : Fintype ↑(fixedPoints G α)
⊢ card α ≡ card ↑(fixedPoints G α) [MOD p]
state_after: no goals

tactic: calc
  card α = card (Σy : Quotient (orbitRel G α), { x // Quotient.mk'' x = y }) :=
    card_congr (Equiv.sigmaFiberEquiv (@Quotient.mk'' _ (orbitRel G α))).symm
  _ = ∑ a : Quotient (orbitRel G α), card { x // Quotient.mk'' x = a } := card_sigma
  _ ≡ ∑ _a : fixedPoints G α, 1 [MOD p] := ?_
  _ = _ := by simp
state_before: p : ℕ
G : Type u_1
inst✝³ : Group G
hG : IsPGroup p G
hp : Fact (Nat.Prime p)
α : Type u_2
inst✝² : MulAction G α
inst✝¹ : Fintype α
inst✝ : Fintype ↑(fixedPoints G α)
⊢ card α ≡ card ↑(fixedPoints G α) [MOD p]
state_after: p : ℕ
G : Type u_1
inst✝³ : Group G
hG : IsPGroup p G
hp : Fact (Nat.Prime p)
α : Type u_2
inst✝² : MulAction G α
inst✝¹ : Fintype α
inst✝ : Fintype ↑(fixedPoints G α)
⊢ ∑ a : Quotient (orbitRel G α), card { x // Quotient.mk'' x = a } ≡ ∑ _a : ↑(fixedPoints G α), 1 [MOD p]

tactic: rw [← ZMod.eq_iff_modEq_nat p, Nat.cast_sum, Nat.cast_sum]
state_before: p : ℕ
G : Type u_1
inst✝³ : Group G
hG : IsPGroup p G
hp : Fact (Nat.Prime p)
α : Type u_2
inst✝² : MulAction G α
inst✝¹ : Fintype α
inst✝ : Fintype ↑(fixedPoints G α)
⊢ ∑ a : Quotient (orbitRel G α), card { x // Quotient.mk'' x = a } ≡ ∑ _a : ↑(fixedPoints G α), 1 [MOD p]
state_after: p : ℕ
G : Type u_1
inst✝³ : Group G
hG : IsPGroup p G
hp : Fact (Nat.Prime p)
α : Type u_2
inst✝² : MulAction G α
inst✝¹ : Fintype α
inst✝ : Fintype ↑(fixedPoints G α)
⊢ ∑ x : Quotient (orbitRel G α), ↑(card { x_1 // Quotient.mk'' x_1 = x }) = ∑ x : ↑(fixedPoints G α), ↑1

tactic: have key :
  ∀ x,
    card { y // (Quotient.mk'' y : Quotient (orbitRel G α)) = Quotient.mk'' x } =
      card (orbit G x) :=
  fun x => by simp only [Quotient.eq'']; congr
state_before: p : ℕ
G : Type u_1
inst✝³ : Group G
hG : IsPGroup p G
hp : Fact (Nat.Prime p)
α : Type u_2
inst✝² : MulAction G α
inst✝¹ : Fintype α
inst✝ : Fintype ↑(fixedPoints G α)
⊢ ∑ x : Quotient (orbitRel G α), ↑(card { x_1 // Quotient.mk'' x_1 = x }) = ∑ x : ↑(fixedPoints G α), ↑1
state_after: p : ℕ
G : Type u_1
inst✝³ : Group G
hG : IsPGroup p G
hp : Fact (Nat.Prime p)
α : Type u_2
inst✝² : MulAction G α
inst✝¹ : Fintype α
inst✝ : Fintype ↑(fixedPoints G α)
key : ∀ (x : α), card { y // Quotient.mk'' y = Quotient.mk'' x } = card ↑(orbit G x)
⊢ ∑ x : Quotient (orbitRel G α), ↑(card { x_1 // Quotient.mk'' x_1 = x }) = ∑ x : ↑(fixedPoints G α), ↑1

tactic: refine
  Eq.symm
    (Finset.sum_bij_ne_zero (fun a _ _ => Quotient.mk'' a.1) (fun _ _ _ => Finset.mem_univ _)
      (fun a₁ _ _ a₂ _ _ h =>
        Subtype.eq (mem_fixedPoints'.mp a₂.2 a₁.1 (Quotient.exact' h)))
      (fun b => Quotient.inductionOn' b fun b _ hb => ?_) fun a ha _ => by
      rw [key, mem_fixedPoints_iff_card_orbit_eq_one.mp a.2])
state_before: p : ℕ
G : Type u_1
inst✝³ : Group G
hG : IsPGroup p G
hp : Fact (Nat.Prime p)
α : Type u_2
inst✝² : MulAction G α
inst✝¹ : Fintype α
inst✝ : Fintype ↑(fixedPoints G α)
key : ∀ (x : α), card { y // Quotient.mk'' y = Quotient.mk'' x } = card ↑(orbit G x)
⊢ ∑ x : Quotient (orbitRel G α), ↑(card { x_1 // Quotient.mk'' x_1 = x }) = ∑ x : ↑(fixedPoints G α), ↑1
state_after: p : ℕ
G : Type u_1
inst✝³ : Group G
hG : IsPGroup p G
hp : Fact (Nat.Prime p)
α : Type u_2
inst✝² : MulAction G α
inst✝¹ : Fintype α
inst✝ : Fintype ↑(fixedPoints G α)
key : ∀ (x : α), card { y // Quotient.mk'' y = Quotient.mk'' x } = card ↑(orbit G x)
b✝ : Quotient (orbitRel G α)
b : α
x✝ : Quotient.mk'' b ∈ Finset.univ
hb : ↑(card { x // Quotient.mk'' x = Quotient.mk'' b }) ≠ 0
⊢ ∃ a, ∃ (h₁ : a ∈ Finset.univ) (h₂ : ↑1 ≠ 0), (fun a x x => Quotient.mk'' ↑a) a h₁ h₂ = Quotient.mk'' b

tactic: obtain ⟨k, hk⟩ := hG.card_orbit b
state_before: p : ℕ
G : Type u_1
inst✝³ : Group G
hG : IsPGroup p G
hp : Fact (Nat.Prime p)
α : Type u_2
inst✝² : MulAction G α
inst✝¹ : Fintype α
inst✝ : Fintype ↑(fixedPoints G α)
key : ∀ (x : α), card { y // Quotient.mk'' y = Quotient.mk'' x } = card ↑(orbit G x)
b✝ : Quotient (orbitRel G α)
b : α
x✝ : Quotient.mk'' b ∈ Finset.univ
hb : ↑(card { x // Quotient.mk'' x = Quotient.mk'' b }) ≠ 0
⊢ ∃ a, ∃ (h₁ : a ∈ Finset.univ) (h₂ : ↑1 ≠ 0), (fun a x x => Quotient.mk'' ↑a) a h₁ h₂ = Quotient.mk'' b
state_after: case intro
p : ℕ
G : Type u_1
inst✝³ : Group G
hG : IsPGroup p G
hp : Fact (Nat.Prime p)
α : Type u_2
inst✝² : MulAction G α
inst✝¹ : Fintype α
inst✝ : Fintype ↑(fixedPoints G α)
key : ∀ (x : α), card { y // Quotient.mk'' y = Quotient.mk'' x } = card ↑(orbit G x)
b✝ : Quotient (orbitRel G α)
b : α
x✝ : Quotient.mk'' b ∈ Finset.univ
hb : ↑(card { x // Quotient.mk'' x = Quotient.mk'' b }) ≠ 0
k : ℕ
hk : card ↑(orbit G b) = p ^ k
⊢ ∃ a, ∃ (h₁ : a ∈ Finset.univ) (h₂ : ↑1 ≠ 0), (fun a x x => Quotient.mk'' ↑a) a h₁ h₂ = Quotient.mk'' b

tactic: have : k = 0 :=
  Nat.le_zero.1
    (Nat.le_of_lt_succ
      (lt_of_not_ge
        (mt (pow_dvd_pow p)
          (by
            rwa [pow_one, ← hk, ← Nat.modEq_zero_iff_dvd, ← ZMod.eq_iff_modEq_nat, ← key,
              Nat.cast_zero]))))
state_before: case intro
p : ℕ
G : Type u_1
inst✝³ : Group G
hG : IsPGroup p G
hp : Fact (Nat.Prime p)
α : Type u_2
inst✝² : MulAction G α
inst✝¹ : Fintype α
inst✝ : Fintype ↑(fixedPoints G α)
key : ∀ (x : α), card { y // Quotient.mk'' y = Quotient.mk'' x } = card ↑(orbit G x)
b✝ : Quotient (orbitRel G α)
b : α
x✝ : Quotient.mk'' b ∈ Finset.univ
hb : ↑(card { x // Quotient.mk'' x = Quotient.mk'' b }) ≠ 0
k : ℕ
hk : card ↑(orbit G b) = p ^ k
⊢ ∃ a, ∃ (h₁ : a ∈ Finset.univ) (h₂ : ↑1 ≠ 0), (fun a x x => Quotient.mk'' ↑a) a h₁ h₂ = Quotient.mk'' b
state_after: case intro
p : ℕ
G : Type u_1
inst✝³ : Group G
hG : IsPGroup p G
hp : Fact (Nat.Prime p)
α : Type u_2
inst✝² : MulAction G α
inst✝¹ : Fintype α
inst✝ : Fintype ↑(fixedPoints G α)
key : ∀ (x : α), card { y // Quotient.mk'' y = Quotient.mk'' x } = card ↑(orbit G x)
b✝ : Quotient (orbitRel G α)
b : α
x✝ : Quotient.mk'' b ∈ Finset.univ
hb : ↑(card { x // Quotient.mk'' x = Quotient.mk'' b }) ≠ 0
k : ℕ
hk : card ↑(orbit G b) = p ^ k
this : k = 0
⊢ ∃ a, ∃ (h₁ : a ∈ Finset.univ) (h₂ : ↑1 ≠ 0), (fun a x x => Quotient.mk'' ↑a) a h₁ h₂ = Quotient.mk'' b

tactic: exact
  ⟨⟨b, mem_fixedPoints_iff_card_orbit_eq_one.2 <| by rw [hk, this, pow_zero]⟩,
    Finset.mem_univ _, ne_of_eq_of_ne Nat.cast_one one_ne_zero, rfl⟩
state_before: case intro
p : ℕ
G : Type u_1
inst✝³ : Group G
hG : IsPGroup p G
hp : Fact (Nat.Prime p)
α : Type u_2
inst✝² : MulAction G α
inst✝¹ : Fintype α
inst✝ : Fintype ↑(fixedPoints G α)
key : ∀ (x : α), card { y // Quotient.mk'' y = Quotient.mk'' x } = card ↑(orbit G x)
b✝ : Quotient (orbitRel G α)
b : α
x✝ : Quotient.mk'' b ∈ Finset.univ
hb : ↑(card { x // Quotient.mk'' x = Quotient.mk'' b }) ≠ 0
k : ℕ
hk : card ↑(orbit G b) = p ^ k
this : k = 0
⊢ ∃ a, ∃ (h₁ : a ∈ Finset.univ) (h₂ : ↑1 ≠ 0), (fun a x x => Quotient.mk'' ↑a) a h₁ h₂ = Quotient.mk'' b
state_after: no goals

tactic: simp
state_before: p : ℕ
G : Type u_1
inst✝³ : Group G
hG : IsPGroup p G
hp : Fact (Nat.Prime p)
α : Type u_2
inst✝² : MulAction G α
inst✝¹ : Fintype α
inst✝ : Fintype ↑(fixedPoints G α)
⊢ ∑ _a : ↑(fixedPoints G α), 1 = card ↑(fixedPoints G α)
state_after: no goals

tactic: simp only [Quotient.eq'']
state_before: p : ℕ
G : Type u_1
inst✝³ : Group G
hG : IsPGroup p G
hp : Fact (Nat.Prime p)
α : Type u_2
inst✝² : MulAction G α
inst✝¹ : Fintype α
inst✝ : Fintype ↑(fixedPoints G α)
x : α
⊢ card { y // Quotient.mk'' y = Quotient.mk'' x } = card ↑(orbit G x)
state_after: p : ℕ
G : Type u_1
inst✝³ : Group G
hG : IsPGroup p G
hp : Fact (Nat.Prime p)
α : Type u_2
inst✝² : MulAction G α
inst✝¹ : Fintype α
inst✝ : Fintype ↑(fixedPoints G α)
x : α
⊢ card { y // Setoid.r y x } = card ↑(orbit G x)

tactic: congr
state_before: p : ℕ
G : Type u_1
inst✝³ : Group G
hG : IsPGroup p G
hp : Fact (Nat.Prime p)
α : Type u_2
inst✝² : MulAction G α
inst✝¹ : Fintype α
inst✝ : Fintype ↑(fixedPoints G α)
x : α
⊢ card { y // Setoid.r y x } = card ↑(orbit G x)
state_after: no goals

tactic: rw [key, mem_fixedPoints_iff_card_orbit_eq_one.mp a.2]
state_before: p : ℕ
G : Type u_1
inst✝³ : Group G
hG : IsPGroup p G
hp : Fact (Nat.Prime p)
α : Type u_2
inst✝² : MulAction G α
inst✝¹ : Fintype α
inst✝ : Fintype ↑(fixedPoints G α)
key : ∀ (x : α), card { y // Quotient.mk'' y = Quotient.mk'' x } = card ↑(orbit G x)
a : ↑(fixedPoints G α)
ha : a ∈ Finset.univ
x✝ : ↑1 ≠ 0
⊢ ↑1 = ↑(card { x // Quotient.mk'' x = (fun a x x => Quotient.mk'' ↑a) a ha x✝ })
state_after: no goals

tactic: rwa [pow_one, ← hk, ← Nat.modEq_zero_iff_dvd, ← ZMod.eq_iff_modEq_nat, ← key,
  Nat.cast_zero]
state_before: p : ℕ
G : Type u_1
inst✝³ : Group G
hG : IsPGroup p G
hp : Fact (Nat.Prime p)
α : Type u_2
inst✝² : MulAction G α
inst✝¹ : Fintype α
inst✝ : Fintype ↑(fixedPoints G α)
key : ∀ (x : α), card { y // Quotient.mk'' y = Quotient.mk'' x } = card ↑(orbit G x)
b✝ : Quotient (orbitRel G α)
b : α
x✝ : Quotient.mk'' b ∈ Finset.univ
hb : ↑(card { x // Quotient.mk'' x = Quotient.mk'' b }) ≠ 0
k : ℕ
hk : card ↑(orbit G b) = p ^ k
⊢ ¬p ^ Nat.succ 0 ∣ p ^ k
state_after: no goals

tactic: rw [hk, this, pow_zero]
state_before: p : ℕ
G : Type u_1
inst✝³ : Group G
hG : IsPGroup p G
hp : Fact (Nat.Prime p)
α : Type u_2
inst✝² : MulAction G α
inst✝¹ : Fintype α
inst✝ : Fintype ↑(fixedPoints G α)
key : ∀ (x : α), card { y // Quotient.mk'' y = Quotient.mk'' x } = card ↑(orbit G x)
b✝ : Quotient (orbitRel G α)
b : α
x✝ : Quotient.mk'' b ∈ Finset.univ
hb : ↑(card { x // Quotient.mk'' x = Quotient.mk'' b }) ≠ 0
k : ℕ
hk : card ↑(orbit G b) = p ^ k
this : k = 0
⊢ card ↑(orbit G b) = 1
state_after: no goals