import Mathlib import OAI.Geometry.Borsuk.SphereGeometry.HomogeneousLift import OAI.Geometry.Borsuk.SphereGeometry.SphereMeasure namespace OAI namespace BorsukNine open scoped RealInnerProductSpace ContDiff open scoped Manifold open MeasureTheory Set Metric open scoped ENNReal Pointwise Matrix section IntegralLift variable {ν ι : Type*} [Fintype ν] [Nonempty ν] [Fintype ι] local notation "E" => EuclideanSpace ℝ ν noncomputable def integralLift (f : E → ι → ℝ) (T : E →L[ℝ] E) : ι → ℝ := fun i => (Fintype.card ν : ℝ) * ∫ x : UnitSphere E, homogeneousLift f (T x) i ∂sphereProbability E omit [Nonempty ν] in lemma Admissible.integrand_continuous {f : E → ι → ℝ} (hf : Admissible f) (T : E →L[ℝ] E) (i : ι) : Continuous (fun x : UnitSphere E => homogeneousLift f (T x) i) := (continuous_apply i).comp (hf.lift_continuous.comp (T.continuous.comp continuous_subtype_val)) lemma Admissible.integrand_integrable {f : E → ι → ℝ} (hf : Admissible f) (T : E →L[ℝ] E) (i : ι) : Integrable (fun x : UnitSphere E => homogeneousLift f (T x) i) (sphereProbability E) := (hf.integrand_continuous T i).integrable_of_hasCompactSupport (HasCompactSupport.of_compactSpace _) omit [Nonempty ν] in lemma Admissible.integralLift_nonneg {f : E → ι → ℝ} (hf : Admissible f) (T : E →L[ℝ] E) (i : ι) : 0 ≤ integralLift f T i := mul_nonneg (Nat.cast_nonneg _) (integral_nonneg (fun _ => hf.lift_nonneg _ i)) lemma Admissible.integralLift_sum {f : E → ι → ℝ} (hf : Admissible f) (T : E →L[ℝ] E) : ∑ i, integralLift f T i = (Fintype.card ν : ℝ) * ∫ x : UnitSphere E, ‖T x‖ ^ 2 ∂sphereProbability E := by classical simp only [integralLift, ← Finset.mul_sum] rw [← integral_finsetSum _ (fun i _ => hf.integrand_integrable T i)] simp only [hf.lift_sum] lemma Admissible.integralLift_pos_iff_sphere {f : E → ι → ℝ} (hf : Admissible f) (T : E →L[ℝ] E) (i : ι) : 0 < integralLift f T i ↔ ∃ x : UnitSphere E, 0 < homogeneousLift f (T x) i := by have hc : (0 : ℝ) < Fintype.card ν := Nat.cast_pos.mpr Fintype.card_pos rw [integralLift, mul_pos_iff_of_pos_left hc] constructor · intro h by_contra hn push Not at hn have he : (fun x : UnitSphere E => homogeneousLift f (T x) i) = 0 := by funext x exact le_antisymm (hn x) (hf.lift_nonneg _ i) rw [he] at h change 0 < ∫ _ : UnitSphere E, (0 : ℝ) ∂sphereProbability E at h simp only [integral_zero, lt_self_iff_false] at h · rintro ⟨x, hx⟩ exact integral_pos_of_integrable_nonneg_nonzero (hf.integrand_continuous T i) (hf.integrand_integrable T i) (fun _ => hf.lift_nonneg _ i) hx.ne' lemma Admissible.integralLift_continuous {f : E → ι → ℝ} (hf : Admissible f) : Continuous (integralLift f) := by apply continuous_pi intro i apply continuous_const.mul have hc : Continuous (fun p : (E →L[ℝ] E) × UnitSphere E => homogeneousLift f (p.1 p.2) i) := (continuous_apply i).comp (hf.lift_continuous.comp (continuous_fst.clm_apply (continuous_subtype_val.comp continuous_snd))) have hi := continuous_parametric_integral_of_continuous (μ := sphereProbability E) (f := fun (T : E →L[ℝ] E) (x : UnitSphere E) => homogeneousLift f (T x) i) hc isCompact_univ simpa only [setIntegral_univ] using hi lemma Admissible.integralLift_pos_iff {f : E → ι → ℝ} (hf : Admissible f) (T : E →L[ℝ] E) (i : ι) : 0 < integralLift f T i ↔ ∃ x : E, 0 < homogeneousLift f (T x) i := by rw [hf.integralLift_pos_iff_sphere] constructor · rintro ⟨x, hx⟩ exact ⟨x, hx⟩ · rintro ⟨x, hx⟩ have hx0 : x ≠ 0 := by rintro rfl simp at hx have hn : 0 < ‖x‖⁻¹ := inv_pos.mpr (norm_pos_iff.mpr hx0) refine ⟨⟨‖x‖⁻¹ • x, mem_sphere_zero_iff_norm.mpr (norm_smul_inv_norm (𝕜 := ℝ) hx0)⟩, ?_⟩ simp only [map_smul, homogeneousLift_smul_pos f _ hn, Pi.smul_apply, smul_eq_mul] exact mul_pos (sq_pos_of_pos hn) hx lemma Admissible.integralLift_support {f : E → ι → ℝ} (hf : Admissible f) (T : E →L[ℝ] E) (i : ι) : 0 < integralLift f T i ↔ ∃ v : E, v ∈ LinearMap.range T.toLinearMap ∧ ‖v‖ = 1 ∧ 0 < f v i := by rw [hf.integralLift_pos_iff] constructor · rintro ⟨x, hx⟩ have hx0 : T x ≠ 0 := by intro hz simp only [hz, homogeneousLift_zero, Pi.zero_apply, lt_self_iff_false] at hx refine ⟨‖T x‖⁻¹ • T x, ⟨‖T x‖⁻¹ • x, by simp⟩, norm_smul_inv_norm (𝕜 := ℝ) hx0, ?_⟩ exact (mul_pos_iff_of_pos_left (sq_pos_of_pos (norm_pos_iff.mpr hx0))).mp hx · rintro ⟨v, ⟨x, rfl⟩, hv, hx⟩ refine ⟨x, ?_⟩ rw [homogeneousLift_unit f (show ‖T x‖ = 1 from hv)] exact hx lemma Admissible.integralLift_orthogonal {f : E → ι → ℝ} (hf : Admissible f) (T S : E →L[ℝ] E) (hTS : ∀ x y, ⟪T x, S y⟫ = 0) (i : ι) : integralLift f T i * integralLift f S i = 0 := by apply mul_eq_zero.mpr by_contra hn push Not at hn have ht := lt_of_le_of_ne (hf.integralLift_nonneg T i) (Ne.symm hn.1) have hs := lt_of_le_of_ne (hf.integralLift_nonneg S i) (Ne.symm hn.2) obtain ⟨x, hx⟩ := (hf.integralLift_pos_iff T i).mp ht obtain ⟨y, hy⟩ := (hf.integralLift_pos_iff S i).mp hs have hp := hf.lift_orthogonal (hTS x y) i exact (ne_of_gt (mul_pos hx hy)) hp omit [Nonempty ν] [Fintype ι] in lemma integralLift_smul_nonneg (f : E → ι → ℝ) (T : E →L[ℝ] E) {t : ℝ} (ht : 0 ≤ t) : integralLift f (t • T) = t ^ 2 • integralLift f T := by ext i simp only [integralLift, smul_apply, homogeneousLift_smul_nonneg f _ ht, Pi.smul_apply, smul_eq_mul, integral_const_mul] ring end IntegralLift end BorsukNine end OAI