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

Commit bc7d81b

Browse files
committed
feat(data/{set,finset}/basic): Convenience lemmas (#17957)
Add a few convenient corollaries to existing lemmas.
1 parent e001509 commit bc7d81b

File tree

23 files changed

+190
-135
lines changed

23 files changed

+190
-135
lines changed

counterexamples/phillips.lean

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ begin
283283
by simp only [s, function.iterate_succ', union_comm, union_diff_self, subtype.coe_mk,
284284
union_diff_left],
285285
rw [nat.succ_eq_add_one, this, f.additive],
286-
swap, { rw disjoint.comm, apply disjoint_diff },
286+
swap, { exact disjoint_sdiff_self_left },
287287
calc ((n + 1 : ℕ) : ℝ) * (ε / 2) = ε / 2 + n * (ε / 2) : by simp only [nat.cast_succ]; ring
288288
... ≤ f (↑(s (n + 1 : ℕ)) \ ↑(s n)) + f (↑(s n)) :
289289
add_le_add (I1 n) IH } },
@@ -339,7 +339,7 @@ begin
339339
simp only [discrete_part, continuous_part, restrict_apply],
340340
rw [← f.additive, ← inter_distrib_right],
341341
{ simp only [union_univ, union_diff_self, univ_inter] },
342-
{ have : disjoint f.discrete_support (univ \ f.discrete_support) := disjoint_diff,
342+
{ have : disjoint f.discrete_support (univ \ f.discrete_support) := disjoint_sdiff_self_right,
343343
exact this.mono (inter_subset_left _ _) (inter_subset_left _ _) }
344344
end
345345

@@ -361,7 +361,7 @@ begin
361361
conv_rhs { rw ← diff_union_inter t s },
362362
rw [additive, self_eq_add_right],
363363
{ exact continuous_part_apply_eq_zero_of_countable _ _ (hs.mono (inter_subset_right _ _)) },
364-
{ exact disjoint.mono_right (inter_subset_right _ _) (disjoint.comm.1 disjoint_diff) },
364+
{ exact disjoint.mono_right (inter_subset_right _ _) disjoint_sdiff_self_left },
365365
end
366366

367367
end bounded_additive_measure
@@ -515,7 +515,7 @@ begin
515515
have : φ (f Hcont x) = ψ (spf Hcont x) := rfl,
516516
have U : univ = spf Hcont x ∪ (univ \ spf Hcont x), by simp only [union_univ, union_diff_self],
517517
rw [this, eq_add_parts, discrete_part_apply, hx, ψ.empty, zero_add, U,
518-
ψ.continuous_part.additive _ _ (disjoint_diff),
518+
ψ.continuous_part.additive _ _ disjoint_sdiff_self_right,
519519
ψ.continuous_part_apply_eq_zero_of_countable _ (countable_compl_spf Hcont x), add_zero],
520520
end
521521

src/algebra/indicator_function.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -364,8 +364,8 @@ by rw [sub_eq_add_neg, indicator_compl']
364364

365365
@[to_additive indicator_diff'] lemma mul_indicator_diff (h : s ⊆ t) (f : α → G) :
366366
mul_indicator (t \ s) f = mul_indicator t f * (mul_indicator s f)⁻¹ :=
367-
eq_mul_inv_of_mul_eq $ by rw [pi.mul_def, ← mul_indicator_union_of_disjoint disjoint_diff.symm f,
368-
diff_union_self, union_eq_self_of_subset_right h]
367+
eq_mul_inv_of_mul_eq $ by { rw [pi.mul_def, ←mul_indicator_union_of_disjoint, diff_union_self,
368+
union_eq_self_of_subset_right h], exact disjoint_sdiff_self_left }
369369

370370
lemma indicator_diff {G : Type*} [add_group G] {s t : set α} (h : s ⊆ t) (f : α → G) :
371371
indicator (t \ s) f = indicator t f - indicator s f :=

src/analysis/box_integral/partition/basic.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -631,7 +631,7 @@ lemma Union_bUnion_partition (h : ∀ J ∈ π, (πi J).is_partition) : (π.bUni
631631
Union_congr_of_surjective id surjective_id $ λ hJ, (h J hJ).Union_eq
632632

633633
lemma is_partition_disj_union_of_eq_diff (h : π₂.Union = I \ π₁.Union) :
634-
is_partition (π₁.disj_union π₂ (h.symm ▸ disjoint_diff)) :=
634+
is_partition (π₁.disj_union π₂ $ h.symm ▸ disjoint_sdiff_self_right) :=
635635
is_partition_iff_Union_eq.2 $ (Union_disj_union _).trans $ by simp [h, π₁.Union_subset]
636636

637637
end prepartition

src/analysis/box_integral/partition/subbox_induction.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ def union_compl_to_subordinate (π₁ : tagged_prepartition I) (π₂ : preparti
205205
(hU : π₂.Union = I \ π₁.Union) (r : (ι → ℝ) → Ioi (0 : ℝ)) :
206206
tagged_prepartition I :=
207207
π₁.disj_union (π₂.to_subordinate r)
208-
(((π₂.Union_to_subordinate r).trans hU).symm ▸ disjoint_diff)
208+
(((π₂.Union_to_subordinate r).trans hU).symm ▸ disjoint_sdiff_self_right)
209209

210210
lemma is_partition_union_compl_to_subordinate (π₁ : tagged_prepartition I) (π₂ : prepartition I)
211211
(hU : π₂.Union = I \ π₁.Union) (r : (ι → ℝ) → Ioi (0 : ℝ)) :

src/data/finset/basic.lean

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -276,8 +276,7 @@ theorem subset_iff {s₁ s₂ : finset α} : s₁ ⊆ s₂ ↔ ∀ ⦃x⦄, x
276276
theorem subset.antisymm_iff {s₁ s₂ : finset α} : s₁ = s₂ ↔ s₁ ⊆ s₂ ∧ s₂ ⊆ s₁ :=
277277
le_antisymm_iff
278278

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]
281280

282281
@[simp] theorem le_eq_subset : ((≤) : finset α → finset α → Prop) = (⊆) := rfl
283282
@[simp] theorem lt_eq_subset : ((<) : finset α → finset α → Prop) = (⊂) := rfl
@@ -438,7 +437,7 @@ end empty
438437
/-! ### singleton -/
439438

440439
section singleton
441-
variables {s : finset α} {a : α}
440+
variables {s : finset α} {a b : α}
442441

443442
/--
444443
`{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
460459
lemma singleton_injective : injective (singleton : α → finset α) :=
461460
λ a b h, mem_singleton.1 (h ▸ mem_singleton_self _)
462461

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
465463

466464
@[simp] theorem singleton_nonempty (a : α) : ({a} : finset α).nonempty := ⟨a, mem_singleton_self a⟩
467465

@@ -512,6 +510,8 @@ singleton_subset_set_iff
512510
@[simp] lemma subset_singleton_iff {s : finset α} {a : α} : s ⊆ {a} ↔ s = ∅ ∨ s = {a} :=
513511
by rw [←coe_subset, coe_singleton, set.subset_singleton_iff_eq, coe_eq_empty, coe_eq_singleton]
514512

513+
lemma singleton_subset_singleton : ({a} : finset α) ⊆ {b} ↔ a = b := by simp
514+
515515
protected lemma nonempty.subset_singleton_iff {s : finset α} {a : α} (h : s.nonempty) :
516516
s ⊆ {a} ↔ s = {a} :=
517517
subset_singleton_iff.trans $ or_iff_right h.ne_empty
@@ -529,6 +529,10 @@ ssubset_singleton_iff.1 hs
529529
lemma eq_singleton_or_nontrivial (ha : a ∈ s) : s = {a} ∨ (s : set α).nontrivial :=
530530
by { rw ←coe_eq_singleton, exact set.eq_singleton_or_nontrivial ha }
531531

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+
532536
instance [nonempty α] : nontrivial (finset α) :=
533537
‹nonempty α›.elim $ λ a, ⟨⟨{a}, ∅, singleton_ne_empty _⟩⟩
534538

@@ -576,7 +580,7 @@ by rwa [← coe_subset, coe_cons, coe_cons, set.insert_subset_insert_iff, coe_su
576580
lemma ssubset_iff_exists_cons_subset : s ⊂ t ↔ ∃ a (h : a ∉ s), s.cons a h ⊆ t :=
577581
begin
578582
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,
580584
exact ⟨a, ht, cons_subset.2 ⟨hs, h.subset⟩⟩,
581585
end
582586

@@ -592,12 +596,12 @@ lemma disjoint_left : disjoint s t ↔ ∀ ⦃a⦄, a ∈ s → a ∉ t :=
592596
singleton_subset_iff.mp (h (singleton_subset_iff.mpr hs) (singleton_subset_iff.mpr ht)),
593597
λ h x hs ht a ha, h (hs ha) (ht ha)⟩
594598

595-
lemma disjoint_val : disjoint s t ↔ s.1.disjoint t.1 := disjoint_left
596-
597599
lemma disjoint_right : disjoint s t ↔ ∀ ⦃a⦄, a ∈ t → a ∉ s := by rw [disjoint.comm, disjoint_left]
598600
lemma disjoint_iff_ne : disjoint s t ↔ ∀ a ∈ s, ∀ b ∈ t, a ≠ b :=
599601
by simp only [disjoint_left, imp_not_comm, forall_eq']
600602

603+
@[simp] lemma disjoint_val : s.1.disjoint t.1 ↔ disjoint s t := disjoint_left.symm
604+
601605
lemma _root_.disjoint.forall_ne_finset (h : disjoint s t) (ha : a ∈ s) (hb : b ∈ t) : a ≠ b :=
602606
disjoint_iff_ne.1 h _ ha _ hb
603607

@@ -639,7 +643,7 @@ end disjoint
639643
It is the same as `s ∪ t`, but it does not require decidable equality on the type. The hypothesis
640644
ensures that the sets are disjoint. -/
641645
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⟩⟩
643647

644648
@[simp] theorem mem_disj_union {α s t h a} :
645649
a ∈ @disj_union α s t h ↔ a ∈ s ∨ a ∈ t :=
@@ -1113,6 +1117,8 @@ end
11131117
lemma inter_subset_inter_left (h : t ⊆ u) : s ∩ t ⊆ s ∩ u := inter_subset_inter subset.rfl h
11141118
lemma inter_subset_inter_right (h : s ⊆ t) : s ∩ u ⊆ t ∩ u := inter_subset_inter h subset.rfl
11151119

1120+
lemma inter_subset_union : s ∩ t ⊆ s ∪ t := le_iff_subset.1 inf_le_sup
1121+
11161122
instance : distrib_lattice (finset α) :=
11171123
{ le_sup_inf := assume a b c, show (a ∪ b) ∩ (a ∪ c) ⊆ a ∪ b ∩ c,
11181124
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 =
11571163
lemma union_subset_iff : s ∪ t ⊆ u ↔ s ⊆ u ∧ t ⊆ u := (sup_le_iff : s ⊔ t ≤ u ↔ s ≤ u ∧ t ≤ u)
11581164
lemma subset_inter_iff : s ⊆ t ∩ u ↔ s ⊆ t ∧ s ⊆ u := (le_inf_iff : s ≤ t ⊓ u ↔ s ≤ t ∧ s ≤ u)
11591165

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
11621168

11631169
lemma inter_congr_left (ht : s ∩ u ⊆ t) (hu : s ∩ t ⊆ u) : s ∩ t = s ∩ u := inf_congr_left ht hu
11641170
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] :
11721178
lemma inter_subset_ite (s s' : finset α) (P : Prop) [decidable P] :
11731179
s ∩ s' ⊆ ite P s s' := inf_le_ite s s' P
11741180

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+
11751189
end lattice
11761190

11771191
/-! ### erase -/
@@ -1256,7 +1270,7 @@ calc s.erase a ⊂ insert a (s.erase a) : ssubset_insert $ not_mem_erase _ _
12561270
lemma ssubset_iff_exists_subset_erase {s t : finset α} : s ⊂ t ↔ ∃ a ∈ t, s ⊆ t.erase a :=
12571271
begin
12581272
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,
12601274
exact ⟨a, ht, subset_erase.2 ⟨h.1, hs⟩⟩,
12611275
end
12621276

@@ -1374,7 +1388,9 @@ lemma sdiff_union_inter (s t : finset α) : (s \ t) ∪ (s ∩ t) = s := sup_sdi
13741388

13751389
@[simp] lemma sdiff_idem (s t : finset α) : s \ t \ t = s \ t := sdiff_idem
13761390

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
13781394

13791395
lemma sdiff_nonempty : (s \ t).nonempty ↔ ¬ s ⊆ t :=
13801396
nonempty_iff_ne_empty.trans sdiff_eq_empty_iff_subset.not
@@ -2218,7 +2234,7 @@ hypothesis ensures that the sets are disjoint. -/
22182234
def disj_Union (s : finset α) (t : α → finset β)
22192235
(hf : (s : set α).pairwise_disjoint t) : finset β :=
22202236
⟨(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⟩⟩
22222238

22232239
@[simp] theorem disj_Union_val (s : finset α) (t : α → finset β) (h) :
22242240
(s.disj_Union t h).1 = (s.1.bind (λ a, (t a).1)) := rfl

src/data/finset/card.lean

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,12 @@ card_le_of_subset $ filter_subset _ _
184184
lemma eq_of_subset_of_card_le {s t : finset α} (h : s ⊆ t) (h₂ : t.card ≤ s.card) : s = t :=
185185
eq_of_veq $ multiset.eq_of_le_of_card_le (val_le_iff.mpr h) h₂
186186

187+
lemma eq_of_superset_of_card_ge (hst : s ⊆ t) (hts : t.card ≤ s.card) : t = s :=
188+
(eq_of_subset_of_card_le hst hts).symm
189+
190+
lemma subset_iff_eq_of_card_le (h : t.card ≤ s.card) : s ⊆ t ↔ s = t :=
191+
⟨λ hst, eq_of_subset_of_card_le hst h, eq.subset'⟩
192+
187193
lemma map_eq_of_subset {f : α ↪ α} (hs : s.map f ⊆ s) : s.map f = s :=
188194
eq_of_subset_of_card_le hs (card_map _).ge
189195

@@ -301,6 +307,9 @@ variables [decidable_eq α]
301307
lemma card_union_add_card_inter (s t : finset α) : (s ∪ t).card + (s ∩ t).card = s.card + t.card :=
302308
finset.induction_on t (by simp) $ λ a r har, by by_cases a ∈ s; simp *; cc
303309

310+
lemma card_inter_add_card_union (s t : finset α) : (s ∩ t).card + (s ∪ t).card = s.card + t.card :=
311+
by rw [add_comm, card_union_add_card_inter]
312+
304313
lemma card_union_le (s t : finset α) : (s ∪ t).card ≤ s.card + t.card :=
305314
card_union_add_card_inter s t ▸ nat.le_add_right _ _
306315

@@ -323,6 +332,9 @@ calc card t - card s
323332
... = card (t \ (s ∩ t)) : (card_sdiff (inter_subset_right s t)).symm
324333
... ≤ card (t \ s) : by rw sdiff_inter_self_right t s
325334

335+
lemma card_le_card_sdiff_add_card : s.card ≤ (s \ t).card + t.card :=
336+
tsub_le_iff_right.1 $ le_card_sdiff _ _
337+
326338
lemma card_sdiff_add_card : (s \ t).card + t.card = (s ∪ t).card :=
327339
by rw [←card_disjoint_union sdiff_disjoint, sdiff_union_self_eq_union]
328340

src/data/finset/image.lean

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,9 @@ by simp only [mem_def, image_val, mem_dedup, multiset.mem_map, exists_prop]
239239

240240
lemma mem_image_of_mem (f : α → β) {a} (h : a ∈ s) : f a ∈ s.image f := mem_image.2 ⟨_, h, rfl⟩
241241

242+
lemma forall_image {p : β → Prop} : (∀ b ∈ s.image f, p b) ↔ ∀ a ∈ s, p (f a) :=
243+
by simp only [mem_image, forall_exists_index, forall_apply_eq_imp_iff₂]
244+
242245
@[simp] lemma mem_image_const : c ∈ s.image (const α b) ↔ s.nonempty ∧ b = c :=
243246
by { rw mem_image, simp only [exists_prop, const_apply, exists_and_distrib_right], refl }
244247

src/data/finset/lattice.lean

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ variables [semilattice_sup α] [order_bot α]
2626
/-- Supremum of a finite set: `sup {a, b, c} f = f a ⊔ f b ⊔ f c` -/
2727
def sup (s : finset β) (f : β → α) : α := s.fold (⊔) ⊥ f
2828

29-
variables {s s₁ s₂ : finset β} {f g : β → α}
29+
variables {s s₁ s₂ : finset β} {f g : β → α} {a : α}
3030

3131
lemma sup_def : s.sup f = (s.1.map f).sup := rfl
3232

@@ -76,6 +76,8 @@ alias finset.sup_le_iff ↔ _ sup_le
7676

7777
attribute [protected] sup_le
7878

79+
lemma sup_const_le : s.sup (λ _, a) ≤ a := finset.sup_le $ λ _ _, le_rfl
80+
7981
lemma le_sup {b : β} (hb : b ∈ s) : f b ≤ s.sup f := finset.sup_le_iff.1 le_rfl _ hb
8082

8183
@[simp] lemma sup_bUnion [decidable_eq β] (s : finset γ) (t : γ → finset β) :
@@ -252,7 +254,7 @@ variables [semilattice_inf α] [order_top α]
252254
/-- Infimum of a finite set: `inf {a, b, c} f = f a ⊓ f b ⊓ f c` -/
253255
def inf (s : finset β) (f : β → α) : α := s.fold (⊓) ⊤ f
254256

255-
variables {s s₁ s₂ : finset β} {f g : β → α}
257+
variables {s s₁ s₂ : finset β} {f g : β → α} {a : α}
256258

257259
lemma inf_def : s.inf f = (s.1.map f).inf := rfl
258260

@@ -301,6 +303,8 @@ alias finset.le_inf_iff ↔ _ le_inf
301303

302304
attribute [protected] le_inf
303305

306+
lemma le_inf_const_le : a ≤ s.inf (λ _, a) := finset.le_inf $ λ _ _, le_rfl
307+
304308
lemma inf_le {b : β} (hb : b ∈ s) : s.inf f ≤ f b := finset.le_inf_iff.1 le_rfl _ hb
305309

306310
lemma inf_mono_fun {g : β → α} (h : ∀ b ∈ s, f b ≤ g b) : s.inf f ≤ s.inf g :=

src/data/fintype/basic.lean

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class fintype (α : Type*) :=
5252
(complete : ∀ x : α, x ∈ elems)
5353

5454
namespace finset
55-
variables [fintype α] {s : finset α}
55+
variables [fintype α] {s t : finset α}
5656

5757
/-- `univ` is the universal finite set of type `finset α` implied from
5858
the assumption `fintype α`. -/
@@ -98,6 +98,12 @@ instance : bounded_order (finset α) :=
9898

9999
lemma ssubset_univ_iff {s : finset α} : s ⊂ univ ↔ s ≠ univ := @lt_top_iff_ne_top _ _ _ s
100100

101+
lemma codisjoint_left : codisjoint s t ↔ ∀ ⦃a⦄, a ∉ s → a ∈ t :=
102+
by { classical, simp [codisjoint_iff, eq_univ_iff_forall, or_iff_not_imp_left] }
103+
104+
lemma codisjoint_right : codisjoint s t ↔ ∀ ⦃a⦄, a ∉ t → a ∈ s :=
105+
codisjoint.comm.trans codisjoint_left
106+
101107
section boolean_algebra
102108
variables [decidable_eq α] {a : α}
103109

@@ -316,6 +322,16 @@ def of_surjective [decidable_eq β] [fintype α] (f : α → β) (H : function.s
316322

317323
end fintype
318324

325+
namespace finset
326+
variables [fintype α] [decidable_eq α] {s t : finset α}
327+
328+
instance decidable_codisjoint : decidable (codisjoint s t) :=
329+
decidable_of_iff _ codisjoint_left.symm
330+
331+
instance decidable_is_compl : decidable (is_compl s t) := decidable_of_iff' _ is_compl_iff
332+
333+
end finset
334+
319335
section inv
320336

321337
namespace function
@@ -699,6 +715,9 @@ instance plift.fintype_Prop (p : Prop) [decidable p] : fintype (plift p) :=
699715
instance Prop.fintype : fintype Prop :=
700716
⟨⟨{true, false}, by simp [true_ne_false]⟩, classical.cases (by simp) (by simp)⟩
701717

718+
@[simp] lemma fintype.univ_Prop : (finset.univ : finset Prop) = {true, false} :=
719+
finset.eq_of_veq $ by simp; refl
720+
702721
instance subtype.fintype (p : α → Prop) [decidable_pred p] [fintype α] : fintype {x // p x} :=
703722
fintype.subtype (univ.filter p) (by simp)
704723

0 commit comments

Comments
 (0)