math / data /lean /ComparatorChallenges /BalancedBoxRouting.lean
introvoyz045's picture
Migrated from GitHub
4a56cd6 verified
Raw History Blame Contribute Delete
3.72 kB
import Mathlib
namespace OAI
open scoped BigOperators ContDiff
namespace BoxTransport.Routing
abbrev Space := Fin 3 β†’ ℝ
abbrev RationalSpace := Fin 3 β†’ β„š
abbrev SpaceTime := ℝ Γ— Space
abbrev RationalSpaceTime := β„š Γ— RationalSpace
abbrev Field := SpaceTime β†’ Space
abbrev Axis := Option (Fin 3)
def coordinateVector (j : Fin 3) : Space := Pi.single j 1
def coordinateDirection : Axis β†’ SpaceTime
| none => (1, 0)
| some j => (0, coordinateVector j)
def realPoint (q : RationalSpace) : Space := fun j => (q j : ℝ)
def realSpaceTime (q : RationalSpaceTime) : SpaceTime := (q.1, realPoint q.2)
def realBox (c r : Space) : Set Space :=
{x | βˆ€ j, |x j - c j| ≀ r j}
def solidBox (a h : RationalSpace) : Set Space :=
realBox (realPoint a) (realPoint h)
def prescribedAffine (a b h k : RationalSpace) (x : Space) : Space :=
fun j => (b j : ℝ) + ((k j / h j : β„š) : ℝ) * (x j - (a j : ℝ))
noncomputable def mixedDerivative : List Axis β†’ Field β†’ Field
| [], U => U
| j :: js, U => fun p => fderiv ℝ (mixedDerivative js U) p (coordinateDirection j)
abbrev RationalCode := β„• Γ— β„• Γ— β„•
def rationalValue (q : RationalCode) : β„š := ((q.1 : β„š) - q.2.1) / (q.2.2 + 1)
abbrev RationalPointCode := RationalCode Γ— RationalCode Γ— RationalCode Γ— RationalCode
def codeSpaceTime (q : RationalPointCode) : SpaceTime :=
((rationalValue q.1 : ℝ), ![(rationalValue q.2.1 : ℝ),
(rationalValue q.2.2.1 : ℝ), (rationalValue q.2.2.2 : ℝ)])
abbrev EvaluationRequest := List Axis Γ— RationalPointCode Γ— β„• Γ— Fin 3
def Effective (U : Field) : Prop :=
βˆƒ eval : EvaluationRequest β†’ RationalCode,
βˆƒ modulus : List Axis Γ— β„• β†’ β„•,
βˆƒ bound : List Axis β†’ β„•,
Computable eval ∧ Computable modulus ∧ Computable bound ∧
(βˆ€ (ds : List Axis) (q : RationalPointCode) (n : β„•) (p : SpaceTime),
β€–p - codeSpaceTime qβ€– ≀ ((modulus (ds, n) : ℝ) + 1)⁻¹ β†’
βˆ€ j : Fin 3,
|mixedDerivative ds U p j - (rationalValue (eval (ds, q, n, j)) : ℝ)| ≀
((n : ℝ) + 1)⁻¹) ∧
(βˆ€ (ds : List Axis) (p : SpaceTime) (j : Fin 3),
|mixedDerivative ds U p j| ≀ (bound ds : ℝ))
noncomputable def spatialDivergence (U : Field) (t : ℝ) (x : Space) : ℝ :=
βˆ‘ j : Fin 3, (fderiv ℝ (fun y => U (t, y)) x (coordinateVector j)) j
def AdmissibleField (U : Field) : Prop :=
ContDiff ℝ ∞ U ∧ HasCompactSupport U ∧ Effective U ∧
(βˆ€ t x, spatialDivergence U t x = 0) ∧
(βˆ€ (t : ℝ) (x : Space), t βˆ‰ Set.Icc (1 / 4 : ℝ) (3 / 4 : ℝ) β†’ U (t, x) = 0)
def IsGlobalFlow (U : Field) (Ξ¦ : ℝ β†’ Space β†’ Space) : Prop :=
(βˆ€ x, Ξ¦ 0 x = x) ∧
(βˆ€ t x, HasDerivAt (fun s => Ξ¦ s x) (U (t, Ξ¦ t x)) t) ∧
(βˆ€ (x : Space) (Ξ³ : ℝ β†’ Space), Ξ³ 0 = x β†’
(βˆ€ t, HasDerivAt Ξ³ (U (t, Ξ³ t)) t) β†’ βˆ€ t, Ξ³ t = Ξ¦ t x)
def Delivers {n : β„•} (a b h k : Fin n β†’ RationalSpace)
(Ξ¦ : ℝ β†’ Space β†’ Space) : Prop :=
βˆ€ i, βˆƒ O : Set Space, IsOpen O ∧ solidBox (a i) (h i) βŠ† O ∧
βˆ€ x ∈ O, Ξ¦ 1 x = prescribedAffine (a i) (b i) (h i) (k i) x
theorem balanced_box_routing
(n : β„•) (a b h k : Fin n β†’ RationalSpace)
(hh : βˆ€ i j, 0 < h i j) (hk : βˆ€ i j, 0 < k i j)
(ha : Pairwise fun i j => Disjoint (solidBox (a i) (h i)) (solidBox (a j) (h j)))
(hb : Pairwise fun i j => Disjoint (solidBox (b i) (k i)) (solidBox (b j) (k j)))
(hvol : βˆ€ i, ∏ j : Fin 3, k i j / h i j = 1) :
βˆƒ U : Field, βˆƒ Ξ¦ : ℝ β†’ Space β†’ Space,
AdmissibleField U ∧ IsGlobalFlow U Φ ∧ Delivers a b h k Φ := by
sorry
end BoxTransport.Routing
end OAI