import Mathlib import OAI.Analysis.Conductivity.Variational.PhysicalOpenVoltage import OAI.Analysis.Conductivity.Sobolev.OriginalSmoothMultiplier import OAI.Analysis.Conductivity.Variational.OriginalGradientLocality namespace OAI section noncomputable section namespace ScalarConductivity open Set MeasureTheory Filter Topology Matrix attribute [local instance] Classical.propDecidable namespace PhysicalFiniteEndingData variable {s : Fin 3 → ℝ} (z : PhysicalFiniteEndingData s) lemma source_patch_gradient {η : ℝ} (hη : 0<η) (hηc : 2*η ℝ) let U : Set R3 := E ⁻¹' physicalOpenBlock have hU : IsOpen U := physicalOpenBlock_open.preimage E.continuous have hUb : U⊆ball := fun x hx => physicalOpenBlock_subset_ball hx have hinside : ∀ᵐ x∂ballMeasure,x∈U → weakGradient W x=weakGradient q x := by apply original_local_value_difference_gradient W q hU hUb (-z.terminalValue 0 j) filter_upwards [hv] with x hx hm change WithLp.ofLp x∈physicalOpenBlock at hm rw [hx,ite_eq_left hm] ring let O : Set R3 := ball∩{x | terminalTime 0 (E x)<0} have hO : IsOpen O := Metric.isOpen_ball.inter (isOpen_lt ((terminalTime_locallyLipschitz 0).continuous.comp E.continuous) continuous_const) have hout : ∀ᵐ x∂ballMeasure,x∈O → weakGradient W x=0 := by apply original_local_constant_gradient W hO inter_subset_left 0 filter_upwards [hv] with x hx hm have hn : E x∉physicalOpenBlock := by intro hh have hh := (sourceOpenBlock_time_iff (E x)).mp hh exact (not_lt.mpr hm.2.le) hh.1 change WithLp.ofLp x∉physicalOpenBlock at hn rw [hx,ite_eq_right hn] exact z.terminalProfile_zero_outside hη hηc j hm.2.le let C : Fin 2 → Set R3 := fun k => ball∩{x | 0 ?_) i exact (sourceChildInverse_quasi (actualChildSign k)).ae h0 have hne := ae_restrict_of_ae (s:=ball) ((PiLp.volume_preserving_ofLp (Fin 3)).quasiMeasurePreserving.ae (ae_all_iff.mpr hh)) filter_upwards [hinside,hout,ae_all_iff.mpr hchild,hne,ae_restrict_mem Metric.isOpen_ball.measurableSet] with x hi ho hc hn hx by_cases hb : WithLp.ofLp x∈physicalOpenBlock · rw [ite_eq_left hb] exact hi hb · rw [ite_eq_right hb] by_cases hp : terminalTime 0 (E x)<0 · exact ho ⟨hx,hp⟩ · have hp' : 0