Datasets:
Tasks:
Text Generation
Modalities:
Text
Sub-tasks:
language-modeling
Languages:
English
Size:
100K - 1M
License:
/- | |
Copyright (c) 2020 Yury Kudriashov. All rights reserved. | |
Released under Apache 2.0 license as described in the file LICENSE. | |
Authors: Yury Kudriashov, YaΓ«l Dillies | |
-/ | |
import analysis.convex.basic | |
import order.closure | |
/-! | |
This file defines the convex hull of a set `s` in a module. `convex_hull π s` is the smallest convex | |
set containing `s`. In order theory speak, this is a closure operator. | |
`convex_hull` is defined as a closure operator. This gives access to the `closure_operator` API | |
while the impact on writing code is minimal as `convex_hull π s` is automatically elaborated as | |
`β(convex_hull π) s`. | |
-/ | |
open set | |
open_locale pointwise | |
variables {π E F : Type*} | |
section convex_hull | |
section ordered_semiring | |
variables [ordered_semiring π] | |
section add_comm_monoid | |
variables (π) [add_comm_monoid E] [add_comm_monoid F] [module π E] [module π F] | |
/-- The convex hull of a set `s` is the minimal convex set that includes `s`. -/ | |
def convex_hull : closure_operator (set E) := | |
closure_operator.mkβ | |
(Ξ» s, β (t : set E) (hst : s β t) (ht : convex π t), t) | |
(convex π) | |
(Ξ» s, set.subset_Inter (Ξ» t, set.subset_Inter $ Ξ» hst, set.subset_Inter $ Ξ» ht, hst)) | |
(Ξ» s, convex_Inter $ Ξ» t, convex_Inter $ Ξ» ht, convex_Inter id) | |
(Ξ» s t hst ht, set.Inter_subset_of_subset t $ set.Inter_subset_of_subset hst $ | |
set.Inter_subset _ ht) | |
variables (s : set E) | |
lemma subset_convex_hull : s β convex_hull π s := (convex_hull π).le_closure s | |
lemma convex_convex_hull : convex π (convex_hull π s) := closure_operator.closure_mem_mkβ s | |
lemma convex_hull_eq_Inter : convex_hull π s = β (t : set E) (hst : s β t) (ht : convex π t), t := | |
rfl | |
variables {π s} {t : set E} {x y : E} | |
lemma mem_convex_hull_iff : x β convex_hull π s β β t, s β t β convex π t β x β t := | |
by simp_rw [convex_hull_eq_Inter, mem_Inter] | |
lemma convex_hull_min (hst : s β t) (ht : convex π t) : convex_hull π s β t := | |
closure_operator.closure_le_mkβ_iff (show s β€ t, from hst) ht | |
lemma convex.convex_hull_subset_iff (ht : convex π t) : convex_hull π s β t β s β t := | |
β¨(subset_convex_hull _ _).trans, Ξ» h, convex_hull_min h htβ© | |
@[mono] lemma convex_hull_mono (hst : s β t) : convex_hull π s β convex_hull π t := | |
(convex_hull π).monotone hst | |
lemma convex.convex_hull_eq (hs : convex π s) : convex_hull π s = s := | |
closure_operator.mem_mkβ_closed hs | |
@[simp] lemma convex_hull_univ : convex_hull π (univ : set E) = univ := | |
closure_operator.closure_top (convex_hull π) | |
@[simp] lemma convex_hull_empty : convex_hull π (β : set E) = β := convex_empty.convex_hull_eq | |
@[simp] lemma convex_hull_empty_iff : convex_hull π s = β β s = β := | |
begin | |
split, | |
{ intro h, | |
rw [βset.subset_empty_iff, βh], | |
exact subset_convex_hull π _ }, | |
{ rintro rfl, | |
exact convex_hull_empty } | |
end | |
@[simp] lemma convex_hull_nonempty_iff : (convex_hull π s).nonempty β s.nonempty := | |
begin | |
rw [βne_empty_iff_nonempty, βne_empty_iff_nonempty, ne.def, ne.def], | |
exact not_congr convex_hull_empty_iff, | |
end | |
alias convex_hull_nonempty_iff β _ set.nonempty.convex_hull | |
attribute [protected] set.nonempty.convex_hull | |
lemma segment_subset_convex_hull (hx : x β s) (hy : y β s) : segment π x y β convex_hull π s := | |
(convex_convex_hull _ _).segment_subset (subset_convex_hull _ _ hx) (subset_convex_hull _ _ hy) | |
@[simp] lemma convex_hull_singleton (x : E) : convex_hull π ({x} : set E) = {x} := | |
(convex_singleton x).convex_hull_eq | |
@[simp] lemma convex_hull_pair (x y : E) : convex_hull π {x, y} = segment π x y := | |
begin | |
refine (convex_hull_min _ $ convex_segment _ _).antisymm | |
(segment_subset_convex_hull (mem_insert _ _) $ mem_insert_of_mem _ $ mem_singleton _), | |
rw [insert_subset, singleton_subset_iff], | |
exact β¨left_mem_segment _ _ _, right_mem_segment _ _ _β©, | |
end | |
lemma convex_hull_convex_hull_union_left (s t : set E) : | |
convex_hull π (convex_hull π s βͺ t) = convex_hull π (s βͺ t) := | |
closure_operator.closure_sup_closure_left _ _ _ | |
lemma convex_hull_convex_hull_union_right (s t : set E) : | |
convex_hull π (s βͺ convex_hull π t) = convex_hull π (s βͺ t) := | |
closure_operator.closure_sup_closure_right _ _ _ | |
lemma convex.convex_remove_iff_not_mem_convex_hull_remove {s : set E} (hs : convex π s) (x : E) : | |
convex π (s \ {x}) β x β convex_hull π (s \ {x}) := | |
begin | |
split, | |
{ rintro hsx hx, | |
rw hsx.convex_hull_eq at hx, | |
exact hx.2 (mem_singleton _) }, | |
rintro hx, | |
suffices h : s \ {x} = convex_hull π (s \ {x}), { convert convex_convex_hull π _ }, | |
exact subset.antisymm (subset_convex_hull π _) (Ξ» y hy, β¨convex_hull_min (diff_subset _ _) hs hy, | |
by { rintro (rfl : y = x), exact hx hy }β©), | |
end | |
lemma is_linear_map.convex_hull_image {f : E β F} (hf : is_linear_map π f) (s : set E) : | |
convex_hull π (f '' s) = f '' convex_hull π s := | |
set.subset.antisymm (convex_hull_min (image_subset _ (subset_convex_hull π s)) $ | |
(convex_convex_hull π s).is_linear_image hf) | |
(image_subset_iff.2 $ convex_hull_min | |
(image_subset_iff.1 $ subset_convex_hull π _) | |
((convex_convex_hull π _).is_linear_preimage hf)) | |
lemma linear_map.convex_hull_image (f : E ββ[π] F) (s : set E) : | |
convex_hull π (f '' s) = f '' convex_hull π s := | |
f.is_linear.convex_hull_image s | |
end add_comm_monoid | |
end ordered_semiring | |
section ordered_comm_semiring | |
variables [ordered_comm_semiring π] [add_comm_monoid E] [module π E] | |
lemma convex_hull_smul (a : π) (s : set E) : convex_hull π (a β’ s) = a β’ convex_hull π s := | |
(linear_map.lsmul _ _ a).convex_hull_image _ | |
end ordered_comm_semiring | |
section ordered_ring | |
variables [ordered_ring π] | |
section add_comm_group | |
variables [add_comm_group E] [add_comm_group F] [module π E] [module π F] (s : set E) | |
lemma affine_map.image_convex_hull (f : E βα΅[π] F) : | |
f '' convex_hull π s = convex_hull π (f '' s) := | |
begin | |
apply set.subset.antisymm, | |
{ rw set.image_subset_iff, | |
refine convex_hull_min _ ((convex_convex_hull π (βf '' s)).affine_preimage f), | |
rw β set.image_subset_iff, | |
exact subset_convex_hull π (f '' s) }, | |
{ exact convex_hull_min (set.image_subset _ (subset_convex_hull π s)) | |
((convex_convex_hull π s).affine_image f) } | |
end | |
lemma convex_hull_subset_affine_span : convex_hull π s β (affine_span π s : set E) := | |
convex_hull_min (subset_affine_span π s) (affine_span π s).convex | |
@[simp] lemma affine_span_convex_hull : affine_span π (convex_hull π s) = affine_span π s := | |
begin | |
refine le_antisymm _ (affine_span_mono π (subset_convex_hull π s)), | |
rw affine_span_le, | |
exact convex_hull_subset_affine_span s, | |
end | |
lemma convex_hull_neg (s : set E) : convex_hull π (-s) = -convex_hull π s := | |
by { simp_rw βimage_neg, exact (affine_map.image_convex_hull _ $ -1).symm } | |
end add_comm_group | |
end ordered_ring | |
end convex_hull | |