Datasets:

Modalities:
Text
Languages:
English
Libraries:
Datasets
License:
Zhangir Azerbayev
squashed?
4365a98
raw
history blame
7.09 kB
/-
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
/-!
# Convex hull
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.
## Implementation notes
`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