@@ -276,8 +276,7 @@ theorem subset_iff {s₁ s₂ : finset α} : s₁ ⊆ s₂ ↔ ∀ ⦃x⦄, x
276
276
theorem subset.antisymm_iff {s₁ s₂ : finset α} : s₁ = s₂ ↔ s₁ ⊆ s₂ ∧ s₂ ⊆ s₁ :=
277
277
le_antisymm_iff
278
278
279
- theorem not_subset (s t : finset α) : ¬(s ⊆ t) ↔ ∃ x ∈ s, ¬(x ∈ t) :=
280
- by simp only [←finset.coe_subset, set.not_subset, exists_prop, finset.mem_coe]
279
+ lemma not_subset : ¬ s ⊆ t ↔ ∃ x ∈ s, x ∉ t := by simp only [←coe_subset, set.not_subset, mem_coe]
281
280
282
281
@[simp] theorem le_eq_subset : ((≤) : finset α → finset α → Prop ) = (⊆) := rfl
283
282
@[simp] theorem lt_eq_subset : ((<) : finset α → finset α → Prop ) = (⊂) := rfl
@@ -438,7 +437,7 @@ end empty
438
437
/-! ### singleton -/
439
438
440
439
section singleton
441
- variables {s : finset α} {a : α}
440
+ variables {s : finset α} {a b : α}
442
441
443
442
/--
444
443
`{a} : finset a` is the set `{a}` containing `a` and nothing else.
@@ -460,8 +459,7 @@ theorem mem_singleton_self (a : α) : a ∈ ({a} : finset α) := or.inl rfl
460
459
lemma singleton_injective : injective (singleton : α → finset α) :=
461
460
λ a b h, mem_singleton.1 (h ▸ mem_singleton_self _)
462
461
463
- theorem singleton_inj {a b : α} : ({a} : finset α) = {b} ↔ a = b :=
464
- singleton_injective.eq_iff
462
+ @[simp] lemma singleton_inj : ({a} : finset α) = {b} ↔ a = b := singleton_injective.eq_iff
465
463
466
464
@[simp] theorem singleton_nonempty (a : α) : ({a} : finset α).nonempty := ⟨a, mem_singleton_self a⟩
467
465
@@ -512,6 +510,8 @@ singleton_subset_set_iff
512
510
@[simp] lemma subset_singleton_iff {s : finset α} {a : α} : s ⊆ {a} ↔ s = ∅ ∨ s = {a} :=
513
511
by rw [←coe_subset, coe_singleton, set.subset_singleton_iff_eq, coe_eq_empty, coe_eq_singleton]
514
512
513
+ lemma singleton_subset_singleton : ({a} : finset α) ⊆ {b} ↔ a = b := by simp
514
+
515
515
protected lemma nonempty.subset_singleton_iff {s : finset α} {a : α} (h : s.nonempty) :
516
516
s ⊆ {a} ↔ s = {a} :=
517
517
subset_singleton_iff.trans $ or_iff_right h.ne_empty
@@ -529,6 +529,10 @@ ssubset_singleton_iff.1 hs
529
529
lemma eq_singleton_or_nontrivial (ha : a ∈ s) : s = {a} ∨ (s : set α).nontrivial :=
530
530
by { rw ←coe_eq_singleton, exact set.eq_singleton_or_nontrivial ha }
531
531
532
+ lemma nonempty.exists_eq_singleton_or_nontrivial :
533
+ s.nonempty → (∃ a, s = {a}) ∨ (s : set α).nontrivial :=
534
+ λ ⟨a, ha⟩, (eq_singleton_or_nontrivial ha).imp_left $ exists.intro a
535
+
532
536
instance [nonempty α] : nontrivial (finset α) :=
533
537
‹nonempty α›.elim $ λ a, ⟨⟨{a}, ∅, singleton_ne_empty _⟩⟩
534
538
@@ -576,7 +580,7 @@ by rwa [← coe_subset, coe_cons, coe_cons, set.insert_subset_insert_iff, coe_su
576
580
lemma ssubset_iff_exists_cons_subset : s ⊂ t ↔ ∃ a (h : a ∉ s), s.cons a h ⊆ t :=
577
581
begin
578
582
refine ⟨λ h, _, λ ⟨a, ha, h⟩, ssubset_of_ssubset_of_subset (ssubset_cons _) h⟩,
579
- obtain ⟨a, hs, ht⟩ := ( not_subset _ _) .1 h.2 ,
583
+ obtain ⟨a, hs, ht⟩ := not_subset.1 h.2 ,
580
584
exact ⟨a, ht, cons_subset.2 ⟨hs, h.subset⟩⟩,
581
585
end
582
586
@@ -592,12 +596,12 @@ lemma disjoint_left : disjoint s t ↔ ∀ ⦃a⦄, a ∈ s → a ∉ t :=
592
596
singleton_subset_iff.mp (h (singleton_subset_iff.mpr hs) (singleton_subset_iff.mpr ht)),
593
597
λ h x hs ht a ha, h (hs ha) (ht ha)⟩
594
598
595
- lemma disjoint_val : disjoint s t ↔ s.1 .disjoint t.1 := disjoint_left
596
-
597
599
lemma disjoint_right : disjoint s t ↔ ∀ ⦃a⦄, a ∈ t → a ∉ s := by rw [disjoint.comm, disjoint_left]
598
600
lemma disjoint_iff_ne : disjoint s t ↔ ∀ a ∈ s, ∀ b ∈ t, a ≠ b :=
599
601
by simp only [disjoint_left, imp_not_comm, forall_eq']
600
602
603
+ @[simp] lemma disjoint_val : s.1 .disjoint t.1 ↔ disjoint s t := disjoint_left.symm
604
+
601
605
lemma _root_.disjoint.forall_ne_finset (h : disjoint s t) (ha : a ∈ s) (hb : b ∈ t) : a ≠ b :=
602
606
disjoint_iff_ne.1 h _ ha _ hb
603
607
@@ -639,7 +643,7 @@ end disjoint
639
643
It is the same as `s ∪ t`, but it does not require decidable equality on the type. The hypothesis
640
644
ensures that the sets are disjoint. -/
641
645
def disj_union (s t : finset α) (h : disjoint s t) : finset α :=
642
- ⟨s.1 + t.1 , multiset.nodup_add.2 ⟨s.2 , t.2 , disjoint_val.1 h⟩⟩
646
+ ⟨s.1 + t.1 , multiset.nodup_add.2 ⟨s.2 , t.2 , disjoint_val.2 h⟩⟩
643
647
644
648
@[simp] theorem mem_disj_union {α s t h a} :
645
649
a ∈ @disj_union α s t h ↔ a ∈ s ∨ a ∈ t :=
@@ -1113,6 +1117,8 @@ end
1113
1117
lemma inter_subset_inter_left (h : t ⊆ u) : s ∩ t ⊆ s ∩ u := inter_subset_inter subset.rfl h
1114
1118
lemma inter_subset_inter_right (h : s ⊆ t) : s ∩ u ⊆ t ∩ u := inter_subset_inter h subset.rfl
1115
1119
1120
+ lemma inter_subset_union : s ∩ t ⊆ s ∪ t := le_iff_subset.1 inf_le_sup
1121
+
1116
1122
instance : distrib_lattice (finset α) :=
1117
1123
{ le_sup_inf := assume a b c, show (a ∪ b) ∩ (a ∪ c) ⊆ a ∪ b ∩ c,
1118
1124
by simp only [subset_iff, mem_inter, mem_union, and_imp, or_imp_distrib] {contextual:=tt};
@@ -1157,8 +1163,8 @@ lemma union_eq_empty_iff (A B : finset α) : A ∪ B = ∅ ↔ A = ∅ ∧ B =
1157
1163
lemma union_subset_iff : s ∪ t ⊆ u ↔ s ⊆ u ∧ t ⊆ u := (sup_le_iff : s ⊔ t ≤ u ↔ s ≤ u ∧ t ≤ u)
1158
1164
lemma subset_inter_iff : s ⊆ t ∩ u ↔ s ⊆ t ∧ s ⊆ u := (le_inf_iff : s ≤ t ⊓ u ↔ s ≤ t ∧ s ≤ u)
1159
1165
1160
- lemma inter_eq_left_iff_subset (s t : finset α) : s ∩ t = s ↔ s ⊆ t := inf_eq_left
1161
- lemma inter_eq_right_iff_subset (s t : finset α) : t ∩ s = s ↔ s ⊆ t := inf_eq_right
1166
+ @[simp] lemma inter_eq_left_iff_subset (s t : finset α) : s ∩ t = s ↔ s ⊆ t := inf_eq_left
1167
+ @[simp] lemma inter_eq_right_iff_subset (s t : finset α) : t ∩ s = s ↔ s ⊆ t := inf_eq_right
1162
1168
1163
1169
lemma inter_congr_left (ht : s ∩ u ⊆ t) (hu : s ∩ t ⊆ u) : s ∩ t = s ∩ u := inf_congr_left ht hu
1164
1170
lemma inter_congr_right (hs : t ∩ u ⊆ s) (ht : s ∩ u ⊆ t) : s ∩ u = t ∩ u := inf_congr_right hs ht
@@ -1172,6 +1178,14 @@ lemma ite_subset_union (s s' : finset α) (P : Prop) [decidable P] :
1172
1178
lemma inter_subset_ite (s s' : finset α) (P : Prop ) [decidable P] :
1173
1179
s ∩ s' ⊆ ite P s s' := inf_le_ite s s' P
1174
1180
1181
+ lemma not_disjoint_iff_nonempty_inter : ¬disjoint s t ↔ (s ∩ t).nonempty :=
1182
+ not_disjoint_iff.trans $ by simp [finset.nonempty]
1183
+
1184
+ alias not_disjoint_iff_nonempty_inter ↔ _ nonempty.not_disjoint
1185
+
1186
+ lemma disjoint_or_nonempty_inter (s t : finset α) : disjoint s t ∨ (s ∩ t).nonempty :=
1187
+ by { rw ←not_disjoint_iff_nonempty_inter, exact em _ }
1188
+
1175
1189
end lattice
1176
1190
1177
1191
/-! ### erase -/
@@ -1256,7 +1270,7 @@ calc s.erase a ⊂ insert a (s.erase a) : ssubset_insert $ not_mem_erase _ _
1256
1270
lemma ssubset_iff_exists_subset_erase {s t : finset α} : s ⊂ t ↔ ∃ a ∈ t, s ⊆ t.erase a :=
1257
1271
begin
1258
1272
refine ⟨λ h, _, λ ⟨a, ha, h⟩, ssubset_of_subset_of_ssubset h $ erase_ssubset ha⟩,
1259
- obtain ⟨a, ht, hs⟩ := ( not_subset _ _) .1 h.2 ,
1273
+ obtain ⟨a, ht, hs⟩ := not_subset.1 h.2 ,
1260
1274
exact ⟨a, ht, subset_erase.2 ⟨h.1 , hs⟩⟩,
1261
1275
end
1262
1276
@@ -1374,7 +1388,9 @@ lemma sdiff_union_inter (s t : finset α) : (s \ t) ∪ (s ∩ t) = s := sup_sdi
1374
1388
1375
1389
@[simp] lemma sdiff_idem (s t : finset α) : s \ t \ t = s \ t := sdiff_idem
1376
1390
1377
- lemma sdiff_eq_empty_iff_subset : s \ t = ∅ ↔ s ⊆ t := sdiff_eq_bot_iff
1391
+ lemma subset_sdiff : s ⊆ t \ u ↔ s ⊆ t ∧ disjoint s u := le_iff_subset.symm.trans le_sdiff
1392
+
1393
+ @[simp] lemma sdiff_eq_empty_iff_subset : s \ t = ∅ ↔ s ⊆ t := sdiff_eq_bot_iff
1378
1394
1379
1395
lemma sdiff_nonempty : (s \ t).nonempty ↔ ¬ s ⊆ t :=
1380
1396
nonempty_iff_ne_empty.trans sdiff_eq_empty_iff_subset.not
@@ -2218,7 +2234,7 @@ hypothesis ensures that the sets are disjoint. -/
2218
2234
def disj_Union (s : finset α) (t : α → finset β)
2219
2235
(hf : (s : set α).pairwise_disjoint t) : finset β :=
2220
2236
⟨(s.val.bind (finset.val ∘ t)), multiset.nodup_bind.mpr
2221
- ⟨λ a ha, (t a).nodup, s.nodup.pairwise $ λ a ha b hb hab, finset. disjoint_val.1 $ hf ha hb hab⟩⟩
2237
+ ⟨λ a ha, (t a).nodup, s.nodup.pairwise $ λ a ha b hb hab, disjoint_val.2 $ hf ha hb hab⟩⟩
2222
2238
2223
2239
@[simp] theorem disj_Union_val (s : finset α) (t : α → finset β) (h) :
2224
2240
(s.disj_Union t h).1 = (s.1 .bind (λ a, (t a).1 )) := rfl
0 commit comments