File size: 2,238 Bytes
8e4d533 | 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 | import Mathlib
namespace OAI
namespace BorsukNine
open scoped Matrix MatrixOrder Matrix.Norms.L2Operator
section PositiveSlice
variable {ν : Type*} [Fintype ν] [DecidableEq ν]
local notation "M" => Matrix ν ν ℝ
noncomputable def unflattenMatrix : EuclideanSpace ℝ (ν × ν) →ₗ[ℝ] M where
toFun x i j := x (i,j)
map_add' _ _ := rfl
map_smul' _ _ := rfl
noncomputable def flatGram (x : EuclideanSpace ℝ (ν × ν)) : M :=
unflattenMatrix x * (unflattenMatrix x)ᴴ
omit [DecidableEq ν] in
lemma flatGram_nonneg (x : EuclideanSpace ℝ (ν × ν)) : 0 ≤ flatGram x :=
(Matrix.posSemidef_self_mul_conjTranspose _).nonneg
omit [DecidableEq ν] in
lemma flatGram_trace (x : EuclideanSpace ℝ (ν × ν)) : Matrix.trace (flatGram x) = ‖x‖ ^ 2 := by
rw [EuclideanSpace.real_norm_sq_eq]
simp only [flatGram,Matrix.trace,Matrix.diag,Matrix.mul_apply,Matrix.conjTranspose_apply,
star_trivial,Fintype.sum_prod_type]
simp only [pow_two]
rfl
omit [DecidableEq ν] in
lemma flatGram_continuous : Continuous (flatGram (ν := ν)) := by
have h := (unflattenMatrix (ν := ν)).continuous_of_finiteDimensional
exact h.mul h.star
lemma positive_slice_image : {Q : M | 0 ≤ Q ∧ Matrix.trace Q = 1} =
flatGram '' Metric.sphere (0 : EuclideanSpace ℝ (ν × ν)) 1 := by
ext Q
constructor
· rintro ⟨hQ,htr⟩
let x : EuclideanSpace ℝ (ν × ν) := WithLp.toLp 2 (fun p => CFC.sqrt Q p.1 p.2)
have hxQ : flatGram x = Q := by
change CFC.sqrt Q * star (CFC.sqrt Q) = Q
rw [(CFC.sqrt_nonneg Q).isSelfAdjoint.star_eq]
exact CFC.sqrt_mul_sqrt_self Q
have hn : ‖x‖ ^ 2 = 1 := by rw [← flatGram_trace,hxQ,htr]
have hnorm : ‖x‖ = 1 := by nlinarith [norm_nonneg x]
exact ⟨x,by simpa [dist_zero_right] using hnorm,hxQ⟩
· rintro ⟨x,hx,rfl⟩
refine ⟨flatGram_nonneg x,?_⟩
have hnorm : ‖x‖ = 1 := by simpa [dist_zero_right] using hx
rw [flatGram_trace,hnorm,one_pow]
lemma positive_slice_compact : IsCompact {Q : M | 0 ≤ Q ∧ Matrix.trace Q = 1} := by
rw [positive_slice_image]
exact (isCompact_sphere (0 : EuclideanSpace ℝ (ν × ν)) 1).image flatGram_continuous
end PositiveSlice
end BorsukNine
end OAI
|