import Mathlib.Geometry.Manifold.BumpFunction import Mathlib.Geometry.Manifold.Instances.Real /-! # Extending a smooth scalar function near a point -/ set_option autoImplicit false open Set Filter open scoped Manifold ContDiff Topology namespace Poincare.Manifold /-- A function smooth on an open set agrees near each point with a globally smooth function. A bump supported in that open set gives the extension. -/ theorem exists_contMDiff_eq_near {n : โ„•} {M : Type*} [TopologicalSpace M] [T2Space M] [ChartedSpace (EuclideanSpace โ„ (Fin n)) M] [IsManifold (๐“ก n) โˆž M] {f : M โ†’ โ„} {U : Set M} (hU : IsOpen U) (hf : ContMDiffOn (๐“ก n) ๐“˜(โ„, โ„) โˆž f U) {x : M} (hx : x โˆˆ U) : โˆƒ F : M โ†’ โ„, ContMDiff (๐“ก n) ๐“˜(โ„, โ„) โˆž F โˆง F =แถ [๐“ x] f := by obtain โŸจฯ‡, _, hฯ‡UโŸฉ := (SmoothBumpFunction.nhds_basis_tsupport (I := ๐“ก n) x).mem_iff.mp (hU.mem_nhds hx) refine โŸจfun y => ฯ‡ y * f y, ?_, ?_โŸฉ ยท intro y by_cases hy : y โˆˆ U ยท exact ฯ‡.contMDiffAt.smul (hf.contMDiffAt (hU.mem_nhds hy)) ยท apply (contMDiffAt_const (c := (0 : โ„))).congr_of_eventuallyEq have hz := notMem_tsupport_iff_eventuallyEq.mp (fun h => hy (hฯ‡U h)) filter_upwards [hz] with z hz simp [hz] ยท filter_upwards [ฯ‡.eventuallyEq_one] with y hy simp [hy] end Poincare.Manifold