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

Commit afbf47d

Browse files
author
Oliver Nash
committed
feat(data/*, order/*) supporting lemmas for characterising well-founded complete lattices (#5446)
1 parent 2434023 commit afbf47d

File tree

6 files changed

+67
-0
lines changed

6 files changed

+67
-0
lines changed

src/data/finset/basic.lean

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,9 @@ exists_mem_of_ne_zero (mt val_eq_zero.1 h)
204204
theorem nonempty_iff_ne_empty {s : finset α} : s.nonempty ↔ s ≠ ∅ :=
205205
⟨nonempty.ne_empty, nonempty_of_ne_empty⟩
206206

207+
@[simp] theorem not_nonempty_iff_eq_empty {s : finset α} : ¬s.nonempty ↔ s = ∅ :=
208+
by { rw nonempty_iff_ne_empty, exact not_not, }
209+
207210
theorem eq_empty_or_nonempty (s : finset α) : s = ∅ ∨ s.nonempty :=
208211
classical.by_cases or.inl (λ h, or.inr (nonempty_of_ne_empty h))
209212

@@ -249,6 +252,15 @@ begin
249252
refine ⟨t.right _, λ r, r.symm ▸ t.left⟩
250253
end
251254

255+
lemma eq_singleton_iff_nonempty_unique_mem {s : finset α} {a : α} :
256+
s = {a} ↔ s.nonempty ∧ ∀ x ∈ s, x = a :=
257+
begin
258+
split,
259+
{ intros h, subst h, simp, },
260+
{ rintros ⟨hne, h_uniq⟩, rw eq_singleton_iff_unique_mem, refine ⟨_, h_uniq⟩,
261+
rw ← h_uniq hne.some hne.some_spec, apply hne.some_spec, },
262+
end
263+
252264
lemma singleton_iff_unique_mem (s : finset α) : (∃ a, s = {a}) ↔ ∃! a, a ∈ s :=
253265
by simp only [eq_singleton_iff_unique_mem, exists_unique]
254266

src/data/finset/lattice.lean

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ Author: Mario Carneiro
66
import data.finset.fold
77
import data.multiset.lattice
88
import order.order_dual
9+
import order.complete_lattice
910

1011
/-!
1112
# Lattice operations on finsets
@@ -121,13 +122,28 @@ calc t.sup f = (s ∪ t).sup f : by rw [finset.union_eq_right_iff_subset.mpr hst
121122
... = s.sup f ⊔ t.sup f : by rw finset.sup_union
122123
... ≥ s.sup f : le_sup_left
123124

125+
lemma sup_closed_of_sup_closed {s : set α} (t : finset α) (htne : t.nonempty) (h_subset : ↑t ⊆ s)
126+
(h : ∀⦃a b⦄, a ∈ s → b ∈ s → a ⊔ b ∈ s) : t.sup id ∈ s :=
127+
begin
128+
classical,
129+
induction t using finset.induction_on with x t h₀ h₁,
130+
{ exfalso, apply finset.not_nonempty_empty htne, },
131+
{ rw [finset.coe_insert, set.insert_subset] at h_subset,
132+
cases t.eq_empty_or_nonempty with hte htne,
133+
{ subst hte, simp only [insert_emptyc_eq, id.def, finset.sup_singleton, h_subset], },
134+
{ rw [finset.sup_insert, id.def], exact h h_subset.1 (h₁ htne h_subset.2), }, },
135+
end
136+
124137
end sup
125138

126139
lemma sup_eq_supr [complete_lattice β] (s : finset α) (f : α → β) : s.sup f = (⨆a∈s, f a) :=
127140
le_antisymm
128141
(finset.sup_le $ assume a ha, le_supr_of_le a $ le_supr _ ha)
129142
(supr_le $ assume a, supr_le $ assume ha, le_sup ha)
130143

144+
lemma sup_eq_Sup [complete_lattice α] (s : finset α) : s.sup id = Sup s :=
145+
by simp [Sup_eq_supr, sup_eq_supr]
146+
131147
/-! ### inf -/
132148
section inf
133149
variables [semilattice_inf_top α]
@@ -193,6 +209,9 @@ end inf
193209
lemma inf_eq_infi [complete_lattice β] (s : finset α) (f : α → β) : s.inf f = (⨅a∈s, f a) :=
194210
@sup_eq_supr _ (order_dual β) _ _ _
195211

212+
lemma inf_eq_Inf [complete_lattice α] (s : finset α) : s.inf id = Inf s :=
213+
by simp [Inf_eq_infi, inf_eq_infi]
214+
196215
/-! ### max and min of finite sets -/
197216
section max_min
198217
variables [linear_order α]

src/data/set/basic.lean

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -753,6 +753,15 @@ lemma eq_singleton_iff_unique_mem {s : set α} {a : α} :
753753
s = {a} ↔ a ∈ s ∧ ∀ x ∈ s, x = a :=
754754
by simp [ext_iff, @iff_def (_ ∈ s), forall_and_distrib, and_comm]
755755

756+
lemma eq_singleton_iff_nonempty_unique_mem {s : set α} {a : α} :
757+
s = {a} ↔ s.nonempty ∧ ∀ x ∈ s, x = a :=
758+
begin
759+
split,
760+
{ intros h, subst h, simp, },
761+
{ rintros ⟨hne, h_uniq⟩, rw eq_singleton_iff_unique_mem, refine ⟨_, h_uniq⟩,
762+
rw ← h_uniq hne.some hne.some_spec, apply hne.some_spec, },
763+
end
764+
756765
/-! ### Lemmas about sets defined as `{x ∈ s | p x}`. -/
757766

758767
theorem mem_sep {s : set α} {p : α → Prop} {x : α} (xs : x ∈ s) (px : p x) : x ∈ {x ∈ s | p x} :=

src/data/set/finite.lean

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,9 @@ theorem finite.preimage {s : set β} {f : α → β}
309309
(I : set.inj_on f (f⁻¹' s)) (h : finite s) : finite (f ⁻¹' s) :=
310310
finite_of_finite_image I (h.subset (image_preimage_subset f s))
311311

312+
theorem finite.preimage_embedding {s : set β} (f : α ↪ β) (h : s.finite) : (f ⁻¹' s).finite :=
313+
finite.preimage (λ _ _ _ _ h', f.injective h') h
314+
312315
instance fintype_Union [decidable_eq α] {ι : Type*} [fintype ι]
313316
(f : ι → set α) [∀ i, fintype (f i)] : fintype (⋃ i, f i) :=
314317
fintype.of_finset (finset.univ.bind (λ i, (f i).to_finset)) $ by simp

src/order/complete_lattice.lean

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,9 +266,17 @@ iff.intro
266266
(assume h a ha, top_unique $ h ▸ Inf_le ha)
267267
(assume h, top_unique $ le_Inf $ assume a ha, top_le_iff.2 $ h a ha)
268268

269+
lemma eq_singleton_top_of_Inf_eq_top_of_nonempty {s : set α}
270+
(h_inf : Inf s = ⊤) (hne : s.nonempty) : s = {⊤} :=
271+
by { rw set.eq_singleton_iff_nonempty_unique_mem, rw Inf_eq_top at h_inf, exact ⟨hne, h_inf⟩, }
272+
269273
@[simp] theorem Sup_eq_bot : Sup s = ⊥ ↔ (∀a∈s, a = ⊥) :=
270274
@Inf_eq_top (order_dual α) _ _
271275

276+
lemma eq_singleton_bot_of_Sup_eq_bot_of_nonempty {s : set α}
277+
(h_sup : Sup s = ⊥) (hne : s.nonempty) : s = {⊥} :=
278+
by { rw set.eq_singleton_iff_nonempty_unique_mem, rw Sup_eq_bot at h_sup, exact ⟨hne, h_sup⟩, }
279+
272280
end
273281

274282
section complete_linear_order

src/order/rel_iso.lean

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,22 @@ end
7979
protected theorem well_founded : ∀ (f : r →r s) (h : well_founded s), well_founded r
8080
| f ⟨H⟩ := ⟨λ a, f.acc _ (H _)⟩
8181

82+
lemma map_inf {α β : Type*} [semilattice_inf α] [linear_order β]
83+
(a : ((<) : β → β → Prop) →r ((<) : α → α → Prop)) (m n : β) : a (m ⊓ n) = a m ⊓ a n :=
84+
begin
85+
symmetry, cases le_or_lt n m with h,
86+
{ rw [inf_eq_right.mpr h, inf_eq_right], exact strict_mono.monotone (λ x y, a.map_rel) h, },
87+
{ rw [inf_eq_left.mpr (le_of_lt h), inf_eq_left], exact le_of_lt (a.map_rel h), },
88+
end
89+
90+
lemma map_sup {α β : Type*} [semilattice_sup α] [linear_order β]
91+
(a : ((>) : β → β → Prop) →r ((>) : α → α → Prop)) (m n : β) : a (m ⊔ n) = a m ⊔ a n :=
92+
begin
93+
symmetry, cases le_or_lt m n with h,
94+
{ rw [sup_eq_right.mpr h, sup_eq_right], exact strict_mono.monotone (λ x y, a.swap.map_rel) h, },
95+
{ rw [sup_eq_left.mpr (le_of_lt h), sup_eq_left], exact le_of_lt (a.map_rel h), },
96+
end
97+
8298
end rel_hom
8399

84100
/-- An increasing function is injective -/

0 commit comments

Comments
 (0)