Download data/lean/OAI/MathematicalPhysics/RapidForcing/Model.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 13.4 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/MathematicalPhysics/RapidForcing/Model.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/MathematicalPhysics/RapidForcing/Model.lean
-
curl -L -o Model.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/MathematicalPhysics/RapidForcing/Model.lean
13.4 kB
| import Mathlib | |
| namespace OAI | |
| open scoped BigOperators ENNReal Topology | |
| open Set MeasureTheory | |
| namespace RapidForcing | |
| abbrev Space := EuclideanSpace β (Fin 3) | |
| abbrev Field (E : Type) := β β Space β E | |
| abbrev MultiIndex := Fin 3 β β | |
| theorem twoAtLeastTwo : Nat.AtLeastTwo 2 := β¨Nat.le_refl 2β© | |
| theorem neZeroThree : NeZero 3 := β¨Nat.succ_ne_zero 2β© | |
| noncomputable def vec (x y z : β) : Space := | |
| letI := twoAtLeastTwo | |
| WithLp.toLp 2 ![x, y, z] | |
| noncomputable def basis (i : Fin 3) : Space := EuclideanSpace.single i 1 | |
| def K : Set Space := | |
| letI := twoAtLeastTwo | |
| letI := neZeroThree | |
| {x | -2 β€ x 0 β§ x 0 β€ 1 β§ | |
| -1 β€ x 1 β§ x 1 β€ 2 β§ -1 β€ x 2 β§ x 2 β€ 1} | |
| noncomputable def spatialD {E : Type} [NormedAddCommGroup E] [NormedSpace β E] | |
| (i : Fin 3) (f : Field E) : Field E := | |
| fun t x => fderiv β (f t) x (basis i) | |
| noncomputable def timeD {E : Type} [NormedAddCommGroup E] [NormedSpace β E] | |
| (f : Field E) : Field E := | |
| fun t x => derivWithin (fun s => f s x) (Ici 0) t | |
| noncomputable def spatialMulti {E : Type} [NormedAddCommGroup E] [NormedSpace β E] | |
| (Ξ± : MultiIndex) (f : Field E) : Field E := | |
| letI := neZeroThree | |
| (spatialD 0)^[Ξ± 0] ((spatialD 1)^[Ξ± 1] ((spatialD 2)^[Ξ± 2] f)) | |
| noncomputable def mixedD {E : Type} [NormedAddCommGroup E] [NormedSpace β E] | |
| (l : β) (Ξ± : MultiIndex) (f : Field E) : Field E := | |
| timeD^[l] (spatialMulti Ξ± f) | |
| def order (Ξ± : MultiIndex) : β := β i, Ξ± i | |
| def Smooth {E : Type} [NormedAddCommGroup E] [NormedSpace β E] (f : Field E) : Prop := | |
| ContDiffOn β (β€ : ββ) (Function.uncurry f) (Ici (0 : β) ΓΛ’ univ) | |
| def Supported {E : Type} [Zero E] (f : Field E) : Prop := | |
| β t : β, 0 β€ t β tsupport (f t) β K | |
| def Rapid {E : Type} [NormedAddCommGroup E] [NormedSpace β E] (f : Field E) : Prop := | |
| β (J l : β) (Ξ± : MultiIndex), β C : β, 0 β€ C β§ | |
| β (t : β), 0 β€ t β β x : Space, | |
| (1 + t) ^ J * βmixedD l Ξ± f t xβ β€ C | |
| def RapidSpaceTime {E : Type} [NormedAddCommGroup E] [NormedSpace β E] | |
| (f : Field E) : Prop := | |
| β (J l : β) (Ξ± : MultiIndex), β C : β, 0 β€ C β§ | |
| β (t : β), 0 β€ t β β x : Space, | |
| (1 + t + βxβ) ^ J * βmixedD l Ξ± f t xβ β€ C | |
| noncomputable def advection (u : Field Space) : Field Space := | |
| fun t x => β i, (u t x i) β’ spatialD i u t x | |
| noncomputable def laplace (u : Field Space) : Field Space := | |
| fun t x => β i, spatialD i (spatialD i u) t x | |
| noncomputable def divergence (u : Field Space) : Field β := | |
| fun t x => β i, (spatialD i u t x) i | |
| noncomputable def gradient (p : Field β) : Field Space := | |
| fun t x => β i, (spatialD i p t x) β’ basis i | |
| noncomputable def residual (Ξ½ : β) (u : Field Space) : Field Space := | |
| fun t x => timeD u t x + advection u t x - Ξ½ β’ laplace u t x | |
| def NavierStokes (Ξ½ : β) (f u : Field Space) (p : Field β) : Prop := | |
| (β (t : β), 0 β€ t β β x : Space, | |
| timeD u t x + advection u t x = | |
| -gradient p t x + Ξ½ β’ laplace u t x + f t x) β§ | |
| (β (t : β), 0 β€ t β β x : Space, divergence u t x = 0) β§ | |
| (β x : Space, u 0 x = 0) | |
| def Classical (u : Field Space) (p : Field β) : Prop := | |
| letI := twoAtLeastTwo | |
| (β t : β, 0 β€ t β ContDiff β 2 (u t) β§ ContDiff β 1 (p t)) β§ | |
| (β x : Space, DifferentiableOn β (fun t => u t x) (Ici 0)) β§ | |
| β T : β, 0 β€ T β | |
| let cylinder := Icc (0 : β) T ΓΛ’ (univ : Set Space) | |
| ContinuousOn (Function.uncurry u) cylinder β§ | |
| ContinuousOn (Function.uncurry (timeD u)) cylinder β§ | |
| (β i, ContinuousOn (Function.uncurry (spatialD i u)) cylinder) β§ | |
| (β i j, ContinuousOn (Function.uncurry (spatialD i (spatialD j u))) cylinder) β§ | |
| ContinuousOn (Function.uncurry p) cylinder β§ | |
| (β i, ContinuousOn (Function.uncurry (spatialD i p)) cylinder) | |
| def L2ContinuousOn {E : Type} [NormedAddCommGroup E] | |
| (f : Field E) (T : β) : Prop := | |
| letI := twoAtLeastTwo | |
| β v : β β Lp E 2 (volume : Measure Space), | |
| ContinuousOn v (Icc 0 T) β§ | |
| β t β Icc 0 T, (v t : Space β E) =α΅[volume] f t | |
| def L2C1On (u : Field Space) (T : β) : Prop := | |
| letI := twoAtLeastTwo | |
| β v v' : β β Lp Space 2 (volume : Measure Space), | |
| ContinuousOn v (Icc 0 T) β§ ContinuousOn v' (Icc 0 T) β§ | |
| (β t β Icc 0 T, (v t : Space β Space) =α΅[volume] u t) β§ | |
| (β t β Icc 0 T, (v' t : Space β Space) =α΅[volume] timeD u t) β§ | |
| β t β Icc 0 T, HasDerivWithinAt v (v' t) (Icc 0 T) t | |
| def EnergyRegularity (u : Field Space) (p : Field β) : Prop := | |
| β T : β, 0 β€ T β | |
| (β Ξ± : MultiIndex, order Ξ± β€ 2 β L2ContinuousOn (spatialMulti Ξ± u) T) β§ | |
| L2C1On u T β§ | |
| (β Ξ± : MultiIndex, order Ξ± β€ 1 β L2ContinuousOn (spatialMulti Ξ± p) T) | |
| def EnergyClass (u : Field Space) (p : Field β) : Prop := | |
| EnergyRegularity u p β§ | |
| β T : β, 0 β€ T β β C : β, β t β Icc 0 T, β x : Space, | |
| βu t xβ + βfderiv β (u t) xβ β€ C | |
| def EnergyCompetitor (u : Field Space) (p : Field β) : Prop := | |
| EnergyRegularity u p β§ | |
| β T : β, 0 β€ T β β C : β, β t β Icc 0 T, β x : Space, βu t xβ β€ C | |
| def UniqueEnergySolution (Ξ½ : β) (f u : Field Space) (p : Field β) : Prop := | |
| Classical u p β§ EnergyClass u p β§ NavierStokes Ξ½ f u p β§ | |
| β (v : Field Space) (q : Field β), | |
| Classical v q β EnergyCompetitor v q β NavierStokes Ξ½ f v q β | |
| β (t : β), 0 β€ t β β x : Space, v t x = u t x β§ q t x = p t x | |
| def TrajectoryOn (u : Field Space) (a : Space) (T : β) (Ξ³ : β β Space) : Prop := | |
| Ξ³ 0 = a β§ β t β Icc 0 T, | |
| HasDerivWithinAt Ξ³ (u t (Ξ³ t)) (Icc 0 T) t | |
| def MaterialFlow (u : Field Space) (X : β β Space β Space) : Prop := | |
| (β a : Space, X 0 a = a) β§ | |
| (β (a : Space) (t : β), 0 β€ t β | |
| HasDerivWithinAt (fun s => X s a) (u t (X t a)) (Ici 0) t) β§ | |
| (β (T : β), 0 < T β β (a : Space) (Ξ³ : β β Space), | |
| TrajectoryOn u a T Ξ³ β β t β Icc 0 T, Ξ³ t = X t a) | |
| abbrev Move := Fin 3 | |
| structure Machine where | |
| states : β | |
| symbols : β | |
| states_pos : 0 < states | |
| symbols_pos : 0 < symbols | |
| initial : Fin states | |
| transition : Fin states β Fin symbols β Option (Fin states Γ Fin symbols Γ Move) | |
| namespace Machine | |
| abbrev Input (M : Machine) := List (Fin M.symbols) | |
| def blank (M : Machine) : Fin M.symbols := β¨0, M.symbols_posβ© | |
| def description (M : Machine) : β Γ β Γ β Γ List (Option (β Γ β Γ Move)) := | |
| (M.states, M.symbols, M.initial.val, | |
| (List.finRange M.states).flatMap fun q => | |
| (List.finRange M.symbols).map fun z => | |
| (M.transition q z).map fun v => (v.1.val, v.2.1.val, v.2.2)) | |
| def inputDescription (M : Machine) (w : M.Input) : β := | |
| Encodable.encode (M.description, w.map Fin.val) | |
| structure Config (M : Machine) where | |
| state : Fin (M.states + 1) | |
| head : β€ | |
| tape : β€ β Fin M.symbols | |
| def initialConfig (M : Machine) (w : M.Input) : M.Config := | |
| β¨β¨M.initial.val, Nat.lt_succ_of_lt M.initial.isLtβ©, 0, | |
| fun i => if 0 β€ i then w[i.toNat]?.getD M.blank else M.blankβ© | |
| def nextConfig (M : Machine) (c : M.Config) : M.Config := | |
| if h : c.state.val < M.states then | |
| match M.transition β¨c.state.val, hβ© (c.tape c.head) with | |
| | none => β¨β¨M.states, Nat.lt_succ_self _β©, c.head, c.tapeβ© | |
| | some (q', z', d) => | |
| β¨β¨q'.val, Nat.lt_succ_of_lt q'.isLtβ©, c.head + (d.val : β€) - 1, | |
| Function.update c.tape c.head z'β© | |
| else c | |
| def run (M : Machine) (w : M.Input) (n : β) : M.Config := | |
| M.nextConfig^[n] (M.initialConfig w) | |
| def Halts (M : Machine) (w : M.Input) : Prop := | |
| β n : β, (M.run w n).state.val = M.states | |
| end Machine | |
| structure ScaleData where | |
| rA : β | |
| rQ : β | |
| B : β | |
| namespace ScaleData | |
| def A (d : ScaleData) : β := 2 ^ d.rA | |
| def S (d : ScaleData) : β := 2 ^ d.rQ | |
| def P (_d : ScaleData) (n : β) : β := 2 ^ (n + 2) | |
| def L (d : ScaleData) (n : β) : β := d.rQ + n + 2 + d.rA * (2 * n + d.B + 1) | |
| def capacity (d : ScaleData) (n : β) : β := 2 ^ d.L n | |
| def C (d : ScaleData) : β := max 1 (max (d.L 0) (1 + 2 * d.rA)) | |
| def s (d : ScaleData) (n : β) : β := d.C * 2 ^ ((n + 2) ^ 2) | |
| def D (d : ScaleData) (n : β) : β := 2 ^ d.s n | |
| noncomputable def Ξ΄ (d : ScaleData) (n : β) : β := | |
| letI := twoAtLeastTwo | |
| (1 / 2 : β) ^ d.s n | |
| noncomputable def b (d : ScaleData) (n : β) : β := d.Ξ΄ (n + 1) * (d.capacity (n + 1) : β) | |
| end ScaleData | |
| namespace Machine | |
| def scaleData (M : Machine) (w : M.Input) : ScaleData := | |
| β¨M.symbols + 1, M.states + 1, w.lengthβ© | |
| def instruction (M : Machine) (q z : β) : β Γ β Γ Move := | |
| letI := neZeroThree | |
| if hq : q < M.states then | |
| if hz : z < M.symbols then | |
| match M.transition β¨q, hqβ© β¨z, hzβ© with | |
| | none => (M.states, z, 1) | |
| | some (q', z', d) => (q'.val, z'.val, d) | |
| else (M.states, z, 1) | |
| else (M.states, z, 1) | |
| def terminalDigit (M : Machine) (d : ScaleData) (k : β) : β := | |
| if k % d.S = M.states then 1 else 0 | |
| def nextDigit (M : Machine) (d : ScaleData) (n k : β) : β := | |
| let q := k % d.S | |
| let j := (k / d.S) % d.P n | |
| let T := k / (d.S * d.P n) | |
| let z := (T / d.A ^ j) % d.A | |
| if q < M.states β§ j β€ 2 * n β§ z < M.symbols then | |
| let inst := M.instruction q z | |
| inst.1 + d.S * (j + inst.2.2.val + | |
| d.P (n + 1) * d.A * (T - z * d.A ^ j + inst.2.1 * d.A ^ j)) | |
| else 0 | |
| def initialDigit (M : Machine) (w : M.Input) : β := | |
| let d := M.scaleData w | |
| M.initial.val + d.S * (d.P 0 * | |
| ((w.map Fin.val).zipIdx.map fun a => a.1 * d.A ^ a.2).sum) | |
| end Machine | |
| noncomputable def ΞΈ (t : β) : β := | |
| letI := twoAtLeastTwo | |
| Real.smoothTransition (2 * t - 1 / 2) | |
| noncomputable def ΞΆ (v : Space) : β := | |
| β i, Real.smoothTransition (16 * (v i + 1 / 8)) * | |
| Real.smoothTransition (16 * (1 / 8 - v i)) | |
| noncomputable def cross (a b : Space) : Space := | |
| letI := neZeroThree | |
| vec (a 1 * b 2 - a 2 * b 1) (a 2 * b 0 - a 0 * b 2) (a 0 * b 1 - a 1 * b 0) | |
| noncomputable def curl (v : Space β Space) (x : Space) : Space := | |
| letI := neZeroThree | |
| vec ((fderiv β v x (basis 1)) 2 - (fderiv β v x (basis 2)) 1) | |
| ((fderiv β v x (basis 2)) 0 - (fderiv β v x (basis 0)) 2) | |
| ((fderiv β v x (basis 0)) 1 - (fderiv β v x (basis 1)) 0) | |
| noncomputable def movingCurl (c : β β Space) (Ξ΄ : β) : Field Space := | |
| letI := twoAtLeastTwo | |
| fun Ο x => curl (fun y => | |
| ΞΆ (Ξ΄β»ΒΉ β’ (y - c Ο)) β’ ((1 / 2 : β) β’ cross (deriv c Ο) (y - c Ο))) x | |
| noncomputable def addressCenter (d : ScaleData) (n m : β) : Space := | |
| vec (-1) ((m : β) * d.Ξ΄ n) 0 | |
| noncomputable def addressDisplacement (M : Machine) (d : ScaleData) (n m : β) : Space := | |
| let k := m % d.capacity n | |
| vec (-d.b n * (M.terminalDigit d k : β)) | |
| (d.Ξ΄ (n + 1) * (M.nextDigit d n k : β)) 0 | |
| noncomputable def addressPath (M : Machine) (d : ScaleData) (n m : β) (Ο : β) : Space := | |
| addressCenter d n m + ΞΈ Ο β’ addressDisplacement M d n m | |
| noncomputable def addressedVelocity (M : Machine) (w : M.Input) : Field Space := | |
| let d := M.scaleData w | |
| let yβ := d.Ξ΄ 0 * (M.initialDigit w : β) | |
| fun t x => if t β€ 1 then | |
| movingCurl (fun s => ΞΈ s β’ vec (-1) yβ 0) 1 t x | |
| else | |
| let n := Nat.floor (t - 1) | |
| β m β Finset.range (d.D n + 1), | |
| movingCurl (addressPath M d n m) (d.Ξ΄ n) (t - 1 - (n : β)) x | |
| noncomputable def addressedForce (Ξ½ : β) (M : Machine) (w : M.Input) : Field Space := | |
| residual Ξ½ (addressedVelocity M w) | |
| abbrev Program := Nat.Partrec.Code | |
| abbrev RationalVector := β Γ β Γ β | |
| abbrev RationalPoint := β Γ RationalVector | |
| noncomputable def rationalVector (q : RationalVector) : Space := | |
| vec q.1 q.2.1 q.2.2 | |
| noncomputable def accuracy (n : β) : β := | |
| letI := twoAtLeastTwo | |
| (1 / 2 : β) ^ n | |
| def NamesReal (c : Program) (x : β) : Prop := | |
| β n : β, β q : β, Encodable.encode q β c.eval n β§ |(q : β) - x| β€ accuracy n | |
| def ComputableReal (x : β) : Prop := β c : Program, NamesReal c x | |
| def NamesPoint (c : Program) (t : β) (x : Space) : Prop := | |
| β n : β, β q : RationalPoint, Encodable.encode q β c.eval n β§ | |
| |(q.1 : β) - t| β€ accuracy n β§ βrationalVector q.2 - xβ β€ accuracy n | |
| def evalQuery (l : β) (Ξ± : MultiIndex) (name : Program) (precision : β) : β := | |
| letI := neZeroThree | |
| Encodable.encode (l, Ξ± 0, Ξ± 1, Ξ± 2, Encodable.encode name, precision) | |
| def boundQuery (J l : β) (Ξ± : MultiIndex) : β := | |
| letI := neZeroThree | |
| Encodable.encode (J, l, Ξ± 0, Ξ± 1, Ξ± 2) | |
| def EvaluatesMixed (c : Program) (f : Field Space) : Prop := | |
| β (l : β) (Ξ± : MultiIndex) (name : Program) (t : β) (x : Space), | |
| 0 β€ t β NamesPoint name t x β β n : β, β q : RationalVector, | |
| Encodable.encode q β c.eval (evalQuery l Ξ± name n) β§ | |
| βrationalVector q - mixedD l Ξ± f t xβ β€ accuracy n | |
| def BoundsMixed (c : Program) (f : Field Space) : Prop := | |
| β (J l : β) (Ξ± : MultiIndex), β C : β, | |
| C β c.eval (boundQuery J l Ξ±) β§ | |
| β (t : β), 0 β€ t β β x : Space, | |
| (1 + t + βxβ) ^ J * βmixedD l Ξ± f t xβ β€ (C : β) | |
| def ForceProgram (codes : β Γ β) (f : Field Space) : Prop := | |
| EvaluatesMixed (Nat.Partrec.Code.ofNatCode codes.1) f β§ | |
| BoundsMixed (Nat.Partrec.Code.ofNatCode codes.2) f | |
| end RapidForcing | |
| end OAI | |