import OAI.MathematicalPhysics.NavierStokes.ShearFlows.FieldExpressions import OAI.MathematicalPhysics.NavierStokes.ShearFlows.Localization namespace OAI noncomputable section open Set MeasureTheory open scoped BigOperators ContDiff Topology open Set Filter open scoped Topology BigOperators ContDiff namespace ShearFlows namespace RationalBox def centerQ {n : ℕ} (R : RationalBox n) (j : Fin n) : ℚ := (R.lower j + R.upper j)/2 theorem centerQ_cast {n : ℕ} (R : RationalBox n) (j : Fin n) : (R.centerQ j : ℝ) = R.center j := by simp [centerQ,center] end RationalBox namespace PeriodicExpr def cutoff (L a b c d : ℚ) : PeriodicExpr := ⟨L,a,d,ProfileExpr.cutoff a b c d⟩ def potential (L a b c d p : ℚ) : PeriodicExpr := ⟨L,a,d,ProfileExpr.potential a b c d p⟩ def mask (L a b c d p : ℚ) : PeriodicExpr := (potential L a b c d p).diff theorem cutoff_valid {L a b c d : ℚ} (hL : 0 (x-(p : ℝ))*closedCutoff a b c d x) := by simp only [val,potential,ProfileExpr.val_potential] theorem mask_val {L a b c d p : ℚ} (hL : 0 if k = j then e else .const 0 theorem along_valid {e : FieldExpr} (he : e.Valid) (j : Fin 3) : (e.along j).Valid := by intro k dsimp [along] split_ifs · exact he · trivial theorem along_val (e : FieldExpr) (j : Fin 3) (y : SpaceTime) : (e.along j).val y = e.val y • basis j := by ext k dsimp [along,VelocityExpr.val] split_ifs with h · subst k; simp [basis] · simp [val,basis,Pi.single_eq_of_ne h] theorem sum_ofFn_val {n : ℕ} (e : Fin n → FieldExpr) (y : SpaceTime) : (sum (List.ofFn e)).val y = ∑ i, (e i).val y := by rw [val_sum,List.map_ofFn,List.sum_ofFn] rfl theorem sum_ofFn_valid {n : ℕ} (e : Fin n → FieldExpr) (he : ∀ i, (e i).Valid) : (sum (List.ofFn e)).Valid := by apply valid_sum intro f hf obtain ⟨i,rfl⟩ := List.mem_ofFn.mp hf exact he i end FieldExpr namespace Input def branchExpr (d : Input) (i : Fin d.instructions.length) : Fin 7 → VelocityExpr := letI := neZeroTwo letI := neZeroThree ![(FieldExpr.mul (.const (d.privateHeight i-d.codingHeight)) (d.sourceExpr i)).along 2, (FieldExpr.mul (.mul (.const (-(d.instructions.get i).factor)) (d.heightExpr i)) (d.horizontalExpr i 0)).along 1, (FieldExpr.mul (.mul (.const ((d.instructions.get i).factor⁻¹-1)) (d.heightExpr i)) (d.horizontalExpr i 1)).along 0, (FieldExpr.mul (d.heightExpr i) (d.horizontalExpr i 0)).along 1, (FieldExpr.mul (.mul (.const ((d.instructions.get i).factor-1)) (d.heightExpr i)) (d.horizontalExpr i 1)).along 0, (fun k => .mul (d.heightExpr i) (.const (![ (d.targets i).centerQ 0-(d.sources i).centerQ 0, (d.targets i).centerQ 1-(d.sources i).centerQ 1, 0] k))), (FieldExpr.mul (.const (d.codingHeight-d.privateHeight i)) (d.targetExpr i)).along 2] def spatialExpr (d : Input) (j : Fin 7) : VelocityExpr := fun k => FieldExpr.sum (List.ofFn (fun i => d.branchExpr i j k)) def velocityExpr (d : Input) : VelocityExpr := fun k => FieldExpr.sum (List.ofFn (fun j => .mul (.atom 0 (PeriodicExpr.pulse j)) (d.spatialExpr j k))) end Input theorem branchExpr_valid {d : Input} (hd : ValidInput d) (i : Fin d.instructions.length) (j : Fin 7) : (d.branchExpr i j).Valid := by have hs := sourceExpr_valid hd i have ht := targetExpr_valid hd i have hz := heightExpr_valid hd i have hx := horizontalExpr_valid hd i 0 have hy := horizontalExpr_valid hd i 1 fin_cases j <;> dsimp [Input.branchExpr] · apply FieldExpr.along_valid; exact ⟨trivial,hs⟩ · apply FieldExpr.along_valid; exact ⟨⟨trivial,hz⟩,hx⟩ · apply FieldExpr.along_valid; exact ⟨⟨trivial,hz⟩,hy⟩ · apply FieldExpr.along_valid; exact ⟨hz,hx⟩ · apply FieldExpr.along_valid; exact ⟨⟨trivial,hz⟩,hy⟩ · intro k; exact ⟨hz,trivial⟩ · apply FieldExpr.along_valid; exact ⟨trivial,ht⟩ theorem spatialExpr_valid {d : Input} (hd : ValidInput d) (j : Fin 7) : (d.spatialExpr j).Valid := fun k => FieldExpr.sum_ofFn_valid _ (fun i => branchExpr_valid hd i j k) theorem velocityExpr_valid {d : Input} (hd : ValidInput d) : d.velocityExpr.Valid := by intro k apply FieldExpr.sum_ofFn_valid intro j exact ⟨PeriodicExpr.pulse_valid j, spatialExpr_valid hd j k⟩ theorem spatialExpr_val {d : Input} (hd : ValidInput d) (j : Fin 7) (y : SpaceTime) : (d.spatialExpr j).val y = d.spatialFields j y.2 := by ext k change (FieldExpr.sum _).val y = _ rw [FieldExpr.sum_ofFn_val] fin_cases j <;> simp only [Input.spatialFields,sevenFields] all_goals simp only [Matrix.cons_val, Fin.reduceFinMk, Fin.isValue, Fin.zero_eta, transverseSum,Finset.sum_apply] apply Finset.sum_congr rfl intro i _ fin_cases k <;> simp [Input.branchExpr, FieldExpr.along, FieldExpr.val, sourceExpr_val hd, targetExpr_val hd,heightExpr_val hd, horizontalExpr_val, selectTwo, horizontal, basis, atHeight, RationalBox.centerQ_cast] all_goals left congr 1 ext k fin_cases k <;> rfl theorem velocityExpr_val {d : Input} (hd : ValidInput d) : d.velocityExpr.val = d.realizingVelocity := by funext y k change (FieldExpr.sum _).val y = _ rw [FieldExpr.sum_ofFn_val] simp only [FieldExpr.val,PeriodicExpr.pulse_val] change (∑ j, periodPulse j y.1 * (d.spatialExpr j).val y k) = _ simp only [Input.realizingVelocity,pulsedSum,Finset.sum_apply,Pi.smul_apply,smul_eq_mul] apply Finset.sum_congr rfl intro j _ rw [spatialExpr_val hd] end ShearFlows end end OAI