l3lab/ntp-mathlib huggingface dataset:
set_option linter.deprecated false in
theorem nodup_toList (p : Perm α) (x : α) : Nodup (toList p x) := by
  by_cases hx : p x = x
  · rw [← not_mem_support, ← toList_eq_nil_iff] at hx
    simp [hx]
  have hc : IsCycle (cycleOf p x) := isCycle_cycleOf p hx
  rw [nodup_iff_nthLe_inj]
  rintro n m hn hm
  rw [length_toList, ← hc.orderOf] at hm hn
  rw [← cycleOf_apply_self, ← Ne.def, ← mem_support] at hx
  rw [nthLe_toList, nthLe_toList, ← cycleOf_pow_apply_self p x n, ←
    cycleOf_pow_apply_self p x m]
  cases' n with n <;> cases' m with m
  · simp
  · rw [← hc.support_pow_of_pos_of_lt_orderOf m.zero_lt_succ hm, mem_support,
      cycleOf_pow_apply_self] at hx
    simp [hx.symm]
  · rw [← hc.support_pow_of_pos_of_lt_orderOf n.zero_lt_succ hn, mem_support,
      cycleOf_pow_apply_self] at hx
    

Proof state:
case neg.succ.zero
α : Type u_1
inst✝¹ : Fintype α
inst✝ : DecidableEq α
p✝ : Perm α
x✝ : α
p : Perm α
x : α
hc : IsCycle (cycleOf p x)
n : ℕ
hx : (p ^ Nat.succ n) x ≠ x
hn✝ : Nat.succ n < length (toList p x)
hn : Nat.succ n < orderOf (cycleOf p x)
hm✝ : Nat.zero < length (toList p x)
hm : Nat.zero < orderOf (cycleOf p x)
⊢ (cycleOf p x ^ Nat.succ n) x = (cycleOf p x ^ Nat.zero) x → Nat.succ n = Nat.zero

Next tactic:
simp [hx]
set_option linter.deprecated false in
theorem nodup_toList (p : Perm α) (x : α) : Nodup (toList p x) := by
  by_cases hx : p x = x
  · rw [← not_mem_support, ← toList_eq_nil_iff] at hx
    simp [hx]
  have hc : IsCycle (cycleOf p x) := isCycle_cycleOf p hx
  rw [nodup_iff_nthLe_inj]
  rintro n m hn hm
  rw [length_toList, ← hc.orderOf] at hm hn
  rw [← cycleOf_apply_self, ← Ne.def, ← mem_support] at hx
  rw [nthLe_toList, nthLe_toList, ← cycleOf_pow_apply_self p x n, ←
    cycleOf_pow_apply_self p x m]
  cases' n with n <;> cases' m with m
  · simp
  · rw [← hc.support_pow_of_pos_of_lt_orderOf m.zero_lt_succ hm, mem_support,
      cycleOf_pow_apply_self] at hx
    simp [hx.symm]
  · rw [← hc.support_pow_of_pos_of_lt_orderOf n.zero_lt_succ hn, mem_support,
      cycleOf_pow_apply_self] at hx
    simp [hx]
  

Proof state:
case neg.succ.succ
α : Type u_1
inst✝¹ : Fintype α
inst✝ : DecidableEq α
p✝ : Perm α
x✝ : α
p : Perm α
x : α
hx : x ∈ support (cycleOf p x)
hc : IsCycle (cycleOf p x)
n : ℕ
hn✝ : Nat.succ n < length (toList p x)
hn : Nat.succ n < orderOf (cycleOf p x)
m : ℕ
hm✝ : Nat.succ m < length (toList p x)
hm : Nat.succ m < orderOf (cycleOf p x)
⊢ (cycleOf p x ^ Nat.succ n) x = (cycleOf p x ^ Nat.succ m) x → Nat.succ n = Nat.succ m

Next tactic:
intro h
set_option linter.deprecated false in
theorem nodup_toList (p : Perm α) (x : α) : Nodup (toList p x) := by
  by_cases hx : p x = x
  · rw [← not_mem_support, ← toList_eq_nil_iff] at hx
    simp [hx]
  have hc : IsCycle (cycleOf p x) := isCycle_cycleOf p hx
  rw [nodup_iff_nthLe_inj]
  rintro n m hn hm
  rw [length_toList, ← hc.orderOf] at hm hn
  rw [← cycleOf_apply_self, ← Ne.def, ← mem_support] at hx
  rw [nthLe_toList, nthLe_toList, ← cycleOf_pow_apply_self p x n, ←
    cycleOf_pow_apply_self p x m]
  cases' n with n <;> cases' m with m
  · simp
  · rw [← hc.support_pow_of_pos_of_lt_orderOf m.zero_lt_succ hm, mem_support,
      cycleOf_pow_apply_self] at hx
    simp [hx.symm]
  · rw [← hc.support_pow_of_pos_of_lt_orderOf n.zero_lt_succ hn, mem_support,
      cycleOf_pow_apply_self] at hx
    simp [hx]
  intro h
  

Proof state:
case neg.succ.succ
α : Type u_1
inst✝¹ : Fintype α
inst✝ : DecidableEq α
p✝ : Perm α
x✝ : α
p : Perm α
x : α
hx : x ∈ support (cycleOf p x)
hc : IsCycle (cycleOf p x)
n : ℕ
hn✝ : Nat.succ n < length (toList p x)
hn : Nat.succ n < orderOf (cycleOf p x)
m : ℕ
hm✝ : Nat.succ m < length (toList p x)
hm : Nat.succ m < orderOf (cycleOf p x)
h : (cycleOf p x ^ Nat.succ n) x = (cycleOf p x ^ Nat.succ m) x
⊢ Nat.succ n = Nat.succ m

Next tactic:
have hn' : ¬orderOf (p.cycleOf x) ∣ n.succ := Nat.not_dvd_of_pos_of_lt n.zero_lt_succ hn
set_option linter.deprecated false in
theorem nodup_toList (p : Perm α) (x : α) : Nodup (toList p x) := by
  by_cases hx : p x = x
  · rw [← not_mem_support, ← toList_eq_nil_iff] at hx
    simp [hx]
  have hc : IsCycle (cycleOf p x) := isCycle_cycleOf p hx
  rw [nodup_iff_nthLe_inj]
  rintro n m hn hm
  rw [length_toList, ← hc.orderOf] at hm hn
  rw [← cycleOf_apply_self, ← Ne.def, ← mem_support] at hx
  rw [nthLe_toList, nthLe_toList, ← cycleOf_pow_apply_self p x n, ←
    cycleOf_pow_apply_self p x m]
  cases' n with n <;> cases' m with m
  · simp
  · rw [← hc.support_pow_of_pos_of_lt_orderOf m.zero_lt_succ hm, mem_support,
      cycleOf_pow_apply_self] at hx
    simp [hx.symm]
  · rw [← hc.support_pow_of_pos_of_lt_orderOf n.zero_lt_succ hn, mem_support,
      cycleOf_pow_apply_self] at hx
    simp [hx]
  intro h
  have hn' : ¬orderOf (p.cycleOf x) ∣ n.succ := Nat.not_dvd_of_pos_of_lt n.zero_lt_succ hn
  

Proof state:
case neg.succ.succ
α : Type u_1
inst✝¹ : Fintype α
inst✝ : DecidableEq α
p✝ : Perm α
x✝ : α
p : Perm α
x : α
hx : x ∈ support (cycleOf p x)
hc : IsCycle (cycleOf p x)
n : ℕ
hn✝ : Nat.succ n < length (toList p x)
hn : Nat.succ n < orderOf (cycleOf p x)
m : ℕ
hm✝ : Nat.succ m < length (toList p x)
hm : Nat.succ m < orderOf (cycleOf p x)
h : (cycleOf p x ^ Nat.succ n) x = (cycleOf p x ^ Nat.succ m) x
hn' : ¬orderOf (cycleOf p x) ∣ Nat.succ n
⊢ Nat.succ n = Nat.succ m

Next tactic:
have hm' : ¬orderOf (p.cycleOf x) ∣ m.succ := Nat.not_dvd_of_pos_of_lt m.zero_lt_succ hm
set_option linter.deprecated false in
theorem nodup_toList (p : Perm α) (x : α) : Nodup (toList p x) := by
  by_cases hx : p x = x
  · rw [← not_mem_support, ← toList_eq_nil_iff] at hx
    simp [hx]
  have hc : IsCycle (cycleOf p x) := isCycle_cycleOf p hx
  rw [nodup_iff_nthLe_inj]
  rintro n m hn hm
  rw [length_toList, ← hc.orderOf] at hm hn
  rw [← cycleOf_apply_self, ← Ne.def, ← mem_support] at hx
  rw [nthLe_toList, nthLe_toList, ← cycleOf_pow_apply_self p x n, ←
    cycleOf_pow_apply_self p x m]
  cases' n with n <;> cases' m with m
  · simp
  · rw [← hc.support_pow_of_pos_of_lt_orderOf m.zero_lt_succ hm, mem_support,
      cycleOf_pow_apply_self] at hx
    simp [hx.symm]
  · rw [← hc.support_pow_of_pos_of_lt_orderOf n.zero_lt_succ hn, mem_support,
      cycleOf_pow_apply_self] at hx
    simp [hx]
  intro h
  have hn' : ¬orderOf (p.cycleOf x) ∣ n.succ := Nat.not_dvd_of_pos_of_lt n.zero_lt_succ hn
  have hm' : ¬orderOf (p.cycleOf x) ∣ m.succ := Nat.not_dvd_of_pos_of_lt m.zero_lt_succ hm
  

Proof state:
case neg.succ.succ
α : Type u_1
inst✝¹ : Fintype α
inst✝ : DecidableEq α
p✝ : Perm α
x✝ : α
p : Perm α
x : α
hx : x ∈ support (cycleOf p x)
hc : IsCycle (cycleOf p x)
n : ℕ
hn✝ : Nat.succ n < length (toList p x)
hn : Nat.succ n < orderOf (cycleOf p x)
m : ℕ
hm✝ : Nat.succ m < length (toList p x)
hm : Nat.succ m < orderOf (cycleOf p x)
h : (cycleOf p x ^ Nat.succ n) x = (cycleOf p x ^ Nat.succ m) x
hn' : ¬orderOf (cycleOf p x) ∣ Nat.succ n
hm' : ¬orderOf (cycleOf p x) ∣ Nat.succ m
⊢ Nat.succ n = Nat.succ m

Next tactic:
rw [← hc.support_pow_eq_iff] at hn' hm'
set_option linter.deprecated false in
theorem nodup_toList (p : Perm α) (x : α) : Nodup (toList p x) := by
  by_cases hx : p x = x
  · rw [← not_mem_support, ← toList_eq_nil_iff] at hx
    simp [hx]
  have hc : IsCycle (cycleOf p x) := isCycle_cycleOf p hx
  rw [nodup_iff_nthLe_inj]
  rintro n m hn hm
  rw [length_toList, ← hc.orderOf] at hm hn
  rw [← cycleOf_apply_self, ← Ne.def, ← mem_support] at hx
  rw [nthLe_toList, nthLe_toList, ← cycleOf_pow_apply_self p x n, ←
    cycleOf_pow_apply_self p x m]
  cases' n with n <;> cases' m with m
  · simp
  · rw [← hc.support_pow_of_pos_of_lt_orderOf m.zero_lt_succ hm, mem_support,
      cycleOf_pow_apply_self] at hx
    simp [hx.symm]
  · rw [← hc.support_pow_of_pos_of_lt_orderOf n.zero_lt_succ hn, mem_support,
      cycleOf_pow_apply_self] at hx
    simp [hx]
  intro h
  have hn' : ¬orderOf (p.cycleOf x) ∣ n.succ := Nat.not_dvd_of_pos_of_lt n.zero_lt_succ hn
  have hm' : ¬orderOf (p.cycleOf x) ∣ m.succ := Nat.not_dvd_of_pos_of_lt m.zero_lt_succ hm
  rw [← hc.support_pow_eq_iff] at hn' hm'
  

Proof state:
case neg.succ.succ
α : Type u_1
inst✝¹ : Fintype α
inst✝ : DecidableEq α
p✝ : Perm α
x✝ : α
p : Perm α
x : α
hx : x ∈ support (cycleOf p x)
hc : IsCycle (cycleOf p x)
n : ℕ
hn✝ : Nat.succ n < length (toList p x)
hn : Nat.succ n < orderOf (cycleOf p x)
m : ℕ
hm✝ : Nat.succ m < length (toList p x)
hm : Nat.succ m < orderOf (cycleOf p x)
h : (cycleOf p x ^ Nat.succ n) x = (cycleOf p x ^ Nat.succ m) x
hn' : support (cycleOf p x ^ Nat.succ n) = support (cycleOf p x)
hm' : support (cycleOf p x ^ Nat.succ m) = support (cycleOf p x)
⊢ Nat.succ n = Nat.succ m

Next tactic:
rw [← Nat.mod_eq_of_lt hn, ← Nat.mod_eq_of_lt hm, ← pow_inj_mod]
set_option linter.deprecated false in
theorem nodup_toList (p : Perm α) (x : α) : Nodup (toList p x) := by
  by_cases hx : p x = x
  · rw [← not_mem_support, ← toList_eq_nil_iff] at hx
    simp [hx]
  have hc : IsCycle (cycleOf p x) := isCycle_cycleOf p hx
  rw [nodup_iff_nthLe_inj]
  rintro n m hn hm
  rw [length_toList, ← hc.orderOf] at hm hn
  rw [← cycleOf_apply_self, ← Ne.def, ← mem_support] at hx
  rw [nthLe_toList, nthLe_toList, ← cycleOf_pow_apply_self p x n, ←
    cycleOf_pow_apply_self p x m]
  cases' n with n <;> cases' m with m
  · simp
  · rw [← hc.support_pow_of_pos_of_lt_orderOf m.zero_lt_succ hm, mem_support,
      cycleOf_pow_apply_self] at hx
    simp [hx.symm]
  · rw [← hc.support_pow_of_pos_of_lt_orderOf n.zero_lt_succ hn, mem_support,
      cycleOf_pow_apply_self] at hx
    simp [hx]
  intro h
  have hn' : ¬orderOf (p.cycleOf x) ∣ n.succ := Nat.not_dvd_of_pos_of_lt n.zero_lt_succ hn
  have hm' : ¬orderOf (p.cycleOf x) ∣ m.succ := Nat.not_dvd_of_pos_of_lt m.zero_lt_succ hm
  rw [← hc.support_pow_eq_iff] at hn' hm'
  rw [← Nat.mod_eq_of_lt hn, ← Nat.mod_eq_of_lt hm, ← pow_inj_mod]
  

Proof state:
case neg.succ.succ
α : Type u_1
inst✝¹ : Fintype α
inst✝ : DecidableEq α
p✝ : Perm α
x✝ : α
p : Perm α
x : α
hx : x ∈ support (cycleOf p x)
hc : IsCycle (cycleOf p x)
n : ℕ
hn✝ : Nat.succ n < length (toList p x)
hn : Nat.succ n < orderOf (cycleOf p x)
m : ℕ
hm✝ : Nat.succ m < length (toList p x)
hm : Nat.succ m < orderOf (cycleOf p x)
h : (cycleOf p x ^ Nat.succ n) x = (cycleOf p x ^ Nat.succ m) x
hn' : support (cycleOf p x ^ Nat.succ n) = support (cycleOf p x)
hm' : support (cycleOf p x ^ Nat.succ m) = support (cycleOf p x)
⊢ cycleOf p x ^ Nat.succ n = cycleOf p x ^ Nat.succ m

Next tactic:
refine' support_congr _ _
set_option linter.deprecated false in
theorem nodup_toList (p : Perm α) (x : α) : Nodup (toList p x) := by
  by_cases hx : p x = x
  · rw [← not_mem_support, ← toList_eq_nil_iff] at hx
    simp [hx]
  have hc : IsCycle (cycleOf p x) := isCycle_cycleOf p hx
  rw [nodup_iff_nthLe_inj]
  rintro n m hn hm
  rw [length_toList, ← hc.orderOf] at hm hn
  rw [← cycleOf_apply_self, ← Ne.def, ← mem_support] at hx
  rw [nthLe_toList, nthLe_toList, ← cycleOf_pow_apply_self p x n, ←
    cycleOf_pow_apply_self p x m]
  cases' n with n <;> cases' m with m
  · simp
  · rw [← hc.support_pow_of_pos_of_lt_orderOf m.zero_lt_succ hm, mem_support,
      cycleOf_pow_apply_self] at hx
    simp [hx.symm]
  · rw [← hc.support_pow_of_pos_of_lt_orderOf n.zero_lt_succ hn, mem_support,
      cycleOf_pow_apply_self] at hx
    simp [hx]
  intro h
  have hn' : ¬orderOf (p.cycleOf x) ∣ n.succ := Nat.not_dvd_of_pos_of_lt n.zero_lt_succ hn
  have hm' : ¬orderOf (p.cycleOf x) ∣ m.succ := Nat.not_dvd_of_pos_of_lt m.zero_lt_succ hm
  rw [← hc.support_pow_eq_iff] at hn' hm'
  rw [← Nat.mod_eq_of_lt hn, ← Nat.mod_eq_of_lt hm, ← pow_inj_mod]
  refine' support_congr _ _
  · 

Proof state:
case neg.succ.succ.refine'_1
α : Type u_1
inst✝¹ : Fintype α
inst✝ : DecidableEq α
p✝ : Perm α
x✝ : α
p : Perm α
x : α
hx : x ∈ support (cycleOf p x)
hc : IsCycle (cycleOf p x)
n : ℕ
hn✝ : Nat.succ n < length (toList p x)
hn : Nat.succ n < orderOf (cycleOf p x)
m : ℕ
hm✝ : Nat.succ m < length (toList p x)
hm : Nat.succ m < orderOf (cycleOf p x)
h : (cycleOf p x ^ Nat.succ n) x = (cycleOf p x ^ Nat.succ m) x
hn' : support (cycleOf p x ^ Nat.succ n) = support (cycleOf p x)
hm' : support (cycleOf p x ^ Nat.succ m) = support (cycleOf p x)
⊢ support (cycleOf p x ^ Nat.succ n) ⊆ support (cycleOf p x ^ Nat.succ m)

Next tactic:
rw [hm', hn']
set_option linter.deprecated false in
theorem nodup_toList (p : Perm α) (x : α) : Nodup (toList p x) := by
  by_cases hx : p x = x
  · rw [← not_mem_support, ← toList_eq_nil_iff] at hx
    simp [hx]
  have hc : IsCycle (cycleOf p x) := isCycle_cycleOf p hx
  rw [nodup_iff_nthLe_inj]
  rintro n m hn hm
  rw [length_toList, ← hc.orderOf] at hm hn
  rw [← cycleOf_apply_self, ← Ne.def, ← mem_support] at hx
  rw [nthLe_toList, nthLe_toList, ← cycleOf_pow_apply_self p x n, ←
    cycleOf_pow_apply_self p x m]
  cases' n with n <;> cases' m with m
  · simp
  · rw [← hc.support_pow_of_pos_of_lt_orderOf m.zero_lt_succ hm, mem_support,
      cycleOf_pow_apply_self] at hx
    simp [hx.symm]
  · rw [← hc.support_pow_of_pos_of_lt_orderOf n.zero_lt_succ hn, mem_support,
      cycleOf_pow_apply_self] at hx
    simp [hx]
  intro h
  have hn' : ¬orderOf (p.cycleOf x) ∣ n.succ := Nat.not_dvd_of_pos_of_lt n.zero_lt_succ hn
  have hm' : ¬orderOf (p.cycleOf x) ∣ m.succ := Nat.not_dvd_of_pos_of_lt m.zero_lt_succ hm
  rw [← hc.support_pow_eq_iff] at hn' hm'
  rw [← Nat.mod_eq_of_lt hn, ← Nat.mod_eq_of_lt hm, ← pow_inj_mod]
  refine' support_congr _ _
  · rw [hm', hn']
  · 

Proof state:
case neg.succ.succ.refine'_2
α : Type u_1
inst✝¹ : Fintype α
inst✝ : DecidableEq α
p✝ : Perm α
x✝ : α
p : Perm α
x : α
hx : x ∈ support (cycleOf p x)
hc : IsCycle (cycleOf p x)
n : ℕ
hn✝ : Nat.succ n < length (toList p x)
hn : Nat.succ n < orderOf (cycleOf p x)
m : ℕ
hm✝ : Nat.succ m < length (toList p x)
hm : Nat.succ m < orderOf (cycleOf p x)
h : (cycleOf p x ^ Nat.succ n) x = (cycleOf p x ^ Nat.succ m) x
hn' : support (cycleOf p x ^ Nat.succ n) = support (cycleOf p x)
hm' : support (cycleOf p x ^ Nat.succ m) = support (cycleOf p x)
⊢ ∀ x_1 ∈ support (cycleOf p x ^ Nat.succ m), (cycleOf p x ^ Nat.succ n) x_1 = (cycleOf p x ^ Nat.succ m) x_1

Next tactic:
rw [hm']
set_option linter.deprecated false in
theorem nodup_toList (p : Perm α) (x : α) : Nodup (toList p x) := by
  by_cases hx : p x = x
  · rw [← not_mem_support, ← toList_eq_nil_iff] at hx
    simp [hx]
  have hc : IsCycle (cycleOf p x) := isCycle_cycleOf p hx
  rw [nodup_iff_nthLe_inj]
  rintro n m hn hm
  rw [length_toList, ← hc.orderOf] at hm hn
  rw [← cycleOf_apply_self, ← Ne.def, ← mem_support] at hx
  rw [nthLe_toList, nthLe_toList, ← cycleOf_pow_apply_self p x n, ←
    cycleOf_pow_apply_self p x m]
  cases' n with n <;> cases' m with m
  · simp
  · rw [← hc.support_pow_of_pos_of_lt_orderOf m.zero_lt_succ hm, mem_support,
      cycleOf_pow_apply_self] at hx
    simp [hx.symm]
  · rw [← hc.support_pow_of_pos_of_lt_orderOf n.zero_lt_succ hn, mem_support,
      cycleOf_pow_apply_self] at hx
    simp [hx]
  intro h
  have hn' : ¬orderOf (p.cycleOf x) ∣ n.succ := Nat.not_dvd_of_pos_of_lt n.zero_lt_succ hn
  have hm' : ¬orderOf (p.cycleOf x) ∣ m.succ := Nat.not_dvd_of_pos_of_lt m.zero_lt_succ hm
  rw [← hc.support_pow_eq_iff] at hn' hm'
  rw [← Nat.mod_eq_of_lt hn, ← Nat.mod_eq_of_lt hm, ← pow_inj_mod]
  refine' support_congr _ _
  · rw [hm', hn']
  · rw [hm']
    

Proof state:
case neg.succ.succ.refine'_2
α : Type u_1
inst✝¹ : Fintype α
inst✝ : DecidableEq α
p✝ : Perm α
x✝ : α
p : Perm α
x : α
hx : x ∈ support (cycleOf p x)
hc : IsCycle (cycleOf p x)
n : ℕ
hn✝ : Nat.succ n < length (toList p x)
hn : Nat.succ n < orderOf (cycleOf p x)
m : ℕ
hm✝ : Nat.succ m < length (toList p x)
hm : Nat.succ m < orderOf (cycleOf p x)
h : (cycleOf p x ^ Nat.succ n) x = (cycleOf p x ^ Nat.succ m) x
hn' : support (cycleOf p x ^ Nat.succ n) = support (cycleOf p x)
hm' : support (cycleOf p x ^ Nat.succ m) = support (cycleOf p x)
⊢ ∀ x_1 ∈ support (cycleOf p x), (cycleOf p x ^ Nat.succ n) x_1 = (cycleOf p x ^ Nat.succ m) x_1

Next tactic:
intro y hy
set_option linter.deprecated false in
theorem nodup_toList (p : Perm α) (x : α) : Nodup (toList p x) := by
  by_cases hx : p x = x
  · rw [← not_mem_support, ← toList_eq_nil_iff] at hx
    simp [hx]
  have hc : IsCycle (cycleOf p x) := isCycle_cycleOf p hx
  rw [nodup_iff_nthLe_inj]
  rintro n m hn hm
  rw [length_toList, ← hc.orderOf] at hm hn
  rw [← cycleOf_apply_self, ← Ne.def, ← mem_support] at hx
  rw [nthLe_toList, nthLe_toList, ← cycleOf_pow_apply_self p x n, ←
    cycleOf_pow_apply_self p x m]
  cases' n with n <;> cases' m with m
  · simp
  · rw [← hc.support_pow_of_pos_of_lt_orderOf m.zero_lt_succ hm, mem_support,
      cycleOf_pow_apply_self] at hx
    simp [hx.symm]
  · rw [← hc.support_pow_of_pos_of_lt_orderOf n.zero_lt_succ hn, mem_support,
      cycleOf_pow_apply_self] at hx
    simp [hx]
  intro h
  have hn' : ¬orderOf (p.cycleOf x) ∣ n.succ := Nat.not_dvd_of_pos_of_lt n.zero_lt_succ hn
  have hm' : ¬orderOf (p.cycleOf x) ∣ m.succ := Nat.not_dvd_of_pos_of_lt m.zero_lt_succ hm
  rw [← hc.support_pow_eq_iff] at hn' hm'
  rw [← Nat.mod_eq_of_lt hn, ← Nat.mod_eq_of_lt hm, ← pow_inj_mod]
  refine' support_congr _ _
  · rw [hm', hn']
  · rw [hm']
    intro y hy
    

Proof state:
case neg.succ.succ.refine'_2
α : Type u_1
inst✝¹ : Fintype α
inst✝ : DecidableEq α
p✝ : Perm α
x✝ : α
p : Perm α
x : α
hx : x ∈ support (cycleOf p x)
hc : IsCycle (cycleOf p x)
n : ℕ
hn✝ : Nat.succ n < length (toList p x)
hn : Nat.succ n < orderOf (cycleOf p x)
m : ℕ
hm✝ : Nat.succ m < length (toList p x)
hm : Nat.succ m < orderOf (cycleOf p x)
h : (cycleOf p x ^ Nat.succ n) x = (cycleOf p x ^ Nat.succ m) x
hn' : support (cycleOf p x ^ Nat.succ n) = support (cycleOf p x)
hm' : support (cycleOf p x ^ Nat.succ m) = support (cycleOf p x)
y : α
hy : y ∈ support (cycleOf p x)
⊢ (cycleOf p x ^ Nat.succ n) y = (cycleOf p x ^ Nat.succ m) y

Next tactic:
obtain ⟨k, rfl⟩ := hc.exists_pow_eq (mem_support.mp hx) (mem_support.mp hy)
set_option linter.deprecated false in
theorem nodup_toList (p : Perm α) (x : α) : Nodup (toList p x) := by
  by_cases hx : p x = x
  · rw [← not_mem_support, ← toList_eq_nil_iff] at hx
    simp [hx]
  have hc : IsCycle (cycleOf p x) := isCycle_cycleOf p hx
  rw [nodup_iff_nthLe_inj]
  rintro n m hn hm
  rw [length_toList, ← hc.orderOf] at hm hn
  rw [← cycleOf_apply_self, ← Ne.def, ← mem_support] at hx
  rw [nthLe_toList, nthLe_toList, ← cycleOf_pow_apply_self p x n, ←
    cycleOf_pow_apply_self p x m]
  cases' n with n <;> cases' m with m
  · simp
  · rw [← hc.support_pow_of_pos_of_lt_orderOf m.zero_lt_succ hm, mem_support,
      cycleOf_pow_apply_self] at hx
    simp [hx.symm]
  · rw [← hc.support_pow_of_pos_of_lt_orderOf n.zero_lt_succ hn, mem_support,
      cycleOf_pow_apply_self] at hx
    simp [hx]
  intro h
  have hn' : ¬orderOf (p.cycleOf x) ∣ n.succ := Nat.not_dvd_of_pos_of_lt n.zero_lt_succ hn
  have hm' : ¬orderOf (p.cycleOf x) ∣ m.succ := Nat.not_dvd_of_pos_of_lt m.zero_lt_succ hm
  rw [← hc.support_pow_eq_iff] at hn' hm'
  rw [← Nat.mod_eq_of_lt hn, ← Nat.mod_eq_of_lt hm, ← pow_inj_mod]
  refine' support_congr _ _
  · rw [hm', hn']
  · rw [hm']
    intro y hy
    obtain ⟨k, rfl⟩ := hc.exists_pow_eq (mem_support.mp hx) (mem_support.mp hy)
    

Proof state:
case neg.succ.succ.refine'_2.intro
α : Type u_1
inst✝¹ : Fintype α
inst✝ : DecidableEq α
p✝ : Perm α
x✝ : α
p : Perm α
x : α
hx : x ∈ support (cycleOf p x)
hc : IsCycle (cycleOf p x)
n : ℕ
hn✝ : Nat.succ n < length (toList p x)
hn : Nat.succ n < orderOf (cycleOf p x)
m : ℕ
hm✝ : Nat.succ m < length (toList p x)
hm : Nat.succ m < orderOf (cycleOf p x)
h : (cycleOf p x ^ Nat.succ n) x = (cycleOf p x ^ Nat.succ m) x
hn' : support (cycleOf p x ^ Nat.succ n) = support (cycleOf p x)
hm' : support (cycleOf p x ^ Nat.succ m) = support (cycleOf p x)
k : ℕ
hy : (cycleOf p x ^ k) x ∈ support (cycleOf p x)
⊢ (cycleOf p x ^ Nat.succ n) ((cycleOf p x ^ k) x) = (cycleOf p x ^ Nat.succ m) ((cycleOf p x ^ k) x)

Next tactic:
rw [← mul_apply, (Commute.pow_pow_self _ _ _).eq, mul_apply, h, ← mul_apply, ← mul_apply,
      (Commute.pow_pow_self _ _ _).eq]
set_option linter.deprecated false in
theorem next_toList_eq_apply (p : Perm α) (x y : α) (hy : y ∈ toList p x) :
    next (toList p x) y hy = p y := by
  

Proof state:
α : Type u_1
inst✝¹ : Fintype α
inst✝ : DecidableEq α
p✝ : Perm α
x✝ : α
p : Perm α
x y : α
hy : y ∈ toList p x
⊢ next (toList p x) y hy = p y

Next tactic:
rw [mem_toList_iff] at hy
set_option linter.deprecated false in
theorem next_toList_eq_apply (p : Perm α) (x y : α) (hy : y ∈ toList p x) :
    next (toList p x) y hy = p y := by
  rw [mem_toList_iff] at hy
  

Proof state:
α : Type u_1
inst✝¹ : Fintype α
inst✝ : DecidableEq α
p✝ : Perm α
x✝ : α
p : Perm α
x y : α
hy✝ : y ∈ toList p x
hy : SameCycle p x y ∧ x ∈ support p
⊢ next (toList p x) y hy✝ = p y

Next tactic:
obtain ⟨k, hk, hk'⟩ := hy.left.exists_pow_eq_of_mem_support hy.right
set_option linter.deprecated false in
theorem next_toList_eq_apply (p : Perm α) (x y : α) (hy : y ∈ toList p x) :
    next (toList p x) y hy = p y := by
  rw [mem_toList_iff] at hy
  obtain ⟨k, hk, hk'⟩ := hy.left.exists_pow_eq_of_mem_support hy.right
  

Proof state:
case intro.intro
α : Type u_1
inst✝¹ : Fintype α
inst✝ : DecidableEq α
p✝ : Perm α
x✝ : α
p : Perm α
x y : α
hy✝ : y ∈ toList p x
hy : SameCycle p x y ∧ x ∈ support p
k : ℕ
hk : k < Finset.card (support (cycleOf p x))
hk' : (p ^ k) x = y
⊢ next (toList p x) y hy✝ = p y

Next tactic:
rw [← nthLe_toList p x k (by simpa using hk)] at hk'
set_option linter.deprecated false in
theorem next_toList_eq_apply (p : Perm α) (x y : α) (hy : y ∈ toList p x) :
    next (toList p x) y hy = p y := by
  rw [mem_toList_iff] at hy
  obtain ⟨k, hk, hk'⟩ := hy.left.exists_pow_eq_of_mem_support hy.right
  rw [← nthLe_toList p x k (by 

Proof state:
α : Type u_1
inst✝¹ : Fintype α
inst✝ : DecidableEq α
p✝ : Perm α
x✝ : α
p : Perm α
x y : α
hy✝ : y ∈ toList p x
hy : SameCycle p x y ∧ x ∈ support p
k : ℕ
hk : k < Finset.card (support (cycleOf p x))
hk' : (p ^ k) x = y
⊢ k < length (toList p x)

Next tactic:
simpa using hk
set_option linter.deprecated false in
theorem next_toList_eq_apply (p : Perm α) (x y : α) (hy : y ∈ toList p x) :
    next (toList p x) y hy = p y := by
  rw [mem_toList_iff] at hy
  obtain ⟨k, hk, hk'⟩ := hy.left.exists_pow_eq_of_mem_support hy.right
  rw [← nthLe_toList p x k (by simpa using hk)] at hk'
  

Proof state:
case intro.intro
α : Type u_1
inst✝¹ : Fintype α
inst✝ : DecidableEq α
p✝ : Perm α
x✝ : α
p : Perm α
x y : α
hy✝ : y ∈ toList p x
hy : SameCycle p x y ∧ x ∈ support p
k : ℕ
hk : k < Finset.card (support (cycleOf p x))
hk' : nthLe (toList p x) k (_ : k < length (toList p x)) = y
⊢ next (toList p x) y hy✝ = p y

Next tactic:
simp_rw [← hk']
set_option linter.deprecated false in
theorem next_toList_eq_apply (p : Perm α) (x y : α) (hy : y ∈ toList p x) :
    next (toList p x) y hy = p y := by
  rw [mem_toList_iff] at hy
  obtain ⟨k, hk, hk'⟩ := hy.left.exists_pow_eq_of_mem_support hy.right
  rw [← nthLe_toList p x k (by simpa using hk)] at hk'
  simp_rw [← hk']
  

Proof state:
case intro.intro
α : Type u_1
inst✝¹ : Fintype α
inst✝ : DecidableEq α
p✝ : Perm α
x✝ : α
p : Perm α
x y : α
hy✝ : y ∈ toList p x
hy : SameCycle p x y ∧ x ∈ support p
k : ℕ
hk : k < Finset.card (support (cycleOf p x))
hk' : nthLe (toList p x) k (_ : k < length (toList p x)) = y
⊢ next (toList p x) (nthLe (toList p x) k (_ : k < length (toList p x)))
      (_ : nthLe (toList p x) k (_ : k < length (toList p x)) ∈ toList p x) =
    p (nthLe (toList p x) k (_ : k < length (toList p x)))

Next tactic:
rw [next_nthLe _ (nodup_toList _ _), nthLe_toList, nthLe_toList, ← mul_apply, ← pow_succ,
    length_toList, ← pow_mod_orderOf_cycleOf_apply p (k + 1), IsCycle.orderOf]