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

Commit 5b294cf

Browse files
committed
feat(data/{finset,set}/basic): A nonempty set of a subsingleton is univ (#16965)
Also provide `nonempty.coe_sort` and `nontrivial.coe_sort` aliases for dot notation.
1 parent 43514e1 commit 5b294cf

File tree

8 files changed

+22
-11
lines changed

8 files changed

+22
-11
lines changed

archive/100-theorems-list/82_cubing_a_cube.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -515,6 +515,6 @@ begin
515515
intros n hn s hfin h2 hd hU hinj,
516516
cases n,
517517
{ cases hn },
518-
exact @not_correct n s coe hfin.to_subtype ((nontrivial_coe _).2 h2)
518+
exact @not_correct n s coe hfin.to_subtype h2.coe_sort
519519
⟨hd.subtype _ _, (Union_subtype _ _).trans hU, hinj.injective, hn⟩
520520
end

src/analysis/normed_space/is_R_or_C.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,5 +98,5 @@ lemma normed_space.sphere_nonempty_is_R_or_C [nontrivial E] {r : ℝ} (hr : 0
9898
nonempty (sphere (0:E) r) :=
9999
begin
100100
letI : normed_space ℝ E := normed_space.restrict_scalars ℝ 𝕜 E,
101-
exact set.nonempty_coe_sort.mpr (normed_space.sphere_nonempty.mpr hr),
101+
exact (normed_space.sphere_nonempty.mpr hr).coe_sort,
102102
end

src/analysis/seminorm.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ noncomputable instance : has_Sup (seminorm 𝕜 E) :=
417417
rcases h with ⟨q, hq⟩,
418418
obtain rfl | h := s.eq_empty_or_nonempty,
419419
{ simp [real.csupr_empty] },
420-
haveI : nonempty ↥s := nonempty_coe_sort.mpr h,
420+
haveI : nonempty ↥s := h.coe_sort,
421421
simp only [supr_apply],
422422
refine csupr_le (λ i, ((i : seminorm 𝕜 E).add_le' x y).trans $
423423
add_le_add (le_csupr ⟨q x, _⟩ i) (le_csupr ⟨q y, _⟩ i));
@@ -465,7 +465,7 @@ private lemma seminorm.is_lub_Sup (s : set (seminorm 𝕜 E)) (hs₁ : bdd_above
465465
is_lub s (Sup s) :=
466466
begin
467467
refine ⟨λ p hp x, _, λ p hp x, _⟩;
468-
haveI : nonempty ↥s := nonempty_coe_sort.mpr hs₂;
468+
haveI : nonempty ↥s := hs₂.coe_sort;
469469
rw [seminorm.coe_Sup_eq hs₁, supr_apply],
470470
{ rcases hs₁ with ⟨q, hq⟩,
471471
exact le_csupr ⟨q x, forall_range_iff.mpr $ λ i : s, hq i.2 x⟩ ⟨p, hp⟩ },

src/data/finset/basic.lean

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,7 @@ decidable_of_iff (∃ a ∈ s, true) $ by simp_rw [exists_prop, and_true, finset
339339
@[simp] lemma nonempty_coe_sort {s : finset α} : nonempty ↥s ↔ s.nonempty := nonempty_subtype
340340

341341
alias coe_nonempty ↔ _ nonempty.to_set
342+
alias nonempty_coe_sort ↔ _ nonempty.coe_sort
342343

343344
lemma nonempty.bex {s : finset α} (h : s.nonempty) : ∃ x : α, x ∈ s := h
344345

@@ -918,7 +919,7 @@ lemma _root_.directed_on.exists_mem_subset_of_finset_subset_bUnion {α ι : Type
918919
{s : finset α} (hs : (s : set α) ⊆ ⋃ i ∈ c, f i) : ∃ i ∈ c, (s : set α) ⊆ f i :=
919920
begin
920921
rw set.bUnion_eq_Union at hs,
921-
haveI := set.nonempty_coe_sort.2 hn,
922+
haveI := hn.coe_sort,
922923
obtain ⟨⟨i, hic⟩, hi⟩ :=
923924
(directed_comp.2 hc.directed_coe).exists_mem_subset_of_finset_subset_bUnion hs,
924925
exact ⟨i, hic, hi⟩

src/data/fintype/basic.lean

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,9 @@ lemma eq_univ_of_forall : (∀ x, x ∈ s) → s = univ := eq_univ_iff_forall.2
103103
@[simp, norm_cast] lemma coe_eq_univ : (s : set α) = set.univ ↔ s = univ :=
104104
by rw [←coe_univ, coe_inj]
105105

106+
lemma nonempty.eq_univ [subsingleton α] : s.nonempty → s = univ :=
107+
by { rintro ⟨x, hx⟩, refine eq_univ_of_forall (λ y, by rwa subsingleton.elim y x) }
108+
106109
lemma univ_nonempty_iff : (univ : finset α).nonempty ↔ nonempty α :=
107110
by rw [← coe_nonempty, coe_univ, set.nonempty_iff_univ_nonempty]
108111

src/data/set/basic.lean

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,8 @@ protected def nonempty (s : set α) : Prop := ∃ x, x ∈ s
289289

290290
@[simp] lemma nonempty_coe_sort {s : set α} : nonempty ↥s ↔ s.nonempty := nonempty_subtype
291291

292+
alias nonempty_coe_sort ↔ _ nonempty.coe_sort
293+
292294
lemma nonempty_def : s.nonempty ↔ ∃ x, x ∈ s := iff.rfl
293295

294296
lemma nonempty_of_mem {x} (h : x ∈ s) : s.nonempty := ⟨x, h⟩
@@ -433,6 +435,9 @@ univ_subset_iff.symm.trans $ forall_congr $ λ x, imp_iff_right trivial
433435

434436
theorem eq_univ_of_forall {s : set α} : (∀ x, x ∈ s) → s = univ := eq_univ_iff_forall.2
435437

438+
lemma nonempty.eq_univ [subsingleton α] : s.nonempty → s = univ :=
439+
by { rintro ⟨x, hx⟩, refine eq_univ_of_forall (λ y, by rwa subsingleton.elim y x) }
440+
436441
lemma eq_univ_of_subset {s t : set α} (h : s ⊆ t) (hs : s = univ) : t = univ :=
437442
eq_univ_of_univ_subset $ hs ▸ h
438443

@@ -1930,17 +1935,19 @@ lemma nontrivial_of_nontrivial (hs : s.nontrivial) : nontrivial α :=
19301935
let ⟨x, _, y, _, hxy⟩ := hs in ⟨⟨x, y, hxy⟩⟩
19311936

19321937
/-- `s`, coerced to a type, is a nontrivial type if and only if `s` is a nontrivial set. -/
1933-
@[simp, norm_cast] lemma nontrivial_coe (s : set α) : nontrivial s ↔ s.nontrivial :=
1938+
@[simp, norm_cast] lemma nontrivial_coe_sort {s : set α} : nontrivial s ↔ s.nontrivial :=
19341939
by simp_rw [← nontrivial_univ_iff, set.nontrivial, mem_univ,
19351940
exists_true_left, set_coe.exists, subtype.mk_eq_mk]
19361941

1942+
alias nontrivial_coe_sort ↔ _ nontrivial.coe_sort
1943+
19371944
/-- A type with a set `s` whose `coe_sort` is a nontrivial type is nontrivial.
19381945
For the corresponding result for `subtype`, see `subtype.nontrivial_iff_exists_ne`. -/
19391946
lemma nontrivial_of_nontrivial_coe (hs : nontrivial s) : nontrivial α :=
1940-
by { rw [s.nontrivial_coe] at hs, exact nontrivial_of_nontrivial hs }
1947+
nontrivial_of_nontrivial $ nontrivial_coe_sort.1 hs
19411948

19421949
theorem nontrivial_mono {α : Type*} {s t : set α} (hst : s ⊆ t) (hs : nontrivial s) :
1943-
nontrivial t := (nontrivial_coe _).2 $ (s.nontrivial_coe.1 hs).mono hst
1950+
nontrivial t := nontrivial.coe_sort $ (nontrivial_coe_sort.1 hs).mono hst
19441951

19451952
/-- The preimage of a nontrivial set under a surjective map is nontrivial. -/
19461953
theorem nontrivial.preimage {s : set β} (hs : s.nontrivial) {f : α → β}

src/measure_theory/function/jacobian.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ begin
220220
{ rcases hs with ⟨x, xs⟩,
221221
rcases s_subset x xs with ⟨n, z, hnz⟩,
222222
exact false.elim z.2 },
223-
{ exact nonempty_coe_sort.2 hT } },
223+
{ exact hT.coe_sort } },
224224
inhabit (ℕ × T × ℕ),
225225
exact ⟨_, encodable.surjective_decode_iget _⟩ },
226226
-- these sets `t q = K n z p` will do

src/topology/algebra/semigroup.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ that this holds for all `m' ∈ N`. -/
5555
λ s hs, set.sInter_subset_of_mem hs⟩,
5656
{ obtain rfl | hcnemp := c.eq_empty_or_nonempty,
5757
{ rw set.sInter_empty, apply set.univ_nonempty },
58-
convert @is_compact.nonempty_Inter_of_directed_nonempty_compact_closed _ _ _
59-
(set.nonempty_coe_sort.mpr hcnemp) (coe : c → set M) _ _ _ _,
58+
convert @is_compact.nonempty_Inter_of_directed_nonempty_compact_closed _ _ _ hcnemp.coe_sort
59+
(coe : c → set M) _ _ _ _,
6060
{ simp only [subtype.range_coe_subtype, set.set_of_mem_eq] } ,
6161
{ refine directed_on.directed_coe (is_chain.directed_on hc.symm) },
6262
exacts [λ i, (hcs i.prop).2.1, λ i, (hcs i.prop).1.is_compact, λ i, (hcs i.prop).1] },

0 commit comments

Comments
 (0)