@@ -340,6 +340,33 @@ end fintype_instances
340
340
341
341
end set
342
342
343
+ /-! ### Finset -/
344
+
345
+ namespace finset
346
+
347
+ /-- Gives a `set.finite` for the `finset` coerced to a `set`.
348
+ This is a wrapper around `set.to_finite`. -/
349
+ lemma finite_to_set (s : finset α) : (s : set α).finite := set.to_finite _
350
+
351
+ @[simp] lemma finite_to_set_to_finset (s : finset α) : s.finite_to_set.to_finset = s :=
352
+ by { ext, rw [set.finite.mem_to_finset, mem_coe] }
353
+
354
+ end finset
355
+
356
+ namespace multiset
357
+
358
+ lemma finite_to_set (s : multiset α) : {x | x ∈ s}.finite :=
359
+ by { classical, simpa only [← multiset.mem_to_finset] using s.to_finset.finite_to_set }
360
+
361
+ @[simp] lemma finite_to_set_to_finset [decidable_eq α] (s : multiset α) :
362
+ s.finite_to_set.to_finset = s.to_finset :=
363
+ by { ext x, simp }
364
+
365
+ end multiset
366
+
367
+ lemma list.finite_to_set (l : list α) : {x | x ∈ l}.finite :=
368
+ (show multiset α, from ⟦l⟧).finite_to_set
369
+
343
370
/-! ### Finite instances
344
371
345
372
There is seemingly some overlap between the following instances and the `fintype` instances
@@ -585,7 +612,7 @@ h.induction_on finite_empty finite_singleton
585
612
theorem exists_finite_iff_finset {p : set α → Prop } :
586
613
(∃ s : set α, s.finite ∧ p s) ↔ ∃ s : finset α, p ↑s :=
587
614
⟨λ ⟨s, hs, hps⟩, ⟨hs.to_finset, hs.coe_to_finset.symm ▸ hps⟩,
588
- λ ⟨s, hs⟩, ⟨↑ s, finite_mem_finset s , hs⟩⟩
615
+ λ ⟨s, hs⟩, ⟨s, s.finite_to_set , hs⟩⟩
589
616
590
617
/-- There are finitely many subsets of a given finite set -/
591
618
lemma finite.finite_subsets {α : Type u} {a : set α} (h : a.finite) : {b | b ⊆ a}.finite :=
@@ -601,13 +628,13 @@ begin
601
628
lift t to Π d, finset (κ d) using ht,
602
629
classical,
603
630
rw ← fintype.coe_pi_finset,
604
- apply finite_mem_finset
631
+ apply finset.finite_to_set
605
632
end
606
633
607
634
/-- A finite union of finsets is finite. -/
608
635
lemma union_finset_finite_of_range_finite (f : α → finset β) (h : (range f).finite) :
609
636
(⋃ a, (f a : set β)).finite :=
610
- by { rw ← bUnion_range, exact h.bUnion (λ y hy, finite_mem_finset y ) }
637
+ by { rw ← bUnion_range, exact h.bUnion (λ y hy, y.finite_to_set ) }
611
638
612
639
lemma finite_range_ite {p : α → Prop } [decidable_pred p] {f g : α → β} (hf : (range f).finite)
613
640
(hg : (range g).finite) : (range (λ x, if p x then f x else g x)).finite :=
@@ -1035,13 +1062,9 @@ lemma Union_univ_pi_of_monotone {ι ι' : Type*} [linear_order ι'] [nonempty ι
1035
1062
(⋃ j : ι', pi univ (λ i, s i j)) = pi univ (λ i, ⋃ j, s i j) :=
1036
1063
Union_pi_of_monotone finite_univ (λ i _, hs i)
1037
1064
1038
- lemma range_find_greatest_subset {P : α → ℕ → Prop } [∀ x, decidable_pred (P x)] {b : ℕ}:
1039
- range (λ x, nat.find_greatest (P x) b) ⊆ ↑(finset.range (b + 1 )) :=
1040
- by { rw range_subset_iff, intro x, simp [nat.lt_succ_iff, nat.find_greatest_le] }
1041
-
1042
1065
lemma finite_range_find_greatest {P : α → ℕ → Prop } [∀ x, decidable_pred (P x)] {b : ℕ} :
1043
1066
(range (λ x, nat.find_greatest (P x) b)).finite :=
1044
- (finite_mem_finset (finset.range (b + 1 ))).subset range_find_greatest_subset
1067
+ (finite_le_nat b).subset $ range_subset_iff. 2 $ λ x, nat.find_greatest_le _
1045
1068
1046
1069
lemma finite.exists_maximal_wrt [partial_order β] (f : α → β) (s : set α) (h : set.finite s) :
1047
1070
s.nonempty → ∃ a ∈ s, ∀ a' ∈ s, f a ≤ f a' → f a = f a' :=
@@ -1116,12 +1139,12 @@ namespace finset
1116
1139
/-- A finset is bounded above. -/
1117
1140
protected lemma bdd_above [semilattice_sup α] [nonempty α] (s : finset α) :
1118
1141
bdd_above (↑s : set α) :=
1119
- (set.finite_mem_finset s) .bdd_above
1142
+ s.finite_to_set .bdd_above
1120
1143
1121
1144
/-- A finset is bounded below. -/
1122
1145
protected lemma bdd_below [semilattice_inf α] [nonempty α] (s : finset α) :
1123
1146
bdd_below (↑s : set α) :=
1124
- (set.finite_mem_finset s) .bdd_below
1147
+ s.finite_to_set .bdd_below
1125
1148
1126
1149
end finset
1127
1150
@@ -1149,17 +1172,3 @@ begin
1149
1172
{ dsimp only [x, y] at this , exact key₁ (f.injective $ subtype.coe_injective this ) },
1150
1173
{ dsimp only [y, z] at this , exact key₂ (f.injective $ subtype.coe_injective this ) }
1151
1174
end
1152
-
1153
- /-! ### Finset -/
1154
-
1155
- namespace finset
1156
-
1157
- /-- Gives a `set.finite` for the `finset` coerced to a `set`.
1158
- This is a wrapper around `set.to_finite`. -/
1159
- lemma finite_to_set (s : finset α) : (s : set α).finite := set.finite_mem_finset s
1160
-
1161
- @[simp] lemma finite_to_set_to_finset {α : Type *} (s : finset α) :
1162
- s.finite_to_set.to_finset = s :=
1163
- by { ext, rw [set.finite.mem_to_finset, mem_coe] }
1164
-
1165
- end finset
0 commit comments