Skip to content
This repository was archived by the owner on Jul 24, 2024. It is now read-only.

Commit b454dae

Browse files
committed
feat(group_theory/perm): swap_mul_swal / swap_swap_apply (by @kckennylau)
1 parent 530e1d1 commit b454dae

File tree

2 files changed

+35
-13
lines changed

2 files changed

+35
-13
lines changed

data/nat/basic.lean

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ succ_le_succ_iff
2424
lemma succ_le_iff {m n : ℕ} : succ m ≤ n ↔ m < n :=
2525
⟨lt_of_succ_le, succ_le_of_lt⟩
2626

27+
theorem pred_eq_of_eq_succ {m n : ℕ} (H : m = n.succ) : m.pred = n := by simp [H]
28+
2729
theorem pred_sub (n m : ℕ) : pred n - m = pred (n - m) :=
2830
by rw [← sub_one, nat.sub_sub, one_add]; refl
2931

group_theory/perm.lean

Lines changed: 33 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,12 @@ end
103103
lemma mul_swap_eq_swap_mul (f : perm α) (x y : α) : f * swap x y = swap (f x) (f y) * f :=
104104
by rw [swap_mul_eq_mul_swap, inv_apply_self, inv_apply_self]
105105

106+
@[simp] lemma swap_mul_self (i j : α) : equiv.swap i j * equiv.swap i j = 1 :=
107+
equiv.swap_swap i j
108+
109+
@[simp] lemma swap_swap_apply (i j k : α) : equiv.swap i j (equiv.swap i j k) = k :=
110+
equiv.swap_core_swap_core k i j
111+
106112
lemma is_swap_of_subtype {p : α → Prop} [decidable_pred p]
107113
{f : perm (subtype p)} (h : is_swap f) : is_swap (of_subtype f) :=
108114
let ⟨⟨x, hx⟩, ⟨y, hy⟩, hxy⟩ := h in
@@ -362,22 +368,34 @@ def sign [fintype α] (f : perm α) := sign_aux3 f mem_univ
362368
instance sign.is_group_hom [fintype α] : is_group_hom (@sign α _ _) :=
363369
⟨λ f g, (sign_aux3_mul_and_swap f g _ mem_univ).1
364370

365-
@[simp] lemma sign_mul [fintype α] (f g : perm α) : sign (f * g) = sign f * sign g :=
371+
section sign
372+
373+
variable [fintype α]
374+
375+
@[simp] lemma sign_mul (f g : perm α) : sign (f * g) = sign f * sign g :=
366376
is_group_hom.mul sign _ _
367377

368-
@[simp] lemma sign_one [fintype α] : (sign (1 : perm α)) = 1 :=
378+
@[simp] lemma sign_one : (sign (1 : perm α)) = 1 :=
369379
is_group_hom.one sign
370380

371-
@[simp] lemma sign_inv [fintype α] (f : perm α) : sign f⁻¹ = sign f :=
381+
@[simp] lemma sign_refl : sign (equiv.refl α) = 1 :=
382+
is_group_hom.one sign
383+
384+
@[simp] lemma sign_inv (f : perm α) : sign f⁻¹ = sign f :=
372385
by rw [is_group_hom.inv sign, int.units_inv_eq_self]; apply_instance
373386

374-
lemma sign_swap [fintype α] {x y : α} (h : x ≠ y) : sign (swap x y) = -1 :=
387+
lemma sign_swap {x y : α} (h : x ≠ y) : sign (swap x y) = -1 :=
375388
(sign_aux3_mul_and_swap 1 1 _ mem_univ).2 x y h
376389

377-
lemma sign_eq_of_is_swap [fintype α] {f : perm α} (h : is_swap f) : sign f = -1 :=
390+
@[simp] lemma sign_swap' {x y : α} :
391+
(swap x y).sign = if x = y then 1 else -1 :=
392+
if H : x = y then by simp [H, swap_self] else
393+
by simp [sign_swap H, H]
394+
395+
lemma sign_eq_of_is_swap {f : perm α} (h : is_swap f) : sign f = -1 :=
378396
let ⟨x, y, hxy⟩ := h in hxy.2.symm ▸ sign_swap hxy.1
379397

380-
lemma sign_aux3_symm_trans_trans [fintype α] [decidable_eq β] [fintype β] (f : perm α)
398+
lemma sign_aux3_symm_trans_trans [decidable_eq β] [fintype β] (f : perm α)
381399
(e : α ≃ β) {s : multiset α} {t : multiset β} (hs : ∀ x, x ∈ s) (ht : ∀ x, x ∈ t) :
382400
sign_aux3 ((e.symm.trans f).trans e) ht = sign_aux3 f hs :=
383401
quotient.induction_on₂ t s
@@ -388,19 +406,19 @@ quotient.induction_on₂ t s
388406
exact congr_arg sign_aux (equiv.ext _ _ (λ x, by simp)))
389407
ht hs
390408

391-
lemma sign_symm_trans_trans [fintype α] [decidable_eq β] [fintype β] (f : perm α)
409+
lemma sign_symm_trans_trans [decidable_eq β] [fintype β] (f : perm α)
392410
(e : α ≃ β) : sign ((e.symm.trans f).trans e) = sign f :=
393411
sign_aux3_symm_trans_trans f e mem_univ mem_univ
394412

395-
lemma sign_prod_list_swap [fintype α] {l : list (perm α)}
413+
lemma sign_prod_list_swap {l : list (perm α)}
396414
(hl : ∀ g ∈ l, is_swap g) : sign l.prod = -1 ^ l.length :=
397415
have h₁ : l.map sign = list.repeat (-1) l.length :=
398416
list.eq_repeat.2by simp, λ u hu,
399417
let ⟨g, hg⟩ := list.mem_map.1 hu in
400418
hg.2 ▸ sign_eq_of_is_swap (hl _ hg.1)⟩,
401419
by rw [← list.prod_repeat, ← h₁, ← is_group_hom.prod (@sign α _ _)]
402420

403-
lemma eq_sign_of_surjective_hom [fintype α] {s : perm α → units ℤ}
421+
lemma eq_sign_of_surjective_hom {s : perm α → units ℤ}
404422
[is_group_hom s] (hs : surjective s) : s = sign :=
405423
have ∀ {f}, is_swap f → s f = -1 :=
406424
λ f ⟨x, y, hxy, hxy'⟩, hxy'.symm ▸ by_contradiction (λ h,
@@ -422,7 +440,7 @@ have hsl : ∀ a ∈ l.map s, a = (-1 : units ℤ) := λ a ha,
422440
by rw [← hl₁, is_group_hom.prod s, list.eq_repeat'.2 hsl, list.length_map,
423441
list.prod_repeat, sign_prod_list_swap hl₂]
424442

425-
lemma sign_subtype_perm [fintype α] (f : perm α) {p : α → Prop} [decidable_pred p]
443+
lemma sign_subtype_perm (f : perm α) {p : α → Prop} [decidable_pred p]
426444
(h₁ : ∀ x, p x ↔ p (f x)) (h₂ : ∀ x, f x ≠ x → p x) : sign (subtype_perm f h₁) = sign f :=
427445
let l := trunc.out (trunc_swap_factors (subtype_perm f h₁)) in
428446
have hl' : ∀ g' ∈ l.1.map of_subtype, is_swap g' :=
@@ -434,17 +452,17 @@ have hl'₂ : (l.1.map of_subtype).prod = f,
434452
by conv {congr, rw ← l.2.1, skip, rw ← hl'₂};
435453
rw [sign_prod_list_swap l.2.2, sign_prod_list_swap hl', list.length_map]
436454

437-
@[simp] lemma sign_of_subtype [fintype α] {p : α → Prop} [decidable_pred p]
455+
@[simp] lemma sign_of_subtype {p : α → Prop} [decidable_pred p]
438456
(f : perm (subtype p)) : sign (of_subtype f) = sign f :=
439457
have ∀ x, of_subtype f x ≠ x → p x, from λ x, not_imp_comm.1 (of_subtype_apply_of_not_mem f),
440458
by conv {to_rhs, rw [← subtype_perm_of_subtype f, sign_subtype_perm _ _ this]}
441459

442-
lemma sign_eq_sign_of_equiv [fintype α] [decidable_eq β] [fintype β] (f : perm α) (g : perm β)
460+
lemma sign_eq_sign_of_equiv [decidable_eq β] [fintype β] (f : perm α) (g : perm β)
443461
(e : α ≃ β) (h : ∀ x, e (f x) = g (e x)) : sign f = sign g :=
444462
have hg : g = (e.symm.trans f).trans e, from equiv.ext _ _ $ by simp [h],
445463
by rw [hg, sign_symm_trans_trans]
446464

447-
lemma sign_bij [fintype α] [decidable_eq β] [fintype β]
465+
lemma sign_bij [decidable_eq β] [fintype β]
448466
{f : perm α} {g : perm β} (i : Π x : α, f x ≠ x → β)
449467
(h : ∀ x hx hx', i (f x) hx' = g (i x hx))
450468
(hi : ∀ x₁ x₂ hx₁ hx₂, i x₁ hx₁ = i x₂ hx₂ → x₁ = x₂)
@@ -463,6 +481,8 @@ calc sign f = sign (@subtype_perm _ f (λ x, f x ≠ x) (by simp)) :
463481
(λ ⟨x, _⟩, subtype.eq (h x _ _))
464482
... = sign g : sign_subtype_perm _ _ (λ _, id)
465483

484+
end sign
485+
466486
lemma is_cycle_swap {x y : α} (hxy : x ≠ y) : is_cycle (swap x y) :=
467487
⟨y, by rwa swap_apply_right,
468488
λ a (ha : ite (a = x) y (ite (a = y) x a) ≠ a),

0 commit comments

Comments
 (0)