Navier–Stokes: the Lean blow-up proof, cleaned up together
OpenAI's 2026 Lean proofs of blowup for forced Navier–Stokes and Euler, rerun by others, not refereed, no ruling from Clay; cleaned up together: more readable, faster to build

| 1 | import NavierStokes.LocalAxisymmetricResidual |
| 2 | import Mathlib.Analysis.SpecialFunctions.Trigonometric.Deriv |
| 3 | import Mathlib.Tactic.FieldSimp |
| 4 | import Mathlib.Tactic.Module |
| 5 | import Mathlib.Tactic.LinearCombination |
| 6 | |
| 7 | /-! |
| 8 | # Actual Cartesian differential operators in cylindrical coordinates |
| 9 | |
| 10 | The chart is `(r,theta,z) ↦ (r cos theta,r sin theta,z)`. Coordinate |
| 11 | derivatives are actual Fréchet derivatives. Pulling Cartesian fields back |
| 12 | through this chart avoids choosing a global inverse angular coordinate. |
| 13 | -/ |
| 14 | |
| 15 | namespace NavierStokes.CylindricalResidual |
| 16 | |
| 17 | noncomputable section |
| 18 | |
| 19 | open ProblemStatement Filter |
| 20 | open AxisymmetricFields (projection) |
| 21 | open AxisymmetricResidual (pack pack_zero pack_one pack_two packDerivative |
| 22 | packDerivative_apply hasFDerivAt_pack) |
| 23 | open scoped BigOperators ContDiff Topology |
| 24 | |
| 25 | variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] |
| 26 | variable {F : Type*} [NormedAddCommGroup F] [NormedSpace ℝ F] |
| 27 | |
| 28 | /-- The three arguments are `r`, `theta`, and `z`, respectively. -/ |
| 29 | noncomputable def chart (q : Space) : Space := |
| 30 | pack (q 0 * Real.cos (q 1)) (q 0 * Real.sin (q 1)) (q 2) |
| 31 | |
| 32 | noncomputable def horizontal : Space →L[ℝ] Space := |
| 33 | packDerivative (projection 0) (projection 1) 0 |
| 34 | |
| 35 | /-- Infinitesimal rotation: `(a,b,c) ↦ (-b,a,0)`. -/ |
| 36 | noncomputable def connection : Space →L[ℝ] Space := |
| 37 | packDerivative (-(projection 1)) (projection 0) 0 |
| 38 | |
| 39 | noncomputable def vertical : Space →L[ℝ] Space := |
| 40 | packDerivative 0 0 (projection 2) |
| 41 | |
| 42 | noncomputable def frame (θ : ℝ) : Space →L[ℝ] Space := |
| 43 | Real.cos θ • horizontal + Real.sin θ • connection + vertical |
| 44 | |
| 45 | theorem frame_apply (θ : ℝ) (v : Space) : |
| 46 | frame θ v = pack (Real.cos θ * v 0 - Real.sin θ * v 1) |
| 47 | (Real.sin θ * v 0 + Real.cos θ * v 1) (v 2) := by |
| 48 | ext i |
| 49 | fin_cases i <;> simp [frame, horizontal, connection, vertical, packDerivative, |
| 50 | pack, coordinateVector] <;> ring |
| 51 | |
| 52 | theorem connection_apply (v : Space) : connection v = pack (-v 1) (v 0) 0 := by |
| 53 | simp [connection, packDerivative_apply] |
| 54 | |
| 55 | theorem frame_connection (θ : ℝ) : |
| 56 | (frame θ).comp connection = -Real.sin θ • horizontal + Real.cos θ • connection := by |
| 57 | ext v i |
| 58 | fin_cases i <;> simp [frame_apply, connection_apply, horizontal, packDerivative_apply] |
| 59 | ring |
| 60 | |
| 61 | theorem frame_inverse (θ : ℝ) (v : Space) : frame (-θ) (frame θ v) = v := by |
| 62 | ext i |
| 63 | fin_cases i |
| 64 | · simp [frame_apply, Real.cos_neg, Real.sin_neg] |
| 65 | linear_combination (v 0) * Real.cos_sq_add_sin_sq θ |
| 66 | · simp [frame_apply, Real.cos_neg, Real.sin_neg] |
| 67 | linear_combination (v 1) * Real.cos_sq_add_sin_sq θ |
| 68 | · simp [frame_apply] |
| 69 | |
| 70 | theorem frame_inverse' (θ : ℝ) (v : Space) : frame θ (frame (-θ) v) = v := by |
| 71 | simpa only [neg_neg] using frame_inverse (-θ) v |
| 72 | |
| 73 | noncomputable def chartJacobian (q : Space) : Space →L[ℝ] Space := |
| 74 | (frame (q 1)).comp (packDerivative (projection 0) (q 0 • projection 1) (projection 2)) |
| 75 | |
| 76 | theorem chartJacobian_apply (q v : Space) : |
| 77 | chartJacobian q v = frame (q 1) (pack (v 0) (q 0 * v 1) (v 2)) := by |
| 78 | simp [chartJacobian, packDerivative_apply] |
| 79 | |
| 80 | theorem hasFDerivAt_chart (q : Space) : HasFDerivAt chart (chartJacobian q) q := by |
| 81 | have h0 := (projection 0).hasFDerivAt (x := q) |
| 82 | have h1 := (projection 1).hasFDerivAt (x := q) |
| 83 | have h2 := (projection 2).hasFDerivAt (x := q) |
| 84 | convert! hasFDerivAt_pack (h0.mul h1.cos) (h0.mul h1.sin) h2 using 1 |
| 85 | ext v i |
| 86 | fin_cases i <;> simp [chartJacobian_apply, frame_apply, packDerivative_apply] <;> ring |
| 87 | |
| 88 | theorem contDiff_chart {n : WithTop ℕ∞} : ContDiff ℝ n chart := by |
| 89 | unfold chart pack |
| 90 | exact ((((projection 0).contDiff.mul (projection 1).contDiff.cos).smul contDiff_const).add |
| 91 | (((projection 0).contDiff.mul (projection 1).contDiff.sin).smul contDiff_const)).add |
| 92 | ((projection 2).contDiff.smul contDiff_const) |
| 93 | |
| 94 | noncomputable def dCoord (i : Fin 3) (f : Space → E) (q : Space) : E := |
| 95 | fderiv ℝ f q (coordinateVector i) |
| 96 | |
| 97 | noncomputable def euclideanLaplacian (f : Space → E) (x : Space) : E := |
| 98 | ∑ i : Fin 3, dCoord i (dCoord i f) x |
| 99 | |
| 100 | noncomputable def scalarLaplacian (f : Space → E) (q : Space) : E := |
| 101 | dCoord 0 (dCoord 0 f) q + (q 0)⁻¹ • dCoord 0 f q + |
| 102 | ((q 0) ^ 2)⁻¹ • dCoord 1 (dCoord 1 f) q + dCoord 2 (dCoord 2 f) q |
| 103 | |
| 104 | theorem contDiffAt_dCoord {f : Space → E} {q : Space} {m n : WithTop ℕ∞} |
| 105 | (hf : ContDiffAt ℝ n f q) (hmn : m + 1 ≤ n) (i : Fin 3) : |
| 106 | ContDiffAt ℝ m (dCoord i f) q := |
| 107 | (hf.fderiv_right hmn).clm_apply contDiffAt_const |
| 108 | |
| 109 | theorem dCoord_congr {f g : Space → E} {q : Space} |
| 110 | (h : f =ᶠ[𝓝 q] g) (i : Fin 3) : dCoord i f q = dCoord i g q := by |
| 111 | unfold dCoord |
| 112 | rw [h.fderiv_eq] |
| 113 | |
| 114 | theorem dCoord_add {f g : Space → E} {q : Space} |
| 115 | (hf : DifferentiableAt ℝ f q) (hg : DifferentiableAt ℝ g q) (i : Fin 3) : |
| 116 | dCoord i (fun y => f y + g y) q = dCoord i f q + dCoord i g q := by |
| 117 | unfold dCoord |
| 118 | rw [fderiv_fun_add hf hg] |
| 119 | rfl |
| 120 | |
| 121 | theorem dCoord_map (L : E →L[ℝ] F) {f : Space → E} {q : Space} |
| 122 | (hf : DifferentiableAt ℝ f q) (i : Fin 3) : |
| 123 | dCoord i (fun y => L (f y)) q = L (dCoord i f q) := by |
| 124 | unfold dCoord |
| 125 | change (fderiv ℝ (L ∘ f) q) _ = _ |
| 126 | rw [(L.hasFDerivAt.comp q hf.hasFDerivAt).fderiv] |
| 127 | rfl |
| 128 | |
| 129 | theorem fderiv_pullback {f : Space → E} {q : Space} |
| 130 | (hf : DifferentiableAt ℝ f (chart q)) (v : Space) : |
| 131 | fderiv ℝ (fun y => f (chart y)) q v = fderiv ℝ f (chart q) (chartJacobian q v) := by |
| 132 | change (fderiv ℝ (f ∘ chart) q) _ = _ |
| 133 | rw [(hf.hasFDerivAt.comp q (hasFDerivAt_chart q)).fderiv] |
| 134 | rfl |
| 135 | |
| 136 | /-- Resolve a Cartesian vector into chart-coordinate components. -/ |
| 137 | noncomputable def chartVector (q v : Space) : Space := |
| 138 | let w := frame (-(q 1)) v |
| 139 | pack (w 0) (w 1 / q 0) (w 2) |
| 140 | |
| 141 | theorem chartJacobian_chartVector (q v : Space) (hr : q 0 ≠ 0) : |
| 142 | chartJacobian q (chartVector q v) = v := by |
| 143 | rw [chartJacobian_apply] |
| 144 | have hpack : pack ((chartVector q v) 0) (q 0 * (chartVector q v) 1) |
| 145 | ((chartVector q v) 2) = frame (-(q 1)) v := by |
| 146 | ext i |
| 147 | fin_cases i <;> simp [chartVector, hr, mul_div_cancel₀] |
| 148 | rw [hpack, frame_inverse'] |
| 149 | |
| 150 | /-- Exact first-order bridge from ordinary Cartesian derivatives. -/ |
| 151 | theorem cartesian_derivative_from_pullback {f : Space → E} {q : Space} |
| 152 | (hf : DifferentiableAt ℝ f (chart q)) (hr : q 0 ≠ 0) (v : Space) : |
| 153 | fderiv ℝ f (chart q) v = |
| 154 | fderiv ℝ (fun y => f (chart y)) q (chartVector q v) := by |
| 155 | rw [fderiv_pullback hf, chartJacobian_chartVector q v hr] |
| 156 | |
| 157 | /-- The actual second Fréchet derivative, with the two directions displayed. -/ |
| 158 | noncomputable def hessian (f : Space → E) (x v w : Space) : E := |
| 159 | fderiv ℝ (fderiv ℝ f) x v w |
| 160 | |
| 161 | theorem dCoord_dCoord {f : Space → E} {q : Space} |
| 162 | (hf : ContDiffAt ℝ 2 f q) (i : Fin 3) : |
| 163 | dCoord i (dCoord i f) q = hessian f q (coordinateVector i) (coordinateVector i) := by |
| 164 | have hD : DifferentiableAt ℝ (fderiv ℝ f) q := |
| 165 | (hf.fderiv_right (m := 1) (by norm_num)).differentiableAt (by norm_num) |
| 166 | unfold dCoord hessian |
| 167 | rw [fderiv_clm_apply hD (differentiableAt_const _)] |
| 168 | simp |
| 169 | |
| 170 | theorem second_chain {f : Space → E} {g : Space → Space} {q : Space} |
| 171 | (hf : ContDiffAt ℝ 2 f (g q)) (hg : ContDiffAt ℝ 2 g q) (i : Fin 3) : |
| 172 | dCoord i (dCoord i (f ∘ g)) q = |
| 173 | hessian f (g q) (dCoord i g q) (dCoord i g q) + |
| 174 | fderiv ℝ f (g q) (dCoord i (dCoord i g) q) := by |
| 175 | have hnear : dCoord i (f ∘ g) =ᶠ[𝓝 q] |
| 176 | fun y => fderiv ℝ f (g y) (dCoord i g y) := by |
| 177 | have hfnear : ∀ᶠ y in 𝓝 q, ContDiffAt ℝ 2 f (g y) := |
| 178 | hg.continuousAt (hf.eventually (by norm_num)) |
| 179 | filter_upwards [hfnear, hg.eventually (by norm_num)] with y hyf hyg |
| 180 | exact congrArg (fun L : Space →L[ℝ] E => L (coordinateVector i)) |
| 181 | ((hyf.differentiableAt (by norm_num)).hasFDerivAt.comp y |
| 182 | (hyg.differentiableAt (by norm_num)).hasFDerivAt).fderiv |
| 183 | rw [dCoord_congr hnear] |
| 184 | have hD := (hf.fderiv_right (m := 1) (by norm_num)).differentiableAt (by norm_num) |
| 185 | have hgD := hg.differentiableAt (by norm_num) |
| 186 | have hDi := (contDiffAt_dCoord hg (m := 1) (by norm_num) i).differentiableAt (by norm_num) |
| 187 | change (fderiv ℝ (fun y => ((fderiv ℝ f) ∘ g) y (dCoord i g y)) q) |
| 188 | (coordinateVector i) = _ |
| 189 | rw [fderiv_clm_apply (hD.comp q hgD) hDi] |
| 190 | rw [show fderiv ℝ ((fderiv ℝ f) ∘ g) q = |
| 191 | (fderiv ℝ (fderiv ℝ f) (g q)).comp (fderiv ℝ g q) from |
| 192 | (hD.hasFDerivAt.comp q hgD.hasFDerivAt).fderiv] |
| 193 | simp [dCoord, hessian, add_comm] |
| 194 | |
| 195 | theorem dCoord_chart_zero (q : Space) : |
| 196 | dCoord 0 chart q = pack (Real.cos (q 1)) (Real.sin (q 1)) 0 := by |
| 197 | simp [dCoord, (hasFDerivAt_chart q).fderiv, chartJacobian_apply, frame_apply, |
| 198 | coordinateVector] |
| 199 | |
| 200 | theorem dCoord_chart_one (q : Space) : |
| 201 | dCoord 1 chart q = pack (-(q 0) * Real.sin (q 1)) (q 0 * Real.cos (q 1)) 0 := by |
| 202 | simp [dCoord, (hasFDerivAt_chart q).fderiv, chartJacobian_apply, frame_apply, |
| 203 | coordinateVector] |
| 204 | ring_nf |
| 205 | |
| 206 | theorem dCoord_chart_two (q : Space) : dCoord 2 chart q = coordinateVector 2 := by |
| 207 | simp [dCoord, (hasFDerivAt_chart q).fderiv, chartJacobian_apply, frame_apply, |
| 208 | coordinateVector, pack] |
| 209 | |
| 210 | theorem dCoord_dCoord_chart_zero (q : Space) : dCoord 0 (dCoord 0 chart) q = 0 := by |
| 211 | rw [show dCoord 0 chart = fun y => pack (Real.cos (y 1)) (Real.sin (y 1)) 0 from |
| 212 | funext dCoord_chart_zero] |
| 213 | have h1 : HasFDerivAt (fun y : Space => y 1) (projection 1) q := |
| 214 | (projection 1).hasFDerivAt |
| 215 | have hz : HasFDerivAt (fun _ : Space => (0 : ℝ)) 0 q := hasFDerivAt_const (𝕜 := ℝ) 0 q |
| 216 | unfold dCoord |
| 217 | rw [(hasFDerivAt_pack h1.cos h1.sin hz).fderiv] |
| 218 | simp [packDerivative_apply, coordinateVector, pack] |
| 219 | |
| 220 | theorem dCoord_dCoord_chart_one (q : Space) : |
| 221 | dCoord 1 (dCoord 1 chart) q = -(q 0) • dCoord 0 chart q := by |
| 222 | rw [show dCoord 1 chart = fun y => |
| 223 | pack (-(y 0) * Real.sin (y 1)) (y 0 * Real.cos (y 1)) 0 from |
| 224 | funext dCoord_chart_one] |
| 225 | have h0 : HasFDerivAt (fun y : Space => y 0) (projection 0) q := |
| 226 | (projection 0).hasFDerivAt |
| 227 | have h1 : HasFDerivAt (fun y : Space => y 1) (projection 1) q := |
| 228 | (projection 1).hasFDerivAt |
| 229 | have hz : HasFDerivAt (fun _ : Space => (0 : ℝ)) 0 q := hasFDerivAt_const (𝕜 := ℝ) 0 q |
| 230 | change (fderiv ℝ (fun y => pack (-y 0 * Real.sin (y 1)) |
| 231 | (y 0 * Real.cos (y 1)) 0) q) _ = _ |
| 232 | rw [(hasFDerivAt_pack (h0.fun_neg.fun_mul h1.sin) (h0.fun_mul h1.cos) hz).fderiv, |
| 233 | dCoord_chart_zero] |
| 234 | ext i |
| 235 | fin_cases i <;> simp [packDerivative_apply, coordinateVector] |
| 236 | |
| 237 | theorem dCoord_dCoord_chart_two (q : Space) : dCoord 2 (dCoord 2 chart) q = 0 := by |
| 238 | rw [show dCoord 2 chart = fun _ => coordinateVector 2 from funext dCoord_chart_two] |
| 239 | simp [dCoord] |
| 240 | |
| 241 | theorem dCoord_pullback {f : Space → E} {q : Space} |
| 242 | (hf : DifferentiableAt ℝ f (chart q)) (i : Fin 3) : |
| 243 | dCoord i (f ∘ chart) q = |
| 244 | fderiv ℝ f (chart q) (dCoord i chart q) := by |
| 245 | simpa only [dCoord, Function.comp_def, (hasFDerivAt_chart q).fderiv] using |
| 246 | fderiv_pullback hf (coordinateVector i) |
| 247 | |
| 248 | /-- The cylindrical scalar Laplacian is the pullback of the Cartesian trace. -/ |
| 249 | theorem scalarLaplacian_pullback {f : Space → E} {q : Space} |
| 250 | (hf : ContDiffAt ℝ 2 f (chart q)) (hr : q 0 ≠ 0) : |
| 251 | scalarLaplacian (fun y => f (chart y)) q = euclideanLaplacian f (chart q) := by |
| 252 | have hc : ContDiffAt ℝ 2 chart q := contDiff_chart.contDiffAt |
| 253 | change scalarLaplacian (f ∘ chart) q = _ |
| 254 | unfold scalarLaplacian euclideanLaplacian |
| 255 | rw [second_chain hf hc 0, second_chain hf hc 1, second_chain hf hc 2, |
| 256 | dCoord_pullback (hf.differentiableAt (by norm_num)) 0, |
| 257 | dCoord_dCoord_chart_zero, dCoord_dCoord_chart_one, dCoord_dCoord_chart_two] |
| 258 | simp only [Fin.sum_univ_three, dCoord_dCoord hf, dCoord_chart_zero, |
| 259 | dCoord_chart_one, dCoord_chart_two, hessian, pack, map_add, map_smul, |
| 260 | map_zero, _root_.add_apply, _root_.smul_apply, |
| 261 | zero_smul, add_zero] |
| 262 | match_scalars <;> field_simp [hr] <;> nlinarith [Real.cos_sq_add_sin_sq (q 1)] |
| 263 | |
| 264 | theorem contDiff_frame {n : WithTop ℕ∞} : ContDiff ℝ n frame := by |
| 265 | unfold frame |
| 266 | exact ((contDiff_id.cos.smul contDiff_const).add |
| 267 | (contDiff_id.sin.smul contDiff_const)).add contDiff_const |
| 268 | |
| 269 | theorem hasFDerivAt_frameField (q : Space) : |
| 270 | HasFDerivAt (fun y : Space => frame (y 1)) |
| 271 | ((projection 1).smulRight ((frame (q 1)).comp connection)) q := by |
| 272 | have h1 : HasFDerivAt (fun y : Space => y 1) (projection 1) q := |
| 273 | (projection 1).hasFDerivAt |
| 274 | convert! ((h1.cos.smul_const horizontal).add (h1.sin.smul_const connection)).add_const |
| 275 | vertical using 1 |
| 276 | ext v w i |
| 277 | fin_cases i <;> simp [ frame_apply, horizontal, connection, packDerivative, |
| 278 | pack, coordinateVector] <;> ring |
| 279 | |
| 280 | /-- Cartesian representation of cylindrical vector components. -/ |
| 281 | noncomputable def encode (w : Space → Space) (q : Space) : Space := frame (q 1) (w q) |
| 282 | |
| 283 | theorem contDiffAt_encode {w : Space → Space} {q : Space} {n : WithTop ℕ∞} |
| 284 | (hw : ContDiffAt ℝ n w q) : ContDiffAt ℝ n (encode w) q := |
| 285 | (contDiff_frame.contDiffAt.comp q (projection 1).contDiff.contDiffAt).clm_apply hw |
| 286 | |
| 287 | theorem fderiv_encode {w : Space → Space} {q : Space} |
| 288 | (hw : DifferentiableAt ℝ w q) (v : Space) : |
| 289 | fderiv ℝ (encode w) q v = |
| 290 | frame (q 1) (fderiv ℝ w q v + v 1 • connection (w q)) := by |
| 291 | unfold encode |
| 292 | rw [((hasFDerivAt_frameField q).clm_apply hw.hasFDerivAt).fderiv] |
| 293 | simp [map_add, map_smul] |
| 294 | |
| 295 | theorem dCoord_encode {w : Space → Space} {q : Space} |
| 296 | (hw : DifferentiableAt ℝ w q) (i : Fin 3) : |
| 297 | dCoord i (encode w) q = |
| 298 | frame (q 1) (dCoord i w q + (coordinateVector i) 1 • connection (w q)) := |
| 299 | fderiv_encode hw (coordinateVector i) |
| 300 | |
| 301 | theorem dCoord_const_smul {f : Space → E} {q : Space} |
| 302 | (hf : DifferentiableAt ℝ f q) (a : ℝ) (i : Fin 3) : |
| 303 | dCoord i (fun y => a • f y) q = a • dCoord i f q := by |
| 304 | unfold dCoord |
| 305 | rw [fderiv_fun_const_smul hf a] |
| 306 | rfl |
| 307 | |
| 308 | theorem dCoord_dCoord_encode {w : Space → Space} {q : Space} |
| 309 | (hw : ContDiffAt ℝ 2 w q) (i : Fin 3) : |
| 310 | dCoord i (dCoord i (encode w)) q = frame (q 1) |
| 311 | (dCoord i (dCoord i w) q + |
| 312 | (2 * (coordinateVector i) 1) • connection (dCoord i w q) + |
| 313 | ((coordinateVector i) 1) ^ 2 • connection (connection (w q))) := by |
| 314 | have hwD := hw.differentiableAt (by norm_num) |
| 315 | have hDi := (contDiffAt_dCoord hw (m := 1) (by norm_num) i).differentiableAt (by norm_num) |
| 316 | have hJ : DifferentiableAt ℝ (fun y => connection (w y)) q := |
| 317 | connection.differentiableAt.comp q hwD |
| 318 | have hnear : dCoord i (encode w) =ᶠ[𝓝 q] |
| 319 | encode (fun y => dCoord i w y + (coordinateVector i) 1 • connection (w y)) := by |
| 320 | filter_upwards [hw.eventually (by norm_num)] with y hy |
| 321 | exact dCoord_encode (hy.differentiableAt (by norm_num)) i |
| 322 | rw [dCoord_congr hnear i, |
| 323 | dCoord_encode (hDi.fun_add (hJ.fun_const_smul _)) i, |
| 324 | dCoord_add hDi (hJ.fun_const_smul _) i, |
| 325 | dCoord_const_smul hJ _ i, dCoord_map connection hwD i] |
| 326 | congr 1 |
| 327 | simp only [map_add, map_smul] |
| 328 | module |
| 329 | |
| 330 | /-- Vector Laplacian of physical components in the moving cylindrical basis. -/ |
| 331 | noncomputable def vectorLaplacian (w : Space → Space) (q : Space) : Space := |
| 332 | scalarLaplacian w q + (2 / (q 0) ^ 2) • connection (dCoord 1 w q) + |
| 333 | ((q 0) ^ 2)⁻¹ • connection (connection (w q)) |
| 334 | |
| 335 | theorem scalarLaplacian_encode {w : Space → Space} {q : Space} |
| 336 | (hw : ContDiffAt ℝ 2 w q) : |
| 337 | scalarLaplacian (encode w) q = frame (q 1) (vectorLaplacian w q) := by |
| 338 | unfold scalarLaplacian vectorLaplacian |
| 339 | rw [dCoord_dCoord_encode hw 0, dCoord_dCoord_encode hw 1, |
| 340 | dCoord_dCoord_encode hw 2, dCoord_encode (hw.differentiableAt (by norm_num)) 0] |
| 341 | simp only [coordinateVector, PiLp.single_apply, ↓reduceIte, Fin.reduceEq, mul_zero, zero_smul, zero_pow (by norm_num : 2 ≠ 0), |
| 342 | add_zero, mul_one, one_pow, one_smul, map_add, map_smul] |
| 343 | simp only [scalarLaplacian, map_add, map_smul] |
| 344 | module |
| 345 | |
| 346 | /-- Cylindrical components of an arbitrary Cartesian vector field. -/ |
| 347 | noncomputable def components (f : Space → Space) (q : Space) : Space := |
| 348 | frame (-(q 1)) (f (chart q)) |
| 349 | |
| 350 | theorem encode_components (f : Space → Space) : |
| 351 | encode (components f) = fun q => f (chart q) := by |
| 352 | funext q |
| 353 | exact frame_inverse' (q 1) (f (chart q)) |
| 354 | |
| 355 | theorem differentiableAt_components {f : Space → Space} {q : Space} |
| 356 | (hf : DifferentiableAt ℝ f (chart q)) : DifferentiableAt ℝ (components f) q := |
| 357 | (((contDiff_frame (n := 1)).differentiable (by norm_num) _).comp q |
| 358 | (projection 1).differentiableAt.neg).clm_apply |
| 359 | (hf.comp q (hasFDerivAt_chart q).differentiableAt) |
| 360 | |
| 361 | theorem contDiffAt_components {f : Space → Space} {q : Space} {n : WithTop ℕ∞} |
| 362 | (hf : ContDiffAt ℝ n f (chart q)) : ContDiffAt ℝ n (components f) q := |
| 363 | (contDiff_frame.contDiffAt.comp q (projection 1).contDiff.contDiffAt.neg).clm_apply |
| 364 | (hf.comp q contDiff_chart.contDiffAt) |
| 365 | |
| 366 | theorem cartesianLaplacian_components {f : Space → Space} {q : Space} |
| 367 | (hf : ContDiffAt ℝ 2 f (chart q)) (hr : q 0 ≠ 0) : |
| 368 | euclideanLaplacian f (chart q) = frame (q 1) (vectorLaplacian (components f) q) := by |
| 369 | rw [← scalarLaplacian_pullback hf hr, ← encode_components, |
| 370 | scalarLaplacian_encode (contDiffAt_components hf)] |
| 371 | |
| 372 | theorem fderiv_pack (f : Space → E) (q : Space) (a b c : ℝ) : |
| 373 | fderiv ℝ f q (pack a b c) = |
| 374 | a • dCoord 0 f q + b • dCoord 1 f q + c • dCoord 2 f q := by |
| 375 | simp [pack, dCoord] |
| 376 | |
| 377 | /-- Cartesian directional differentiation, resolved in the cylindrical frame. -/ |
| 378 | theorem cartesianDerivative_components {f : Space → Space} {q : Space} |
| 379 | (hf : DifferentiableAt ℝ f (chart q)) (hr : q 0 ≠ 0) (b : Space) : |
| 380 | frame (-(q 1)) (fderiv ℝ f (chart q) (frame (q 1) b)) = |
| 381 | b 0 • dCoord 0 (components f) q + |
| 382 | (b 1 / q 0) • (dCoord 1 (components f) q + connection (components f q)) + |
| 383 | b 2 • dCoord 2 (components f) q := by |
| 384 | rw [cartesian_derivative_from_pullback hf hr, ← encode_components, |
| 385 | fderiv_encode (differentiableAt_components hf), frame_inverse] |
| 386 | simp only [chartVector, frame_inverse, fderiv_pack, pack_one] |
| 387 | module |
| 388 | |
| 389 | noncomputable def vectorAdvection (w : Space → Space) (q : Space) : Space := |
| 390 | w q 0 • dCoord 0 w q + (w q 1 / q 0) • (dCoord 1 w q + connection (w q)) + |
| 391 | w q 2 • dCoord 2 w q |
| 392 | |
| 393 | theorem cartesianAdvection_components {f : Space → Space} {q : Space} |
| 394 | (hf : DifferentiableAt ℝ f (chart q)) (hr : q 0 ≠ 0) : |
| 395 | fderiv ℝ f (chart q) (f (chart q)) = |
| 396 | frame (q 1) (vectorAdvection (components f) q) := by |
| 397 | have h := cartesianDerivative_components hf hr (components f q) |
| 398 | have hrec : frame (q 1) (components f q) = f (chart q) := frame_inverse' _ _ |
| 399 | rw [hrec] at h |
| 400 | unfold vectorAdvection |
| 401 | rw [← h, frame_inverse'] |
| 402 | |
| 403 | noncomputable def euclideanDivergence (f : Space → Space) (x : Space) : ℝ := |
| 404 | ∑ i : Fin 3, (fderiv ℝ f x (coordinateVector i)) i |
| 405 | |
| 406 | noncomputable def vectorDivergence (w : Space → Space) (q : Space) : ℝ := |
| 407 | (dCoord 0 w q) 0 + w q 0 / q 0 + (dCoord 1 w q) 1 / q 0 + (dCoord 2 w q) 2 |
| 408 | |
| 409 | theorem trace_rotation (A : Space →L[ℝ] Space) (θ : ℝ) : |
| 410 | (∑ i : Fin 3, (A (coordinateVector i)) i) = |
| 411 | ∑ i : Fin 3, (frame (-θ) (A (frame θ (coordinateVector i)))) i := by |
| 412 | simp [Fin.sum_univ_three, frame_apply, pack, coordinateVector] |
| 413 | linear_combination -((A (EuclideanSpace.single 0 1)) 0 + |
| 414 | (A (EuclideanSpace.single 1 1)) 1) * Real.cos_sq_add_sin_sq θ |
| 415 | |
| 416 | theorem cartesianDivergence_components {f : Space → Space} {q : Space} |
| 417 | (hf : DifferentiableAt ℝ f (chart q)) (hr : q 0 ≠ 0) : |
| 418 | euclideanDivergence f (chart q) = vectorDivergence (components f) q := by |
| 419 | unfold euclideanDivergence |
| 420 | rw [trace_rotation _ (q 1)] |
| 421 | simp_rw [cartesianDerivative_components hf hr] |
| 422 | simp [Fin.sum_univ_three, vectorDivergence, coordinateVector, connection_apply] |
| 423 | ring |
| 424 | |
| 425 | noncomputable def euclideanGradient (f : Space → ℝ) (x : Space) : Space := |
| 426 | ∑ i : Fin 3, dCoord i f x • coordinateVector i |
| 427 | |
| 428 | noncomputable def scalarGradient (f : Space → ℝ) (q : Space) : Space := |
| 429 | pack (dCoord 0 f q) (dCoord 1 f q / q 0) (dCoord 2 f q) |
| 430 | |
| 431 | theorem cartesianGradient_pullback {f : Space → ℝ} {q : Space} |
| 432 | (hf : DifferentiableAt ℝ f (chart q)) (hr : q 0 ≠ 0) : |
| 433 | euclideanGradient f (chart q) = frame (q 1) (scalarGradient (f ∘ chart) q) := by |
| 434 | unfold scalarGradient |
| 435 | rw [dCoord_pullback hf 0, dCoord_pullback hf 1, dCoord_pullback hf 2] |
| 436 | rw [dCoord_chart_zero, dCoord_chart_one, dCoord_chart_two] |
| 437 | ext i |
| 438 | fin_cases i |
| 439 | · simp [euclideanGradient, Fin.sum_univ_three, frame_apply, pack, dCoord, coordinateVector] |
| 440 | field_simp [hr] |
| 441 | linear_combination -(fderiv ℝ f (chart q) (EuclideanSpace.single 0 1)) * |
| 442 | Real.cos_sq_add_sin_sq (q 1) |
| 443 | · simp [euclideanGradient, Fin.sum_univ_three, frame_apply, pack, dCoord, coordinateVector] |
| 444 | field_simp [hr] |
| 445 | linear_combination -(fderiv ℝ f (chart q) (EuclideanSpace.single 1 1)) * |
| 446 | Real.cos_sq_add_sin_sq (q 1) |
| 447 | · simp [euclideanGradient, Fin.sum_univ_three, frame_apply, |
| 448 | pack, dCoord, coordinateVector] |
| 449 | |
| 450 | /-- Pullback of a time-dependent velocity into the moving cylindrical frame. -/ |
| 451 | noncomputable def velocityComponents (u : VelocityField) : VelocityField := |
| 452 | fun tq => components (fun x => u (tq.1, x)) tq.2 |
| 453 | |
| 454 | noncomputable def pressurePullback (p : PressureField) : PressureField := |
| 455 | fun tq => p (tq.1, chart tq.2) |
| 456 | |
| 457 | noncomputable def cylindricalResidual (w : VelocityField) (p : PressureField) |
| 458 | (t : ℝ) (q : Space) : Space := |
| 459 | temporalDerivative w t q + vectorAdvection (fun y => w (t, y)) q - |
| 460 | vectorLaplacian (fun y => w (t, y)) q + scalarGradient (fun y => p (t, y)) q |
| 461 | |
| 462 | theorem temporalDerivative_components {u : VelocityField} {t : ℝ} {q : Space} |
| 463 | (ht : DifferentiableAt ℝ (fun s => u (s, chart q)) t) : |
| 464 | temporalDerivative (velocityComponents u) t q = |
| 465 | frame (-(q 1)) (temporalDerivative u t (chart q)) := by |
| 466 | unfold temporalDerivative velocityComponents components |
| 467 | change (fderiv ℝ ((frame (-(q 1))) ∘ (fun s => u (s, chart q))) t) 1 = _ |
| 468 | rw [((frame (-(q 1))).hasFDerivAt.comp t ht.hasFDerivAt).fderiv] |
| 469 | rfl |
| 470 | |
| 471 | /-- The full actual Cartesian Navier--Stokes residual, under local regularity. -/ |
| 472 | theorem navierStokesResidual_cylindrical_of_slices |
| 473 | {u : VelocityField} {p : PressureField} {t : ℝ} {q : Space} |
| 474 | (hu : ContDiffAt ℝ 2 (fun x => u (t, x)) (chart q)) |
| 475 | (ht : DifferentiableAt ℝ (fun s => u (s, chart q)) t) |
| 476 | (hp : DifferentiableAt ℝ (fun x => p (t, x)) (chart q)) |
| 477 | (hr : 0 < q 0) : |
| 478 | navierStokesResidual u p t (chart q) = |
| 479 | frame (q 1) (cylindricalResidual (velocityComponents u) (pressurePullback p) t q) := by |
| 480 | have hr' : q 0 ≠ 0 := ne_of_gt hr |
| 481 | have huD := hu.differentiableAt (by norm_num) |
| 482 | have ht' : temporalDerivative u t (chart q) = |
| 483 | frame (q 1) (temporalDerivative (velocityComponents u) t q) := by |
| 484 | rw [temporalDerivative_components ht, frame_inverse'] |
| 485 | change temporalDerivative u t (chart q) + |
| 486 | fderiv ℝ (fun x => u (t, x)) (chart q) (u (t, chart q)) - |
| 487 | euclideanLaplacian (fun x => u (t, x)) (chart q) + |
| 488 | euclideanGradient (fun x => p (t, x)) (chart q) = _ |
| 489 | rw [ht', cartesianAdvection_components huD hr', cartesianLaplacian_components hu hr', |
| 490 | cartesianGradient_pullback hp hr'] |
| 491 | simp only [cylindricalResidual, velocityComponents, pressurePullback, map_add, map_sub] |
| 492 | rfl |
| 493 | |
| 494 | /-- Joint local C² regularity supplies all velocity slice hypotheses. -/ |
| 495 | theorem navierStokesResidual_cylindrical |
| 496 | {u : VelocityField} {p : PressureField} {t : ℝ} {q : Space} |
| 497 | (hu : ContDiffAt ℝ 2 u (t, chart q)) |
| 498 | (hp : DifferentiableAt ℝ p (t, chart q)) (hr : 0 < q 0) : |
| 499 | navierStokesResidual u p t (chart q) = |
| 500 | frame (q 1) (cylindricalResidual (velocityComponents u) (pressurePullback p) t q) := by |
| 501 | apply navierStokesResidual_cylindrical_of_slices |
| 502 | · exact hu.comp (chart q) (contDiffAt_const.prodMk contDiffAt_id) |
| 503 | · exact (hu.differentiableAt (by norm_num)).comp t |
| 504 | (differentiableAt_id.prodMk (differentiableAt_const _)) |
| 505 | · exact hp.comp (chart q) ((differentiableAt_const _).prodMk differentiableAt_id) |
| 506 | · exact hr |
| 507 | |
| 508 | theorem divergence_cylindrical {u : VelocityField} {t : ℝ} {q : Space} |
| 509 | (hu : DifferentiableAt ℝ (fun x => u (t, x)) (chart q)) (hr : 0 < q 0) : |
| 510 | spatialDivergence u t (chart q) = |
| 511 | vectorDivergence (fun y => velocityComponents u (t, y)) q := |
| 512 | cartesianDivergence_components hu (ne_of_gt hr) |
| 513 | |
| 514 | theorem vectorAdvection_radial (w : Space → Space) (q : Space) : |
| 515 | vectorAdvection w q 0 = |
| 516 | w q 0 * dCoord 0 w q 0 + w q 1 / q 0 * dCoord 1 w q 0 + |
| 517 | w q 2 * dCoord 2 w q 0 - (w q 1) ^ 2 / q 0 := by |
| 518 | simp [vectorAdvection, connection_apply] |
| 519 | ring |
| 520 | |
| 521 | theorem vectorAdvection_angular (w : Space → Space) (q : Space) : |
| 522 | vectorAdvection w q 1 = |
| 523 | w q 0 * dCoord 0 w q 1 + w q 1 / q 0 * dCoord 1 w q 1 + |
| 524 | w q 2 * dCoord 2 w q 1 + w q 0 * w q 1 / q 0 := by |
| 525 | simp [vectorAdvection, connection_apply] |
| 526 | ring |
| 527 | |
| 528 | theorem vectorAdvection_axial (w : Space → Space) (q : Space) : |
| 529 | vectorAdvection w q 2 = |
| 530 | w q 0 * dCoord 0 w q 2 + w q 1 / q 0 * dCoord 1 w q 2 + |
| 531 | w q 2 * dCoord 2 w q 2 := by |
| 532 | simp [vectorAdvection, connection_apply] |
| 533 | |
| 534 | theorem vectorLaplacian_radial (w : Space → Space) (q : Space) : |
| 535 | vectorLaplacian w q 0 = scalarLaplacian w q 0 - |
| 536 | w q 0 / (q 0) ^ 2 - 2 * dCoord 1 w q 1 / (q 0) ^ 2 := by |
| 537 | simp [vectorLaplacian, connection_apply] |
| 538 | ring |
| 539 | |
| 540 | theorem vectorLaplacian_angular (w : Space → Space) (q : Space) : |
| 541 | vectorLaplacian w q 1 = scalarLaplacian w q 1 - |
| 542 | w q 1 / (q 0) ^ 2 + 2 * dCoord 1 w q 0 / (q 0) ^ 2 := by |
| 543 | simp [vectorLaplacian, connection_apply] |
| 544 | ring |
| 545 | |
| 546 | theorem vectorLaplacian_axial (w : Space → Space) (q : Space) : |
| 547 | vectorLaplacian w q 2 = scalarLaplacian w q 2 := by |
| 548 | simp [vectorLaplacian, connection_apply] |
| 549 | |
| 550 | theorem dCoord_eventuallyEq {f g : Space → E} {q : Space} |
| 551 | (h : f =ᶠ[𝓝 q] g) (i : Fin 3) : dCoord i f =ᶠ[𝓝 q] dCoord i g := by |
| 552 | filter_upwards [h.fderiv (𝕜 := ℝ)] with y hy |
| 553 | exact congrArg (fun L : Space →L[ℝ] E => L (coordinateVector i)) hy |
| 554 | |
| 555 | theorem scalarLaplacian_congr {f g : Space → E} {q : Space} |
| 556 | (h : f =ᶠ[𝓝 q] g) : scalarLaplacian f q = scalarLaplacian g q := by |
| 557 | simp only [scalarLaplacian, dCoord_congr (dCoord_eventuallyEq h 0) 0, |
| 558 | dCoord_congr h 0, dCoord_congr (dCoord_eventuallyEq h 1) 1, |
| 559 | dCoord_congr (dCoord_eventuallyEq h 2) 2] |
| 560 | |
| 561 | /-- Every cylindrical operator depends only on the local germ of its fields. -/ |
| 562 | theorem cylindricalResidual_congr {u v : VelocityField} {p P : PressureField} |
| 563 | {t : ℝ} {q : Space} (hu : u =ᶠ[𝓝 (t, q)] v) (hp : p =ᶠ[𝓝 (t, q)] P) : |
| 564 | cylindricalResidual u p t q = cylindricalResidual v P t q := by |
| 565 | have hs : (fun y => u (t, y)) =ᶠ[𝓝 q] (fun y => v (t, y)) := |
| 566 | hu.comp_tendsto (continuous_const.prodMk continuous_id).continuousAt |
| 567 | have ht : (fun s => u (s, q)) =ᶠ[𝓝 t] (fun s => v (s, q)) := |
| 568 | hu.comp_tendsto (continuous_id.prodMk continuous_const).continuousAt |
| 569 | have hps : (fun y => p (t, y)) =ᶠ[𝓝 q] (fun y => P (t, y)) := |
| 570 | hp.comp_tendsto (continuous_const.prodMk continuous_id).continuousAt |
| 571 | unfold cylindricalResidual temporalDerivative vectorAdvection vectorLaplacian scalarGradient |
| 572 | rw [ht.fderiv_eq] |
| 573 | dsimp only |
| 574 | rw [hs.eq_of_nhds] |
| 575 | simp only [dCoord_congr hs 0, dCoord_congr hs 1, dCoord_congr hs 2, |
| 576 | dCoord_congr hps 0, dCoord_congr hps 1, dCoord_congr hps 2, scalarLaplacian_congr hs] |
| 577 | |
| 578 | /-- Apply the coordinate law to an arbitrary locally specified cylindrical ansatz. |
| 579 | The velocity premise is an equality of values on a neighborhood, not an assumed |
| 580 | identity between derivatives or differential operators. -/ |
| 581 | theorem navierStokesResidual_of_representation |
| 582 | {u w : VelocityField} {p P : PressureField} {t : ℝ} {q : Space} |
| 583 | (hu : ContDiffAt ℝ 2 u (t, chart q)) |
| 584 | (hp : DifferentiableAt ℝ p (t, chart q)) (hr : 0 < q 0) |
| 585 | (hw : (fun tq : SpaceTime => u (tq.1, chart tq.2)) =ᶠ[𝓝 (t, q)] |
| 586 | (fun tq => frame (tq.2 1) (w tq))) |
| 587 | (hP : pressurePullback p =ᶠ[𝓝 (t, q)] P) : |
| 588 | navierStokesResidual u p t (chart q) = frame (q 1) (cylindricalResidual w P t q) := by |
| 589 | have hc : velocityComponents u =ᶠ[𝓝 (t, q)] w := by |
| 590 | filter_upwards [hw] with tq hq |
| 591 | change frame (-(tq.2 1)) (u (tq.1, chart tq.2)) = w tq |
| 592 | rw [hq, frame_inverse] |
| 593 | rw [navierStokesResidual_cylindrical hu hp hr, cylindricalResidual_congr hc hP] |
| 594 | |
| 595 | theorem navierStokesResidual_zero_iff |
| 596 | {u : VelocityField} {p : PressureField} {t : ℝ} {q : Space} |
| 597 | (hu : ContDiffAt ℝ 2 u (t, chart q)) |
| 598 | (hp : DifferentiableAt ℝ p (t, chart q)) (hr : 0 < q 0) : |
| 599 | navierStokesResidual u p t (chart q) = 0 ↔ |
| 600 | cylindricalResidual (velocityComponents u) (pressurePullback p) t q = 0 := by |
| 601 | rw [navierStokesResidual_cylindrical hu hp hr] |
| 602 | constructor |
| 603 | · intro h |
| 604 | have h' := congrArg (frame (-(q 1))) h |
| 605 | simpa only [frame_inverse, map_zero] using h' |
| 606 | · intro h |
| 607 | rw [h, map_zero] |
| 608 | |
| 609 | theorem dCoord_dCoord_map (L : E →L[ℝ] F) {f : Space → E} {q : Space} |
| 610 | (hf : ContDiffAt ℝ 2 f q) (i : Fin 3) : |
| 611 | dCoord i (dCoord i (fun y => L (f y))) q = L (dCoord i (dCoord i f) q) := by |
| 612 | have hnear : dCoord i (fun y => L (f y)) =ᶠ[𝓝 q] fun y => L (dCoord i f y) := by |
| 613 | filter_upwards [hf.eventually (by norm_num)] with y hy |
| 614 | exact dCoord_map L (hy.differentiableAt (by norm_num)) i |
| 615 | rw [dCoord_congr hnear, dCoord_map L |
| 616 | ((contDiffAt_dCoord hf (m := 1) (by norm_num) i).differentiableAt (by norm_num))] |
| 617 | |
| 618 | theorem scalarLaplacian_map (L : E →L[ℝ] F) {f : Space → E} {q : Space} |
| 619 | (hf : ContDiffAt ℝ 2 f q) : |
| 620 | scalarLaplacian (fun y => L (f y)) q = L (scalarLaplacian f q) := by |
| 621 | simp only [scalarLaplacian, dCoord_dCoord_map L hf, |
| 622 | dCoord_map L (hf.differentiableAt (by norm_num)), map_add, map_smul] |
| 623 | |
| 624 | /-- The vector-valued scalar Laplacian has the expected actual scalar components. -/ |
| 625 | theorem scalarLaplacian_component {w : Space → Space} {q : Space} |
| 626 | (hw : ContDiffAt ℝ 2 w q) (j : Fin 3) : |
| 627 | scalarLaplacian (fun y => w y j) q = scalarLaplacian w q j := |
| 628 | scalarLaplacian_map (projection j) hw |
| 629 | |
| 630 | end |
| 631 | |
| 632 | end NavierStokes.CylindricalResidual |