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

Commit 20715f4

Browse files
committed
feat(data/set/sups): Set family operations (#18172)
Followup to #17947. Add a similar `set` API (but do not define `set.disj_sups` because I don't need it), correct a few lemma names and connect to upper/lower sets.
1 parent acebd8d commit 20715f4

File tree

4 files changed

+315
-50
lines changed

4 files changed

+315
-50
lines changed

src/data/finset/n_ary.lean

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ open function set
2727

2828
namespace finset
2929

30-
variables {α α' β β' γ γ' δ δ' ε ε' : Type*}
30+
variables {α α' β β' γ γ' δ δ' ε ε' ζ ζ' ν : Type*}
3131
[decidable_eq α'] [decidable_eq β'] [decidable_eq γ] [decidable_eq γ'] [decidable_eq δ]
3232
[decidable_eq δ'] [decidable_eq ε] [decidable_eq ε']
3333
{f f' : α → β → γ} {g g' : α → β → γ → δ} {s s' : finset α} {t t' : finset β} {u u' : finset γ}
@@ -71,11 +71,11 @@ lemma image₂_subset_left (ht : t ⊆ t') : image₂ f s t ⊆ image₂ f s t'
7171
lemma image₂_subset_right (hs : s ⊆ s') : image₂ f s t ⊆ image₂ f s' t :=
7272
image₂_subset hs subset.rfl
7373

74-
lemma image_subset_image₂_left (hb : b ∈ t) : (λ a, f a b) '' s ⊆ image₂ f s t :=
75-
ball_image_of_ball $ λ a ha, mem_image₂_of_mem ha hb
74+
lemma image_subset_image₂_left (hb : b ∈ t) : s.image (λ a, f a b) ⊆ image₂ f s t :=
75+
image_subset_iff.2 $ λ a ha, mem_image₂_of_mem ha hb
7676

77-
lemma image_subset_image₂_right (ha : a ∈ s) : f a '' t ⊆ image₂ f s t :=
78-
ball_image_of_ball $ λ b, mem_image₂_of_mem ha
77+
lemma image_subset_image₂_right (ha : a ∈ s) : t.image (f a) ⊆ image₂ f s t :=
78+
image_subset_iff.2 $ λ b, mem_image₂_of_mem ha
7979

8080
lemma forall_image₂_iff {p : γ → Prop} : (∀ z ∈ image₂ f s t, p z) ↔ ∀ (x ∈ s) (y ∈ t), p (f x y) :=
8181
by simp_rw [←mem_coe, coe_image₂, forall_image2_iff]
@@ -252,6 +252,13 @@ lemma image₂_right_comm {γ : Type*} {u : finset γ} {f : δ → γ → ε} {g
252252
image₂ f (image₂ g s t) u = image₂ g' (image₂ f' s u) t :=
253253
coe_injective $ by { push_cast, exact image2_right_comm h_right_comm }
254254

255+
lemma image₂_image₂_image₂_comm {γ δ : Type*} {u : finset γ} {v : finset δ} [decidable_eq ζ]
256+
[decidable_eq ζ'] [decidable_eq ν] {f : ε → ζ → ν} {g : α → β → ε} {h : γ → δ → ζ}
257+
{f' : ε' → ζ' → ν} {g' : α → γ → ε'} {h' : β → δ → ζ'}
258+
(h_comm : ∀ a b c d, f (g a b) (h c d) = f' (g' a c) (h' b d)) :
259+
image₂ f (image₂ g s t) (image₂ h u v) = image₂ f' (image₂ g' s u) (image₂ h' t v) :=
260+
coe_injective $ by { push_cast, exact image2_image2_image2_comm h_comm }
261+
255262
lemma image_image₂_distrib {g : γ → δ} {f' : α' → β' → δ} {g₁ : α → α'} {g₂ : β → β'}
256263
(h_distrib : ∀ a b, g (f a b) = f' (g₁ a) (g₂ b)) :
257264
(image₂ f s t).image g = image₂ f' (s.image g₁) (t.image g₂) :=

src/data/finset/sups.lean

Lines changed: 67 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
44
Authors: Yaël Dillies
55
-/
66
import 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
2223
We 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

3233
open function
34+
open_locale set_family
3335

3436
variables {α : Type*} [decidable_eq α]
3537

3638
namespace finset
3739
section 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

4547
variables {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

4951
variables (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

5355
lemma 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₂
6365
lemma sups_subset_left : t₁ ⊆ t₂ → s ⊻ t₁ ⊆ s ⊻ t₂ := image₂_subset_left
6466
lemma 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

6971
lemma forall_sups_iff {p : α → Prop} : (∀ c ∈ s ⊻ t, p c) ↔ ∀ (a ∈ s) (b ∈ t), p (a ⊔ b) :=
7072
forall_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₂
7779
lemma nonempty.of_sups_left : (s ⊻ t).nonempty → s.nonempty := nonempty.of_image₂_left
7880
lemma 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

9091
lemma sups_union_left : (s₁ ∪ s₂) ⊻ t = s₁ ⊻ t ∪ s₂ ⊻ t := image₂_union_left
9192
lemma 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₂ ⊻
9495
lemma sups_inter_subset_right : s ⊻ (t₁ ∩ t₂) ⊆ s ⊻ t₁ ∩ s ⊻ t₂ := image₂_inter_subset_right
9596

9697
lemma 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' :=
9899
subset_image₂
99100

100-
variables (s t u)
101+
variables (s t u v)
101102

102103
lemma bUnion_image_sup_left : s.bUnion (λ a, t.image $ (⊔) a) = s ⊻ t := bUnion_image_left
103104
lemma 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 $ λ _ _
109110
lemma sups_comm : s ⊻ t = t ⊻ s := image₂_comm $ λ _ _, sup_comm
110111
lemma sups_left_comm : s ⊻ (t ⊻ u) = t ⊻ (s ⊻ u) := image₂_left_comm sup_left_comm
111112
lemma 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

113116
end sups
114117

115118
section 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

123126
variables {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

127130
variables (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

131134
lemma 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₂
141144
lemma infs_subset_left : t₁ ⊆ t₂ → s ⊼ t₁ ⊆ s ⊼ t₂ := image₂_subset_left
142145
lemma 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

147150
lemma forall_infs_iff {p : α → Prop} : (∀ c ∈ s ⊼ t, p c) ↔ ∀ (a ∈ s) (b ∈ t), p (a ⊓ b) :=
148151
forall_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₂
155158
lemma nonempty.of_infs_left : (s ⊼ t).nonempty → s.nonempty := nonempty.of_image₂_left
156159
lemma 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

168170
lemma infs_union_left : (s₁ ∪ s₂) ⊼ t = s₁ ⊼ t ∪ s₂ ⊼ t := image₂_union_left
169171
lemma 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₂ ⊼
172174
lemma infs_inter_subset_right : s ⊼ (t₁ ∩ t₂) ⊆ s ⊼ t₁ ∩ s ⊼ t₂ := image₂_inter_subset_right
173175

174176
lemma 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' :=
176178
subset_image₂
177179

178-
variables (s t u)
180+
variables (s t u v)
179181

180182
lemma bUnion_image_inf_left : s.bUnion (λ a, t.image $ (⊓) a) = s ⊼ t := bUnion_image_left
181183
lemma 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 $ λ _ _
187189
lemma infs_comm : s ⊼ t = t ⊼ s := image₂_comm $ λ _ _, inf_comm
188190
lemma infs_left_comm : s ⊼ (t ⊼ u) = t ⊼ (s ⊼ u) := image₂_left_comm inf_left_comm
189191
lemma 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

191195
end infs
192196

193197
open_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+
195216
section disj_sups
196217
variables [semilattice_sup α] [order_bot α] [@decidable_rel α disjoint]
197218
(s s₁ s₂ t t₁ t₂ u : finset α)
@@ -271,7 +292,7 @@ end disj_sups
271292
open_locale finset_family
272293

273294
section 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

276297
lemma disj_sups_assoc : ∀ s t u : finset α, (s ○ t) ○ u = s ○ (t ○ u) :=
277298
begin
@@ -288,5 +309,8 @@ by simp_rw [←disj_sups_assoc, disj_sups_comm s]
288309
lemma disj_sups_right_comm : (s ○ t) ○ u = (s ○ u) ○ t :=
289310
by 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+
291315
end distrib_lattice
292316
end finset

src/data/set/n_ary.lean

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,9 @@ and `set.image2` already fulfills this task.
2626
open function
2727

2828
namespace set
29-
variables {α α' β β' γ γ' δ δ' ε ε' : Type*} {f f' : α → β → γ} {g g' : α → β → γ → δ}
30-
variables {s s' : set α} {t t' : set β} {u u' : set γ} {a a' : α} {b b' : β} {c c' : γ} {d d' : δ}
29+
variables {α α' β β' γ γ' δ δ' ε ε' ζ ζ' ν : Type*} {f f' : α → β → γ} {g g' : α → β → γ → δ}
30+
variables {s s' : set α} {t t' : set β} {u u' : set γ} {v : set δ} {a a' : α} {b b' : β} {c c' : γ}
31+
{d d' : δ}
3132

3233

3334
/-- The image of a binary function `f : α → β → γ` as a function `set α → set β → set γ`.
@@ -235,6 +236,19 @@ lemma image2_right_comm {f : δ → γ → ε} {g : α → β → δ} {f' : α
235236
image2 f (image2 g s t) u = image2 g' (image2 f' s u) t :=
236237
by { rw [image2_swap g, image2_swap g'], exact image2_assoc (λ _ _ _, h_right_comm _ _ _) }
237238

239+
lemma image2_image2_image2_comm {f : ε → ζ → ν} {g : α → β → ε} {h : γ → δ → ζ} {f' : ε' → ζ' → ν}
240+
{g' : α → γ → ε'} {h' : β → δ → ζ'}
241+
(h_comm : ∀ a b c d, f (g a b) (h c d) = f' (g' a c) (h' b d)) :
242+
image2 f (image2 g s t) (image2 h u v) = image2 f' (image2 g' s u) (image2 h' t v) :=
243+
begin
244+
ext,
245+
split,
246+
{ rintro ⟨_, _, ⟨a, b, ha, hb, rfl⟩, ⟨c, d, hc, hd, rfl⟩, rfl⟩,
247+
exact ⟨_, _, ⟨a, c, ha, hc, rfl⟩, ⟨b, d, hb, hd, rfl⟩, (h_comm _ _ _ _).symm⟩ },
248+
{ rintro ⟨_, _, ⟨a, c, ha, hc, rfl⟩, ⟨b, d, hb, hd, rfl⟩, rfl⟩,
249+
exact ⟨_, _, ⟨a, b, ha, hb, rfl⟩, ⟨c, d, hc, hd, rfl⟩, h_comm _ _ _ _⟩ }
250+
end
251+
238252
lemma image_image2_distrib {g : γ → δ} {f' : α' → β' → δ} {g₁ : α → α'} {g₂ : β → β'}
239253
(h_distrib : ∀ a b, g (f a b) = f' (g₁ a) (g₂ b)) :
240254
(image2 f s t).image g = image2 f' (s.image g₁) (t.image g₂) :=

0 commit comments

Comments
 (0)