Datasets:
Tasks:
Text Generation
Modalities:
Text
Sub-tasks:
language-modeling
Languages:
English
Size:
100K - 1M
License:
/- | |
Copyright (c) 2021 YaΓ«l Dillies, Bhavik Mehta. All rights reserved. | |
Released under Apache 2.0 license as described in the file LICENSE. | |
Authors: YaΓ«l Dillies, Bhavik Mehta | |
-/ | |
import analysis.convex.topology | |
import tactic.by_contra | |
/-! | |
# Simplicial complexes | |
In this file, we define simplicial complexes in `π`-modules. A simplicial complex is a collection | |
of simplices closed by inclusion (of vertices) and intersection (of underlying sets). | |
We model them by a downward-closed set of affine independent finite sets whose convex hulls "glue | |
nicely", each finite set and its convex hull corresponding respectively to the vertices and the | |
underlying set of a simplex. | |
## Main declarations | |
* `simplicial_complex π E`: A simplicial complex in the `π`-module `E`. | |
* `simplicial_complex.vertices`: The zero dimensional faces of a simplicial complex. | |
* `simplicial_complex.facets`: The maximal faces of a simplicial complex. | |
## Notation | |
`s β K` means that `s` is a face of `K`. | |
`K β€ L` means that the faces of `K` are faces of `L`. | |
## Implementation notes | |
"glue nicely" usually means that the intersection of two faces (as sets in the ambient space) is a | |
face. Given that we store the vertices, not the faces, this would be a bit awkward to spell. | |
Instead, `simplicial_complex.inter_subset_convex_hull` is an equivalent condition which works on the | |
vertices. | |
## TODO | |
Simplicial complexes can be generalized to affine spaces once `convex_hull` has been ported. | |
-/ | |
open finset set | |
variables (π E : Type*) {ΞΉ : Type*} [ordered_ring π] [add_comm_group E] [module π E] | |
namespace geometry | |
/-- A simplicial complex in a `π`-module is a collection of simplices which glue nicely together. | |
Note that the textbook meaning of "glue nicely" is given in | |
`geometry.simplicial_complex.disjoint_or_exists_inter_eq_convex_hull`. It is mostly useless, as | |
`geometry.simplicial_complex.convex_hull_inter_convex_hull` is enough for all purposes. -/ | |
-- TODO: update to new binder order? not sure what binder order is correct for `down_closed`. | |
@[ext] structure simplicial_complex := | |
(faces : set (finset E)) | |
(not_empty_mem : β β faces) | |
(indep : β {s}, s β faces β affine_independent π (coe : (s : set E) β E)) | |
(down_closed : β {s t}, s β faces β t β s β t β β β t β faces) | |
(inter_subset_convex_hull : β {s t}, s β faces β t β faces β | |
convex_hull π βs β© convex_hull π βt β convex_hull π (s β© t : set E)) | |
namespace simplicial_complex | |
variables {π E} {K : simplicial_complex π E} {s t : finset E} {x : E} | |
/-- A `finset` belongs to a `simplicial_complex` if it's a face of it. -/ | |
instance : has_mem (finset E) (simplicial_complex π E) := β¨Ξ» s K, s β K.facesβ© | |
/-- The underlying space of a simplicial complex is the union of its faces. -/ | |
def space (K : simplicial_complex π E) : set E := β s β K.faces, convex_hull π (s : set E) | |
lemma mem_space_iff : x β K.space β β s β K.faces, x β convex_hull π (s : set E) := mem_Unionβ | |
lemma convex_hull_subset_space (hs : s β K.faces) : convex_hull π βs β K.space := | |
subset_bUnion_of_mem hs | |
protected lemma subset_space (hs : s β K.faces) : (s : set E) β K.space := | |
(subset_convex_hull π _).trans $ convex_hull_subset_space hs | |
lemma convex_hull_inter_convex_hull (hs : s β K.faces) (ht : t β K.faces) : | |
convex_hull π βs β© convex_hull π βt = convex_hull π (s β© t : set E) := | |
(K.inter_subset_convex_hull hs ht).antisymm $ subset_inter | |
(convex_hull_mono $ set.inter_subset_left _ _) $ convex_hull_mono $ set.inter_subset_right _ _ | |
/-- The conclusion is the usual meaning of "glue nicely" in textbooks. It turns out to be quite | |
unusable, as it's about faces as sets in space rather than simplices. Further, additional structure | |
on `π` means the only choice of `u` is `s β© t` (but it's hard to prove). -/ | |
lemma disjoint_or_exists_inter_eq_convex_hull (hs : s β K.faces) (ht : t β K.faces) : | |
disjoint (convex_hull π (s : set E)) (convex_hull π βt) β¨ | |
β u β K.faces, convex_hull π (s : set E) β© convex_hull π βt = convex_hull π βu := | |
begin | |
classical, | |
by_contra' h, | |
refine h.2 (s β© t) (K.down_closed hs (inter_subset_left _ _) $ Ξ» hst, h.1 $ | |
(K.inter_subset_convex_hull hs ht).trans _) _, | |
{ rw [βcoe_inter, hst, coe_empty, convex_hull_empty], | |
refl }, | |
{ rw [coe_inter, convex_hull_inter_convex_hull hs ht] } | |
end | |
/-- Construct a simplicial complex by removing the empty face for you. -/ | |
@[simps] def of_erase | |
(faces : set (finset E)) | |
(indep : β s β faces, affine_independent π (coe : (s : set E) β E)) | |
(down_closed : β s β faces, β t β s, t β faces) | |
(inter_subset_convex_hull : β s t β faces, | |
convex_hull π βs β© convex_hull π βt β convex_hull π (s β© t : set E)) : | |
simplicial_complex π E := | |
{ faces := faces \ {β }, | |
not_empty_mem := Ξ» h, h.2 (mem_singleton _), | |
indep := Ξ» s hs, indep _ hs.1, | |
down_closed := Ξ» s t hs hts ht, β¨down_closed _ hs.1 _ hts, htβ©, | |
inter_subset_convex_hull := Ξ» s t hs ht, inter_subset_convex_hull _ hs.1 _ ht.1 } | |
/-- Construct a simplicial complex as a subset of a given simplicial complex. -/ | |
@[simps] def of_subcomplex (K : simplicial_complex π E) | |
(faces : set (finset E)) | |
(subset : faces β K.faces) | |
(down_closed : β {s t}, s β faces β t β s β t β faces) : | |
simplicial_complex π E := | |
{ faces := faces, | |
not_empty_mem := Ξ» h, K.not_empty_mem (subset h), | |
indep := Ξ» s hs, K.indep (subset hs), | |
down_closed := Ξ» s t hs hts _, down_closed hs hts, | |
inter_subset_convex_hull := Ξ» s t hs ht, K.inter_subset_convex_hull (subset hs) (subset ht) } | |
/-! ### Vertices -/ | |
/-- The vertices of a simplicial complex are its zero dimensional faces. -/ | |
def vertices (K : simplicial_complex π E) : set E := {x | {x} β K.faces} | |
lemma mem_vertices : x β K.vertices β {x} β K.faces := iff.rfl | |
lemma vertices_eq : K.vertices = β k β K.faces, (k : set E) := | |
begin | |
ext x, | |
refine β¨Ξ» h, mem_bUnion h $ mem_coe.2 $ mem_singleton_self x, Ξ» h, _β©, | |
obtain β¨s, hs, hxβ© := mem_Unionβ.1 h, | |
exact K.down_closed hs (finset.singleton_subset_iff.2 $ mem_coe.1 hx) (singleton_ne_empty _), | |
end | |
lemma vertices_subset_space : K.vertices β K.space := | |
vertices_eq.subset.trans $ Unionβ_mono $ Ξ» x hx, subset_convex_hull π x | |
lemma vertex_mem_convex_hull_iff (hx : x β K.vertices) (hs : s β K.faces) : | |
x β convex_hull π (s : set E) β x β s := | |
begin | |
refine β¨Ξ» h, _, Ξ» h, subset_convex_hull _ _ hβ©, | |
classical, | |
have h := K.inter_subset_convex_hull hx hs β¨by simp, hβ©, | |
by_contra H, | |
rwa [βcoe_inter, finset.disjoint_iff_inter_eq_empty.1 | |
(finset.disjoint_singleton_right.2 H).symm, coe_empty, convex_hull_empty] at h, | |
end | |
/-- A face is a subset of another one iff its vertices are. -/ | |
lemma face_subset_face_iff (hs : s β K.faces) (ht : t β K.faces) : | |
convex_hull π (s : set E) β convex_hull π βt β s β t := | |
β¨Ξ» h x hxs, (vertex_mem_convex_hull_iff (K.down_closed hs (finset.singleton_subset_iff.2 hxs) $ | |
singleton_ne_empty _) ht).1 (h (subset_convex_hull π βs hxs)), convex_hull_monoβ© | |
/-! ### Facets -/ | |
/-- A facet of a simplicial complex is a maximal face. -/ | |
def facets (K : simplicial_complex π E) : set (finset E) := | |
{s β K.faces | β β¦tβ¦, t β K.faces β s β t β s = t} | |
lemma mem_facets : s β K.facets β s β K.faces β§ β t β K.faces, s β t β s = t := mem_sep_iff | |
lemma facets_subset : K.facets β K.faces := Ξ» s hs, hs.1 | |
lemma not_facet_iff_subface (hs : s β K.faces) : (s β K.facets β β t, t β K.faces β§ s β t) := | |
begin | |
refine β¨Ξ» (hs' : Β¬ (_ β§ _)), _, _β©, | |
{ push_neg at hs', | |
obtain β¨t, htβ© := hs' hs, | |
exact β¨t, ht.1, β¨ht.2.1, (Ξ» hts, ht.2.2 (subset.antisymm ht.2.1 hts))β©β© }, | |
{ rintro β¨t, htβ© β¨hs, hs'β©, | |
have := hs' ht.1 ht.2.1, | |
rw this at ht, | |
exact ht.2.2 (subset.refl t) } -- `has_ssubset.ssubset.ne` would be handy here | |
end | |
/-! | |
### The semilattice of simplicial complexes | |
`K β€ L` means that `K.faces β L.faces`. | |
-/ | |
variables (π E) | |
/-- The complex consisting of only the faces present in both of its arguments. -/ | |
instance : has_inf (simplicial_complex π E) := | |
β¨Ξ» K L, { faces := K.faces β© L.faces, | |
not_empty_mem := Ξ» h, K.not_empty_mem (set.inter_subset_left _ _ h), | |
indep := Ξ» s hs, K.indep hs.1, | |
down_closed := Ξ» s t hs hst ht, β¨K.down_closed hs.1 hst ht, L.down_closed hs.2 hst htβ©, | |
inter_subset_convex_hull := Ξ» s t hs ht, K.inter_subset_convex_hull hs.1 ht.1 }β© | |
instance : semilattice_inf (simplicial_complex π E) := | |
{ inf := (β), | |
inf_le_left := Ξ» K L s hs, hs.1, | |
inf_le_right := Ξ» K L s hs, hs.2, | |
le_inf := Ξ» K L M hKL hKM s hs, β¨hKL hs, hKM hsβ©, | |
.. (partial_order.lift faces $ Ξ» x y, ext _ _) } | |
instance : has_bot (simplicial_complex π E) := | |
β¨{ faces := β , | |
not_empty_mem := set.not_mem_empty β , | |
indep := Ξ» s hs, (set.not_mem_empty _ hs).elim, | |
down_closed := Ξ» s _ hs, (set.not_mem_empty _ hs).elim, | |
inter_subset_convex_hull := Ξ» s _ hs, (set.not_mem_empty _ hs).elim }β© | |
instance : order_bot (simplicial_complex π E) := | |
{ bot_le := Ξ» K, set.empty_subset _, .. simplicial_complex.has_bot π E } | |
instance : inhabited (simplicial_complex π E) := β¨β₯β© | |
variables {π E} | |
lemma faces_bot : (β₯ : simplicial_complex π E).faces = β := rfl | |
lemma space_bot : (β₯ : simplicial_complex π E).space = β := set.bUnion_empty _ | |
lemma facets_bot : (β₯ : simplicial_complex π E).facets = β := eq_empty_of_subset_empty facets_subset | |
end simplicial_complex | |
end geometry | |