@@ -26,7 +26,7 @@ There's also the typeclass `fintype α`
26
26
as well as the predicate `finite` on `s : set α` (which asserts `nonempty (fintype s)`).
27
27
-/
28
28
29
- open multiset subtype nat
29
+ open multiset subtype nat function
30
30
31
31
variables {α : Type *} {β : Type *} {γ : Type *}
32
32
@@ -90,7 +90,7 @@ ext_iff.2
90
90
@[simp, norm_cast] theorem coe_inj {s₁ s₂ : finset α} : (s₁ : set α) = s₂ ↔ s₁ = s₂ :=
91
91
set.ext_iff.trans ext_iff.symm
92
92
93
- lemma coe_injective {α} : function. injective (coe : finset α → set α) :=
93
+ lemma coe_injective {α} : injective (coe : finset α → set α) :=
94
94
λ s t, coe_inj.1
95
95
96
96
/-! ### subset -/
@@ -328,6 +328,9 @@ ext $ λ a, by simp
328
328
↑(insert a s) = (insert a s : set α) :=
329
329
set.ext $ λ x, by simp only [mem_coe, mem_insert, set.mem_insert_iff]
330
330
331
+ lemma mem_insert_coe {s : finset α} {x y : α} : x ∈ insert y s ↔ x ∈ insert y (s : set α) :=
332
+ by simp
333
+
331
334
instance : is_lawful_singleton α (finset α) := ⟨λ a, by { ext, simp }⟩
332
335
333
336
@[simp] theorem insert_eq_of_mem {a : α} {s : finset α} (h : a ∈ s) : insert a s = s :=
@@ -923,7 +926,7 @@ lemma piecewise_insert_of_ne [decidable_eq α] {i j : α} [∀i, decidable (i
923
926
by simp [piecewise, h]
924
927
925
928
lemma piecewise_insert [decidable_eq α] (j : α) [∀i, decidable (i ∈ insert j s)] :
926
- (insert j s).piecewise f g = function. update (s.piecewise f g) j (f j) :=
929
+ (insert j s).piecewise f g = update (s.piecewise f g) j (f j) :=
927
930
begin
928
931
classical,
929
932
rw [← piecewise_coe, ← piecewise_coe, ← set.piecewise_insert, ← coe_insert j s],
@@ -938,7 +941,7 @@ lemma piecewise_mem_set_pi {δ : α → Type*} {t : set α} {t' : Π i, set (δ
938
941
by { classical, rw ← piecewise_coe, exact set.piecewise_mem_pi ↑s hf hg }
939
942
940
943
lemma piecewise_singleton [decidable_eq α] (i : α) :
941
- piecewise {i} f g = function. update g i (f i) :=
944
+ piecewise {i} f g = update g i (f i) :=
942
945
by rw [← insert_emptyc_eq, piecewise_insert, piecewise_empty]
943
946
944
947
lemma piecewise_piecewise_of_subset_left {s t : finset α} [Π i, decidable (i ∈ s)]
@@ -960,30 +963,29 @@ s.piecewise_congr (λ _ _, rfl) (λ i hi, t.piecewise_eq_of_not_mem _ _ (mt (@h
960
963
piecewise_piecewise_of_subset_right (subset.refl _) f g₁ g₂
961
964
962
965
lemma update_eq_piecewise {β : Type *} [decidable_eq α] (f : α → β) (i : α) (v : β) :
963
- function. update f i v = piecewise (singleton i) (λj, v) f :=
966
+ update f i v = piecewise (singleton i) (λj, v) f :=
964
967
(piecewise_singleton _ _ _).symm
965
968
966
969
lemma update_piecewise [decidable_eq α] (i : α) (v : δ i) :
967
- function.update (s.piecewise f g) i v =
968
- s.piecewise (function.update f i v) (function.update g i v) :=
970
+ update (s.piecewise f g) i v = s.piecewise (update f i v) (update g i v) :=
969
971
begin
970
972
ext j,
971
973
rcases em (j = i) with (rfl|hj); by_cases hs : j ∈ s; simp *
972
974
end
973
975
974
976
lemma update_piecewise_of_mem [decidable_eq α] {i : α} (hi : i ∈ s) (v : δ i) :
975
- function. update (s.piecewise f g) i v = s.piecewise (function. update f i v) g :=
977
+ update (s.piecewise f g) i v = s.piecewise (update f i v) g :=
976
978
begin
977
979
rw update_piecewise,
978
- refine s.piecewise_congr (λ _ _, rfl) (λ j hj, function. update_noteq _ _ _),
980
+ refine s.piecewise_congr (λ _ _, rfl) (λ j hj, update_noteq _ _ _),
979
981
exact λ h, hj (h.symm ▸ hi)
980
982
end
981
983
982
984
lemma update_piecewise_of_not_mem [decidable_eq α] {i : α} (hi : i ∉ s) (v : δ i) :
983
- function. update (s.piecewise f g) i v = s.piecewise f (function. update g i v) :=
985
+ update (s.piecewise f g) i v = s.piecewise f (update g i v) :=
984
986
begin
985
987
rw update_piecewise,
986
- refine s.piecewise_congr (λ j hj, function. update_noteq _ _ _) (λ _ _, rfl),
988
+ refine s.piecewise_congr (λ j hj, update_noteq _ _ _) (λ _ _, rfl),
987
989
exact λ h, hi (h ▸ hj)
988
990
end
989
991
@@ -1373,14 +1375,16 @@ rfl
1373
1375
@[simp] theorem to_finset_cons {a : α} {l : list α} : to_finset (a :: l) = insert a (to_finset l) :=
1374
1376
finset.eq_of_veq $ by by_cases h : a ∈ l; simp [finset.insert_val', multiset.erase_dup_cons, h]
1375
1377
1376
- theorem to_finset_surjective : function.surjective ( to_finset : list α → finset α) :=
1378
+ lemma to_finset_surj_on : set.surj_on to_finset {l : list α | l.nodup} set.univ :=
1377
1379
begin
1378
- refine λ s, ⟨quotient.out' s.val, finset.ext $ λ x, _⟩,
1379
- obtain ⟨l, hl⟩ := quot.exists_rep s.val,
1380
- rw [list.mem_to_finset, finset.mem_def, ←hl],
1381
- exact list.perm.mem_iff (quotient.mk_out l)
1380
+ rintro s -,
1381
+ cases s with t hl, induction t using quot.ind with l,
1382
+ refine ⟨l, hl, (to_finset_eq hl).symm⟩
1382
1383
end
1383
1384
1385
+ theorem to_finset_surjective : surjective (to_finset : list α → finset α) :=
1386
+ by { intro s, rcases to_finset_surj_on (set.mem_univ s) with ⟨l, -, hls⟩, exact ⟨l, hls⟩ }
1387
+
1384
1388
end list
1385
1389
1386
1390
namespace finset
@@ -1618,7 +1622,7 @@ by simp [ext_iff, subtype.forall, subtype.coe_mk]; refl
1618
1622
/-- `s.subtype p` converts back to `s.filter p` with
1619
1623
`embedding.subtype`. -/
1620
1624
@[simp] lemma subtype_map (p : α → Prop ) [decidable_pred p] :
1621
- (s.subtype p).map (function. embedding.subtype _) = s.filter p :=
1625
+ (s.subtype p).map (embedding.subtype _) = s.filter p :=
1622
1626
begin
1623
1627
ext x,
1624
1628
rw mem_map,
@@ -1638,14 +1642,14 @@ end
1638
1642
/-- If all elements of a `finset` satisfy the predicate `p`,
1639
1643
`s.subtype p` converts back to `s` with `embedding.subtype`. -/
1640
1644
lemma subtype_map_of_mem {p : α → Prop } [decidable_pred p] (h : ∀ x ∈ s, p x) :
1641
- (s.subtype p).map (function. embedding.subtype _) = s :=
1645
+ (s.subtype p).map (embedding.subtype _) = s :=
1642
1646
by rw [subtype_map, filter_true_of_mem h]
1643
1647
1644
1648
/-- If a `finset` of a subtype is converted to the main type with
1645
1649
`embedding.subtype`, all elements of the result have the property of
1646
1650
the subtype. -/
1647
1651
lemma property_of_mem_map_subtype {p : α → Prop } (s : finset {x // p x}) {a : α}
1648
- (h : a ∈ s.map (function. embedding.subtype _)) : p a :=
1652
+ (h : a ∈ s.map (embedding.subtype _)) : p a :=
1649
1653
begin
1650
1654
rcases mem_map.1 h with ⟨x, hx, rfl⟩,
1651
1655
exact x.2
@@ -1655,14 +1659,14 @@ end
1655
1659
`embedding.subtype`, the result does not contain any value that does
1656
1660
not satisfy the property of the subtype. -/
1657
1661
lemma not_mem_map_subtype_of_not_property {p : α → Prop } (s : finset {x // p x})
1658
- {a : α} (h : ¬ p a) : a ∉ (s.map (function. embedding.subtype _)) :=
1662
+ {a : α} (h : ¬ p a) : a ∉ (s.map (embedding.subtype _)) :=
1659
1663
mt s.property_of_mem_map_subtype h
1660
1664
1661
1665
/-- If a `finset` of a subtype is converted to the main type with
1662
1666
`embedding.subtype`, the result is a subset of the set giving the
1663
1667
subtype. -/
1664
1668
lemma map_subtype_subset {t : set α} (s : finset t) :
1665
- ↑(s.map (function. embedding.subtype _)) ⊆ t :=
1669
+ ↑(s.map (embedding.subtype _)) ⊆ t :=
1666
1670
begin
1667
1671
intros a ha,
1668
1672
rw mem_coe at ha,
@@ -1782,7 +1786,7 @@ theorem card_image_of_inj_on [decidable_eq β] {f : α → β} {s : finset α}
1782
1786
by simp only [card, image_val_of_inj_on H, card_map]
1783
1787
1784
1788
theorem card_image_of_injective [decidable_eq β] {f : α → β} (s : finset α)
1785
- (H : function. injective f) : card (image f s) = card s :=
1789
+ (H : injective f) : card (image f s) = card s :=
1786
1790
card_image_of_inj_on $ λ x _ y _ h, H h
1787
1791
1788
1792
lemma fiber_card_ne_zero_iff_mem_image (s : finset α) (f : α → β) [decidable_eq β] (y : β) :
@@ -1934,7 +1938,7 @@ let f' : {x // x ∈ s} → {x // x ∈ t} := λ x, ⟨f x.1 x.2, hf x.1 x.2⟩
1934
1938
let g : {x // x ∈ t} → {x // x ∈ s} :=
1935
1939
@surj_inv _ _ f'
1936
1940
(λ x, let ⟨y, hy₁, hy₂⟩ := hsurj x.1 x.2 in ⟨⟨y, hy₁⟩, subtype.eq hy₂.symm⟩) in
1937
- have hg : injective g, from function. injective_surj_inv _,
1941
+ have hg : injective g, from injective_surj_inv _,
1938
1942
have hsg : surjective g, from λ x,
1939
1943
let ⟨y, hy⟩ := surj_on_of_inj_on_of_card_le (λ (x : {x // x ∈ t}) (hx : x ∈ t.attach), g x)
1940
1944
(λ x _, show (g x) ∈ s.attach, from mem_attach _ _)
@@ -2094,7 +2098,7 @@ theorem sigma_mono {s₁ s₂ : finset α} {t₁ t₂ : Πa, finset (σ a)}
2094
2098
2095
2099
theorem sigma_eq_bind [decidable_eq (Σ a, σ a)] (s : finset α)
2096
2100
(t : Πa, finset (σ a)) :
2097
- s.sigma t = s.bind (λa, (t a).map $ function. embedding.sigma_mk a) :=
2101
+ s.sigma t = s.bind (λa, (t a).map $ embedding.sigma_mk a) :=
2098
2102
by { ext ⟨x, y⟩, simp [and.left_comm] }
2099
2103
2100
2104
end sigma
0 commit comments