Skip to content

Commit 4f99ec0

Browse files
feat(GroupTheory/Perm/Cycle/Factors): Remove finiteness requirement from cycleOf. (#13145)
cycleOf can be defined using only a decidability condition, rather than the current finiteness condition (from which decidability can be inferred). This commit removes this dependency on finiteness. Co-authored-by: Wrenna Robson <wren.robson@gmail.com>
1 parent 7852921 commit 4f99ec0

File tree

2 files changed

+66
-37
lines changed

2 files changed

+66
-37
lines changed

Mathlib/GroupTheory/Perm/Cycle/Basic.lean

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,17 @@ theorem SameCycle.exists_pow_eq'' [Finite α] (h : SameCycle f x y) :
243243
· exact ⟨i.succ, i.zero_lt_succ, hi.le, by rfl⟩
244244
#align equiv.perm.same_cycle.exists_pow_eq'' Equiv.Perm.SameCycle.exists_pow_eq''
245245

246+
instance (f : Perm α) [DecidableRel (SameCycle f⁻¹)] :
247+
DecidableRel (SameCycle f) := fun x y =>
248+
decidable_of_iff (f⁻¹.SameCycle x y) (sameCycle_inv)
249+
250+
instance (f : Perm α) [DecidableRel (SameCycle f)] :
251+
DecidableRel (SameCycle f⁻¹) := fun x y =>
252+
decidable_of_iff (f.SameCycle x y) (sameCycle_inv).symm
253+
254+
instance (priority := 100) [DecidableEq α] : DecidableRel (SameCycle (1 : Perm α)) := fun x y =>
255+
decidable_of_iff (x = y) sameCycle_one.symm
256+
246257
instance [Fintype α] [DecidableEq α] (f : Perm α) : DecidableRel (SameCycle f) := fun x y =>
247258
decidable_of_iff (∃ n ∈ List.range (Fintype.card (Perm α)), (f ^ n) x = y)
248259
fun ⟨n, _, hn⟩ => ⟨n, hn⟩, fun ⟨i, hi⟩ => ⟨(i % orderOf f).natAbs,

Mathlib/GroupTheory/Perm/Cycle/Factors.lean

Lines changed: 55 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,14 @@ namespace Equiv.Perm
3838

3939
section CycleOf
4040

41-
variable [DecidableEq α] [Fintype α] {f g : Perm α} {x y : α}
41+
variable {f g : Perm α} {x y : α} [DecidableRel f.SameCycle] [DecidableRel g.SameCycle]
4242

4343
/-- `f.cycleOf x` is the cycle of the permutation `f` to which `x` belongs. -/
44-
def cycleOf (f : Perm α) (x : α) : Perm α :=
44+
def cycleOf (f : Perm α) [DecidableRel f.SameCycle] (x : α) : Perm α :=
4545
ofSubtype (subtypePerm f fun _ => sameCycle_apply_right.symm : Perm { y // SameCycle f x y })
4646
#align equiv.perm.cycle_of Equiv.Perm.cycleOf
4747

48-
theorem cycleOf_apply (f : Perm α) (x y : α) :
48+
theorem cycleOf_apply (f : Perm α) [DecidableRel f.SameCycle] (x y : α) :
4949
cycleOf f x y = if SameCycle f x y then f y else y := by
5050
dsimp only [cycleOf]
5151
split_ifs with h
@@ -55,14 +55,16 @@ theorem cycleOf_apply (f : Perm α) (x y : α) :
5555
exact h
5656
#align equiv.perm.cycle_of_apply Equiv.Perm.cycleOf_apply
5757

58-
theorem cycleOf_inv (f : Perm α) (x : α) : (cycleOf f x)⁻¹ = cycleOf f⁻¹ x :=
58+
theorem cycleOf_inv (f : Perm α) [DecidableRel f.SameCycle] (x : α) :
59+
(cycleOf f x)⁻¹ = cycleOf f⁻¹ x :=
5960
Equiv.ext fun y => by
6061
rw [inv_eq_iff_eq, cycleOf_apply, cycleOf_apply]
6162
split_ifs <;> simp_all [sameCycle_inv, sameCycle_inv_apply_right]
6263
#align equiv.perm.cycle_of_inv Equiv.Perm.cycleOf_inv
6364

6465
@[simp]
65-
theorem cycleOf_pow_apply_self (f : Perm α) (x : α) : ∀ n : ℕ, (cycleOf f x ^ n) x = (f ^ n) x := by
66+
theorem cycleOf_pow_apply_self (f : Perm α) [DecidableRel f.SameCycle] (x : α) :
67+
∀ n : ℕ, (cycleOf f x ^ n) x = (f ^ n) x := by
6668
intro n
6769
induction' n with n hn
6870
· rfl
@@ -71,7 +73,7 @@ theorem cycleOf_pow_apply_self (f : Perm α) (x : α) : ∀ n : ℕ, (cycleOf f
7173
#align equiv.perm.cycle_of_pow_apply_self Equiv.Perm.cycleOf_pow_apply_self
7274

7375
@[simp]
74-
theorem cycleOf_zpow_apply_self (f : Perm α) (x : α) :
76+
theorem cycleOf_zpow_apply_self (f : Perm α) [DecidableRel f.SameCycle] (x : α) :
7577
∀ n : ℤ, (cycleOf f x ^ n) x = (f ^ n) x := by
7678
intro z
7779
induction' z with z hz
@@ -96,26 +98,27 @@ theorem SameCycle.cycleOf_eq (h : SameCycle f x y) : cycleOf f x = cycleOf f y :
9698
#align equiv.perm.same_cycle.cycle_of_eq Equiv.Perm.SameCycle.cycleOf_eq
9799

98100
@[simp]
99-
theorem cycleOf_apply_apply_zpow_self (f : Perm α) (x : α) (k : ℤ) :
101+
theorem cycleOf_apply_apply_zpow_self (f : Perm α) [DecidableRel f.SameCycle] (x : α) (k : ℤ) :
100102
cycleOf f x ((f ^ k) x) = (f ^ (k + 1) : Perm α) x := by
101103
rw [SameCycle.cycleOf_apply]
102104
· rw [add_comm, zpow_add, zpow_one, mul_apply]
103105
· exact ⟨k, rfl⟩
104106
#align equiv.perm.cycle_of_apply_apply_zpow_self Equiv.Perm.cycleOf_apply_apply_zpow_self
105107

106108
@[simp]
107-
theorem cycleOf_apply_apply_pow_self (f : Perm α) (x : α) (k : ℕ) :
109+
theorem cycleOf_apply_apply_pow_self (f : Perm α) [DecidableRel f.SameCycle] (x : α) (k : ℕ) :
108110
cycleOf f x ((f ^ k) x) = (f ^ (k + 1) : Perm α) x := by
109111
convert cycleOf_apply_apply_zpow_self f x k using 1
110112
#align equiv.perm.cycle_of_apply_apply_pow_self Equiv.Perm.cycleOf_apply_apply_pow_self
111113

112114
@[simp]
113-
theorem cycleOf_apply_apply_self (f : Perm α) (x : α) : cycleOf f x (f x) = f (f x) := by
115+
theorem cycleOf_apply_apply_self (f : Perm α) [DecidableRel f.SameCycle] (x : α) :
116+
cycleOf f x (f x) = f (f x) := by
114117
convert cycleOf_apply_apply_pow_self f x 1 using 1
115118
#align equiv.perm.cycle_of_apply_apply_self Equiv.Perm.cycleOf_apply_apply_self
116119

117120
@[simp]
118-
theorem cycleOf_apply_self (f : Perm α) (x : α) : cycleOf f x x = f x :=
121+
theorem cycleOf_apply_self (f : Perm α) [DecidableRel f.SameCycle] (x : α) : cycleOf f x x = f x :=
119122
SameCycle.rfl.cycleOf_apply
120123
#align equiv.perm.cycle_of_apply_self Equiv.Perm.cycleOf_apply_self
121124

@@ -128,7 +131,7 @@ theorem IsCycle.cycleOf_eq (hf : IsCycle f) (hx : f x ≠ x) : cycleOf f x = f :
128131
#align equiv.perm.is_cycle.cycle_of_eq Equiv.Perm.IsCycle.cycleOf_eq
129132

130133
@[simp]
131-
theorem cycleOf_eq_one_iff (f : Perm α) : cycleOf f x = 1 ↔ f x = x := by
134+
theorem cycleOf_eq_one_iff (f : Perm α) [DecidableRel f.SameCycle] : cycleOf f x = 1 ↔ f x = x := by
132135
simp_rw [ext_iff, cycleOf_apply, one_apply]
133136
refine ⟨fun h => (if_pos (SameCycle.refl f x)).symm.trans (h x), fun h y => ?_⟩
134137
by_cases hy : f y = y
@@ -137,32 +140,36 @@ theorem cycleOf_eq_one_iff (f : Perm α) : cycleOf f x = 1 ↔ f x = x := by
137140
#align equiv.perm.cycle_of_eq_one_iff Equiv.Perm.cycleOf_eq_one_iff
138141

139142
@[simp]
140-
theorem cycleOf_self_apply (f : Perm α) (x : α) : cycleOf f (f x) = cycleOf f x :=
143+
theorem cycleOf_self_apply (f : Perm α) [DecidableRel f.SameCycle] (x : α) :
144+
cycleOf f (f x) = cycleOf f x :=
141145
(sameCycle_apply_right.2 SameCycle.rfl).symm.cycleOf_eq
142146
#align equiv.perm.cycle_of_self_apply Equiv.Perm.cycleOf_self_apply
143147

144148
@[simp]
145-
theorem cycleOf_self_apply_pow (f : Perm α) (n : ℕ) (x : α) : cycleOf f ((f ^ n) x) = cycleOf f x :=
149+
theorem cycleOf_self_apply_pow (f : Perm α) [DecidableRel f.SameCycle] (n : ℕ) (x : α) :
150+
cycleOf f ((f ^ n) x) = cycleOf f x :=
146151
SameCycle.rfl.pow_left.cycleOf_eq
147152
#align equiv.perm.cycle_of_self_apply_pow Equiv.Perm.cycleOf_self_apply_pow
148153

149154
@[simp]
150-
theorem cycleOf_self_apply_zpow (f : Perm α) (n : ℤ) (x : α) :
155+
theorem cycleOf_self_apply_zpow (f : Perm α) [DecidableRel f.SameCycle] (n : ℤ) (x : α) :
151156
cycleOf f ((f ^ n) x) = cycleOf f x :=
152157
SameCycle.rfl.zpow_left.cycleOf_eq
153158
#align equiv.perm.cycle_of_self_apply_zpow Equiv.Perm.cycleOf_self_apply_zpow
154159

155-
protected theorem IsCycle.cycleOf (hf : IsCycle f) : cycleOf f x = if f x = x then 1 else f := by
160+
protected theorem IsCycle.cycleOf [DecidableEq α] (hf : IsCycle f) :
161+
cycleOf f x = if f x = x then 1 else f := by
156162
by_cases hx : f x = x
157163
· rwa [if_pos hx, cycleOf_eq_one_iff]
158164
· rwa [if_neg hx, hf.cycleOf_eq]
159165
#align equiv.perm.is_cycle.cycle_of Equiv.Perm.IsCycle.cycleOf
160166

161-
theorem cycleOf_one (x : α) : cycleOf 1 x = 1 :=
162-
(cycleOf_eq_one_iff 1).mpr rfl
167+
theorem cycleOf_one [DecidableRel (1 : Perm α).SameCycle] (x : α) :
168+
cycleOf 1 x = 1 := (cycleOf_eq_one_iff 1).mpr rfl
163169
#align equiv.perm.cycle_of_one Equiv.Perm.cycleOf_one
164170

165-
theorem isCycle_cycleOf (f : Perm α) (hx : f x ≠ x) : IsCycle (cycleOf f x) :=
171+
theorem isCycle_cycleOf (f : Perm α) [DecidableRel f.SameCycle] (hx : f x ≠ x) :
172+
IsCycle (cycleOf f x) :=
166173
have : cycleOf f x x ≠ x := by rwa [SameCycle.rfl.cycleOf_apply]
167174
(isCycle_iff_sameCycle this).2 @fun y =>
168175
fun h => mt h.apply_eq_self_iff.2 this, fun h =>
@@ -175,29 +182,32 @@ theorem isCycle_cycleOf (f : Perm α) (hx : f x ≠ x) : IsCycle (cycleOf f x) :
175182
#align equiv.perm.is_cycle_cycle_of Equiv.Perm.isCycle_cycleOf
176183

177184
@[simp]
178-
theorem two_le_card_support_cycleOf_iff : 2 ≤ card (cycleOf f x).support ↔ f x ≠ x := by
185+
theorem two_le_card_support_cycleOf_iff [DecidableEq α] [Fintype α] :
186+
2 ≤ card (cycleOf f x).support ↔ f x ≠ x := by
179187
refine ⟨fun h => ?_, fun h => by simpa using (isCycle_cycleOf _ h).two_le_card_support⟩
180188
contrapose! h
181189
rw [← cycleOf_eq_one_iff] at h
182190
simp [h]
183191
#align equiv.perm.two_le_card_support_cycle_of_iff Equiv.Perm.two_le_card_support_cycleOf_iff
184192

185-
@[simp] lemma support_cycleOf_nonempty : (cycleOf f x).support.Nonempty ↔ f x ≠ x := by
193+
@[simp] lemma support_cycleOf_nonempty [DecidableEq α] [Fintype α] :
194+
(cycleOf f x).support.Nonempty ↔ f x ≠ x := by
186195
rw [← two_le_card_support_cycleOf_iff, ← card_pos, ← Nat.succ_le_iff]
187196
exact ⟨fun h => Or.resolve_left h.eq_or_lt (card_support_ne_one _).symm, zero_lt_two.trans_le⟩
188197
#align equiv.perm.card_support_cycle_of_pos_iff Equiv.Perm.support_cycleOf_nonempty
189198

190199
@[deprecated support_cycleOf_nonempty (since := "2024-06-16")]
191-
theorem card_support_cycleOf_pos_iff : 0 < card (cycleOf f x).support ↔ f x ≠ x := by
200+
theorem card_support_cycleOf_pos_iff [DecidableEq α] [Fintype α] :
201+
0 < card (cycleOf f x).support ↔ f x ≠ x := by
192202
rw [card_pos, support_cycleOf_nonempty]
193203

194-
theorem pow_mod_orderOf_cycleOf_apply (f : Perm α) (n : ℕ) (x : α) :
204+
theorem pow_mod_orderOf_cycleOf_apply (f : Perm α) [DecidableRel f.SameCycle] (n : ℕ) (x : α) :
195205
(f ^ (n % orderOf (cycleOf f x))) x = (f ^ n) x := by
196206
rw [← cycleOf_pow_apply_self f, ← cycleOf_pow_apply_self f, pow_mod_orderOf]
197207
#align equiv.perm.pow_apply_eq_pow_mod_order_of_cycle_of_apply Equiv.Perm.pow_mod_orderOf_cycleOf_apply
198208

199-
theorem cycleOf_mul_of_apply_right_eq_self (h : Commute f g) (x : α) (hx : g x = x) :
200-
(f * g).cycleOf x = f.cycleOf x := by
209+
theorem cycleOf_mul_of_apply_right_eq_self [DecidableRel (f * g).SameCycle]
210+
(h : Commute f g) (x : α) (hx : g x = x) : (f * g).cycleOf x = f.cycleOf x := by
201211
ext y
202212
by_cases hxy : (f * g).SameCycle x y
203213
· obtain ⟨z, rfl⟩ := hxy
@@ -210,25 +220,29 @@ theorem cycleOf_mul_of_apply_right_eq_self (h : Commute f g) (x : α) (hx : g x
210220
simp [h.mul_zpow, zpow_apply_eq_self_of_apply_eq_self hx]
211221
#align equiv.perm.cycle_of_mul_of_apply_right_eq_self Equiv.Perm.cycleOf_mul_of_apply_right_eq_self
212222

213-
theorem Disjoint.cycleOf_mul_distrib (h : f.Disjoint g) (x : α) :
223+
theorem Disjoint.cycleOf_mul_distrib [DecidableRel (f * g).SameCycle]
224+
[DecidableRel (g * f).SameCycle] (h : f.Disjoint g) (x : α) :
214225
(f * g).cycleOf x = f.cycleOf x * g.cycleOf x := by
215226
cases' (disjoint_iff_eq_or_eq.mp h) x with hfx hgx
216227
· simp [h.commute.eq, cycleOf_mul_of_apply_right_eq_self h.symm.commute, hfx]
217228
· simp [cycleOf_mul_of_apply_right_eq_self h.commute, hgx]
218229
#align equiv.perm.disjoint.cycle_of_mul_distrib Equiv.Perm.Disjoint.cycleOf_mul_distrib
219230

220-
theorem support_cycleOf_eq_nil_iff : (f.cycleOf x).support = ∅ ↔ x ∉ f.support := by simp
231+
theorem support_cycleOf_eq_nil_iff [DecidableEq α] [Fintype α] :
232+
(f.cycleOf x).support = ∅ ↔ x ∉ f.support := by simp
221233
#align equiv.perm.support_cycle_of_eq_nil_iff Equiv.Perm.support_cycleOf_eq_nil_iff
222234

223-
theorem support_cycleOf_le (f : Perm α) (x : α) : support (f.cycleOf x) ≤ support f := by
235+
theorem support_cycleOf_le [DecidableEq α] [Fintype α] (f : Perm α) (x : α) :
236+
support (f.cycleOf x) ≤ support f := by
224237
intro y hy
225238
rw [mem_support, cycleOf_apply] at hy
226239
split_ifs at hy
227240
· exact mem_support.mpr hy
228241
· exact absurd rfl hy
229242
#align equiv.perm.support_cycle_of_le Equiv.Perm.support_cycleOf_le
230243

231-
theorem mem_support_cycleOf_iff : y ∈ support (f.cycleOf x) ↔ SameCycle f x y ∧ x ∈ support f := by
244+
theorem mem_support_cycleOf_iff [DecidableEq α] [Fintype α] :
245+
y ∈ support (f.cycleOf x) ↔ SameCycle f x y ∧ x ∈ support f := by
232246
by_cases hx : f x = x
233247
· rw [(cycleOf_eq_one_iff _).mpr hx]
234248
simp [hx]
@@ -241,31 +255,35 @@ theorem mem_support_cycleOf_iff : y ∈ support (f.cycleOf x) ↔ SameCycle f x
241255
· simpa [hx] using hy
242256
#align equiv.perm.mem_support_cycle_of_iff Equiv.Perm.mem_support_cycleOf_iff
243257

244-
theorem mem_support_cycleOf_iff' (hx : f x ≠ x) : y ∈ support (f.cycleOf x) ↔ SameCycle f x y := by
258+
theorem mem_support_cycleOf_iff' (hx : f x ≠ x) [DecidableEq α] [Fintype α] :
259+
y ∈ support (f.cycleOf x) ↔ SameCycle f x y := by
245260
rw [mem_support_cycleOf_iff, and_iff_left (mem_support.2 hx)]
246261
#align equiv.perm.mem_support_cycle_of_iff' Equiv.Perm.mem_support_cycleOf_iff'
247262

248-
theorem SameCycle.mem_support_iff (h : SameCycle f x y) : x ∈ support f ↔ y ∈ support f :=
263+
theorem SameCycle.mem_support_iff {f} [DecidableEq α] [Fintype α] (h : SameCycle f x y) :
264+
x ∈ support f ↔ y ∈ support f :=
249265
fun hx => support_cycleOf_le f x (mem_support_cycleOf_iff.mpr ⟨h, hx⟩), fun hy =>
250266
support_cycleOf_le f y (mem_support_cycleOf_iff.mpr ⟨h.symm, hy⟩)⟩
251267
#align equiv.perm.same_cycle.mem_support_iff Equiv.Perm.SameCycle.mem_support_iff
252268

253-
theorem pow_mod_card_support_cycleOf_self_apply (f : Perm α) (n : ℕ) (x : α) :
254-
(f ^ (n % (f.cycleOf x).support.card)) x = (f ^ n) x := by
269+
theorem pow_mod_card_support_cycleOf_self_apply [DecidableEq α] [Fintype α]
270+
(f : Perm α) (n : ℕ) (x : α) : (f ^ (n % (f.cycleOf x).support.card)) x = (f ^ n) x := by
255271
by_cases hx : f x = x
256272
· rw [pow_apply_eq_self_of_apply_eq_self hx, pow_apply_eq_self_of_apply_eq_self hx]
257273
· rw [← cycleOf_pow_apply_self, ← cycleOf_pow_apply_self f, ← (isCycle_cycleOf f hx).orderOf,
258274
pow_mod_orderOf]
259275
#align equiv.perm.pow_mod_card_support_cycle_of_self_apply Equiv.Perm.pow_mod_card_support_cycleOf_self_apply
260276

261277
/-- `x` is in the support of `f` iff `Equiv.Perm.cycle_of f x` is a cycle. -/
262-
theorem isCycle_cycleOf_iff (f : Perm α) : IsCycle (cycleOf f x) ↔ f x ≠ x := by
278+
theorem isCycle_cycleOf_iff (f : Perm α) [DecidableRel f.SameCycle] :
279+
IsCycle (cycleOf f x) ↔ f x ≠ x := by
263280
refine ⟨fun hx => ?_, f.isCycle_cycleOf⟩
264281
rw [Ne, ← cycleOf_eq_one_iff f]
265282
exact hx.ne_one
266283
#align equiv.perm.is_cycle_cycle_of_iff Equiv.Perm.isCycle_cycleOf_iff
267284

268-
theorem isCycleOn_support_cycleOf (f : Perm α) (x : α) : f.IsCycleOn (f.cycleOf x).support :=
285+
theorem isCycleOn_support_cycleOf [DecidableEq α] [Fintype α] (f : Perm α) (x : α) :
286+
f.IsCycleOn (f.cycleOf x).support :=
269287
⟨f.bijOn <| by
270288
refine fun _ ↦ ⟨fun h ↦ mem_support_cycleOf_iff.2 ?_, fun h ↦ mem_support_cycleOf_iff.2 ?_⟩
271289
· exact ⟨sameCycle_apply_right.1 (mem_support_cycleOf_iff.1 h).1,
@@ -278,14 +296,14 @@ theorem isCycleOn_support_cycleOf (f : Perm α) (x : α) : f.IsCycleOn (f.cycleO
278296
exact ha.1.symm.trans hb.1
279297
#align equiv.perm.is_cycle_on_support_cycle_of Equiv.Perm.isCycleOn_support_cycleOf
280298

281-
theorem SameCycle.exists_pow_eq_of_mem_support (h : SameCycle f x y) (hx : x ∈ f.support) :
282-
∃ i < (f.cycleOf x).support.card, (f ^ i) x = y := by
299+
theorem SameCycle.exists_pow_eq_of_mem_support {f} [DecidableEq α] [Fintype α] (h : SameCycle f x y)
300+
(hx : x ∈ f.support) : ∃ i < (f.cycleOf x).support.card, (f ^ i) x = y := by
283301
rw [mem_support] at hx
284302
exact Equiv.Perm.IsCycleOn.exists_pow_eq (b := y) (f.isCycleOn_support_cycleOf x)
285303
(by rw [mem_support_cycleOf_iff' hx]) (by rwa [mem_support_cycleOf_iff' hx])
286304
#align equiv.perm.same_cycle.exists_pow_eq_of_mem_support Equiv.Perm.SameCycle.exists_pow_eq_of_mem_support
287305

288-
theorem SameCycle.exists_pow_eq (f : Perm α) (h : SameCycle f x y) :
306+
theorem SameCycle.exists_pow_eq [DecidableEq α] [Fintype α] (f : Perm α) (h : SameCycle f x y) :
289307
∃ i : ℕ, 0 < i ∧ i ≤ (f.cycleOf x).support.card + 1 ∧ (f ^ i) x = y := by
290308
by_cases hx : x ∈ f.support
291309
· obtain ⟨k, hk, hk'⟩ := h.exists_pow_eq_of_mem_support hx

0 commit comments

Comments
 (0)