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/Coefficient): 2 small modules folded into the file that imports them (−22.3%, measured) #669
Merged
+0 −98 Euler/CoefficientPathBounds.lean deleted
| @@ -1,98 +0,0 @@ | ||
| 1 | -import Euler.CoefficientPathSmooth | |
| 2 | -import Euler.ParameterSobolevCoefficient | |
| 3 | -import Euler.H6Pressure | |
| 4 | - | |
| 5 | -/-! | |
| 6 | -The bounds stored in the actual recursive coefficient jet are controlled | |
| 7 | -by the true word derivatives of its bounded-field translation orbit. A | |
| 8 | -single enlargement of the coefficient radius gives fixed-base Sobolev | |
| 9 | -bounds, independent of the jet truncation. | |
| 10 | --/ | |
| 11 | - | |
| 12 | -noncomputable section | |
| 13 | - | |
| 14 | -namespace EulerCoefficientPath | |
| 15 | - | |
| 16 | -open Set Finset ContinuousLinearMap EulerSmoothLimit EulerLiftedGradientSpace | |
| 17 | - EulerMeanCoefficients EulerMetricTransport EulerTransportDerivatives | |
| 18 | - EulerSpatialSobolevInverse EulerCylinderSobolev EulerJetProductBounds | |
| 19 | - EulerParameterWordGevrey EulerGevrey | |
| 20 | -open scoped ContDiff BoundedContinuousFunction | |
| 21 | - | |
| 22 | -variable {K : Type*} [TopologicalSpace K] [CompactSpace K] | |
| 23 | - | |
| 24 | -def coefficientDirections (i : Fin 4) : Space := (standardDirection i).1 | |
| 25 | - | |
| 26 | -theorem coefficientDirections_norm (i : Fin 4) : ‖coefficientDirections i‖ ≤ 1 := by | |
| 27 | - cases i using Fin.cases <;> simp [coefficientDirections] | |
| 28 | - | |
| 29 | -omit [CompactSpace K] in | |
| 30 | -theorem translateCoefficientPath_zero {V : Type*} [NormedAddCommGroup V] [NormedSpace ℝ V] | |
| 31 | - (A : C(K,Space →ᵇ V)) : translateCoefficientPath A 0 = A := by | |
| 32 | - apply ContinuousMap.ext | |
| 33 | - intro t | |
| 34 | - apply BoundedContinuousFunction.ext | |
| 35 | - intro x | |
| 36 | - change A t (x+0) = A t x | |
| 37 | - rw [add_zero] | |
| 38 | - | |
| 39 | -private local instance : NormedAddCommGroup (Space →L[ℝ] Space) := inferInstance | |
| 40 | -private local instance : NormedSpace ℝ (Space →L[ℝ] Space) := inferInstance | |
| 41 | -private local instance : NormedAddCommGroup (Space →ᵇ Space →L[ℝ] Space) := inferInstance | |
| 42 | -private local instance : NormedSpace ℝ (Space →ᵇ Space →L[ℝ] Space) := inferInstance | |
| 43 | - | |
| 44 | -variable (P : ℝ) [Fact (0 < P)] | |
| 45 | - (A : C(K,Space →ᵇ Space →L[ℝ] Space)) | |
| 46 | - (hA : ContDiff ℝ ∞ (translateCoefficientPath A)) | |
| 47 | - | |
| 48 | -theorem coefficientJet_boundLevel_le_words (s n : ℕ) (t : K) : | |
| 49 | - boundLevel P (coefficientJet P A hA s t) n ≤ | |
| 50 | - wordSum coefficientDirections (translateCoefficientPath A) n 0 := by | |
| 51 | - induction s generalizing A n with | |
| 52 | - | zero => | |
| 53 | - cases n with | |
| 54 | - | zero => | |
| 55 | - rw [wordSum_zero,translateCoefficientPath_zero] | |
| 56 | - simp only [coefficientJet,boundLevel] | |
| 57 | - exact A.norm_coe_le_norm t | |
| 58 | - | succ n => | |
| 59 | - simp only [coefficientJet,boundLevel] | |
| 60 | - exact wordSum_nonneg _ _ _ _ | |
| 61 | - | succ s ih => | |
| 62 | - cases n with | |
| 63 | - | zero => | |
| 64 | - rw [wordSum_zero,translateCoefficientPath_zero] | |
| 65 | - simp only [coefficientJet,boundLevel] | |
| 66 | - exact A.norm_coe_le_norm t | |
| 67 | - | succ n => | |
| 68 | - rw [wordSum_succ coefficientDirections (translateCoefficientPath A) hA n 0] | |
| 69 | - rw [coefficientJet, boundLevel.eq_def] | |
| 70 | - apply sum_le_sum | |
| 71 | - intro i _ | |
| 72 | - have hh := ih (orbitDerivativePath A (coefficientDirections i)) | |
| 73 | - (orbitDerivativePath_orbit A hA (coefficientDirections i)) n | |
| 74 | - have he : translateCoefficientPath (orbitDerivativePath A (coefficientDirections i)) = | |
| 75 | - directional coefficientDirections (translateCoefficientPath A) i := | |
| 76 | - funext (orbitDerivativePath_translation A hA (coefficientDirections i)) | |
| 77 | - rw [he] at hh | |
| 78 | - exact hh | |
| 79 | - | |
| 80 | -theorem coefficientJet_block_le_words (s q n : ℕ) (t : K) : | |
| 81 | - EulerH6Pressure.coefficientBlock P (coefficientJet P A hA s t) q n ≤ | |
| 82 | - EulerParameterWordGevrey.coefficientBlock coefficientDirections q (translateCoefficientPath A) n 0 := by | |
| 83 | - change (2 : ℝ)^q*(∑ r ∈ range (q+1),boundLevel P (coefficientJet P A hA s t) (n+r)) ≤ | |
| 84 | - (2 : ℝ)^q*block coefficientDirections q (translateCoefficientPath A) n 0 | |
| 85 | - rw [block_eq_sum_levels coefficientDirections q (translateCoefficientPath A) hA n 0] | |
| 86 | - exact mul_le_mul_of_nonneg_left | |
| 87 | - (sum_le_sum (fun r _ => coefficientJet_boundLevel_le_words P A hA s (n+r) t)) (by positivity) | |
| 88 | - | |
| 89 | -theorem coefficientJet_block_bound (s q : ℕ) (Rc C : ℝ) (hRc : 0 ≤ Rc) (hC : 0 ≤ C) | |
| 90 | - (hb : ∀ n x, ‖iteratedFDeriv ℝ n (translateCoefficientPath A) x‖ ≤ C*majorant Rc 0 n) | |
| 91 | - (n : ℕ) (t : K) : | |
| 92 | - EulerH6Pressure.coefficientBlock P (coefficientJet P A hA s t) q n ≤ | |
| 93 | - sobolevCoefficientAmplitude (Fin 4) q Rc C * majorant (sobolevCoefficientRadius (Fin 4) Rc) 0 n := | |
| 94 | - (coefficientJet_block_le_words P A hA s q n t).trans | |
| 95 | - (coefficientBlock_of_tensor_bound coefficientDirections coefficientDirections_norm q | |
| 96 | - (translateCoefficientPath A) hA Rc C hRc hC hb n 0) | |
| 97 | - | |
| 98 | -end EulerCoefficientPath | |
+203 −1 Euler/CoefficientPathPressureBounds.lean View file
| @@ -1,10 +1,212 @@ | ||
| 1 | -import Euler.CoefficientPathWeightedBounds | |
| 1 | +import Euler.CoefficientPathSmooth | |
| 2 | +import Euler.ParameterSobolevCoefficient | |
| 3 | +import Euler.H6Pressure | |
| 4 | +import Euler.SobolevGevreyOperators | |
| 5 | +import Euler.PacketTailBound | |
| 2 | 6 | import Euler.CoefficientJetPressureBounds |
| 3 | 7 | import Euler.H6PressureConstants |
| 4 | 8 | |
| 5 | 9 | /-! Actual coefficient-orbit bounds control the fixed H5/H6 pressure |
| 6 | 10 | constants uniformly over all higher jet truncations. -/ |
| 7 | 11 | |
| 12 | +/-! ## From `Euler/CoefficientPathBounds.lean` | |
| 13 | + | |
| 14 | +The text of `Euler/CoefficientPathBounds.lean`, folded into this file, which was its only importer. -/ | |
| 15 | + | |
| 16 | +section | |
| 17 | + | |
| 18 | +/-! | |
| 19 | +The bounds stored in the actual recursive coefficient jet are controlled | |
| 20 | +by the true word derivatives of its bounded-field translation orbit. A | |
| 21 | +single enlargement of the coefficient radius gives fixed-base Sobolev | |
| 22 | +bounds, independent of the jet truncation. | |
| 23 | +-/ | |
| 24 | + | |
| 25 | +noncomputable section | |
| 26 | + | |
| 27 | +namespace EulerCoefficientPath | |
| 28 | + | |
| 29 | +open Set Finset ContinuousLinearMap EulerSmoothLimit EulerLiftedGradientSpace | |
| 30 | + EulerMeanCoefficients EulerMetricTransport EulerTransportDerivatives | |
| 31 | + EulerSpatialSobolevInverse EulerCylinderSobolev EulerJetProductBounds | |
| 32 | + EulerParameterWordGevrey EulerGevrey | |
| 33 | +open scoped ContDiff BoundedContinuousFunction | |
| 34 | + | |
| 35 | +variable {K : Type*} [TopologicalSpace K] [CompactSpace K] | |
| 36 | + | |
| 37 | +def coefficientDirections (i : Fin 4) : Space := (standardDirection i).1 | |
| 38 | + | |
| 39 | +theorem coefficientDirections_norm (i : Fin 4) : ‖coefficientDirections i‖ ≤ 1 := by | |
| 40 | + cases i using Fin.cases <;> simp [coefficientDirections] | |
| 41 | + | |
| 42 | +omit [CompactSpace K] in | |
| 43 | +theorem translateCoefficientPath_zero {V : Type*} [NormedAddCommGroup V] [NormedSpace ℝ V] | |
| 44 | + (A : C(K,Space →ᵇ V)) : translateCoefficientPath A 0 = A := by | |
| 45 | + apply ContinuousMap.ext | |
| 46 | + intro t | |
| 47 | + apply BoundedContinuousFunction.ext | |
| 48 | + intro x | |
| 49 | + change A t (x+0) = A t x | |
| 50 | + rw [add_zero] | |
| 51 | + | |
| 52 | +private local instance : NormedAddCommGroup (Space →L[ℝ] Space) := inferInstance | |
| 53 | +private local instance : NormedSpace ℝ (Space →L[ℝ] Space) := inferInstance | |
| 54 | +private local instance : NormedAddCommGroup (Space →ᵇ Space →L[ℝ] Space) := inferInstance | |
| 55 | +private local instance : NormedSpace ℝ (Space →ᵇ Space →L[ℝ] Space) := inferInstance | |
| 56 | + | |
| 57 | +variable (P : ℝ) [Fact (0 < P)] | |
| 58 | + (A : C(K,Space →ᵇ Space →L[ℝ] Space)) | |
| 59 | + (hA : ContDiff ℝ ∞ (translateCoefficientPath A)) | |
| 60 | + | |
| 61 | +theorem coefficientJet_boundLevel_le_words (s n : ℕ) (t : K) : | |
| 62 | + boundLevel P (coefficientJet P A hA s t) n ≤ | |
| 63 | + wordSum coefficientDirections (translateCoefficientPath A) n 0 := by | |
| 64 | + induction s generalizing A n with | |
| 65 | + | zero => | |
| 66 | + cases n with | |
| 67 | + | zero => | |
| 68 | + rw [wordSum_zero,translateCoefficientPath_zero] | |
| 69 | + simp only [coefficientJet,boundLevel] | |
| 70 | + exact A.norm_coe_le_norm t | |
| 71 | + | succ n => | |
| 72 | + simp only [coefficientJet,boundLevel] | |
| 73 | + exact wordSum_nonneg _ _ _ _ | |
| 74 | + | succ s ih => | |
| 75 | + cases n with | |
| 76 | + | zero => | |
| 77 | + rw [wordSum_zero,translateCoefficientPath_zero] | |
| 78 | + simp only [coefficientJet,boundLevel] | |
| 79 | + exact A.norm_coe_le_norm t | |
| 80 | + | succ n => | |
| 81 | + rw [wordSum_succ coefficientDirections (translateCoefficientPath A) hA n 0] | |
| 82 | + rw [coefficientJet, boundLevel.eq_def] | |
| 83 | + apply sum_le_sum | |
| 84 | + intro i _ | |
| 85 | + have hh := ih (orbitDerivativePath A (coefficientDirections i)) | |
| 86 | + (orbitDerivativePath_orbit A hA (coefficientDirections i)) n | |
| 87 | + have he : translateCoefficientPath (orbitDerivativePath A (coefficientDirections i)) = | |
| 88 | + directional coefficientDirections (translateCoefficientPath A) i := | |
| 89 | + funext (orbitDerivativePath_translation A hA (coefficientDirections i)) | |
| 90 | + rw [he] at hh | |
| 91 | + exact hh | |
| 92 | + | |
| 93 | +theorem coefficientJet_block_le_words (s q n : ℕ) (t : K) : | |
| 94 | + EulerH6Pressure.coefficientBlock P (coefficientJet P A hA s t) q n ≤ | |
| 95 | + EulerParameterWordGevrey.coefficientBlock coefficientDirections q (translateCoefficientPath A) n 0 := by | |
| 96 | + change (2 : ℝ)^q*(∑ r ∈ range (q+1),boundLevel P (coefficientJet P A hA s t) (n+r)) ≤ | |
| 97 | + (2 : ℝ)^q*block coefficientDirections q (translateCoefficientPath A) n 0 | |
| 98 | + rw [block_eq_sum_levels coefficientDirections q (translateCoefficientPath A) hA n 0] | |
| 99 | + exact mul_le_mul_of_nonneg_left | |
| 100 | + (sum_le_sum (fun r _ => coefficientJet_boundLevel_le_words P A hA s (n+r) t)) (by positivity) | |
| 101 | + | |
| 102 | +theorem coefficientJet_block_bound (s q : ℕ) (Rc C : ℝ) (hRc : 0 ≤ Rc) (hC : 0 ≤ C) | |
| 103 | + (hb : ∀ n x, ‖iteratedFDeriv ℝ n (translateCoefficientPath A) x‖ ≤ C*majorant Rc 0 n) | |
| 104 | + (n : ℕ) (t : K) : | |
| 105 | + EulerH6Pressure.coefficientBlock P (coefficientJet P A hA s t) q n ≤ | |
| 106 | + sobolevCoefficientAmplitude (Fin 4) q Rc C * majorant (sobolevCoefficientRadius (Fin 4) Rc) 0 n := | |
| 107 | + (coefficientJet_block_le_words P A hA s q n t).trans | |
| 108 | + (coefficientBlock_of_tensor_bound coefficientDirections coefficientDirections_norm q | |
| 109 | + (translateCoefficientPath A) hA Rc C hRc hC hb n 0) | |
| 110 | + | |
| 111 | +end EulerCoefficientPath | |
| 112 | +end | |
| 113 | + | |
| 114 | +end | |
| 115 | + | |
| 116 | +/-! ## From `Euler/CoefficientPathWeightedBounds.lean` | |
| 117 | + | |
| 118 | +The text of `Euler/CoefficientPathWeightedBounds.lean`, folded into this file, which was its only importer. -/ | |
| 119 | + | |
| 120 | +section | |
| 121 | + | |
| 122 | +/-! | |
| 123 | +Cutoff-independent weighted estimates for the actual coefficient jets. | |
| 124 | +The positive-order coefficient normalization is paid once by a fixed | |
| 125 | +coefficient radius, independent of the solution amplitude and grade. | |
| 126 | +-/ | |
| 127 | + | |
| 128 | +noncomputable section | |
| 129 | + | |
| 130 | +namespace EulerCoefficientPath | |
| 131 | + | |
| 132 | +open Set Finset ContinuousLinearMap EulerSmoothLimit EulerLiftedGradientSpace | |
| 133 | + EulerMeanCoefficients EulerSpatialSobolevInverse EulerJetProductBounds | |
| 134 | + EulerParameterWordGevrey EulerGevrey EulerPacketWeights EulerSobolevGevreyOperators | |
| 135 | + EulerPacketTailBound EulerOperatorGevreyCalculus | |
| 136 | +open scoped ContDiff BoundedContinuousFunction | |
| 137 | + | |
| 138 | +def normalizedCoefficientRadius (q : ℕ) (Rc C : ℝ) : ℝ := | |
| 139 | + max 1 (sobolevCoefficientAmplitude (Fin 4) q Rc C) * sobolevCoefficientRadius (Fin 4) Rc | |
| 140 | + | |
| 141 | +theorem normalizedCoefficientRadius_nonneg (q : ℕ) (Rc C : ℝ) (hRc : 0 ≤ Rc) : | |
| 142 | + 0 ≤ normalizedCoefficientRadius q Rc C := | |
| 143 | + mul_nonneg (le_trans zero_le_one (le_max_left _ _)) (sobolevCoefficientRadius_nonneg Rc hRc) | |
| 144 | + | |
| 145 | +theorem amplitude_majorant_le_normalized (q : ℕ) (Rc C : ℝ) (hRc : 0 ≤ Rc) | |
| 146 | + (n : ℕ) (hn : 1 ≤ n) : | |
| 147 | + sobolevCoefficientAmplitude (Fin 4) q Rc C * majorant (sobolevCoefficientRadius (Fin 4) Rc) 0 n ≤ | |
| 148 | + majorant (normalizedCoefficientRadius q Rc C) 0 n := by | |
| 149 | + have hp : sobolevCoefficientAmplitude (Fin 4) q Rc C ≤ | |
| 150 | + (max 1 (sobolevCoefficientAmplitude (Fin 4) q Rc C))^n := | |
| 151 | + (le_max_right _ _).trans (by | |
| 152 | + simpa only [pow_one] using pow_le_pow_right₀ | |
| 153 | + (le_max_left (1 : ℝ) (sobolevCoefficientAmplitude (Fin 4) q Rc C)) hn) | |
| 154 | + calc | |
| 155 | + _ ≤ (max 1 (sobolevCoefficientAmplitude (Fin 4) q Rc C))^n * | |
| 156 | + majorant (sobolevCoefficientRadius (Fin 4) Rc) 0 n := | |
| 157 | + mul_le_mul_of_nonneg_right hp (majorant_nonneg _ (sobolevCoefficientRadius_nonneg Rc hRc) 0 n) | |
| 158 | + _ = _ := by simp only [majorant,normalizedCoefficientRadius,Nat.add_zero,mul_pow]; ring | |
| 159 | + | |
| 160 | +variable {K : Type*} [TopologicalSpace K] [CompactSpace K] | |
| 161 | + (P : ℝ) [Fact (0 < P)] | |
| 162 | + (A : C(K,Space →ᵇ Space →L[ℝ] Space)) | |
| 163 | + (hA : ContDiff ℝ ∞ (translateCoefficientPath A)) | |
| 164 | + | |
| 165 | +theorem coefficientJet_block_normalized (s q : ℕ) (Rc C : ℝ) (hRc : 0 ≤ Rc) (hC : 0 ≤ C) | |
| 166 | + (hb : ∀ n x, ‖iteratedFDeriv ℝ n (translateCoefficientPath A) x‖ ≤ C*majorant Rc 0 n) | |
| 167 | + (R : ℝ) (hR : normalizedCoefficientRadius q Rc C ≤ R) | |
| 168 | + (n : ℕ) (hn : 1 ≤ n) (t : K) : | |
| 169 | + EulerH6Pressure.coefficientBlock P (coefficientJet P A hA s t) q n ≤ | |
| 170 | + R^n*(n.factorial : ℝ)^2 := by | |
| 171 | + have h := (coefficientJet_block_bound P A hA s q Rc C hRc hC hb n t).trans | |
| 172 | + (amplitude_majorant_le_normalized q Rc C hRc n hn) | |
| 173 | + exact h.trans (majorant_radius_mono _ R (normalizedCoefficientRadius_nonneg q Rc C hRc) hR 0 n) | |
| 174 | + | |
| 175 | +private theorem weight_majorant_zero (ρ R : ℝ) (n : ℕ) : | |
| 176 | + weight ρ n*majorant R 0 n = (ρ*R)^n := by | |
| 177 | + unfold weight majorant | |
| 178 | + simp only [Nat.add_zero,mul_pow] | |
| 179 | + field_simp [factorial_cast_ne_zero n] | |
| 180 | + | |
| 181 | +theorem coefficientJet_weighted_bound (s q N : ℕ) (Rc C : ℝ) (hRc : 0 ≤ Rc) (hC : 0 ≤ C) | |
| 182 | + (hb : ∀ n x, ‖iteratedFDeriv ℝ n (translateCoefficientPath A) x‖ ≤ C*majorant Rc 0 n) | |
| 183 | + (ρ : ℝ) (hρ : 0 < ρ) (hsmall : ρ*sobolevCoefficientRadius (Fin 4) Rc ≤ 1/2) (t : K) : | |
| 184 | + weightedCoefficient P (coefficientJet P A hA s t) q N ρ ≤ | |
| 185 | + 2*sobolevCoefficientAmplitude (Fin 4) q Rc C := by | |
| 186 | + have hB := sobolevCoefficientAmplitude_nonneg (ι := Fin 4) q Rc C hRc hC | |
| 187 | + calc | |
| 188 | + _ ≤ ∑ n ∈ range (N+1), weight ρ n * | |
| 189 | + (sobolevCoefficientAmplitude (Fin 4) q Rc C * majorant (sobolevCoefficientRadius (Fin 4) Rc) 0 n) := by | |
| 190 | + apply sum_le_sum | |
| 191 | + intro n _ | |
| 192 | + exact mul_le_mul_of_nonneg_left (coefficientJet_block_bound P A hA s q Rc C hRc hC hb n t) | |
| 193 | + (weight_pos hρ n).le | |
| 194 | + _ = sobolevCoefficientAmplitude (Fin 4) q Rc C * | |
| 195 | + ∑ n ∈ range (N+1), (ρ*sobolevCoefficientRadius (Fin 4) Rc)^n := by | |
| 196 | + rw [mul_sum] | |
| 197 | + apply sum_congr rfl | |
| 198 | + intro n _ | |
| 199 | + rw [← weight_majorant_zero ρ (sobolevCoefficientRadius (Fin 4) Rc) n] | |
| 200 | + ring | |
| 201 | + _ ≤ _ := (mul_le_mul_of_nonneg_left | |
| 202 | + (sum_geometric_le_two _ (mul_nonneg hρ.le (sobolevCoefficientRadius_nonneg Rc hRc)) hsmall (N+1)) | |
| 203 | + hB).trans_eq (mul_comm _ _) | |
| 204 | + | |
| 205 | +end EulerCoefficientPath | |
| 206 | +end | |
| 207 | + | |
| 208 | +end | |
| 209 | + | |
| 8 | 210 | noncomputable section |
| 9 | 211 | |
| 10 | 212 | namespace EulerCoefficientPath |
+0 −88 Euler/CoefficientPathWeightedBounds.lean deleted
| @@ -1,88 +0,0 @@ | ||
| 1 | -import Euler.CoefficientPathBounds | |
| 2 | -import Euler.SobolevGevreyOperators | |
| 3 | -import Euler.PacketTailBound | |
| 4 | - | |
| 5 | -/-! | |
| 6 | -Cutoff-independent weighted estimates for the actual coefficient jets. | |
| 7 | -The positive-order coefficient normalization is paid once by a fixed | |
| 8 | -coefficient radius, independent of the solution amplitude and grade. | |
| 9 | --/ | |
| 10 | - | |
| 11 | -noncomputable section | |
| 12 | - | |
| 13 | -namespace EulerCoefficientPath | |
| 14 | - | |
| 15 | -open Set Finset ContinuousLinearMap EulerSmoothLimit EulerLiftedGradientSpace | |
| 16 | - EulerMeanCoefficients EulerSpatialSobolevInverse EulerJetProductBounds | |
| 17 | - EulerParameterWordGevrey EulerGevrey EulerPacketWeights EulerSobolevGevreyOperators | |
| 18 | - EulerPacketTailBound EulerOperatorGevreyCalculus | |
| 19 | -open scoped ContDiff BoundedContinuousFunction | |
| 20 | - | |
| 21 | -def normalizedCoefficientRadius (q : ℕ) (Rc C : ℝ) : ℝ := | |
| 22 | - max 1 (sobolevCoefficientAmplitude (Fin 4) q Rc C) * sobolevCoefficientRadius (Fin 4) Rc | |
| 23 | - | |
| 24 | -theorem normalizedCoefficientRadius_nonneg (q : ℕ) (Rc C : ℝ) (hRc : 0 ≤ Rc) : | |
| 25 | - 0 ≤ normalizedCoefficientRadius q Rc C := | |
| 26 | - mul_nonneg (le_trans zero_le_one (le_max_left _ _)) (sobolevCoefficientRadius_nonneg Rc hRc) | |
| 27 | - | |
| 28 | -theorem amplitude_majorant_le_normalized (q : ℕ) (Rc C : ℝ) (hRc : 0 ≤ Rc) | |
| 29 | - (n : ℕ) (hn : 1 ≤ n) : | |
| 30 | - sobolevCoefficientAmplitude (Fin 4) q Rc C * majorant (sobolevCoefficientRadius (Fin 4) Rc) 0 n ≤ | |
| 31 | - majorant (normalizedCoefficientRadius q Rc C) 0 n := by | |
| 32 | - have hp : sobolevCoefficientAmplitude (Fin 4) q Rc C ≤ | |
| 33 | - (max 1 (sobolevCoefficientAmplitude (Fin 4) q Rc C))^n := | |
| 34 | - (le_max_right _ _).trans (by | |
| 35 | - simpa only [pow_one] using pow_le_pow_right₀ | |
| 36 | - (le_max_left (1 : ℝ) (sobolevCoefficientAmplitude (Fin 4) q Rc C)) hn) | |
| 37 | - calc | |
| 38 | - _ ≤ (max 1 (sobolevCoefficientAmplitude (Fin 4) q Rc C))^n * | |
| 39 | - majorant (sobolevCoefficientRadius (Fin 4) Rc) 0 n := | |
| 40 | - mul_le_mul_of_nonneg_right hp (majorant_nonneg _ (sobolevCoefficientRadius_nonneg Rc hRc) 0 n) | |
| 41 | - _ = _ := by simp only [majorant,normalizedCoefficientRadius,Nat.add_zero,mul_pow]; ring | |
| 42 | - | |
| 43 | -variable {K : Type*} [TopologicalSpace K] [CompactSpace K] | |
| 44 | - (P : ℝ) [Fact (0 < P)] | |
| 45 | - (A : C(K,Space →ᵇ Space →L[ℝ] Space)) | |
| 46 | - (hA : ContDiff ℝ ∞ (translateCoefficientPath A)) | |
| 47 | - | |
| 48 | -theorem coefficientJet_block_normalized (s q : ℕ) (Rc C : ℝ) (hRc : 0 ≤ Rc) (hC : 0 ≤ C) | |
| 49 | - (hb : ∀ n x, ‖iteratedFDeriv ℝ n (translateCoefficientPath A) x‖ ≤ C*majorant Rc 0 n) | |
| 50 | - (R : ℝ) (hR : normalizedCoefficientRadius q Rc C ≤ R) | |
| 51 | - (n : ℕ) (hn : 1 ≤ n) (t : K) : | |
| 52 | - EulerH6Pressure.coefficientBlock P (coefficientJet P A hA s t) q n ≤ | |
| 53 | - R^n*(n.factorial : ℝ)^2 := by | |
| 54 | - have h := (coefficientJet_block_bound P A hA s q Rc C hRc hC hb n t).trans | |
| 55 | - (amplitude_majorant_le_normalized q Rc C hRc n hn) | |
| 56 | - exact h.trans (majorant_radius_mono _ R (normalizedCoefficientRadius_nonneg q Rc C hRc) hR 0 n) | |
| 57 | - | |
| 58 | -private theorem weight_majorant_zero (ρ R : ℝ) (n : ℕ) : | |
| 59 | - weight ρ n*majorant R 0 n = (ρ*R)^n := by | |
| 60 | - unfold weight majorant | |
| 61 | - simp only [Nat.add_zero,mul_pow] | |
| 62 | - field_simp [factorial_cast_ne_zero n] | |
| 63 | - | |
| 64 | -theorem coefficientJet_weighted_bound (s q N : ℕ) (Rc C : ℝ) (hRc : 0 ≤ Rc) (hC : 0 ≤ C) | |
| 65 | - (hb : ∀ n x, ‖iteratedFDeriv ℝ n (translateCoefficientPath A) x‖ ≤ C*majorant Rc 0 n) | |
| 66 | - (ρ : ℝ) (hρ : 0 < ρ) (hsmall : ρ*sobolevCoefficientRadius (Fin 4) Rc ≤ 1/2) (t : K) : | |
| 67 | - weightedCoefficient P (coefficientJet P A hA s t) q N ρ ≤ | |
| 68 | - 2*sobolevCoefficientAmplitude (Fin 4) q Rc C := by | |
| 69 | - have hB := sobolevCoefficientAmplitude_nonneg (ι := Fin 4) q Rc C hRc hC | |
| 70 | - calc | |
| 71 | - _ ≤ ∑ n ∈ range (N+1), weight ρ n * | |
| 72 | - (sobolevCoefficientAmplitude (Fin 4) q Rc C * majorant (sobolevCoefficientRadius (Fin 4) Rc) 0 n) := by | |
| 73 | - apply sum_le_sum | |
| 74 | - intro n _ | |
| 75 | - exact mul_le_mul_of_nonneg_left (coefficientJet_block_bound P A hA s q Rc C hRc hC hb n t) | |
| 76 | - (weight_pos hρ n).le | |
| 77 | - _ = sobolevCoefficientAmplitude (Fin 4) q Rc C * | |
| 78 | - ∑ n ∈ range (N+1), (ρ*sobolevCoefficientRadius (Fin 4) Rc)^n := by | |
| 79 | - rw [mul_sum] | |
| 80 | - apply sum_congr rfl | |
| 81 | - intro n _ | |
| 82 | - rw [← weight_majorant_zero ρ (sobolevCoefficientRadius (Fin 4) Rc) n] | |
| 83 | - ring | |
| 84 | - _ ≤ _ := (mul_le_mul_of_nonneg_left | |
| 85 | - (sum_geometric_le_two _ (mul_nonneg hρ.le (sobolevCoefficientRadius_nonneg Rc hRc)) hsmall (N+1)) | |
| 86 | - hB).trans_eq (mul_comm _ _) | |
| 87 | - | |
| 88 | -end EulerCoefficientPath | |
+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") | |
+20 −0 routes/s5-euler-coefficient-1/README.md added View file
| @@ -0,0 +1,20 @@ | ||
| 1 | +--- | |
| 2 | +issue: 14 | |
| 3 | +status: working | |
| 4 | +--- | |
| 5 | +# s5-euler-coefficient-1 | |
| 6 | + | |
| 7 | +The family `Euler/Coefficient*` for S-5 (a change brought over from Lean Pool's cleaned copy: fewer | |
| 8 | +modules, its pull requests 405 and 570). This unit folds the two modules of the family that exactly one | |
| 9 | +file imported — `Euler/CoefficientPathBounds.lean` (98 lines) and | |
| 10 | +`Euler/CoefficientPathWeightedBounds.lean` (88 lines) — into that file, | |
| 11 | +`Euler/CoefficientPathPressureBounds.lean` (260 lines after), text unchanged, each under a heading that | |
| 12 | +names where it came from and in a `section` of its own. No statement, proof or docstring changes; | |
| 13 | +`fold.py check` makes every changed file again from `origin/main`'s text and compares byte for byte, and | |
| 14 | +the plan that did it is `routes/s5-euler-coefficient-1/plan.json`. | |
| 15 | + | |
| 16 | +## Next | |
| 17 | + | |
| 18 | +The pull request is open. What comes next is the maintainer's verdict on whether this kind of change is | |
| 19 | +wanted; the rest of the series' folds wait on it, one family per pull request. Nothing here reads worse | |
| 20 | +folded than the two files did apart. | |
+10 −0 routes/s5-euler-coefficient-1/plan.json added View file
| @@ -0,0 +1,10 @@ | ||
| 1 | +{ | |
| 2 | +"imports": "in place", | |
| 3 | +"folds": { | |
| 4 | +"Euler/CoefficientPathPressureBounds.lean": [ | |
| 5 | +"Euler/CoefficientPathBounds.lean", | |
| 6 | +"Euler/CoefficientPathWeightedBounds.lean", | |
| 7 | +"Euler/CoefficientPathPressureBounds.lean" | |
| 8 | +] | |
| 9 | +} | |
| 10 | +} | |