Theorem: Finset.product_self_eq_disjiUnion_perm
File: Mathlib/GroupTheory/Perm/Cycle/Basic.lean

tactic: ext ⟨a, b⟩
state_before: ι : Type u_1
α : Type u_2
β : Type u_3
f : Perm α
s : Finset α
hf : f.IsCycleOn ↑s
⊢ s ×ˢ s = (range s.card).disjiUnion (fun k => map { toFun := fun i => (i, (f ^ k) i), inj' := ⋯ } s) ⋯
state_after: case a.mk
ι : Type u_1
α : Type u_2
β : Type u_3
f : Perm α
s : Finset α
hf : f.IsCycleOn ↑s
a b : α
⊢ (a, b) ∈ s ×ˢ s ↔
    (a, b) ∈ (range s.card).disjiUnion (fun k => map { toFun := fun i => (i, (f ^ k) i), inj' := ⋯ } s) ⋯

tactic: simp only [mem_product, Equiv.Perm.coe_pow, mem_disjiUnion, mem_range, mem_map,
  Function.Embedding.coeFn_mk, Prod.mk.inj_iff, exists_prop]
state_before: case a.mk
ι : Type u_1
α : Type u_2
β : Type u_3
f : Perm α
s : Finset α
hf : f.IsCycleOn ↑s
a b : α
⊢ (a, b) ∈ s ×ˢ s ↔
    (a, b) ∈ (range s.card).disjiUnion (fun k => map { toFun := fun i => (i, (f ^ k) i), inj' := ⋯ } s) ⋯
state_after: case a.mk
ι : Type u_1
α : Type u_2
β : Type u_3
f : Perm α
s : Finset α
hf : f.IsCycleOn ↑s
a b : α
⊢ a ∈ s ∧ b ∈ s ↔ ∃ a_1 < s.card, ∃ a_2 ∈ s, a_2 = a ∧ (⇑f)^[a_1] a_2 = b

tactic: refine ⟨fun hx => ?_, ?_⟩
state_before: case a.mk
ι : Type u_1
α : Type u_2
β : Type u_3
f : Perm α
s : Finset α
hf : f.IsCycleOn ↑s
a b : α
⊢ a ∈ s ∧ b ∈ s ↔ ∃ a_1 < s.card, ∃ a_2 ∈ s, a_2 = a ∧ (⇑f)^[a_1] a_2 = b
state_after: case a.mk.refine_1
ι : Type u_1
α : Type u_2
β : Type u_3
f : Perm α
s : Finset α
hf : f.IsCycleOn ↑s
a b : α
hx : a ∈ s ∧ b ∈ s
⊢ ∃ a_1 < s.card, ∃ a_2 ∈ s, a_2 = a ∧ (⇑f)^[a_1] a_2 = b

case a.mk.refine_2
ι : Type u_1
α : Type u_2
β : Type u_3
f : Perm α
s : Finset α
hf : f.IsCycleOn ↑s
a b : α
⊢ (∃ a_1 < s.card, ∃ a_2 ∈ s, a_2 = a ∧ (⇑f)^[a_1] a_2 = b) → a ∈ s ∧ b ∈ s

tactic: obtain ⟨n, hn, rfl⟩ := hf.exists_pow_eq hx.1 hx.2
state_before: case a.mk.refine_1
ι : Type u_1
α : Type u_2
β : Type u_3
f : Perm α
s : Finset α
hf : f.IsCycleOn ↑s
a b : α
hx : a ∈ s ∧ b ∈ s
⊢ ∃ a_1 < s.card, ∃ a_2 ∈ s, a_2 = a ∧ (⇑f)^[a_1] a_2 = b
state_after: case a.mk.refine_1.intro.intro
ι : Type u_1
α : Type u_2
β : Type u_3
f : Perm α
s : Finset α
hf : f.IsCycleOn ↑s
a : α
n : ℕ
hn : n < s.card
hx : a ∈ s ∧ (f ^ n) a ∈ s
⊢ ∃ a_1 < s.card, ∃ a_2 ∈ s, a_2 = a ∧ (⇑f)^[a_1] a_2 = (f ^ n) a

tactic: exact ⟨n, hn, a, hx.1, rfl, by rw [f.iterate_eq_pow]⟩
state_before: case a.mk.refine_1.intro.intro
ι : Type u_1
α : Type u_2
β : Type u_3
f : Perm α
s : Finset α
hf : f.IsCycleOn ↑s
a : α
n : ℕ
hn : n < s.card
hx : a ∈ s ∧ (f ^ n) a ∈ s
⊢ ∃ a_1 < s.card, ∃ a_2 ∈ s, a_2 = a ∧ (⇑f)^[a_1] a_2 = (f ^ n) a
state_after: no goals

tactic: rw [f.iterate_eq_pow]
state_before: ι : Type u_1
α : Type u_2
β : Type u_3
f : Perm α
s : Finset α
hf : f.IsCycleOn ↑s
a : α
n : ℕ
hn : n < s.card
hx : a ∈ s ∧ (f ^ n) a ∈ s
⊢ (⇑f)^[n] a = (f ^ n) a
state_after: no goals

tactic: rintro ⟨n, -, a, ha, rfl, rfl⟩
state_before: case a.mk.refine_2
ι : Type u_1
α : Type u_2
β : Type u_3
f : Perm α
s : Finset α
hf : f.IsCycleOn ↑s
a b : α
⊢ (∃ a_1 < s.card, ∃ a_2 ∈ s, a_2 = a ∧ (⇑f)^[a_1] a_2 = b) → a ∈ s ∧ b ∈ s
state_after: case a.mk.refine_2.intro.intro.intro.intro.intro
ι : Type u_1
α : Type u_2
β : Type u_3
f : Perm α
s : Finset α
hf : f.IsCycleOn ↑s
n : ℕ
a : α
ha : a ∈ s
⊢ a ∈ s ∧ (⇑f)^[n] a ∈ s

tactic: exact ⟨ha, (hf.1.iterate _).mapsTo ha⟩
state_before: case a.mk.refine_2.intro.intro.intro.intro.intro
ι : Type u_1
α : Type u_2
β : Type u_3
f : Perm α
s : Finset α
hf : f.IsCycleOn ↑s
n : ℕ
a : α
ha : a ∈ s
⊢ a ∈ s ∧ (⇑f)^[n] a ∈ s
state_after: no goals