import YM.AnalyticNext.CONNECTED_ACTIVITY_BOUNDS.FrameCosts import YM.AnalyticNext.CONNECTED_ACTIVITY_BOUNDS.Station import YM.AnalyticNext.CONNECTED_ACTIVITY_BOUNDS.Veil /-! # Forecast the REAL affine remainder on the local unmasked arguments Each piece estimated before regrouping. Polynomial costs all here post-L, paid at fixed stencil and order. Don't estimate actual output on a forest using only one period norm for analytic germs; these all-period invoices involve each actual `T` and its path/alignment costs. -/ set_option autoImplicit false noncomputable section namespace YM.AnalyticNext.ConnectedActivity.Aff open Function Lattice RG Precision Wilson Pressure Pressure.Stores Exterior Bloch Turn open Matrix Work.F03 Progress.StationaryScenes Push.SectorMeasure Push.SectorMeasure.Oriented open Push.AbsoluteSums Tree Next.Fluctuations Finset Filter open scoped Topology BigOperators Matrix.Norms.Frobenius Classical variable {G : Gauge} {c f n : Side} {S : StepData c f} def forecast (T : Tube G S) (p : Pos S) (a : LogField G f) (b : LogField G c) := let x := orient p.1 a let y := orient p.1 b p.2.elim (fun i => xLin T.high T.up x i-Fout T y i) (fun i => zLin S x y i-Qout T y i) -- This will give a forecast even for N (affine complement, needed on V) def Guess (u v : G.Color) (A h w : ℝ) := ‖v‖ ≤ A*h ∧ ‖u-v‖ ≤ A*h*w lemma Guess.loosen {u v : G.Color} {A h w B e : ℝ} (he : Guess u v A h w) (hh : 0≤h) (hv : 0≤w) (hB : 0≤B) (hy : A ≤ B) (hw : w≤e) : Guess u v B h e := ⟨he.1.trans (by gcongr),he.2.trans (by gcongr)⟩ lemma Guess.subtract {u v a b : G.Color} {A B h w : ℝ} (he : Guess u v A h w) (hh : Guess a b B h w) : Guess (u-a) (v-b) (A+B) h w := by constructor · exact (norm_sub_le ..).trans ((add_le_add he.1 hh.1).trans_eq (add_mul A B h).symm) rw [show u-a-(v-b)=(u-v)-(a-b) by abel]; exact (norm_sub_le ..).trans ((add_le_add he.2 hh.2).trans_eq (by ring)) -- Analogous to EBare's interior L. zip first rather than maxtnorm of covariance. private lemma ghost {X Y : Type} [Fintype X] [Fintype Y] (F W : X → Y → Pay G) (f v : Y → G.Color) {A D h w : ℝ} (hA : 0≤A) (hD : 0≤D) (hh : 0≤h) (hw : 0≤w) (hf : NearFlat F W A w) (he : ∀ i, Guess (f i) (v i) D h w) : ∀ x, Guess (zip F f x) (zip W v x) (2*A*D) h w := by intro i; constructor · apply (Work.E07.zip_uniform W v i (hf.full.rows i) (show 0≤D*h by positivity) (fun j => (he j).1)).trans nlinarith [mul_nonneg (mul_nonneg hA hD) hh] rw [show zip F f i-zip W v i=zip F (f-v) i+zip (F-W) v i by unfold zip; simp only [Pi.sub_apply,map_sub,_root_.sub_apply,sum_sub_distrib]; abel] exact (norm_add_le ..).trans ((add_le_add (Work.E07.zip_uniform F (f-v) i (hf.cut.rows i) (show 0≤D*h*w by positivity) (fun j => (he j).2)) (Work.E07.zip_uniform (F-W) v i (hf.close.rows i) (show 0≤D*h by positivity) (fun j => (he j).1))).trans_eq (by ring)) lemma orient_norm (s : Signed) (x : LogField G n) : ‖orient s x‖ ≤ ‖x‖ := by refine (pi_norm_le_iff_of_nonneg (norm_nonneg _)).mpr (fun i => ?_) unfold orient Aff.form; rw [maps_cost]; exact norm_le_pi_norm x _ lemma ordered_cost (P : Teller G) (D : Patch) (hb : D.Branches P.bind G) : ∃ C τ r : ℝ, 0 simp [hh] lemma forecast_step {P : Teller G} {T : Tube G S} (hp : P.Funds S T) (p : Pos S) (x y : LogField G f) (b : LogField G c) : forecast T p (x+y) b=forecast T p x b + forecast T p y 0 := by let h := hp.feeds; obtain ⟨C,L,h1,h2⟩ := h rw [← hp.high] at h1 have hv (a : LogField G f) (b : LogField G f) (i : Twin f) : xLin T.high T.up (a+b) i=xLin T.high T.up a i+xLin T.high T.up b i := by have he (p : Cell f) : faceCurl p (a+b)=faceCurl p a+faceCurl p b := by conv_lhs => rw [← form_collect (a+b),show collect G (a+b) = collect G a+collect G b from rfl] rw [← form_collect a, ← form_collect b]; simp only [collect_form]; apply curl_add -- loops check unfold xLin ellLine; split next => simp only [he,smul_add]; exact (ellLine_summable _ h1 ..).tsum_add (ellLine_summable _ h1 ..) next => rw [he,smul_add] have hZ : Limage T (0:LogField G c)=0 := funext (x_zero T.low T.down) have he i (x y : LogField G f) (b : LogField G c) : zLin S (x+y) b i=zLin S x b i + zLin S y 0 i := by ext k; simp only [zLin,PiLp.add_apply,PiLp.sub_apply,PiLp.smul_apply, Pi.zero_apply,PiLp.zero_apply] rw [show parts G 1 (x+y) k=parts G 1 x k+parts G 1 y k from rfl, Matrix.mulVec_add,Pi.add_apply]; module rcases p with ⟨s,i|i⟩ · simp only [forecast,orient_plus,hv,orient_zero,Fout,hZ,Sum.elim_inl]; unfold zip; simp only [Pi.zero_apply, map_zero,Finset.sum_const_zero,sub_zero]; abel simp only [forecast, orient_plus, he,orient_zero,Qout,hZ,Sum.elim_inr]; unfold zip; simp only [Pi.zero_apply, map_zero,Finset.sum_const_zero,sub_zero]; abel lemma leave (P : Teller G) (x : ℝ) (T : Tube G S) (hp : P.Funds S T) (p : Pos S) (w : Directions G f) (a : ℝ) (ha : 0 ≤ a) (hx : ∀ i, ‖w i‖ ≤ a) : ‖forecast T p (form w) 0- derivative T (till x) p 1 w‖ ≤ Real.exp (-P.top.width*till x)*P.top.paths*4*a := by obtain ⟨L,C,hA,hV⟩ := hp.feeds have hH : Limage T 0=0 := funext (x_zero T.low T.down) have he : untwine S p 1 w=maps p.1 1 w := by unfold untwine; rw [replica_one,show pull p.1 0 (1:Config G c)=1 from funext fun i => by simp [pull,Step.read]] funext; simp [rotateG,corner_flat] have hu : orient p.1 (form w)=form (untwine S p 1 w) := by rw [he,orient,collect_form] have hv v : ‖untwine S p 1 w v‖ ≤ a := by rw [pull_cost]; exact hx _ let R := till x let B := Real.exp (-P.top.width*R) have hb : 0≤B := (Real.exp_pos _).le have hy : 0 < P.top.paths := P.top.paths_pos rcases p with ⟨s,⟨i,y⟩|i⟩ · unfold forecast derivative; dsimp only [Sum.elim_inl] rw [hu,orient_zero,Fout,hH,show zip (flatF T) 0 (i,y)=0 from by simp [zip],sub_zero,level,xLin]; split next hy => let z := untwine S (s,Sum.inl (i,y)) (1:Config G c) w let u (l : ℕ) := (T.up.row i.2 l).1 • curl (slotFace (T.up.row i.2 l).2 i.1) z let v l := bandTerm T R i l z have hu : Summable u := ellLine_summable _ hA .. have h2 : Summable v := band_summable hp .. change ‖(∑' l,u l)- ∑' l, v l‖ ≤ B*P.top.paths*4*a rw [← hu.tsum_sub h2] let A l := |(T.up.row i.2 l).1| * Real.exp (P.top.width*(T.up.row i.2 l).2.length) have H : SumBudget A P.top.paths := hA.rows _ have hf l : ‖u l-v l‖ ≤ A l * (4*a*B) := by unfold v bandTerm; split next ht => unfold u; rw [sub_self,norm_zero]; unfold A; positivity next ht => rw [sub_zero]; unfold u; rw [norm_smul]; unfold A let X := (T.up.row i.2 l).1 let L := (T.up.row i.2 l).2.length have hp := P.top.width_pos have hh : 1 ≤ Real.exp (P.top.width*L)*B := by unfold B; rw [← Real.exp_add]; apply Real.one_le_exp have he : (R:ℝ) ≤ L := Nat.cast_le.mpr ((Nat.lt_of_not_ge ht).le) linarith only [mul_le_mul_of_nonneg_left he hp.le] apply le_trans (mul_le_mul_of_nonneg_left (curl_cost _ _ _ hv) (norm_nonneg _)) calc ‖X‖*(4*a) ≤ ‖X‖*(4*a)*(Real.exp (P.top.width*L)*B) := le_mul_of_one_le_right (by positivity) hh _ = _ := by rw [Real.norm_eq_abs]; unfold L X; ring have hs := (H.2.1.mul_right (4*a*B)).of_nonneg_of_le (fun l => norm_nonneg _) hf calc _ ≤ ∑' l,A l *(4*a*B) := (norm_tsum_le_tsum_norm hs).trans (hs.tsum_le_tsum hf (H.2.1.mul_right _)) _ ≤ P.top.paths*(4*a*B) := by rw [tsum_mul_right]; gcongr; exact H.2.2 _ = _ := by ring next => rw [sub_self,norm_zero]; positivity unfold forecast derivative; dsimp only [Sum.elim_inr] rw [hu,orient_zero,Qout,hH, show zip (flatI T) 0 i=0 from by simp [zip], sub_zero,sub_self,norm_zero]; positivity end YM.AnalyticNext.ConnectedActivity.Aff