Datasets:
Tasks:
Text Generation
Modalities:
Text
Sub-tasks:
language-modeling
Languages:
English
Size:
100K - 1M
License:
File size: 10,211 Bytes
4365a98 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 |
/-
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
|