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

Commit 3a58b50

Browse files
urkudChrisHughes24
authored andcommitted
feat(data/equiv/basic): add more functions for equivalences between complex types (#1384)
* Add more `equiv` combinators * Fix compile * Minor fixes * Update src/data/equiv/basic.lean Co-Authored-By: Chris Hughes <33847686+ChrisHughes24@users.noreply.github.com>
1 parent a199f85 commit 3a58b50

File tree

5 files changed

+62
-23
lines changed

5 files changed

+62
-23
lines changed

src/data/equiv/basic.lean

Lines changed: 58 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -404,9 +404,9 @@ def sum_equiv_sigma_bool (α β : Sort*) : α ⊕ β ≃ (Σ b: bool, cond b α
404404
λ s, by cases s; refl,
405405
λ s, by rcases s with ⟨_|_, _⟩; refl⟩
406406

407-
def equiv_fib {α β : Type*} (f : α → β) :
408-
α ≃ Σ y : β, {x // f x = y} :=
409-
⟨λ x, ⟨f x, x, rfl⟩, λ x, x.2.1, λ x, rfl, λ ⟨y, x, rfl⟩, rfl⟩
407+
def sigma_preimage_equiv {α β : Type*} (f : α → β) :
408+
(Σ y : β, {x // f x = y}) ≃ α :=
409+
⟨λ x, x.2.1, λ x, ⟨f x, x, rfl, λ ⟨y, x, rfl⟩, rfl, λ x, rfl⟩
410410

411411
end
412412

@@ -563,26 +563,68 @@ subtype_congr (equiv.refl α) (assume a, h ▸ iff.refl _)
563563
def set_congr {α : Type*} {s t : set α} (h : s = t) : s ≃ t :=
564564
subtype_congr_prop h
565565

566-
def subtype_subtype_equiv_subtype {α : Type u} (p : α → Prop) (q : subtype p → Prop) :
566+
def subtype_subtype_equiv_subtype_exists {α : Type u} (p : α → Prop) (q : subtype p → Prop) :
567567
subtype q ≃ {a : α // ∃h:p a, q ⟨a, h⟩ } :=
568568
⟨λ⟨⟨a, ha⟩, ha'⟩, ⟨a, ha, ha'⟩,
569569
λ⟨a, ha⟩, ⟨⟨a, ha.cases_on $ assume h _, h⟩, by { cases ha, exact ha_h }⟩,
570570
assume ⟨⟨a, ha⟩, h⟩, rfl, assume ⟨a, h₁, h₂⟩, rfl⟩
571571

572-
/- A subtype of a sigma-type is a sigma-type over a subtype. -/
572+
def subtype_subtype_equiv_subtype_inter {α : Type u} (p q : α → Prop) :
573+
{x : subtype p // q x.1} ≃ subtype (λ x, p x ∧ q x) :=
574+
(subtype_subtype_equiv_subtype_exists p _).trans $
575+
subtype_congr_right $ λ x, exists_prop
576+
577+
/-- If the outer subtype has more restrictive predicate than the inner one,
578+
then we can drop the latter. -/
579+
def subtype_subtype_equiv_subtype {α : Type u} {p q : α → Prop} (h : ∀ {x}, q x → p x) :
580+
{x : subtype p // q x.1} ≃ subtype q :=
581+
(subtype_subtype_equiv_subtype_inter p _).trans $
582+
subtype_congr_right $
583+
assume x,
584+
⟨and.right, λ h₁, ⟨h h₁, h₁⟩⟩
585+
586+
/-- If a proposition holds for all elements, then the subtype is
587+
equivalent to the original type. -/
588+
def subtype_univ_equiv {α : Type u} {p : α → Prop} (h : ∀ x, p x) :
589+
subtype p ≃ α :=
590+
⟨λ x, x, λ x, ⟨x, h x⟩, λ x, subtype.eq rfl, λ x, rfl⟩
591+
592+
/-- A subtype of a sigma-type is a sigma-type over a subtype. -/
573593
def subtype_sigma_equiv {α : Type u} (p : α → Type v) (q : α → Prop) :
574594
{ y : sigma p // q y.1 } ≃ Σ(x : subtype q), p x.1 :=
575-
begin
576-
fsplit,
577-
rintro ⟨⟨x, y⟩, z⟩, exact ⟨⟨x, z⟩, y⟩,
578-
rintro ⟨⟨x, y⟩, z⟩, exact ⟨⟨x, z⟩, y⟩,
579-
rintro ⟨⟨x, y⟩, z⟩, refl,
580-
rintro ⟨⟨x, y⟩, z⟩, refl,
581-
end
595+
⟨λ x, ⟨⟨x.1.1, x.2⟩, x.1.2⟩,
596+
λ x, ⟨⟨x.1.1, x.2⟩, x.1.2⟩,
597+
λ ⟨⟨x, h⟩, y⟩, rfl,
598+
λ ⟨⟨x, y⟩, h⟩, rfl⟩
599+
600+
/-- A sigma type over a subtype is equivalent to the sigma set over the original type,
601+
if the fiber is empty outside of the subset -/
602+
def sigma_subtype_equiv_of_subset {α : Type u} (p : α → Type v) (q : α → Prop)
603+
(h : ∀ x, p x → q x) :
604+
(Σ x : subtype q, p x) ≃ Σ x : α, p x :=
605+
(subtype_sigma_equiv p q).symm.trans $ subtype_univ_equiv $ λ x, h x.1 x.2
606+
607+
def sigma_subtype_preimage_equiv {α : Type u} {β : Type v} (f : α → β) (p : β → Prop)
608+
(h : ∀ x, p (f x)) :
609+
(Σ y : subtype p, {x : α // f x = y}) ≃ α :=
610+
calc _ ≃ Σ y : β, {x : α // f x = y} : sigma_subtype_equiv_of_subset _ p (λ y ⟨x, h'⟩, h' ▸ h x)
611+
... ≃ α : sigma_preimage_equiv f
612+
613+
def sigma_subtype_preimage_equiv_subtype {α : Type u} {β : Type v} (f : α → β)
614+
{p : α → Prop} {q : β → Prop} (h : ∀ x, p x ↔ q (f x)) :
615+
(Σ y : subtype q, {x : α // f x = y}) ≃ subtype p :=
616+
calc (Σ y : subtype q, {x : α // f x = y}) ≃
617+
Σ y : subtype q, {x : subtype p // subtype.mk (f x) ((h x).1 x.2) = y} :
618+
begin
619+
apply sigma_congr_right,
620+
assume y,
621+
symmetry,
622+
refine (subtype_subtype_equiv_subtype_exists _ _).trans (subtype_congr_right _),
623+
assume x,
624+
exact ⟨λ ⟨hp, h'⟩, congr_arg subtype.val h', λ h', ⟨(h x).2 (h'.symm ▸ y.2), subtype.eq h'⟩⟩
625+
end
582626

583-
/-- aka coimage -/
584-
def equiv_sigma_subtype {α : Type u} {β : Type v} (f : α → β) : α ≃ Σ b, {x : α // f x = b} :=
585-
⟨λ x, ⟨f x, x, rfl⟩, λ x, x.2.1, λ x, rfl, λ ⟨b, x, H⟩, sigma.eq H $ eq.drec_on H $ subtype.eq rfl⟩
627+
... ≃ subtype p : sigma_preimage_equiv (λ x : subtype p, (⟨f x, (h x).1 x.property⟩ : subtype q))
586628

587629
def pi_equiv_subtype_sigma (ι : Type*) (π : ι → Type*) :
588630
(Πi, π i) ≃ {f : ι → Σi, π i | ∀i, (f i).1 = i } :=
@@ -757,10 +799,7 @@ protected def congr {α β : Type*} (e : α ≃ β) : set α ≃ set β :=
757799

758800
protected def sep {α : Type u} (s : set α) (t : α → Prop) :
759801
({ x ∈ s | t x } : set α) ≃ { x : s | t x.1 } :=
760-
begin
761-
symmetry, apply (equiv.subtype_subtype_equiv_subtype _ _).trans _,
762-
simp only [mem_set_of_eq, exists_prop], refl
763-
end
802+
(equiv.subtype_subtype_equiv_subtype_inter s t).symm
764803

765804
end set
766805

src/group_theory/coset.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ def left_coset_equiv_subgroup (g : α) : left_coset g s ≃ s :=
207207
noncomputable def group_equiv_quotient_times_subgroup (hs : is_subgroup s) :
208208
α ≃ quotient s × s :=
209209
calc α ≃ Σ L : quotient s, {x : α // (x : quotient s)= L} :
210-
equiv.equiv_fib quotient_group.mk
210+
(equiv.sigma_preimage_equiv quotient_group.mk).symm
211211
... ≃ Σ L : quotient s, left_coset (quotient.out' L) s :
212212
equiv.sigma_congr_right (λ L,
213213
begin rw ← eq_class_eq_left_coset,

src/group_theory/sylow.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ end
3131
lemma card_modeq_card_fixed_points [fintype α] [fintype G] [fintype (fixed_points G α)]
3232
{p n : ℕ} (hp : nat.prime p) (h : card G = p ^ n) : card α ≡ card (fixed_points G α) [MOD p] :=
3333
calc card α = card (Σ y : quotient (orbit_rel G α), {x // quotient.mk' x = y}) :
34-
card_congr (equiv_fib (@quotient.mk' _ (orbit_rel G α)))
34+
card_congr (sigma_preimage_equiv (@quotient.mk' _ (orbit_rel G α))).symm
3535
... = univ.sum (λ a : quotient (orbit_rel G α), card {x // quotient.mk' x = a}) : card_sigma _
3636
... ≡ (@univ (fixed_points G α) _).sum (λ _, 1) [MOD p] :
3737
begin

src/set_theory/cardinal.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -778,7 +778,7 @@ quotient.sound ⟨equiv.option_equiv_sum_punit α⟩
778778

779779
theorem mk_list_eq_sum_pow (α : Type u) : mk (list α) = sum (λ n : ℕ, (mk α)^(n:cardinal.{u})) :=
780780
calc mk (list α)
781-
= mk (Σ n, vector α n) : quotient.sound ⟨equiv.equiv_sigma_subtype list.length⟩
781+
= mk (Σ n, vector α n) : quotient.sound ⟨(equiv.sigma_preimage_equiv list.length).symm
782782
... = mk (Σ n, fin n → α) : quotient.sound ⟨equiv.sigma_congr_right $ λ n,
783783
⟨vector.nth, vector.of_fn, vector.of_fn_nth, λ f, funext $ vector.nth_of_fn f⟩⟩
784784
... = mk (Σ n : ℕ, ulift.{u} (fin n) → α) : quotient.sound ⟨equiv.sigma_congr_right $ λ n,

src/set_theory/cofinality.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ begin
400400
refine ⟨a, {x | ∃(h : x ∈ s), f ⟨x, h⟩ = a}, _, _, _⟩,
401401
{ rintro x ⟨hx, hx'⟩, exact hx },
402402
{ refine le_trans ha _, apply ge_of_eq, apply quotient.sound, constructor,
403-
refine equiv.trans _ (equiv.subtype_subtype_equiv_subtype _ _).symm,
403+
refine equiv.trans _ (equiv.subtype_subtype_equiv_subtype_exists _ _).symm,
404404
simp only [set_coe_eq_subtype, mem_singleton_iff, mem_preimage, mem_set_of_eq] },
405405
rintro x ⟨hx, hx'⟩, exact hx'
406406
end

0 commit comments

Comments
 (0)