l3lab/ntp-mathlib huggingface dataset:
theorem count_succ_eq_succ_count_iff {n : ℕ} : count p (n + 1) = count p n + 1 ↔ p n := by
  by_cases h : p n <;> 

Proof state:
case neg
p : ℕ → Prop
inst✝ : DecidablePred p
n : ℕ
h : ¬p n
⊢ count p (n + 1) = count p n + 1 ↔ p n

Next tactic:
simp [h, count_succ]
theorem count_succ_eq_count_iff {n : ℕ} : count p (n + 1) = count p n ↔ ¬p n := by
  

Proof state:
p : ℕ → Prop
inst✝ : DecidablePred p
n : ℕ
⊢ count p (n + 1) = count p n ↔ ¬p n

Next tactic:
by_cases h : p n
theorem count_succ_eq_count_iff {n : ℕ} : count p (n + 1) = count p n ↔ ¬p n := by
  by_cases h : p n <;> 

Proof state:
case pos
p : ℕ → Prop
inst✝ : DecidablePred p
n : ℕ
h : p n
⊢ count p (n + 1) = count p n ↔ ¬p n

Next tactic:
simp [h, count_succ]
theorem count_succ_eq_count_iff {n : ℕ} : count p (n + 1) = count p n ↔ ¬p n := by
  by_cases h : p n <;> 

Proof state:
case neg
p : ℕ → Prop
inst✝ : DecidablePred p
n : ℕ
h : ¬p n
⊢ count p (n + 1) = count p n ↔ ¬p n

Next tactic:
simp [h, count_succ]
theorem count_le_cardinal (n : ℕ) : (count p n : Cardinal) ≤ Cardinal.mk { k | p k } := by
  

Proof state:
p : ℕ → Prop
inst✝ : DecidablePred p
n : ℕ
⊢ ↑(count p n) ≤ Cardinal.mk ↑{k | p k}

Next tactic:
rw [count_eq_card_fintype, ← Cardinal.mk_fintype]
theorem count_le_cardinal (n : ℕ) : (count p n : Cardinal) ≤ Cardinal.mk { k | p k } := by
  rw [count_eq_card_fintype, ← Cardinal.mk_fintype]
  

Proof state:
p : ℕ → Prop
inst✝ : DecidablePred p
n : ℕ
⊢ Cardinal.mk { k // k < n ∧ p k } ≤ Cardinal.mk ↑{k | p k}

Next tactic:
exact Cardinal.mk_subtype_mono fun x hx ↦ hx.2
theorem count_injective {m n : ℕ} (hm : p m) (hn : p n) (heq : count p m = count p n) : m = n := by
  

Proof state:
p : ℕ → Prop
inst✝ : DecidablePred p
m n : ℕ
hm : p m
hn : p n
heq : count p m = count p n
⊢ m = n

Next tactic:
by_contra! h : m ≠ n
theorem count_injective {m n : ℕ} (hm : p m) (hn : p n) (heq : count p m = count p n) : m = n := by
  by_contra! h : m ≠ n
  

Proof state:
p : ℕ → Prop
inst✝ : DecidablePred p
m n : ℕ
hm : p m
hn : p n
heq : count p m = count p n
h : m ≠ n
⊢ False

Next tactic:
wlog hmn : m < n
theorem count_injective {m n : ℕ} (hm : p m) (hn : p n) (heq : count p m = count p n) : m = n := by
  by_contra! h : m ≠ n
  wlog hmn : m < n
  · 

Proof state:
case inr
p : ℕ → Prop
inst✝ : DecidablePred p
m n : ℕ
hm : p m
hn : p n
heq : count p m = count p n
h : m ≠ n
this : ∀ {p : ℕ → Prop} [inst : DecidablePred p] {m n : ℕ}, p m → p n → count p m = count p n → m ≠ n → m < n → False
hmn : ¬m < n
⊢ False

Next tactic:
exact this hn hm heq.symm h.symm (h.lt_or_lt.resolve_left hmn)
theorem count_injective {m n : ℕ} (hm : p m) (hn : p n) (heq : count p m = count p n) : m = n := by
  by_contra! h : m ≠ n
  wlog hmn : m < n
  · exact this hn hm heq.symm h.symm (h.lt_or_lt.resolve_left hmn)
  · 

Proof state:
p✝ : ℕ → Prop
inst✝¹ : DecidablePred p✝
p : ℕ → Prop
inst✝ : DecidablePred p
m n : ℕ
hm : p m
hn : p n
heq : count p m = count p n
h : m ≠ n
hmn : m < n
⊢ False

Next tactic:
simpa [heq] using count_strict_mono hm hmn
theorem count_le_card (hp : (setOf p).Finite) (n : ℕ) : count p n ≤ hp.toFinset.card := by
  

Proof state:
p : ℕ → Prop
inst✝ : DecidablePred p
hp : Set.Finite (setOf p)
n : ℕ
⊢ count p n ≤ card (Set.Finite.toFinset hp)

Next tactic:
rw [count_eq_card_filter_range]
theorem count_le_card (hp : (setOf p).Finite) (n : ℕ) : count p n ≤ hp.toFinset.card := by
  rw [count_eq_card_filter_range]
  

Proof state:
p : ℕ → Prop
inst✝ : DecidablePred p
hp : Set.Finite (setOf p)
n : ℕ
⊢ card (filter p (range n)) ≤ card (Set.Finite.toFinset hp)

Next tactic:
exact Finset.card_mono fun x hx ↦ hp.mem_toFinset.2 (mem_filter.1 hx).2
theorem count_mono_left {n : ℕ} (hpq : ∀ k, p k → q k) : count p n ≤ count q n := by
  

Proof state:
p : ℕ → Prop
inst✝¹ : DecidablePred p
q : ℕ → Prop
inst✝ : DecidablePred q
n : ℕ
hpq : ∀ (k : ℕ), p k → q k
⊢ count p n ≤ count q n

Next tactic:
simp only [count_eq_card_filter_range]
theorem count_mono_left {n : ℕ} (hpq : ∀ k, p k → q k) : count p n ≤ count q n := by
  simp only [count_eq_card_filter_range]
  

Proof state:
p : ℕ → Prop
inst✝¹ : DecidablePred p
q : ℕ → Prop
inst✝ : DecidablePred q
n : ℕ
hpq : ∀ (k : ℕ), p k → q k
⊢ card (filter p (range n)) ≤ card (filter q (range n))

Next tactic:
exact card_le_of_subset ((range n).monotone_filter_right hpq)
protected theorem _root_.Eq.sameCycle (h : x = y) (f : Perm α) : f.SameCycle x y := by 

Proof state:
ι : Type u_1
α : Type u_2
β : Type u_3
f✝ g : Perm α
p : α → Prop
x y z : α
h : x = y
f : Perm α
⊢ SameCycle f x y

Next tactic:
rw [h]
@[symm]
theorem SameCycle.symm : SameCycle f x y → SameCycle f y x := fun ⟨i, hi⟩ =>
  ⟨-i, by 

Proof state:
ι : Type u_1
α : Type u_2
β : Type u_3
f g : Perm α
p : α → Prop
x y z : α
x✝ : SameCycle f x y
i : ℤ
hi : (f ^ i) x = y
⊢ (f ^ (-i)) y = x

Next tactic:
rw [zpow_neg, ← hi, inv_apply_self]
@[trans]
theorem SameCycle.trans : SameCycle f x y → SameCycle f y z → SameCycle f x z :=
  fun ⟨i, hi⟩ ⟨j, hj⟩ => ⟨j + i, by 

Proof state:
ι : Type u_1
α : Type u_2
β : Type u_3
f g : Perm α
p : α → Prop
x y z : α
x✝¹ : SameCycle f x y
x✝ : SameCycle f y z
i : ℤ
hi : (f ^ i) x = y
j : ℤ
hj : (f ^ j) y = z
⊢ (f ^ (j + i)) x = z

Next tactic:
rw [zpow_add, mul_apply, hi, hj]
@[simp]
theorem sameCycle_one : SameCycle 1 x y ↔ x = y := by 

Proof state:
ι : Type u_1
α : Type u_2
β : Type u_3
f g : Perm α
p : α → Prop
x y z : α
⊢ SameCycle 1 x y ↔ x = y

Next tactic:
simp [SameCycle]
@[simp]
theorem sameCycle_inv : SameCycle f⁻¹ x y ↔ SameCycle f x y :=
  (Equiv.neg _).exists_congr_left.trans <| by 

Proof state:
ι : Type u_1
α : Type u_2
β : Type u_3
f g : Perm α
p : α → Prop
x y z : α
⊢ (∃ b, (f⁻¹ ^ (Equiv.neg ℤ).symm b) x = y) ↔ SameCycle f x y

Next tactic:
simp [SameCycle]
@[simp]
theorem sameCycle_conj : SameCycle (g * f * g⁻¹) x y ↔ SameCycle f (g⁻¹ x) (g⁻¹ y) :=
  exists_congr fun i => by 

Proof state:
ι : Type u_1
α : Type u_2
β : Type u_3
f g : Perm α
p : α → Prop
x y z : α
i : ℤ
⊢ ((g * f * g⁻¹) ^ i) x = y ↔ (f ^ i) (g⁻¹ x) = g⁻¹ y

Next tactic:
simp [conj_zpow, eq_inv_iff_eq]
theorem SameCycle.conj : SameCycle f x y → SameCycle (g * f * g⁻¹) (g x) (g y) := by
  

Proof state:
ι : Type u_1
α : Type u_2
β : Type u_3
f g : Perm α
p : α → Prop
x y z : α
⊢ SameCycle f x y → SameCycle (g * f * g⁻¹) (g x) (g y)

Next tactic:
simp [sameCycle_conj]
theorem SameCycle.apply_eq_self_iff : SameCycle f x y → (f x = x ↔ f y = y) := fun ⟨i, hi⟩ => by
  

Proof state:
ι : Type u_1
α : Type u_2
β : Type u_3
f g : Perm α
p : α → Prop
x y z : α
x✝ : SameCycle f x y
i : ℤ
hi : (f ^ i) x = y
⊢ f x = x ↔ f y = y

Next tactic:
rw [← hi, ← mul_apply, ← zpow_one_add, add_comm, zpow_add_one, mul_apply,
    (f ^ i).injective.eq_iff]
@[simp]
theorem sameCycle_apply_left : SameCycle f (f x) y ↔ SameCycle f x y :=
  (Equiv.addRight 1).exists_congr_left.trans <| by
    

Proof state:
ι : Type u_1
α : Type u_2
β : Type u_3
f g : Perm α
p : α → Prop
x y z : α
⊢ (∃ b, (f ^ (Equiv.addRight 1).symm b) (f x) = y) ↔ SameCycle f x y

Next tactic:
simp [zpow_sub, SameCycle, Int.add_neg_one, Function.comp]
@[simp]
theorem sameCycle_apply_right : SameCycle f x (f y) ↔ SameCycle f x y := by
  

Proof state:
ι : Type u_1
α : Type u_2
β : Type u_3
f g : Perm α
p : α → Prop
x y z : α
⊢ SameCycle f x (f y) ↔ SameCycle f x y

Next tactic:
rw [sameCycle_comm, sameCycle_apply_left, sameCycle_comm]
@[simp]
theorem sameCycle_inv_apply_left : SameCycle f (f⁻¹ x) y ↔ SameCycle f x y := by
  

Proof state:
ι : Type u_1
α : Type u_2
β : Type u_3
f g : Perm α
p : α → Prop
x y z : α
⊢ SameCycle f (f⁻¹ x) y ↔ SameCycle f x y

Next tactic:
rw [← sameCycle_apply_left, apply_inv_self]
@[simp]
theorem sameCycle_inv_apply_right : SameCycle f x (f⁻¹ y) ↔ SameCycle f x y := by
  

Proof state:
ι : Type u_1
α : Type u_2
β : Type u_3
f g : Perm α
p : α → Prop
x y z : α
⊢ SameCycle f x (f⁻¹ y) ↔ SameCycle f x y

Next tactic:
rw [← sameCycle_apply_right, apply_inv_self]
@[simp]
theorem sameCycle_zpow_left {n : ℤ} : SameCycle f ((f ^ n) x) y ↔ SameCycle f x y :=
  (Equiv.addRight (n : ℤ)).exists_congr_left.trans <| by 

Proof state:
ι : Type u_1
α : Type u_2
β : Type u_3
f g : Perm α
p : α → Prop
x y z : α
n : ℤ
⊢ (∃ b, (f ^ (Equiv.addRight n).symm b) ((f ^ n) x) = y) ↔ SameCycle f x y

Next tactic:
simp [SameCycle, zpow_add]
@[simp]
theorem sameCycle_zpow_right {n : ℤ} : SameCycle f x ((f ^ n) y) ↔ SameCycle f x y := by
  

Proof state:
ι : Type u_1
α : Type u_2
β : Type u_3
f g : Perm α
p : α → Prop
x y z : α
n : ℤ
⊢ SameCycle f x ((f ^ n) y) ↔ SameCycle f x y

Next tactic:
rw [sameCycle_comm, sameCycle_zpow_left, sameCycle_comm]
@[simp]
theorem sameCycle_pow_left {n : ℕ} : SameCycle f ((f ^ n) x) y ↔ SameCycle f x y := by
  

Proof state:
ι : Type u_1
α : Type u_2
β : Type u_3
f g : Perm α
p : α → Prop
x y z : α
n : ℕ
⊢ SameCycle f ((f ^ n) x) y ↔ SameCycle f x y

Next tactic:
rw [← zpow_ofNat, sameCycle_zpow_left]
@[simp]
theorem sameCycle_pow_right {n : ℕ} : SameCycle f x ((f ^ n) y) ↔ SameCycle f x y := by
  

Proof state:
ι : Type u_1
α : Type u_2
β : Type u_3
f g : Perm α
p : α → Prop
x y z : α
n : ℕ
⊢ SameCycle f x ((f ^ n) y) ↔ SameCycle f x y

Next tactic:
rw [← zpow_ofNat, sameCycle_zpow_right]
theorem SameCycle.of_pow {n : ℕ} : SameCycle (f ^ n) x y → SameCycle f x y := fun ⟨m, h⟩ =>
  ⟨n * m, by 

Proof state:
ι : Type u_1
α : Type u_2
β : Type u_3
f g : Perm α
p : α → Prop
x y z : α
n : ℕ
x✝ : SameCycle (f ^ n) x y
m : ℤ
h : ((f ^ n) ^ m) x = y
⊢ (f ^ (↑n * m)) x = y

Next tactic:
simp [zpow_mul, h]
theorem SameCycle.of_zpow {n : ℤ} : SameCycle (f ^ n) x y → SameCycle f x y := fun ⟨m, h⟩ =>
  ⟨n * m, by 

Proof state:
ι : Type u_1
α : Type u_2
β : Type u_3
f g : Perm α
p : α → Prop
x y z : α
n : ℤ
x✝ : SameCycle (f ^ n) x y
m : ℤ
h : ((f ^ n) ^ m) x = y
⊢ (f ^ (n * m)) x = y

Next tactic:
simp [zpow_mul, h]
@[simp]
theorem sameCycle_subtypePerm {h} {x y : { x // p x }} :
    (f.subtypePerm h).SameCycle x y ↔ f.SameCycle x y :=
  exists_congr fun n => by 

Proof state:
ι : Type u_1
α : Type u_2
β : Type u_3
f g : Perm α
p : α → Prop
x✝ y✝ z : α
h : ∀ (x : α), p x ↔ p (f x)
x y : { x // p x }
n : ℤ
⊢ (subtypePerm f h ^ n) x = y ↔ (f ^ n) ↑x = ↑y

Next tactic:
simp [Subtype.ext_iff]
@[simp]
theorem sameCycle_extendDomain {p : β → Prop} [DecidablePred p] {f : α ≃ Subtype p} :
    SameCycle (g.extendDomain f) (f x) (f y) ↔ g.SameCycle x y :=
  exists_congr fun n => by
    

Proof state:
ι : Type u_1
α : Type u_2
β : Type u_3
f✝ g : Perm α
p✝ : α → Prop
x y z : α
p : β → Prop
inst✝ : DecidablePred p
f : α ≃ Subtype p
n : ℤ
⊢ (extendDomain g f ^ n) ↑(f x) = ↑(f y) ↔ (g ^ n) x = y

Next tactic:
rw [← extendDomain_zpow, extendDomain_apply_image, Subtype.coe_inj, f.injective.eq_iff]
theorem SameCycle.exists_pow_eq' [Finite α] : SameCycle f x y → ∃ i < orderOf f, (f ^ i) x = y := by
  

Proof state:
ι : Type u_1
α : Type u_2
β : Type u_3
f g : Perm α
p : α → Prop
x y z : α
inst✝ : Finite α
⊢ SameCycle f x y → ∃ i < orderOf f, (f ^ i) x = y

Next tactic:
classical
    rintro ⟨k, rfl⟩
    use (k % orderOf f).natAbs
    have h₀ := Int.coe_nat_pos.mpr (orderOf_pos f)
    have h₁ := Int.emod_nonneg k h₀.ne'
    rw [← zpow_ofNat, Int.natAbs_of_nonneg h₁, zpow_mod_orderOf]
    refine' ⟨_, by rfl⟩
    rw [← Int.ofNat_lt, Int.natAbs_of_nonneg h₁]
    exact Int.emod_lt_of_pos _ h₀
theorem SameCycle.exists_pow_eq' [Finite α] : SameCycle f x y → ∃ i < orderOf f, (f ^ i) x = y := by
  classical
    

Proof state:
ι : Type u_1
α : Type u_2
β : Type u_3
f g : Perm α
p : α → Prop
x y z : α
inst✝ : Finite α
⊢ SameCycle f x y → ∃ i < orderOf f, (f ^ i) x = y

Next tactic:
rintro ⟨k, rfl⟩
theorem SameCycle.exists_pow_eq' [Finite α] : SameCycle f x y → ∃ i < orderOf f, (f ^ i) x = y := by
  classical
    rintro ⟨k, rfl⟩
    

Proof state:
case intro
ι : Type u_1
α : Type u_2
β : Type u_3
f g : Perm α
p : α → Prop
x z : α
inst✝ : Finite α
k : ℤ
⊢ ∃ i < orderOf f, (f ^ i) x = (f ^ k) x

Next tactic:
use (k % orderOf f).natAbs
theorem SameCycle.exists_pow_eq' [Finite α] : SameCycle f x y → ∃ i < orderOf f, (f ^ i) x = y := by
  classical
    rintro ⟨k, rfl⟩
    use (k % orderOf f).natAbs
    

Proof state:
case h
ι : Type u_1
α : Type u_2
β : Type u_3
f g : Perm α
p : α → Prop
x z : α
inst✝ : Finite α
k : ℤ
⊢ Int.natAbs (k % ↑(orderOf f)) < orderOf f ∧ (f ^ Int.natAbs (k % ↑(orderOf f))) x = (f ^ k) x

Next tactic:
have h₀ := Int.coe_nat_pos.mpr (orderOf_pos f)
theorem SameCycle.exists_pow_eq' [Finite α] : SameCycle f x y → ∃ i < orderOf f, (f ^ i) x = y := by
  classical
    rintro ⟨k, rfl⟩
    use (k % orderOf f).natAbs
    have h₀ := Int.coe_nat_pos.mpr (orderOf_pos f)
    

Proof state:
case h
ι : Type u_1
α : Type u_2
β : Type u_3
f g : Perm α
p : α → Prop
x z : α
inst✝ : Finite α
k : ℤ
h₀ : 0 < ↑(orderOf f)
⊢ Int.natAbs (k % ↑(orderOf f)) < orderOf f ∧ (f ^ Int.natAbs (k % ↑(orderOf f))) x = (f ^ k) x

Next tactic:
have h₁ := Int.emod_nonneg k h₀.ne'
theorem SameCycle.exists_pow_eq' [Finite α] : SameCycle f x y → ∃ i < orderOf f, (f ^ i) x = y := by
  classical
    rintro ⟨k, rfl⟩
    use (k % orderOf f).natAbs
    have h₀ := Int.coe_nat_pos.mpr (orderOf_pos f)
    have h₁ := Int.emod_nonneg k h₀.ne'
    

Proof state:
case h
ι : Type u_1
α : Type u_2
β : Type u_3
f g : Perm α
p : α → Prop
x z : α
inst✝ : Finite α
k : ℤ
h₀ : 0 < ↑(orderOf f)
h₁ : 0 ≤ k % ↑(orderOf f)
⊢ Int.natAbs (k % ↑(orderOf f)) < orderOf f ∧ (f ^ Int.natAbs (k % ↑(orderOf f))) x = (f ^ k) x

Next tactic:
rw [← zpow_ofNat, Int.natAbs_of_nonneg h₁, zpow_mod_orderOf]
theorem SameCycle.exists_pow_eq' [Finite α] : SameCycle f x y → ∃ i < orderOf f, (f ^ i) x = y := by
  classical
    rintro ⟨k, rfl⟩
    use (k % orderOf f).natAbs
    have h₀ := Int.coe_nat_pos.mpr (orderOf_pos f)
    have h₁ := Int.emod_nonneg k h₀.ne'
    rw [← zpow_ofNat, Int.natAbs_of_nonneg h₁, zpow_mod_orderOf]
    

Proof state:
case h
ι : Type u_1
α : Type u_2
β : Type u_3
f g : Perm α
p : α → Prop
x z : α
inst✝ : Finite α
k : ℤ
h₀ : 0 < ↑(orderOf f)
h₁ : 0 ≤ k % ↑(orderOf f)
⊢ Int.natAbs (k % ↑(orderOf f)) < orderOf f ∧ (f ^ k) x = (f ^ k) x

Next tactic:
refine' ⟨_, by rfl⟩
theorem SameCycle.exists_pow_eq' [Finite α] : SameCycle f x y → ∃ i < orderOf f, (f ^ i) x = y := by
  classical
    rintro ⟨k, rfl⟩
    use (k % orderOf f).natAbs
    have h₀ := Int.coe_nat_pos.mpr (orderOf_pos f)
    have h₁ := Int.emod_nonneg k h₀.ne'
    rw [← zpow_ofNat, Int.natAbs_of_nonneg h₁, zpow_mod_orderOf]
    refine' ⟨_, by 

Proof state:
ι : Type u_1
α : Type u_2
β : Type u_3
f g : Perm α
p : α → Prop
x z : α
inst✝ : Finite α
k : ℤ
h₀ : 0 < ↑(orderOf f)
h₁ : 0 ≤ k % ↑(orderOf f)
⊢ (f ^ k) x = (f ^ k) x

Next tactic:
rfl
theorem SameCycle.exists_pow_eq' [Finite α] : SameCycle f x y → ∃ i < orderOf f, (f ^ i) x = y := by
  classical
    rintro ⟨k, rfl⟩
    use (k % orderOf f).natAbs
    have h₀ := Int.coe_nat_pos.mpr (orderOf_pos f)
    have h₁ := Int.emod_nonneg k h₀.ne'
    rw [← zpow_ofNat, Int.natAbs_of_nonneg h₁, zpow_mod_orderOf]
    refine' ⟨_, by rfl⟩
    

Proof state:
case h
ι : Type u_1
α : Type u_2
β : Type u_3
f g : Perm α
p : α → Prop
x z : α
inst✝ : Finite α
k : ℤ
h₀ : 0 < ↑(orderOf f)
h₁ : 0 ≤ k % ↑(orderOf f)
⊢ Int.natAbs (k % ↑(orderOf f)) < orderOf f

Next tactic:
rw [← Int.ofNat_lt, Int.natAbs_of_nonneg h₁]
theorem SameCycle.exists_pow_eq' [Finite α] : SameCycle f x y → ∃ i < orderOf f, (f ^ i) x = y := by
  classical
    rintro ⟨k, rfl⟩
    use (k % orderOf f).natAbs
    have h₀ := Int.coe_nat_pos.mpr (orderOf_pos f)
    have h₁ := Int.emod_nonneg k h₀.ne'
    rw [← zpow_ofNat, Int.natAbs_of_nonneg h₁, zpow_mod_orderOf]
    refine' ⟨_, by rfl⟩
    rw [← Int.ofNat_lt, Int.natAbs_of_nonneg h₁]
    

Proof state:
case h
ι : Type u_1
α : Type u_2
β : Type u_3
f g : Perm α
p : α → Prop
x z : α
inst✝ : Finite α
k : ℤ
h₀ : 0 < ↑(orderOf f)
h₁ : 0 ≤ k % ↑(orderOf f)
⊢ k % ↑(orderOf f) < ↑(orderOf f)

Next tactic:
exact Int.emod_lt_of_pos _ h₀
theorem SameCycle.exists_pow_eq'' [Finite α] (h : SameCycle f x y) :
    ∃ i : ℕ, 0 < i ∧ i ≤ orderOf f ∧ (f ^ i) x = y := by
  

Proof state:
ι : Type u_1
α : Type u_2
β : Type u_3
f g : Perm α
p : α → Prop
x y z : α
inst✝ : Finite α
h : SameCycle f x y
⊢ ∃ i, 0 < i ∧ i ≤ orderOf f ∧ (f ^ i) x = y

Next tactic:
classical
    obtain ⟨_ | i, hi, rfl⟩ := h.exists_pow_eq'
    · refine' ⟨orderOf f, orderOf_pos f, le_rfl, _⟩
      rw [pow_orderOf_eq_one, pow_zero]
    · exact ⟨i.succ, i.zero_lt_succ, hi.le, by rfl⟩
theorem SameCycle.exists_pow_eq'' [Finite α] (h : SameCycle f x y) :
    ∃ i : ℕ, 0 < i ∧ i ≤ orderOf f ∧ (f ^ i) x = y := by
  classical
    

Proof state:
ι : Type u_1
α : Type u_2
β : Type u_3
f g : Perm α
p : α → Prop
x y z : α
inst✝ : Finite α
h : SameCycle f x y
⊢ ∃ i, 0 < i ∧ i ≤ orderOf f ∧ (f ^ i) x = y

Next tactic:
obtain ⟨_ | i, hi, rfl⟩ := h.exists_pow_eq'
theorem SameCycle.exists_pow_eq'' [Finite α] (h : SameCycle f x y) :
    ∃ i : ℕ, 0 < i ∧ i ≤ orderOf f ∧ (f ^ i) x = y := by
  classical
    obtain ⟨_ | i, hi, rfl⟩ := h.exists_pow_eq'
    · 

Proof state:
case intro.zero.intro
ι : Type u_1
α : Type u_2
β : Type u_3
f g : Perm α
p : α → Prop
x z : α
inst✝ : Finite α
hi : Nat.zero < orderOf f
h : SameCycle f x ((f ^ Nat.zero) x)
⊢ ∃ i, 0 < i ∧ i ≤ orderOf f ∧ (f ^ i) x = (f ^ Nat.zero) x

Next tactic:
refine' ⟨orderOf f, orderOf_pos f, le_rfl, _⟩
theorem SameCycle.exists_pow_eq'' [Finite α] (h : SameCycle f x y) :
    ∃ i : ℕ, 0 < i ∧ i ≤ orderOf f ∧ (f ^ i) x = y := by
  classical
    obtain ⟨_ | i, hi, rfl⟩ := h.exists_pow_eq'
    · refine' ⟨orderOf f, orderOf_pos f, le_rfl, _⟩
      

Proof state:
case intro.zero.intro
ι : Type u_1
α : Type u_2
β : Type u_3
f g : Perm α
p : α → Prop
x z : α
inst✝ : Finite α
hi : Nat.zero < orderOf f
h : SameCycle f x ((f ^ Nat.zero) x)
⊢ (f ^ orderOf f) x = (f ^ Nat.zero) x

Next tactic:
rw [pow_orderOf_eq_one, pow_zero]
theorem SameCycle.exists_pow_eq'' [Finite α] (h : SameCycle f x y) :
    ∃ i : ℕ, 0 < i ∧ i ≤ orderOf f ∧ (f ^ i) x = y := by
  classical
    obtain ⟨_ | i, hi, rfl⟩ := h.exists_pow_eq'
    · refine' ⟨orderOf f, orderOf_pos f, le_rfl, _⟩
      rw [pow_orderOf_eq_one, pow_zero]
    · 

Proof state:
case intro.succ.intro
ι : Type u_1
α : Type u_2
β : Type u_3
f g : Perm α
p : α → Prop
x z : α
inst✝ : Finite α
i : ℕ
hi : Nat.succ i < orderOf f
h : SameCycle f x ((f ^ Nat.succ i) x)
⊢ ∃ i_1, 0 < i_1 ∧ i_1 ≤ orderOf f ∧ (f ^ i_1) x = (f ^ Nat.succ i) x

Next tactic:
exact ⟨i.succ, i.zero_lt_succ, hi.le, by rfl⟩
theorem SameCycle.exists_pow_eq'' [Finite α] (h : SameCycle f x y) :
    ∃ i : ℕ, 0 < i ∧ i ≤ orderOf f ∧ (f ^ i) x = y := by
  classical
    obtain ⟨_ | i, hi, rfl⟩ := h.exists_pow_eq'
    · refine' ⟨orderOf f, orderOf_pos f, le_rfl, _⟩
      rw [pow_orderOf_eq_one, pow_zero]
    · exact ⟨i.succ, i.zero_lt_succ, hi.le, by 

Proof state:
ι : Type u_1
α : Type u_2
β : Type u_3
f g : Perm α
p : α → Prop
x z : α
inst✝ : Finite α
i : ℕ
hi : Nat.succ i < orderOf f
h : SameCycle f x ((f ^ Nat.succ i) x)
⊢ (f ^ Nat.succ i) x = (f ^ Nat.succ i) x

Next tactic:
rfl
instance [Fintype α] [DecidableEq α] (f : Perm α) : DecidableRel (SameCycle f) := fun x y =>
  decidable_of_iff (∃ n ∈ List.range (Fintype.card (Perm α)), (f ^ n) x = y)
    ⟨fun ⟨n, _, hn⟩ => ⟨n, hn⟩, fun ⟨i, hi⟩ => ⟨(i % orderOf f).natAbs,
      List.mem_range.2 (Int.ofNat_lt.1 <| by
        

Proof state:
ι : Type u_1
α : Type u_2
β : Type u_3
f✝ g : Perm α
p : α → Prop
x✝¹ y✝ z : α
inst✝¹ : Fintype α
inst✝ : DecidableEq α
f : Perm α
x y : α
x✝ : SameCycle f x y
i : ℤ
hi : (f ^ i) x = y
⊢ ↑(Int.natAbs (i % ↑(orderOf f))) < ↑(Fintype.card (Perm α))

Next tactic:
rw [Int.natAbs_of_nonneg (Int.emod_nonneg _ <| Int.coe_nat_ne_zero.2 (orderOf_pos _).ne')]
instance [Fintype α] [DecidableEq α] (f : Perm α) : DecidableRel (SameCycle f) := fun x y =>
  decidable_of_iff (∃ n ∈ List.range (Fintype.card (Perm α)), (f ^ n) x = y)
    ⟨fun ⟨n, _, hn⟩ => ⟨n, hn⟩, fun ⟨i, hi⟩ => ⟨(i % orderOf f).natAbs,
      List.mem_range.2 (Int.ofNat_lt.1 <| by
        rw [Int.natAbs_of_nonneg (Int.emod_nonneg _ <| Int.coe_nat_ne_zero.2 (orderOf_pos _).ne')]
        · 

Proof state:
ι : Type u_1
α : Type u_2
β : Type u_3
f✝ g : Perm α
p : α → Prop
x✝¹ y✝ z : α
inst✝¹ : Fintype α
inst✝ : DecidableEq α
f : Perm α
x y : α
x✝ : SameCycle f x y
i : ℤ
hi : (f ^ i) x = y
⊢ i % ↑(orderOf f) < ↑(Fintype.card (Perm α))

Next tactic:
refine' (Int.emod_lt _ <| Int.coe_nat_ne_zero_iff_pos.2 <| orderOf_pos _).trans_le _
instance [Fintype α] [DecidableEq α] (f : Perm α) : DecidableRel (SameCycle f) := fun x y =>
  decidable_of_iff (∃ n ∈ List.range (Fintype.card (Perm α)), (f ^ n) x = y)
    ⟨fun ⟨n, _, hn⟩ => ⟨n, hn⟩, fun ⟨i, hi⟩ => ⟨(i % orderOf f).natAbs,
      List.mem_range.2 (Int.ofNat_lt.1 <| by
        rw [Int.natAbs_of_nonneg (Int.emod_nonneg _ <| Int.coe_nat_ne_zero.2 (orderOf_pos _).ne')]
        · refine' (Int.emod_lt _ <| Int.coe_nat_ne_zero_iff_pos.2 <| orderOf_pos _).trans_le _
          

Proof state:
ι : Type u_1
α : Type u_2
β : Type u_3
f✝ g : Perm α
p : α → Prop
x✝¹ y✝ z : α
inst✝¹ : Fintype α
inst✝ : DecidableEq α
f : Perm α
x y : α
x✝ : SameCycle f x y
i : ℤ
hi : (f ^ i) x = y
⊢ |↑(orderOf f)| ≤ ↑(Fintype.card (Perm α))

Next tactic:
simp [orderOf_le_card_univ]
instance [Fintype α] [DecidableEq α] (f : Perm α) : DecidableRel (SameCycle f) := fun x y =>
  decidable_of_iff (∃ n ∈ List.range (Fintype.card (Perm α)), (f ^ n) x = y)
    ⟨fun ⟨n, _, hn⟩ => ⟨n, hn⟩, fun ⟨i, hi⟩ => ⟨(i % orderOf f).natAbs,
      List.mem_range.2 (Int.ofNat_lt.1 <| by
        rw [Int.natAbs_of_nonneg (Int.emod_nonneg _ <| Int.coe_nat_ne_zero.2 (orderOf_pos _).ne')]
        · refine' (Int.emod_lt _ <| Int.coe_nat_ne_zero_iff_pos.2 <| orderOf_pos _).trans_le _
          simp [orderOf_le_card_univ]),
      by
        

Proof state:
ι : Type u_1
α : Type u_2
β : Type u_3
f✝ g : Perm α
p : α → Prop
x✝¹ y✝ z : α
inst✝¹ : Fintype α
inst✝ : DecidableEq α
f : Perm α
x y : α
x✝ : SameCycle f x y
i : ℤ
hi : (f ^ i) x = y
⊢ (f ^ Int.natAbs (i % ↑(orderOf f))) x = y

Next tactic:
rw [← zpow_ofNat, Int.natAbs_of_nonneg (Int.emod_nonneg _ <|
          Int.coe_nat_ne_zero_iff_pos.2 <| orderOf_pos _), zpow_mod_orderOf, hi]
theorem IsCycle.ne_one (h : IsCycle f) : f ≠ 1 := fun hf => by 

Proof state:
ι : Type u_1
α : Type u_2
β : Type u_3
f g : Perm α
x y : α
h : IsCycle f
hf : f = 1
⊢ False

Next tactic:
simp [hf, IsCycle] at h
protected theorem IsCycle.sameCycle (hf : IsCycle f) (hx : f x ≠ x) (hy : f y ≠ y) :
    SameCycle f x y :=
  let ⟨g, hg⟩ := hf
  let ⟨a, ha⟩ := hg.2 hx
  let ⟨b, hb⟩ := hg.2 hy
  ⟨b - a, by 

Proof state:
ι : Type u_1
α : Type u_2
β : Type u_3
f g✝ : Perm α
x y : α
hf : IsCycle f
hx : f x ≠ x
hy : f y ≠ y
g : α
hg : f g ≠ g ∧ ∀ ⦃y : α⦄, f y ≠ y → SameCycle f g y
a : ℤ
ha : (f ^ a) g = x
b : ℤ
hb : (f ^ b) g = y
⊢ (f ^ (b - a)) x = y

Next tactic:
rw [← ha, ← mul_apply, ← zpow_add, sub_add_cancel, hb]
theorem IsCycle.conj : IsCycle f → IsCycle (g * f * g⁻¹) := by
  

Proof state:
ι : Type u_1
α : Type u_2
β : Type u_3
f g : Perm α
x y : α
⊢ IsCycle f → IsCycle (g * f * g⁻¹)

Next tactic:
rintro ⟨x, hx, h⟩
theorem IsCycle.conj : IsCycle f → IsCycle (g * f * g⁻¹) := by
  rintro ⟨x, hx, h⟩
  

Proof state:
case intro.intro
ι : Type u_1
α : Type u_2
β : Type u_3
f g : Perm α
x✝ y x : α
hx : f x ≠ x
h : ∀ ⦃y : α⦄, f y ≠ y → SameCycle f x y
⊢ IsCycle (g * f * g⁻¹)

Next tactic:
refine' ⟨g x, by simp [coe_mul, inv_apply_self, hx], fun y hy => _⟩
theorem IsCycle.conj : IsCycle f → IsCycle (g * f * g⁻¹) := by
  rintro ⟨x, hx, h⟩
  refine' ⟨g x, by 

Proof state:
ι : Type u_1
α : Type u_2
β : Type u_3
f g : Perm α
x✝ y x : α
hx : f x ≠ x
h : ∀ ⦃y : α⦄, f y ≠ y → SameCycle f x y
⊢ (g * f * g⁻¹) (g x) ≠ g x

Next tactic:
simp [coe_mul, inv_apply_self, hx]
theorem IsCycle.conj : IsCycle f → IsCycle (g * f * g⁻¹) := by
  rintro ⟨x, hx, h⟩
  refine' ⟨g x, by simp [coe_mul, inv_apply_self, hx], fun y hy => _⟩
  

Proof state:
case intro.intro
ι : Type u_1
α : Type u_2
β : Type u_3
f g : Perm α
x✝ y✝ x : α
hx : f x ≠ x
h : ∀ ⦃y : α⦄, f y ≠ y → SameCycle f x y
y : α
hy : (g * f * g⁻¹) y ≠ y
⊢ SameCycle (g * f * g⁻¹) (g x) y

Next tactic:
rw [← apply_inv_self g y]