Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(combinatorics/set_family/shadow): Shadow of a set family (#10223)
This defines `shadow π` where `π : finset (finset Ξ±))`.
- Loading branch information
1 parent
7fec401
commit 0a2a922
Showing
1 changed file
with
123 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
/- | ||
Copyright (c) 2021 Bhavik Mehta. All rights reserved. | ||
Released under Apache 2.0 license as described in the file LICENSE. | ||
Authors: Bhavik Mehta, Alena Gusakov, YaΓ«l Dillies | ||
-/ | ||
import data.finset.lattice | ||
|
||
/-! | ||
# Shadows | ||
This file defines shadows of a set family. The shadow of a set family is the set family of sets we | ||
get by removing any element from any set of the original family. If one pictures `finset Ξ±` as a big | ||
hypercube (each dimension being membership of a given element), then taking the shadow corresponds | ||
to projecting each finset down once in all available directions. | ||
## Main definitions | ||
The `shadow` of a set family is everything we can get by removing an element from each set. | ||
## Notation | ||
`β π` is notation for `shadow π`. It is situated in locale `finset_family`. | ||
We also maintain the convention that `a, b : Ξ±` are elements of the ground type, `s, t : finset Ξ±` | ||
are finsets, and `π, β¬ : finset (finset Ξ±)` are finset families. | ||
## References | ||
* https://github.com/b-mehta/maths-notes/blob/master/iii/mich/combinatorics.pdf | ||
* http://discretemath.imp.fu-berlin.de/DMII-2015-16/kruskal.pdf | ||
## Tags | ||
shadow, set family | ||
-/ | ||
|
||
open finset nat | ||
|
||
variables {Ξ± : Type*} | ||
|
||
namespace finset | ||
variables [decidable_eq Ξ±] {π : finset (finset Ξ±)} {s t : finset Ξ±} {a : Ξ±} {k : β} | ||
|
||
/-- The shadow of a set family `π` is all sets we can get by removing one element from any set in | ||
`π`, and the (`k` times) iterated shadow (`shadow^[k]`) is all sets we can get by removing `k` | ||
elements from any set in `π`. -/ | ||
def shadow (π : finset (finset Ξ±)) : finset (finset Ξ±) := π.sup (Ξ» s, s.image (erase s)) | ||
|
||
localized "notation `β `:90 := finset.shadow" in finset_family | ||
|
||
/-- The shadow of the empty set is empty. -/ | ||
@[simp] lemma shadow_empty : β (β : finset (finset Ξ±)) = β := rfl | ||
|
||
/-- The shadow is monotone. -/ | ||
@[mono] lemma shadow_monotone : monotone (shadow : finset (finset Ξ±) β finset (finset Ξ±)) := | ||
Ξ» π β¬, sup_mono | ||
|
||
/-- `s` is in the shadow of `π` iff there is an `t β π` from which we can remove one element to | ||
get `s`. -/ | ||
lemma mem_shadow_iff : s β β π β β t β π, β a β t, erase t a = s := | ||
by simp only [shadow, mem_sup, mem_image] | ||
|
||
lemma erase_mem_shadow (hs : s β π) (ha : a β s) : erase s a β β π := | ||
mem_shadow_iff.2 β¨s, hs, a, ha, rflβ© | ||
|
||
/-- `t` is in the shadow of `π` iff we can add an element to it so that the resulting finset is in | ||
`π`. -/ | ||
lemma mem_shadow_iff_insert_mem : s β β π β β a β s, insert a s β π := | ||
begin | ||
refine mem_shadow_iff.trans β¨_, _β©, | ||
{ rintro β¨s, hs, a, ha, rflβ©, | ||
refine β¨a, not_mem_erase a s, _β©, | ||
rwa insert_erase ha }, | ||
{ rintro β¨a, ha, hsβ©, | ||
exact β¨insert a s, hs, a, mem_insert_self _ _, erase_insert haβ© } | ||
end | ||
|
||
/-- `s β β π` iff `s` is exactly one element less than something from `π` -/ | ||
lemma mem_shadow_iff_exists_mem_card_add_one : | ||
s β β π β β t β π, s β t β§ t.card = s.card + 1 := | ||
begin | ||
refine mem_shadow_iff_insert_mem.trans β¨_, _β©, | ||
{ rintro β¨a, ha, hsβ©, | ||
exact β¨insert a s, hs, subset_insert _ _, card_insert_of_not_mem haβ© }, | ||
{ rintro β¨t, ht, hst, hβ©, | ||
obtain β¨a, haβ© : β a, t \ s = {a} := | ||
card_eq_one.1 (by rw [card_sdiff hst, h, add_tsub_cancel_left]), | ||
exact β¨a, Ξ» hat, | ||
not_mem_sdiff_of_mem_right hat ((ha.ge : _ β _) $ mem_singleton_self a), | ||
by rwa [insert_eq a s, βha, sdiff_union_of_subset hst]β© } | ||
end | ||
|
||
/-- Being in the shadow of `π` means we have a superset in `π`. -/ | ||
lemma exists_subset_of_mem_shadow (hs : s β β π) : β t β π, s β t := | ||
let β¨t, ht, hstβ© := mem_shadow_iff_exists_mem_card_add_one.1 hs in β¨t, ht, hst.1β© | ||
|
||
/-- `t β β^k π` iff `t` is exactly `k` elements less than something in `π`. -/ | ||
lemma mem_shadow_iff_exists_mem_card_add : | ||
s β (β^[k]) π β β t β π, s β t β§ t.card = s.card + k := | ||
begin | ||
induction k with k ih generalizing π s, | ||
{ refine β¨Ξ» hs, β¨s, hs, subset.refl _, rflβ©, _β©, | ||
rintro β¨t, ht, hst, hcardβ©, | ||
rwa eq_of_subset_of_card_le hst hcard.le }, | ||
simp only [exists_prop, function.comp_app, function.iterate_succ], | ||
refine ih.trans _, | ||
clear ih, | ||
split, | ||
{ rintro β¨t, ht, hst, hcardstβ©, | ||
obtain β¨u, hu, htu, hcardtuβ© := mem_shadow_iff_exists_mem_card_add_one.1 ht, | ||
refine β¨u, hu, hst.trans htu, _β©, | ||
rw [hcardtu, hcardst], | ||
refl }, | ||
{ rintro β¨t, ht, hst, hcardβ©, | ||
obtain β¨u, hsu, hut, huβ© := finset.exists_intermediate_set k | ||
(by { rw [add_comm, hcard], exact le_succ _ }) hst, | ||
rw add_comm at hu, | ||
refine β¨u, mem_shadow_iff_exists_mem_card_add_one.2 β¨t, ht, hut, _β©, hsu, huβ©, | ||
rw [hcard, hu], | ||
refl } | ||
end | ||
|
||
end finset |