File size: 3,868 Bytes
695bd70
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import OAI.Combinatorics.PerfectMatching.Simplex
import Mathlib.Geometry.Convex.ConvexSpace.CompactSpaceStdSimplex
import Mathlib.Geometry.Convex.ConvexSpace.Barycenter
import Mathlib.Analysis.Convex.Contractible
import Mathlib.Analysis.Convex.Topology
import Mathlib.Topology.MetricSpace.Basic
import Mathlib.Topology.Algebra.Module.LocallyConvex

namespace OAI

noncomputable section

open Convexity

namespace Problem340.RealSimplex

variable {Index : Type*} [Fintype Index]

instance coordinatesFun : CoeFun (StdSimplex ℝ Index) (fun _ => Index → ℝ) :=
  ⟨fun point => point.weights⟩

def coordinates (point : StdSimplex ℝ Index) : Index → ℝ := point.weights

omit [Fintype Index] in
@[simp] lemma single_apply [DecidableEq Index] (vertex index : Index) :
    StdSimplex.single (R := ℝ) vertex index = if vertex = index then 1 else 0 := by
  change (StdSimplex.single vertex).weights index = _
  simp [Finsupp.single_apply]

@[simp] lemma barycenter_apply [Nonempty Index] (index : Index) :
    (StdSimplex.barycenter : StdSimplex ℝ Index) index = (Fintype.card Index : ℝ)⁻¹ :=
  StdSimplex.weights_barycenter_apply index

lemma map_apply {Target : Type*} [Fintype Target] [DecidableEq Target]
    (mapping : Index → Target) (point : StdSimplex ℝ Index) (index : Target) :
    point.map mapping index =
      ∑ source ∈ Finset.univ.filter (fun source => mapping source = index), point source := by
  classical
  change (point.map mapping).weights index = _
  rw [StdSimplex.weights_map, Finsupp.mapDomain_apply,
    Finsupp.sum_fintype _ _ (by simp), Finset.sum_filter]
  simp [Finsupp.single_apply]

lemma coordinates_injective : Function.Injective (coordinates (Index := Index)) :=
  (StdSimplex.isEmbedding_toFun_comp_weights ℝ Index).injective

def coordinateSet (Index : Type*) [Fintype Index] : Set (Index → ℝ) :=
  {weights | (∀ index, 0 ≤ weights index) ∧ ∑ index, weights index = 1}

lemma mem_coordinateSet (point : StdSimplex ℝ Index) :
    coordinates point ∈ coordinateSet Index :=
  ⟨point.weights_nonneg, point.total_of_fintype⟩

lemma convex_coordinateSet : Convex ℝ (coordinateSet Index) :=
  MatchingEntropy.convex_probabilitySimplex Index

def coordinateHomeomorph : StdSimplex ℝ Index ≃ₜ coordinateSet Index :=
  (StdSimplex.isEmbedding_toFun_comp_weights ℝ Index).toHomeomorph.trans
    (Homeomorph.setCongr (by
      rw [StdSimplex.range_toFun_comp_weights]
      ext weights
      simp [coordinateSet]))

@[simp] lemma coordinateHomeomorph_apply (point : StdSimplex ℝ Index) :
    (coordinateHomeomorph point : Index → ℝ) = coordinates point := rfl

@[simp] lemma coordinateHomeomorph_symm_apply (point : coordinateSet Index) :
    coordinates (coordinateHomeomorph.symm point) = point :=
  congrArg Subtype.val (coordinateHomeomorph.apply_symm_apply point)

instance metricSpace : MetricSpace (StdSimplex ℝ Index) :=
  (StdSimplex.isEmbedding_toFun_comp_weights ℝ Index).comapMetricSpace _

@[simp] lemma coordinateHomeomorph_symm_apply_at (point : coordinateSet Index) (index : Index) :
    coordinateHomeomorph.symm point index = point.val index :=
  congrFun (coordinateHomeomorph_symm_apply point) index

lemma contractible [Nonempty Index] : ContractibleSpace (StdSimplex ℝ Index) := by
  have : ContractibleSpace (coordinateSet Index) :=
    convex_coordinateSet.contractibleSpace
      ⟨coordinates (StdSimplex.single (Classical.arbitrary Index)), mem_coordinateSet _⟩
  exact (coordinateHomeomorph (Index := Index)).contractibleSpace

lemma locallyPathConnected : LocallyPathConnectedSpace (StdSimplex ℝ Index) := by
  have : LocallyPathConnectedSpace (coordinateSet Index) :=
    convex_coordinateSet.locallyPathConnectedSpace
  exact (coordinateHomeomorph (Index := Index)).symm.locallyPathConnectedSpace

end Problem340.RealSimplex

end

end OAI