Download data/lean/ComparatorChallenges/BalancedThreeStack.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 8.69 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/ComparatorChallenges/BalancedThreeStack.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/ComparatorChallenges/BalancedThreeStack.lean
-
curl -L -o BalancedThreeStack.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/ComparatorChallenges/BalancedThreeStack.lean
8.69 kB
| 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 | |