l3lab/ntp-mathlib huggingface dataset:
/-- The subgroup generated by a cycle is in bijection with its support -/
noncomputable def IsCycle.zpowersEquivSupport {σ : Perm α} (hσ : IsCycle σ) :
    (Subgroup.zpowers σ) ≃ σ.support :=
  Equiv.ofBijective
    (fun (τ : ↥ ((Subgroup.zpowers σ) : Set (Perm α))) =>
      ⟨(τ : Perm α) (Classical.choose hσ), by
        obtain ⟨τ, n, rfl⟩ := τ
        erw [Finset.mem_coe, Subtype.coe_mk, zpow_apply_mem_support, mem_support]
        exact (Classical.choose_spec hσ).1⟩)
    (by
      constructor
      · rintro ⟨a, m, rfl⟩ ⟨b, n, rfl⟩ h
        ext y
        by_cases hy : σ y = y
        · 

Proof state:
case pos
ι : Type u_1
α : Type u_2
β : Type u_3
f g : Perm α
x y✝ : α
inst✝¹ : DecidableEq α
inst✝ : Fintype α
σ : Perm α
hσ : IsCycle σ
m n : ℤ
h :
  (fun τ => { val := ↑τ (Classical.choose hσ), property := (_ : ↑τ (Classical.choose hσ) ∈ support σ) })
      { val := (fun x => σ ^ x) m, property := (_ : ∃ y, (fun x => σ ^ x) y = (fun x => σ ^ x) m) } =
    (fun τ => { val := ↑τ (Classical.choose hσ), property := (_ : ↑τ (Classical.choose hσ) ∈ support σ) })
      { val := (fun x => σ ^ x) n, property := (_ : ∃ y, (fun x => σ ^ x) y = (fun x => σ ^ x) n) }
y : α
hy : σ y = y
⊢ ↑{ val := (fun x => σ ^ x) m, property := (_ : ∃ y, (fun x => σ ^ x) y = (fun x => σ ^ x) m) } y =
    ↑{ val := (fun x => σ ^ x) n, property := (_ : ∃ y, (fun x => σ ^ x) y = (fun x => σ ^ x) n) } y

Next tactic:
simp_rw [zpow_apply_eq_self_of_apply_eq_self hy]
/-- The subgroup generated by a cycle is in bijection with its support -/
noncomputable def IsCycle.zpowersEquivSupport {σ : Perm α} (hσ : IsCycle σ) :
    (Subgroup.zpowers σ) ≃ σ.support :=
  Equiv.ofBijective
    (fun (τ : ↥ ((Subgroup.zpowers σ) : Set (Perm α))) =>
      ⟨(τ : Perm α) (Classical.choose hσ), by
        obtain ⟨τ, n, rfl⟩ := τ
        erw [Finset.mem_coe, Subtype.coe_mk, zpow_apply_mem_support, mem_support]
        exact (Classical.choose_spec hσ).1⟩)
    (by
      constructor
      · rintro ⟨a, m, rfl⟩ ⟨b, n, rfl⟩ h
        ext y
        by_cases hy : σ y = y
        · simp_rw [zpow_apply_eq_self_of_apply_eq_self hy]
        · 

Proof state:
case neg
ι : Type u_1
α : Type u_2
β : Type u_3
f g : Perm α
x y✝ : α
inst✝¹ : DecidableEq α
inst✝ : Fintype α
σ : Perm α
hσ : IsCycle σ
m n : ℤ
h :
  (fun τ => { val := ↑τ (Classical.choose hσ), property := (_ : ↑τ (Classical.choose hσ) ∈ support σ) })
      { val := (fun x => σ ^ x) m, property := (_ : ∃ y, (fun x => σ ^ x) y = (fun x => σ ^ x) m) } =
    (fun τ => { val := ↑τ (Classical.choose hσ), property := (_ : ↑τ (Classical.choose hσ) ∈ support σ) })
      { val := (fun x => σ ^ x) n, property := (_ : ∃ y, (fun x => σ ^ x) y = (fun x => σ ^ x) n) }
y : α
hy : ¬σ y = y
⊢ ↑{ val := (fun x => σ ^ x) m, property := (_ : ∃ y, (fun x => σ ^ x) y = (fun x => σ ^ x) m) } y =
    ↑{ val := (fun x => σ ^ x) n, property := (_ : ∃ y, (fun x => σ ^ x) y = (fun x => σ ^ x) n) } y

Next tactic:
obtain ⟨i, rfl⟩ := (Classical.choose_spec hσ).2 hy
/-- The subgroup generated by a cycle is in bijection with its support -/
noncomputable def IsCycle.zpowersEquivSupport {σ : Perm α} (hσ : IsCycle σ) :
    (Subgroup.zpowers σ) ≃ σ.support :=
  Equiv.ofBijective
    (fun (τ : ↥ ((Subgroup.zpowers σ) : Set (Perm α))) =>
      ⟨(τ : Perm α) (Classical.choose hσ), by
        obtain ⟨τ, n, rfl⟩ := τ
        erw [Finset.mem_coe, Subtype.coe_mk, zpow_apply_mem_support, mem_support]
        exact (Classical.choose_spec hσ).1⟩)
    (by
      constructor
      · rintro ⟨a, m, rfl⟩ ⟨b, n, rfl⟩ h
        ext y
        by_cases hy : σ y = y
        · simp_rw [zpow_apply_eq_self_of_apply_eq_self hy]
        · obtain ⟨i, rfl⟩ := (Classical.choose_spec hσ).2 hy
          

Proof state:
case neg.intro
ι : Type u_1
α : Type u_2
β : Type u_3
f g : Perm α
x y : α
inst✝¹ : DecidableEq α
inst✝ : Fintype α
σ : Perm α
hσ : IsCycle σ
m n : ℤ
h :
  (fun τ => { val := ↑τ (Classical.choose hσ), property := (_ : ↑τ (Classical.choose hσ) ∈ support σ) })
      { val := (fun x => σ ^ x) m, property := (_ : ∃ y, (fun x => σ ^ x) y = (fun x => σ ^ x) m) } =
    (fun τ => { val := ↑τ (Classical.choose hσ), property := (_ : ↑τ (Classical.choose hσ) ∈ support σ) })
      { val := (fun x => σ ^ x) n, property := (_ : ∃ y, (fun x => σ ^ x) y = (fun x => σ ^ x) n) }
i : ℤ
hy : ¬σ ((σ ^ i) (Classical.choose hσ)) = (σ ^ i) (Classical.choose hσ)
⊢ ↑{ val := (fun x => σ ^ x) m, property := (_ : ∃ y, (fun x => σ ^ x) y = (fun x => σ ^ x) m) }
      ((σ ^ i) (Classical.choose hσ)) =
    ↑{ val := (fun x => σ ^ x) n, property := (_ : ∃ y, (fun x => σ ^ x) y = (fun x => σ ^ x) n) }
      ((σ ^ i) (Classical.choose hσ))

Next tactic:
rw [Subtype.coe_mk, Subtype.coe_mk, zpow_apply_comm σ m i, zpow_apply_comm σ n i]
/-- The subgroup generated by a cycle is in bijection with its support -/
noncomputable def IsCycle.zpowersEquivSupport {σ : Perm α} (hσ : IsCycle σ) :
    (Subgroup.zpowers σ) ≃ σ.support :=
  Equiv.ofBijective
    (fun (τ : ↥ ((Subgroup.zpowers σ) : Set (Perm α))) =>
      ⟨(τ : Perm α) (Classical.choose hσ), by
        obtain ⟨τ, n, rfl⟩ := τ
        erw [Finset.mem_coe, Subtype.coe_mk, zpow_apply_mem_support, mem_support]
        exact (Classical.choose_spec hσ).1⟩)
    (by
      constructor
      · rintro ⟨a, m, rfl⟩ ⟨b, n, rfl⟩ h
        ext y
        by_cases hy : σ y = y
        · simp_rw [zpow_apply_eq_self_of_apply_eq_self hy]
        · obtain ⟨i, rfl⟩ := (Classical.choose_spec hσ).2 hy
          rw [Subtype.coe_mk, Subtype.coe_mk, zpow_apply_comm σ m i, zpow_apply_comm σ n i]
          

Proof state:
case neg.intro
ι : Type u_1
α : Type u_2
β : Type u_3
f g : Perm α
x y : α
inst✝¹ : DecidableEq α
inst✝ : Fintype α
σ : Perm α
hσ : IsCycle σ
m n : ℤ
h :
  (fun τ => { val := ↑τ (Classical.choose hσ), property := (_ : ↑τ (Classical.choose hσ) ∈ support σ) })
      { val := (fun x => σ ^ x) m, property := (_ : ∃ y, (fun x => σ ^ x) y = (fun x => σ ^ x) m) } =
    (fun τ => { val := ↑τ (Classical.choose hσ), property := (_ : ↑τ (Classical.choose hσ) ∈ support σ) })
      { val := (fun x => σ ^ x) n, property := (_ : ∃ y, (fun x => σ ^ x) y = (fun x => σ ^ x) n) }
i : ℤ
hy : ¬σ ((σ ^ i) (Classical.choose hσ)) = (σ ^ i) (Classical.choose hσ)
⊢ (σ ^ i) ((σ ^ m) (Classical.choose hσ)) = (σ ^ i) ((σ ^ n) (Classical.choose hσ))

Next tactic:
exact congr_arg _ (Subtype.ext_iff.mp h)
/-- The subgroup generated by a cycle is in bijection with its support -/
noncomputable def IsCycle.zpowersEquivSupport {σ : Perm α} (hσ : IsCycle σ) :
    (Subgroup.zpowers σ) ≃ σ.support :=
  Equiv.ofBijective
    (fun (τ : ↥ ((Subgroup.zpowers σ) : Set (Perm α))) =>
      ⟨(τ : Perm α) (Classical.choose hσ), by
        obtain ⟨τ, n, rfl⟩ := τ
        erw [Finset.mem_coe, Subtype.coe_mk, zpow_apply_mem_support, mem_support]
        exact (Classical.choose_spec hσ).1⟩)
    (by
      constructor
      · rintro ⟨a, m, rfl⟩ ⟨b, n, rfl⟩ h
        ext y
        by_cases hy : σ y = y
        · simp_rw [zpow_apply_eq_self_of_apply_eq_self hy]
        · obtain ⟨i, rfl⟩ := (Classical.choose_spec hσ).2 hy
          rw [Subtype.coe_mk, Subtype.coe_mk, zpow_apply_comm σ m i, zpow_apply_comm σ n i]
          exact congr_arg _ (Subtype.ext_iff.mp h)
      · 

Proof state:
case right
ι : Type u_1
α : Type u_2
β : Type u_3
f g : Perm α
x y : α
inst✝¹ : DecidableEq α
inst✝ : Fintype α
σ : Perm α
hσ : IsCycle σ
⊢ Surjective fun τ => { val := ↑τ (Classical.choose hσ), property := (_ : ↑τ (Classical.choose hσ) ∈ support σ) }

Next tactic:
rintro ⟨y, hy⟩
/-- The subgroup generated by a cycle is in bijection with its support -/
noncomputable def IsCycle.zpowersEquivSupport {σ : Perm α} (hσ : IsCycle σ) :
    (Subgroup.zpowers σ) ≃ σ.support :=
  Equiv.ofBijective
    (fun (τ : ↥ ((Subgroup.zpowers σ) : Set (Perm α))) =>
      ⟨(τ : Perm α) (Classical.choose hσ), by
        obtain ⟨τ, n, rfl⟩ := τ
        erw [Finset.mem_coe, Subtype.coe_mk, zpow_apply_mem_support, mem_support]
        exact (Classical.choose_spec hσ).1⟩)
    (by
      constructor
      · rintro ⟨a, m, rfl⟩ ⟨b, n, rfl⟩ h
        ext y
        by_cases hy : σ y = y
        · simp_rw [zpow_apply_eq_self_of_apply_eq_self hy]
        · obtain ⟨i, rfl⟩ := (Classical.choose_spec hσ).2 hy
          rw [Subtype.coe_mk, Subtype.coe_mk, zpow_apply_comm σ m i, zpow_apply_comm σ n i]
          exact congr_arg _ (Subtype.ext_iff.mp h)
      · rintro ⟨y, hy⟩
        

Proof state:
case right.mk
ι : Type u_1
α : Type u_2
β : Type u_3
f g : Perm α
x y✝ : α
inst✝¹ : DecidableEq α
inst✝ : Fintype α
σ : Perm α
hσ : IsCycle σ
y : α
hy : y ∈ support σ
⊢ ∃ a,
    (fun τ => { val := ↑τ (Classical.choose hσ), property := (_ : ↑τ (Classical.choose hσ) ∈ support σ) }) a =
      { val := y, property := hy }

Next tactic:
erw [Finset.mem_coe, mem_support] at hy
/-- The subgroup generated by a cycle is in bijection with its support -/
noncomputable def IsCycle.zpowersEquivSupport {σ : Perm α} (hσ : IsCycle σ) :
    (Subgroup.zpowers σ) ≃ σ.support :=
  Equiv.ofBijective
    (fun (τ : ↥ ((Subgroup.zpowers σ) : Set (Perm α))) =>
      ⟨(τ : Perm α) (Classical.choose hσ), by
        obtain ⟨τ, n, rfl⟩ := τ
        erw [Finset.mem_coe, Subtype.coe_mk, zpow_apply_mem_support, mem_support]
        exact (Classical.choose_spec hσ).1⟩)
    (by
      constructor
      · rintro ⟨a, m, rfl⟩ ⟨b, n, rfl⟩ h
        ext y
        by_cases hy : σ y = y
        · simp_rw [zpow_apply_eq_self_of_apply_eq_self hy]
        · obtain ⟨i, rfl⟩ := (Classical.choose_spec hσ).2 hy
          rw [Subtype.coe_mk, Subtype.coe_mk, zpow_apply_comm σ m i, zpow_apply_comm σ n i]
          exact congr_arg _ (Subtype.ext_iff.mp h)
      · rintro ⟨y, hy⟩
        erw [Finset.mem_coe, mem_support] at hy
        

Proof state:
case right.mk
ι : Type u_1
α : Type u_2
β : Type u_3
f g : Perm α
x y✝ : α
inst✝¹ : DecidableEq α
inst✝ : Fintype α
σ : Perm α
hσ : IsCycle σ
y : α
hy✝ : y ∈ support σ
hy : σ y ≠ y
⊢ ∃ a,
    (fun τ => { val := ↑τ (Classical.choose hσ), property := (_ : ↑τ (Classical.choose hσ) ∈ support σ) }) a =
      { val := y, property := hy✝ }

Next tactic:
obtain ⟨n, rfl⟩ := (Classical.choose_spec hσ).2 hy
/-- The subgroup generated by a cycle is in bijection with its support -/
noncomputable def IsCycle.zpowersEquivSupport {σ : Perm α} (hσ : IsCycle σ) :
    (Subgroup.zpowers σ) ≃ σ.support :=
  Equiv.ofBijective
    (fun (τ : ↥ ((Subgroup.zpowers σ) : Set (Perm α))) =>
      ⟨(τ : Perm α) (Classical.choose hσ), by
        obtain ⟨τ, n, rfl⟩ := τ
        erw [Finset.mem_coe, Subtype.coe_mk, zpow_apply_mem_support, mem_support]
        exact (Classical.choose_spec hσ).1⟩)
    (by
      constructor
      · rintro ⟨a, m, rfl⟩ ⟨b, n, rfl⟩ h
        ext y
        by_cases hy : σ y = y
        · simp_rw [zpow_apply_eq_self_of_apply_eq_self hy]
        · obtain ⟨i, rfl⟩ := (Classical.choose_spec hσ).2 hy
          rw [Subtype.coe_mk, Subtype.coe_mk, zpow_apply_comm σ m i, zpow_apply_comm σ n i]
          exact congr_arg _ (Subtype.ext_iff.mp h)
      · rintro ⟨y, hy⟩
        erw [Finset.mem_coe, mem_support] at hy
        obtain ⟨n, rfl⟩ := (Classical.choose_spec hσ).2 hy
        

Proof state:
case right.mk.intro
ι : Type u_1
α : Type u_2
β : Type u_3
f g : Perm α
x y : α
inst✝¹ : DecidableEq α
inst✝ : Fintype α
σ : Perm α
hσ : IsCycle σ
n : ℤ
hy✝ : (σ ^ n) (Classical.choose hσ) ∈ support σ
hy : σ ((σ ^ n) (Classical.choose hσ)) ≠ (σ ^ n) (Classical.choose hσ)
⊢ ∃ a,
    (fun τ => { val := ↑τ (Classical.choose hσ), property := (_ : ↑τ (Classical.choose hσ) ∈ support σ) }) a =
      { val := (σ ^ n) (Classical.choose hσ), property := hy✝ }

Next tactic:
exact ⟨⟨σ ^ n, n, rfl⟩, rfl⟩
protected theorem IsCycle.orderOf (hf : IsCycle f) : orderOf f = f.support.card := by
  

Proof state:
ι : Type u_1
α : Type u_2
β : Type u_3
f g : Perm α
x y : α
inst✝¹ : DecidableEq α
inst✝ : Fintype α
hf : IsCycle f
⊢ orderOf f = card (support f)

Next tactic:
rw [← Fintype.card_zpowers, ← Fintype.card_coe]
protected theorem IsCycle.orderOf (hf : IsCycle f) : orderOf f = f.support.card := by
  rw [← Fintype.card_zpowers, ← Fintype.card_coe]
  

Proof state:
ι : Type u_1
α : Type u_2
β : Type u_3
f g : Perm α
x y : α
inst✝¹ : DecidableEq α
inst✝ : Fintype α
hf : IsCycle f
⊢ Fintype.card ↥(Subgroup.zpowers f) = Fintype.card { x // x ∈ support f }

Next tactic:
convert Fintype.card_congr (IsCycle.zpowersEquivSupport hf)
theorem isCycle_swap_mul_aux₁ {α : Type*} [DecidableEq α] :
    ∀ (n : ℕ) {b x : α} {f : Perm α} (_ : (swap x (f x) * f) b ≠ b) (_ : (f ^ n) (f x) = b),
      ∃ i : ℤ, ((swap x (f x) * f) ^ i) (f x) = b := by
  

Proof state:
ι : Type u_1
α✝ : Type u_2
β : Type u_3
f g : Perm α✝
x y : α✝
inst✝² : DecidableEq α✝
inst✝¹ : Fintype α✝
α : Type u_4
inst✝ : DecidableEq α
⊢ ∀ (n : ℕ) {b x : α} {f : Perm α},
    (swap x (f x) * f) b ≠ b → (f ^ n) (f x) = b → ∃ i, ((swap x (f x) * f) ^ i) (f x) = b

Next tactic:
intro n
theorem isCycle_swap_mul_aux₁ {α : Type*} [DecidableEq α] :
    ∀ (n : ℕ) {b x : α} {f : Perm α} (_ : (swap x (f x) * f) b ≠ b) (_ : (f ^ n) (f x) = b),
      ∃ i : ℤ, ((swap x (f x) * f) ^ i) (f x) = b := by
  intro n
  

Proof state:
ι : Type u_1
α✝ : Type u_2
β : Type u_3
f g : Perm α✝
x y : α✝
inst✝² : DecidableEq α✝
inst✝¹ : Fintype α✝
α : Type u_4
inst✝ : DecidableEq α
n : ℕ
⊢ ∀ {b x : α} {f : Perm α}, (swap x (f x) * f) b ≠ b → (f ^ n) (f x) = b → ∃ i, ((swap x (f x) * f) ^ i) (f x) = b

Next tactic:
induction' n with n hn
theorem isCycle_swap_mul_aux₁ {α : Type*} [DecidableEq α] :
    ∀ (n : ℕ) {b x : α} {f : Perm α} (_ : (swap x (f x) * f) b ≠ b) (_ : (f ^ n) (f x) = b),
      ∃ i : ℤ, ((swap x (f x) * f) ^ i) (f x) = b := by
  intro n
  induction' n with n hn
  · 

Proof state:
case zero
ι : Type u_1
α✝ : Type u_2
β : Type u_3
f g : Perm α✝
x y : α✝
inst✝² : DecidableEq α✝
inst✝¹ : Fintype α✝
α : Type u_4
inst✝ : DecidableEq α
⊢ ∀ {b x : α} {f : Perm α},
    (swap x (f x) * f) b ≠ b → (f ^ Nat.zero) (f x) = b → ∃ i, ((swap x (f x) * f) ^ i) (f x) = b

Next tactic:
exact fun _ h => ⟨0, h⟩
theorem isCycle_swap_mul_aux₁ {α : Type*} [DecidableEq α] :
    ∀ (n : ℕ) {b x : α} {f : Perm α} (_ : (swap x (f x) * f) b ≠ b) (_ : (f ^ n) (f x) = b),
      ∃ i : ℤ, ((swap x (f x) * f) ^ i) (f x) = b := by
  intro n
  induction' n with n hn
  · exact fun _ h => ⟨0, h⟩
  · 

Proof state:
case succ
ι : Type u_1
α✝ : Type u_2
β : Type u_3
f g : Perm α✝
x y : α✝
inst✝² : DecidableEq α✝
inst✝¹ : Fintype α✝
α : Type u_4
inst✝ : DecidableEq α
n : ℕ
hn : ∀ {b x : α} {f : Perm α}, (swap x (f x) * f) b ≠ b → (f ^ n) (f x) = b → ∃ i, ((swap x (f x) * f) ^ i) (f x) = b
⊢ ∀ {b x : α} {f : Perm α},
    (swap x (f x) * f) b ≠ b → (f ^ Nat.succ n) (f x) = b → ∃ i, ((swap x (f x) * f) ^ i) (f x) = b

Next tactic:
intro b x f hb h
theorem isCycle_swap_mul_aux₁ {α : Type*} [DecidableEq α] :
    ∀ (n : ℕ) {b x : α} {f : Perm α} (_ : (swap x (f x) * f) b ≠ b) (_ : (f ^ n) (f x) = b),
      ∃ i : ℤ, ((swap x (f x) * f) ^ i) (f x) = b := by
  intro n
  induction' n with n hn
  · exact fun _ h => ⟨0, h⟩
  · intro b x f hb h
    

Proof state:
case succ
ι : Type u_1
α✝ : Type u_2
β : Type u_3
f✝ g : Perm α✝
x✝ y : α✝
inst✝² : DecidableEq α✝
inst✝¹ : Fintype α✝
α : Type u_4
inst✝ : DecidableEq α
n : ℕ
hn : ∀ {b x : α} {f : Perm α}, (swap x (f x) * f) b ≠ b → (f ^ n) (f x) = b → ∃ i, ((swap x (f x) * f) ^ i) (f x) = b
b x : α
f : Perm α
hb : (swap x (f x) * f) b ≠ b
h : (f ^ Nat.succ n) (f x) = b
⊢ ∃ i, ((swap x (f x) * f) ^ i) (f x) = b

Next tactic:
exact if hfbx : f x = b then ⟨0, hfbx⟩
      else
        have : f b ≠ b ∧ b ≠ x := ne_and_ne_of_swap_mul_apply_ne_self hb
        have hb' : (swap x (f x) * f) (f⁻¹ b) ≠ f⁻¹ b := by
          rw [mul_apply, apply_inv_self, swap_apply_of_ne_of_ne this.2 (Ne.symm hfbx), Ne.def, ←
            f.injective.eq_iff, apply_inv_self]
          exact this.1
        let ⟨i, hi⟩ := hn hb' (f.injective <| by
          rw [apply_inv_self]; rwa [pow_succ, mul_apply] at h)
        ⟨i + 1, by
          rw [add_comm, zpow_add, mul_apply, hi, zpow_one, mul_apply, apply_inv_self,
            swap_apply_of_ne_of_ne (ne_and_ne_of_swap_mul_apply_ne_self hb).2 (Ne.symm hfbx)]⟩
theorem isCycle_swap_mul_aux₁ {α : Type*} [DecidableEq α] :
    ∀ (n : ℕ) {b x : α} {f : Perm α} (_ : (swap x (f x) * f) b ≠ b) (_ : (f ^ n) (f x) = b),
      ∃ i : ℤ, ((swap x (f x) * f) ^ i) (f x) = b := by
  intro n
  induction' n with n hn
  · exact fun _ h => ⟨0, h⟩
  · intro b x f hb h
    exact if hfbx : f x = b then ⟨0, hfbx⟩
      else
        have : f b ≠ b ∧ b ≠ x := ne_and_ne_of_swap_mul_apply_ne_self hb
        have hb' : (swap x (f x) * f) (f⁻¹ b) ≠ f⁻¹ b := by
          

Proof state:
ι : Type u_1
α✝ : Type u_2
β : Type u_3
f✝ g : Perm α✝
x✝ y : α✝
inst✝² : DecidableEq α✝
inst✝¹ : Fintype α✝
α : Type u_4
inst✝ : DecidableEq α
n : ℕ
hn : ∀ {b x : α} {f : Perm α}, (swap x (f x) * f) b ≠ b → (f ^ n) (f x) = b → ∃ i, ((swap x (f x) * f) ^ i) (f x) = b
b x : α
f : Perm α
hb : (swap x (f x) * f) b ≠ b
h : (f ^ Nat.succ n) (f x) = b
hfbx : ¬f x = b
this : f b ≠ b ∧ b ≠ x
⊢ (swap x (f x) * f) (f⁻¹ b) ≠ f⁻¹ b

Next tactic:
rw [mul_apply, apply_inv_self, swap_apply_of_ne_of_ne this.2 (Ne.symm hfbx), Ne.def, ←
            f.injective.eq_iff, apply_inv_self]
theorem isCycle_swap_mul_aux₁ {α : Type*} [DecidableEq α] :
    ∀ (n : ℕ) {b x : α} {f : Perm α} (_ : (swap x (f x) * f) b ≠ b) (_ : (f ^ n) (f x) = b),
      ∃ i : ℤ, ((swap x (f x) * f) ^ i) (f x) = b := by
  intro n
  induction' n with n hn
  · exact fun _ h => ⟨0, h⟩
  · intro b x f hb h
    exact if hfbx : f x = b then ⟨0, hfbx⟩
      else
        have : f b ≠ b ∧ b ≠ x := ne_and_ne_of_swap_mul_apply_ne_self hb
        have hb' : (swap x (f x) * f) (f⁻¹ b) ≠ f⁻¹ b := by
          rw [mul_apply, apply_inv_self, swap_apply_of_ne_of_ne this.2 (Ne.symm hfbx), Ne.def, ←
            f.injective.eq_iff, apply_inv_self]
          

Proof state:
ι : Type u_1
α✝ : Type u_2
β : Type u_3
f✝ g : Perm α✝
x✝ y : α✝
inst✝² : DecidableEq α✝
inst✝¹ : Fintype α✝
α : Type u_4
inst✝ : DecidableEq α
n : ℕ
hn : ∀ {b x : α} {f : Perm α}, (swap x (f x) * f) b ≠ b → (f ^ n) (f x) = b → ∃ i, ((swap x (f x) * f) ^ i) (f x) = b
b x : α
f : Perm α
hb : (swap x (f x) * f) b ≠ b
h : (f ^ Nat.succ n) (f x) = b
hfbx : ¬f x = b
this : f b ≠ b ∧ b ≠ x
⊢ ¬f b = b

Next tactic:
exact this.1
theorem isCycle_swap_mul_aux₁ {α : Type*} [DecidableEq α] :
    ∀ (n : ℕ) {b x : α} {f : Perm α} (_ : (swap x (f x) * f) b ≠ b) (_ : (f ^ n) (f x) = b),
      ∃ i : ℤ, ((swap x (f x) * f) ^ i) (f x) = b := by
  intro n
  induction' n with n hn
  · exact fun _ h => ⟨0, h⟩
  · intro b x f hb h
    exact if hfbx : f x = b then ⟨0, hfbx⟩
      else
        have : f b ≠ b ∧ b ≠ x := ne_and_ne_of_swap_mul_apply_ne_self hb
        have hb' : (swap x (f x) * f) (f⁻¹ b) ≠ f⁻¹ b := by
          rw [mul_apply, apply_inv_self, swap_apply_of_ne_of_ne this.2 (Ne.symm hfbx), Ne.def, ←
            f.injective.eq_iff, apply_inv_self]
          exact this.1
        let ⟨i, hi⟩ := hn hb' (f.injective <| by
          

Proof state:
ι : Type u_1
α✝ : Type u_2
β : Type u_3
f✝ g : Perm α✝
x✝ y : α✝
inst✝² : DecidableEq α✝
inst✝¹ : Fintype α✝
α : Type u_4
inst✝ : DecidableEq α
n : ℕ
hn : ∀ {b x : α} {f : Perm α}, (swap x (f x) * f) b ≠ b → (f ^ n) (f x) = b → ∃ i, ((swap x (f x) * f) ^ i) (f x) = b
b x : α
f : Perm α
hb : (swap x (f x) * f) b ≠ b
h : (f ^ Nat.succ n) (f x) = b
hfbx : ¬f x = b
this : f b ≠ b ∧ b ≠ x
hb' : (swap x (f x) * f) (f⁻¹ b) ≠ f⁻¹ b
⊢ f ((f ^ n) (f x)) = f (f⁻¹ b)

Next tactic:
rw [apply_inv_self]
theorem isCycle_swap_mul_aux₁ {α : Type*} [DecidableEq α] :
    ∀ (n : ℕ) {b x : α} {f : Perm α} (_ : (swap x (f x) * f) b ≠ b) (_ : (f ^ n) (f x) = b),
      ∃ i : ℤ, ((swap x (f x) * f) ^ i) (f x) = b := by
  intro n
  induction' n with n hn
  · exact fun _ h => ⟨0, h⟩
  · intro b x f hb h
    exact if hfbx : f x = b then ⟨0, hfbx⟩
      else
        have : f b ≠ b ∧ b ≠ x := ne_and_ne_of_swap_mul_apply_ne_self hb
        have hb' : (swap x (f x) * f) (f⁻¹ b) ≠ f⁻¹ b := by
          rw [mul_apply, apply_inv_self, swap_apply_of_ne_of_ne this.2 (Ne.symm hfbx), Ne.def, ←
            f.injective.eq_iff, apply_inv_self]
          exact this.1
        let ⟨i, hi⟩ := hn hb' (f.injective <| by
          rw [apply_inv_self]; 

Proof state:
ι : Type u_1
α✝ : Type u_2
β : Type u_3
f✝ g : Perm α✝
x✝ y : α✝
inst✝² : DecidableEq α✝
inst✝¹ : Fintype α✝
α : Type u_4
inst✝ : DecidableEq α
n : ℕ
hn : ∀ {b x : α} {f : Perm α}, (swap x (f x) * f) b ≠ b → (f ^ n) (f x) = b → ∃ i, ((swap x (f x) * f) ^ i) (f x) = b
b x : α
f : Perm α
hb : (swap x (f x) * f) b ≠ b
h : (f ^ Nat.succ n) (f x) = b
hfbx : ¬f x = b
this : f b ≠ b ∧ b ≠ x
hb' : (swap x (f x) * f) (f⁻¹ b) ≠ f⁻¹ b
⊢ f ((f ^ n) (f x)) = b

Next tactic:
rwa [pow_succ, mul_apply] at h
theorem isCycle_swap_mul_aux₁ {α : Type*} [DecidableEq α] :
    ∀ (n : ℕ) {b x : α} {f : Perm α} (_ : (swap x (f x) * f) b ≠ b) (_ : (f ^ n) (f x) = b),
      ∃ i : ℤ, ((swap x (f x) * f) ^ i) (f x) = b := by
  intro n
  induction' n with n hn
  · exact fun _ h => ⟨0, h⟩
  · intro b x f hb h
    exact if hfbx : f x = b then ⟨0, hfbx⟩
      else
        have : f b ≠ b ∧ b ≠ x := ne_and_ne_of_swap_mul_apply_ne_self hb
        have hb' : (swap x (f x) * f) (f⁻¹ b) ≠ f⁻¹ b := by
          rw [mul_apply, apply_inv_self, swap_apply_of_ne_of_ne this.2 (Ne.symm hfbx), Ne.def, ←
            f.injective.eq_iff, apply_inv_self]
          exact this.1
        let ⟨i, hi⟩ := hn hb' (f.injective <| by
          rw [apply_inv_self]; rwa [pow_succ, mul_apply] at h)
        ⟨i + 1, by
          

Proof state:
ι : Type u_1
α✝ : Type u_2
β : Type u_3
f✝ g : Perm α✝
x✝ y : α✝
inst✝² : DecidableEq α✝
inst✝¹ : Fintype α✝
α : Type u_4
inst✝ : DecidableEq α
n : ℕ
hn : ∀ {b x : α} {f : Perm α}, (swap x (f x) * f) b ≠ b → (f ^ n) (f x) = b → ∃ i, ((swap x (f x) * f) ^ i) (f x) = b
b x : α
f : Perm α
hb : (swap x (f x) * f) b ≠ b
h : (f ^ Nat.succ n) (f x) = b
hfbx : ¬f x = b
this : f b ≠ b ∧ b ≠ x
hb' : (swap x (f x) * f) (f⁻¹ b) ≠ f⁻¹ b
i : ℤ
hi : ((swap x (f x) * f) ^ i) (f x) = f⁻¹ b
⊢ ((swap x (f x) * f) ^ (i + 1)) (f x) = b

Next tactic:
rw [add_comm, zpow_add, mul_apply, hi, zpow_one, mul_apply, apply_inv_self,
            swap_apply_of_ne_of_ne (ne_and_ne_of_swap_mul_apply_ne_self hb).2 (Ne.symm hfbx)]
theorem isCycle_swap_mul_aux₂ {α : Type*} [DecidableEq α] :
    ∀ (n : ℤ) {b x : α} {f : Perm α} (_ : (swap x (f x) * f) b ≠ b) (_ : (f ^ n) (f x) = b),
      ∃ i : ℤ, ((swap x (f x) * f) ^ i) (f x) = b := by
  

Proof state:
ι : Type u_1
α✝ : Type u_2
β : Type u_3
f g : Perm α✝
x y : α✝
inst✝² : DecidableEq α✝
inst✝¹ : Fintype α✝
α : Type u_4
inst✝ : DecidableEq α
⊢ ∀ (n : ℤ) {b x : α} {f : Perm α},
    (swap x (f x) * f) b ≠ b → (f ^ n) (f x) = b → ∃ i, ((swap x (f x) * f) ^ i) (f x) = b

Next tactic:
intro n
theorem isCycle_swap_mul_aux₂ {α : Type*} [DecidableEq α] :
    ∀ (n : ℤ) {b x : α} {f : Perm α} (_ : (swap x (f x) * f) b ≠ b) (_ : (f ^ n) (f x) = b),
      ∃ i : ℤ, ((swap x (f x) * f) ^ i) (f x) = b := by
  intro n
  

Proof state:
ι : Type u_1
α✝ : Type u_2
β : Type u_3
f g : Perm α✝
x y : α✝
inst✝² : DecidableEq α✝
inst✝¹ : Fintype α✝
α : Type u_4
inst✝ : DecidableEq α
n : ℤ
⊢ ∀ {b x : α} {f : Perm α}, (swap x (f x) * f) b ≠ b → (f ^ n) (f x) = b → ∃ i, ((swap x (f x) * f) ^ i) (f x) = b

Next tactic:
induction' n with n n
theorem isCycle_swap_mul_aux₂ {α : Type*} [DecidableEq α] :
    ∀ (n : ℤ) {b x : α} {f : Perm α} (_ : (swap x (f x) * f) b ≠ b) (_ : (f ^ n) (f x) = b),
      ∃ i : ℤ, ((swap x (f x) * f) ^ i) (f x) = b := by
  intro n
  induction' n with n n
  · 

Proof state:
case ofNat
ι : Type u_1
α✝ : Type u_2
β : Type u_3
f g : Perm α✝
x y : α✝
inst✝² : DecidableEq α✝
inst✝¹ : Fintype α✝
α : Type u_4
inst✝ : DecidableEq α
n : ℕ
⊢ ∀ {b x : α} {f : Perm α},
    (swap x (f x) * f) b ≠ b → (f ^ Int.ofNat n) (f x) = b → ∃ i, ((swap x (f x) * f) ^ i) (f x) = b

Next tactic:
exact isCycle_swap_mul_aux₁ n
theorem isCycle_swap_mul_aux₂ {α : Type*} [DecidableEq α] :
    ∀ (n : ℤ) {b x : α} {f : Perm α} (_ : (swap x (f x) * f) b ≠ b) (_ : (f ^ n) (f x) = b),
      ∃ i : ℤ, ((swap x (f x) * f) ^ i) (f x) = b := by
  intro n
  induction' n with n n
  · exact isCycle_swap_mul_aux₁ n
  · 

Proof state:
case negSucc
ι : Type u_1
α✝ : Type u_2
β : Type u_3
f g : Perm α✝
x y : α✝
inst✝² : DecidableEq α✝
inst✝¹ : Fintype α✝
α : Type u_4
inst✝ : DecidableEq α
n : ℕ
⊢ ∀ {b x : α} {f : Perm α},
    (swap x (f x) * f) b ≠ b → (f ^ Int.negSucc n) (f x) = b → ∃ i, ((swap x (f x) * f) ^ i) (f x) = b

Next tactic:
intro b x f hb h