l3lab/ntp-mathlib huggingface dataset:
theorem Disjoint.isConj_mul {α : Type*} [Finite α] {σ τ π ρ : Perm α} (hc1 : IsConj σ π)
    (hc2 : IsConj τ ρ) (hd1 : Disjoint σ τ) (hd2 : Disjoint π ρ) : IsConj (σ * τ) (π * ρ) := by
  classical
    cases nonempty_fintype α
    obtain ⟨f, rfl⟩ := isConj_iff.1 hc1
    obtain ⟨g, rfl⟩ := isConj_iff.1 hc2
    have hd1' := coe_inj.2 hd1.support_mul
    have hd2' := coe_inj.2 hd2.support_mul
    rw [coe_union] at *
    have hd1'' := disjoint_coe.2 (disjoint_iff_disjoint_support.1 hd1)
    have hd2'' := disjoint_coe.2 (disjoint_iff_disjoint_support.1 hd2)
    refine' isConj_of_support_equiv _ _
    · refine'
          ((Equiv.Set.ofEq hd1').trans (Equiv.Set.union hd1''.le_bot)).trans
            ((Equiv.sumCongr (subtypeEquiv f fun a => _) (subtypeEquiv g fun a => _)).trans
              ((Equiv.Set.ofEq hd2').trans (Equiv.Set.union hd2''.le_bot)).symm) <;>
      · simp only [Set.mem_image, toEmbedding_apply, exists_eq_right, support_conj, coe_map,
          apply_eq_iff_eq]
    · intro x hx
      simp only [trans_apply, symm_trans_apply, Equiv.Set.ofEq_apply, Equiv.Set.ofEq_symm_apply,
        Equiv.sumCongr_apply]
      rw [hd1', Set.mem_union] at hx
      cases' hx with hxσ hxτ
      · rw [mem_coe, mem_support] at hxσ
        rw [Set.union_apply_left hd1''.le_bot _, Set.union_apply_left hd1''.le_bot _]
        simp only [subtypeEquiv_apply, Perm.coe_mul, Sum.map_inl, comp_apply,
          Set.union_symm_apply_left, Subtype.coe_mk, apply_eq_iff_eq]
        · have h := (hd2 (f x)).resolve_left ?_
          · rw [mul_apply, mul_apply] at h
            rw [h, inv_apply_self, (hd1 x).resolve_left hxσ]
          · rwa [mul_apply, mul_apply, inv_apply_self, apply_eq_iff_eq]
        · rwa [Subtype.coe_mk, Perm.mul_apply, (hd1 x).resolve_left hxσ, mem_coe,
            apply_mem_support, mem_support]
        · rwa [Subtype.coe_mk, mem_coe, mem_support]
      · rw [mem_coe, ← apply_mem_support, mem_support] at hxτ
        rw [Set.union_apply_right hd1''.le_bot _, Set.union_apply_right hd1''.le_bot _]
        simp only [subtypeEquiv_apply, Perm.coe_mul, Sum.map_inr, comp_apply,
          Set.union_symm_apply_right, Subtype.coe_mk, apply_eq_iff_eq]
        · 

Proof state:
case intro.intro.intro.refine'_2.inr
ι : Type u_1
α✝ : Type u_2
β : Type u_3
inst✝² : DecidableEq α✝
inst✝¹ : Fintype α✝
σ✝ τ✝ : Perm α✝
α : Type u_4
inst✝ : Finite α
σ τ : Perm α
hd1 : Disjoint σ τ
val✝ : Fintype α
f : Perm α
hc1 : IsConj σ (f * σ * f⁻¹)
g : Perm α
hc2 : IsConj τ (g * τ * g⁻¹)
hd2 : Disjoint (f * σ * f⁻¹) (g * τ * g⁻¹)
hd1' : ↑(support (σ * τ)) = ↑(support σ) ∪ ↑(support τ)
hd2' : ↑(support (f * σ * f⁻¹ * (g * τ * g⁻¹))) = ↑(support (f * σ * f⁻¹)) ∪ ↑(support (g * τ * g⁻¹))
hd1'' : _root_.Disjoint ↑(support σ) ↑(support τ)
hd2'' : _root_.Disjoint ↑(support (f * σ * f⁻¹)) ↑(support (g * τ * g⁻¹))
x : α
hx : x ∈ ↑(support (σ * τ))
hxτ : τ (τ x) ≠ τ x
⊢ g (σ (τ x)) = f (σ (f⁻¹ (g (τ (g⁻¹ (g x))))))

Next tactic:
have h := (hd2 (g (τ x))).resolve_right ?_
theorem Disjoint.isConj_mul {α : Type*} [Finite α] {σ τ π ρ : Perm α} (hc1 : IsConj σ π)
    (hc2 : IsConj τ ρ) (hd1 : Disjoint σ τ) (hd2 : Disjoint π ρ) : IsConj (σ * τ) (π * ρ) := by
  classical
    cases nonempty_fintype α
    obtain ⟨f, rfl⟩ := isConj_iff.1 hc1
    obtain ⟨g, rfl⟩ := isConj_iff.1 hc2
    have hd1' := coe_inj.2 hd1.support_mul
    have hd2' := coe_inj.2 hd2.support_mul
    rw [coe_union] at *
    have hd1'' := disjoint_coe.2 (disjoint_iff_disjoint_support.1 hd1)
    have hd2'' := disjoint_coe.2 (disjoint_iff_disjoint_support.1 hd2)
    refine' isConj_of_support_equiv _ _
    · refine'
          ((Equiv.Set.ofEq hd1').trans (Equiv.Set.union hd1''.le_bot)).trans
            ((Equiv.sumCongr (subtypeEquiv f fun a => _) (subtypeEquiv g fun a => _)).trans
              ((Equiv.Set.ofEq hd2').trans (Equiv.Set.union hd2''.le_bot)).symm) <;>
      · simp only [Set.mem_image, toEmbedding_apply, exists_eq_right, support_conj, coe_map,
          apply_eq_iff_eq]
    · intro x hx
      simp only [trans_apply, symm_trans_apply, Equiv.Set.ofEq_apply, Equiv.Set.ofEq_symm_apply,
        Equiv.sumCongr_apply]
      rw [hd1', Set.mem_union] at hx
      cases' hx with hxσ hxτ
      · rw [mem_coe, mem_support] at hxσ
        rw [Set.union_apply_left hd1''.le_bot _, Set.union_apply_left hd1''.le_bot _]
        simp only [subtypeEquiv_apply, Perm.coe_mul, Sum.map_inl, comp_apply,
          Set.union_symm_apply_left, Subtype.coe_mk, apply_eq_iff_eq]
        · have h := (hd2 (f x)).resolve_left ?_
          · rw [mul_apply, mul_apply] at h
            rw [h, inv_apply_self, (hd1 x).resolve_left hxσ]
          · rwa [mul_apply, mul_apply, inv_apply_self, apply_eq_iff_eq]
        · rwa [Subtype.coe_mk, Perm.mul_apply, (hd1 x).resolve_left hxσ, mem_coe,
            apply_mem_support, mem_support]
        · rwa [Subtype.coe_mk, mem_coe, mem_support]
      · rw [mem_coe, ← apply_mem_support, mem_support] at hxτ
        rw [Set.union_apply_right hd1''.le_bot _, Set.union_apply_right hd1''.le_bot _]
        simp only [subtypeEquiv_apply, Perm.coe_mul, Sum.map_inr, comp_apply,
          Set.union_symm_apply_right, Subtype.coe_mk, apply_eq_iff_eq]
        · have h := (hd2 (g (τ x))).resolve_right ?_
          · 

Proof state:
case intro.intro.intro.refine'_2.inr.refine_2
ι : Type u_1
α✝ : Type u_2
β : Type u_3
inst✝² : DecidableEq α✝
inst✝¹ : Fintype α✝
σ✝ τ✝ : Perm α✝
α : Type u_4
inst✝ : Finite α
σ τ : Perm α
hd1 : Disjoint σ τ
val✝ : Fintype α
f : Perm α
hc1 : IsConj σ (f * σ * f⁻¹)
g : Perm α
hc2 : IsConj τ (g * τ * g⁻¹)
hd2 : Disjoint (f * σ * f⁻¹) (g * τ * g⁻¹)
hd1' : ↑(support (σ * τ)) = ↑(support σ) ∪ ↑(support τ)
hd2' : ↑(support (f * σ * f⁻¹ * (g * τ * g⁻¹))) = ↑(support (f * σ * f⁻¹)) ∪ ↑(support (g * τ * g⁻¹))
hd1'' : _root_.Disjoint ↑(support σ) ↑(support τ)
hd2'' : _root_.Disjoint ↑(support (f * σ * f⁻¹)) ↑(support (g * τ * g⁻¹))
x : α
hx : x ∈ ↑(support (σ * τ))
hxτ : τ (τ x) ≠ τ x
h : (f * σ * f⁻¹) (g (τ x)) = g (τ x)
⊢ g (σ (τ x)) = f (σ (f⁻¹ (g (τ (g⁻¹ (g x))))))

Next tactic:
rw [mul_apply, mul_apply] at h
theorem Disjoint.isConj_mul {α : Type*} [Finite α] {σ τ π ρ : Perm α} (hc1 : IsConj σ π)
    (hc2 : IsConj τ ρ) (hd1 : Disjoint σ τ) (hd2 : Disjoint π ρ) : IsConj (σ * τ) (π * ρ) := by
  classical
    cases nonempty_fintype α
    obtain ⟨f, rfl⟩ := isConj_iff.1 hc1
    obtain ⟨g, rfl⟩ := isConj_iff.1 hc2
    have hd1' := coe_inj.2 hd1.support_mul
    have hd2' := coe_inj.2 hd2.support_mul
    rw [coe_union] at *
    have hd1'' := disjoint_coe.2 (disjoint_iff_disjoint_support.1 hd1)
    have hd2'' := disjoint_coe.2 (disjoint_iff_disjoint_support.1 hd2)
    refine' isConj_of_support_equiv _ _
    · refine'
          ((Equiv.Set.ofEq hd1').trans (Equiv.Set.union hd1''.le_bot)).trans
            ((Equiv.sumCongr (subtypeEquiv f fun a => _) (subtypeEquiv g fun a => _)).trans
              ((Equiv.Set.ofEq hd2').trans (Equiv.Set.union hd2''.le_bot)).symm) <;>
      · simp only [Set.mem_image, toEmbedding_apply, exists_eq_right, support_conj, coe_map,
          apply_eq_iff_eq]
    · intro x hx
      simp only [trans_apply, symm_trans_apply, Equiv.Set.ofEq_apply, Equiv.Set.ofEq_symm_apply,
        Equiv.sumCongr_apply]
      rw [hd1', Set.mem_union] at hx
      cases' hx with hxσ hxτ
      · rw [mem_coe, mem_support] at hxσ
        rw [Set.union_apply_left hd1''.le_bot _, Set.union_apply_left hd1''.le_bot _]
        simp only [subtypeEquiv_apply, Perm.coe_mul, Sum.map_inl, comp_apply,
          Set.union_symm_apply_left, Subtype.coe_mk, apply_eq_iff_eq]
        · have h := (hd2 (f x)).resolve_left ?_
          · rw [mul_apply, mul_apply] at h
            rw [h, inv_apply_self, (hd1 x).resolve_left hxσ]
          · rwa [mul_apply, mul_apply, inv_apply_self, apply_eq_iff_eq]
        · rwa [Subtype.coe_mk, Perm.mul_apply, (hd1 x).resolve_left hxσ, mem_coe,
            apply_mem_support, mem_support]
        · rwa [Subtype.coe_mk, mem_coe, mem_support]
      · rw [mem_coe, ← apply_mem_support, mem_support] at hxτ
        rw [Set.union_apply_right hd1''.le_bot _, Set.union_apply_right hd1''.le_bot _]
        simp only [subtypeEquiv_apply, Perm.coe_mul, Sum.map_inr, comp_apply,
          Set.union_symm_apply_right, Subtype.coe_mk, apply_eq_iff_eq]
        · have h := (hd2 (g (τ x))).resolve_right ?_
          · rw [mul_apply, mul_apply] at h
            

Proof state:
case intro.intro.intro.refine'_2.inr.refine_2
ι : Type u_1
α✝ : Type u_2
β : Type u_3
inst✝² : DecidableEq α✝
inst✝¹ : Fintype α✝
σ✝ τ✝ : Perm α✝
α : Type u_4
inst✝ : Finite α
σ τ : Perm α
hd1 : Disjoint σ τ
val✝ : Fintype α
f : Perm α
hc1 : IsConj σ (f * σ * f⁻¹)
g : Perm α
hc2 : IsConj τ (g * τ * g⁻¹)
hd2 : Disjoint (f * σ * f⁻¹) (g * τ * g⁻¹)
hd1' : ↑(support (σ * τ)) = ↑(support σ) ∪ ↑(support τ)
hd2' : ↑(support (f * σ * f⁻¹ * (g * τ * g⁻¹))) = ↑(support (f * σ * f⁻¹)) ∪ ↑(support (g * τ * g⁻¹))
hd1'' : _root_.Disjoint ↑(support σ) ↑(support τ)
hd2'' : _root_.Disjoint ↑(support (f * σ * f⁻¹)) ↑(support (g * τ * g⁻¹))
x : α
hx : x ∈ ↑(support (σ * τ))
hxτ : τ (τ x) ≠ τ x
h : f (σ (f⁻¹ (g (τ x)))) = g (τ x)
⊢ g (σ (τ x)) = f (σ (f⁻¹ (g (τ (g⁻¹ (g x))))))

Next tactic:
rw [inv_apply_self, h, (hd1 (τ x)).resolve_right hxτ]
theorem Disjoint.isConj_mul {α : Type*} [Finite α] {σ τ π ρ : Perm α} (hc1 : IsConj σ π)
    (hc2 : IsConj τ ρ) (hd1 : Disjoint σ τ) (hd2 : Disjoint π ρ) : IsConj (σ * τ) (π * ρ) := by
  classical
    cases nonempty_fintype α
    obtain ⟨f, rfl⟩ := isConj_iff.1 hc1
    obtain ⟨g, rfl⟩ := isConj_iff.1 hc2
    have hd1' := coe_inj.2 hd1.support_mul
    have hd2' := coe_inj.2 hd2.support_mul
    rw [coe_union] at *
    have hd1'' := disjoint_coe.2 (disjoint_iff_disjoint_support.1 hd1)
    have hd2'' := disjoint_coe.2 (disjoint_iff_disjoint_support.1 hd2)
    refine' isConj_of_support_equiv _ _
    · refine'
          ((Equiv.Set.ofEq hd1').trans (Equiv.Set.union hd1''.le_bot)).trans
            ((Equiv.sumCongr (subtypeEquiv f fun a => _) (subtypeEquiv g fun a => _)).trans
              ((Equiv.Set.ofEq hd2').trans (Equiv.Set.union hd2''.le_bot)).symm) <;>
      · simp only [Set.mem_image, toEmbedding_apply, exists_eq_right, support_conj, coe_map,
          apply_eq_iff_eq]
    · intro x hx
      simp only [trans_apply, symm_trans_apply, Equiv.Set.ofEq_apply, Equiv.Set.ofEq_symm_apply,
        Equiv.sumCongr_apply]
      rw [hd1', Set.mem_union] at hx
      cases' hx with hxσ hxτ
      · rw [mem_coe, mem_support] at hxσ
        rw [Set.union_apply_left hd1''.le_bot _, Set.union_apply_left hd1''.le_bot _]
        simp only [subtypeEquiv_apply, Perm.coe_mul, Sum.map_inl, comp_apply,
          Set.union_symm_apply_left, Subtype.coe_mk, apply_eq_iff_eq]
        · have h := (hd2 (f x)).resolve_left ?_
          · rw [mul_apply, mul_apply] at h
            rw [h, inv_apply_self, (hd1 x).resolve_left hxσ]
          · rwa [mul_apply, mul_apply, inv_apply_self, apply_eq_iff_eq]
        · rwa [Subtype.coe_mk, Perm.mul_apply, (hd1 x).resolve_left hxσ, mem_coe,
            apply_mem_support, mem_support]
        · rwa [Subtype.coe_mk, mem_coe, mem_support]
      · rw [mem_coe, ← apply_mem_support, mem_support] at hxτ
        rw [Set.union_apply_right hd1''.le_bot _, Set.union_apply_right hd1''.le_bot _]
        simp only [subtypeEquiv_apply, Perm.coe_mul, Sum.map_inr, comp_apply,
          Set.union_symm_apply_right, Subtype.coe_mk, apply_eq_iff_eq]
        · have h := (hd2 (g (τ x))).resolve_right ?_
          · rw [mul_apply, mul_apply] at h
            rw [inv_apply_self, h, (hd1 (τ x)).resolve_right hxτ]
          · 

Proof state:
case intro.intro.intro.refine'_2.inr.refine_1
ι : Type u_1
α✝ : Type u_2
β : Type u_3
inst✝² : DecidableEq α✝
inst✝¹ : Fintype α✝
σ✝ τ✝ : Perm α✝
α : Type u_4
inst✝ : Finite α
σ τ : Perm α
hd1 : Disjoint σ τ
val✝ : Fintype α
f : Perm α
hc1 : IsConj σ (f * σ * f⁻¹)
g : Perm α
hc2 : IsConj τ (g * τ * g⁻¹)
hd2 : Disjoint (f * σ * f⁻¹) (g * τ * g⁻¹)
hd1' : ↑(support (σ * τ)) = ↑(support σ) ∪ ↑(support τ)
hd2' : ↑(support (f * σ * f⁻¹ * (g * τ * g⁻¹))) = ↑(support (f * σ * f⁻¹)) ∪ ↑(support (g * τ * g⁻¹))
hd1'' : _root_.Disjoint ↑(support σ) ↑(support τ)
hd2'' : _root_.Disjoint ↑(support (f * σ * f⁻¹)) ↑(support (g * τ * g⁻¹))
x : α
hx : x ∈ ↑(support (σ * τ))
hxτ : τ (τ x) ≠ τ x
⊢ ¬(g * τ * g⁻¹) (g (τ x)) = g (τ x)

Next tactic:
rwa [mul_apply, mul_apply, inv_apply_self, apply_eq_iff_eq]
theorem fixed_point_card_lt_of_ne_one [Fintype α] {σ : Perm α} (h : σ ≠ 1) :
    (filter (fun x => σ x = x) univ).card < Fintype.card α - 1 := by
  

Proof state:
ι : Type u_1
α : Type u_2
β : Type u_3
inst✝² : DecidableEq α
inst✝¹ : Fintype α
σ✝ τ : Perm α
inst✝ : Fintype α
σ : Perm α
h : σ ≠ 1
⊢ card (filter (fun x => σ x = x) univ) < Fintype.card α - 1

Next tactic:
rw [lt_tsub_iff_left, ← lt_tsub_iff_right, ← Finset.card_compl, Finset.compl_filter]
theorem fixed_point_card_lt_of_ne_one [Fintype α] {σ : Perm α} (h : σ ≠ 1) :
    (filter (fun x => σ x = x) univ).card < Fintype.card α - 1 := by
  rw [lt_tsub_iff_left, ← lt_tsub_iff_right, ← Finset.card_compl, Finset.compl_filter]
  

Proof state:
ι : Type u_1
α : Type u_2
β : Type u_3
inst✝² : DecidableEq α
inst✝¹ : Fintype α
σ✝ τ : Perm α
inst✝ : Fintype α
σ : Perm α
h : σ ≠ 1
⊢ 1 < card (filter (fun x => ¬σ x = x) univ)

Next tactic:
exact one_lt_card_support_of_ne_one h
set_option linter.deprecated false in -- nthLe
theorem _root_.List.Nodup.isCycleOn_formPerm (h : l.Nodup) :
    l.formPerm.IsCycleOn { a | a ∈ l } := by
  

Proof state:
ι : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ inst✝ : DecidableEq α
l : List α
h : List.Nodup l
⊢ IsCycleOn (List.formPerm l) {a | a ∈ l}

Next tactic:
refine' ⟨l.formPerm.bijOn fun _ => List.formPerm_mem_iff_mem, fun a ha b hb => _⟩
set_option linter.deprecated false in -- nthLe
theorem _root_.List.Nodup.isCycleOn_formPerm (h : l.Nodup) :
    l.formPerm.IsCycleOn { a | a ∈ l } := by
  refine' ⟨l.formPerm.bijOn fun _ => List.formPerm_mem_iff_mem, fun a ha b hb => _⟩
  

Proof state:
ι : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ inst✝ : DecidableEq α
l : List α
h : List.Nodup l
a : α
ha : a ∈ {a | a ∈ l}
b : α
hb : b ∈ {a | a ∈ l}
⊢ SameCycle (List.formPerm l) a b

Next tactic:
rw [Set.mem_setOf, ← List.indexOf_lt_length] at ha hb
set_option linter.deprecated false in -- nthLe
theorem _root_.List.Nodup.isCycleOn_formPerm (h : l.Nodup) :
    l.formPerm.IsCycleOn { a | a ∈ l } := by
  refine' ⟨l.formPerm.bijOn fun _ => List.formPerm_mem_iff_mem, fun a ha b hb => _⟩
  rw [Set.mem_setOf, ← List.indexOf_lt_length] at ha hb
  

Proof state:
ι : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ inst✝ : DecidableEq α
l : List α
h : List.Nodup l
a : α
ha : List.indexOf a l < List.length l
b : α
hb : List.indexOf b l < List.length l
⊢ SameCycle (List.formPerm l) a b

Next tactic:
rw [← List.indexOf_get ha, ← List.indexOf_get hb]
set_option linter.deprecated false in -- nthLe
theorem _root_.List.Nodup.isCycleOn_formPerm (h : l.Nodup) :
    l.formPerm.IsCycleOn { a | a ∈ l } := by
  refine' ⟨l.formPerm.bijOn fun _ => List.formPerm_mem_iff_mem, fun a ha b hb => _⟩
  rw [Set.mem_setOf, ← List.indexOf_lt_length] at ha hb
  rw [← List.indexOf_get ha, ← List.indexOf_get hb]
  

Proof state:
ι : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ inst✝ : DecidableEq α
l : List α
h : List.Nodup l
a : α
ha : List.indexOf a l < List.length l
b : α
hb : List.indexOf b l < List.length l
⊢ SameCycle (List.formPerm l) (List.get l { val := List.indexOf a l, isLt := ha })
    (List.get l { val := List.indexOf b l, isLt := hb })

Next tactic:
refine' ⟨l.indexOf b - l.indexOf a, _⟩
set_option linter.deprecated false in -- nthLe
theorem _root_.List.Nodup.isCycleOn_formPerm (h : l.Nodup) :
    l.formPerm.IsCycleOn { a | a ∈ l } := by
  refine' ⟨l.formPerm.bijOn fun _ => List.formPerm_mem_iff_mem, fun a ha b hb => _⟩
  rw [Set.mem_setOf, ← List.indexOf_lt_length] at ha hb
  rw [← List.indexOf_get ha, ← List.indexOf_get hb]
  refine' ⟨l.indexOf b - l.indexOf a, _⟩
  

Proof state:
ι : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ inst✝ : DecidableEq α
l : List α
h : List.Nodup l
a : α
ha : List.indexOf a l < List.length l
b : α
hb : List.indexOf b l < List.length l
⊢ (List.formPerm l ^ (↑(List.indexOf b l) - ↑(List.indexOf a l))) (List.get l { val := List.indexOf a l, isLt := ha }) =
    List.get l { val := List.indexOf b l, isLt := hb }

Next tactic:
simp only [sub_eq_neg_add, zpow_add, zpow_neg, Equiv.Perm.inv_eq_iff_eq, zpow_ofNat,
    Equiv.Perm.coe_mul, ← List.nthLe_eq, List.formPerm_pow_apply_nthLe _ h, Function.comp]
set_option linter.deprecated false in -- nthLe
theorem _root_.List.Nodup.isCycleOn_formPerm (h : l.Nodup) :
    l.formPerm.IsCycleOn { a | a ∈ l } := by
  refine' ⟨l.formPerm.bijOn fun _ => List.formPerm_mem_iff_mem, fun a ha b hb => _⟩
  rw [Set.mem_setOf, ← List.indexOf_lt_length] at ha hb
  rw [← List.indexOf_get ha, ← List.indexOf_get hb]
  refine' ⟨l.indexOf b - l.indexOf a, _⟩
  simp only [sub_eq_neg_add, zpow_add, zpow_neg, Equiv.Perm.inv_eq_iff_eq, zpow_ofNat,
    Equiv.Perm.coe_mul, ← List.nthLe_eq, List.formPerm_pow_apply_nthLe _ h, Function.comp]
  

Proof state:
ι : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ inst✝ : DecidableEq α
l : List α
h : List.Nodup l
a : α
ha : List.indexOf a l < List.length l
b : α
hb : List.indexOf b l < List.length l
⊢ List.nthLe l ((List.indexOf a l + List.indexOf b l) % List.length l)
      (_ : (List.indexOf a l + List.indexOf b l) % List.length l < List.length l) =
    List.nthLe l ((List.indexOf b l + List.indexOf a l) % List.length l)
      (_ : (List.indexOf b l + List.indexOf a l) % List.length l < List.length l)

Next tactic:
rw [add_comm]
theorem _root_.Int.addLeft_one_isCycle : (Equiv.addLeft 1 : Perm ℤ).IsCycle :=
  ⟨0, one_ne_zero, fun n _ => ⟨n, by 

Proof state:
ι : Type u_1
α : Type u_2
β : Type u_3
inst✝ : DecidableEq α
n : ℤ
x✝ : (Equiv.addLeft 1) n ≠ n
⊢ (Equiv.addLeft 1 ^ n) 0 = n

Next tactic:
simp
theorem _root_.Int.addRight_one_isCycle : (Equiv.addRight 1 : Perm ℤ).IsCycle :=
  ⟨0, one_ne_zero, fun n _ => ⟨n, by 

Proof state:
ι : Type u_1
α : Type u_2
β : Type u_3
inst✝ : DecidableEq α
n : ℤ
x✝ : (Equiv.addRight 1) n ≠ n
⊢ (Equiv.addRight 1 ^ n) 0 = n

Next tactic:
simp
theorem _root_.Finset.exists_cycleOn (s : Finset α) :
    ∃ f : Perm α, f.IsCycleOn s ∧ f.support ⊆ s := by
  

Proof state:
ι : Type u_1
α : Type u_2
β : Type u_3
inst✝² inst✝¹ : DecidableEq α
inst✝ : Fintype α
s : Finset α
⊢ ∃ f, IsCycleOn f ↑s ∧ support f ⊆ s

Next tactic:
refine'
    ⟨s.toList.formPerm, _, fun x hx => by
      simpa using List.mem_of_formPerm_apply_ne _ _ (Perm.mem_support.1 hx)⟩
theorem _root_.Finset.exists_cycleOn (s : Finset α) :
    ∃ f : Perm α, f.IsCycleOn s ∧ f.support ⊆ s := by
  refine'
    ⟨s.toList.formPerm, _, fun x hx => by
      

Proof state:
ι : Type u_1
α : Type u_2
β : Type u_3
inst✝² inst✝¹ : DecidableEq α
inst✝ : Fintype α
s : Finset α
x : α
hx : x ∈ support (List.formPerm (toList s))
⊢ x ∈ s

Next tactic:
simpa using List.mem_of_formPerm_apply_ne _ _ (Perm.mem_support.1 hx)
theorem _root_.Finset.exists_cycleOn (s : Finset α) :
    ∃ f : Perm α, f.IsCycleOn s ∧ f.support ⊆ s := by
  refine'
    ⟨s.toList.formPerm, _, fun x hx => by
      simpa using List.mem_of_formPerm_apply_ne _ _ (Perm.mem_support.1 hx)⟩
  

Proof state:
ι : Type u_1
α : Type u_2
β : Type u_3
inst✝² inst✝¹ : DecidableEq α
inst✝ : Fintype α
s : Finset α
⊢ IsCycleOn (List.formPerm (toList s)) ↑s

Next tactic:
convert s.nodup_toList.isCycleOn_formPerm
theorem _root_.Finset.exists_cycleOn (s : Finset α) :
    ∃ f : Perm α, f.IsCycleOn s ∧ f.support ⊆ s := by
  refine'
    ⟨s.toList.formPerm, _, fun x hx => by
      simpa using List.mem_of_formPerm_apply_ne _ _ (Perm.mem_support.1 hx)⟩
  convert s.nodup_toList.isCycleOn_formPerm
  

Proof state:
case h.e'_3
ι : Type u_1
α : Type u_2
β : Type u_3
inst✝² inst✝¹ : DecidableEq α
inst✝ : Fintype α
s : Finset α
⊢ ↑s = {a | a ∈ toList s}

Next tactic:
simp
theorem _root_.Set.Countable.exists_cycleOn (hs : s.Countable) :
    ∃ f : Perm α, f.IsCycleOn s ∧ { x | f x ≠ x } ⊆ s := by
  

Proof state:
ι : Type u_1
α : Type u_2
β : Type u_3
inst✝ : DecidableEq α
f : Perm α
s : Set α
hs : Set.Countable s
⊢ ∃ f, IsCycleOn f s ∧ {x | f x ≠ x} ⊆ s

Next tactic:
classical
    obtain hs' | hs' := s.finite_or_infinite
    · refine'
        ⟨hs'.toFinset.toList.formPerm, _, fun x hx => by
          simpa using List.mem_of_formPerm_apply_ne _ _ hx⟩
      convert hs'.toFinset.nodup_toList.isCycleOn_formPerm
      simp
    haveI := hs.to_subtype
    haveI := hs'.to_subtype
    obtain ⟨f⟩ : Nonempty (ℤ ≃ s) := inferInstance
    refine'
      ⟨(Equiv.addRight 1).extendDomain f, _, fun x hx =>
        of_not_not fun h => hx <| Perm.extendDomain_apply_not_subtype _ _ h⟩
    convert Int.addRight_one_isCycle.isCycleOn.extendDomain f
    rw [Set.image_comp, Equiv.image_eq_preimage]
    ext
    simp
theorem _root_.Set.Countable.exists_cycleOn (hs : s.Countable) :
    ∃ f : Perm α, f.IsCycleOn s ∧ { x | f x ≠ x } ⊆ s := by
  classical
    

Proof state:
ι : Type u_1
α : Type u_2
β : Type u_3
inst✝ : DecidableEq α
f : Perm α
s : Set α
hs : Set.Countable s
⊢ ∃ f, IsCycleOn f s ∧ {x | f x ≠ x} ⊆ s

Next tactic:
obtain hs' | hs' := s.finite_or_infinite
theorem _root_.Set.Countable.exists_cycleOn (hs : s.Countable) :
    ∃ f : Perm α, f.IsCycleOn s ∧ { x | f x ≠ x } ⊆ s := by
  classical
    obtain hs' | hs' := s.finite_or_infinite
    · 

Proof state:
case inl
ι : Type u_1
α : Type u_2
β : Type u_3
inst✝ : DecidableEq α
f : Perm α
s : Set α
hs : Set.Countable s
hs' : Set.Finite s
⊢ ∃ f, IsCycleOn f s ∧ {x | f x ≠ x} ⊆ s

Next tactic:
refine'
        ⟨hs'.toFinset.toList.formPerm, _, fun x hx => by
          simpa using List.mem_of_formPerm_apply_ne _ _ hx⟩
theorem _root_.Set.Countable.exists_cycleOn (hs : s.Countable) :
    ∃ f : Perm α, f.IsCycleOn s ∧ { x | f x ≠ x } ⊆ s := by
  classical
    obtain hs' | hs' := s.finite_or_infinite
    · refine'
        ⟨hs'.toFinset.toList.formPerm, _, fun x hx => by
          

Proof state:
ι : Type u_1
α : Type u_2
β : Type u_3
inst✝ : DecidableEq α
f : Perm α
s : Set α
hs : Set.Countable s
hs' : Set.Finite s
x : α
hx : x ∈ {x | (List.formPerm (toList (Set.Finite.toFinset hs'))) x ≠ x}
⊢ x ∈ s

Next tactic:
simpa using List.mem_of_formPerm_apply_ne _ _ hx
theorem _root_.Set.Countable.exists_cycleOn (hs : s.Countable) :
    ∃ f : Perm α, f.IsCycleOn s ∧ { x | f x ≠ x } ⊆ s := by
  classical
    obtain hs' | hs' := s.finite_or_infinite
    · refine'
        ⟨hs'.toFinset.toList.formPerm, _, fun x hx => by
          simpa using List.mem_of_formPerm_apply_ne _ _ hx⟩
      

Proof state:
case inl
ι : Type u_1
α : Type u_2
β : Type u_3
inst✝ : DecidableEq α
f : Perm α
s : Set α
hs : Set.Countable s
hs' : Set.Finite s
⊢ IsCycleOn (List.formPerm (toList (Set.Finite.toFinset hs'))) s

Next tactic:
convert hs'.toFinset.nodup_toList.isCycleOn_formPerm
theorem _root_.Set.Countable.exists_cycleOn (hs : s.Countable) :
    ∃ f : Perm α, f.IsCycleOn s ∧ { x | f x ≠ x } ⊆ s := by
  classical
    obtain hs' | hs' := s.finite_or_infinite
    · refine'
        ⟨hs'.toFinset.toList.formPerm, _, fun x hx => by
          simpa using List.mem_of_formPerm_apply_ne _ _ hx⟩
      convert hs'.toFinset.nodup_toList.isCycleOn_formPerm
      

Proof state:
case h.e'_3
ι : Type u_1
α : Type u_2
β : Type u_3
inst✝ : DecidableEq α
f : Perm α
s : Set α
hs : Set.Countable s
hs' : Set.Finite s
⊢ s = {a | a ∈ toList (Set.Finite.toFinset hs')}

Next tactic:
simp
theorem _root_.Set.Countable.exists_cycleOn (hs : s.Countable) :
    ∃ f : Perm α, f.IsCycleOn s ∧ { x | f x ≠ x } ⊆ s := by
  classical
    obtain hs' | hs' := s.finite_or_infinite
    · refine'
        ⟨hs'.toFinset.toList.formPerm, _, fun x hx => by
          simpa using List.mem_of_formPerm_apply_ne _ _ hx⟩
      convert hs'.toFinset.nodup_toList.isCycleOn_formPerm
      simp
    

Proof state:
case inr
ι : Type u_1
α : Type u_2
β : Type u_3
inst✝ : DecidableEq α
f : Perm α
s : Set α
hs : Set.Countable s
hs' : Set.Infinite s
⊢ ∃ f, IsCycleOn f s ∧ {x | f x ≠ x} ⊆ s

Next tactic:
haveI := hs.to_subtype