@@ -4,6 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
44Authors: Yaël Dillies
55-/
66import data.finset.n_ary
7+ import data.set.sups
78
89/-!
910# Set family operations
@@ -12,16 +13,16 @@ This file defines a few binary operations on `finset α` for use in set family c
1213
1314## Main declarations
1415
15- * `finset.sups s t`: Finset of elements of the form `a ⊔ b` where `a ∈ s`, `b ∈ t`.
16- * `finset.infs s t`: Finset of elements of the form `a ⊓ b` where `a ∈ s`, `b ∈ t`.
16+ * `s ⊻ t`: Finset of elements of the form `a ⊔ b` where `a ∈ s`, `b ∈ t`.
17+ * `s ⊼ t`: Finset of elements of the form `a ⊓ b` where `a ∈ s`, `b ∈ t`.
1718* `finset.disj_sups s t`: Finset of elements of the form `a ⊔ b` where `a ∈ s`, `b ∈ t` and `a`
1819 and `b` are disjoint.
1920
2021 ## Notation
2122
2223We define the following notation in locale `finset_family`:
23- * `s ⊻ t` for `finset.sups s t`
24- * `s ⊼ t` for `finset.infs s t`
24+ * `s ⊻ t`
25+ * `s ⊼ t`
2526* `s ○ t` for `finset.disj_sups s t`
2627
2728 ## References
@@ -30,25 +31,26 @@ We define the following notation in locale `finset_family`:
3031-/
3132
3233open function
34+ open_locale set_family
3335
3436variables {α : Type *} [decidable_eq α]
3537
3638namespace finset
3739section sups
38- variables [semilattice_sup α] (s s₁ s₂ t t₁ t₂ u : finset α)
40+ variables [semilattice_sup α] (s s₁ s₂ t t₁ t₂ u v : finset α)
3941
40- /-- The finset of elements of the form `a ⊔ b` where `a ∈ s`, `b ∈ t`. -/
41- def sups (s t : finset α) : finset α := image₂ (⊔) s t
42+ /-- `s ⊻ t` is the finset of elements of the form `a ⊔ b` where `a ∈ s`, `b ∈ t`. -/
43+ protected def has_sups : has_sups ( finset α) := ⟨ image₂ (⊔)⟩
4244
43- localized " infix (name := finset.sups) ` ⊻ `:74 := finset.sups " in finset_family
45+ localized " attribute [instance] finset.has_sups " in finset_family
4446
4547variables {s t} {a b c : α}
4648
47- @[simp] lemma mem_sups : c ∈ s ⊻ t ↔ ∃ (a ∈ s) (b ∈ t), a ⊔ b = c := by simp [sups ]
49+ @[simp] lemma mem_sups : c ∈ s ⊻ t ↔ ∃ (a ∈ s) (b ∈ t), a ⊔ b = c := by simp [(⊻) ]
4850
4951variables (s t)
5052
51- @[simp, norm_cast] lemma coe_sups : (s ⊻ t : set α) = set.image2 (⊔) s t := coe_image₂ _ _ _
53+ @[simp, norm_cast] lemma coe_sups : (↑( s ⊻ t) : set α) = s ⊻ t := coe_image₂ _ _ _
5254
5355lemma card_sups_le : (s ⊻ t).card ≤ s.card * t.card := card_image₂_le _ _ _
5456
@@ -63,29 +65,28 @@ lemma sups_subset : s₁ ⊆ s₂ → t₁ ⊆ t₂ → s₁ ⊻ t₁ ⊆ s₂
6365lemma sups_subset_left : t₁ ⊆ t₂ → s ⊻ t₁ ⊆ s ⊻ t₂ := image₂_subset_left
6466lemma sups_subset_right : s₁ ⊆ s₂ → s₁ ⊻ t ⊆ s₂ ⊻ t := image₂_subset_right
6567
66- lemma image_subset_sups_left : b ∈ t → (λ a, a ⊔ b) '' s ⊆ s ⊻ t := image_subset_image₂_left
67- lemma image_subset_sups_right : a ∈ s → ( ⊔) a '' t ⊆ s ⊻ t := image_subset_image₂_right
68+ lemma image_subset_sups_left : b ∈ t → s.image (λ a, a ⊔ b) ⊆ s ⊻ t := image_subset_image₂_left
69+ lemma image_subset_sups_right : a ∈ s → t.image (( ⊔) a) ⊆ s ⊻ t := image_subset_image₂_right
6870
6971lemma forall_sups_iff {p : α → Prop } : (∀ c ∈ s ⊻ t, p c) ↔ ∀ (a ∈ s) (b ∈ t), p (a ⊔ b) :=
7072forall_image₂_iff
7173
7274@[simp] lemma sups_subset_iff : s ⊻ t ⊆ u ↔ ∀ (a ∈ s) (b ∈ t), a ⊔ b ∈ u := image₂_subset_iff
7375
74- @[simp] lemma sups_nonempty_iff : (s ⊻ t).nonempty ↔ s.nonempty ∧ t.nonempty := image₂_nonempty_iff
76+ @[simp] lemma sups_nonempty : (s ⊻ t).nonempty ↔ s.nonempty ∧ t.nonempty := image₂_nonempty_iff
7577
76- lemma nonempty.sups : s.nonempty → t.nonempty → (s ⊻ t).nonempty := nonempty.image₂
78+ protected lemma nonempty.sups : s.nonempty → t.nonempty → (s ⊻ t).nonempty := nonempty.image₂
7779lemma nonempty.of_sups_left : (s ⊻ t).nonempty → s.nonempty := nonempty.of_image₂_left
7880lemma nonempty.of_sups_right : (s ⊻ t).nonempty → t.nonempty := nonempty.of_image₂_right
7981
80- @[simp] lemma sups_empty_left : ∅ ⊻ t = ∅ := image₂_empty_left
81- @[simp] lemma sups_empty_right : s ⊻ ∅ = ∅ := image₂_empty_right
82- @[simp] lemma sups_eq_empty_iff : s ⊻ t = ∅ ↔ s = ∅ ∨ t = ∅ := image₂_eq_empty_iff
82+ @[simp] lemma empty_sups : ∅ ⊻ t = ∅ := image₂_empty_left
83+ @[simp] lemma sups_empty : s ⊻ ∅ = ∅ := image₂_empty_right
84+ @[simp] lemma sups_eq_empty : s ⊻ t = ∅ ↔ s = ∅ ∨ t = ∅ := image₂_eq_empty_iff
8385
84- @[simp] lemma sups_singleton_left : {a} ⊻ t = t.image (λ b, a ⊔ b) := image₂_singleton_left
85- @[simp] lemma sups_singleton_right : s ⊻ {b} = s.image (λ a, a ⊔ b) := image₂_singleton_right
86- lemma sups_singleton_left' : {a} ⊻ t = t.image ((⊔) a) := image₂_singleton_left'
86+ @[simp] lemma singleton_sups : {a} ⊻ t = t.image (λ b, a ⊔ b) := image₂_singleton_left
87+ @[simp] lemma sups_singleton : s ⊻ {b} = s.image (λ a, a ⊔ b) := image₂_singleton_right
8788
88- lemma sups_singleton : ({a} ⊻ {b} : finset α) = {a ⊔ b} := image₂_singleton
89+ lemma singleton_sups_singleton : ({a} ⊻ {b} : finset α) = {a ⊔ b} := image₂_singleton
8990
9091lemma sups_union_left : (s₁ ∪ s₂) ⊻ t = s₁ ⊻ t ∪ s₂ ⊻ t := image₂_union_left
9192lemma sups_union_right : s ⊻ (t₁ ∪ t₂) = s ⊻ t₁ ∪ s ⊻ t₂ := image₂_union_right
@@ -94,10 +95,10 @@ lemma sups_inter_subset_left : (s₁ ∩ s₂) ⊻ t ⊆ s₁ ⊻ t ∩ s₂ ⊻
9495lemma sups_inter_subset_right : s ⊻ (t₁ ∩ t₂) ⊆ s ⊻ t₁ ∩ s ⊻ t₂ := image₂_inter_subset_right
9596
9697lemma subset_sups {s t : set α} :
97- ↑u ⊆ set.image2 (⊔) s t → ∃ s' t' : finset α, ↑s' ⊆ s ∧ ↑t' ⊆ t ∧ u ⊆ s' ⊻ t' :=
98+ ↑u ⊆ s ⊻ t → ∃ s' t' : finset α, ↑s' ⊆ s ∧ ↑t' ⊆ t ∧ u ⊆ s' ⊻ t' :=
9899subset_image₂
99100
100- variables (s t u)
101+ variables (s t u v )
101102
102103lemma bUnion_image_sup_left : s.bUnion (λ a, t.image $ (⊔) a) = s ⊻ t := bUnion_image_left
103104lemma bUnion_image_sup_right : t.bUnion (λ b, s.image $ λ a, a ⊔ b) = s ⊻ t := bUnion_image_right
@@ -109,24 +110,26 @@ lemma sups_assoc : (s ⊻ t) ⊻ u = s ⊻ (t ⊻ u) := image₂_assoc $ λ _ _
109110lemma sups_comm : s ⊻ t = t ⊻ s := image₂_comm $ λ _ _, sup_comm
110111lemma sups_left_comm : s ⊻ (t ⊻ u) = t ⊻ (s ⊻ u) := image₂_left_comm sup_left_comm
111112lemma sups_right_comm : (s ⊻ t) ⊻ u = (s ⊻ u) ⊻ t := image₂_right_comm sup_right_comm
113+ lemma sups_sups_sups_comm : (s ⊻ t) ⊻ (u ⊻ v) = (s ⊻ u) ⊻ (t ⊻ v) :=
114+ image₂_image₂_image₂_comm sup_sup_sup_comm
112115
113116end sups
114117
115118section infs
116- variables [semilattice_inf α] (s s₁ s₂ t t₁ t₂ u : finset α)
119+ variables [semilattice_inf α] (s s₁ s₂ t t₁ t₂ u v : finset α)
117120
118- /-- The finset of elements of the form `a ⊓ b` where `a ∈ s`, `b ∈ t`. -/
119- def infs (s t : finset α) : finset α := image₂ (⊓) s t
121+ /-- `s ⊼ t` is the finset of elements of the form `a ⊓ b` where `a ∈ s`, `b ∈ t`. -/
122+ protected def has_infs : has_infs ( finset α) := ⟨ image₂ (⊓)⟩
120123
121- localized " infix (name := finset.infs) ` ⊼ `:74 := finset.infs " in finset_family
124+ localized " attribute [instance] finset.has_infs " in finset_family
122125
123126variables {s t} {a b c : α}
124127
125- @[simp] lemma mem_infs : c ∈ s ⊼ t ↔ ∃ (a ∈ s) (b ∈ t), a ⊓ b = c := by simp [infs ]
128+ @[simp] lemma mem_infs : c ∈ s ⊼ t ↔ ∃ (a ∈ s) (b ∈ t), a ⊓ b = c := by simp [(⊼) ]
126129
127130variables (s t)
128131
129- @[simp, norm_cast] lemma coe_infs : (s ⊼ t : set α) = set.image2 (⊓) s t := coe_image₂ _ _ _
132+ @[simp, norm_cast] lemma coe_infs : (↑( s ⊼ t) : set α) = s ⊼ t := coe_image₂ _ _ _
130133
131134lemma card_infs_le : (s ⊼ t).card ≤ s.card * t.card := card_image₂_le _ _ _
132135
@@ -141,29 +144,28 @@ lemma infs_subset : s₁ ⊆ s₂ → t₁ ⊆ t₂ → s₁ ⊼ t₁ ⊆ s₂
141144lemma infs_subset_left : t₁ ⊆ t₂ → s ⊼ t₁ ⊆ s ⊼ t₂ := image₂_subset_left
142145lemma infs_subset_right : s₁ ⊆ s₂ → s₁ ⊼ t ⊆ s₂ ⊼ t := image₂_subset_right
143146
144- lemma image_subset_infs_left : b ∈ t → (λ a, a ⊓ b) '' s ⊆ s ⊼ t := image_subset_image₂_left
145- lemma image_subset_infs_right : a ∈ s → ( ⊓) a '' t ⊆ s ⊼ t := image_subset_image₂_right
147+ lemma image_subset_infs_left : b ∈ t → s.image (λ a, a ⊓ b) ⊆ s ⊼ t := image_subset_image₂_left
148+ lemma image_subset_infs_right : a ∈ s → t.image (( ⊓) a) ⊆ s ⊼ t := image_subset_image₂_right
146149
147150lemma forall_infs_iff {p : α → Prop } : (∀ c ∈ s ⊼ t, p c) ↔ ∀ (a ∈ s) (b ∈ t), p (a ⊓ b) :=
148151forall_image₂_iff
149152
150153@[simp] lemma infs_subset_iff : s ⊼ t ⊆ u ↔ ∀ (a ∈ s) (b ∈ t), a ⊓ b ∈ u := image₂_subset_iff
151154
152- @[simp] lemma infs_nonempty_iff : (s ⊼ t).nonempty ↔ s.nonempty ∧ t.nonempty := image₂_nonempty_iff
155+ @[simp] lemma infs_nonempty : (s ⊼ t).nonempty ↔ s.nonempty ∧ t.nonempty := image₂_nonempty_iff
153156
154- lemma nonempty.infs : s.nonempty → t.nonempty → (s ⊼ t).nonempty := nonempty.image₂
157+ protected lemma nonempty.infs : s.nonempty → t.nonempty → (s ⊼ t).nonempty := nonempty.image₂
155158lemma nonempty.of_infs_left : (s ⊼ t).nonempty → s.nonempty := nonempty.of_image₂_left
156159lemma nonempty.of_infs_right : (s ⊼ t).nonempty → t.nonempty := nonempty.of_image₂_right
157160
158- @[simp] lemma infs_empty_left : ∅ ⊼ t = ∅ := image₂_empty_left
159- @[simp] lemma infs_empty_right : s ⊼ ∅ = ∅ := image₂_empty_right
160- @[simp] lemma infs_eq_empty_iff : s ⊼ t = ∅ ↔ s = ∅ ∨ t = ∅ := image₂_eq_empty_iff
161+ @[simp] lemma empty_infs : ∅ ⊼ t = ∅ := image₂_empty_left
162+ @[simp] lemma infs_empty : s ⊼ ∅ = ∅ := image₂_empty_right
163+ @[simp] lemma infs_eq_empty : s ⊼ t = ∅ ↔ s = ∅ ∨ t = ∅ := image₂_eq_empty_iff
161164
162- @[simp] lemma infs_singleton_left : {a} ⊼ t = t.image (λ b, a ⊓ b) := image₂_singleton_left
163- @[simp] lemma infs_singleton_right : s ⊼ {b} = s.image (λ a, a ⊓ b) := image₂_singleton_right
164- lemma infs_singleton_left' : {a} ⊼ t = t.image ((⊓) a) := image₂_singleton_left'
165+ @[simp] lemma singleton_infs : {a} ⊼ t = t.image (λ b, a ⊓ b) := image₂_singleton_left
166+ @[simp] lemma infs_singleton : s ⊼ {b} = s.image (λ a, a ⊓ b) := image₂_singleton_right
165167
166- lemma infs_singleton : ({a} ⊼ {b} : finset α) = {a ⊓ b} := image₂_singleton
168+ lemma singleton_infs_singleton : ({a} ⊼ {b} : finset α) = {a ⊓ b} := image₂_singleton
167169
168170lemma infs_union_left : (s₁ ∪ s₂) ⊼ t = s₁ ⊼ t ∪ s₂ ⊼ t := image₂_union_left
169171lemma infs_union_right : s ⊼ (t₁ ∪ t₂) = s ⊼ t₁ ∪ s ⊼ t₂ := image₂_union_right
@@ -172,10 +174,10 @@ lemma infs_inter_subset_left : (s₁ ∩ s₂) ⊼ t ⊆ s₁ ⊼ t ∩ s₂ ⊼
172174lemma infs_inter_subset_right : s ⊼ (t₁ ∩ t₂) ⊆ s ⊼ t₁ ∩ s ⊼ t₂ := image₂_inter_subset_right
173175
174176lemma subset_infs {s t : set α} :
175- ↑u ⊆ set.image2 (⊓) s t → ∃ s' t' : finset α, ↑s' ⊆ s ∧ ↑t' ⊆ t ∧ u ⊆ s' ⊼ t' :=
177+ ↑u ⊆ s ⊼ t → ∃ s' t' : finset α, ↑s' ⊆ s ∧ ↑t' ⊆ t ∧ u ⊆ s' ⊼ t' :=
176178subset_image₂
177179
178- variables (s t u)
180+ variables (s t u v )
179181
180182lemma bUnion_image_inf_left : s.bUnion (λ a, t.image $ (⊓) a) = s ⊼ t := bUnion_image_left
181183lemma bUnion_image_inf_right : t.bUnion (λ b, s.image $ λ a, a ⊓ b) = s ⊼ t := bUnion_image_right
@@ -187,11 +189,30 @@ lemma infs_assoc : (s ⊼ t) ⊼ u = s ⊼ (t ⊼ u) := image₂_assoc $ λ _ _
187189lemma infs_comm : s ⊼ t = t ⊼ s := image₂_comm $ λ _ _, inf_comm
188190lemma infs_left_comm : s ⊼ (t ⊼ u) = t ⊼ (s ⊼ u) := image₂_left_comm inf_left_comm
189191lemma infs_right_comm : (s ⊼ t) ⊼ u = (s ⊼ u) ⊼ t := image₂_right_comm inf_right_comm
192+ lemma infs_infs_infs_comm : (s ⊼ t) ⊼ (u ⊼ v) = (s ⊼ u) ⊼ (t ⊼ v) :=
193+ image₂_image₂_image₂_comm inf_inf_inf_comm
190194
191195end infs
192196
193197open_locale finset_family
194198
199+ section distrib_lattice
200+ variables [distrib_lattice α] (s t u : finset α)
201+
202+ lemma sups_infs_subset_left : s ⊻ (t ⊼ u) ⊆ (s ⊻ t) ⊼ (s ⊻ u) :=
203+ image₂_distrib_subset_left $ λ _ _ _, sup_inf_left
204+
205+ lemma sups_infs_subset_right : (t ⊼ u) ⊻ s ⊆ (t ⊻ s) ⊼ (u ⊻ s) :=
206+ image₂_distrib_subset_right $ λ _ _ _, sup_inf_right
207+
208+ lemma infs_sups_subset_left : s ⊼ (t ⊻ u) ⊆ (s ⊼ t) ⊻ (s ⊼ u) :=
209+ image₂_distrib_subset_left $ λ _ _ _, inf_sup_left
210+
211+ lemma infs_sups_subset_right : (t ⊻ u) ⊼ s ⊆ (t ⊼ s) ⊻ (u ⊼ s) :=
212+ image₂_distrib_subset_right $ λ _ _ _, inf_sup_right
213+
214+ end distrib_lattice
215+
195216section disj_sups
196217variables [semilattice_sup α] [order_bot α] [@decidable_rel α disjoint]
197218 (s s₁ s₂ t t₁ t₂ u : finset α)
@@ -271,7 +292,7 @@ end disj_sups
271292open_locale finset_family
272293
273294section distrib_lattice
274- variables [distrib_lattice α] [order_bot α] [@decidable_rel α disjoint] (s t u : finset α)
295+ variables [distrib_lattice α] [order_bot α] [@decidable_rel α disjoint] (s t u v : finset α)
275296
276297lemma disj_sups_assoc : ∀ s t u : finset α, (s ○ t) ○ u = s ○ (t ○ u) :=
277298begin
@@ -288,5 +309,8 @@ by simp_rw [←disj_sups_assoc, disj_sups_comm s]
288309lemma disj_sups_right_comm : (s ○ t) ○ u = (s ○ u) ○ t :=
289310by simp_rw [disj_sups_assoc, disj_sups_comm]
290311
312+ lemma disj_sups_disj_sups_disj_sups_comm : (s ○ t) ○ (u ○ v) = (s ○ u) ○ (t ○ v) :=
313+ by simp_rw [←disj_sups_assoc, disj_sups_right_comm]
314+
291315end distrib_lattice
292316end finset
0 commit comments