l3lab/ntp-mathlib huggingface dataset:
@[elab_as_elim]
theorem cycle_induction_on [Finite β] (P : Perm β → Prop) (σ : Perm β) (base_one : P 1)
    (base_cycles : ∀ σ : Perm β, σ.IsCycle → P σ)
    (induction_disjoint : ∀ σ τ : Perm β,
      Disjoint σ τ → IsCycle σ → P σ → P τ → P (σ * τ)) : P σ := by
  cases nonempty_fintype β
  suffices ∀ l : List (Perm β),
      (∀ τ : Perm β, τ ∈ l → τ.IsCycle) → l.Pairwise Disjoint → P l.prod by
    classical
      let x := σ.truncCycleFactors.out
      exact (congr_arg P x.2.1).mp (this x.1 x.2.2.1 x.2.2.2)
  intro l
  induction' l with σ l ih
  · exact fun _ _ => base_one
  · 

Proof state:
case intro.cons
ι : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : DecidableEq α
inst✝ : Finite β
P : Perm β → Prop
σ✝ : Perm β
base_one : P 1
base_cycles : ∀ (σ : Perm β), IsCycle σ → P σ
induction_disjoint : ∀ (σ τ : Perm β), Disjoint σ τ → IsCycle σ → P σ → P τ → P (σ * τ)
val✝ : Fintype β
σ : Perm β
l : List (Perm β)
ih : (∀ τ ∈ l, IsCycle τ) → List.Pairwise Disjoint l → P (List.prod l)
⊢ (∀ τ ∈ σ :: l, IsCycle τ) → List.Pairwise Disjoint (σ :: l) → P (List.prod (σ :: l))

Next tactic:
intro h1 h2
@[elab_as_elim]
theorem cycle_induction_on [Finite β] (P : Perm β → Prop) (σ : Perm β) (base_one : P 1)
    (base_cycles : ∀ σ : Perm β, σ.IsCycle → P σ)
    (induction_disjoint : ∀ σ τ : Perm β,
      Disjoint σ τ → IsCycle σ → P σ → P τ → P (σ * τ)) : P σ := by
  cases nonempty_fintype β
  suffices ∀ l : List (Perm β),
      (∀ τ : Perm β, τ ∈ l → τ.IsCycle) → l.Pairwise Disjoint → P l.prod by
    classical
      let x := σ.truncCycleFactors.out
      exact (congr_arg P x.2.1).mp (this x.1 x.2.2.1 x.2.2.2)
  intro l
  induction' l with σ l ih
  · exact fun _ _ => base_one
  · intro h1 h2
    

Proof state:
case intro.cons
ι : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : DecidableEq α
inst✝ : Finite β
P : Perm β → Prop
σ✝ : Perm β
base_one : P 1
base_cycles : ∀ (σ : Perm β), IsCycle σ → P σ
induction_disjoint : ∀ (σ τ : Perm β), Disjoint σ τ → IsCycle σ → P σ → P τ → P (σ * τ)
val✝ : Fintype β
σ : Perm β
l : List (Perm β)
ih : (∀ τ ∈ l, IsCycle τ) → List.Pairwise Disjoint l → P (List.prod l)
h1 : ∀ τ ∈ σ :: l, IsCycle τ
h2 : List.Pairwise Disjoint (σ :: l)
⊢ P (List.prod (σ :: l))

Next tactic:
rw [List.prod_cons]
@[elab_as_elim]
theorem cycle_induction_on [Finite β] (P : Perm β → Prop) (σ : Perm β) (base_one : P 1)
    (base_cycles : ∀ σ : Perm β, σ.IsCycle → P σ)
    (induction_disjoint : ∀ σ τ : Perm β,
      Disjoint σ τ → IsCycle σ → P σ → P τ → P (σ * τ)) : P σ := by
  cases nonempty_fintype β
  suffices ∀ l : List (Perm β),
      (∀ τ : Perm β, τ ∈ l → τ.IsCycle) → l.Pairwise Disjoint → P l.prod by
    classical
      let x := σ.truncCycleFactors.out
      exact (congr_arg P x.2.1).mp (this x.1 x.2.2.1 x.2.2.2)
  intro l
  induction' l with σ l ih
  · exact fun _ _ => base_one
  · intro h1 h2
    rw [List.prod_cons]
    

Proof state:
case intro.cons
ι : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : DecidableEq α
inst✝ : Finite β
P : Perm β → Prop
σ✝ : Perm β
base_one : P 1
base_cycles : ∀ (σ : Perm β), IsCycle σ → P σ
induction_disjoint : ∀ (σ τ : Perm β), Disjoint σ τ → IsCycle σ → P σ → P τ → P (σ * τ)
val✝ : Fintype β
σ : Perm β
l : List (Perm β)
ih : (∀ τ ∈ l, IsCycle τ) → List.Pairwise Disjoint l → P (List.prod l)
h1 : ∀ τ ∈ σ :: l, IsCycle τ
h2 : List.Pairwise Disjoint (σ :: l)
⊢ P (σ * List.prod l)

Next tactic:
exact
      induction_disjoint σ l.prod (disjoint_prod_right _ (List.pairwise_cons.mp h2).1)
        (h1 _ (List.mem_cons_self _ _)) (base_cycles σ (h1 σ (l.mem_cons_self σ)))
        (ih (fun τ hτ => h1 τ (List.mem_cons_of_mem σ hτ)) h2.of_cons)
theorem cycleFactorsFinset_mul_inv_mem_eq_sdiff [Fintype α] {f g : Perm α}
    (h : f ∈ cycleFactorsFinset g) : cycleFactorsFinset (g * f⁻¹) = cycleFactorsFinset g \ {f} := by
  

Proof state:
ι : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : DecidableEq α
inst✝ : Fintype α
f g : Perm α
h : f ∈ cycleFactorsFinset g
⊢ cycleFactorsFinset (g * f⁻¹) = cycleFactorsFinset g \ {f}

Next tactic:
revert f
theorem cycleFactorsFinset_mul_inv_mem_eq_sdiff [Fintype α] {f g : Perm α}
    (h : f ∈ cycleFactorsFinset g) : cycleFactorsFinset (g * f⁻¹) = cycleFactorsFinset g \ {f} := by
  revert f
  

Proof state:
ι : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : DecidableEq α
inst✝ : Fintype α
g : Perm α
⊢ ∀ {f : Perm α}, f ∈ cycleFactorsFinset g → cycleFactorsFinset (g * f⁻¹) = cycleFactorsFinset g \ {f}

Next tactic:
refine'
    cycle_induction_on (P := fun {g : Perm α} ↦
      ∀ {f}, (f ∈ cycleFactorsFinset g)
        → cycleFactorsFinset (g * f⁻¹) = cycleFactorsFinset g \ {f}) _ _ _ _
theorem cycleFactorsFinset_mul_inv_mem_eq_sdiff [Fintype α] {f g : Perm α}
    (h : f ∈ cycleFactorsFinset g) : cycleFactorsFinset (g * f⁻¹) = cycleFactorsFinset g \ {f} := by
  revert f
  refine'
    cycle_induction_on (P := fun {g : Perm α} ↦
      ∀ {f}, (f ∈ cycleFactorsFinset g)
        → cycleFactorsFinset (g * f⁻¹) = cycleFactorsFinset g \ {f}) _ _ _ _
  · 

Proof state:
case refine'_1
ι : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : DecidableEq α
inst✝ : Fintype α
g f✝ : Perm α
⊢ fun {g} => ∀ {f : Perm α}, f ∈ cycleFactorsFinset g → cycleFactorsFinset (g * f⁻¹) = cycleFactorsFinset g \ {f}

Next tactic:
simp
theorem cycleFactorsFinset_mul_inv_mem_eq_sdiff [Fintype α] {f g : Perm α}
    (h : f ∈ cycleFactorsFinset g) : cycleFactorsFinset (g * f⁻¹) = cycleFactorsFinset g \ {f} := by
  revert f
  refine'
    cycle_induction_on (P := fun {g : Perm α} ↦
      ∀ {f}, (f ∈ cycleFactorsFinset g)
        → cycleFactorsFinset (g * f⁻¹) = cycleFactorsFinset g \ {f}) _ _ _ _
  · simp
  · 

Proof state:
case refine'_2
ι : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : DecidableEq α
inst✝ : Fintype α
g f✝ : Perm α
⊢ ∀ (σ : Perm α),
    IsCycle σ → fun {g} =>
      ∀ {f : Perm α}, f ∈ cycleFactorsFinset g → cycleFactorsFinset (g * f⁻¹) = cycleFactorsFinset g \ {f}

Next tactic:
intro σ hσ f hf
theorem cycleFactorsFinset_mul_inv_mem_eq_sdiff [Fintype α] {f g : Perm α}
    (h : f ∈ cycleFactorsFinset g) : cycleFactorsFinset (g * f⁻¹) = cycleFactorsFinset g \ {f} := by
  revert f
  refine'
    cycle_induction_on (P := fun {g : Perm α} ↦
      ∀ {f}, (f ∈ cycleFactorsFinset g)
        → cycleFactorsFinset (g * f⁻¹) = cycleFactorsFinset g \ {f}) _ _ _ _
  · simp
  · intro σ hσ f hf
    

Proof state:
case refine'_2
ι : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : DecidableEq α
inst✝ : Fintype α
g f✝ σ : Perm α
hσ : IsCycle σ
f : Perm α
hf : f ∈ cycleFactorsFinset σ
⊢ cycleFactorsFinset (σ * f⁻¹) = cycleFactorsFinset σ \ {f}

Next tactic:
simp only [cycleFactorsFinset_eq_singleton_self_iff.mpr hσ, mem_singleton] at hf ⊢
theorem cycleFactorsFinset_mul_inv_mem_eq_sdiff [Fintype α] {f g : Perm α}
    (h : f ∈ cycleFactorsFinset g) : cycleFactorsFinset (g * f⁻¹) = cycleFactorsFinset g \ {f} := by
  revert f
  refine'
    cycle_induction_on (P := fun {g : Perm α} ↦
      ∀ {f}, (f ∈ cycleFactorsFinset g)
        → cycleFactorsFinset (g * f⁻¹) = cycleFactorsFinset g \ {f}) _ _ _ _
  · simp
  · intro σ hσ f hf
    simp only [cycleFactorsFinset_eq_singleton_self_iff.mpr hσ, mem_singleton] at hf ⊢
    

Proof state:
case refine'_2
ι : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : DecidableEq α
inst✝ : Fintype α
g f✝ σ : Perm α
hσ : IsCycle σ
f : Perm α
hf : f = σ
⊢ cycleFactorsFinset (σ * f⁻¹) = {σ} \ {f}

Next tactic:
simp [hf]
theorem cycleFactorsFinset_mul_inv_mem_eq_sdiff [Fintype α] {f g : Perm α}
    (h : f ∈ cycleFactorsFinset g) : cycleFactorsFinset (g * f⁻¹) = cycleFactorsFinset g \ {f} := by
  revert f
  refine'
    cycle_induction_on (P := fun {g : Perm α} ↦
      ∀ {f}, (f ∈ cycleFactorsFinset g)
        → cycleFactorsFinset (g * f⁻¹) = cycleFactorsFinset g \ {f}) _ _ _ _
  · simp
  · intro σ hσ f hf
    simp only [cycleFactorsFinset_eq_singleton_self_iff.mpr hσ, mem_singleton] at hf ⊢
    simp [hf]
  · 

Proof state:
case refine'_3
ι : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : DecidableEq α
inst✝ : Fintype α
g f✝ : Perm α
⊢ ∀ (σ τ : Perm α),
    Disjoint σ τ →
      IsCycle σ →
        (fun {g} =>
            ∀ {f : Perm α}, f ∈ cycleFactorsFinset g → cycleFactorsFinset (g * f⁻¹) = cycleFactorsFinset g \ {f}) →
          (fun {g} =>
              ∀ {f : Perm α}, f ∈ cycleFactorsFinset g → cycleFactorsFinset (g * f⁻¹) = cycleFactorsFinset g \ {f}) →
            fun {g} =>
            ∀ {f : Perm α}, f ∈ cycleFactorsFinset g → cycleFactorsFinset (g * f⁻¹) = cycleFactorsFinset g \ {f}

Next tactic:
intro σ τ hd _ hσ hτ f
theorem cycleFactorsFinset_mul_inv_mem_eq_sdiff [Fintype α] {f g : Perm α}
    (h : f ∈ cycleFactorsFinset g) : cycleFactorsFinset (g * f⁻¹) = cycleFactorsFinset g \ {f} := by
  revert f
  refine'
    cycle_induction_on (P := fun {g : Perm α} ↦
      ∀ {f}, (f ∈ cycleFactorsFinset g)
        → cycleFactorsFinset (g * f⁻¹) = cycleFactorsFinset g \ {f}) _ _ _ _
  · simp
  · intro σ hσ f hf
    simp only [cycleFactorsFinset_eq_singleton_self_iff.mpr hσ, mem_singleton] at hf ⊢
    simp [hf]
  · intro σ τ hd _ hσ hτ f
    

Proof state:
case refine'_3
ι : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : DecidableEq α
inst✝ : Fintype α
g f✝ σ τ : Perm α
hd : Disjoint σ τ
a✝ : IsCycle σ
hσ : ∀ {f : Perm α}, f ∈ cycleFactorsFinset σ → cycleFactorsFinset (σ * f⁻¹) = cycleFactorsFinset σ \ {f}
hτ : ∀ {f : Perm α}, f ∈ cycleFactorsFinset τ → cycleFactorsFinset (τ * f⁻¹) = cycleFactorsFinset τ \ {f}
f : Perm α
⊢ f ∈ cycleFactorsFinset (σ * τ) → cycleFactorsFinset (σ * τ * f⁻¹) = cycleFactorsFinset (σ * τ) \ {f}

Next tactic:
simp_rw [hd.cycleFactorsFinset_mul_eq_union, mem_union]
theorem cycleFactorsFinset_mul_inv_mem_eq_sdiff [Fintype α] {f g : Perm α}
    (h : f ∈ cycleFactorsFinset g) : cycleFactorsFinset (g * f⁻¹) = cycleFactorsFinset g \ {f} := by
  revert f
  refine'
    cycle_induction_on (P := fun {g : Perm α} ↦
      ∀ {f}, (f ∈ cycleFactorsFinset g)
        → cycleFactorsFinset (g * f⁻¹) = cycleFactorsFinset g \ {f}) _ _ _ _
  · simp
  · intro σ hσ f hf
    simp only [cycleFactorsFinset_eq_singleton_self_iff.mpr hσ, mem_singleton] at hf ⊢
    simp [hf]
  · intro σ τ hd _ hσ hτ f
    simp_rw [hd.cycleFactorsFinset_mul_eq_union, mem_union]
    -- if only `wlog` could work here...
    

Proof state:
case refine'_3
ι : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : DecidableEq α
inst✝ : Fintype α
g f✝ σ τ : Perm α
hd : Disjoint σ τ
a✝ : IsCycle σ
hσ : ∀ {f : Perm α}, f ∈ cycleFactorsFinset σ → cycleFactorsFinset (σ * f⁻¹) = cycleFactorsFinset σ \ {f}
hτ : ∀ {f : Perm α}, f ∈ cycleFactorsFinset τ → cycleFactorsFinset (τ * f⁻¹) = cycleFactorsFinset τ \ {f}
f : Perm α
⊢ f ∈ cycleFactorsFinset σ ∨ f ∈ cycleFactorsFinset τ →
    cycleFactorsFinset (σ * τ * f⁻¹) = (cycleFactorsFinset σ ∪ cycleFactorsFinset τ) \ {f}

Next tactic:
rintro (hf | hf)
theorem cycleFactorsFinset_mul_inv_mem_eq_sdiff [Fintype α] {f g : Perm α}
    (h : f ∈ cycleFactorsFinset g) : cycleFactorsFinset (g * f⁻¹) = cycleFactorsFinset g \ {f} := by
  revert f
  refine'
    cycle_induction_on (P := fun {g : Perm α} ↦
      ∀ {f}, (f ∈ cycleFactorsFinset g)
        → cycleFactorsFinset (g * f⁻¹) = cycleFactorsFinset g \ {f}) _ _ _ _
  · simp
  · intro σ hσ f hf
    simp only [cycleFactorsFinset_eq_singleton_self_iff.mpr hσ, mem_singleton] at hf ⊢
    simp [hf]
  · intro σ τ hd _ hσ hτ f
    simp_rw [hd.cycleFactorsFinset_mul_eq_union, mem_union]
    -- if only `wlog` could work here...
    rintro (hf | hf)
    · 

Proof state:
case refine'_3.inl
ι : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : DecidableEq α
inst✝ : Fintype α
g f✝ σ τ : Perm α
hd : Disjoint σ τ
a✝ : IsCycle σ
hσ : ∀ {f : Perm α}, f ∈ cycleFactorsFinset σ → cycleFactorsFinset (σ * f⁻¹) = cycleFactorsFinset σ \ {f}
hτ : ∀ {f : Perm α}, f ∈ cycleFactorsFinset τ → cycleFactorsFinset (τ * f⁻¹) = cycleFactorsFinset τ \ {f}
f : Perm α
hf : f ∈ cycleFactorsFinset σ
⊢ cycleFactorsFinset (σ * τ * f⁻¹) = (cycleFactorsFinset σ ∪ cycleFactorsFinset τ) \ {f}

Next tactic:
rw [hd.commute.eq, union_comm, union_sdiff_distrib, sdiff_singleton_eq_erase,
        erase_eq_of_not_mem, mul_assoc, Disjoint.cycleFactorsFinset_mul_eq_union, hσ hf]
theorem cycleFactorsFinset_mul_inv_mem_eq_sdiff [Fintype α] {f g : Perm α}
    (h : f ∈ cycleFactorsFinset g) : cycleFactorsFinset (g * f⁻¹) = cycleFactorsFinset g \ {f} := by
  revert f
  refine'
    cycle_induction_on (P := fun {g : Perm α} ↦
      ∀ {f}, (f ∈ cycleFactorsFinset g)
        → cycleFactorsFinset (g * f⁻¹) = cycleFactorsFinset g \ {f}) _ _ _ _
  · simp
  · intro σ hσ f hf
    simp only [cycleFactorsFinset_eq_singleton_self_iff.mpr hσ, mem_singleton] at hf ⊢
    simp [hf]
  · intro σ τ hd _ hσ hτ f
    simp_rw [hd.cycleFactorsFinset_mul_eq_union, mem_union]
    -- if only `wlog` could work here...
    rintro (hf | hf)
    · rw [hd.commute.eq, union_comm, union_sdiff_distrib, sdiff_singleton_eq_erase,
        erase_eq_of_not_mem, mul_assoc, Disjoint.cycleFactorsFinset_mul_eq_union, hσ hf]
      · 

Proof state:
case refine'_3.inl
ι : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : DecidableEq α
inst✝ : Fintype α
g f✝ σ τ : Perm α
hd : Disjoint σ τ
a✝ : IsCycle σ
hσ : ∀ {f : Perm α}, f ∈ cycleFactorsFinset σ → cycleFactorsFinset (σ * f⁻¹) = cycleFactorsFinset σ \ {f}
hτ : ∀ {f : Perm α}, f ∈ cycleFactorsFinset τ → cycleFactorsFinset (τ * f⁻¹) = cycleFactorsFinset τ \ {f}
f : Perm α
hf : f ∈ cycleFactorsFinset σ
⊢ Disjoint τ (σ * f⁻¹)

Next tactic:
rw [mem_cycleFactorsFinset_iff] at hf
theorem cycleFactorsFinset_mul_inv_mem_eq_sdiff [Fintype α] {f g : Perm α}
    (h : f ∈ cycleFactorsFinset g) : cycleFactorsFinset (g * f⁻¹) = cycleFactorsFinset g \ {f} := by
  revert f
  refine'
    cycle_induction_on (P := fun {g : Perm α} ↦
      ∀ {f}, (f ∈ cycleFactorsFinset g)
        → cycleFactorsFinset (g * f⁻¹) = cycleFactorsFinset g \ {f}) _ _ _ _
  · simp
  · intro σ hσ f hf
    simp only [cycleFactorsFinset_eq_singleton_self_iff.mpr hσ, mem_singleton] at hf ⊢
    simp [hf]
  · intro σ τ hd _ hσ hτ f
    simp_rw [hd.cycleFactorsFinset_mul_eq_union, mem_union]
    -- if only `wlog` could work here...
    rintro (hf | hf)
    · rw [hd.commute.eq, union_comm, union_sdiff_distrib, sdiff_singleton_eq_erase,
        erase_eq_of_not_mem, mul_assoc, Disjoint.cycleFactorsFinset_mul_eq_union, hσ hf]
      · rw [mem_cycleFactorsFinset_iff] at hf
        

Proof state:
case refine'_3.inl
ι : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : DecidableEq α
inst✝ : Fintype α
g f✝ σ τ : Perm α
hd : Disjoint σ τ
a✝ : IsCycle σ
hσ : ∀ {f : Perm α}, f ∈ cycleFactorsFinset σ → cycleFactorsFinset (σ * f⁻¹) = cycleFactorsFinset σ \ {f}
hτ : ∀ {f : Perm α}, f ∈ cycleFactorsFinset τ → cycleFactorsFinset (τ * f⁻¹) = cycleFactorsFinset τ \ {f}
f : Perm α
hf : IsCycle f ∧ ∀ a ∈ support f, f a = σ a
⊢ Disjoint τ (σ * f⁻¹)

Next tactic:
intro x
theorem cycleFactorsFinset_mul_inv_mem_eq_sdiff [Fintype α] {f g : Perm α}
    (h : f ∈ cycleFactorsFinset g) : cycleFactorsFinset (g * f⁻¹) = cycleFactorsFinset g \ {f} := by
  revert f
  refine'
    cycle_induction_on (P := fun {g : Perm α} ↦
      ∀ {f}, (f ∈ cycleFactorsFinset g)
        → cycleFactorsFinset (g * f⁻¹) = cycleFactorsFinset g \ {f}) _ _ _ _
  · simp
  · intro σ hσ f hf
    simp only [cycleFactorsFinset_eq_singleton_self_iff.mpr hσ, mem_singleton] at hf ⊢
    simp [hf]
  · intro σ τ hd _ hσ hτ f
    simp_rw [hd.cycleFactorsFinset_mul_eq_union, mem_union]
    -- if only `wlog` could work here...
    rintro (hf | hf)
    · rw [hd.commute.eq, union_comm, union_sdiff_distrib, sdiff_singleton_eq_erase,
        erase_eq_of_not_mem, mul_assoc, Disjoint.cycleFactorsFinset_mul_eq_union, hσ hf]
      · rw [mem_cycleFactorsFinset_iff] at hf
        intro x
        

Proof state:
case refine'_3.inl
ι : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : DecidableEq α
inst✝ : Fintype α
g f✝ σ τ : Perm α
hd : Disjoint σ τ
a✝ : IsCycle σ
hσ : ∀ {f : Perm α}, f ∈ cycleFactorsFinset σ → cycleFactorsFinset (σ * f⁻¹) = cycleFactorsFinset σ \ {f}
hτ : ∀ {f : Perm α}, f ∈ cycleFactorsFinset τ → cycleFactorsFinset (τ * f⁻¹) = cycleFactorsFinset τ \ {f}
f : Perm α
hf : IsCycle f ∧ ∀ a ∈ support f, f a = σ a
x : α
⊢ τ x = x ∨ (σ * f⁻¹) x = x

Next tactic:
cases' hd.symm x with hx hx
theorem cycleFactorsFinset_mul_inv_mem_eq_sdiff [Fintype α] {f g : Perm α}
    (h : f ∈ cycleFactorsFinset g) : cycleFactorsFinset (g * f⁻¹) = cycleFactorsFinset g \ {f} := by
  revert f
  refine'
    cycle_induction_on (P := fun {g : Perm α} ↦
      ∀ {f}, (f ∈ cycleFactorsFinset g)
        → cycleFactorsFinset (g * f⁻¹) = cycleFactorsFinset g \ {f}) _ _ _ _
  · simp
  · intro σ hσ f hf
    simp only [cycleFactorsFinset_eq_singleton_self_iff.mpr hσ, mem_singleton] at hf ⊢
    simp [hf]
  · intro σ τ hd _ hσ hτ f
    simp_rw [hd.cycleFactorsFinset_mul_eq_union, mem_union]
    -- if only `wlog` could work here...
    rintro (hf | hf)
    · rw [hd.commute.eq, union_comm, union_sdiff_distrib, sdiff_singleton_eq_erase,
        erase_eq_of_not_mem, mul_assoc, Disjoint.cycleFactorsFinset_mul_eq_union, hσ hf]
      · rw [mem_cycleFactorsFinset_iff] at hf
        intro x
        cases' hd.symm x with hx hx
        · 

Proof state:
case refine'_3.inl.inl
ι : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : DecidableEq α
inst✝ : Fintype α
g f✝ σ τ : Perm α
hd : Disjoint σ τ
a✝ : IsCycle σ
hσ : ∀ {f : Perm α}, f ∈ cycleFactorsFinset σ → cycleFactorsFinset (σ * f⁻¹) = cycleFactorsFinset σ \ {f}
hτ : ∀ {f : Perm α}, f ∈ cycleFactorsFinset τ → cycleFactorsFinset (τ * f⁻¹) = cycleFactorsFinset τ \ {f}
f : Perm α
hf : IsCycle f ∧ ∀ a ∈ support f, f a = σ a
x : α
hx : τ x = x
⊢ τ x = x ∨ (σ * f⁻¹) x = x

Next tactic:
exact Or.inl hx
theorem cycleFactorsFinset_mul_inv_mem_eq_sdiff [Fintype α] {f g : Perm α}
    (h : f ∈ cycleFactorsFinset g) : cycleFactorsFinset (g * f⁻¹) = cycleFactorsFinset g \ {f} := by
  revert f
  refine'
    cycle_induction_on (P := fun {g : Perm α} ↦
      ∀ {f}, (f ∈ cycleFactorsFinset g)
        → cycleFactorsFinset (g * f⁻¹) = cycleFactorsFinset g \ {f}) _ _ _ _
  · simp
  · intro σ hσ f hf
    simp only [cycleFactorsFinset_eq_singleton_self_iff.mpr hσ, mem_singleton] at hf ⊢
    simp [hf]
  · intro σ τ hd _ hσ hτ f
    simp_rw [hd.cycleFactorsFinset_mul_eq_union, mem_union]
    -- if only `wlog` could work here...
    rintro (hf | hf)
    · rw [hd.commute.eq, union_comm, union_sdiff_distrib, sdiff_singleton_eq_erase,
        erase_eq_of_not_mem, mul_assoc, Disjoint.cycleFactorsFinset_mul_eq_union, hσ hf]
      · rw [mem_cycleFactorsFinset_iff] at hf
        intro x
        cases' hd.symm x with hx hx
        · exact Or.inl hx
        · 

Proof state:
case refine'_3.inl.inr
ι : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : DecidableEq α
inst✝ : Fintype α
g f✝ σ τ : Perm α
hd : Disjoint σ τ
a✝ : IsCycle σ
hσ : ∀ {f : Perm α}, f ∈ cycleFactorsFinset σ → cycleFactorsFinset (σ * f⁻¹) = cycleFactorsFinset σ \ {f}
hτ : ∀ {f : Perm α}, f ∈ cycleFactorsFinset τ → cycleFactorsFinset (τ * f⁻¹) = cycleFactorsFinset τ \ {f}
f : Perm α
hf : IsCycle f ∧ ∀ a ∈ support f, f a = σ a
x : α
hx : σ x = x
⊢ τ x = x ∨ (σ * f⁻¹) x = x

Next tactic:
refine' Or.inr _
theorem cycleFactorsFinset_mul_inv_mem_eq_sdiff [Fintype α] {f g : Perm α}
    (h : f ∈ cycleFactorsFinset g) : cycleFactorsFinset (g * f⁻¹) = cycleFactorsFinset g \ {f} := by
  revert f
  refine'
    cycle_induction_on (P := fun {g : Perm α} ↦
      ∀ {f}, (f ∈ cycleFactorsFinset g)
        → cycleFactorsFinset (g * f⁻¹) = cycleFactorsFinset g \ {f}) _ _ _ _
  · simp
  · intro σ hσ f hf
    simp only [cycleFactorsFinset_eq_singleton_self_iff.mpr hσ, mem_singleton] at hf ⊢
    simp [hf]
  · intro σ τ hd _ hσ hτ f
    simp_rw [hd.cycleFactorsFinset_mul_eq_union, mem_union]
    -- if only `wlog` could work here...
    rintro (hf | hf)
    · rw [hd.commute.eq, union_comm, union_sdiff_distrib, sdiff_singleton_eq_erase,
        erase_eq_of_not_mem, mul_assoc, Disjoint.cycleFactorsFinset_mul_eq_union, hσ hf]
      · rw [mem_cycleFactorsFinset_iff] at hf
        intro x
        cases' hd.symm x with hx hx
        · exact Or.inl hx
        · refine' Or.inr _
          

Proof state:
case refine'_3.inl.inr
ι : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : DecidableEq α
inst✝ : Fintype α
g f✝ σ τ : Perm α
hd : Disjoint σ τ
a✝ : IsCycle σ
hσ : ∀ {f : Perm α}, f ∈ cycleFactorsFinset σ → cycleFactorsFinset (σ * f⁻¹) = cycleFactorsFinset σ \ {f}
hτ : ∀ {f : Perm α}, f ∈ cycleFactorsFinset τ → cycleFactorsFinset (τ * f⁻¹) = cycleFactorsFinset τ \ {f}
f : Perm α
hf : IsCycle f ∧ ∀ a ∈ support f, f a = σ a
x : α
hx : σ x = x
⊢ (σ * f⁻¹) x = x

Next tactic:
by_cases hfx : f x = x
theorem cycleFactorsFinset_mul_inv_mem_eq_sdiff [Fintype α] {f g : Perm α}
    (h : f ∈ cycleFactorsFinset g) : cycleFactorsFinset (g * f⁻¹) = cycleFactorsFinset g \ {f} := by
  revert f
  refine'
    cycle_induction_on (P := fun {g : Perm α} ↦
      ∀ {f}, (f ∈ cycleFactorsFinset g)
        → cycleFactorsFinset (g * f⁻¹) = cycleFactorsFinset g \ {f}) _ _ _ _
  · simp
  · intro σ hσ f hf
    simp only [cycleFactorsFinset_eq_singleton_self_iff.mpr hσ, mem_singleton] at hf ⊢
    simp [hf]
  · intro σ τ hd _ hσ hτ f
    simp_rw [hd.cycleFactorsFinset_mul_eq_union, mem_union]
    -- if only `wlog` could work here...
    rintro (hf | hf)
    · rw [hd.commute.eq, union_comm, union_sdiff_distrib, sdiff_singleton_eq_erase,
        erase_eq_of_not_mem, mul_assoc, Disjoint.cycleFactorsFinset_mul_eq_union, hσ hf]
      · rw [mem_cycleFactorsFinset_iff] at hf
        intro x
        cases' hd.symm x with hx hx
        · exact Or.inl hx
        · refine' Or.inr _
          by_cases hfx : f x = x
          · 

Proof state:
case pos
ι : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : DecidableEq α
inst✝ : Fintype α
g f✝ σ τ : Perm α
hd : Disjoint σ τ
a✝ : IsCycle σ
hσ : ∀ {f : Perm α}, f ∈ cycleFactorsFinset σ → cycleFactorsFinset (σ * f⁻¹) = cycleFactorsFinset σ \ {f}
hτ : ∀ {f : Perm α}, f ∈ cycleFactorsFinset τ → cycleFactorsFinset (τ * f⁻¹) = cycleFactorsFinset τ \ {f}
f : Perm α
hf : IsCycle f ∧ ∀ a ∈ support f, f a = σ a
x : α
hx : σ x = x
hfx : f x = x
⊢ (σ * f⁻¹) x = x

Next tactic:
rw [← hfx]
theorem cycleFactorsFinset_mul_inv_mem_eq_sdiff [Fintype α] {f g : Perm α}
    (h : f ∈ cycleFactorsFinset g) : cycleFactorsFinset (g * f⁻¹) = cycleFactorsFinset g \ {f} := by
  revert f
  refine'
    cycle_induction_on (P := fun {g : Perm α} ↦
      ∀ {f}, (f ∈ cycleFactorsFinset g)
        → cycleFactorsFinset (g * f⁻¹) = cycleFactorsFinset g \ {f}) _ _ _ _
  · simp
  · intro σ hσ f hf
    simp only [cycleFactorsFinset_eq_singleton_self_iff.mpr hσ, mem_singleton] at hf ⊢
    simp [hf]
  · intro σ τ hd _ hσ hτ f
    simp_rw [hd.cycleFactorsFinset_mul_eq_union, mem_union]
    -- if only `wlog` could work here...
    rintro (hf | hf)
    · rw [hd.commute.eq, union_comm, union_sdiff_distrib, sdiff_singleton_eq_erase,
        erase_eq_of_not_mem, mul_assoc, Disjoint.cycleFactorsFinset_mul_eq_union, hσ hf]
      · rw [mem_cycleFactorsFinset_iff] at hf
        intro x
        cases' hd.symm x with hx hx
        · exact Or.inl hx
        · refine' Or.inr _
          by_cases hfx : f x = x
          · rw [← hfx]
            

Proof state:
case pos
ι : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : DecidableEq α
inst✝ : Fintype α
g f✝ σ τ : Perm α
hd : Disjoint σ τ
a✝ : IsCycle σ
hσ : ∀ {f : Perm α}, f ∈ cycleFactorsFinset σ → cycleFactorsFinset (σ * f⁻¹) = cycleFactorsFinset σ \ {f}
hτ : ∀ {f : Perm α}, f ∈ cycleFactorsFinset τ → cycleFactorsFinset (τ * f⁻¹) = cycleFactorsFinset τ \ {f}
f : Perm α
hf : IsCycle f ∧ ∀ a ∈ support f, f a = σ a
x : α
hx : σ x = x
hfx : f x = x
⊢ (σ * f⁻¹) (f x) = f x

Next tactic:
simpa [hx] using hfx.symm