introvoyz045's picture
Migrated from GitHub
4a56cd6 verified
Raw History Blame Contribute Delete
9.33 kB
import Mathlib
namespace OAI
open scoped BigOperators ENNReal NNReal Topology ContDiff
open MeasureTheory
namespace AlternatingNS
theorem neZeroThree : NeZero 3 := ⟨Nat.succ_ne_zero 2⟩
theorem twoAtLeastTwo : Nat.AtLeastTwo 2 := ⟨Nat.le_refl 2⟩
theorem threeAtLeastTwo : Nat.AtLeastTwo 3 := ⟨Nat.le_succ 2⟩
theorem eightAtLeastTwo : Nat.AtLeastTwo 8 := ⟨by decide⟩
abbrev Rule := β„• Γ— β„• Γ— Fin 3
abbrev Machine := β„• Γ— β„• Γ— β„• Γ— List β„• Γ— List (Option Rule)
namespace Machine
def states (M : Machine) : β„• := M.1 + 1
def alphabet (M : Machine) : β„• := M.2.1 + 1
def initialState (M : Machine) : β„• := M.2.2.1
def haltingStates (M : Machine) : List β„• := M.2.2.2.1
def table (M : Machine) : List (Option Rule) := M.2.2.2.2
def instruction (M : Machine) (q a : β„•) : Option Rule :=
(M.table[q * M.alphabet + a]?).join
def WellFormed (M : Machine) : Prop :=
M.initialState < M.states ∧
(βˆ€ q ∈ M.haltingStates, q < M.states) ∧
βˆ€ q a r, q < M.states β†’ a < M.alphabet β†’ M.instruction q a = some r β†’
r.1 < M.states ∧ r.2.1 < M.alphabet
def ValidInput (M : Machine) (w : List β„•) : Prop :=
βˆ€ a ∈ w, a < M.alphabet
structure Configuration where
state : β„•
head : β„€
tape : β„€ β†’ β„•
def isHalting (M : Machine) (c : Configuration) : Bool :=
decide (c.state = M.states ∨ c.state ∈ M.haltingStates)
def initial (M : Machine) (w : List β„•) : Configuration where
state := M.initialState
head := 0
tape := fun i => if 0 ≀ i then w[i.toNat]?.getD 0 else 0
def step (M : Machine) (c : Configuration) : Configuration :=
if M.isHalting c then c else
match M.instruction c.state (c.tape c.head) with
| none => { c with state := M.states }
| some r =>
{ state := r.1
head := c.head + ((r.2.2.val : β„€) - 1)
tape := Function.update c.tape c.head r.2.1 }
def run (M : Machine) (w : List β„•) (n : β„•) : Configuration :=
(M.step)^[n] (M.initial w)
def Halts (M : Machine) (w : List β„•) : Prop :=
βˆƒ n : β„•, M.isHalting (M.run w n) = true
end Machine
abbrev Space := EuclideanSpace ℝ (Fin 3)
abbrev Field (E : Type*) := ℝ β†’ Space β†’ E
abbrev Velocity := Field Space
abbrev Pressure := Field ℝ
abbrev MultiIndex := Fin 3 β†’ β„•
noncomputable section
def e (i : Fin 3) : Space := EuclideanSpace.single i 1
def dx {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E]
(i : Fin 3) (F : Field E) : Field E :=
fun t x => fderiv ℝ (F t) x (e i)
def dt {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E]
(F : Field E) : Field E :=
fun t x => fderivWithin ℝ (fun s => F s x) (Set.Ici 0) t 1
def spatial {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E]
(Ξ± : MultiIndex) (F : Field E) : Field E :=
(dx 0)^[Ξ± 0] ((dx 1)^[Ξ± 1] ((dx 2)^[Ξ± 2] F))
def mixed {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E]
(l : β„•) (Ξ± : MultiIndex) (F : Field E) : Field E :=
dt^[l] (spatial Ξ± F)
def div (u : Velocity) (t : ℝ) (x : Space) : ℝ :=
βˆ‘ i : Fin 3, dx i u t x i
def grad (p : Pressure) (t : ℝ) (x : Space) : Space :=
(EuclideanSpace.equiv (Fin 3) ℝ).symm (fun i => dx i p t x)
def laplacian (u : Velocity) (t : ℝ) (x : Space) : Space :=
βˆ‘ i : Fin 3, dx i (dx i u) t x
def advection (u : Velocity) (t : ℝ) (x : Space) : Space :=
fderiv ℝ (u t) x (u t x)
def residual (Ξ½ : ℝ) (u : Velocity) : Velocity :=
fun t x => dt u t x + advection u t x - Ξ½ β€’ laplacian u t x
def timeCylinder (T : ℝ) : Set (ℝ Γ— Space) := Set.Icc 0 T Γ—Λ’ Set.univ
def Smooth {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E]
(F : Field E) : Prop :=
ContDiffOn ℝ (∞) (Function.uncurry F) (Set.Ici 0 Γ—Λ’ Set.univ)
def ClassicalRegularity (u : Velocity) (p : Pressure) : Prop :=
(βˆ€ x, DifferentiableOn ℝ (fun t => u t x) (Set.Ici 0)) ∧
(βˆ€ t, 0 ≀ t β†’ Differentiable ℝ (u t)) ∧
(βˆ€ t, 0 ≀ t β†’ βˆ€ i, Differentiable ℝ (dx i u t)) ∧
(βˆ€ t, 0 ≀ t β†’ Differentiable ℝ (p t)) ∧
βˆ€ T, 0 ≀ T β†’
ContinuousOn (Function.uncurry u) (timeCylinder T) ∧
ContinuousOn (Function.uncurry (dt u)) (timeCylinder T) ∧
(βˆ€ i, ContinuousOn (Function.uncurry (dx i u)) (timeCylinder T)) ∧
(βˆ€ i j, ContinuousOn (Function.uncurry (dx i (dx j u))) (timeCylinder T)) ∧
ContinuousOn (Function.uncurry p) (timeCylinder T) ∧
(βˆ€ i, ContinuousOn (Function.uncurry (dx i p)) (timeCylinder T))
def ContinuousInH {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E]
(k : β„•) (F : Field E) (T : ℝ) : Prop :=
βˆ€ Ξ± : MultiIndex, (βˆ‘ i, Ξ± i) ≀ k β†’
βˆƒ g : ℝ β†’ Lp E 2 (volume : Measure Space),
ContinuousOn g (Set.Icc 0 T) ∧
βˆ€ t ∈ Set.Icc 0 T,
βˆ€α΅ x βˆ‚(volume : Measure Space), (g t) x = spatial Ξ± F t x
def C1InL2 (u : Velocity) (T : ℝ) : Prop :=
βˆƒ g g' : ℝ β†’ Lp Space 2 (volume : Measure Space),
ContinuousOn g (Set.Icc 0 T) ∧
ContinuousOn g' (Set.Icc 0 T) ∧
(βˆ€ t ∈ Set.Icc 0 T, HasDerivWithinAt g (g' t) (Set.Icc 0 T) t) ∧
(βˆ€ t ∈ Set.Icc 0 T, βˆ€α΅ x βˆ‚(volume : Measure Space), (g t) x = u t x) ∧
(βˆ€ t ∈ Set.Icc 0 T, βˆ€α΅ x βˆ‚(volume : Measure Space), (g' t) x = dt u t x)
def CompetitorEnergyClass (u : Velocity) (p : Pressure) : Prop :=
βˆ€ T, 0 ≀ T β†’
ContinuousInH 2 u T ∧ C1InL2 u T ∧ ContinuousInH 1 p T ∧
βˆƒ C : ℝ, βˆ€ t ∈ Set.Icc 0 T, βˆ€ x, β€–u t xβ€– ≀ C
def EnergyClass (u : Velocity) (p : Pressure) : Prop :=
CompetitorEnergyClass u p ∧
βˆ€ T, 0 ≀ T β†’ βˆƒ C : ℝ, βˆ€ t ∈ Set.Icc 0 T, βˆ€ x,
β€–u t xβ€– + β€–fderiv ℝ (u t) xβ€– ≀ C
def NavierStokes (Ξ½ : ℝ) (f u : Velocity) (p : Pressure) : Prop :=
ClassicalRegularity u p ∧
(βˆ€ x, u 0 x = 0) ∧
βˆ€ t, 0 ≀ t β†’ βˆ€ x,
div u t x = 0 ∧
dt u t x + advection u t x = -grad p t x + Ξ½ β€’ laplacian u t x + f t x
def Rapid (F : Velocity) : Prop :=
βˆ€ J l : β„•, βˆ€ Ξ± : MultiIndex, βˆƒ C : ℝ, 0 ≀ C ∧
βˆ€ t, 0 ≀ t β†’ βˆ€ x,
(1 + t + β€–xβ€–) ^ J * β€–mixed l Ξ± F t xβ€– ≀ C
def SupportedIn (F : Velocity) (K : Set Space) : Prop :=
βˆ€ t, 0 ≀ t β†’ Function.support (F t) βŠ† K
def IsTrajectory (u : Velocity) (a : Space) (Ξ³ : ℝ β†’ Space) : Prop :=
Ξ³ 0 = a ∧ βˆ€ t, 0 ≀ t β†’ HasDerivWithinAt Ξ³ (u t (Ξ³ t)) (Set.Ici 0) t
def observedParticle : Space := (EuclideanSpace.equiv (Fin 3) ℝ).symm ![-1, 0, 0]
abbrev RationalPoint := β„š Γ— β„š Γ— β„š Γ— β„š
abbrev RationalVector := β„š Γ— β„š Γ— β„š
abbrev IndexCode := β„• Γ— β„• Γ— β„•
abbrev Program := Nat.Partrec.Code
abbrev FieldProgram := Program Γ— Program Γ— Program
def Returns {A B : Type*} [Encodable A] [Encodable B]
(c : Program) (a : A) (b : B) : Prop :=
Encodable.encode b ∈ c.eval (Encodable.encode a)
def index (Ξ± : IndexCode) : MultiIndex := ![Ξ±.1, Ξ±.2.1, Ξ±.2.2]
def rationalVector (q : RationalVector) : Space :=
(EuclideanSpace.equiv (Fin 3) ℝ).symm ![(q.1 : ℝ), (q.2.1 : ℝ), (q.2.2 : ℝ)]
def rationalPoint (q : RationalPoint) : ℝ Γ— Space :=
((q.1 : ℝ), rationalVector q.2)
def dyadicError (n : β„•) : ℝ := (1 / 2 : ℝ) ^ n
def ComputableReal (r : ℝ) : Prop :=
βˆƒ a : β„• β†’ β„š, Computable (fun n => ((a n).num, (a n).den)) ∧
βˆ€ n, |r - (a n : ℝ)| ≀ dyadicError n
def ProgramFor (c : FieldProgram) (F : Velocity) : Prop :=
(βˆ€ (l : β„•) (Ξ± : IndexCode) (q : RationalPoint) (k : β„•),
βˆƒ v : RationalVector, Returns c.1 (l, Ξ±, q, k) v ∧
(0 ≀ q.1 β†’
β€–rationalVector v - mixed l (index Ξ±) F (rationalPoint q).1 (rationalPoint q).2β€–
≀ dyadicError k)) ∧
(βˆ€ (l : β„•) (Ξ± : IndexCode) (R k : β„•),
βˆƒ m : β„•, Returns c.2.1 (l, Ξ±, R, k) m ∧
βˆ€ z z' : ℝ Γ— Space,
0 ≀ z.1 β†’ 0 ≀ z'.1 β†’ β€–zβ€– ≀ R β†’ β€–z'β€– ≀ R β†’
β€–z - z'β€– ≀ dyadicError m β†’
β€–mixed l (index Ξ±) F z.1 z.2 - mixed l (index Ξ±) F z'.1 z'.2β€– ≀ dyadicError k) ∧
(βˆ€ (J l : β„•) (Ξ± : IndexCode),
βˆƒ B : β„•, Returns c.2.2 (J, l, Ξ±) B ∧
βˆ€ t, 0 ≀ t β†’ βˆ€ x,
(1 + t + β€–xβ€–) ^ J * β€–mixed l (index Ξ±) F t xβ€– ≀ B)
def AlternatingConclusion (Ξ½ : ℝ) : Prop :=
βˆƒ (compileForce compileVelocity : Machine Γ— List β„• β†’ FieldProgram),
Computable compileForce ∧ Computable compileVelocity ∧
βˆƒ K : Set Space, IsCompact K ∧
βˆ€ (M : Machine) (w : List β„•), M.WellFormed β†’ M.ValidInput w β†’
βˆƒ (f U : Velocity) (X : Space β†’ ℝ β†’ Space),
ProgramFor (compileForce (M, w)) f ∧
ProgramFor (compileVelocity (M, w)) U ∧
Smooth f ∧ Smooth U ∧
SupportedIn f K ∧ SupportedIn U K ∧ Rapid f ∧ Rapid U ∧
f = residual ν U ∧
NavierStokes ν f U (fun _ _ => 0) ∧ EnergyClass U (fun _ _ => 0) ∧
(βˆ€ (v : Velocity) (p : Pressure),
NavierStokes Ξ½ f v p β†’ CompetitorEnergyClass v p β†’
βˆ€ t, 0 ≀ t β†’ βˆ€ x, v t x = U t x ∧ p t x = 0) ∧
(βˆ€ a, IsTrajectory U a (X a)) ∧
(βˆ€ a Ξ³, IsTrajectory U a Ξ³ β†’ βˆ€ t, 0 ≀ t β†’ Ξ³ t = X a t) ∧
((βˆƒ t : ℝ, 0 ≀ t ∧ 0 < X observedParticle t 0) ↔ M.Halts w)
end
end AlternatingNS
end OAI