import Euler.PacketPhysicalSize import Euler.PacketMovingVelocity import Euler.PacketScaledVelocityAlgebra import Mathlib.LinearAlgebra.CrossProduct /-! The source's next-frame scalar formulas represent the actual normalized physical ray and velocity. Orientation, physical norms, and pressure numerators are identified exactly before any quantitative estimate is used. -/ /-! ## From `Euler/PacketOrientedCoordinates.lean` The text of `Euler/PacketOrientedCoordinates.lean`, folded into this file, which was its only importer. -/ section /-! Oriented cross products in the actual normalized primary frame. -/ noncomputable section namespace EulerPacketMovingFrame open EulerSmoothLimit EulerPacketCrossProduct InnerProductSpace ContinuousLinearMap WithLp def frameCoordinates (p q x : Space) (i : Fin 3) : ℝ := ⟪frame p q i,x⟫_ℝ def frameVector (p q : Space) (X : Fin 3 → ℝ) : Space := X 0 • p+X 1 • q+X 2 • cross p q theorem frameVector_coordinates (p q x : Space) (hp : ⟪p,p⟫_ℝ = 1) (hq : ⟪q,q⟫_ℝ = 1) (hpq : ⟪p,q⟫_ℝ = 0) : frameVector p q (frameCoordinates p q x) = x := by have h := (frameBasis p q hp hq hpq).sum_repr' x simp only [frameBasis_apply, Fin.sum_univ_three] at h dsimp [frame] at h exact h theorem cross_add_left (x y z : Space) : cross (x+y) z = cross x z+cross y z := by change crossBilinear (x+y) z = crossBilinear x z+crossBilinear y z simp only [map_add, add_apply] theorem cross_add_right (x y z : Space) : cross x (y+z) = cross x y+cross x z := by exact (crossBilinear x).map_add y z theorem cross_smul_left (a : ℝ) (x y : Space) : cross (a • x) y = a • cross x y := by change crossBilinear (a • x) y = a • crossBilinear x y simp only [map_smul, smul_apply] theorem cross_smul_right (a : ℝ) (x y : Space) : cross x (a • y) = a • cross x y := by exact (crossBilinear x).map_smul a y theorem cross_same (x : Space) : cross x x = 0 := by simp only [cross, _root_.cross_self, toLp_zero] theorem cross_swap (x y : Space) : cross y x = -cross x y := by simp only [cross, ← _root_.cross_anticomm (ofLp x) (ofLp y), toLp_neg] theorem cross_frameVector (p q : Space) (X Y : Fin 3 → ℝ) (hp : ⟪p,p⟫_ℝ = 1) (hq : ⟪q,q⟫_ℝ = 1) (hpq : ⟪p,q⟫_ℝ = 0) : cross (frameVector p q X) (frameVector p q Y) = frameVector p q (_root_.crossProduct X Y) := by have hp2 : ‖p‖^2 = 1 := by simpa only [real_inner_self_eq_norm_sq] using hp have hq2 : ‖q‖^2 = 1 := by simpa only [real_inner_self_eq_norm_sq] using hq have hqp : ⟪q,p⟫_ℝ = 0 := (real_inner_comm _ _).trans hpq have hpn : cross p (cross p q) = -q := by rw [EulerPacketCrossProduct.cross_cross, hpq, hp2, zero_smul, one_smul, zero_sub] have hqn : cross q (cross p q) = p := by rw [cross_swap q p] change (crossBilinear q) (-(cross q p)) = p rw [map_neg] change -(cross q (cross q p)) = p rw [EulerPacketCrossProduct.cross_cross, hqp, hq2, zero_smul, one_smul, zero_sub, neg_neg] have hnp : cross (cross p q) p = q := by rw [cross_swap p (cross p q), hpn, neg_neg] have hnq : cross (cross p q) q = -p := by rw [cross_swap q (cross p q), hqn] simp [frameVector, _root_.cross_apply, cross_add_left, cross_add_right, cross_smul_left, cross_smul_right, cross_same, hpn, hqn, hnp, hnq, cross_swap p q] module theorem frameVector_inner (p q z : Space) (X : Fin 3 → ℝ) : ⟪frameVector p q X,z⟫_ℝ = X 0*frameCoordinates p q z 0+X 1*frameCoordinates p q z 1+X 2*frameCoordinates p q z 2 := by dsimp [frameVector, frameCoordinates, frame] simp only [inner_add_left, real_inner_smul_left] /-- Cross-product and orientation errors cannot be hidden in a coordinate model: the triple product equals the actual oriented-frame expression. -/ theorem cross_inner_coordinates (p q x y z : Space) (hp : ⟪p,p⟫_ℝ = 1) (hq : ⟪q,q⟫_ℝ = 1) (hpq : ⟪p,q⟫_ℝ = 0) : ⟪cross x y,z⟫_ℝ = (_root_.crossProduct (frameCoordinates p q x) (frameCoordinates p q y)) 0*frameCoordinates p q z 0+ (_root_.crossProduct (frameCoordinates p q x) (frameCoordinates p q y)) 1*frameCoordinates p q z 1+ (_root_.crossProduct (frameCoordinates p q x) (frameCoordinates p q y)) 2*frameCoordinates p q z 2 := by calc _ = ⟪cross (frameVector p q (frameCoordinates p q x)) (frameVector p q (frameCoordinates p q y)),z⟫_ℝ := by rw [frameVector_coordinates p q x hp hq hpq, frameVector_coordinates p q y hp hq hpq] _ = _ := by rw [cross_frameVector p q _ _ hp hq hpq, frameVector_inner] end EulerPacketMovingFrame end end /-! ## From `Euler/PacketFrameRenewalAlgebra.lean` The text of `Euler/PacketFrameRenewalAlgebra.lean`, folded into this file, which was its only importer. -/ section /-! Exact scaled cross and pressure algebra used by physical frame renewal. -/ noncomputable section namespace EulerPacketMovingFrame open EulerPacketRay EulerPacketFrameStability theorem velocityNumerator_homogeneous (A : Fin 3 → Fin 3 → ℝ) (P Q N U V W : ℝ) (hV : V ≠ 0) : velocityNumerator A P Q N U V W = V*velocityNumerator A P Q N (U/V) 1 (W/V) := by unfold velocityNumerator field_simp theorem scaling_cross_flux {a : ℝ} (ha : a ≠ 0) (s₀ ε : ℝ) (M : Fin 3 → Fin 3 → ℝ) (R V : Fin 3 → ℝ) (hV : V 1 ≠ 0) : (∑ i : Fin 3, (_root_.crossProduct (fun j => s₀*rayScale ε j*R j) (fun j => velocityScale ε j*V j)) i * (∑ j : Fin 3, M i j*(velocityScale ε j*V j))) = s₀*a*(V 1)^2*frameCrossNumerator ε (R 0) (R 1) (R 2) (V 0/V 1) (V 2/V 1) (rowAction (scaledVelocityEntry a ε M) 0 (V 0/V 1) (V 2/V 1)) (rowAction (scaledVelocityEntry a ε M) 1 (V 0/V 1) (V 2/V 1)) (rowAction (scaledVelocityEntry a ε M) 2 (V 0/V 1) (V 2/V 1)) := by norm_num [Fin.sum_univ_three, _root_.cross_apply, velocityScale, rayScale, scaledVelocityEntry, frameCrossNumerator, rowAction, Fin.ext_iff, Matrix.cons_val_two, Matrix.tail_cons, Matrix.head_cons] field_simp ring end EulerPacketMovingFrame end end noncomputable section namespace EulerPacketMovingFrame open EulerSmoothLimit EulerPacketNormalizedPrimary EulerPacketCrossProduct EulerPacketRay EulerPacketFrameStability InnerProductSpace ContinuousLinearMap theorem physical_pressure_ratio (M : Space →L[ℝ] Space) (m v r w : ℝ → Space) {s₀ t₀ a ε τ : ℝ} (ha : a ≠ 0) (hs₀ : s₀ ≠ 0) (hε : ε ≠ 0) (hm : m (physicalTime t₀ a ε τ) ≠ 0) (hv : v (physicalTime t₀ a ε τ) ≠ 0) (hmv : ⟪m (physicalTime t₀ a ε τ),v (physicalTime t₀ a ε τ)⟫_ℝ = 0) (hV : scaledVelocity m v w t₀ a ε τ 1 ≠ 0) : let R := scaledRay m v r s₀ t₀ a ε τ let V := scaledVelocity m v w t₀ a ε τ let A := scaledAction M m v a ε (physicalTime t₀ a ε τ) ⟪r (physicalTime t₀ a ε τ),M (w (physicalTime t₀ a ε τ))⟫_ℝ = s₀*a*V 1*velocityNumerator A (R 0) (R 1) (R 2) (V 0/V 1) 1 (V 2/V 1) := by rw [← movingFlux_eq M m v r w _ hm hv hmv, movingFlux_scaling M m v r w ha hs₀ hε, velocityNumerator_homogeneous _ _ _ _ _ _ _ hV] dsimp only ring theorem physical_cross_ratio (M : Space →L[ℝ] Space) (m v r w : ℝ → Space) {s₀ t₀ a ε τ : ℝ} (ha : a ≠ 0) (hs₀ : s₀ ≠ 0) (hε : ε ≠ 0) (hm : m (physicalTime t₀ a ε τ) ≠ 0) (hv : v (physicalTime t₀ a ε τ) ≠ 0) (hmv : ⟪m (physicalTime t₀ a ε τ),v (physicalTime t₀ a ε τ)⟫_ℝ = 0) (hV : scaledVelocity m v w t₀ a ε τ 1 ≠ 0) : let R := scaledRay m v r s₀ t₀ a ε τ let V := scaledVelocity m v w t₀ a ε τ let A := scaledAction M m v a ε (physicalTime t₀ a ε τ) ⟪cross (r (physicalTime t₀ a ε τ)) (w (physicalTime t₀ a ε τ)), M (w (physicalTime t₀ a ε τ))⟫_ℝ = s₀*a*(V 1)^2*frameCrossNumerator ε (R 0) (R 1) (R 2) (V 0/V 1) (V 2/V 1) (rowAction A 0 (V 0/V 1) (V 2/V 1)) (rowAction A 1 (V 0/V 1) (V 2/V 1)) (rowAction A 2 (V 0/V 1) (V 2/V 1)) := by let p := unit (m (physicalTime t₀ a ε τ)) let q := unit (v (physicalTime t₀ a ε τ)) have hp : ⟪p,p⟫_ℝ = 1 := unit_inner_self hm have hq : ⟪q,q⟫_ℝ = 1 := unit_inner_self hv have hpq : ⟪p,q⟫_ℝ = 0 := unit_inner_zero hmv have hact (i : Fin 3) : frameCoordinates p q (M (w (physicalTime t₀ a ε τ))) i = ∑ j : Fin 3, frameMatrix M p q i j*movingVelocity m v w (physicalTime t₀ a ε τ) j := (frame_action M p q (w (physicalTime t₀ a ε τ)) hp hq hpq i).symm have hc : ⟪cross (r (physicalTime t₀ a ε τ)) (w (physicalTime t₀ a ε τ)), M (w (physicalTime t₀ a ε τ))⟫_ℝ = ∑ i : Fin 3, (_root_.crossProduct (movingRay m v r (physicalTime t₀ a ε τ)) (movingVelocity m v w (physicalTime t₀ a ε τ))) i * (∑ j : Fin 3, frameMatrix M p q i j*movingVelocity m v w (physicalTime t₀ a ε τ) j) := by have h := cross_inner_coordinates p q (r (physicalTime t₀ a ε τ)) (w (physicalTime t₀ a ε τ)) (M (w (physicalTime t₀ a ε τ))) hp hq hpq simp only [hact] at h have hR : frameCoordinates p q (r (physicalTime t₀ a ε τ)) = movingRay m v r (physicalTime t₀ a ε τ) := rfl have hW : frameCoordinates p q (w (physicalTime t₀ a ε τ)) = movingVelocity m v w (physicalTime t₀ a ε τ) := rfl rw [hR, hW] at h simpa only [Fin.sum_univ_three] using h rw [hc] have hR : movingRay m v r (physicalTime t₀ a ε τ) = fun j => s₀*rayScale ε j*scaledRay m v r s₀ t₀ a ε τ j := funext fun j => (scaledRay_restore m v r hs₀ hε j).symm have hW : movingVelocity m v w (physicalTime t₀ a ε τ) = fun j => velocityScale ε j*scaledVelocity m v w t₀ a ε τ j := funext fun j => (scaledVelocity_restore m v w hε j).symm rw [hR, hW] exact scaling_cross_flux ha s₀ ε (frameMatrix M p q) (scaledRay m v r s₀ t₀ a ε τ) (scaledVelocity m v w t₀ a ε τ) hV /-- Exact source (34) quantities for the actual next normalized frame. -/ theorem physical_frame_formulas (M : Space →L[ℝ] Space) (m v r w : ℝ → Space) {s₀ t₀ a ε τ : ℝ} (ha : a ≠ 0) (hs₀ : 0 < s₀) (hε : ε ≠ 0) (hm : m (physicalTime t₀ a ε τ) ≠ 0) (hv : v (physicalTime t₀ a ε τ) ≠ 0) (hmv : ⟪m (physicalTime t₀ a ε τ),v (physicalTime t₀ a ε τ)⟫_ℝ = 0) (hr : r (physicalTime t₀ a ε τ) ≠ 0) (hV : 0 < scaledVelocity m v w t₀ a ε τ 1) : let R := scaledRay m v r s₀ t₀ a ε τ let V := scaledVelocity m v w t₀ a ε τ let A := scaledAction M m v a ε (physicalTime t₀ a ε τ) let D := rayDenominator ε (R 0) (R 1) (R 2) let E := velocityDirectionNormSq ε (V 0/V 1) (V 2/V 1) let J := velocityNumerator A (R 0) (R 1) (R 2) (V 0/V 1) 1 (V 2/V 1) let C := frameCrossNumerator ε (R 0) (R 1) (R 2) (V 0/V 1) (V 2/V 1) (rowAction A 0 (V 0/V 1) (V 2/V 1)) (rowAction A 1 (V 0/V 1) (V 2/V 1)) (rowAction A 2 (V 0/V 1) (V 2/V 1)) normalizedCoupling M (r (physicalTime t₀ a ε τ)) (w (physicalTime t₀ a ε τ))/a = J/(Real.sqrt D*Real.sqrt E) ∧ normalizedTilt M (r (physicalTime t₀ a ε τ)) (w (physicalTime t₀ a ε τ)) = C/(J*Real.sqrt E) := by let R := scaledRay m v r s₀ t₀ a ε τ let V := scaledVelocity m v w t₀ a ε τ let A := scaledAction M m v a ε (physicalTime t₀ a ε τ) let D := rayDenominator ε (R 0) (R 1) (R 2) let E := velocityDirectionNormSq ε (V 0/V 1) (V 2/V 1) let J := velocityNumerator A (R 0) (R 1) (R 2) (V 0/V 1) 1 (V 2/V 1) let C := frameCrossNumerator ε (R 0) (R 1) (R 2) (V 0/V 1) (V 2/V 1) (rowAction A 0 (V 0/V 1) (V 2/V 1)) (rowAction A 1 (V 0/V 1) (V 2/V 1)) (rowAction A 2 (V 0/V 1) (V 2/V 1)) change normalizedCoupling M (r (physicalTime t₀ a ε τ)) (w (physicalTime t₀ a ε τ))/a = J/(Real.sqrt D*Real.sqrt E) ∧ normalizedTilt M (r (physicalTime t₀ a ε τ)) (w (physicalTime t₀ a ε τ)) = C/(J*Real.sqrt E) have hs₀ne := ne_of_gt hs₀ have hVne : V 1 ≠ 0 := ne_of_gt hV have hEpos : 0 < E := velocityDenominator_pos ε (V 0/V 1) (V 2/V 1) have hrootE : Real.sqrt E ≠ 0 := ne_of_gt (Real.sqrt_pos.mpr hEpos) have hDne : D ≠ 0 := scaled_denominator_ne_zero m v r hs₀ne hε hm hv hmv hr have hDpos : 0 < D := by have hD0 : 0 ≤ D := by dsimp [D, rayDenominator]; positivity exact lt_of_le_of_ne hD0 (Ne.symm hDne) have hrootD : Real.sqrt D ≠ 0 := ne_of_gt (Real.sqrt_pos.mpr hDpos) have hrn : ‖r (physicalTime t₀ a ε τ)‖ = s₀*Real.sqrt D := by simpa only [abs_of_pos hs₀] using scaledRay_norm m v r hs₀ne hε hm hv hmv have hwn : ‖w (physicalTime t₀ a ε τ)‖ = V 1*Real.sqrt E := by simpa only [abs_of_pos hV, E, V, velocityDirectionNormSq, velocityDenominator] using scaledVelocity_norm_ratio m v w hε hm hv hmv hVne have hw : w (physicalTime t₀ a ε τ) ≠ 0 := by intro hz rw [hz, norm_zero] at hwn exact (mul_ne_zero hVne hrootE) hwn.symm have hflux : ⟪r (physicalTime t₀ a ε τ),M (w (physicalTime t₀ a ε τ))⟫_ℝ = s₀*a*V 1*J := physical_pressure_ratio M m v r w ha hs₀ne hε hm hv hmv hVne have hcross : ⟪cross (r (physicalTime t₀ a ε τ)) (w (physicalTime t₀ a ε τ)), M (w (physicalTime t₀ a ε τ))⟫_ℝ = s₀*a*(V 1)^2*C := physical_cross_ratio M m v r w ha hs₀ne hε hm hv hmv hVne constructor · rw [normalizedCoupling_eq, hflux, hrn, hwn] field_simp · by_cases hJ : J = 0 · have hz : normalizedCoupling M (r (physicalTime t₀ a ε τ)) (w (physicalTime t₀ a ε τ)) = 0 := by rw [normalizedCoupling_eq, hflux, hJ, mul_zero, zero_div] simp only [normalizedTilt, hz, hJ, zero_mul, div_zero] · have hfluxne : ⟪r (physicalTime t₀ a ε τ),M (w (physicalTime t₀ a ε τ))⟫_ℝ ≠ 0 := by rw [hflux] exact mul_ne_zero (mul_ne_zero (mul_ne_zero hs₀ne ha) hVne) hJ rw [normalizedTilt_eq M _ _ hr hw hfluxne, hflux, hcross, hwn] field_simp end EulerPacketMovingFrame