Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/Lean/Mathlib/Mathlib/Analysis/Convex/     Datei vom 15.10.2026 mit Größe 7 kB image not shown  

Quelle  Hull.lean   Sprache: Lean

 

/-
Copyright (c) 2020 Yury Kudryashov. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yury Kudryashov, Yaël Dillies
-/

module

public import Mathlib.Analysis.Convex.Basic

set_option doc.verso true
set_option doc.verso.suggestions false

/-!
# Convex hull

This file defines the convex hull of a set `s` in a module. `convexHull �� s` is the smallest convex
set containing `s`. In order theory speak, this is a closure operator.

## Implementation notes

`convexHull` is defined as a closure operator. This gives access to the `ClosureOperator` API
while the impact on writing code is minimal as `convexHull �� s` is automatically elaborated as
`(convexHull ��) s`.
-/


@[expose] public section


open Set

open scoped Pointwise

variable {�� E F : Type*}

section convexHull

section OrderedSemiring

variable [Semiring ��] [PartialOrder ��]

section AddCommMonoid

variable (��)
variable [AddCommMonoid E] [AddCommMonoid F] [Module �� E] [Module �� F]

/-- The convex hull of a set `s` is the minimal convex set that includes `s`. -/
@[simps! isClosed]
def convexHull : ClosureOperator (Set E) := .ofCompletePred (Convex ��) fun _ ↦ convex_sInter

variable (s : Set E)

theorem subset_convexHull : s ⊆ convexHull �� s :=
  (convexHull ��).le_closure s

theorem convex_convexHull : Convex �� (convexHull �� s) := (convexHull ��).isClosed_closure s

set_option backward.isDefEq.respectTransparency false in
theorem convexHull_eq_iInter : convexHull �� s = ⋂ (t : Set E) (_ : s ⊆ t) (_ : Convex �� t), t := by
  simp [convexHull, iInter_subtype, iInter_and]

variable {�� s} {t : Set E} {x y : E}

theorem mem_convexHull_iff : x ∈ convexHull �� s ↔ ∀ t, s ⊆ t → Convex �� t → x ∈ t := by
  simp_rw [convexHull_eq_iInter, mem_iInter]

theorem convexHull_min : s ⊆ t → Convex �� t → convexHull �� s ⊆ t := (convexHull ��).closure_min

theorem Convex.convexHull_subset_iff (ht : Convex �� t) : convexHull �� s ⊆ t ↔ s ⊆ t :=
  (show (convexHull ��).IsClosed t from ht).closure_le_iff

@[mono, gcongr]
theorem convexHull_mono (hst : s ⊆ t) : convexHull �� s ⊆ convexHull �� t :=
  (convexHull ��).monotone hst

lemma convexHull_eq_self : convexHull �� s = s ↔ Convex �� s := (convexHull ��).isClosed_iff.symm

alias ⟨_, Convex.convexHull_eq⟩ := convexHull_eq_self

@[simp]
theorem convexHull_univ : convexHull �� (univ : Set E) = univ :=
  ClosureOperator.closure_top (convexHull ��)

@[simp]
theorem convexHull_empty : convexHull �� (∅ : Set E) = ∅ :=
  convex_empty.convexHull_eq

@[simp]
theorem convexHull_eq_empty : convexHull �� s = ∅ ↔ s = ∅ := by
  constructor
  · intro h
    rw [← Set.subset_empty_iff, ← h]
    exact subset_convexHull �� _
  · rintro rfl
    exact convexHull_empty

@[simp]
theorem convexHull_nonempty_iff : (convexHull �� s).Nonempty ↔ s.Nonempty := by
  rw [nonempty_iff_ne_empty, nonempty_iff_ne_empty, Ne, Ne]
  exact not_congr convexHull_eq_empty

protected alias ⟨_, Set.Nonempty.convexHull⟩ := convexHull_nonempty_iff

theorem segment_subset_convexHull (hx : x ∈ s) (hy : y ∈ s) : segment �� x y ⊆ convexHull �� s :=
  (convex_convexHull _ _).segment_subset (subset_convexHull _ _ hx) (subset_convexHull _ _ hy)

@[simp]
theorem convexHull_singleton (x : E) : convexHull �� ({x} : Set E) = {x} :=
  (convex_singleton x).convexHull_eq

@[simp] lemma convexHull_eq_singleton : convexHull �� s = {x} ↔ s = {x} where
  mp hs := by
    rw [← Set.Nonempty.subset_singleton_iff, ← hs]
    · exact subset_convexHull ..
    · by_contra! hs
      simp_all [eq_comm (a := ∅)]
  mpr hs := by simp [hs]

@[simp]
theorem convexHull_zero : convexHull �� (0 : Set E) = 0 :=
  convexHull_singleton 0

@[simp] lemma convexHull_eq_zero : convexHull �� s = 0 ↔ s = 0 := convexHull_eq_singleton

@[simp]
theorem convexHull_pair [IsOrderedRing ��] (x y : E) : convexHull �� {x, y} = segment �� x y := by
  refine (convexHull_min ?_ <| convex_segment _ _).antisymm
    (segment_subset_convexHull (mem_insert _ _) <| subset_insert _ _ <| mem_singleton _)
  rw [insert_subset_iff, singleton_subset_iff]
  exact ⟨left_mem_segment _ _ _, right_mem_segment _ _ _⟩

theorem convexHull_convexHull_union_left (s t : Set E) :
    convexHull �� (convexHull �� s ∪ t) = convexHull �� (s ∪ t) :=
  ClosureOperator.closure_sup_closure_left _ _ _

theorem convexHull_convexHull_union_right (s t : Set E) :
    convexHull �� (s ∪ convexHull �� t) = convexHull �� (s ∪ t) :=
  ClosureOperator.closure_sup_closure_right _ _ _

theorem Convex.convex_remove_iff_notMem_convexHull_remove {s : Set E} (hs : Convex �� s) (x : E) :
    Convex �� (s \ {x}) ↔ x ∉ convexHull �� (s \ {x}) := by
  constructor
  · rintro hsx hx
    rw [hsx.convexHull_eq] at hx
    exact hx.2 (mem_singleton _)
  rintro hx
  suffices h : s \ {x} = convexHull �� (s \ {x}) by
    rw [h]
    exact convex_convexHull �� _
  exact
    Subset.antisymm (subset_convexHull �� _) fun y hy =>
      ⟨convexHull_min sdiff_subset hs hy, by
        rintro (rfl : y = x)
        exact hx hy⟩

theorem IsLinearMap.image_convexHull {f : E → F} (hf : IsLinearMap �� f) (s : Set E) :
    f '' convexHull �� s = convexHull �� (f '' s) :=
  Set.Subset.antisymm
    (image_subset_iff.2 <|
      convexHull_min (image_subset_iff.1 <| subset_convexHull �� _)
        ((convex_convexHull �� _).is_linear_preimage hf))
    (convexHull_min (image_mono (subset_convexHull �� s)) <|
      (convex_convexHull �� s).is_linear_image hf)

theorem LinearMap.image_convexHull (f : E →ₗ[��] F) (s : Set E) :
    f '' convexHull �� s = convexHull �� (f '' s) :=
  f.isLinear.image_convexHull s

theorem convexHull_add_subset {s t : Set E} :
    convexHull �� (s + t) ⊆ convexHull �� s + convexHull �� t :=
  convexHull_min (add_subset_add (subset_convexHull _ _) (subset_convexHull _ _))
    (Convex.add (convex_convexHull �� s) (convex_convexHull �� t))

end AddCommMonoid

end OrderedSemiring

section CommSemiring

variable [CommSemiring ��] [PartialOrder ��] [AddCommMonoid E] [Module �� E]

theorem convexHull_smul (a : ��) (s : Set E) : convexHull �� (a • s) = a • convexHull �� s :=
  (LinearMap.lsmul _ _ a).image_convexHull _ |>.symm

end CommSemiring

section OrderedRing

variable [Ring ��] [PartialOrder ��]

section AddCommGroup

variable [AddCommGroup E] [AddCommGroup F] [Module �� E] [Module �� F]

theorem AffineMap.image_convexHull (f : E →ᵃ[��] F) (s : Set E) :
    f '' convexHull �� s = convexHull �� (f '' s) := by
  apply Set.Subset.antisymm
  · rw [Set.image_subset_iff]
    refine convexHull_min ?_ ((convex_convexHull �� (f '' s)).affine_preimage f)
    rw [← Set.image_subset_iff]
    exact subset_convexHull �� (f '' s)
  · exact convexHull_min (Set.image_mono (subset_convexHull �� s))
      ((convex_convexHull �� s).affine_image f)

theorem convexHull_subset_affineSpan (s : Set E) : convexHull �� s ⊆ (affineSpan �� s : Set E) :=
  convexHull_min (subset_affineSpan �� s) (affineSpan �� s).convex

@[simp]
theorem affineSpan_convexHull (s : Set E) : affineSpan �� (convexHull �� s) = affineSpan �� s := by
  refine le_antisymm ?_ (affineSpan_mono �� (subset_convexHull �� s))
  rw [affineSpan_le]
  exact convexHull_subset_affineSpan s

theorem convexHull_neg (s : Set E) : convexHull �� (-s) = -convexHull �� s := by
  simp_rw [← image_neg_eq_neg]
  exact AffineMap.image_convexHull (-1) _ |>.symm

lemma convexHull_vadd (x : E) (s : Set E) : convexHull �� (x +ᵥ s) = x +ᵥ convexHull �� s :=
  (AffineEquiv.constVAdd �� _ x).toAffineMap.image_convexHull s |>.symm

end AddCommGroup

end OrderedRing

end convexHull

Messung
CHZG
9310010097

¤ Dauer der Verarbeitung: 0.10 Sekunden  ¤

*© Formatika GbR, Deutschland