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

Commit d351cfe

Browse files
committed
feat(data/finset): sup_eq_bind (#5717)
`finset.sup s f` is equal to `finset.bind s f` when `f : α → finset β` is an indexed family of finite sets. This is a proof of that with a couple supporting lemmas. (There might be a more direct proof through the definitions of `sup` and `bind`, which are eventually in terms of `multiset.foldr`.) I also moved `finset.mem_sup` to `multiset.mem_sup` and gave a new `finset.mem_sup` for indexed families of `finset`, where the old one was for indexed families of `multiset`.
1 parent 3ac4bb2 commit d351cfe

File tree

3 files changed

+51
-24
lines changed

3 files changed

+51
-24
lines changed

src/data/finset/basic.lean

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1414,6 +1414,13 @@ by simp only [finset.subset_iff, multiset.subset_iff, multiset.mem_to_finset]
14141414

14151415
end multiset
14161416

1417+
namespace finset
1418+
1419+
@[simp] lemma val_to_finset [decidable_eq α] (s : finset α) : s.val.to_finset = s :=
1420+
by { ext, rw [multiset.mem_to_finset, ←mem_def] }
1421+
1422+
end finset
1423+
14171424
namespace list
14181425
variable [decidable_eq α]
14191426

src/data/finset/lattice.lean

Lines changed: 43 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -86,35 +86,17 @@ lemma sup_coe {P : α → Prop}
8686
(@sup _ _ (subtype.semilattice_sup_bot Pbot Psup) t f : α) = t.sup (λ x, f x) :=
8787
by { classical, rw [comp_sup_eq_sup_comp coe]; intros; refl }
8888

89+
@[simp] lemma sup_to_finset {α β} [decidable_eq β]
90+
(s : finset α) (f : α → multiset β) :
91+
(s.sup f).to_finset = s.sup (λ x, (f x).to_finset) :=
92+
comp_sup_eq_sup_comp multiset.to_finset to_finset_union rfl
93+
8994
theorem subset_range_sup_succ (s : finset ℕ) : s ⊆ range (s.sup id).succ :=
9095
λ n hn, mem_range.2 $ nat.lt_succ_of_le $ le_sup hn
9196

9297
theorem exists_nat_subset_range (s : finset ℕ) : ∃n : ℕ, s ⊆ range n :=
9398
⟨_, s.subset_range_sup_succ⟩
9499

95-
lemma mem_sup {α β} [decidable_eq β] {s : finset α} {f : α → multiset β}
96-
{x : β} : x ∈ s.sup f ↔ ∃ v ∈ s, x ∈ f v :=
97-
begin
98-
classical,
99-
apply s.induction_on,
100-
{ simp },
101-
{ intros a s has hxs,
102-
rw [finset.sup_insert, multiset.sup_eq_union, multiset.mem_union],
103-
split,
104-
{ intro hxi,
105-
cases hxi with hf hf,
106-
{ refine ⟨a, _, hf⟩,
107-
simp only [true_or, eq_self_iff_true, finset.mem_insert] },
108-
{ rcases hxs.mp hf with ⟨v, hv, hfv⟩,
109-
refine ⟨v, _, hfv⟩,
110-
simp only [hv, or_true, finset.mem_insert] } },
111-
{ rintros ⟨v, hv, hfv⟩,
112-
rw [finset.mem_insert] at hv,
113-
rcases hv with rfl | hv,
114-
{ exact or.inl hfv },
115-
{ refine or.inr (hxs.mpr ⟨v, hv, hfv⟩) } } },
116-
end
117-
118100
lemma sup_subset {α β} [semilattice_sup_bot β] {s t : finset α} (hst : s ⊆ t) (f : α → β) :
119101
s.sup f ≤ t.sup f :=
120102
by classical;
@@ -432,8 +414,46 @@ begin
432414
refl }
433415
end
434416

417+
lemma mem_sup {α β} [decidable_eq β] {s : finset α} {f : α → multiset β}
418+
{x : β} : x ∈ s.sup f ↔ ∃ v ∈ s, x ∈ f v :=
419+
begin
420+
classical,
421+
apply s.induction_on,
422+
{ simp },
423+
{ intros a s has hxs,
424+
rw [finset.sup_insert, multiset.sup_eq_union, multiset.mem_union],
425+
split,
426+
{ intro hxi,
427+
cases hxi with hf hf,
428+
{ refine ⟨a, _, hf⟩,
429+
simp only [true_or, eq_self_iff_true, finset.mem_insert] },
430+
{ rcases hxs.mp hf with ⟨v, hv, hfv⟩,
431+
refine ⟨v, _, hfv⟩,
432+
simp only [hv, or_true, finset.mem_insert] } },
433+
{ rintros ⟨v, hv, hfv⟩,
434+
rw [finset.mem_insert] at hv,
435+
rcases hv with rfl | hv,
436+
{ exact or.inl hfv },
437+
{ refine or.inr (hxs.mpr ⟨v, hv, hfv⟩) } } },
438+
end
439+
435440
end multiset
436441

442+
namespace finset
443+
444+
lemma mem_sup {α β} [decidable_eq β] {s : finset α} {f : α → finset β}
445+
{x : β} : x ∈ s.sup f ↔ ∃ v ∈ s, x ∈ f v :=
446+
begin
447+
change _ ↔ ∃ v ∈ s, x ∈ (f v).val,
448+
rw [←multiset.mem_sup, ←multiset.mem_to_finset, sup_to_finset],
449+
simp_rw [val_to_finset],
450+
end
451+
452+
lemma sup_eq_bind {α β} [decidable_eq β] (s : finset α) (t : α → finset β) :
453+
s.sup t = s.bind t :=
454+
by { ext, rw [mem_sup, mem_bind], }
455+
456+
end finset
437457

438458
section lattice
439459
variables {ι : Type*} {ι' : Sort*} [complete_lattice α]

src/data/mv_polynomial/variables.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ lemma degrees_pow (p : mv_polynomial σ R) :
152152

153153
lemma mem_degrees {p : mv_polynomial σ R} {i : σ} :
154154
i ∈ p.degrees ↔ ∃ d, p.coeff d ≠ 0 ∧ i ∈ d.support :=
155-
by simp only [degrees, finset.mem_sup, ← finsupp.mem_support_iff, coeff,
155+
by simp only [degrees, multiset.mem_sup, ← finsupp.mem_support_iff, coeff,
156156
finsupp.mem_to_multiset, exists_prop]
157157

158158
lemma le_degrees_add {p q : mv_polynomial σ R} (h : p.degrees.disjoint q.degrees) :

0 commit comments

Comments
 (0)