Zhangir Azerbayev
squashed?
4365a98
raw
history blame
10.2 kB
/-
Copyright (c) 2022 Yaรซl Dillies. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yaรซl Dillies
-/
import analysis.convex.combination
/-!
# Convex join
This file defines the convex join of two sets. The convex join of `s` and `t` is the union of the
segments with one end in `s` and the other in `t`. This is notably a useful gadget to deal with
convex hulls of finite sets.
-/
open set
open_locale big_operators
variables {ฮน : Sort*} {๐•œ E : Type*}
section ordered_semiring
variables (๐•œ) [ordered_semiring ๐•œ] [add_comm_monoid E] [module ๐•œ E] {s t sโ‚ sโ‚‚ tโ‚ tโ‚‚ u : set E}
{x y : E}
/-- The join of two sets is the union of the segments joining them. This can be interpreted as the
topological join, but within the original space. -/
def convex_join (s t : set E) : set E := โ‹ƒ (x โˆˆ s) (y โˆˆ t), segment ๐•œ x y
variables {๐•œ}
lemma mem_convex_join : x โˆˆ convex_join ๐•œ s t โ†” โˆƒ (a โˆˆ s) (b โˆˆ t), x โˆˆ segment ๐•œ a b :=
by simp [convex_join]
lemma convex_join_comm (s t : set E) : convex_join ๐•œ s t = convex_join ๐•œ t s :=
(Unionโ‚‚_comm _).trans $ by simp_rw [convex_join, segment_symm]
lemma convex_join_mono (hs : sโ‚ โŠ† sโ‚‚) (ht : tโ‚ โŠ† tโ‚‚) : convex_join ๐•œ sโ‚ tโ‚ โŠ† convex_join ๐•œ sโ‚‚ tโ‚‚ :=
bUnion_mono hs $ ฮป x hx, bUnion_mono ht $ ฮป y hy, subset.rfl
lemma convex_join_mono_left (hs : sโ‚ โŠ† sโ‚‚) : convex_join ๐•œ sโ‚ t โŠ† convex_join ๐•œ sโ‚‚ t :=
convex_join_mono hs subset.rfl
lemma convex_join_mono_right (ht : tโ‚ โŠ† tโ‚‚) : convex_join ๐•œ s tโ‚ โŠ† convex_join ๐•œ s tโ‚‚ :=
convex_join_mono subset.rfl ht
@[simp] lemma convex_join_empty_left (t : set E) : convex_join ๐•œ โˆ… t = โˆ… := by simp [convex_join]
@[simp] lemma convex_join_empty_right (s : set E) : convex_join ๐•œ s โˆ… = โˆ… := by simp [convex_join]
@[simp] lemma convex_join_singleton_left (t : set E) (x : E) :
convex_join ๐•œ {x} t = โ‹ƒ (y โˆˆ t), segment ๐•œ x y := by simp [convex_join]
@[simp] lemma convex_join_singleton_right (s : set E) (y : E) :
convex_join ๐•œ s {y} = โ‹ƒ (x โˆˆ s), segment ๐•œ x y := by simp [convex_join]
@[simp] lemma convex_join_singletons (x : E) : convex_join ๐•œ {x} {y} = segment ๐•œ x y :=
by simp [convex_join]
@[simp] lemma convex_join_union_left (sโ‚ sโ‚‚ t : set E) :
convex_join ๐•œ (sโ‚ โˆช sโ‚‚) t = convex_join ๐•œ sโ‚ t โˆช convex_join ๐•œ sโ‚‚ t :=
by simp_rw [convex_join, mem_union_eq, Union_or, Union_union_distrib]
@[simp] lemma convex_join_union_right (s tโ‚ tโ‚‚ : set E) :
convex_join ๐•œ s (tโ‚ โˆช tโ‚‚) = convex_join ๐•œ s tโ‚ โˆช convex_join ๐•œ s tโ‚‚ :=
by simp_rw [convex_join, mem_union_eq, Union_or, Union_union_distrib]
@[simp] lemma convex_join_Union_left (s : ฮน โ†’ set E) (t : set E) :
convex_join ๐•œ (โ‹ƒ i, s i) t = โ‹ƒ i, convex_join ๐•œ (s i) t :=
by { simp_rw [convex_join, mem_Union, Union_exists], exact Union_comm _ }
@[simp] lemma convex_join_Union_right (s : set E) (t : ฮน โ†’ set E) :
convex_join ๐•œ s (โ‹ƒ i, t i) = โ‹ƒ i, convex_join ๐•œ s (t i) :=
by simp_rw [convex_join_comm s, convex_join_Union_left]
lemma segment_subset_convex_join (hx : x โˆˆ s) (hy : y โˆˆ t) : segment ๐•œ x y โŠ† convex_join ๐•œ s t :=
(subset_Unionโ‚‚ y hy).trans (subset_Unionโ‚‚ x hx)
lemma subset_convex_join_left (h : t.nonempty) : s โŠ† convex_join ๐•œ s t :=
ฮป x hx, let โŸจy, hyโŸฉ := h in segment_subset_convex_join hx hy $ left_mem_segment _ _ _
lemma subset_convex_join_right (h : s.nonempty) : t โŠ† convex_join ๐•œ s t :=
ฮป y hy, let โŸจx, hxโŸฉ := h in segment_subset_convex_join hx hy $ right_mem_segment _ _ _
lemma convex_join_subset (hs : s โŠ† u) (ht : t โŠ† u) (hu : convex ๐•œ u) : convex_join ๐•œ s t โŠ† u :=
Unionโ‚‚_subset $ ฮป x hx, Unionโ‚‚_subset $ ฮป y hy, hu.segment_subset (hs hx) (ht hy)
lemma convex_join_subset_convex_hull (s t : set E) : convex_join ๐•œ s t โŠ† convex_hull ๐•œ (s โˆช t) :=
convex_join_subset ((subset_union_left _ _).trans $ subset_convex_hull _ _)
((subset_union_right _ _).trans $ subset_convex_hull _ _) $ convex_convex_hull _ _
end ordered_semiring
section linear_ordered_field
variables [linear_ordered_field ๐•œ] [add_comm_group E] [module ๐•œ E] {s t u : set E} {x y : E}
lemma convex_join_assoc_aux (s t u : set E) :
convex_join ๐•œ (convex_join ๐•œ s t) u โŠ† convex_join ๐•œ s (convex_join ๐•œ t u) :=
begin
simp_rw [subset_def, mem_convex_join],
rintro _ โŸจz, โŸจx, hx, y, hy, aโ‚, bโ‚, haโ‚, hbโ‚, habโ‚, rflโŸฉ, z, hz, aโ‚‚, bโ‚‚, haโ‚‚, hbโ‚‚, habโ‚‚, rflโŸฉ,
obtain rfl | hbโ‚‚ := hbโ‚‚.eq_or_lt,
{ refine โŸจx, hx, y, โŸจy, hy, z, hz, left_mem_segment _ _ _โŸฉ, aโ‚, bโ‚, haโ‚, hbโ‚, habโ‚, _โŸฉ,
rw add_zero at habโ‚‚,
rw [habโ‚‚, one_smul, zero_smul, add_zero] },
have haโ‚‚bโ‚ : 0 โ‰ค aโ‚‚ * bโ‚ := mul_nonneg haโ‚‚ hbโ‚,
have hab : 0 < aโ‚‚ * bโ‚ + bโ‚‚ := add_pos_of_nonneg_of_pos haโ‚‚bโ‚ hbโ‚‚,
refine โŸจx, hx, ((aโ‚‚ * bโ‚) / (aโ‚‚ * bโ‚ + bโ‚‚)) โ€ข y + (bโ‚‚ / (aโ‚‚ * bโ‚ + bโ‚‚)) โ€ข z,
โŸจy, hy, z, hz, _, _, _, _, _, rflโŸฉ, aโ‚‚ * aโ‚, aโ‚‚ * bโ‚ + bโ‚‚, mul_nonneg haโ‚‚ haโ‚, hab.le, _, _โŸฉ,
{ exact div_nonneg haโ‚‚bโ‚ hab.le },
{ exact div_nonneg hbโ‚‚.le hab.le },
{ rw [โ†add_div, div_self hab.ne'] },
{ rw [โ†add_assoc, โ†mul_add, habโ‚, mul_one, habโ‚‚] },
{ simp_rw [smul_add, โ†mul_smul, mul_div_cancel' _ hab.ne', add_assoc] }
end
lemma convex_join_assoc (s t u : set E) :
convex_join ๐•œ (convex_join ๐•œ s t) u = convex_join ๐•œ s (convex_join ๐•œ t u) :=
begin
refine (convex_join_assoc_aux _ _ _).antisymm _,
simp_rw [convex_join_comm s, convex_join_comm _ u],
exact convex_join_assoc_aux _ _ _,
end
lemma convex_join_left_comm (s t u : set E) :
convex_join ๐•œ s (convex_join ๐•œ t u) = convex_join ๐•œ t (convex_join ๐•œ s u) :=
by simp_rw [โ†convex_join_assoc, convex_join_comm]
lemma convex_join_right_comm (s t u : set E) :
convex_join ๐•œ (convex_join ๐•œ s t) u = convex_join ๐•œ (convex_join ๐•œ s u) t :=
by simp_rw [convex_join_assoc, convex_join_comm]
lemma convex_join_convex_join_convex_join_comm (s t u v : set E) :
convex_join ๐•œ (convex_join ๐•œ s t) (convex_join ๐•œ u v) =
convex_join ๐•œ (convex_join ๐•œ s u) (convex_join ๐•œ t v) :=
by simp_rw [โ†convex_join_assoc, convex_join_right_comm]
lemma convex_hull_insert (hs : s.nonempty) :
convex_hull ๐•œ (insert x s) = convex_join ๐•œ {x} (convex_hull ๐•œ s) :=
begin
classical,
refine (convex_join_subset ((singleton_subset_iff.2 $ mem_insert _ _).trans $ subset_convex_hull
_ _) (convex_hull_mono $ subset_insert _ _) $ convex_convex_hull _ _).antisymm' (ฮป x hx, _),
rw convex_hull_eq at hx,
obtain โŸจฮน, t, w, z, hwโ‚€, hwโ‚, hz, rflโŸฉ := hx,
have : (โˆ‘ i in t.filter (ฮป i, z i = x), w i) โ€ข x + โˆ‘ i in t.filter (ฮป i, z i โ‰  x), w i โ€ข z i =
t.center_mass w z,
{ rw [finset.center_mass_eq_of_sum_1 _ _ hwโ‚, finset.sum_smul],
convert finset.sum_filter_add_sum_filter_not _ _ (w โ€ข z) using 2,
refine finset.sum_congr rfl (ฮป i hi, _),
rw [pi.smul_apply', (finset.mem_filter.1 hi).2] },
rw โ†this,
have hwโ‚€' : โˆ€ i โˆˆ t.filter (ฮป i, z i โ‰  x), 0 โ‰ค w i := ฮป i hi, hwโ‚€ _ $ finset.filter_subset _ _ hi,
obtain hw | hw := (finset.sum_nonneg hwโ‚€').eq_or_gt,
{ rw [โ†finset.sum_filter_add_sum_filter_not _ (ฮป i, z i = x), hw, add_zero] at hwโ‚,
rw [hwโ‚, one_smul, finset.sum_eq_zero, add_zero],
{ exact subset_convex_join_left hs.convex_hull (mem_singleton _) },
simp_rw finset.sum_eq_zero_iff_of_nonneg hwโ‚€' at hw,
rintro i hi,
rw [hw _ hi, zero_smul] },
refine mem_convex_join.2 โŸจx, mem_singleton _, (t.filter $ ฮป i, z i โ‰  x).center_mass w z,
finset.center_mass_mem_convex_hull _ hwโ‚€' hw (ฮป i hi, _),
โˆ‘ i in t.filter (ฮป i, z i = x), w i, โˆ‘ i in t.filter (ฮป i, z i โ‰  x), w i,
finset.sum_nonneg (ฮป i hi, hwโ‚€ _ $ finset.filter_subset _ _ hi), finset.sum_nonneg hwโ‚€', _, _โŸฉ,
{ rw finset.mem_filter at hi,
exact mem_of_mem_insert_of_ne (hz _ hi.1) hi.2 },
{ rw [finset.sum_filter_add_sum_filter_not, hwโ‚] },
{ rw [finset.center_mass, smul_inv_smulโ‚€ hw.ne', finset.sum_smul] }
end
lemma convex_join_segments (a b c d : E) :
convex_join ๐•œ (segment ๐•œ a b) (segment ๐•œ c d) = convex_hull ๐•œ {a, b, c, d} :=
by simp only [convex_hull_insert, insert_nonempty, singleton_nonempty, convex_hull_pair,
โ†convex_join_assoc, convex_join_singletons]
lemma convex_join_segment_singleton (a b c : E) :
convex_join ๐•œ (segment ๐•œ a b) {c} = convex_hull ๐•œ {a, b, c} :=
by rw [โ†pair_eq_singleton, โ†convex_join_segments, segment_same, pair_eq_singleton]
lemma convex_join_singleton_segment (a b c : E) :
convex_join ๐•œ {a} (segment ๐•œ b c) = convex_hull ๐•œ {a, b, c} :=
by rw [โ†segment_same ๐•œ, convex_join_segments, insert_idem]
protected lemma convex.convex_join (hs : convex ๐•œ s) (ht : convex ๐•œ t) :
convex ๐•œ (convex_join ๐•œ s t) :=
begin
rw convex_iff_segment_subset at โŠข ht hs,
simp_rw mem_convex_join,
rintro x y โŸจxa, hxa, xb, hxb, hxโŸฉ โŸจya, hya, yb, hyb, hyโŸฉ,
refine (segment_subset_convex_join hx hy).trans _,
have triv : ({xa, xb, ya, yb} : set E) = {xa, ya, xb, yb} := by simp only [set.insert_comm],
rw [convex_join_segments, triv, โ†convex_join_segments],
exact convex_join_mono (hs hxa hya) (ht hxb hyb),
end
protected lemma convex.convex_hull_union (hs : convex ๐•œ s) (ht : convex ๐•œ t) (hsโ‚€ : s.nonempty)
(htโ‚€ : t.nonempty) :
convex_hull ๐•œ (s โˆช t) = convex_join ๐•œ s t :=
(convex_hull_min (union_subset (subset_convex_join_left htโ‚€) $ subset_convex_join_right hsโ‚€) $
hs.convex_join ht).antisymm $ convex_join_subset_convex_hull _ _
lemma convex_hull_union (hs : s.nonempty) (ht : t.nonempty) :
convex_hull ๐•œ (s โˆช t) = convex_join ๐•œ (convex_hull ๐•œ s) (convex_hull ๐•œ t) :=
begin
rw [โ†convex_hull_convex_hull_union_left, โ†convex_hull_convex_hull_union_right],
exact (convex_convex_hull ๐•œ s).convex_hull_union (convex_convex_hull ๐•œ t)
hs.convex_hull ht.convex_hull,
end
end linear_ordered_field