|
|
|
|
SSL Basic.lean
Sprache: Lean
|
|
/-
Copyright (c) 2019 Alexander Bentkamp. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Alexander Bentkamp, Yury Kudryashov, Yaël Dillies
-/
module
public import Mathlib.Analysis.Convex.Star
public import Mathlib.LinearAlgebra.AffineSpace.AffineSubspace.Defs
public import Mathlib.Tactic.Field
import Mathlib.Algebra.Ring.Action.Pointwise.Set
import Mathlib.Tactic.NoncommRing
/-!
# Convex sets
In a -vector space, we define the following property:
* `Convex s`: A set `s` is convex if for any two points `x y ∈ s` it includes `segment x y`.
We provide various equivalent versions, and prove that some specific sets are convex.
## TODO
Generalize all this file to affine spaces.
-/
@[expose] public section
variable { E F β : Type*}
open LinearMap Set
open scoped Convex Pointwise
/-! ### Convexity of sets -/
section OrderedSemiring
variable [Semiring ] [PartialOrder ]
section AddCommMonoid
variable [AddCommMonoid E] [AddCommMonoid F]
section SMul
variable () [SMul E] [SMul F] (s : Set E) {x : E}
/-- Convexity of sets. -/
def Convex : Prop :=
∀ ⦃x : E⦄, x ∈ s → StarConvex x s
variable { s}
theorem Convex.starConvex (hs : Convex s) (hx : x ∈ s) : StarConvex x s :=
hs hx
theorem convex_iff_segment_subset : Convex s ↔ ∀ ⦃x⦄, x ∈ s → ∀ ⦃y⦄, y ∈ s → [x -[] y] ⊆ s :=
forall₂_congr fun _ _ => starConvex_iff_segment_subset
theorem Convex.segment_subset (h : Convex s) {x y : E} (hx : x ∈ s) (hy : y ∈ s) :
[x -[] y] ⊆ s :=
convex_iff_segment_subset.1 h hx hy
theorem Convex.openSegment_subset (h : Convex s) {x y : E} (hx : x ∈ s) (hy : y ∈ s) :
openSegment x y ⊆ s :=
(openSegment_subset_segment x y).trans (h.segment_subset hx hy)
theorem convex_iff_add_mem : Convex s ↔
∀ ⦃x⦄, x ∈ s → ∀ ⦃y⦄, y ∈ s → ∀ ⦃a b : ⦄, 0 ≤ a → 0 ≤ b → a + b = 1 → a • x + b • y ∈ s := by
simp_rw [convex_iff_segment_subset, segment_subset_iff]
/-- Alternative definition of set convexity, in terms of pointwise set operations. -/
theorem convex_iff_pointwise_add_subset :
Convex s ↔ ∀ ⦃a b : ⦄, 0 ≤ a → 0 ≤ b → a + b = 1 → a • s + b • s ⊆ s :=
Iff.intro
(by
rintro hA a b ha hb hab w ⟨au, ⟨u, hu, rfl⟩, bv, ⟨v, hv, rfl⟩, rfl⟩
exact hA hu hv ha hb hab)
fun h _ hx _ hy _ _ ha hb hab => (h ha hb hab) (Set.add_mem_add ⟨_, hx, rfl⟩ ⟨_, hy, rfl⟩)
alias ⟨Convex.set_combo_subset, _⟩ := convex_iff_pointwise_add_subset
theorem convex_empty : Convex (∅ : Set E) := fun _ => False.elim
theorem convex_univ : Convex (Set.univ : Set E) := fun _ _ => starConvex_univ _
theorem Convex.inter {t : Set E} (hs : Convex s) (ht : Convex t) : Convex (s ∩ t) :=
fun _ hx => (hs hx.1).inter (ht hx.2)
theorem convex_sInter {S : Set (Set E)} (h : ∀ s ∈ S, Convex s) : Convex (⋂₀ S) := fun _ hx =>
starConvex_sInter fun _ hs => h _ hs <| hx _ hs
theorem convex_iInter {ι : Sort*} {s : ι → Set E} (h : ∀ i, Convex (s i)) :
Convex (⋂ i, s i) :=
sInter_range s ▸ convex_sInter <| forall_mem_range.2 h
theorem convex_iInter₂ {ι : Sort*} {κ : ι → Sort*} {s : (i : ι) → κ i → Set E}
(h : ∀ i j, Convex (s i j)) : Convex (⋂ (i) (j), s i j) :=
convex_iInter fun i => convex_iInter <| h i
theorem Convex.prod {s : Set E} {t : Set F} (hs : Convex s) (ht : Convex t) :
Convex (s ×ˢ t) := fun _ hx => (hs hx.1).prod (ht hx.2)
theorem convex_pi {ι : Type*} {E : ι → Type*} [∀ i, AddCommMonoid (E i)] [∀ i, SMul (E i)]
{s : Set ι} {t : ∀ i, Set (E i)} (ht : ∀ ⦃i⦄, i ∈ s → Convex (t i)) : Convex (s.pi t) :=
fun _ hx => starConvex_pi fun _ hi => ht hi <| hx _ hi
theorem Directed.convex_iUnion {ι : Sort*} {s : ι → Set E} (hdir : Directed (· ⊆ ·) s)
(hc : ∀ ⦃i : ι⦄, Convex (s i)) : Convex (⋃ i, s i) := by
rintro x hx y hy a b ha hb hab
rw [mem_iUnion] at hx hy ⊢
obtain ⟨i, hx⟩ := hx
obtain ⟨j, hy⟩ := hy
obtain ⟨k, hik, hjk⟩ := hdir i j
exact ⟨k, hc (hik hx) (hjk hy) ha hb hab⟩
theorem DirectedOn.convex_sUnion {c : Set (Set E)} (hdir : DirectedOn (· ⊆ ·) c)
(hc : ∀ ⦃A : Set E⦄, A ∈ c → Convex A) : Convex (⋃₀ c) := by
rw [sUnion_eq_iUnion]
exact (directedOn_iff_directed.1 hdir).convex_iUnion fun A => hc A.2
theorem Convex.setOfPred_const_imp {P : Prop} (hs : Convex s) : Convex {x | P → x ∈ s} := by
by_cases hP : P <;> simp [hP, hs, convex_univ]
@[deprecated (since := "2026-07-09")] alias Convex.setOf_const_imp := Convex.setOfPred_const_imp
end SMul
section Module
variable [Module E] [Module F] {s : Set E} {x : E}
theorem convex_iff_openSegment_subset [ZeroLEOneClass ] :
Convex s ↔ ∀ ⦃x⦄, x ∈ s → ∀ ⦃y⦄, y ∈ s → openSegment x y ⊆ s :=
forall₂_congr fun _ => starConvex_iff_openSegment_subset
theorem convex_iff_forall_pos :
Convex s ↔
∀ ⦃x⦄, x ∈ s → ∀ ⦃y⦄, y ∈ s → ∀ ⦃a b : ⦄, 0 < a → 0 < b → a + b = 1 → a • x + b • y ∈ s :=
forall₂_congr fun _ => starConvex_iff_forall_pos
theorem convex_iff_pairwise_pos : Convex s ↔
s.Pairwise fun x y => ∀ ⦃a b : ⦄, 0 < a → 0 < b → a + b = 1 → a • x + b • y ∈ s := by
refine convex_iff_forall_pos.trans ⟨fun h x hx y hy _ => h hx hy, ?_⟩
intro h x hx y hy a b ha hb hab
obtain rfl | hxy := eq_or_ne x y
· rwa [Convex.combo_self hab]
· exact h hx hy hxy ha hb hab
theorem Convex.starConvex_iff [ZeroLEOneClass ] (hs : Convex s) (h : s.Nonempty) :
StarConvex x s ↔ x ∈ s :=
⟨fun hxs => hxs.mem h, hs.starConvex⟩
protected theorem Set.Subsingleton.convex {s : Set E} (h : s.Subsingleton) : Convex s :=
convex_iff_pairwise_pos.mpr (h.pairwise _)
@[simp] theorem convex_singleton (c : E) : Convex ({c} : Set E) :=
subsingleton_singleton.convex
theorem convex_zero : Convex (0 : Set E) :=
convex_singleton _
theorem convex_segment [IsOrderedRing ] (x y : E) : Convex [x -[] y] := by
rintro p ⟨ap, bp, hap, hbp, habp, rfl⟩ q ⟨aq, bq, haq, hbq, habq, rfl⟩ a b ha hb hab
refine
⟨a * ap + b * aq, a * bp + b * bq, add_nonneg (mul_nonneg ha hap) (mul_nonneg hb haq),
add_nonneg (mul_nonneg ha hbp) (mul_nonneg hb hbq), ?_, ?_⟩
· rw [add_add_add_comm, ← mul_add, ← mul_add, habp, habq, mul_one, mul_one, hab]
· match_scalars <;> noncomm_ring
/-- See `Convex.semilinear_image` for a version for semilinear maps, but requiring that `` be a
linear order, instead of just a partial order. -/
theorem Convex.linear_image (hs : Convex s) (f : E →ₗ[] F) : Convex (f '' s) := by
rintro _ ⟨x, hx, rfl⟩ _ ⟨y, hy, rfl⟩ a b ha hb hab
exact ⟨a • x + b • y, hs hx hy ha hb hab, by rw [f.map_add, f.map_smul, f.map_smul]⟩
theorem Convex.is_linear_image (hs : Convex s) {f : E → F} (hf : IsLinearMap f) :
Convex (f '' s) :=
hs.linear_image <| hf.mk' f
theorem Convex.linear_preimage {s : Set F} (hs : Convex s) (f : E →ₗ[] F) : Convex (f ⁻¹' s) :=
fun x hx y hy a b ha hb hab => by
rw [mem_preimage, f.map_add, LinearMap.map_smul_of_tower, LinearMap.map_smul_of_tower]
exact hs hx hy ha hb hab
theorem Convex.is_linear_preimage {s : Set F} (hs : Convex s) {f : E → F} (hf : IsLinearMap f) :
Convex (f ⁻¹' s) := hs.linear_preimage <| hf.mk' f
theorem Convex.add {t : Set E} (hs : Convex s) (ht : Convex t) : Convex (s + t) := by
rw [← add_image_prod]
exact (hs.prod ht).is_linear_image IsLinearMap.isLinearMap_add
variable ( E)
/-- The convex sets form an additive submonoid under pointwise addition. -/
noncomputable def convexAddSubmonoid : AddSubmonoid (Set E) where
carrier := {s : Set E | Convex s}
zero_mem' := convex_zero
add_mem' := Convex.add
@[simp, norm_cast]
theorem coe_convexAddSubmonoid : ↑(convexAddSubmonoid E) = {s : Set E | Convex s} :=
rfl
variable { E}
@[simp]
theorem mem_convexAddSubmonoid {s : Set E} : s ∈ convexAddSubmonoid E ↔ Convex s :=
Iff.rfl
theorem convex_list_sum {l : List (Set E)} (h : ∀ i ∈ l, Convex i) : Convex l.sum :=
(convexAddSubmonoid E).list_sum_mem h
theorem convex_multiset_sum {s : Multiset (Set E)} (h : ∀ i ∈ s, Convex i) : Convex s.sum :=
(convexAddSubmonoid E).multiset_sum_mem _ h
theorem convex_sum {ι} {s : Finset ι} (t : ι → Set E) (h : ∀ i ∈ s, Convex (t i)) :
Convex (∑ i ∈ s, t i) :=
(convexAddSubmonoid E).sum_mem h
theorem Convex.vadd (hs : Convex s) (z : E) : Convex (z +ᵥ s) := by
simp_rw [← image_vadd, vadd_eq_add, ← singleton_add]
exact (convex_singleton _).add hs
theorem Convex.translate (hs : Convex s) (z : E) : Convex ((fun x => z + x) '' s) :=
hs.vadd _
/-- The translation of a convex set is also convex. -/
theorem Convex.translate_preimage_right (hs : Convex s) (z : E) :
Convex ((fun x => z + x) ⁻¹' s) := by
intro x hx y hy a b ha hb hab
have h := hs hx hy ha hb hab
rwa [smul_add, smul_add, add_add_add_comm, ← add_smul, hab, one_smul] at h
/-- The translation of a convex set is also convex. -/
theorem Convex.translate_preimage_left (hs : Convex s) (z : E) :
Convex ((fun x => x + z) ⁻¹' s) := by
simpa only [add_comm] using hs.translate_preimage_right z
section OrderedAddCommMonoid
variable [AddCommMonoid β] [PartialOrder β] [IsOrderedAddMonoid β] [Module β] [PosSMulMono β]
theorem convex_Iic (r : β) : Convex (Iic r) := fun x hx y hy a b ha hb hab =>
calc
a • x + b • y ≤ a • r + b • r :=
add_le_add (smul_le_smul_of_nonneg_left hx ha) (smul_le_smul_of_nonneg_left hy hb)
_ = r := Convex.combo_self hab _
theorem convex_Ici (r : β) : Convex (Ici r) :=
convex_Iic (β := βᵒᵈ) r
theorem convex_Icc (r s : β) : Convex (Icc r s) :=
Ici_inter_Iic.subst ((convex_Ici r).inter <| convex_Iic s)
theorem convex_halfSpace_le {f : E → β} (h : IsLinearMap f) (r : β) : Convex { w | f w ≤ r } :=
(convex_Iic r).is_linear_preimage h
theorem convex_halfSpace_ge {f : E → β} (h : IsLinearMap f) (r : β) : Convex { w | r ≤ f w } :=
(convex_Ici r).is_linear_preimage h
theorem convex_hyperplane {f : E → β} (h : IsLinearMap f) (r : β) : Convex { w | f w = r } := by
simp_rw [le_antisymm_iff]
exact (convex_halfSpace_le h r).inter (convex_halfSpace_ge h r)
end OrderedAddCommMonoid
section OrderedCancelAddCommMonoid
variable [AddCommMonoid β] [PartialOrder β] [IsOrderedCancelAddMonoid β]
[Module β] [PosSMulStrictMono β]
theorem convex_Iio (r : β) : Convex (Iio r) := by
intro x hx y hy a b ha hb hab
obtain rfl | ha' := ha.eq_or_lt
· rw [zero_add] at hab
rwa [zero_smul, zero_add, hab, one_smul]
rw [mem_Iio] at hx hy
calc
a • x + b • y < a • r + b • r := add_lt_add_of_lt_of_le
(smul_lt_smul_of_pos_left hx ha') (smul_le_smul_of_nonneg_left hy.le hb)
_ = r := Convex.combo_self hab _
theorem convex_Ioi (r : β) : Convex (Ioi r) :=
convex_Iio (β := βᵒᵈ) r
theorem convex_Ioo (r s : β) : Convex (Ioo r s) :=
Ioi_inter_Iio.subst ((convex_Ioi r).inter <| convex_Iio s)
theorem convex_Ico (r s : β) : Convex (Ico r s) :=
Ici_inter_Iio.subst ((convex_Ici r).inter <| convex_Iio s)
theorem convex_Ioc (r s : β) : Convex (Ioc r s) :=
Ioi_inter_Iic.subst ((convex_Ioi r).inter <| convex_Iic s)
theorem convex_halfSpace_lt {f : E → β} (h : IsLinearMap f) (r : β) : Convex { w | f w < r } :=
(convex_Iio r).is_linear_preimage h
theorem convex_halfSpace_gt {f : E → β} (h : IsLinearMap f) (r : β) : Convex { w | r < f w } :=
(convex_Ioi r).is_linear_preimage h
end OrderedCancelAddCommMonoid
section LinearOrderedAddCommMonoid
variable [AddCommMonoid β] [LinearOrder β] [IsOrderedAddMonoid β] [Module β] [PosSMulMono β]
theorem convex_uIcc (r s : β) : Convex (uIcc r s) :=
convex_Icc _ _
end LinearOrderedAddCommMonoid
end Module
section IsScalarTower
variable [ZeroLEOneClass ] [Module E]
variable (R : Type*) [Semiring R] [PartialOrder R] [Module R E]
variable [Module R ] [IsScalarTower R E]
/-- Lift the convexity of a set up through a scalar tower. -/
theorem Convex.lift [SMulPosMono R ] {s : Set E} (hs : Convex s) : Convex R s := by
intro x hx y hy a b ha hb hab
suffices (a • (1 : )) • x + (b • (1 : )) • y ∈ s by simpa using this
refine hs hx hy ?_ ?_ (by simpa [add_smul] using congr($hab • (1 : )))
all_goals exact zero_smul R (1 : ) ▸ smul_le_smul_of_nonneg_right ‹_› zero_le_one
end IsScalarTower
end AddCommMonoid
section LinearOrderedAddCommMonoid
variable [AddCommMonoid E] [LinearOrder E] [IsOrderedAddMonoid E]
[PartialOrder β] [Module E] [PosSMulMono E]
{s : Set E} {f : E → β}
theorem MonotoneOn.convex_le (hf : MonotoneOn f s) (hs : Convex s) (r : β) :
Convex ({ x ∈ s | f x ≤ r }) := fun x hx y hy _ _ ha hb hab =>
⟨hs hx.1 hy.1 ha hb hab,
(hf (hs hx.1 hy.1 ha hb hab) (max_rec' (· ∈ s) hx.1 hy.1)
(Convex.combo_le_max x y ha hb hab)).trans
(max_rec' (f · ≤ r) hx.2 hy.2)⟩
theorem MonotoneOn.convex_lt (hf : MonotoneOn f s) (hs : Convex s) (r : β) :
Convex ({ x ∈ s | f x < r }) := fun x hx y hy _ _ ha hb hab =>
⟨hs hx.1 hy.1 ha hb hab,
(hf (hs hx.1 hy.1 ha hb hab) (max_rec' (· ∈ s) hx.1 hy.1)
(Convex.combo_le_max x y ha hb hab)).trans_lt
(max_rec' (f · < r) hx.2 hy.2)⟩
theorem MonotoneOn.convex_ge (hf : MonotoneOn f s) (hs : Convex s) (r : β) :
Convex ({ x ∈ s | r ≤ f x }) :=
MonotoneOn.convex_le (E := Eᵒᵈ) (β := βᵒᵈ) hf.dual (by exact hs) r
theorem MonotoneOn.convex_gt (hf : MonotoneOn f s) (hs : Convex s) (r : β) :
Convex ({ x ∈ s | r < f x }) :=
MonotoneOn.convex_lt (E := Eᵒᵈ) (β := βᵒᵈ) hf.dual (by exact hs) r
theorem AntitoneOn.convex_le (hf : AntitoneOn f s) (hs : Convex s) (r : β) :
Convex ({ x ∈ s | f x ≤ r }) :=
MonotoneOn.convex_ge (β := βᵒᵈ) hf hs r
theorem AntitoneOn.convex_lt (hf : AntitoneOn f s) (hs : Convex s) (r : β) :
Convex ({ x ∈ s | f x < r }) :=
MonotoneOn.convex_gt (β := βᵒᵈ) hf hs r
theorem AntitoneOn.convex_ge (hf : AntitoneOn f s) (hs : Convex s) (r : β) :
Convex ({ x ∈ s | r ≤ f x }) :=
MonotoneOn.convex_le (β := βᵒᵈ) hf hs r
theorem AntitoneOn.convex_gt (hf : AntitoneOn f s) (hs : Convex s) (r : β) :
Convex ({ x ∈ s | r < f x }) :=
MonotoneOn.convex_lt (β := βᵒᵈ) hf hs r
theorem Monotone.convex_le (hf : Monotone f) (r : β) : Convex { x | f x ≤ r } :=
Set.sep_univ.subst ((hf.monotoneOn univ).convex_le convex_univ r)
theorem Monotone.convex_lt (hf : Monotone f) (r : β) : Convex { x | f x < r } :=
Set.sep_univ.subst ((hf.monotoneOn univ).convex_lt convex_univ r)
theorem Monotone.convex_ge (hf : Monotone f) (r : β) : Convex { x | r ≤ f x } :=
Set.sep_univ.subst ((hf.monotoneOn univ).convex_ge convex_univ r)
theorem Monotone.convex_gt (hf : Monotone f) (r : β) : Convex { x | r < f x } :=
Set.sep_univ.subst ((hf.monotoneOn univ).convex_gt convex_univ r)
theorem Antitone.convex_le (hf : Antitone f) (r : β) : Convex { x | f x ≤ r } :=
Set.sep_univ.subst ((hf.antitoneOn univ).convex_le convex_univ r)
theorem Antitone.convex_lt (hf : Antitone f) (r : β) : Convex { x | f x < r } :=
Set.sep_univ.subst ((hf.antitoneOn univ).convex_lt convex_univ r)
theorem Antitone.convex_ge (hf : Antitone f) (r : β) : Convex { x | r ≤ f x } :=
Set.sep_univ.subst ((hf.antitoneOn univ).convex_ge convex_univ r)
theorem Antitone.convex_gt (hf : Antitone f) (r : β) : Convex { x | r < f x } :=
Set.sep_univ.subst ((hf.antitoneOn univ).convex_gt convex_univ r)
end LinearOrderedAddCommMonoid
end OrderedSemiring
section OrderedCommSemiring
variable [CommSemiring ] [PartialOrder ]
section AddCommMonoid
variable [AddCommMonoid E] [AddCommMonoid F] [Module E] [Module F] {s : Set E}
theorem Convex.smul (hs : Convex s) (c : ) : Convex (c • s) :=
hs.linear_image (LinearMap.lsmul _ _ c)
theorem Convex.smul_preimage (hs : Convex s) (c : ) : Convex ((fun z => c • z) ⁻¹' s) :=
hs.linear_preimage (LinearMap.lsmul _ _ c)
theorem Convex.affinity (hs : Convex s) (z : E) (c : ) :
Convex ((fun x => z + c • x) '' s) := by
simpa only [← image_smul, ← image_vadd, image_image] using! (hs.smul c).vadd z
end AddCommMonoid
end OrderedCommSemiring
section StrictOrderedCommSemiring
variable [CommSemiring ] [PartialOrder ] [IsStrictOrderedRing ] [AddCommGroup E] [Module E]
theorem convex_openSegment (a b : E) : Convex (openSegment a b) := by
rw [convex_iff_openSegment_subset]
rintro p ⟨ap, bp, hap, hbp, habp, rfl⟩ q ⟨aq, bq, haq, hbq, habq, rfl⟩ z ⟨a, b, ha, hb, hab, rfl⟩
refine ⟨a * ap + b * aq, a * bp + b * bq, by positivity, by positivity, ?_, ?_⟩
· linear_combination (norm := noncomm_ring) a * habp + b * habq + hab
· module
end StrictOrderedCommSemiring
section OrderedRing
variable [Ring ] [PartialOrder ]
section AddCommGroup
variable [AddCommGroup E] [AddCommGroup F] [Module E] [Module F] {s t : Set E}
@[simp]
theorem convex_vadd (a : E) : Convex (a +ᵥ s) ↔ Convex s :=
⟨fun h ↦ by simpa using h.vadd (-a), fun h ↦ h.vadd _⟩
/-- Affine subspaces are convex. -/
theorem AffineSubspace.convex (Q : AffineSubspace E) : Convex (Q : Set E) :=
fun x hx y hy a b _ _ hab ↦ by simpa [Convex.combo_eq_smul_sub_add hab] using! Q.2 _ hy hx hx
/-- The preimage of a convex set under an affine map is convex. -/
theorem Convex.affine_preimage (f : E →ᵃ[] F) {s : Set F} (hs : Convex s) : Convex (f ⁻¹' s) :=
fun _ hx => (hs hx).affine_preimage _
/-- The image of a convex set under an affine map is convex. -/
theorem Convex.affine_image (f : E →ᵃ[] F) (hs : Convex s) : Convex (f '' s) := by
rintro _ ⟨x, hx, rfl⟩
exact (hs hx).affine_image _
theorem Convex.neg (hs : Convex s) : Convex (-s) :=
hs.is_linear_preimage IsLinearMap.isLinearMap_neg
theorem Convex.sub (hs : Convex s) (ht : Convex t) : Convex (s - t) := by
rw [sub_eq_add_neg]
exact hs.add ht.neg
variable [AddRightMono ]
theorem Convex.add_smul_mem (hs : Convex s) {x y : E} (hx : x ∈ s) (hy : x + y ∈ s) {t : }
(ht : t ∈ Icc (0 : ) 1) : x + t • y ∈ s := by
have h : x + t • y = (1 - t) • x + t • (x + y) := by match_scalars <;> noncomm_ring
rw [h]
exact hs hx hy (sub_nonneg_of_le ht.2) ht.1 (sub_add_cancel _ _)
theorem Convex.smul_mem_of_zero_mem (hs : Convex s) {x : E} (zero_mem : (0 : E) ∈ s) (hx : x ∈ s)
{t : } (ht : t ∈ Icc (0 : ) 1) : t • x ∈ s := by
simpa using hs.add_smul_mem zero_mem (by simpa using hx) ht
theorem Convex.mapsTo_lineMap (h : Convex s) {x y : E} (hx : x ∈ s) (hy : y ∈ s) :
MapsTo (AffineMap.lineMap x y) (Icc (0 : ) 1) s := by
simpa only [mapsTo_iff_image_subset, segment_eq_image_lineMap] using h.segment_subset hx hy
theorem Convex.lineMap_mem (h : Convex s) {x y : E} (hx : x ∈ s) (hy : y ∈ s) {t : }
(ht : t ∈ Icc 0 1) : AffineMap.lineMap x y t ∈ s :=
h.mapsTo_lineMap hx hy ht
theorem Convex.add_smul_sub_mem (h : Convex s) {x y : E} (hx : x ∈ s) (hy : y ∈ s) {t : }
(ht : t ∈ Icc (0 : ) 1) : x + t • (y - x) ∈ s := by
rw [add_comm]
exact h.lineMap_mem hx hy ht
end AddCommGroup
end OrderedRing
section LinearOrder
variable [Semiring ] [AddCommMonoid E]
section SemilinearMap
variable [PartialOrder ]
variable {' : Type*} [Semiring '] [PartialOrder ']
variable {σ : →+* '} [RingHomSurjective σ]
variable {F' : Type*} [AddCommMonoid F'] [Module ' F'] [Module E]
theorem Convex.semilinear_image {s : Set E} (hs : Convex s) (hσ : ∀ {s t}, σ s ≤ σ t ↔ s ≤ t)
(f : E →ₛₗ[σ] F') : Convex ' (f '' s) := by
rintro _ ⟨x, hx, rfl⟩ _ ⟨y, hy, rfl⟩ a b ha hb hab
obtain ⟨r, rfl⟩ : ∃ r : , σ r = a := RingHomSurjective.is_surjective ..
obtain ⟨t, rfl⟩ : ∃ t : , σ t = b := RingHomSurjective.is_surjective ..
refine ⟨r • x + t • y, hs hx hy (by simp_all [(@hσ 0 r).mp]) (by simp_all [(@hσ 0 t).mp])
?_, by simp⟩
apply_fun σ using Function.Injective.of_eq_imp_le (hσ.mp ·.le)
simpa
end SemilinearMap
variable [LinearOrder ] [IsOrderedRing ]
theorem Convex_subadditive_le [SMul E] {f : E → } (hf1 : ∀ x y, f (x + y) ≤ (f x) + (f y))
(hf2 : ∀ ⦃c⦄ x, 0 ≤ c → f (c • x) ≤ c * f x) (B : ) :
Convex { x | f x ≤ B } := by
rw [convex_iff_segment_subset]
rintro x hx y hy z ⟨a, b, ha, hb, hs, rfl⟩
calc
_ ≤ a • (f x) + b • (f y) := le_trans (hf1 _ _) (add_le_add (hf2 x ha) (hf2 y hb))
_ ≤ a • B + b • B := by gcongr <;> assumption
_ ≤ B := by rw [← add_smul, hs, one_smul]
end LinearOrder
theorem Convex.midpoint_mem [Ring ] [LinearOrder ] [IsStrictOrderedRing ]
[AddCommGroup E] [Module E] [Invertible (2 : )] {s : Set E} {x y : E}
(h : Convex s) (hx : x ∈ s) (hy : y ∈ s) : midpoint x y ∈ s :=
h.segment_subset hx hy <| midpoint_mem_segment x y
section LinearOrderedField
variable [Field ] [LinearOrder ] [IsStrictOrderedRing ]
section AddCommGroup
variable [AddCommGroup E] [AddCommGroup F] [Module E] [Module F] {s : Set E}
/-- Alternative definition of set convexity, using division. -/
theorem convex_iff_div :
Convex s ↔ ∀ ⦃x⦄, x ∈ s → ∀ ⦃y⦄, y ∈ s →
∀ ⦃a b : ⦄, 0 ≤ a → 0 ≤ b → 0 < a + b → (a / (a + b)) • x + (b / (a + b)) • y ∈ s :=
forall₂_congr fun _ _ => starConvex_iff_div
theorem Convex.mem_smul_of_zero_mem (h : Convex s) {x : E} (zero_mem : (0 : E) ∈ s) (hx : x ∈ s)
{t : } (ht : 1 ≤ t) : x ∈ t • s := by
rw [mem_smul_set_iff_inv_smul_mem₀ (zero_lt_one.trans_le ht).ne']
exact h.smul_mem_of_zero_mem zero_mem hx
⟨inv_nonneg.2 (zero_le_one.trans ht), inv_le_one_of_one_le₀ ht⟩
theorem Convex.exists_mem_add_smul_eq (h : Convex s) {x y : E} {p q : } (hx : x ∈ s) (hy : y ∈ s)
(hp : 0 ≤ p) (hq : 0 ≤ q) : ∃ z ∈ s, (p + q) • z = p • x + q • y := by
rcases _root_.em (p = 0 ∧ q = 0) with (⟨rfl, rfl⟩ | hpq)
· use x, hx
simp
· replace hpq : 0 < p + q :=
(add_nonneg hp hq).lt_of_ne' (mt (add_eq_zero_iff_of_nonneg hp hq).1 hpq)
refine ⟨_, convex_iff_div.1 h hx hy hp hq hpq, ?_⟩
match_scalars <;> field
protected theorem Convex.add_smul (h_conv : Convex s) {p q : } (hp : 0 ≤ p) (hq : 0 ≤ q) :
(p + q) • s = p • s + q • s := (add_smul_subset _ _ _).antisymm <| by
rintro _ ⟨_, ⟨v₁, h₁, rfl⟩, _, ⟨v₂, h₂, rfl⟩, rfl⟩
exact h_conv.exists_mem_add_smul_eq h₁ h₂ hp hq
theorem Convex.add_half_self_eq_self (h_conv : Convex s) : (2 : )⁻¹ • s + (2 : )⁻¹ • s = s := by
rw [← h_conv.add_smul (by simp) (by simp)]
ring_nf
rw [one_smul]
end AddCommGroup
end LinearOrderedField
/-!
#### Convex sets in an ordered space
Relates `Convex` and `OrdConnected`.
-/
section
theorem Set.OrdConnected.convex_of_chain [Semiring ] [PartialOrder ] [AddCommMonoid E]
[PartialOrder E] [IsOrderedAddMonoid E] [Module E] [PosSMulMono E] {s : Set E}
(hs : s.OrdConnected) (h : IsChain (· ≤ ·) s) : Convex s := by
refine convex_iff_segment_subset.mpr fun x hx y hy => ?_
obtain hxy | hyx := h.total hx hy
· exact (segment_subset_Icc hxy).trans (hs.out hx hy)
· rw [segment_symm]
exact (segment_subset_Icc hyx).trans (hs.out hy hx)
theorem Set.OrdConnected.convex [Semiring ] [PartialOrder ] [AddCommMonoid E] [LinearOrder E]
[IsOrderedAddMonoid E] [Module E] [PosSMulMono E] {s : Set E} (hs : s.OrdConnected) :
Convex s :=
hs.convex_of_chain <| isChain_of_trichotomous s
theorem convex_iff_ordConnected [Field ] [LinearOrder ] [IsStrictOrderedRing ] {s : Set } :
Convex s ↔ s.OrdConnected := by
simp_rw [convex_iff_segment_subset, segment_eq_uIcc, ordConnected_iff_uIcc_subset]
alias ⟨Convex.ordConnected, _⟩ := convex_iff_ordConnected
end
/-! #### Convexity of submodules/subspaces -/
namespace Submodule
variable [Semiring ] [PartialOrder ] [AddCommMonoid E] [Module E]
protected theorem convex (K : Submodule E) : Convex (↑K : Set E) := by
repeat' intro
refine add_mem (smul_mem _ _ ?_) (smul_mem _ _ ?_) <;> assumption
protected theorem starConvex (K : Submodule E) : StarConvex (0 : E) K :=
K.convex K.zero_mem
theorem Convex.semilinear_range {' : Type*} [Semiring '] {σ : ' →+* }
[RingHomSurjective σ] {F' : Type*} [AddCommMonoid F'] [Module ' F']
(f : F' →ₛₗ[σ] E) : Convex (LinearMap.range f : Set E) := Submodule.convex ..
end Submodule
section CommSemiring
variable {R : Type*} [CommSemiring R]
variable (A : Type*) [Semiring A] [Algebra R A]
variable {M : Type*} [AddCommMonoid M] [Module A M] [Module R M] [IsScalarTower R A M]
variable [PartialOrder R] [PartialOrder A]
lemma convex_of_nonneg_surjective_algebraMap [FaithfulSMul R A] {s : Set M}
(halg : Set.Ici 0 ⊆ algebraMap R A '' Set.Ici 0) (hs : Convex R s) :
Convex A s := by
simp only [Convex, StarConvex] at hs ⊢
intro u hu v hv a b ha hb hab
obtain ⟨c, hc1, hc2⟩ := halg ha
obtain ⟨d, hd1, hd2⟩ := halg hb
convert hs hu hv hc1 hd1 _
· rw [← hc2, algebraMap_smul]
· rw [← hd2, algebraMap_smul]
rw [← hc2, ← hd2, ← algebraMap.coe_add] at hab
exact (FaithfulSMul.algebraMap_eq_one_iff R A).mp hab
end CommSemiring
¤ Dauer der Verarbeitung: 0.8 Sekunden
(vorverarbeitet am 2026-11-24)
¤
*© Formatika GbR, Deutschland
|
|
2026-11-24
|
|
|
|
|