l3lab/ntp-mathlib huggingface dataset:
theorem IsCycle.isCycle_pow_pos_of_lt_prime_order [Finite β] {f : Perm β} (hf : IsCycle f)
    (hf' : (orderOf f).Prime) (n : ℕ) (hn : 0 < n) (hn' : n < orderOf f) : IsCycle (f ^ n) := by
  classical
    cases nonempty_fintype β
    have : n.Coprime (orderOf f) := by
      refine' Nat.Coprime.symm _
      rw [Nat.Prime.coprime_iff_not_dvd hf']
      

Proof state:
ι : Type u_1
α : Type u_2
β : Type u_3
f✝ g : Perm α
x y : α
inst✝² : DecidableEq α
inst✝¹ : Fintype α
inst✝ : Finite β
f : Perm β
hf : IsCycle f
hf' : Nat.Prime (orderOf f)
n : ℕ
hn : 0 < n
hn' : n < orderOf f
val✝ : Fintype β
⊢ ¬orderOf f ∣ n

Next tactic:
exact Nat.not_dvd_of_pos_of_lt hn hn'
theorem IsCycle.isCycle_pow_pos_of_lt_prime_order [Finite β] {f : Perm β} (hf : IsCycle f)
    (hf' : (orderOf f).Prime) (n : ℕ) (hn : 0 < n) (hn' : n < orderOf f) : IsCycle (f ^ n) := by
  classical
    cases nonempty_fintype β
    have : n.Coprime (orderOf f) := by
      refine' Nat.Coprime.symm _
      rw [Nat.Prime.coprime_iff_not_dvd hf']
      exact Nat.not_dvd_of_pos_of_lt hn hn'
    

Proof state:
case intro
ι : Type u_1
α : Type u_2
β : Type u_3
f✝ g : Perm α
x y : α
inst✝² : DecidableEq α
inst✝¹ : Fintype α
inst✝ : Finite β
f : Perm β
hf : IsCycle f
hf' : Nat.Prime (orderOf f)
n : ℕ
hn : 0 < n
hn' : n < orderOf f
val✝ : Fintype β
this : Nat.Coprime n (orderOf f)
⊢ IsCycle (f ^ n)

Next tactic:
obtain ⟨m, hm⟩ := exists_pow_eq_self_of_coprime this
theorem IsCycle.isCycle_pow_pos_of_lt_prime_order [Finite β] {f : Perm β} (hf : IsCycle f)
    (hf' : (orderOf f).Prime) (n : ℕ) (hn : 0 < n) (hn' : n < orderOf f) : IsCycle (f ^ n) := by
  classical
    cases nonempty_fintype β
    have : n.Coprime (orderOf f) := by
      refine' Nat.Coprime.symm _
      rw [Nat.Prime.coprime_iff_not_dvd hf']
      exact Nat.not_dvd_of_pos_of_lt hn hn'
    obtain ⟨m, hm⟩ := exists_pow_eq_self_of_coprime this
    

Proof state:
case intro.intro
ι : Type u_1
α : Type u_2
β : Type u_3
f✝ g : Perm α
x y : α
inst✝² : DecidableEq α
inst✝¹ : Fintype α
inst✝ : Finite β
f : Perm β
hf : IsCycle f
hf' : Nat.Prime (orderOf f)
n : ℕ
hn : 0 < n
hn' : n < orderOf f
val✝ : Fintype β
this : Nat.Coprime n (orderOf f)
m : ℕ
hm : (f ^ n) ^ m = f
⊢ IsCycle (f ^ n)

Next tactic:
have hf'' := hf
theorem IsCycle.isCycle_pow_pos_of_lt_prime_order [Finite β] {f : Perm β} (hf : IsCycle f)
    (hf' : (orderOf f).Prime) (n : ℕ) (hn : 0 < n) (hn' : n < orderOf f) : IsCycle (f ^ n) := by
  classical
    cases nonempty_fintype β
    have : n.Coprime (orderOf f) := by
      refine' Nat.Coprime.symm _
      rw [Nat.Prime.coprime_iff_not_dvd hf']
      exact Nat.not_dvd_of_pos_of_lt hn hn'
    obtain ⟨m, hm⟩ := exists_pow_eq_self_of_coprime this
    have hf'' := hf
    

Proof state:
case intro.intro
ι : Type u_1
α : Type u_2
β : Type u_3
f✝ g : Perm α
x y : α
inst✝² : DecidableEq α
inst✝¹ : Fintype α
inst✝ : Finite β
f : Perm β
hf : IsCycle f
hf' : Nat.Prime (orderOf f)
n : ℕ
hn : 0 < n
hn' : n < orderOf f
val✝ : Fintype β
this : Nat.Coprime n (orderOf f)
m : ℕ
hm : (f ^ n) ^ m = f
hf'' : IsCycle f
⊢ IsCycle (f ^ n)

Next tactic:
rw [← hm] at hf''
theorem IsCycle.isCycle_pow_pos_of_lt_prime_order [Finite β] {f : Perm β} (hf : IsCycle f)
    (hf' : (orderOf f).Prime) (n : ℕ) (hn : 0 < n) (hn' : n < orderOf f) : IsCycle (f ^ n) := by
  classical
    cases nonempty_fintype β
    have : n.Coprime (orderOf f) := by
      refine' Nat.Coprime.symm _
      rw [Nat.Prime.coprime_iff_not_dvd hf']
      exact Nat.not_dvd_of_pos_of_lt hn hn'
    obtain ⟨m, hm⟩ := exists_pow_eq_self_of_coprime this
    have hf'' := hf
    rw [← hm] at hf''
    

Proof state:
case intro.intro
ι : Type u_1
α : Type u_2
β : Type u_3
f✝ g : Perm α
x y : α
inst✝² : DecidableEq α
inst✝¹ : Fintype α
inst✝ : Finite β
f : Perm β
hf : IsCycle f
hf' : Nat.Prime (orderOf f)
n : ℕ
hn : 0 < n
hn' : n < orderOf f
val✝ : Fintype β
this : Nat.Coprime n (orderOf f)
m : ℕ
hm : (f ^ n) ^ m = f
hf'' : IsCycle ((f ^ n) ^ m)
⊢ IsCycle (f ^ n)

Next tactic:
refine' hf''.of_pow _
theorem IsCycle.isCycle_pow_pos_of_lt_prime_order [Finite β] {f : Perm β} (hf : IsCycle f)
    (hf' : (orderOf f).Prime) (n : ℕ) (hn : 0 < n) (hn' : n < orderOf f) : IsCycle (f ^ n) := by
  classical
    cases nonempty_fintype β
    have : n.Coprime (orderOf f) := by
      refine' Nat.Coprime.symm _
      rw [Nat.Prime.coprime_iff_not_dvd hf']
      exact Nat.not_dvd_of_pos_of_lt hn hn'
    obtain ⟨m, hm⟩ := exists_pow_eq_self_of_coprime this
    have hf'' := hf
    rw [← hm] at hf''
    refine' hf''.of_pow _
    

Proof state:
case intro.intro
ι : Type u_1
α : Type u_2
β : Type u_3
f✝ g : Perm α
x y : α
inst✝² : DecidableEq α
inst✝¹ : Fintype α
inst✝ : Finite β
f : Perm β
hf : IsCycle f
hf' : Nat.Prime (orderOf f)
n : ℕ
hn : 0 < n
hn' : n < orderOf f
val✝ : Fintype β
this : Nat.Coprime n (orderOf f)
m : ℕ
hm : (f ^ n) ^ m = f
hf'' : IsCycle ((f ^ n) ^ m)
⊢ support (f ^ n) ⊆ support ((f ^ n) ^ m)

Next tactic:
rw [hm]
theorem IsCycle.isCycle_pow_pos_of_lt_prime_order [Finite β] {f : Perm β} (hf : IsCycle f)
    (hf' : (orderOf f).Prime) (n : ℕ) (hn : 0 < n) (hn' : n < orderOf f) : IsCycle (f ^ n) := by
  classical
    cases nonempty_fintype β
    have : n.Coprime (orderOf f) := by
      refine' Nat.Coprime.symm _
      rw [Nat.Prime.coprime_iff_not_dvd hf']
      exact Nat.not_dvd_of_pos_of_lt hn hn'
    obtain ⟨m, hm⟩ := exists_pow_eq_self_of_coprime this
    have hf'' := hf
    rw [← hm] at hf''
    refine' hf''.of_pow _
    rw [hm]
    

Proof state:
case intro.intro
ι : Type u_1
α : Type u_2
β : Type u_3
f✝ g : Perm α
x y : α
inst✝² : DecidableEq α
inst✝¹ : Fintype α
inst✝ : Finite β
f : Perm β
hf : IsCycle f
hf' : Nat.Prime (orderOf f)
n : ℕ
hn : 0 < n
hn' : n < orderOf f
val✝ : Fintype β
this : Nat.Coprime n (orderOf f)
m : ℕ
hm : (f ^ n) ^ m = f
hf'' : IsCycle ((f ^ n) ^ m)
⊢ support (f ^ n) ⊆ support f

Next tactic:
exact support_pow_le f n
@[simp]
theorem isCycleOn_empty : f.IsCycleOn ∅ := by 

Proof state:
ι : Type u_1
α : Type u_2
β : Type u_3
f g : Perm α
s t : Set α
a b x y : α
⊢ IsCycleOn f ∅

Next tactic:
simp [IsCycleOn, Set.bijOn_empty]
@[simp]
theorem isCycleOn_one : (1 : Perm α).IsCycleOn s ↔ s.Subsingleton := by
  

Proof state:
ι : Type u_1
α : Type u_2
β : Type u_3
f g : Perm α
s t : Set α
a b x y : α
⊢ IsCycleOn 1 s ↔ Set.Subsingleton s

Next tactic:
simp [IsCycleOn, Set.bijOn_id, Set.Subsingleton]
@[simp]
theorem isCycleOn_singleton : f.IsCycleOn {a} ↔ f a = a := by 

Proof state:
ι : Type u_1
α : Type u_2
β : Type u_3
f g : Perm α
s t : Set α
a b x y : α
⊢ IsCycleOn f {a} ↔ f a = a

Next tactic:
simp [IsCycleOn, SameCycle.rfl]
@[simp]
theorem isCycleOn_inv : f⁻¹.IsCycleOn s ↔ f.IsCycleOn s := by
  

Proof state:
ι : Type u_1
α : Type u_2
β : Type u_3
f g : Perm α
s t : Set α
a b x y : α
⊢ IsCycleOn f⁻¹ s ↔ IsCycleOn f s

Next tactic:
simp only [IsCycleOn, sameCycle_inv, and_congr_left_iff]
@[simp]
theorem isCycleOn_inv : f⁻¹.IsCycleOn s ↔ f.IsCycleOn s := by
  simp only [IsCycleOn, sameCycle_inv, and_congr_left_iff]
  

Proof state:
ι : Type u_1
α : Type u_2
β : Type u_3
f g : Perm α
s t : Set α
a b x y : α
⊢ (∀ ⦃x : α⦄, x ∈ s → ∀ ⦃y : α⦄, y ∈ s → SameCycle f x y) → (Set.BijOn (⇑f⁻¹) s s ↔ Set.BijOn (⇑f) s s)

Next tactic:
exact fun _ ↦ ⟨fun h ↦ Set.BijOn.perm_inv h, fun h ↦ Set.BijOn.perm_inv h⟩
theorem IsCycleOn.conj (h : f.IsCycleOn s) : (g * f * g⁻¹).IsCycleOn ((g : Perm α) '' s) :=
  ⟨(g.bijOn_image.comp h.1).comp g.bijOn_symm_image, fun x hx y hy => by
    

Proof state:
ι : Type u_1
α : Type u_2
β : Type u_3
f g : Perm α
s t : Set α
a b x✝ y✝ : α
h : IsCycleOn f s
x : α
hx : x ∈ ⇑g '' s
y : α
hy : y ∈ ⇑g '' s
⊢ SameCycle (g * f * g⁻¹) x y

Next tactic:
rw [← preimage_inv] at hx hy
theorem IsCycleOn.conj (h : f.IsCycleOn s) : (g * f * g⁻¹).IsCycleOn ((g : Perm α) '' s) :=
  ⟨(g.bijOn_image.comp h.1).comp g.bijOn_symm_image, fun x hx y hy => by
    rw [← preimage_inv] at hx hy
    

Proof state:
ι : Type u_1
α : Type u_2
β : Type u_3
f g : Perm α
s t : Set α
a b x✝ y✝ : α
h : IsCycleOn f s
x : α
hx : x ∈ ⇑g⁻¹ ⁻¹' s
y : α
hy : y ∈ ⇑g⁻¹ ⁻¹' s
⊢ SameCycle (g * f * g⁻¹) x y

Next tactic:
convert Equiv.Perm.SameCycle.conj (h.2 hx hy) (g := g)
theorem IsCycleOn.conj (h : f.IsCycleOn s) : (g * f * g⁻¹).IsCycleOn ((g : Perm α) '' s) :=
  ⟨(g.bijOn_image.comp h.1).comp g.bijOn_symm_image, fun x hx y hy => by
    rw [← preimage_inv] at hx hy
    convert Equiv.Perm.SameCycle.conj (h.2 hx hy) (g := g) <;> 

Proof state:
case h.e'_3
ι : Type u_1
α : Type u_2
β : Type u_3
f g : Perm α
s t : Set α
a b x✝ y✝ : α
h : IsCycleOn f s
x : α
hx : x ∈ ⇑g⁻¹ ⁻¹' s
y : α
hy : y ∈ ⇑g⁻¹ ⁻¹' s
⊢ x = g (g⁻¹ x)

Next tactic:
rw [apply_inv_self]
theorem IsCycleOn.conj (h : f.IsCycleOn s) : (g * f * g⁻¹).IsCycleOn ((g : Perm α) '' s) :=
  ⟨(g.bijOn_image.comp h.1).comp g.bijOn_symm_image, fun x hx y hy => by
    rw [← preimage_inv] at hx hy
    convert Equiv.Perm.SameCycle.conj (h.2 hx hy) (g := g) <;> 

Proof state:
case h.e'_4
ι : Type u_1
α : Type u_2
β : Type u_3
f g : Perm α
s t : Set α
a b x✝ y✝ : α
h : IsCycleOn f s
x : α
hx : x ∈ ⇑g⁻¹ ⁻¹' s
y : α
hy : y ∈ ⇑g⁻¹ ⁻¹' s
⊢ y = g (g⁻¹ y)

Next tactic:
rw [apply_inv_self]
theorem isCycleOn_swap [DecidableEq α] (hab : a ≠ b) : (swap a b).IsCycleOn {a, b} :=
  ⟨bijOn_swap (by 

Proof state:
ι : Type u_1
α : Type u_2
β : Type u_3
f g : Perm α
s t : Set α
a b x y : α
inst✝ : DecidableEq α
hab : a ≠ b
⊢ a ∈ {a, b}

Next tactic:
simp
theorem isCycleOn_swap [DecidableEq α] (hab : a ≠ b) : (swap a b).IsCycleOn {a, b} :=
  ⟨bijOn_swap (by simp) (by 

Proof state:
ι : Type u_1
α : Type u_2
β : Type u_3
f g : Perm α
s t : Set α
a b x y : α
inst✝ : DecidableEq α
hab : a ≠ b
⊢ b ∈ {a, b}

Next tactic:
simp
theorem isCycleOn_swap [DecidableEq α] (hab : a ≠ b) : (swap a b).IsCycleOn {a, b} :=
  ⟨bijOn_swap (by simp) (by simp), fun x hx y hy => by
    

Proof state:
ι : Type u_1
α : Type u_2
β : Type u_3
f g : Perm α
s t : Set α
a b x✝ y✝ : α
inst✝ : DecidableEq α
hab : a ≠ b
x : α
hx : x ∈ {a, b}
y : α
hy : y ∈ {a, b}
⊢ SameCycle (swap a b) x y

Next tactic:
rw [Set.mem_insert_iff, Set.mem_singleton_iff] at hx hy
theorem isCycleOn_swap [DecidableEq α] (hab : a ≠ b) : (swap a b).IsCycleOn {a, b} :=
  ⟨bijOn_swap (by simp) (by simp), fun x hx y hy => by
    rw [Set.mem_insert_iff, Set.mem_singleton_iff] at hx hy
    

Proof state:
ι : Type u_1
α : Type u_2
β : Type u_3
f g : Perm α
s t : Set α
a b x✝ y✝ : α
inst✝ : DecidableEq α
hab : a ≠ b
x : α
hx : x = a ∨ x = b
y : α
hy : y = a ∨ y = b
⊢ SameCycle (swap a b) x y

Next tactic:
obtain rfl | rfl := hx
theorem isCycleOn_swap [DecidableEq α] (hab : a ≠ b) : (swap a b).IsCycleOn {a, b} :=
  ⟨bijOn_swap (by simp) (by simp), fun x hx y hy => by
    rw [Set.mem_insert_iff, Set.mem_singleton_iff] at hx hy
    obtain rfl | rfl := hx <;> 

Proof state:
case inl
ι : Type u_1
α : Type u_2
β : Type u_3
f g : Perm α
s t : Set α
b x✝ y✝ : α
inst✝ : DecidableEq α
x y : α
hab : x ≠ b
hy : y = x ∨ y = b
⊢ SameCycle (swap x b) x y

Next tactic:
obtain rfl | rfl := hy
theorem isCycleOn_swap [DecidableEq α] (hab : a ≠ b) : (swap a b).IsCycleOn {a, b} :=
  ⟨bijOn_swap (by simp) (by simp), fun x hx y hy => by
    rw [Set.mem_insert_iff, Set.mem_singleton_iff] at hx hy
    obtain rfl | rfl := hx <;> 

Proof state:
case inr
ι : Type u_1
α : Type u_2
β : Type u_3
f g : Perm α
s t : Set α
a x✝ y✝ : α
inst✝ : DecidableEq α
x y : α
hab : a ≠ x
hy : y = a ∨ y = x
⊢ SameCycle (swap a x) x y

Next tactic:
obtain rfl | rfl := hy
theorem isCycleOn_swap [DecidableEq α] (hab : a ≠ b) : (swap a b).IsCycleOn {a, b} :=
  ⟨bijOn_swap (by simp) (by simp), fun x hx y hy => by
    rw [Set.mem_insert_iff, Set.mem_singleton_iff] at hx hy
    obtain rfl | rfl := hx <;> obtain rfl | rfl := hy
    · 

Proof state:
case inl.inl
ι : Type u_1
α : Type u_2
β : Type u_3
f g : Perm α
s t : Set α
b x y✝ : α
inst✝ : DecidableEq α
y : α
hab : y ≠ b
⊢ SameCycle (swap y b) y y

Next tactic:
exact ⟨0, by rw [zpow_zero, coe_one, id.def]⟩
theorem isCycleOn_swap [DecidableEq α] (hab : a ≠ b) : (swap a b).IsCycleOn {a, b} :=
  ⟨bijOn_swap (by simp) (by simp), fun x hx y hy => by
    rw [Set.mem_insert_iff, Set.mem_singleton_iff] at hx hy
    obtain rfl | rfl := hx <;> obtain rfl | rfl := hy
    · exact ⟨0, by 

Proof state:
ι : Type u_1
α : Type u_2
β : Type u_3
f g : Perm α
s t : Set α
b x y✝ : α
inst✝ : DecidableEq α
y : α
hab : y ≠ b
⊢ (swap y b ^ 0) y = y

Next tactic:
rw [zpow_zero, coe_one, id.def]
theorem isCycleOn_swap [DecidableEq α] (hab : a ≠ b) : (swap a b).IsCycleOn {a, b} :=
  ⟨bijOn_swap (by simp) (by simp), fun x hx y hy => by
    rw [Set.mem_insert_iff, Set.mem_singleton_iff] at hx hy
    obtain rfl | rfl := hx <;> obtain rfl | rfl := hy
    · exact ⟨0, by rw [zpow_zero, coe_one, id.def]⟩
    · 

Proof state:
case inl.inr
ι : Type u_1
α : Type u_2
β : Type u_3
f g : Perm α
s t : Set α
x✝ y✝ : α
inst✝ : DecidableEq α
x y : α
hab : x ≠ y
⊢ SameCycle (swap x y) x y

Next tactic:
exact ⟨1, by rw [zpow_one, swap_apply_left]⟩
theorem isCycleOn_swap [DecidableEq α] (hab : a ≠ b) : (swap a b).IsCycleOn {a, b} :=
  ⟨bijOn_swap (by simp) (by simp), fun x hx y hy => by
    rw [Set.mem_insert_iff, Set.mem_singleton_iff] at hx hy
    obtain rfl | rfl := hx <;> obtain rfl | rfl := hy
    · exact ⟨0, by rw [zpow_zero, coe_one, id.def]⟩
    · exact ⟨1, by 

Proof state:
ι : Type u_1
α : Type u_2
β : Type u_3
f g : Perm α
s t : Set α
x✝ y✝ : α
inst✝ : DecidableEq α
x y : α
hab : x ≠ y
⊢ (swap x y ^ 1) x = y

Next tactic:
rw [zpow_one, swap_apply_left]
theorem isCycleOn_swap [DecidableEq α] (hab : a ≠ b) : (swap a b).IsCycleOn {a, b} :=
  ⟨bijOn_swap (by simp) (by simp), fun x hx y hy => by
    rw [Set.mem_insert_iff, Set.mem_singleton_iff] at hx hy
    obtain rfl | rfl := hx <;> obtain rfl | rfl := hy
    · exact ⟨0, by rw [zpow_zero, coe_one, id.def]⟩
    · exact ⟨1, by rw [zpow_one, swap_apply_left]⟩
    · 

Proof state:
case inr.inl
ι : Type u_1
α : Type u_2
β : Type u_3
f g : Perm α
s t : Set α
x✝ y✝ : α
inst✝ : DecidableEq α
x y : α
hab : y ≠ x
⊢ SameCycle (swap y x) x y

Next tactic:
exact ⟨1, by rw [zpow_one, swap_apply_right]⟩
theorem isCycleOn_swap [DecidableEq α] (hab : a ≠ b) : (swap a b).IsCycleOn {a, b} :=
  ⟨bijOn_swap (by simp) (by simp), fun x hx y hy => by
    rw [Set.mem_insert_iff, Set.mem_singleton_iff] at hx hy
    obtain rfl | rfl := hx <;> obtain rfl | rfl := hy
    · exact ⟨0, by rw [zpow_zero, coe_one, id.def]⟩
    · exact ⟨1, by rw [zpow_one, swap_apply_left]⟩
    · exact ⟨1, by 

Proof state:
ι : Type u_1
α : Type u_2
β : Type u_3
f g : Perm α
s t : Set α
x✝ y✝ : α
inst✝ : DecidableEq α
x y : α
hab : y ≠ x
⊢ (swap y x ^ 1) x = y

Next tactic:
rw [zpow_one, swap_apply_right]
theorem isCycleOn_swap [DecidableEq α] (hab : a ≠ b) : (swap a b).IsCycleOn {a, b} :=
  ⟨bijOn_swap (by simp) (by simp), fun x hx y hy => by
    rw [Set.mem_insert_iff, Set.mem_singleton_iff] at hx hy
    obtain rfl | rfl := hx <;> obtain rfl | rfl := hy
    · exact ⟨0, by rw [zpow_zero, coe_one, id.def]⟩
    · exact ⟨1, by rw [zpow_one, swap_apply_left]⟩
    · exact ⟨1, by rw [zpow_one, swap_apply_right]⟩
    · 

Proof state:
case inr.inr
ι : Type u_1
α : Type u_2
β : Type u_3
f g : Perm α
s t : Set α
a x y✝ : α
inst✝ : DecidableEq α
y : α
hab : a ≠ y
⊢ SameCycle (swap a y) y y

Next tactic:
exact ⟨0, by rw [zpow_zero, coe_one, id.def]⟩
theorem isCycleOn_swap [DecidableEq α] (hab : a ≠ b) : (swap a b).IsCycleOn {a, b} :=
  ⟨bijOn_swap (by simp) (by simp), fun x hx y hy => by
    rw [Set.mem_insert_iff, Set.mem_singleton_iff] at hx hy
    obtain rfl | rfl := hx <;> obtain rfl | rfl := hy
    · exact ⟨0, by rw [zpow_zero, coe_one, id.def]⟩
    · exact ⟨1, by rw [zpow_one, swap_apply_left]⟩
    · exact ⟨1, by rw [zpow_one, swap_apply_right]⟩
    · exact ⟨0, by 

Proof state:
ι : Type u_1
α : Type u_2
β : Type u_3
f g : Perm α
s t : Set α
a x y✝ : α
inst✝ : DecidableEq α
y : α
hab : a ≠ y
⊢ (swap a y ^ 0) y = y

Next tactic:
rw [zpow_zero, coe_one, id.def]
protected theorem IsCycleOn.apply_ne (hf : f.IsCycleOn s) (hs : s.Nontrivial) (ha : a ∈ s) :
    f a ≠ a := by
  

Proof state:
ι : Type u_1
α : Type u_2
β : Type u_3
f g : Perm α
s t : Set α
a b x y : α
hf : IsCycleOn f s
hs : Set.Nontrivial s
ha : a ∈ s
⊢ f a ≠ a

Next tactic:
obtain ⟨b, hb, hba⟩ := hs.exists_ne a
protected theorem IsCycleOn.apply_ne (hf : f.IsCycleOn s) (hs : s.Nontrivial) (ha : a ∈ s) :
    f a ≠ a := by
  obtain ⟨b, hb, hba⟩ := hs.exists_ne a
  

Proof state:
case intro.intro
ι : Type u_1
α : Type u_2
β : Type u_3
f g : Perm α
s t : Set α
a b✝ x y : α
hf : IsCycleOn f s
hs : Set.Nontrivial s
ha : a ∈ s
b : α
hb : b ∈ s
hba : b ≠ a
⊢ f a ≠ a

Next tactic:
obtain ⟨n, rfl⟩ := hf.2 ha hb
protected theorem IsCycleOn.apply_ne (hf : f.IsCycleOn s) (hs : s.Nontrivial) (ha : a ∈ s) :
    f a ≠ a := by
  obtain ⟨b, hb, hba⟩ := hs.exists_ne a
  obtain ⟨n, rfl⟩ := hf.2 ha hb
  

Proof state:
case intro.intro.intro
ι : Type u_1
α : Type u_2
β : Type u_3
f g : Perm α
s t : Set α
a b x y : α
hf : IsCycleOn f s
hs : Set.Nontrivial s
ha : a ∈ s
n : ℤ
hb : (f ^ n) a ∈ s
hba : (f ^ n) a ≠ a
⊢ f a ≠ a

Next tactic:
exact fun h => hba (IsFixedPt.perm_zpow h n)
/-- This lemma demonstrates the relation between `Equiv.Perm.IsCycle` and `Equiv.Perm.IsCycleOn`
in non-degenerate cases. -/
theorem isCycle_iff_exists_isCycleOn :
    f.IsCycle ↔ ∃ s : Set α, s.Nontrivial ∧ f.IsCycleOn s ∧ ∀ ⦃x⦄, ¬IsFixedPt f x → x ∈ s := by
  

Proof state:
ι : Type u_1
α : Type u_2
β : Type u_3
f g : Perm α
s t : Set α
a b x y : α
⊢ IsCycle f ↔ ∃ s, Set.Nontrivial s ∧ IsCycleOn f s ∧ ∀ ⦃x : α⦄, ¬IsFixedPt (⇑f) x → x ∈ s

Next tactic:
refine' ⟨fun hf => ⟨{ x | f x ≠ x }, _, hf.isCycleOn, fun _ => id⟩, _⟩
/-- This lemma demonstrates the relation between `Equiv.Perm.IsCycle` and `Equiv.Perm.IsCycleOn`
in non-degenerate cases. -/
theorem isCycle_iff_exists_isCycleOn :
    f.IsCycle ↔ ∃ s : Set α, s.Nontrivial ∧ f.IsCycleOn s ∧ ∀ ⦃x⦄, ¬IsFixedPt f x → x ∈ s := by
  refine' ⟨fun hf => ⟨{ x | f x ≠ x }, _, hf.isCycleOn, fun _ => id⟩, _⟩
  · 

Proof state:
case refine'_1
ι : Type u_1
α : Type u_2
β : Type u_3
f g : Perm α
s t : Set α
a b x y : α
hf : IsCycle f
⊢ Set.Nontrivial {x | f x ≠ x}

Next tactic:
obtain ⟨a, ha⟩ := hf
/-- This lemma demonstrates the relation between `Equiv.Perm.IsCycle` and `Equiv.Perm.IsCycleOn`
in non-degenerate cases. -/
theorem isCycle_iff_exists_isCycleOn :
    f.IsCycle ↔ ∃ s : Set α, s.Nontrivial ∧ f.IsCycleOn s ∧ ∀ ⦃x⦄, ¬IsFixedPt f x → x ∈ s := by
  refine' ⟨fun hf => ⟨{ x | f x ≠ x }, _, hf.isCycleOn, fun _ => id⟩, _⟩
  · obtain ⟨a, ha⟩ := hf
    

Proof state:
case refine'_1.intro
ι : Type u_1
α : Type u_2
β : Type u_3
f g : Perm α
s t : Set α
a✝ b x y a : α
ha : f a ≠ a ∧ ∀ ⦃y : α⦄, f y ≠ y → SameCycle f a y
⊢ Set.Nontrivial {x | f x ≠ x}

Next tactic:
exact ⟨f a, f.injective.ne ha.1, a, ha.1, ha.1⟩
/-- This lemma demonstrates the relation between `Equiv.Perm.IsCycle` and `Equiv.Perm.IsCycleOn`
in non-degenerate cases. -/
theorem isCycle_iff_exists_isCycleOn :
    f.IsCycle ↔ ∃ s : Set α, s.Nontrivial ∧ f.IsCycleOn s ∧ ∀ ⦃x⦄, ¬IsFixedPt f x → x ∈ s := by
  refine' ⟨fun hf => ⟨{ x | f x ≠ x }, _, hf.isCycleOn, fun _ => id⟩, _⟩
  · obtain ⟨a, ha⟩ := hf
    exact ⟨f a, f.injective.ne ha.1, a, ha.1, ha.1⟩
  · 

Proof state:
case refine'_2
ι : Type u_1
α : Type u_2
β : Type u_3
f g : Perm α
s t : Set α
a b x y : α
⊢ (∃ s, Set.Nontrivial s ∧ IsCycleOn f s ∧ ∀ ⦃x : α⦄, ¬IsFixedPt (⇑f) x → x ∈ s) → IsCycle f

Next tactic:
rintro ⟨s, hs, hf, hsf⟩
/-- This lemma demonstrates the relation between `Equiv.Perm.IsCycle` and `Equiv.Perm.IsCycleOn`
in non-degenerate cases. -/
theorem isCycle_iff_exists_isCycleOn :
    f.IsCycle ↔ ∃ s : Set α, s.Nontrivial ∧ f.IsCycleOn s ∧ ∀ ⦃x⦄, ¬IsFixedPt f x → x ∈ s := by
  refine' ⟨fun hf => ⟨{ x | f x ≠ x }, _, hf.isCycleOn, fun _ => id⟩, _⟩
  · obtain ⟨a, ha⟩ := hf
    exact ⟨f a, f.injective.ne ha.1, a, ha.1, ha.1⟩
  · rintro ⟨s, hs, hf, hsf⟩
    

Proof state:
case refine'_2.intro.intro.intro
ι : Type u_1
α : Type u_2
β : Type u_3
f g : Perm α
s✝ t : Set α
a b x y : α
s : Set α
hs : Set.Nontrivial s
hf : IsCycleOn f s
hsf : ∀ ⦃x : α⦄, ¬IsFixedPt (⇑f) x → x ∈ s
⊢ IsCycle f

Next tactic:
obtain ⟨a, ha⟩ := hs.nonempty
/-- This lemma demonstrates the relation between `Equiv.Perm.IsCycle` and `Equiv.Perm.IsCycleOn`
in non-degenerate cases. -/
theorem isCycle_iff_exists_isCycleOn :
    f.IsCycle ↔ ∃ s : Set α, s.Nontrivial ∧ f.IsCycleOn s ∧ ∀ ⦃x⦄, ¬IsFixedPt f x → x ∈ s := by
  refine' ⟨fun hf => ⟨{ x | f x ≠ x }, _, hf.isCycleOn, fun _ => id⟩, _⟩
  · obtain ⟨a, ha⟩ := hf
    exact ⟨f a, f.injective.ne ha.1, a, ha.1, ha.1⟩
  · rintro ⟨s, hs, hf, hsf⟩
    obtain ⟨a, ha⟩ := hs.nonempty
    

Proof state:
case refine'_2.intro.intro.intro.intro
ι : Type u_1
α : Type u_2
β : Type u_3
f g : Perm α
s✝ t : Set α
a✝ b x y : α
s : Set α
hs : Set.Nontrivial s
hf : IsCycleOn f s
hsf : ∀ ⦃x : α⦄, ¬IsFixedPt (⇑f) x → x ∈ s
a : α
ha : a ∈ s
⊢ IsCycle f

Next tactic:
exact ⟨a, hf.apply_ne hs ha, fun b hb => hf.2 ha <| hsf hb⟩
theorem IsCycleOn.apply_mem_iff (hf : f.IsCycleOn s) : f x ∈ s ↔ x ∈ s :=
  ⟨fun hx => by
    

Proof state:
ι : Type u_1
α : Type u_2
β : Type u_3
f g : Perm α
s t : Set α
a b x y : α
hf : IsCycleOn f s
hx : f x ∈ s
⊢ x ∈ s

Next tactic:
convert hf.1.perm_inv.1 hx
theorem IsCycleOn.apply_mem_iff (hf : f.IsCycleOn s) : f x ∈ s ↔ x ∈ s :=
  ⟨fun hx => by
    convert hf.1.perm_inv.1 hx
    

Proof state:
case h.e'_4
ι : Type u_1
α : Type u_2
β : Type u_3
f g : Perm α
s t : Set α
a b x y : α
hf : IsCycleOn f s
hx : f x ∈ s
⊢ x = f⁻¹ (f x)

Next tactic:
rw [inv_apply_self]
/-- Note that the identity satisfies `IsCycleOn` for any subsingleton set, but not `IsCycle`. -/
theorem IsCycleOn.isCycle_subtypePerm (hf : f.IsCycleOn s) (hs : s.Nontrivial) :
    (f.subtypePerm fun _ => hf.apply_mem_iff.symm : Perm s).IsCycle := by
  

Proof state:
ι : Type u_1
α : Type u_2
β : Type u_3
f g : Perm α
s t : Set α
a b x y : α
hf : IsCycleOn f s
hs : Set.Nontrivial s
⊢ IsCycle (subtypePerm f (_ : ∀ (x : α), x ∈ s ↔ f x ∈ s))

Next tactic:
obtain ⟨a, ha⟩ := hs.nonempty
/-- Note that the identity satisfies `IsCycleOn` for any subsingleton set, but not `IsCycle`. -/
theorem IsCycleOn.isCycle_subtypePerm (hf : f.IsCycleOn s) (hs : s.Nontrivial) :
    (f.subtypePerm fun _ => hf.apply_mem_iff.symm : Perm s).IsCycle := by
  obtain ⟨a, ha⟩ := hs.nonempty
  

Proof state:
case intro
ι : Type u_1
α : Type u_2
β : Type u_3
f g : Perm α
s t : Set α
a✝ b x y : α
hf : IsCycleOn f s
hs : Set.Nontrivial s
a : α
ha : a ∈ s
⊢ IsCycle (subtypePerm f (_ : ∀ (x : α), x ∈ s ↔ f x ∈ s))

Next tactic:
exact
    ⟨⟨a, ha⟩, ne_of_apply_ne ((↑) : s → α) (hf.apply_ne hs ha), fun b _ =>
      (hf.2 (⟨a, ha⟩ : s).2 b.2).subtypePerm⟩
/-- Note that the identity is a cycle on any subsingleton set, but not a cycle. -/
protected theorem IsCycleOn.subtypePerm (hf : f.IsCycleOn s) :
    (f.subtypePerm fun _ => hf.apply_mem_iff.symm : Perm s).IsCycleOn _root_.Set.univ := by
  

Proof state:
ι : Type u_1
α : Type u_2
β : Type u_3
f g : Perm α
s t : Set α
a b x y : α
hf : IsCycleOn f s
⊢ IsCycleOn (subtypePerm f (_ : ∀ (x : α), x ∈ s ↔ f x ∈ s)) _root_.Set.univ

Next tactic:
obtain hs | hs := s.subsingleton_or_nontrivial
/-- Note that the identity is a cycle on any subsingleton set, but not a cycle. -/
protected theorem IsCycleOn.subtypePerm (hf : f.IsCycleOn s) :
    (f.subtypePerm fun _ => hf.apply_mem_iff.symm : Perm s).IsCycleOn _root_.Set.univ := by
  obtain hs | hs := s.subsingleton_or_nontrivial
  · 

Proof state:
case inl
ι : Type u_1
α : Type u_2
β : Type u_3
f g : Perm α
s t : Set α
a b x y : α
hf : IsCycleOn f s
hs : Set.Subsingleton s
⊢ IsCycleOn (subtypePerm f (_ : ∀ (x : α), x ∈ s ↔ f x ∈ s)) _root_.Set.univ

Next tactic:
haveI := hs.coe_sort
/-- Note that the identity is a cycle on any subsingleton set, but not a cycle. -/
protected theorem IsCycleOn.subtypePerm (hf : f.IsCycleOn s) :
    (f.subtypePerm fun _ => hf.apply_mem_iff.symm : Perm s).IsCycleOn _root_.Set.univ := by
  obtain hs | hs := s.subsingleton_or_nontrivial
  · haveI := hs.coe_sort
    

Proof state:
case inl
ι : Type u_1
α : Type u_2
β : Type u_3
f g : Perm α
s t : Set α
a b x y : α
hf : IsCycleOn f s
hs : Set.Subsingleton s
this : Subsingleton ↑s
⊢ IsCycleOn (subtypePerm f (_ : ∀ (x : α), x ∈ s ↔ f x ∈ s)) _root_.Set.univ

Next tactic:
exact isCycleOn_of_subsingleton _ _