@@ -71,6 +71,9 @@ theorem shadow_empty : ∂ (∅ : Finset (Finset α)) = ∅ :=
71
71
rfl
72
72
#align finset.shadow_empty Finset.shadow_empty
73
73
74
+ @[simp] lemma shadow_iterate_empty (k : ℕ) : ∂^[k] (∅ : Finset (Finset α)) = ∅ := by
75
+ induction' k <;> simp [*, shadow_empty]
76
+
74
77
@[simp]
75
78
theorem shadow_singleton_empty : ∂ ({∅} : Finset (Finset α)) = ∅ :=
76
79
rfl
@@ -83,34 +86,84 @@ theorem shadow_monotone : Monotone (shadow : Finset (Finset α) → Finset (Fins
83
86
sup_mono
84
87
#align finset.shadow_monotone Finset.shadow_monotone
85
88
86
- /-- `s ` is in the shadow of `𝒜` iff there is a `t ∈ 𝒜` from which we can remove one element to
87
- get `s `. -/
88
- theorem mem_shadow_iff : s ∈ ∂ 𝒜 ↔ ∃ t ∈ 𝒜, ∃ a ∈ t , erase t a = s := by
89
+ /-- `t ` is in the shadow of `𝒜` iff there is a `s ∈ 𝒜` from which we can remove one element to
90
+ get `t `. -/
91
+ lemma mem_shadow_iff : t ∈ ∂ 𝒜 ↔ ∃ s ∈ 𝒜, ∃ a ∈ s , erase s a = t := by
89
92
simp only [shadow, mem_sup, mem_image]
90
93
#align finset.mem_shadow_iff Finset.mem_shadow_iff
91
94
92
95
theorem erase_mem_shadow (hs : s ∈ 𝒜) (ha : a ∈ s) : erase s a ∈ ∂ 𝒜 :=
93
96
mem_shadow_iff.2 ⟨s, hs, a, ha, rfl⟩
94
97
#align finset.erase_mem_shadow Finset.erase_mem_shadow
95
98
99
+ /-- `t ∈ ∂𝒜` iff `t` is exactly one element less than something from `𝒜`.
100
+
101
+ See also `Finset.mem_shadow_iff_exists_mem_card_add_one`. -/
102
+ lemma mem_shadow_iff_exists_sdiff : t ∈ ∂ 𝒜 ↔ ∃ s ∈ 𝒜, t ⊆ s ∧ (s \ t).card = 1 := by
103
+ simp_rw [mem_shadow_iff, ←covby_iff_card_sdiff_eq_one, covby_iff_exists_erase, eq_comm]
104
+
96
105
/-- `t` is in the shadow of `𝒜` iff we can add an element to it so that the resulting finset is in
97
106
`𝒜`. -/
98
- theorem mem_shadow_iff_insert_mem : s ∈ ∂ 𝒜 ↔ ∃ (a : _) (_ : a ∉ s), insert a s ∈ 𝒜 := by
99
- refine' mem_shadow_iff.trans ⟨_, _⟩
100
- · rintro ⟨s, hs, a, ha, rfl⟩
101
- refine' ⟨a, not_mem_erase a s, _⟩
102
- rwa [insert_erase ha]
103
- · rintro ⟨a, ha, hs⟩
104
- exact ⟨insert a s, hs, a, mem_insert_self _ _, erase_insert ha⟩
107
+ lemma mem_shadow_iff_insert_mem : t ∈ ∂ 𝒜 ↔ ∃ a, a ∉ t ∧ insert a t ∈ 𝒜 := by
108
+ simp_rw [mem_shadow_iff_exists_sdiff, ←covby_iff_card_sdiff_eq_one, covby_iff_exists_insert]
109
+ aesop
105
110
#align finset.mem_shadow_iff_insert_mem Finset.mem_shadow_iff_insert_mem
106
111
112
+ /-- `s ∈ ∂ 𝒜` iff `s` is exactly one element less than something from `𝒜`.
113
+
114
+ See also `Finset.mem_shadow_iff_exists_sdiff`. -/
115
+ lemma mem_shadow_iff_exists_mem_card_add_one :
116
+ t ∈ ∂ 𝒜 ↔ ∃ s ∈ 𝒜, t ⊆ s ∧ s.card = t.card + 1 := by
117
+ refine mem_shadow_iff_exists_sdiff.trans $ exists_congr fun t ↦ and_congr_right fun _ ↦
118
+ and_congr_right fun hst ↦ ?_
119
+ rw [card_sdiff hst, tsub_eq_iff_eq_add_of_le, add_comm]
120
+ exact card_mono hst
121
+ #align finset.mem_shadow_iff_exists_mem_card_add_one Finset.mem_shadow_iff_exists_mem_card_add_one
122
+
123
+ lemma mem_shadow_iterate_iff_exists_card :
124
+ t ∈ ∂^[k] 𝒜 ↔ ∃ u : Finset α, u.card = k ∧ Disjoint t u ∧ t ∪ u ∈ 𝒜 := by
125
+ induction' k with k ih generalizing t
126
+ · simp
127
+ simp only [mem_shadow_iff_insert_mem, ih, Function.iterate_succ_apply', card_eq_succ]
128
+ aesop
129
+
130
+ /-- `t ∈ ∂^k 𝒜` iff `t` is exactly `k` elements less than something from `𝒜`.
131
+
132
+ See also `Finset.mem_shadow_iff_exists_mem_card_add`. -/
133
+ lemma mem_shadow_iterate_iff_exists_sdiff : t ∈ ∂^[k] 𝒜 ↔ ∃ s ∈ 𝒜, t ⊆ s ∧ (s \ t).card = k := by
134
+ rw [mem_shadow_iterate_iff_exists_card]
135
+ constructor
136
+ · rintro ⟨u, rfl, htu, hsuA⟩
137
+ exact ⟨_, hsuA, subset_union_left _ _, by rw [union_sdiff_cancel_left htu]⟩
138
+ · rintro ⟨s, hs, hts, rfl⟩
139
+ refine ⟨s \ t, rfl, disjoint_sdiff, ?_⟩
140
+ rwa [union_sdiff_self_eq_union, union_eq_right.2 hts]
141
+
142
+ /-- `t ∈ ∂^k 𝒜` iff `t` is exactly `k` elements less than something in `𝒜`.
143
+
144
+ See also `Finset.mem_shadow_iterate_iff_exists_sdiff`. -/
145
+ lemma mem_shadow_iterate_iff_exists_mem_card_add :
146
+ t ∈ ∂^[k] 𝒜 ↔ ∃ s ∈ 𝒜, t ⊆ s ∧ s.card = t.card + k := by
147
+ refine mem_shadow_iterate_iff_exists_sdiff.trans $ exists_congr fun t ↦ and_congr_right fun _ ↦
148
+ and_congr_right fun hst ↦ ?_
149
+ rw [card_sdiff hst, tsub_eq_iff_eq_add_of_le, add_comm]
150
+ exact card_mono hst
151
+ #align finset.mem_shadow_iff_exists_mem_card_add Finset.mem_shadow_iterate_iff_exists_mem_card_add
152
+
107
153
/-- The shadow of a family of `r`-sets is a family of `r - 1`-sets. -/
108
- protected theorem Set.Sized.shadow (h𝒜 : (𝒜 : Set (Finset α)).Sized r) :
154
+ protected theorem _root_. Set.Sized.shadow (h𝒜 : (𝒜 : Set (Finset α)).Sized r) :
109
155
(∂ 𝒜 : Set (Finset α)).Sized (r - 1 ) := by
110
156
intro A h
111
157
obtain ⟨A, hA, i, hi, rfl⟩ := mem_shadow_iff.1 h
112
158
rw [card_erase_of_mem hi, h𝒜 hA]
113
- #align finset.set.sized.shadow Finset.Set.Sized.shadow
159
+ #align finset.set.sized.shadow Set.Sized.shadow
160
+
161
+ /-- The `k`-th shadow of a family of `r`-sets is a family of `r - k`-sets. -/
162
+ lemma _root_.Set.Sized.shadow_iterate (h𝒜 : (𝒜 : Set (Finset α)).Sized r) :
163
+ (∂^[k] 𝒜 : Set (Finset α)).Sized (r - k) := by
164
+ simp_rw [Set.Sized, mem_coe, mem_shadow_iterate_iff_exists_sdiff]
165
+ rintro t ⟨s, hs, hts, rfl⟩
166
+ rw [card_sdiff hts, ←h𝒜 hs, Nat.sub_sub_self (card_le_of_subset hts)]
114
167
115
168
theorem sized_shadow_iff (h : ∅ ∉ 𝒜) :
116
169
(∂ 𝒜 : Set (Finset α)).Sized r ↔ (𝒜 : Set (Finset α)).Sized (r + 1 ) := by
@@ -119,55 +172,12 @@ theorem sized_shadow_iff (h : ∅ ∉ 𝒜) :
119
172
rw [← h𝒜 (erase_mem_shadow hs ha), card_erase_add_one ha]
120
173
#align finset.sized_shadow_iff Finset.sized_shadow_iff
121
174
122
- /-- `s ∈ ∂ 𝒜` iff `s` is exactly one element less than something from `𝒜` -/
123
- theorem mem_shadow_iff_exists_mem_card_add_one :
124
- s ∈ ∂ 𝒜 ↔ ∃ t ∈ 𝒜, s ⊆ t ∧ t.card = s.card + 1 := by
125
- refine' mem_shadow_iff_insert_mem.trans ⟨_, _⟩
126
- · rintro ⟨a, ha, hs⟩
127
- exact ⟨insert a s, hs, subset_insert _ _, card_insert_of_not_mem ha⟩
128
- · rintro ⟨t, ht, hst, h⟩
129
- obtain ⟨a, ha⟩ : ∃ a, t \ s = {a} :=
130
- card_eq_one.1 (by rw [card_sdiff hst, h, add_tsub_cancel_left])
131
- exact
132
- ⟨a, fun hat => not_mem_sdiff_of_mem_right hat (ha.superset <| mem_singleton_self a),
133
- by rwa [insert_eq a s, ← ha, sdiff_union_of_subset hst]⟩
134
- #align finset.mem_shadow_iff_exists_mem_card_add_one Finset.mem_shadow_iff_exists_mem_card_add_one
135
-
136
175
/-- Being in the shadow of `𝒜` means we have a superset in `𝒜`. -/
137
- theorem exists_subset_of_mem_shadow (hs : s ∈ ∂ 𝒜) : ∃ t ∈ 𝒜, s ⊆ t :=
176
+ lemma exists_subset_of_mem_shadow (hs : t ∈ ∂ 𝒜) : ∃ s ∈ 𝒜, t ⊆ s :=
138
177
let ⟨t, ht, hst⟩ := mem_shadow_iff_exists_mem_card_add_one.1 hs
139
178
⟨t, ht, hst.1 ⟩
140
179
#align finset.exists_subset_of_mem_shadow Finset.exists_subset_of_mem_shadow
141
180
142
- /-- `t ∈ ∂^k 𝒜` iff `t` is exactly `k` elements less than something in `𝒜`. -/
143
- theorem mem_shadow_iff_exists_mem_card_add :
144
- s ∈ ∂ ^[k] 𝒜 ↔ ∃ t ∈ 𝒜, s ⊆ t ∧ t.card = s.card + k := by
145
- induction' k with k ih generalizing 𝒜 s
146
- · refine' ⟨fun hs => ⟨s, hs, Subset.refl _, rfl⟩, _⟩
147
- rintro ⟨t, ht, hst, hcard⟩
148
- rwa [eq_of_subset_of_card_le hst hcard.le]
149
- simp only [exists_prop, Function.comp_apply, Function.iterate_succ]
150
- refine' ih.trans _
151
- clear ih
152
- constructor
153
- · rintro ⟨t, ht, hst, hcardst⟩
154
- obtain ⟨u, hu, htu, hcardtu⟩ := mem_shadow_iff_exists_mem_card_add_one.1 ht
155
- refine' ⟨u, hu, hst.trans htu, _⟩
156
- rw [hcardtu, hcardst]
157
- rfl
158
- · rintro ⟨t, ht, hst, hcard⟩
159
- obtain ⟨u, hsu, hut, hu⟩ :=
160
- Finset.exists_intermediate_set k
161
- (by
162
- rw [add_comm, hcard]
163
- exact le_succ _)
164
- hst
165
- rw [add_comm] at hu
166
- refine' ⟨u, mem_shadow_iff_exists_mem_card_add_one.2 ⟨t, ht, hut, _⟩, hsu, hu⟩
167
- rw [hcard, hu]
168
- rfl
169
- #align finset.mem_shadow_iff_exists_mem_card_add Finset.mem_shadow_iff_exists_mem_card_add
170
-
171
181
end Shadow
172
182
173
183
open FinsetFamily
@@ -198,48 +208,83 @@ theorem upShadow_monotone : Monotone (upShadow : Finset (Finset α) → Finset (
198
208
fun _ _ => sup_mono
199
209
#align finset.up_shadow_monotone Finset.upShadow_monotone
200
210
201
- /-- `s ` is in the upper shadow of `𝒜` iff there is a `t ∈ 𝒜` from which we can remove one element
202
- to get `s `. -/
203
- theorem mem_upShadow_iff : s ∈ ∂⁺ 𝒜 ↔ ∃ t ∈ 𝒜, ∃ (a : _) (_ : a ∉ t), insert a t = s := by
204
- simp_rw [upShadow, mem_sup, mem_image, exists_prop, mem_compl]
211
+ /-- `t ` is in the upper shadow of `𝒜` iff there is a `s ∈ 𝒜` from which we can remove one element
212
+ to get `t `. -/
213
+ lemma mem_upShadow_iff : t ∈ ∂⁺ 𝒜 ↔ ∃ s ∈ 𝒜, ∃ a, a ∉ s ∧ insert a s = t := by
214
+ simp_rw [upShadow, mem_sup, mem_image, mem_compl]
205
215
#align finset.mem_up_shadow_iff Finset.mem_upShadow_iff
206
216
207
217
theorem insert_mem_upShadow (hs : s ∈ 𝒜) (ha : a ∉ s) : insert a s ∈ ∂⁺ 𝒜 :=
208
218
mem_upShadow_iff.2 ⟨s, hs, a, ha, rfl⟩
209
219
#align finset.insert_mem_up_shadow Finset.insert_mem_upShadow
210
220
211
- /-- The upper shadow of a family of `r`-sets is a family of `r + 1`-sets. -/
212
- protected theorem Set.Sized.upShadow (h𝒜 : (𝒜 : Set (Finset α)).Sized r) :
213
- (∂⁺ 𝒜 : Set (Finset α)).Sized (r + 1 ) := by
214
- intro A h
215
- obtain ⟨A, hA, i, hi, rfl⟩ := mem_upShadow_iff.1 h
216
- rw [card_insert_of_not_mem hi, h𝒜 hA]
217
- #align finset.set.sized.up_shadow Finset.Set.Sized.upShadow
221
+ /-- `t` is in the upper shadow of `𝒜` iff `t` is exactly one element more than something from `𝒜`.
222
+
223
+ See also `Finset.mem_upShadow_iff_exists_mem_card_add_one`. -/
224
+ lemma mem_upShadow_iff_exists_sdiff : t ∈ ∂⁺ 𝒜 ↔ ∃ s ∈ 𝒜, s ⊆ t ∧ (t \ s).card = 1 := by
225
+ simp_rw [mem_upShadow_iff, ←covby_iff_card_sdiff_eq_one, covby_iff_exists_insert]
218
226
219
227
/-- `t` is in the upper shadow of `𝒜` iff we can remove an element from it so that the resulting
220
228
finset is in `𝒜`. -/
221
- theorem mem_upShadow_iff_erase_mem : s ∈ ∂⁺ 𝒜 ↔ ∃ a ∈ s, s.erase a ∈ 𝒜 := by
222
- refine' mem_upShadow_iff.trans ⟨_, _⟩
223
- · rintro ⟨s, hs, a, ha, rfl⟩
224
- refine' ⟨a, mem_insert_self a s, _⟩
225
- rwa [erase_insert ha]
226
- · rintro ⟨a, ha, hs⟩
227
- exact ⟨s.erase a, hs, a, not_mem_erase _ _, insert_erase ha⟩
229
+ lemma mem_upShadow_iff_erase_mem : t ∈ ∂⁺ 𝒜 ↔ ∃ a, a ∈ t ∧ erase t a ∈ 𝒜 := by
230
+ simp_rw [mem_upShadow_iff_exists_sdiff, ←covby_iff_card_sdiff_eq_one, covby_iff_exists_erase]
231
+ aesop
228
232
#align finset.mem_up_shadow_iff_erase_mem Finset.mem_upShadow_iff_erase_mem
229
233
230
- /-- `s ∈ ∂⁺ 𝒜` iff `s` is exactly one element less than something from `𝒜`. -/
231
- theorem mem_upShadow_iff_exists_mem_card_add_one :
232
- s ∈ ∂⁺ 𝒜 ↔ ∃ t ∈ 𝒜, t ⊆ s ∧ t.card + 1 = s.card := by
233
- refine' mem_upShadow_iff_erase_mem.trans ⟨_, _⟩
234
- · rintro ⟨a, ha, hs⟩
235
- exact ⟨s.erase a, hs, erase_subset _ _, card_erase_add_one ha⟩
236
- · rintro ⟨t, ht, hts, h⟩
237
- obtain ⟨a, ha⟩ : ∃ a, s \ t = {a} :=
238
- card_eq_one.1 (by rw [card_sdiff hts, ← h, add_tsub_cancel_left])
239
- refine' ⟨a, sdiff_subset _ _ ((ha.ge : _ ⊆ _) <| mem_singleton_self a), _⟩
240
- rwa [← sdiff_singleton_eq_erase, ← ha, sdiff_sdiff_eq_self hts]
234
+ /-- `t` is in the upper shadow of `𝒜` iff `t` is exactly one element less than something from `𝒜`.
235
+
236
+ See also `Finset.mem_upShadow_iff_exists_sdiff`. -/
237
+ lemma mem_upShadow_iff_exists_mem_card_add_one :
238
+ t ∈ ∂⁺ 𝒜 ↔ ∃ s ∈ 𝒜, s ⊆ t ∧ t.card = s.card + 1 := by
239
+ refine mem_upShadow_iff_exists_sdiff.trans $ exists_congr fun t ↦ and_congr_right fun _ ↦
240
+ and_congr_right fun hst ↦ ?_
241
+ rw [card_sdiff hst, tsub_eq_iff_eq_add_of_le, add_comm]
242
+ exact card_mono hst
241
243
#align finset.mem_up_shadow_iff_exists_mem_card_add_one Finset.mem_upShadow_iff_exists_mem_card_add_one
242
244
245
+ lemma mem_upShadow_iterate_iff_exists_card :
246
+ t ∈ ∂⁺^[k] 𝒜 ↔ ∃ u : Finset α, u.card = k ∧ u ⊆ t ∧ t \ u ∈ 𝒜 := by
247
+ induction' k with k ih generalizing t
248
+ · simp
249
+ simp only [mem_upShadow_iff_erase_mem, ih, Function.iterate_succ_apply', card_eq_succ,
250
+ subset_erase, erase_sdiff_comm, ←sdiff_insert]
251
+ constructor
252
+ · rintro ⟨a, hat, u, rfl, ⟨hut, hau⟩, htu⟩
253
+ exact ⟨_, ⟨_, _, hau, rfl, rfl⟩, insert_subset hat hut, htu⟩
254
+ · rintro ⟨_, ⟨a, u, hau, rfl, rfl⟩, hut, htu⟩
255
+ rw [insert_subset_iff] at hut
256
+ exact ⟨a, hut.1 , _, rfl, ⟨hut.2 , hau⟩, htu⟩
257
+
258
+ /-- `t` is in the upper shadow of `𝒜` iff `t` is exactly `k` elements less than something from `𝒜`.
259
+
260
+ See also `Finset.mem_upShadow_iff_exists_mem_card_add`. -/
261
+ lemma mem_upShadow_iterate_iff_exists_sdiff :
262
+ t ∈ ∂⁺^[k] 𝒜 ↔ ∃ s ∈ 𝒜, s ⊆ t ∧ (t \ s).card = k := by
263
+ rw [mem_upShadow_iterate_iff_exists_card]
264
+ constructor
265
+ · rintro ⟨u, rfl, hut, htu⟩
266
+ exact ⟨_, htu, sdiff_subset _ _, by rw [sdiff_sdiff_eq_self hut]⟩
267
+ · rintro ⟨s, hs, hst, rfl⟩
268
+ exact ⟨_, rfl, sdiff_subset _ _, by rwa [sdiff_sdiff_eq_self hst]⟩
269
+
270
+ /-- `t ∈ ∂⁺^k 𝒜` iff `t` is exactly `k` elements less than something in `𝒜`.
271
+
272
+ See also `Finset.mem_upShadow_iterate_iff_exists_sdiff`. -/
273
+ lemma mem_upShadow_iterate_iff_exists_mem_card_add :
274
+ t ∈ ∂⁺^[k] 𝒜 ↔ ∃ s ∈ 𝒜, s ⊆ t ∧ t.card = s.card + k := by
275
+ refine mem_upShadow_iterate_iff_exists_sdiff.trans $ exists_congr fun t ↦ and_congr_right fun _ ↦
276
+ and_congr_right fun hst ↦ ?_
277
+ rw [card_sdiff hst, tsub_eq_iff_eq_add_of_le, add_comm]
278
+ exact card_mono hst
279
+
280
+ /-- The upper shadow of a family of `r`-sets is a family of `r + 1`-sets. -/
281
+ protected lemma _root_.Set.Sized.upShadow (h𝒜 : (𝒜 : Set (Finset α)).Sized r) :
282
+ (∂⁺ 𝒜 : Set (Finset α)).Sized (r + 1 ) := by
283
+ intro A h
284
+ obtain ⟨A, hA, i, hi, rfl⟩ := mem_upShadow_iff.1 h
285
+ rw [card_insert_of_not_mem hi, h𝒜 hA]
286
+ #align finset.set.sized.up_shadow Set.Sized.upShadow
287
+
243
288
/-- Being in the upper shadow of `𝒜` means we have a superset in `𝒜`. -/
244
289
theorem exists_subset_of_mem_upShadow (hs : s ∈ ∂⁺ 𝒜) : ∃ t ∈ 𝒜, t ⊆ s :=
245
290
let ⟨t, ht, hts, _⟩ := mem_upShadow_iff_exists_mem_card_add_one.1 hs
@@ -260,7 +305,7 @@ theorem mem_upShadow_iff_exists_mem_card_add :
260
305
· rintro ⟨t, ht, hts, hcardst⟩
261
306
obtain ⟨u, hu, hut, hcardtu⟩ := mem_upShadow_iff_exists_mem_card_add_one.1 ht
262
307
refine' ⟨u, hu, hut.trans hts, _⟩
263
- rw [← hcardst, ← hcardtu, add_right_comm]
308
+ rw [← hcardst, hcardtu, add_right_comm]
264
309
rfl
265
310
· rintro ⟨t, ht, hts, hcard⟩
266
311
obtain ⟨u, htu, hus, hu⟩ :=
@@ -270,7 +315,7 @@ theorem mem_upShadow_iff_exists_mem_card_add :
270
315
exact add_le_add_left (succ_le_of_lt (zero_lt_succ _)) _)
271
316
hts
272
317
rw [add_comm] at hu
273
- refine' ⟨u, mem_upShadow_iff_exists_mem_card_add_one.2 ⟨t, ht, htu, hu.symm ⟩, hus, _⟩
318
+ refine' ⟨u, mem_upShadow_iff_exists_mem_card_add_one.2 ⟨t, ht, htu, hu⟩, hus, _⟩
274
319
rw [hu, ← hcard, add_right_comm]
275
320
rfl
276
321
#align finset.mem_up_shadow_iff_exists_mem_card_add Finset.mem_upShadow_iff_exists_mem_card_add
0 commit comments