import OAI.Geometry.Perimeter.Regularity.EllipticCutField namespace OAI noncomputable section open Set Filter MeasureTheory open scoped Topology ENNReal ContDiff InnerProductSpace namespace RPISingularHarnack variable {n : ℕ} def gradientEnergy (f : Euc n → ℝ) (p : Euc n) (r : ℝ) (q : Euc n) : ℝ := ∫ x in Metric.ball p r, ‖gradient f x-q‖^2 theorem constant_gradient_pairing_zero {U : Set (Euc n)} (φ : SmoothLocalTest U) (q : Euc n) : (∫ x, inner ℝ q (gradient φ.val x))=0 := by have h := (scalar_compact_integration_parts_C1 (u := fun _ : Euc n ↦ (1:ℝ)) contDiff_const (φ.property.1.of_le (by simp)) φ.property.2.1 q).2.2 simpa [inner_gradient_right] using h theorem inner_gradient_pairing_integrable {W : Euc n → Euc n} (hW : Continuous W) {U : Set (Euc n)} (φ : SmoothLocalTest U) : Integrable (fun x ↦ inner ℝ (W x) (gradient φ.val x)) volume := (hW.inner (gradient_contDiff φ.property.1).continuous).integrable_of_hasCompactSupport ((gradient_hasCompactSupport φ.property.2.1).of_isClosed_subset (isClosed_tsupport _) (by apply closure_minimal _ (isClosed_tsupport _) intro x hx by_contra hh exact hx (by simp [image_eq_zero_of_notMem_tsupport hh]))) theorem gradient_sub_linear {f : Euc n → ℝ} (hf : Differentiable ℝ f) (q : Euc n) (x : Euc n) : gradient (fun y ↦ f y-inner ℝ q y) x=gradient f x-q := by apply ext_inner_right ℝ intro y simp only [inner_gradient_left,inner_sub_left] have h := ((hf x).hasFDerivAt.sub (innerSL ℝ q).hasFDerivAt).fderiv exact congrArg (fun L : Euc n →L[ℝ] ℝ ↦ L y) h theorem continuous_gradient_one_scale (hn : 0