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

refactor(Euler/Linear): 2 small modules folded into the file that imports them (−28.1%, measured) #692
Merged
+0 −98 Euler/LinearDuhamelFrozenGevrey.lean deleted
| @@ -1,98 +0,0 @@ | ||
| 1 | -import Euler.LinearDuhamelFrozenOperator | |
| 2 | -import Euler.ParameterSobolevCoefficient | |
| 3 | -import Euler.ParameterSobolevLinear | |
| 4 | - | |
| 5 | -/-! | |
| 6 | -# Quantitative bounds for the actual frozen forward equation | |
| 7 | - | |
| 8 | -The frozen coefficient has a polynomial tensor multiplier bound derived | |
| 9 | -from the original coefficient and the H3 Green bound. Its fixed-Sobolev | |
| 10 | -forcing block is bounded directly by the original initial/forcing blocks. | |
| 11 | -No profile extremum, inverse amplitude, or raw weighted primitive is used. | |
| 12 | --/ | |
| 13 | - | |
| 14 | -noncomputable section | |
| 15 | - | |
| 16 | -namespace EulerLinearDuhamel | |
| 17 | - | |
| 18 | -open Set ContinuousLinearMap EulerContinuousTimeIntegral EulerContinuousTimeWeight | |
| 19 | - EulerContinuousPathCalculus EulerOperatorGevreyCalculus EulerGevrey EulerParameterWordGevrey | |
| 20 | -open scoped ContDiff | |
| 21 | - | |
| 22 | -variable {P E : Type*} [NormedAddCommGroup P] [NormedSpace ℝ P] | |
| 23 | - [NormedAddCommGroup E] [NormedSpace ℝ E] [CompleteSpace E] | |
| 24 | - (T : ℝ) (hT : 0 ≤ T) (B : P → C(Icc (0 : ℝ) T,E →L[ℝ] E)) | |
| 25 | - (U : ∀ x, Evolution T hT (B x)) | |
| 26 | - (g : C(Icc (0 : ℝ) T,ℝ)) (hg : ∀ t, 0 < g t) | |
| 27 | - | |
| 28 | -private local instance : NormedAddCommGroup (E →L[ℝ] E) := inferInstance | |
| 29 | -private local instance : NormedSpace ℝ (E →L[ℝ] E) := inferInstance | |
| 30 | -private local instance : NormedAddCommGroup C(Icc (0 : ℝ) T,E) := inferInstance | |
| 31 | -private local instance : NormedSpace ℝ C(Icc (0 : ℝ) T,E) := inferInstance | |
| 32 | -private local instance : NormedAddCommGroup C(Icc (0 : ℝ) T,E →L[ℝ] E) := inferInstance | |
| 33 | -private local instance : NormedSpace ℝ C(Icc (0 : ℝ) T,E →L[ℝ] E) := inferInstance | |
| 34 | -private local instance : NormedAddCommGroup (C(Icc (0 : ℝ) T,E) →L[ℝ] C(Icc (0 : ℝ) T,E)) := inferInstance | |
| 35 | -private local instance : NormedSpace ℝ (C(Icc (0 : ℝ) T,E) →L[ℝ] C(Icc (0 : ℝ) T,E)) := inferInstance | |
| 36 | - | |
| 37 | -/-- The frozen coefficient amplitude is polynomial in the original coefficient and H3 constant. -/ | |
| 38 | -def frozenAmplitude (T C CB : ℝ) : ℝ := 1+2*C*T*CB | |
| 39 | - | |
| 40 | -/-- Actual derivatives of the frozen coefficient have the stated polynomial bound. -/ | |
| 41 | -theorem frozenOperator_bound (hB : ContDiff ℝ ∞ B) | |
| 42 | - (hg₀ : g ⟨0,le_rfl,hT⟩ = 1) (C CB Rc : ℝ) (hC : 0 ≤ C) (hCB : 0 ≤ CB) (hRc : 0 ≤ Rc) | |
| 43 | - (hBb : ∀ n y, ‖iteratedFDeriv ℝ n B y‖ ≤ CB*majorant Rc 0 n) | |
| 44 | - (x : P) (hU : ∀ t s : Icc (0 : ℝ) T, s ≤ t → ‖(U x).propagator t s‖ ≤ C*g t/g s) | |
| 45 | - (n : ℕ) (y : P) : | |
| 46 | - ‖iteratedFDeriv ℝ n (frozenOperator T hT B U g hg x) y‖ ≤ | |
| 47 | - frozenAmplitude T C CB*majorant Rc 0 n := by | |
| 48 | - let K := (U x).weightedForcing g hg | |
| 49 | - let D := (fun z => multiplier (B z))-fun _ => multiplier (B x) | |
| 50 | - have hM := contDiff_multiplier B hB | |
| 51 | - have hD : ContDiff ℝ ∞ D := hM.sub contDiff_const | |
| 52 | - have hMb := multiplier_bound B hB Rc CB hRc hCB 0 hBb | |
| 53 | - have hMx : ‖multiplier (B x)‖ ≤ CB := by | |
| 54 | - simpa only [norm_iteratedFDeriv_zero, majorant, Nat.add_zero, pow_zero, | |
| 55 | - Nat.factorial_zero, Nat.cast_one, one_pow, mul_one] using hMb 0 x | |
| 56 | - have hDb := sub_bound (fun z => multiplier (B z)) (fun _ : P => multiplier (B x)) | |
| 57 | - hM contDiff_const Rc CB CB 0 hMb (const_bound (multiplier (B x)) Rc CB hRc hMx) | |
| 58 | - have hKb : ‖K‖ ≤ C*T := (U x).weightedForcing_norm g hg hg₀ C hC hU | |
| 59 | - have hKD (j : ℕ) (z : P) : ‖iteratedFDeriv ℝ j (fun w => K.comp (D w)) z‖ ≤ | |
| 60 | - (2*C*T*CB)*majorant Rc 0 j := by | |
| 61 | - have h := clm_comp_const_left_bound K D hD Rc (CB+CB) hRc (by positivity) 0 hDb j z | |
| 62 | - apply h.trans | |
| 63 | - apply mul_le_mul_of_nonneg_right _ (majorant_nonneg Rc hRc 0 j) | |
| 64 | - calc | |
| 65 | - ‖K‖*(CB+CB) ≤ (C*T)*(CB+CB) := mul_le_mul_of_nonneg_right hKb (by positivity) | |
| 66 | - _ = 2*C*T*CB := by ring | |
| 67 | - have h := sub_bound (fun _ : P => ContinuousLinearMap.id ℝ C(Icc (0 : ℝ) T,E)) | |
| 68 | - (fun z => K.comp (D z)) contDiff_const (contDiff_const.clm_comp hD) | |
| 69 | - Rc 1 (2*C*T*CB) 0 | |
| 70 | - (const_bound (ContinuousLinearMap.id ℝ C(Icc (0 : ℝ) T,E)) Rc 1 hRc norm_id_le) hKD n y | |
| 71 | - exact h | |
| 72 | - | |
| 73 | -/-- The transformed right side preserves the original fixed-Sobolev external radius. -/ | |
| 74 | -theorem frozenForcing_block_bound {ι : Type*} [Fintype ι] (directions : ι → P) (q : ℕ) | |
| 75 | - (f : P → C(Icc (0 : ℝ) T,E)) (a₀ : P → E) | |
| 76 | - (hf : ContDiff ℝ ∞ f) (ha₀ : ContDiff ℝ ∞ a₀) | |
| 77 | - (hg₀ : g ⟨0,le_rfl,hT⟩ = 1) (C A D R : ℝ) (hC : 0 ≤ C) | |
| 78 | - (x : P) (hU : ∀ t s : Icc (0 : ℝ) T, s ≤ t → ‖(U x).propagator t s‖ ≤ C*g t/g s) | |
| 79 | - (d : ℕ) (hfa : ∀ n, block directions q f n x ≤ D*majorant R d n) | |
| 80 | - (haa : ∀ n, block directions q a₀ n x ≤ A*majorant R d n) (n : ℕ) : | |
| 81 | - block directions q (frozenForcing T hT B U g hg f a₀ x) n x ≤ | |
| 82 | - (C*A+C*T*D)*majorant R d n := by | |
| 83 | - let H := (U x).weightedInitial g hg | |
| 84 | - let K := (U x).weightedForcing g hg | |
| 85 | - have hH := block_comp_clm_le directions q H a₀ ha₀ n x | |
| 86 | - have hK := block_comp_clm_le directions q K f hf n x | |
| 87 | - have hs := block_add_le directions q (H ∘ a₀) (K ∘ f) | |
| 88 | - (H.contDiff.comp ha₀) (K.contDiff.comp hf) n x | |
| 89 | - apply hs.trans | |
| 90 | - calc | |
| 91 | - _ ≤ C*(A*majorant R d n)+(C*T)*(D*majorant R d n) := add_le_add | |
| 92 | - (hH.trans (mul_le_mul ((U x).weightedInitial_norm g hg hg₀ C hC hU) | |
| 93 | - (haa n) (block_nonneg directions q a₀ n x) hC)) | |
| 94 | - (hK.trans (mul_le_mul ((U x).weightedForcing_norm g hg hg₀ C hC hU) | |
| 95 | - (hfa n) (block_nonneg directions q f n x) (mul_nonneg hC hT))) | |
| 96 | - _ = _ := by ring | |
| 97 | - | |
| 98 | -end EulerLinearDuhamel | |
+0 −77 Euler/LinearDuhamelFrozenOperator.lean deleted
| @@ -1,77 +0,0 @@ | ||
| 1 | -import Euler.LinearDuhamelGevrey | |
| 2 | - | |
| 3 | -/-! | |
| 4 | -# A frozen bounded-operator equation for the actual forward solve | |
| 5 | - | |
| 6 | -At a chosen parameter x, Duhamel gives an exact equation with coefficient | |
| 7 | -Id minus the fixed Green operator applied to the coefficient difference. | |
| 8 | -Its coefficient at x is exactly Id. Thus the fixed-Sobolev inverse estimate | |
| 9 | -can use the identity inverse; it never requires a norm for a profile-weighted | |
| 10 | -raw time primitive. | |
| 11 | --/ | |
| 12 | - | |
| 13 | -noncomputable section | |
| 14 | - | |
| 15 | -namespace EulerLinearDuhamel | |
| 16 | - | |
| 17 | -open Set ContinuousLinearMap EulerContinuousTimeIntegral EulerContinuousTimeWeight | |
| 18 | - EulerContinuousPathCalculus | |
| 19 | -open scoped ContDiff | |
| 20 | - | |
| 21 | -variable {P E : Type*} [NormedAddCommGroup P] [NormedSpace ℝ P] | |
| 22 | - [NormedAddCommGroup E] [NormedSpace ℝ E] [CompleteSpace E] | |
| 23 | - (T : ℝ) (hT : 0 ≤ T) (B : P → C(Icc (0 : ℝ) T,E →L[ℝ] E)) | |
| 24 | - (U : ∀ x, Evolution T hT (B x)) | |
| 25 | - (g : C(Icc (0 : ℝ) T,ℝ)) (hg : ∀ t, 0 < g t) | |
| 26 | - | |
| 27 | -private local instance : NormedAddCommGroup (E →L[ℝ] E) := inferInstance | |
| 28 | -private local instance : NormedSpace ℝ (E →L[ℝ] E) := inferInstance | |
| 29 | -private local instance : NormedAddCommGroup C(Icc (0 : ℝ) T,E) := inferInstance | |
| 30 | -private local instance : NormedSpace ℝ C(Icc (0 : ℝ) T,E) := inferInstance | |
| 31 | -private local instance : NormedAddCommGroup C(Icc (0 : ℝ) T,E →L[ℝ] E) := inferInstance | |
| 32 | -private local instance : NormedSpace ℝ C(Icc (0 : ℝ) T,E →L[ℝ] E) := inferInstance | |
| 33 | -private local instance : NormedAddCommGroup (C(Icc (0 : ℝ) T,E) →L[ℝ] C(Icc (0 : ℝ) T,E)) := inferInstance | |
| 34 | -private local instance : NormedSpace ℝ (C(Icc (0 : ℝ) T,E) →L[ℝ] C(Icc (0 : ℝ) T,E)) := inferInstance | |
| 35 | - | |
| 36 | -/-- The exact frozen coefficient, using the actual weighted Green operator. -/ | |
| 37 | -def frozenOperator (x y : P) : C(Icc (0 : ℝ) T,E) →L[ℝ] C(Icc (0 : ℝ) T,E) := | |
| 38 | - ContinuousLinearMap.id ℝ _ - ((U x).weightedForcing g hg).comp (multiplier (B y)-multiplier (B x)) | |
| 39 | - | |
| 40 | -/-- The exact transformed data under the fixed homogeneous and Green operators. -/ | |
| 41 | -def frozenForcing (f : P → C(Icc (0 : ℝ) T,E)) (a₀ : P → E) (x y : P) : C(Icc (0 : ℝ) T,E) := | |
| 42 | - (U x).weightedInitial g hg (a₀ y)+(U x).weightedForcing g hg (f y) | |
| 43 | - | |
| 44 | -omit [NormedAddCommGroup P] [NormedSpace ℝ P] in | |
| 45 | -/-- The frozen coefficient at its base parameter is the identity. -/ | |
| 46 | -theorem frozenOperator_self (x : P) : | |
| 47 | - frozenOperator T hT B U g hg x x = ContinuousLinearMap.id ℝ _ := by | |
| 48 | - simp only [frozenOperator, sub_self, comp_zero, sub_zero] | |
| 49 | - | |
| 50 | -omit [NormedAddCommGroup P] [NormedSpace ℝ P] in | |
| 51 | -/-- The actual normalized Duhamel solution satisfies this bounded-operator equation. -/ | |
| 52 | -theorem frozenOperator_equation (f : P → C(Icc (0 : ℝ) T,E)) (a₀ : P → E) (x y : P) : | |
| 53 | - frozenOperator T hT B U g hg x y ((U y).weightedSolution g hg (f y) (a₀ y)) = | |
| 54 | - frozenForcing T hT B U g hg f a₀ x y := by | |
| 55 | - have hd : multiplier (B y-B x) = multiplier (B y)-multiplier (B x) := by | |
| 56 | - ext p t | |
| 57 | - rfl | |
| 58 | - have h := (U x).weighted_frozen_solution g hg (U y) (f y) (a₀ y) | |
| 59 | - rw [hd, map_add] at h | |
| 60 | - change (U y).weightedSolution g hg (f y) (a₀ y)- | |
| 61 | - (U x).weightedForcing g hg ((multiplier (B y)-multiplier (B x)) | |
| 62 | - ((U y).weightedSolution g hg (f y) (a₀ y))) = _ | |
| 63 | - exact sub_eq_iff_eq_add.mpr (by simpa only [frozenForcing, add_assoc] using h) | |
| 64 | - | |
| 65 | -/-- The frozen coefficient is genuinely smooth in the translated coefficients. -/ | |
| 66 | -theorem frozenOperator_contDiff (hB : ContDiff ℝ ∞ B) (x : P) : | |
| 67 | - ContDiff ℝ ∞ (frozenOperator T hT B U g hg x) := | |
| 68 | - contDiff_const.sub (contDiff_const.clm_comp ((contDiff_multiplier B hB).sub contDiff_const)) | |
| 69 | - | |
| 70 | -/-- The transformed data retain the actual parameter smoothness of the original data. -/ | |
| 71 | -theorem frozenForcing_contDiff (f : P → C(Icc (0 : ℝ) T,E)) (a₀ : P → E) | |
| 72 | - (hf : ContDiff ℝ ∞ f) (ha₀ : ContDiff ℝ ∞ a₀) (x : P) : | |
| 73 | - ContDiff ℝ ∞ (frozenForcing T hT B U g hg f a₀ x) := | |
| 74 | - (((U x).weightedInitial g hg).contDiff.comp ha₀).add | |
| 75 | - (((U x).weightedForcing g hg).contDiff.comp hf) | |
| 76 | - | |
| 77 | -end EulerLinearDuhamel | |
+192 −1 Euler/LinearDuhamelSobolevGevrey.lean View file
| @@ -1,4 +1,6 @@ | ||
| 1 | -import Euler.LinearDuhamelFrozenGevrey | |
| 1 | +import Euler.LinearDuhamelGevrey | |
| 2 | +import Euler.ParameterSobolevCoefficient | |
| 3 | +import Euler.ParameterSobolevLinear | |
| 2 | 4 | import Euler.ParameterSobolevGevreyAt |
| 3 | 5 | |
| 4 | 6 | /-! |
| @@ -11,6 +13,195 @@ shift at the same input/output radius. Every constant is a fixed polynomial | ||
| 11 | 13 | in the coefficient, data, propagator and time-length constants when q is fixed. |
| 12 | 14 | -/ |
| 13 | 15 | |
| 16 | +/-! ## From `Euler/LinearDuhamelFrozenOperator.lean` | |
| 17 | + | |
| 18 | +The text of `Euler/LinearDuhamelFrozenOperator.lean`, folded into this file, which was its only importer. -/ | |
| 19 | + | |
| 20 | +section | |
| 21 | + | |
| 22 | +/-! | |
| 23 | +# A frozen bounded-operator equation for the actual forward solve | |
| 24 | + | |
| 25 | +At a chosen parameter x, Duhamel gives an exact equation with coefficient | |
| 26 | +Id minus the fixed Green operator applied to the coefficient difference. | |
| 27 | +Its coefficient at x is exactly Id. Thus the fixed-Sobolev inverse estimate | |
| 28 | +can use the identity inverse; it never requires a norm for a profile-weighted | |
| 29 | +raw time primitive. | |
| 30 | +-/ | |
| 31 | + | |
| 32 | +noncomputable section | |
| 33 | + | |
| 34 | +namespace EulerLinearDuhamel | |
| 35 | + | |
| 36 | +open Set ContinuousLinearMap EulerContinuousTimeIntegral EulerContinuousTimeWeight | |
| 37 | + EulerContinuousPathCalculus | |
| 38 | +open scoped ContDiff | |
| 39 | + | |
| 40 | +variable {P E : Type*} [NormedAddCommGroup P] [NormedSpace ℝ P] | |
| 41 | + [NormedAddCommGroup E] [NormedSpace ℝ E] [CompleteSpace E] | |
| 42 | + (T : ℝ) (hT : 0 ≤ T) (B : P → C(Icc (0 : ℝ) T,E →L[ℝ] E)) | |
| 43 | + (U : ∀ x, Evolution T hT (B x)) | |
| 44 | + (g : C(Icc (0 : ℝ) T,ℝ)) (hg : ∀ t, 0 < g t) | |
| 45 | + | |
| 46 | +private local instance : NormedAddCommGroup (E →L[ℝ] E) := inferInstance | |
| 47 | +private local instance : NormedSpace ℝ (E →L[ℝ] E) := inferInstance | |
| 48 | +private local instance : NormedAddCommGroup C(Icc (0 : ℝ) T,E) := inferInstance | |
| 49 | +private local instance : NormedSpace ℝ C(Icc (0 : ℝ) T,E) := inferInstance | |
| 50 | +private local instance : NormedAddCommGroup C(Icc (0 : ℝ) T,E →L[ℝ] E) := inferInstance | |
| 51 | +private local instance : NormedSpace ℝ C(Icc (0 : ℝ) T,E →L[ℝ] E) := inferInstance | |
| 52 | +private local instance : NormedAddCommGroup (C(Icc (0 : ℝ) T,E) →L[ℝ] C(Icc (0 : ℝ) T,E)) := inferInstance | |
| 53 | +private local instance : NormedSpace ℝ (C(Icc (0 : ℝ) T,E) →L[ℝ] C(Icc (0 : ℝ) T,E)) := inferInstance | |
| 54 | + | |
| 55 | +/-- The exact frozen coefficient, using the actual weighted Green operator. -/ | |
| 56 | +def frozenOperator (x y : P) : C(Icc (0 : ℝ) T,E) →L[ℝ] C(Icc (0 : ℝ) T,E) := | |
| 57 | + ContinuousLinearMap.id ℝ _ - ((U x).weightedForcing g hg).comp (multiplier (B y)-multiplier (B x)) | |
| 58 | + | |
| 59 | +/-- The exact transformed data under the fixed homogeneous and Green operators. -/ | |
| 60 | +def frozenForcing (f : P → C(Icc (0 : ℝ) T,E)) (a₀ : P → E) (x y : P) : C(Icc (0 : ℝ) T,E) := | |
| 61 | + (U x).weightedInitial g hg (a₀ y)+(U x).weightedForcing g hg (f y) | |
| 62 | + | |
| 63 | +omit [NormedAddCommGroup P] [NormedSpace ℝ P] in | |
| 64 | +/-- The frozen coefficient at its base parameter is the identity. -/ | |
| 65 | +theorem frozenOperator_self (x : P) : | |
| 66 | + frozenOperator T hT B U g hg x x = ContinuousLinearMap.id ℝ _ := by | |
| 67 | + simp only [frozenOperator, sub_self, comp_zero, sub_zero] | |
| 68 | + | |
| 69 | +omit [NormedAddCommGroup P] [NormedSpace ℝ P] in | |
| 70 | +/-- The actual normalized Duhamel solution satisfies this bounded-operator equation. -/ | |
| 71 | +theorem frozenOperator_equation (f : P → C(Icc (0 : ℝ) T,E)) (a₀ : P → E) (x y : P) : | |
| 72 | + frozenOperator T hT B U g hg x y ((U y).weightedSolution g hg (f y) (a₀ y)) = | |
| 73 | + frozenForcing T hT B U g hg f a₀ x y := by | |
| 74 | + have hd : multiplier (B y-B x) = multiplier (B y)-multiplier (B x) := by | |
| 75 | + ext p t | |
| 76 | + rfl | |
| 77 | + have h := (U x).weighted_frozen_solution g hg (U y) (f y) (a₀ y) | |
| 78 | + rw [hd, map_add] at h | |
| 79 | + change (U y).weightedSolution g hg (f y) (a₀ y)- | |
| 80 | + (U x).weightedForcing g hg ((multiplier (B y)-multiplier (B x)) | |
| 81 | + ((U y).weightedSolution g hg (f y) (a₀ y))) = _ | |
| 82 | + exact sub_eq_iff_eq_add.mpr (by simpa only [frozenForcing, add_assoc] using h) | |
| 83 | + | |
| 84 | +/-- The frozen coefficient is genuinely smooth in the translated coefficients. -/ | |
| 85 | +theorem frozenOperator_contDiff (hB : ContDiff ℝ ∞ B) (x : P) : | |
| 86 | + ContDiff ℝ ∞ (frozenOperator T hT B U g hg x) := | |
| 87 | + contDiff_const.sub (contDiff_const.clm_comp ((contDiff_multiplier B hB).sub contDiff_const)) | |
| 88 | + | |
| 89 | +/-- The transformed data retain the actual parameter smoothness of the original data. -/ | |
| 90 | +theorem frozenForcing_contDiff (f : P → C(Icc (0 : ℝ) T,E)) (a₀ : P → E) | |
| 91 | + (hf : ContDiff ℝ ∞ f) (ha₀ : ContDiff ℝ ∞ a₀) (x : P) : | |
| 92 | + ContDiff ℝ ∞ (frozenForcing T hT B U g hg f a₀ x) := | |
| 93 | + (((U x).weightedInitial g hg).contDiff.comp ha₀).add | |
| 94 | + (((U x).weightedForcing g hg).contDiff.comp hf) | |
| 95 | + | |
| 96 | +end EulerLinearDuhamel | |
| 97 | +end | |
| 98 | + | |
| 99 | +end | |
| 100 | + | |
| 101 | +/-! ## From `Euler/LinearDuhamelFrozenGevrey.lean` | |
| 102 | + | |
| 103 | +The text of `Euler/LinearDuhamelFrozenGevrey.lean`, folded into this file, which was its only importer. -/ | |
| 104 | + | |
| 105 | +section | |
| 106 | + | |
| 107 | +/-! | |
| 108 | +# Quantitative bounds for the actual frozen forward equation | |
| 109 | + | |
| 110 | +The frozen coefficient has a polynomial tensor multiplier bound derived | |
| 111 | +from the original coefficient and the H3 Green bound. Its fixed-Sobolev | |
| 112 | +forcing block is bounded directly by the original initial/forcing blocks. | |
| 113 | +No profile extremum, inverse amplitude, or raw weighted primitive is used. | |
| 114 | +-/ | |
| 115 | + | |
| 116 | +noncomputable section | |
| 117 | + | |
| 118 | +namespace EulerLinearDuhamel | |
| 119 | + | |
| 120 | +open Set ContinuousLinearMap EulerContinuousTimeIntegral EulerContinuousTimeWeight | |
| 121 | + EulerContinuousPathCalculus EulerOperatorGevreyCalculus EulerGevrey EulerParameterWordGevrey | |
| 122 | +open scoped ContDiff | |
| 123 | + | |
| 124 | +variable {P E : Type*} [NormedAddCommGroup P] [NormedSpace ℝ P] | |
| 125 | + [NormedAddCommGroup E] [NormedSpace ℝ E] [CompleteSpace E] | |
| 126 | + (T : ℝ) (hT : 0 ≤ T) (B : P → C(Icc (0 : ℝ) T,E →L[ℝ] E)) | |
| 127 | + (U : ∀ x, Evolution T hT (B x)) | |
| 128 | + (g : C(Icc (0 : ℝ) T,ℝ)) (hg : ∀ t, 0 < g t) | |
| 129 | + | |
| 130 | +private local instance : NormedAddCommGroup (E →L[ℝ] E) := inferInstance | |
| 131 | +private local instance : NormedSpace ℝ (E →L[ℝ] E) := inferInstance | |
| 132 | +private local instance : NormedAddCommGroup C(Icc (0 : ℝ) T,E) := inferInstance | |
| 133 | +private local instance : NormedSpace ℝ C(Icc (0 : ℝ) T,E) := inferInstance | |
| 134 | +private local instance : NormedAddCommGroup C(Icc (0 : ℝ) T,E →L[ℝ] E) := inferInstance | |
| 135 | +private local instance : NormedSpace ℝ C(Icc (0 : ℝ) T,E →L[ℝ] E) := inferInstance | |
| 136 | +private local instance : NormedAddCommGroup (C(Icc (0 : ℝ) T,E) →L[ℝ] C(Icc (0 : ℝ) T,E)) := inferInstance | |
| 137 | +private local instance : NormedSpace ℝ (C(Icc (0 : ℝ) T,E) →L[ℝ] C(Icc (0 : ℝ) T,E)) := inferInstance | |
| 138 | + | |
| 139 | +/-- The frozen coefficient amplitude is polynomial in the original coefficient and H3 constant. -/ | |
| 140 | +def frozenAmplitude (T C CB : ℝ) : ℝ := 1+2*C*T*CB | |
| 141 | + | |
| 142 | +/-- Actual derivatives of the frozen coefficient have the stated polynomial bound. -/ | |
| 143 | +theorem frozenOperator_bound (hB : ContDiff ℝ ∞ B) | |
| 144 | + (hg₀ : g ⟨0,le_rfl,hT⟩ = 1) (C CB Rc : ℝ) (hC : 0 ≤ C) (hCB : 0 ≤ CB) (hRc : 0 ≤ Rc) | |
| 145 | + (hBb : ∀ n y, ‖iteratedFDeriv ℝ n B y‖ ≤ CB*majorant Rc 0 n) | |
| 146 | + (x : P) (hU : ∀ t s : Icc (0 : ℝ) T, s ≤ t → ‖(U x).propagator t s‖ ≤ C*g t/g s) | |
| 147 | + (n : ℕ) (y : P) : | |
| 148 | + ‖iteratedFDeriv ℝ n (frozenOperator T hT B U g hg x) y‖ ≤ | |
| 149 | + frozenAmplitude T C CB*majorant Rc 0 n := by | |
| 150 | + let K := (U x).weightedForcing g hg | |
| 151 | + let D := (fun z => multiplier (B z))-fun _ => multiplier (B x) | |
| 152 | + have hM := contDiff_multiplier B hB | |
| 153 | + have hD : ContDiff ℝ ∞ D := hM.sub contDiff_const | |
| 154 | + have hMb := multiplier_bound B hB Rc CB hRc hCB 0 hBb | |
| 155 | + have hMx : ‖multiplier (B x)‖ ≤ CB := by | |
| 156 | + simpa only [norm_iteratedFDeriv_zero, majorant, Nat.add_zero, pow_zero, | |
| 157 | + Nat.factorial_zero, Nat.cast_one, one_pow, mul_one] using hMb 0 x | |
| 158 | + have hDb := sub_bound (fun z => multiplier (B z)) (fun _ : P => multiplier (B x)) | |
| 159 | + hM contDiff_const Rc CB CB 0 hMb (const_bound (multiplier (B x)) Rc CB hRc hMx) | |
| 160 | + have hKb : ‖K‖ ≤ C*T := (U x).weightedForcing_norm g hg hg₀ C hC hU | |
| 161 | + have hKD (j : ℕ) (z : P) : ‖iteratedFDeriv ℝ j (fun w => K.comp (D w)) z‖ ≤ | |
| 162 | + (2*C*T*CB)*majorant Rc 0 j := by | |
| 163 | + have h := clm_comp_const_left_bound K D hD Rc (CB+CB) hRc (by positivity) 0 hDb j z | |
| 164 | + apply h.trans | |
| 165 | + apply mul_le_mul_of_nonneg_right _ (majorant_nonneg Rc hRc 0 j) | |
| 166 | + calc | |
| 167 | + ‖K‖*(CB+CB) ≤ (C*T)*(CB+CB) := mul_le_mul_of_nonneg_right hKb (by positivity) | |
| 168 | + _ = 2*C*T*CB := by ring | |
| 169 | + have h := sub_bound (fun _ : P => ContinuousLinearMap.id ℝ C(Icc (0 : ℝ) T,E)) | |
| 170 | + (fun z => K.comp (D z)) contDiff_const (contDiff_const.clm_comp hD) | |
| 171 | + Rc 1 (2*C*T*CB) 0 | |
| 172 | + (const_bound (ContinuousLinearMap.id ℝ C(Icc (0 : ℝ) T,E)) Rc 1 hRc norm_id_le) hKD n y | |
| 173 | + exact h | |
| 174 | + | |
| 175 | +/-- The transformed right side preserves the original fixed-Sobolev external radius. -/ | |
| 176 | +theorem frozenForcing_block_bound {ι : Type*} [Fintype ι] (directions : ι → P) (q : ℕ) | |
| 177 | + (f : P → C(Icc (0 : ℝ) T,E)) (a₀ : P → E) | |
| 178 | + (hf : ContDiff ℝ ∞ f) (ha₀ : ContDiff ℝ ∞ a₀) | |
| 179 | + (hg₀ : g ⟨0,le_rfl,hT⟩ = 1) (C A D R : ℝ) (hC : 0 ≤ C) | |
| 180 | + (x : P) (hU : ∀ t s : Icc (0 : ℝ) T, s ≤ t → ‖(U x).propagator t s‖ ≤ C*g t/g s) | |
| 181 | + (d : ℕ) (hfa : ∀ n, block directions q f n x ≤ D*majorant R d n) | |
| 182 | + (haa : ∀ n, block directions q a₀ n x ≤ A*majorant R d n) (n : ℕ) : | |
| 183 | + block directions q (frozenForcing T hT B U g hg f a₀ x) n x ≤ | |
| 184 | + (C*A+C*T*D)*majorant R d n := by | |
| 185 | + let H := (U x).weightedInitial g hg | |
| 186 | + let K := (U x).weightedForcing g hg | |
| 187 | + have hH := block_comp_clm_le directions q H a₀ ha₀ n x | |
| 188 | + have hK := block_comp_clm_le directions q K f hf n x | |
| 189 | + have hs := block_add_le directions q (H ∘ a₀) (K ∘ f) | |
| 190 | + (H.contDiff.comp ha₀) (K.contDiff.comp hf) n x | |
| 191 | + apply hs.trans | |
| 192 | + calc | |
| 193 | + _ ≤ C*(A*majorant R d n)+(C*T)*(D*majorant R d n) := add_le_add | |
| 194 | + (hH.trans (mul_le_mul ((U x).weightedInitial_norm g hg hg₀ C hC hU) | |
| 195 | + (haa n) (block_nonneg directions q a₀ n x) hC)) | |
| 196 | + (hK.trans (mul_le_mul ((U x).weightedForcing_norm g hg hg₀ C hC hU) | |
| 197 | + (hfa n) (block_nonneg directions q f n x) (mul_nonneg hC hT))) | |
| 198 | + _ = _ := by ring | |
| 199 | + | |
| 200 | +end EulerLinearDuhamel | |
| 201 | +end | |
| 202 | + | |
| 203 | +end | |
| 204 | + | |
| 14 | 205 | noncomputable section |
| 15 | 206 | |
| 16 | 207 | namespace EulerLinearDuhamel |
+75 −0 docs/s5-folding/ContentTail.lean added View file
| @@ -0,0 +1,75 @@ | ||
| 1 | + | |
| 2 | +-- Every named constant of the two libraries with a hash of its type (and of its value when it is a definition) in which | |
| 3 | +-- an auxiliary constant counts by what it is, not by what it is called: private declarations, nested-proof lemmas, | |
| 4 | +-- matchers and automatically named local instances get their names from the module and from the order of elaboration, | |
| 5 | +-- and a fold changes both. A theorem met inside a term counts by its statement alone. | |
| 6 | +open Lean | |
| 7 | + | |
| 8 | +namespace FoldCheck | |
| 9 | + | |
| 10 | +def isAux (n : Name) : Bool := | |
| 11 | + n.components.any fun c => match c with | |
| 12 | + | .str _ s => s.startsWith "_" || (s.startsWith "match_" && (s.drop 6).all Char.isDigit) || (s.startsWith "proof_" && (s.drop 6).all Char.isDigit) | |
| 13 | + | .num _ _ => true | |
| 14 | + | .anonymous => false | |
| 15 | + | |
| 16 | +def userName (n : Name) : Name := | |
| 17 | + if isPrivateName n then ((n.components.dropWhile fun c => !c.isNum).drop 1).foldl (· ++ ·) `_private else n | |
| 18 | + | |
| 19 | +abbrev M := StateM (Std.HashMap Name UInt64 × Std.HashSet Name) | |
| 20 | + | |
| 21 | +mutual | |
| 22 | + partial def constHash (env : Environment) (n : Name) : M UInt64 := do | |
| 23 | + if let some h := (← get).1[n]? then return h | |
| 24 | + if (← get).2.contains n then return hash (userName n) | |
| 25 | + let some ci := env.find? n | return hash (userName n) | |
| 26 | + modify fun (m, v) => (m, v.insert n) | |
| 27 | + let th ← exprHash env ci.type | |
| 28 | + let (k, vh) ← match ci with | |
| 29 | + | .thmInfo _ => pure ((1 : UInt64), (0 : UInt64)) | |
| 30 | + | .defnInfo d => do pure (2, ← exprHash env d.value) | |
| 31 | + | .opaqueInfo d => do pure (3, ← exprHash env d.value) | |
| 32 | + | .ctorInfo c => pure (4, c.cidx.toUInt64) | |
| 33 | + | .inductInfo _ => pure (5, 0) | |
| 34 | + | .recInfo _ => pure (6, 0) | |
| 35 | + | _ => pure (7, 0) | |
| 36 | + let h := mixHash k (mixHash th vh) | |
| 37 | + modify fun (m, v) => (m.insert n h, v.erase n) | |
| 38 | + return h | |
| 39 | + partial def exprHash (env : Environment) (e : Expr) : M UInt64 := do | |
| 40 | + for u in e.getUsedConstants do | |
| 41 | + if isAux u then discard <| constHash env u | |
| 42 | + let memo := (← get).1 | |
| 43 | + let e' := e.replace fun | |
| 44 | + | .const n ls => if isAux n then some (.const (Name.mkNum `_h (memo.getD n 0).toNat) ls) else none | |
| 45 | + | _ => none | |
| 46 | + return e'.hash | |
| 47 | +end | |
| 48 | + | |
| 49 | +end FoldCheck | |
| 50 | + | |
| 51 | +open FoldCheck in | |
| 52 | +#eval show CoreM Unit from do | |
| 53 | + let env ← getEnv | |
| 54 | + let mods := env.header.moduleNames | |
| 55 | + let proj (m : Name) : Bool := m.getRoot == `NavierStokes || m.getRoot == `Euler | |
| 56 | + let h ← IO.FS.Handle.mk "/out/content.tsv" IO.FS.Mode.write | |
| 57 | + let mut st : Std.HashMap Name UInt64 × Std.HashSet Name := ({}, {}) | |
| 58 | + let mut n := 0 | |
| 59 | + for (c, ci) in env.constants.map₁.toList do | |
| 60 | + let some idx := env.getModuleIdxFor? c | continue | |
| 61 | + unless proj mods[idx.toNat]! do continue | |
| 62 | + if isAux c then continue | |
| 63 | + let (th, st1) := (exprHash env ci.type).run st | |
| 64 | + st := st1 | |
| 65 | + let mut v := "-" | |
| 66 | + match ci with | |
| 67 | + | .defnInfo d => let (vh, st2) := (exprHash env d.value).run st; st := st2; v := toString vh | |
| 68 | + | .opaqueInfo d => let (vh, st2) := (exprHash env d.value).run st; st := st2; v := toString vh | |
| 69 | + | _ => pure () | |
| 70 | + let kind := match ci with | |
| 71 | + | .thmInfo _ => "theorem" | .defnInfo _ => "def" | .axiomInfo _ => "axiom" | .opaqueInfo _ => "opaque" | |
| 72 | + | .inductInfo _ => "inductive" | .ctorInfo _ => "ctor" | .recInfo _ => "rec" | .quotInfo _ => "quot" | |
| 73 | + h.putStrLn s!"{c}\t{kind}\t{th}\t{v}" | |
| 74 | + n := n + 1 | |
| 75 | + IO.println s!"{n} named constants written" | |
+12 −0 docs/s5-folding/README.md View file
| @@ -101,3 +101,15 @@ Each pull request of the series keeps its plan in its route notes (`routes/<bran | ||
| 101 | 101 | ## What this does not show |
| 102 | 102 | |
| 103 | 103 | The wall-clock time of a build on your machine; that every file is now in its best shape for reading (P-8 splits the large ones; nothing here grows past 600 lines). |
| 104 | + | |
| 105 | +## Statements, and the series as it was opened | |
| 106 | + | |
| 107 | +The first pull request of the series was cut from a plan of 582 folds. Before the others were opened, main and the folded tree were both built and every named constant of the two libraries was listed with a hash of its type and, for a definition, of its value (`ContentTail.lean`, after one `import` line a module). In that listing an auxiliary constant inside a term (a private declaration, a nested-proof lemma, an automatically named local instance) counts by what it is, not by its name, and a theorem by its statement: a fold changes the names of such constants and nothing else about them. | |
| 108 | + | |
| 109 | +The first plan did not pass. Of 53,802 named constants, 12 differed. In one, `Euler.ComparatorBridge.compactSolenoidalTests_representation`, the word `divergence` resolved to `Euler.divergence` in the folded file and to `EulerSmoothLimit.divergence` on main: once folded, the text saw more names. The build passed all the same. In the others an instance was found by another path (`NormedCommRing ℂ` through the C⋆-algebra instances, `DistribSMul ℝ` through the semiring), or a proof inside the statement differed. | |
| 110 | + | |
| 111 | +Two changes followed. `fold.py` now puts a folded module's imports where its import line stood, so that every other module is loaded in the order it was loaded before (a plan file says which way it was cut, and `check` follows it, so the first pull request still checks). And five files keep their modules: `Euler/CompactProjectedEulerLaw.lean`, `Euler/CylinderJetLpAlgebra.lean`, `Euler/MeanCutoffDifferenceBound.lean`, `NavierStokes/R3/CompactEnergy.lean`, `NavierStokes/R3/PressureRecovery.lean`. | |
| 112 | + | |
| 113 | +The series as opened is 575 folds into 338 files. On it the two listings are equal: 53,802 named constants, none missing, none with another type or value; the first pull request's twelve folds were checked alone and are equal too. The whole tree goes from 54.73 T instructions over 2,587 files to 50.97 T over 2,012 (−6.9%), in place of the figures at the top of this page. | |
| 114 | + | |
| 115 | +What the listing does not show: that two terms with different hashes mean different things (the twelve were read one by one), or anything about proofs, which are not listed. | |
+30 −11 docs/s5-folding/fold.py View file
| @@ -111,11 +111,21 @@ def plan(src, small, cap, skip=()): | ||
| 111 | 111 | return {a: p for a, p in parts.items() if len(p) > 1} |
| 112 | 112 | |
| 113 | 113 | |
| 114 | -def folded(src, host, parts): | |
| 115 | - """the host's new text""" | |
| 114 | +def folded(src, host, parts, inplace=False): | |
| 115 | + """the host's new text. `inplace`: a folded module's import line is replaced, where it stood, by that module's own | |
| 116 | + imports, so that every other module is loaded in the order it was loaded before (Lean breaks ties between instances | |
| 117 | + by that order); otherwise the folded modules' imports come after the host's own.""" | |
| 116 | 118 | head, mods, body = split(src[host]) |
| 117 | - inside = {module(p) for p in parts} | |
| 118 | - new = [m for m in mods if m not in inside] | |
| 119 | + inside = {module(p): p for p in parts[:-1]} | |
| 120 | + if inplace: | |
| 121 | + new = [] | |
| 122 | + def take(ms): | |
| 123 | + for m in ms: | |
| 124 | + if m in inside: take(split(src[inside[m]])[1]) | |
| 125 | + elif m not in new: new.append(m) | |
| 126 | + take(mods) | |
| 127 | + else: | |
| 128 | + new = [m for m in mods if m not in inside] | |
| 119 | 129 | out_parts = [] |
| 120 | 130 | for p in parts[:-1]: |
| 121 | 131 | h, pm, pb = split(src[p]) |
| @@ -141,10 +151,16 @@ def folded(src, host, parts): | ||
| 141 | 151 | return "\n".join(out + body) |
| 142 | 152 | |
| 143 | 153 | |
| 144 | -def apply(tree, pl): | |
| 154 | +def load(path): | |
| 155 | + """(the folds, whether imports go in place) of a plan file; the first plans were a bare table of folds""" | |
| 156 | + d = json.load(open(path)) | |
| 157 | + return (d["folds"], d.get("imports") == "in place") if "folds" in d else (d, False) | |
| 158 | + | |
| 159 | + | |
| 160 | +def apply(tree, pl, inplace=False): | |
| 145 | 161 | src = read_tree(tree) |
| 146 | 162 | for host, parts in pl.items(): |
| 147 | - text = folded(src, host, parts) | |
| 163 | + text = folded(src, host, parts, inplace) | |
| 148 | 164 | # every line of every folded file and of the host is still there (imports aside) |
| 149 | 165 | want = collections.Counter(l for p in parts for l in (lambda s: s[0] + s[2])(split(src[p])) if l.strip()) |
| 150 | 166 | have = collections.Counter(l for l in text.split("\n") if l.strip() and not IMPORT.match(l)) |
| @@ -153,12 +169,12 @@ def apply(tree, pl): | ||
| 153 | 169 | for p in parts[:-1]: os.remove(os.path.join(tree, p)) |
| 154 | 170 | |
| 155 | 171 | |
| 156 | -def check(repo, pl, rev): | |
| 172 | +def check(repo, pl, rev, inplace=False): | |
| 157 | 173 | """the working tree against what `apply` makes of the revision's text: every changed file, byte for byte""" |
| 158 | 174 | show = lambda f: subprocess.run(["git", "-C", repo, "show", f"{rev}:{f}"], capture_output=True, text=True, check=True).stdout |
| 159 | 175 | bad = [] |
| 160 | 176 | for host, parts in pl.items(): |
| 161 | - want = folded({p: show(p) for p in parts}, host, parts) | |
| 177 | + want = folded({p: show(p) for p in parts}, host, parts, inplace) | |
| 162 | 178 | path = os.path.join(repo, host) |
| 163 | 179 | if not os.path.exists(path) or open(path, encoding="utf-8").read() != want: bad.append(f"{host} is not {rev}'s text folded") |
| 164 | 180 | bad += [f"{p} is still there" for p in parts[:-1] if os.path.exists(os.path.join(repo, p))] |
| @@ -178,6 +194,9 @@ def self_test(): | ||
| 178 | 194 | assert t.startswith("import Mathlib.X\nimport Euler.Bar\nimport Mathlib.Y\n\n/-! # A -/\n"), t |
| 179 | 195 | assert "end Euler.B\nend\n\nend\n" in t and t.index("theorem c") < t.index("theorem b") < t.index("theorem a"), t |
| 180 | 196 | assert unclosed(src["Euler/FooB.lean"].split("\n")) == [("section", ""), ("namespace", "Euler.B")] |
| 197 | + t2 = folded(src, "Euler/FooA.lean", pl["Euler/FooA.lean"], inplace=True) | |
| 198 | + assert t2.startswith("import Mathlib.X\nimport Mathlib.Y\nimport Euler.Bar\n\n/-! # A -/\n"), t2 | |
| 199 | + assert t2.split("\n\n", 1)[1] == t.split("\n\n", 1)[1] | |
| 181 | 200 | assert plan(src, 100, 1000, skip={"Euler/FooB.lean"}) == {} |
| 182 | 201 | assert plan(src, 2, 1000) == {}, plan(src, 2, 1000) |
| 183 | 202 | print("ok") |
| @@ -191,10 +210,10 @@ if __name__ == "__main__": | ||
| 191 | 210 | src = read_tree(a[1]) |
| 192 | 211 | skip = set(open(opt("--skip", "")).read().split()) if "--skip" in a else set() |
| 193 | 212 | pl = plan(src, int(opt("--small", 200)), int(opt("--cap", 600)), skip) |
| 194 | - json.dump(pl, open(a[2], "w"), indent=0) | |
| 213 | + json.dump({"imports": "in place", "folds": pl}, open(a[2], "w"), indent=0) | |
| 195 | 214 | n = sum(len(p) - 1 for p in pl.values()) |
| 196 | 215 | print(f"folds: {n} modules into {len(pl)} files in {len({fam(h) for h in pl})} families; largest file after: {max((sum(src[p].count(chr(10)) for p in ps), h) for h, ps in pl.items()) if pl else None}") |
| 197 | 216 | elif a[0] == "check": |
| 198 | - sys.exit(check(a[1], json.load(open(a[2])), a[3] if len(a) > 3 else "origin/main")) | |
| 217 | + pl, inplace = load(a[2]); sys.exit(check(a[1], pl, a[3] if len(a) > 3 else "origin/main", inplace)) | |
| 199 | 218 | elif a[0] == "apply": |
| 200 | - pl = json.load(open(a[2])); apply(a[1], pl); print("applied", sum(len(p) - 1 for p in pl.values()), "folds") | |
| 219 | + pl, inplace = load(a[2]); apply(a[1], pl, inplace); print("applied", sum(len(p) - 1 for p in pl.values()), "folds") | |
+13 −0 routes/s5-euler-linear-1/README.md added View file
| @@ -0,0 +1,13 @@ | ||
| 1 | +--- | |
| 2 | +issue: 14 | |
| 3 | +status: working | |
| 4 | +--- | |
| 5 | +# s5-euler-linear-1 | |
| 6 | + | |
| 7 | +One unit of #14 (S-5, Lean Pool's "fewer modules"): the family `Euler/Linear*`. `Euler/LinearDuhamelFrozenOperator.lean` (77 lines) and `Euler/LinearDuhamelFrozenGevrey.lean` (98 lines) had exactly one importer, `Euler/LinearDuhamelSobolevGevrey.lean`, so they are folded into it with their text unchanged, under a heading that names each file and in a `section` of its own, before the file's own text. The plan is `plan.json` here; `python3 -I docs/s5-folding/fold.py check . routes/s5-euler-linear-1/plan.json` makes the changed file again from `origin/main`'s text and compares byte for byte. | |
| 8 | + | |
| 9 | +Folded, `Euler/LinearDuhamelSobolevGevrey.lean` is 298 lines and goes from 44.84 G to 32.23 G instructions (−28.1%), measured as `unit.json` in the unit and PR.md describe. Read top to bottom, the file reads as three parts in order: the two folded modules' text, then the file's own forward estimate; nothing reads worse folded than the three files did apart. | |
| 10 | + | |
| 11 | +## Next | |
| 12 | + | |
| 13 | +The pull request is open. What comes next is the maintainer's verdict on whether this kind of change is wanted; the rest of the series' families wait on it, one family per pull request. | |
+10 −0 routes/s5-euler-linear-1/plan.json added View file
| @@ -0,0 +1,10 @@ | ||
| 1 | +{ | |
| 2 | +"imports": "in place", | |
| 3 | +"folds": { | |
| 4 | +"Euler/LinearDuhamelSobolevGevrey.lean": [ | |
| 5 | +"Euler/LinearDuhamelFrozenOperator.lean", | |
| 6 | +"Euler/LinearDuhamelFrozenGevrey.lean", | |
| 7 | +"Euler/LinearDuhamelSobolevGevrey.lean" | |
| 8 | +] | |
| 9 | +} | |
| 10 | +} | |