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

Commit f10d0ab

Browse files
committed
feat(*): add lemmas about sigma types (#15085)
* move `set.range_sigma_mk` to `data.set.sigma`; * add `set.preimage_image_sigma_mk_of_ne`, `set.image_sigma_mk_preimage_sigma_map_subset`, and `set.image_sigma_mk_preimage_sigma_map`; * add `function.injective.of_sigma_map` and `function.injective.sigma_map_iff`; * don't use pattern matching in the definition of `prod.to_sigma`; * add `filter.map_sigma_mk_comap`
1 parent 527afb3 commit f10d0ab

File tree

4 files changed

+56
-28
lines changed

4 files changed

+56
-28
lines changed

src/data/set/basic.lean

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1993,15 +1993,6 @@ by simp [range_subset_iff, funext_iff, mem_singleton]
19931993
lemma image_compl_preimage {f : α → β} {s : set β} : f '' ((f ⁻¹' s)ᶜ) = range f \ s :=
19941994
by rw [compl_eq_univ_diff, image_diff_preimage, image_univ]
19951995

1996-
@[simp] theorem range_sigma_mk {β : α → Type*} (a : α) :
1997-
range (sigma.mk a : β a → Σ a, β a) = sigma.fst ⁻¹' {a} :=
1998-
begin
1999-
apply subset.antisymm,
2000-
{ rintros _ ⟨b, rfl⟩, simp },
2001-
{ rintros ⟨x, y⟩ (rfl|_),
2002-
exact mem_range_self y }
2003-
end
2004-
20051996
/-- Any map `f : ι → β` factors through a map `range_factorization f : ι → range f`. -/
20061997
def range_factorization (f : ι → β) : ι → range f :=
20071998
λ i, ⟨f i, mem_range_self i⟩

src/data/set/sigma.lean

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,36 @@ This file defines `set.sigma`, the indexed sum of sets.
1313

1414
namespace set
1515
variables {ι ι' : Type*} {α β : ι → Type*} {s s₁ s₂ : set ι} {t t₁ t₂ : Π i, set (α i)}
16-
{u : set (Σ i, α i)} {x : Σ i, α i} {i : ι} {a : α i}
16+
{u : set (Σ i, α i)} {x : Σ i, α i} {i j : ι} {a : α i}
17+
18+
@[simp] theorem range_sigma_mk (i : ι) :
19+
range (sigma.mk i : α i → sigma α) = sigma.fst ⁻¹' {i} :=
20+
begin
21+
apply subset.antisymm,
22+
{ rintros _ ⟨b, rfl⟩, simp },
23+
{ rintros ⟨x, y⟩ (rfl|_),
24+
exact mem_range_self y }
25+
end
26+
27+
theorem preimage_image_sigma_mk_of_ne (h : i ≠ j) (s : set (α j)) :
28+
sigma.mk i ⁻¹' (sigma.mk j '' s) = ∅ :=
29+
by { ext x, simp [h.symm] }
30+
31+
lemma image_sigma_mk_preimage_sigma_map_subset {β : ι' → Type*} (f : ι → ι')
32+
(g : Π i, α i → β (f i)) (i : ι) (s : set (β (f i))) :
33+
sigma.mk i '' (g i ⁻¹' s) ⊆ sigma.map f g ⁻¹' (sigma.mk (f i) '' s) :=
34+
image_subset_iff.2 $ λ x hx, ⟨g i x, hx, rfl⟩
35+
36+
lemma image_sigma_mk_preimage_sigma_map {β : ι' → Type*} {f : ι → ι'} (hf : function.injective f)
37+
(g : Π i, α i → β (f i)) (i : ι) (s : set (β (f i))) :
38+
sigma.mk i '' (g i ⁻¹' s) = sigma.map f g ⁻¹' (sigma.mk (f i) '' s) :=
39+
begin
40+
refine (image_sigma_mk_preimage_sigma_map_subset f g i s).antisymm _,
41+
rintro ⟨j, x⟩ ⟨y, hys, hxy⟩,
42+
simp only [hf.eq_iff, sigma.map] at hxy,
43+
rcases hxy with ⟨rfl, hxy⟩, rw [heq_iff_eq] at hxy, subst y,
44+
exact ⟨x, hys, rfl⟩
45+
end
1746

1847
/-- Indexed sum of sets. `s.sigma t` is the set of dependent pairs `⟨i, a⟩` such that `i ∈ s` and
1948
`a ∈ t i`.-/

src/data/sigma/basic.lean

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -97,21 +97,25 @@ lemma function.injective.sigma_map {f₁ : α₁ → α₂} {f₂ : Πa, β₁ a
9797
| ⟨i, x⟩ ⟨j, y⟩ h :=
9898
begin
9999
obtain rfl : i = j, from h₁ (sigma.mk.inj_iff.mp h).1,
100-
obtain rfl : x = y, from h₂ i (eq_of_heq (sigma.mk.inj_iff.mp h).2),
100+
obtain rfl : x = y, from h₂ i (sigma_mk_injective h),
101101
refl
102102
end
103103

104+
lemma function.injective.of_sigma_map {f₁ : α₁ → α₂} {f₂ : Πa, β₁ a → β₂ (f₁ a)}
105+
(h : function.injective (sigma.map f₁ f₂)) (a : α₁) : function.injective (f₂ a) :=
106+
λ x y hxy, sigma_mk_injective $ @h ⟨a, x⟩ ⟨a, y⟩ (sigma.ext rfl (heq_iff_eq.2 hxy))
107+
108+
lemma function.injective.sigma_map_iff {f₁ : α₁ → α₂} {f₂ : Πa, β₁ a → β₂ (f₁ a)}
109+
(h₁ : function.injective f₁) :
110+
function.injective (sigma.map f₁ f₂) ↔ ∀ a, function.injective (f₂ a) :=
111+
⟨λ h, h.of_sigma_map, h₁.sigma_map⟩
112+
104113
lemma function.surjective.sigma_map {f₁ : α₁ → α₂} {f₂ : Πa, β₁ a → β₂ (f₁ a)}
105114
(h₁ : function.surjective f₁) (h₂ : ∀ a, function.surjective (f₂ a)) :
106115
function.surjective (sigma.map f₁ f₂) :=
107116
begin
108-
intros y,
109-
cases y with j y,
110-
cases h₁ j with i hi,
111-
subst j,
112-
cases h₂ i y with x hx,
113-
subst y,
114-
exact ⟨⟨i, x⟩, rfl⟩
117+
simp only [function.surjective, sigma.forall, h₁.forall],
118+
exact λ i, (h₂ _).forall.2 (λ x, ⟨⟨i, x⟩, rfl⟩)
115119
end
116120

117121
/-- Interpret a function on `Σ x : α, β x` as a dependent function with two arguments.
@@ -137,17 +141,11 @@ lemma sigma.curry_uncurry {γ : Π a, β a → Type*} (f : Π x (y : β x), γ x
137141
rfl
138142

139143
/-- Convert a product type to a Σ-type. -/
140-
@[simp]
141-
def prod.to_sigma {α β} : α × β → Σ _ : α, β
142-
| ⟨x,y⟩ := ⟨x,y⟩
144+
def prod.to_sigma {α β} (p : α × β) : Σ _ : α, β := ⟨p.1, p.2
143145

144-
@[simp]
145-
lemma prod.fst_to_sigma {α β} (x : α × β) : (prod.to_sigma x).fst = x.fst :=
146-
by cases x; refl
147-
148-
@[simp]
149-
lemma prod.snd_to_sigma {α β} (x : α × β) : (prod.to_sigma x).snd = x.snd :=
150-
by cases x; refl
146+
@[simp] lemma prod.fst_to_sigma {α β} (x : α × β) : (prod.to_sigma x).fst = x.fst := rfl
147+
@[simp] lemma prod.snd_to_sigma {α β} (x : α × β) : (prod.to_sigma x).snd = x.snd := rfl
148+
@[simp] lemma prod.to_sigma_mk {α β} (x : α) (y : β) : (x, y).to_sigma = ⟨x, y⟩ := rfl
151149

152150
-- we generate this manually as `@[derive has_reflect]` fails
153151
@[instance]

src/order/filter/bases.lean

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -777,6 +777,16 @@ lemma has_basis.coprod {ι ι' : Type*} {pa : ι → Prop} {sa : ι → set α}
777777

778778
end two_types
779779

780+
lemma map_sigma_mk_comap {π : α → Type*} {π' : β → Type*} {f : α → β}
781+
(hf : function.injective f) (g : Π a, π a → π' (f a)) (a : α) (l : filter (π' (f a))) :
782+
map (sigma.mk a) (comap (g a) l) = comap (sigma.map f g) (map (sigma.mk (f a)) l) :=
783+
begin
784+
refine (((basis_sets _).comap _).map _).eq_of_same_basis _,
785+
convert ((basis_sets _).map _).comap _,
786+
ext1 s,
787+
apply image_sigma_mk_preimage_sigma_map hf
788+
end
789+
780790
end filter
781791

782792
end sort

0 commit comments

Comments
 (0)