import NavierStokes.GenericJetRateAlgebra noncomputable section namespace NavierStokes.GenericDifferentialPolynomial open Set Filter DiagonalResidual open scoped Topology ContDiff variable {D : Type*} [NormedAddCommGroup D] [NormedSpace ℝ D] /-- Quantitative approximation data. Constants may depend on the stage, while the power losses and derivative thresholds are fixed functions of the jet order. -/ structure ApproximationRates (l : Filter D) (q : D → ℝ) (gain : ℕ → ℝ) (f : D → ℝ) (stage : ℕ → D → ℝ) where growthLoss : ℕ → ℝ tailLoss : ℕ → ℝ threshold : ℕ → ℕ stage_growth : ∀ J m, JetRate l q (stage J) m (-growthLoss m) tail_rate : ∀ m J, threshold m ≤ J → JetRate l q (fun x => f x - stage J x) m (gain J - tailLoss m) private def maxThreshold (M : ℕ → ℕ) (m : ℕ) : ℕ := (Finset.range (m + 1)).sup M private theorem le_maxThreshold (M : ℕ → ℕ) {k m : ℕ} (hk : k ≤ m) : M k ≤ maxThreshold M m := Finset.le_sup (f := M) (Finset.mem_range.mpr (Nat.lt_succ_of_le hk)) variable {l : Filter D} {q : D → ℝ} {gain : ℕ → ℝ} {U : Set D} variable {f g : D → ℝ} {fs gs : ℕ → D → ℝ} /-- A finite differential expression in scalar components with fixed variable coefficients. Products, sums, and arbitrary fixed directional derivatives are allowed at every node; consequently the order and polynomial degree are finite. -/ inductive Expression (D ι κ : Type*) where | input : ι → Expression D ι κ | coeff : κ → Expression D ι κ | add : Expression D ι κ → Expression D ι κ → Expression D ι κ | mul : Expression D ι κ → Expression D ι κ → Expression D ι κ | directional : D → Expression D ι κ → Expression D ι κ namespace Expression variable {ι κ : Type*} /-- Evaluation uses actual Fréchet derivatives, including at derivative nodes. -/ def eval (c : κ → D → ℝ) (u : ι → D → ℝ) : Expression D ι κ → D → ℝ | .input i => u i | .coeff i => c i | .add a b => fun x => eval c u a x + eval c u b x | .mul a b => fun x => eval c u a x * eval c u b x | .directional v a => fun x => fderiv ℝ (eval c u a) x v end Expression end NavierStokes.GenericDifferentialPolynomial