@@ -284,6 +284,12 @@ union_subset_union h (by refl)
284
284
theorem union_subset_union_right (s) {t₁ t₂ : set α} (h : t₁ ⊆ t₂) : s ∪ t₁ ⊆ s ∪ t₂ :=
285
285
union_subset_union (by refl) h
286
286
287
+ lemma subset_union_of_subset_left {s t : set α} (h : s ⊆ t) (u : set α) : s ⊆ t ∪ u :=
288
+ subset.trans h (subset_union_left t u)
289
+
290
+ lemma subset_union_of_subset_right {s u : set α} (h : s ⊆ u) (t : set α) : s ⊆ t ∪ u :=
291
+ subset.trans h (subset_union_right t u)
292
+
287
293
@[simp] theorem union_empty_iff {s t : set α} : s ∪ t = ∅ ↔ s = ∅ ∧ t = ∅ :=
288
294
⟨by finish [ext_iff], by finish [ext_iff]⟩
289
295
@@ -496,6 +502,9 @@ by simp [eq_empty_iff_forall_not_mem]
496
502
theorem inter_singleton_eq_empty : s ∩ {a} = ∅ ↔ a ∉ s :=
497
503
by rw [inter_comm, singleton_inter_eq_empty]
498
504
505
+ lemma nmem_singleton_empty {s : set α} : s ∉ ({∅} : set (set α)) ↔ nonempty s :=
506
+ by simp [coe_nonempty_iff_ne_empty]
507
+
499
508
/- separation -/
500
509
501
510
theorem mem_sep {s : set α} {p : α → Prop } {x : α} (xs : x ∈ s) (px : p x) : x ∈ {x ∈ s | p x} :=
@@ -553,6 +562,17 @@ by finish [ext_iff]
553
562
@[simp] theorem compl_univ : -(univ : set α) = ∅ :=
554
563
by finish [ext_iff]
555
564
565
+ lemma compl_empty_iff {s : set α} : -s = ∅ ↔ s = univ :=
566
+ by { split, intro h, rw [←compl_compl s, h, compl_empty], intro h, rw [h, compl_univ] }
567
+
568
+ lemma compl_univ_iff {s : set α} : -s = univ ↔ s = ∅ :=
569
+ by rw [←compl_empty_iff, compl_compl]
570
+
571
+ lemma nonempty_compl {s : set α} : nonempty (-s : set α) ↔ s ≠ univ :=
572
+ by { symmetry, rw [coe_nonempty_iff_ne_empty], apply not_congr,
573
+ split, intro h, rw [h, compl_univ],
574
+ intro h, rw [←compl_compl s, h, compl_empty] }
575
+
556
576
theorem union_eq_compl_compl_inter_compl (s t : set α) : s ∪ t = -(-s ∩ -t) :=
557
577
by simp [compl_inter, compl_compl]
558
578
@@ -667,6 +687,15 @@ lemma diff_subset_iff {s t u : set α} : s \ t ⊆ u ↔ s ⊆ t ∪ u :=
667
687
⟨assume h x xs, classical.by_cases or.inl (assume nxt, or.inr (h ⟨xs, nxt⟩)),
668
688
assume h x ⟨xs, nxt⟩, or.resolve_left (h xs) nxt⟩
669
689
690
+ lemma subset_insert_diff (s t : set α) : s ⊆ (s \ t) ∪ t :=
691
+ by rw [union_comm, ←diff_subset_iff]
692
+
693
+ @[simp] lemma diff_singleton_subset_iff {x : α} {s t : set α} : s \ {x} ⊆ t ↔ s ⊆ insert x t :=
694
+ by { rw [←union_singleton, union_comm], apply diff_subset_iff }
695
+
696
+ lemma subset_insert_diff_singleton (x : α) (s : set α) : s ⊆ insert x (s \ {x}) :=
697
+ by rw [←diff_singleton_subset_iff]
698
+
670
699
lemma diff_subset_comm {s t u : set α} : s \ t ⊆ u ↔ s \ u ⊆ t :=
671
700
by rw [diff_subset_iff, diff_subset_iff, union_comm]
672
701
@@ -694,6 +723,13 @@ by simp [insert_eq, union_diff_self, -union_singleton, -singleton_union]
694
723
695
724
@[simp] lemma diff_self {s : set α} : s \ s = ∅ := ext $ by simp
696
725
726
+ lemma mem_diff_singleton {s s' : set α} {t : set (set α)} : s ∈ t \ {s'} ↔ (s ∈ t ∧ s ≠ s') :=
727
+ by simp
728
+
729
+ lemma mem_diff_singleton_empty {s : set α} {t : set (set α)} :
730
+ s ∈ t \ {∅} ↔ (s ∈ t ∧ nonempty s) :=
731
+ by simp [coe_nonempty_iff_ne_empty]
732
+
697
733
/- powerset -/
698
734
699
735
theorem mem_powerset {x s : set α} (h : x ⊆ s) : x ∈ powerset s := h
@@ -799,6 +835,10 @@ mem_image_elim h h_y
799
835
(h : ∀a∈s, f a = g a) : f '' s = g '' s :=
800
836
by safe [ext_iff, iff_def]
801
837
838
+ /- A common special case of `image_congr` -/
839
+ lemma image_congr' {f g : α → β} {s : set α} (h : ∀ (x : α), f x = g x) : f '' s = g '' s :=
840
+ image_congr (λx _, h x)
841
+
802
842
theorem image_eq_image_of_eq_on {f₁ f₂ : α → β} {s : set α} (heq : eq_on f₁ f₂ s) :
803
843
f₁ '' s = f₂ '' s :=
804
844
image_congr heq
@@ -815,6 +855,11 @@ begin
815
855
finish
816
856
end -/
817
857
858
+ /-- A variant of `image_comp`, useful for rewriting -/
859
+ lemma image_image (g : β → γ) (f : α → β) (s : set α) : g '' (f '' s) = (λ x, g (f x)) '' s :=
860
+ (image_comp g f s).symm
861
+
862
+
818
863
theorem image_subset {a b : set α} (f : α → β) (h : a ⊆ b) : f '' a ⊆ f '' b :=
819
864
by finish [subset_def, mem_image_eq]
820
865
861
906
862
907
@[simp] theorem image_id (s : set α) : id '' s = s := ext $ by simp
863
908
909
+ /-- A variant of `image_id` -/
910
+ @[simp] lemma image_id' (s : set α) : (λx, x) '' s = s := image_id s
911
+
864
912
theorem compl_compl_image (S : set (set α)) :
865
913
compl '' (compl '' S) = S :=
866
914
by rw [← image_comp, compl_comp_compl, image_id]
@@ -899,6 +947,9 @@ by rw ← image_union; simp [image_univ_of_surjective H]
899
947
theorem image_compl_eq {f : α → β} {s : set α} (H : bijective f) : f '' -s = -(f '' s) :=
900
948
subset.antisymm (image_compl_subset H.1 ) (subset_image_compl H.2 )
901
949
950
+ lemma nonempty_image (f : α → β) {s : set α} : nonempty s → nonempty (f '' s)
951
+ | ⟨⟨x, hx⟩⟩ := ⟨⟨f x, mem_image_of_mem f hx⟩⟩
952
+
902
953
/- image and preimage are a Galois connection -/
903
954
theorem image_subset_iff {s : set α} {t : set β} {f : α → β} :
904
955
f '' s ⊆ t ↔ s ⊆ f ⁻¹' t :=
@@ -1051,6 +1102,23 @@ lemma image_preimage_eq_of_subset {f : α → β} {s : set β} (hs : s ⊆ range
1051
1102
f '' (f ⁻¹' s) = s :=
1052
1103
by rw [image_preimage_eq_inter_range, inter_eq_self_of_subset_left hs]
1053
1104
1105
+ lemma preimage_subset_preimage_iff {s t : set α} {f : β → α} (hs : s ⊆ range f) :
1106
+ f ⁻¹' s ⊆ f ⁻¹' t ↔ s ⊆ t :=
1107
+ begin
1108
+ split,
1109
+ { intros h x hx, rcases hs hx with ⟨y, rfl⟩, exact h hx },
1110
+ intros h x, apply h
1111
+ end
1112
+
1113
+ lemma preimage_eq_preimage' {s t : set α} {f : β → α} (hs : s ⊆ range f) (ht : t ⊆ range f) :
1114
+ f ⁻¹' s = f ⁻¹' t ↔ s = t :=
1115
+ begin
1116
+ split,
1117
+ { intro h, apply subset.antisymm, rw [←preimage_subset_preimage_iff hs, h],
1118
+ rw [←preimage_subset_preimage_iff ht, h] },
1119
+ rintro rfl, refl
1120
+ end
1121
+
1054
1122
theorem preimage_inter_range {f : α → β} {s : set β} : f ⁻¹' (s ∩ range f) = f ⁻¹' s :=
1055
1123
set.ext $ λ x, and_iff_left ⟨x, rfl⟩
1056
1124
@@ -1082,6 +1150,9 @@ funext $ λ i, rfl
1082
1150
lemma surjective_onto_range : surjective (range_factorization f) :=
1083
1151
λ ⟨_, ⟨i, rfl⟩⟩, ⟨i, rfl⟩
1084
1152
1153
+ lemma image_eq_range (f : α → β) (s : set α) : f '' s = range (λ(x : s), f x.1 ) :=
1154
+ by { ext, split, rintro ⟨x, h1, h2⟩, exact ⟨⟨x, h1⟩, h2⟩, rintro ⟨⟨x, h1⟩, h2⟩, exact ⟨x, h1, h2⟩ }
1155
+
1085
1156
end range
1086
1157
1087
1158
/-- The set `s` is pairwise `r` if `r x y` for all *distinct* `x y ∈ s`. -/
@@ -1096,6 +1167,7 @@ theorem pairwise_on.mono' {s : set α} {r r' : α → α → Prop}
1096
1167
λ x xs y ys h, H _ _ (hp x xs y ys h)
1097
1168
1098
1169
end set
1170
+ open set
1099
1171
1100
1172
/- image and preimage on subtypes -/
1101
1173
@@ -1112,6 +1184,10 @@ set.ext $ assume a,
1112
1184
@[simp] lemma val_range {p : α → Prop } :
1113
1185
set.range (@subtype.val _ p) = {x | p x} :=
1114
1186
by rw ← set.image_univ; simp [-set.image_univ, val_image]
1187
+
1188
+ @[simp] lemma range_val (s : set α) : range (subtype.val : s → α) = s :=
1189
+ val_range
1190
+
1115
1191
theorem val_image_subset (s : set α) (t : set (subtype s)) : t.image val ⊆ s :=
1116
1192
λ x ⟨y, yt, yvaleq⟩, by rw ←yvaleq; exact y.property
1117
1193
@@ -1133,6 +1209,16 @@ begin
1133
1209
split, { intro h, rw h },
1134
1210
intro h, exact set.injective_image (val_injective) h
1135
1211
end
1212
+
1213
+ lemma exists_set_subtype {t : set α} (p : set α → Prop ) :
1214
+ (∃(s : set t), p (subtype.val '' s)) ↔ ∃(s : set α), s ⊆ t ∧ p s :=
1215
+ begin
1216
+ split,
1217
+ { rintro ⟨s, hs⟩, refine ⟨subtype.val '' s, _, hs⟩,
1218
+ convert image_subset_range _ _, rw [range_val] },
1219
+ rintro ⟨s, hs₁, hs₂⟩, refine ⟨subtype.val ⁻¹' s, _⟩,
1220
+ rw [image_preimage_eq_of_subset], exact hs₂, rw [range_val], exact hs₁
1221
+ end
1136
1222
end subtype
1137
1223
1138
1224
namespace set
0 commit comments