File size: 8,694 Bytes
16a4018
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
import Mathlib

namespace OAI

namespace BalancedTransport
namespace Recorder
inductive Direction where
  | stay | left | right
  deriving DecidableEq

instance : Fintype Direction :=
  ⟨{.stay, .left, .right}, by intro d; cases d <;> simp⟩

structure Transition (Q Γ : Type*) where
  state : Q
  write : Γ
  move : Direction
end Recorder

structure FiniteMachine where
  states : ℕ
  symbols : ℕ
  initial : Fin (states + 1)
  blank : Fin (symbols + 1)
  transition : Fin (states + 1) → Fin (symbols + 1) →
    Option (Recorder.Transition (Fin (states + 1)) (Fin (symbols + 1)))

abbrev Input (M : FiniteMachine) := List (Fin (M.symbols + 1))

structure TapeConfiguration (M : FiniteMachine) where
  state : Fin (M.states + 1)
  head : ℤ
  tape : ℤ → Fin (M.symbols + 1)

def initialConfiguration (M : FiniteMachine) (w : Input M) : TapeConfiguration M :=
  ⟨M.initial, 0, fun z => if 0 ≤ z then w[z.toNat]?.getD M.blank else M.blank⟩

def machineStep (M : FiniteMachine) (c : TapeConfiguration M) : Option (TapeConfiguration M) :=
  (M.transition c.state (c.tape c.head)).map fun v =>
    ⟨v.state, c.head + (match v.move with | .stay => 0 | .left => -1 | .right => 1),
      Function.update c.tape c.head v.write⟩

def Halts (M : FiniteMachine) (w : Input M) : Prop :=
  ∃ c, Relation.ReflTransGen (fun c d => machineStep M c = some d)
    (initialConfiguration M w) c ∧ machineStep M c = none

def Recorder.Direction.number : Recorder.Direction → ℕ
  | .stay => 0
  | .left => 1
  | .right => 2

def FiniteMachine.code (M : FiniteMachine) : ℕ :=
  Encodable.encode (M.states, M.symbols, M.initial.val, M.blank.val,
    (List.finRange (M.states + 1)).map fun q =>
      (List.finRange (M.symbols + 1)).map fun a =>
        (M.transition q a).map fun v => (v.state.val, v.write.val, v.move.number))

def inputCode (M : FiniteMachine) (w : Input M) : ℕ :=
  Encodable.encode (M.code, w.map Fin.val)

abbrev Space := Fin 3 → ℝ
abbrev Field (F : Type*) := ℝ → Space → F
abbrev Velocity := Field Space
abbrev Pressure := Field ℝ
abbrev Family (F : Type*) := (M : FiniteMachine) → Input M → F
abbrev MaterialFlow := ℝ → Space → Space
abbrev MultiIndex := List (Option (Fin 3))
abbrev RationalPoint := ℚ × (Fin 3 → ℚ)

noncomputable section

open MeasureTheory
open scoped ENNReal

variable {F : Type*} [NormedAddCommGroup F] [NormedSpace ℝ F]

def timeD (v : Field F) : Field F :=
  fun t x => derivWithin (fun s => v s x) (Set.Ici 0) t

def spaceD (i : Fin 3) (v : Field F) : Field F :=
  fun t x => fderiv ℝ (v t) x (Pi.single i 1)

def mixedD : MultiIndex → Field F → Field F
  | [], v => v
  | none :: a, v => timeD (mixedD a v)
  | some i :: a, v => spaceD i (mixedD a v)

def spatialD : List (Fin 3) → Field F → Field F
  | [], v => v
  | i :: a, v => spaceD i (spatialD a v)

def Smooth (v : Field F) : Prop :=
  ContDiffOn ℝ (⊤ : ℕ∞) (fun z : ℝ × Space => v z.1 z.2) (Set.Ici 0 ×ˢ Set.univ)

def BoundedMixed (v : Field F) : Prop :=
  ∀ a : MultiIndex, ∃ C : ℝ, 0 ≤ C ∧ ∀ t, 0 ≤ t → ∀ x, ‖mixedD a v t x‖ ≤ C

def CH (k : ℕ) (v : Field F) : Prop :=
  ∀ a : List (Fin 3), a.length ≤ k →
    ∃ V : ℝ → Lp F 2 (volume : Measure Space),
      ContinuousOn V (Set.Ici 0) ∧
      ∀ t, 0 ≤ t → (V t : Space → F) =ᵐ[volume] spatialD a v t

def C1L2 (v : Field F) : Prop :=
  ∃ V W : ℝ → Lp F 2 (volume : Measure Space),
    ContinuousOn V (Set.Ici 0) ∧ ContinuousOn W (Set.Ici 0) ∧
    ∀ t, 0 ≤ t →
      (V t : Space → F) =ᵐ[volume] v t ∧
      (W t : Space → F) =ᵐ[volume] timeD v t ∧
      HasDerivWithinAt V (W t) (Set.Ici 0) t

def div (u : Velocity) (t : ℝ) (x : Space) : ℝ :=
  ∑ i, spaceD i u t x i

def laplacian (u : Velocity) : Velocity :=
  fun t x => ∑ i, spaceD i (spaceD i u) t x

def convection (u : Velocity) : Velocity :=
  fun t x => ∑ i, (u t x i) • spaceD i u t x

def gradient (p : Pressure) (t : ℝ) (x : Space) : Space :=
  fun i => spaceD i p t x

def affineForce (f₀ f₁ : Velocity) (ν : ℝ) : Velocity :=
  fun t x => f₀ t x + ν • f₁ t x

def inertialCoefficient (u : Velocity) : Velocity :=
  fun t x => timeD u t x + convection u t x

def viscousCoefficient (u : Velocity) : Velocity :=
  fun t x => -laplacian u t x

def ZeroDataSolution (ν : ℝ) (f u : Velocity) (p : Pressure) : Prop :=
  Smooth u ∧ Smooth p ∧
  (∀ x, u 0 x = 0) ∧
  (∀ t, 0 ≤ t → ∀ x, div u t x = 0) ∧
  (∀ t, 0 ≤ t → ∀ x,
    timeD u t x + convection u t x =
      -gradient p t x + ν • laplacian u t x + f t x)

def BoundedOnFiniteSlabs (u : Velocity) : Prop :=
  ∀ T : ℝ, 0 ≤ T → ∃ C : ℝ, 0 ≤ C ∧
    ∀ t ∈ Set.Icc (0 : ℝ) T, ∀ x,
      ‖u t x‖ ≤ C ∧ ∀ i : Fin 3, ‖spaceD i u t x‖ ≤ C

def ComparisonClass (u : Velocity) (p : Pressure) : Prop :=
  CH 2 u ∧ C1L2 u ∧ BoundedOnFiniteSlabs u ∧
    ∃ c : ℝ → ℝ, CH 1 (fun t x => p t x - c t)

def UniqueInComparison (ν : ℝ) (f U : Velocity) : Prop :=
  ∀ u p, ZeroDataSolution ν f u p → ComparisonClass u p →
    (∀ t, 0 ≤ t → ∀ x, u t x = U t x) ∧
    (∀ t, 0 ≤ t → ∀ x y, p t x = p t y)

def CommonCompactSupport (U f₀ f₁ : Velocity) : Prop :=
  ∃ K : Set Space, IsCompact K ∧
    ∀ t, 0 ≤ t → ∀ x, x ∉ K → U t x = 0 ∧ f₀ t x = 0 ∧ f₁ t x = 0

def PeriodicAfterOne (v : Velocity) : Prop :=
  ∀ t, 1 ≤ t → ∀ x, v (t + 1) x = v t x

def IsMaterialFlow (u : Velocity) (X : MaterialFlow) : Prop :=
  (∀ a, X 0 a = a) ∧
  ∀ a t, 0 ≤ t → HasDerivWithinAt (fun s => X s a) (u t (X t a)) (Set.Ici 0) t

def fixedLabel : Space := ![4, 0, 0]

def observer : Set Space :=
  Set.pi Set.univ (fun _ : Fin 3 => Set.Ioo (-1 : ℝ) 2)

def rationalSpace (x : Fin 3 → ℚ) : Space := fun i => (x i : ℝ)

def error (n : ℕ) : ℝ := (2 : ℝ)⁻¹ ^ n

def EffectiveFamily (v : Family Velocity) : Prop :=
  ∃ E : (ℕ × MultiIndex × RationalPoint × ℕ) → (Fin 3 → ℚ),
  ∃ b : (ℕ × MultiIndex) → ℕ,
  ∃ R : ℕ → ℕ,
    Computable E ∧ Computable b ∧ Computable R ∧
    (∀ M w a z n, 0 ≤ z.1 → ∀ i,
      |(E (inputCode M w, a, z, n) i : ℝ) -
        mixedD a (v M w) (z.1 : ℝ) (rationalSpace z.2) i| ≤ error n) ∧
    (∀ M w a t, 0 ≤ t → ∀ x,
      ‖mixedD a (v M w) t x‖ ≤ (b (inputCode M w, a) : ℝ)) ∧
    (∀ M w t, 0 ≤ t → ∀ x,
      (R (inputCode M w) : ℝ) < ‖x‖ → v M w t x = 0)

def EffectiveFieldIn (O : Set (ℕ →. ℕ)) (v : Velocity) : Prop :=
  ∃ E : (MultiIndex × RationalPoint × ℕ) → (Fin 3 → ℚ),
  ∃ b : MultiIndex → ℕ,
    ComputableIn O E ∧ ComputableIn O b ∧
    (∀ a z n, 0 ≤ z.1 → ∀ i,
      |(E (a, z, n) i : ℝ) -
        mixedD a v (z.1 : ℝ) (rationalSpace z.2) i| ≤ error n) ∧
    (∀ a t, 0 ≤ t → ∀ x, ‖mixedD a v t x‖ ≤ (b a : ℝ))

def RealName (name : ℕ → ℚ) (x : ℝ) : Prop :=
  ∀ n, |(name n : ℝ) - x| ≤ error n

def ComputableReal (x : ℝ) : Prop :=
  ∃ name : ℕ → ℚ, Computable name ∧ RealName name x

def nameOracle (name : ℕ → ℚ) : ℕ →. ℕ :=
  fun n => Part.some (Encodable.encode (name n))

end
end BalancedTransport

namespace BalancedTransport

theorem balanced_three_stack_realization :
    ∃ U f₀ f₁ : Family Velocity,
    ∃ X : Family MaterialFlow,
    ∃ repeated : FiniteMachine → Velocity,
      EffectiveFamily U ∧ EffectiveFamily f₀ ∧ EffectiveFamily f₁ ∧
      (∀ M, Function.Periodic (repeated M) 1) ∧
      ∀ (M : FiniteMachine) (w : Input M),
        Smooth (U M w) ∧ Smooth (f₀ M w) ∧ Smooth (f₁ M w) ∧
        f₀ M w = inertialCoefficient (U M w) ∧
        f₁ M w = viscousCoefficient (U M w) ∧
        CommonCompactSupport (U M w) (f₀ M w) (f₁ M w) ∧
        BoundedMixed (U M w) ∧
        PeriodicAfterOne (U M w) ∧
        (∀ t, 1 ≤ t → ∀ x, U M w t x = repeated M t x) ∧
        ComparisonClass (U M w) (fun _ _ => 0) ∧
        IsMaterialFlow (U M w) (X M w) ∧
        ((∃ t : ℝ, 0 ≤ t ∧ X M w t fixedLabel ∈ observer) ↔ Halts M w) ∧
        ∀ ν : ℝ, 0 < ν →
          let f := affineForce (f₀ M w) (f₁ M w) ν
          ZeroDataSolution ν f (U M w) (fun _ _ => 0) ∧
          Smooth f ∧ BoundedMixed f ∧ PeriodicAfterOne f ∧
          UniqueInComparison ν f (U M w) ∧
          (ComputableReal ν → EffectiveFieldIn ∅ f) ∧
          (∀ name : ℕ → ℚ, RealName name ν → EffectiveFieldIn {nameOracle name} f) := by
  sorry

end BalancedTransport

end OAI