import PoincareLib.Geometry.RicciFlow.ReducedGeometry.ReducedLength.Variation.Adapted.MaximalAdaptedField import Mathlib.Data.Set.Piecewise /-! # Gluing a restart of adapted transport The fields agree on their open interval overlap. Their union is therefore an actual smooth adapted solution through the original initial value. -/ set_option autoImplicit false open scoped Manifold ContDiff Bundle Topology open Filter universe u namespace PoincareMT.ReducedLength variable {n : β„•} {M : Type u} [TopologicalSpace M] [ChartedSpace (EuclideanSpace ℝ (Fin n)) M] [IsManifold (𝓑 n) ∞ M] [T2Space M] theorem exists_adaptedIntervalSolution_union {J : Set ℝ} {F : RicciFlow n M J} {T : ℝ} {Ξ³ : ℝ β†’ M} {U : Set ℝ} {s0 : ℝ} {v0 : TangentSpace (𝓑 n) (Ξ³ s0)} (b : ℝ) (hb : 0 < b) (hwindow : Set.Icc (T - b) T βŠ† J) (htime : U βŠ† Set.Ioo (-Real.sqrt b) (Real.sqrt b)) (hΞ³ : ContMDiffOn (π“˜(ℝ, ℝ)) (𝓑 n) ∞ Ξ³ U) (A : AdaptedIntervalSolution F T Ξ³ U s0 v0) (s : ℝ) (hs : s ∈ A.domain) (B : AdaptedIntervalSolution F T Ξ³ U s (A.field s)) : βˆƒ C : AdaptedIntervalSolution F T Ξ³ U s0 v0, C.domain = A.domain βˆͺ B.domain ∧ (βˆ€ t ∈ A.domain, C.field t = A.field t) ∧ (βˆ€ t ∈ B.domain, C.field t = B.field t) := by classical have hp := adaptedField_eqOn F T b hb hwindow Ξ³ A.field B.field (A.domain ∩ B.domain) (A.open_domain.inter B.open_domain) (A.preconnected_domain.ordConnected.inter B.preconnected_domain.ordConnected).isPreconnected (fun _ ht ↦ htime (A.domain_subset ht.1)) (hΞ³.mono (fun _ ht ↦ A.domain_subset ht.1)) (A.adapted.mono Set.inter_subset_left) (B.adapted.mono Set.inter_subset_right) s ⟨hs, B.initial_mem⟩ B.initial_value.symm let P : βˆ€ t, TangentSpace (𝓑 n) (Ξ³ t) := fun t ↦ if t ∈ A.domain then A.field t else B.field t have heA : βˆ€ t ∈ A.domain, P t = A.field t := fun t ht ↦ if_pos ht have heB : βˆ€ t ∈ B.domain, P t = B.field t := by intro t ht by_cases htA : t ∈ A.domain Β· exact (heA t htA).trans (hp t ⟨htA, ht⟩) Β· exact if_neg htA have hgA : βˆ€ t ∈ A.domain, βˆ€αΆ  r in 𝓝 t, P r = A.field r := by intro t ht filter_upwards [A.open_domain.mem_nhds ht] with r hr using heA r hr have hgB : βˆ€ t ∈ B.domain, βˆ€αΆ  r in 𝓝 t, P r = B.field r := by intro t ht filter_upwards [B.open_domain.mem_nhds ht] with r hr using heB r hr have hP : IsAdaptedFieldOn F T Ξ³ P (A.domain βˆͺ B.domain) := by apply IsAdaptedFieldOn.of_locally intro t ht rcases ht with ht | ht Β· exact ⟨A.field, A.domain, A.open_domain, ht, A.adapted, hgA t ht⟩ Β· exact ⟨B.field, B.domain, B.open_domain, ht, B.adapted, hgB t ht⟩ let C : AdaptedIntervalSolution F T Ξ³ U s0 v0 := { domain := A.domain βˆͺ B.domain open_domain := A.open_domain.union B.open_domain preconnected_domain := A.preconnected_domain.union s hs B.initial_mem B.preconnected_domain initial_mem := Or.inl A.initial_mem domain_subset := fun _ ht ↦ ht.elim (fun h ↦ A.domain_subset h) (fun h ↦ B.domain_subset h) field := P adapted := hP initial_value := (heA s0 A.initial_mem).trans A.initial_value } exact ⟨C, rfl, heA, heB⟩ theorem maximalAdaptedDomain_contains_restart {J : Set ℝ} (F : RicciFlow n M J) (T b : ℝ) (hb : 0 < b) (hwindow : Set.Icc (T - b) T βŠ† J) (Ξ³ : ℝ β†’ M) (U : Set ℝ) (hU : IsOpen U) (htime : U βŠ† Set.Ioo (-Real.sqrt b) (Real.sqrt b)) (hΞ³ : ContMDiffOn (π“˜(ℝ, ℝ)) (𝓑 n) ∞ Ξ³ U) (s0 : ℝ) (hs0 : s0 ∈ U) (v0 : TangentSpace (𝓑 n) (Ξ³ s0)) (s : ℝ) (hs : s ∈ maximalAdaptedDomain F T Ξ³ U s0 v0) (B : AdaptedIntervalSolution F T Ξ³ U s (maximalAdaptedField F T Ξ³ U s0 v0 s)) : B.domain βŠ† maximalAdaptedDomain F T Ξ³ U s0 v0 := by let A := maximalAdaptedSolution F T b hb hwindow Ξ³ U hU htime hΞ³ s0 hs0 v0 obtain ⟨C, hC, _, _⟩ := exists_adaptedIntervalSolution_union b hb hwindow htime hΞ³ A s hs B intro t ht exact C.domain_subset_maximal (hC.symm β–Έ Or.inr ht) end PoincareMT.ReducedLength