import YM.Next.SCHEDULE.Circuit import YM.Work.A05.Window import YM.Work.B09.Shell /-! # Issue path-label derivative bills PricePoint and Projection actual hit costs for 𝒒 path labels. For cubic & quartic with actual Ξ² ratio at band, these costs with an extra length reserve attain a size gasket before recursions. Use also with posterior activation of e.g. contour price requests. Not an account of the subsequent near-integral costs. This price is period independent. -/ set_option autoImplicit false noncomputable section namespace YM.Next.Scheduling open Wages Lattice Corona RG RG.Supply Bid Clock Instrument Pressure Precision open Filter Function open scoped Topology Matrix.Norms.Frobenius BigOperators variable {G : Gauge} -- Invoice independent of all Roll parameters except approved M, L, ancestry q costs. def tollRate (s : Survey G) (q : Quote) (e : Exchange) (j : β„•) (d k : β„•) (L B : β„•) : ℝ := footprintCost s j e d L B * fund G (s.o.P j) (s.o.k j) k (s.o.A j) (q.widths.width j) lemma fund_pos (G : Gauge) (P k d) (a Οƒ : ℝ) (h : 0 < Οƒ) : 0 < Wages.fund G P d k a Οƒ := by have hs : 0 < Wages.startup G k P d := by unfold Wages.startup; have ht:=lt_of_lt_of_le zero_lt_one (slot_ge G P d 0); positivity unfold Wages.fund apply mul_pos (mul_pos hs (Real.exp_pos _)) unfold momentCost let c:=grade k P d have hj:= decay_summable c (Οƒ/4) (by positivity) have h:=hj.sum_le_tsum ({0}:Finset β„•) (fun i _ => by unfold decay; positivity) apply lt_of_lt_of_le _ h; simp [decay] private lemma tollShape (s : Survey G) (q : Quote) (e : Exchange) (j d k L B) : tollRate s q e j d k L B=tollRate s q e j d k L 1*(B:ℝ)^ (4:β„•) := by unfold tollRate footprintCost; push_cast; ring /-- All costs at the step relevant to testing the Atom from the input. `d` a booked polynomial power in downstream cover size; any finite power chosen at the stage fits. If a caller works at order or tests higher than that booked, they must issue new gates. -/ structure Loan (s : Survey G) (q : Quote) (e : Exchange) (x y : ℝ) (d j L : β„•) : Prop where fit : let a:=s.o.A j; let Οƒ:=q.widths.width j; a / ↑(plain.body y) ≀ Οƒ/4 lens : plain.body y ≀ 2*plain.body x paths (Ξ² : ℝ) : inBand y Ξ² β†’ βˆ€ k∈ Finset.Icc 3 4, tollRate s q e j d k L (plain.body x)*(q.classicalCost.cap j)*Ξ²*(plain.t y)^k ≀ Real.sqrt (gap y) loops (ΞΈ : ℝ) : 0 < ΞΈ β†’ ΞΈ ≀ 1 β†’ tollRate s q e j d 2 L (plain.body x)*(2*LevelCost ΞΈ y)*(plain.t y)^ (2:β„•) ≀ Real.sqrt (gap y) open Real in lemma Loan.prepare (s : Survey G) (q : Quote) (e : Exchange) (c : ℝ) (d j L : β„•) (hh : 1 ≀ L) : βˆ€αΆ  x : ℝ in atTop, Loan s q e x (x+c) d j L := by let H k B:=tollRate s q e j d k L B have hL0 (k) : 0 < H k 1 := by unfold H tollRate; exact mul_pos (footprintCost_pos _ _ _ _ _ _ hh zero_lt_one) (fund_pos G _ _ _ _ _ (q.widths.wp j)) let C:=q.classicalCost.cap j; have hC :0.eventually (ge_mem_nhds (show 0 < q.widths.width j/4 from div_pos (q.widths.wp j) (by norm_num)))] with y hy simpa [Instrument.body,plain] using hy filter_upwards [advance (hx.and ((ha 3).and ((ha 4).and (hb.and ((plain.pitched.and hk)) )))), just_near c,plain.support 2 one_lt_two] with x hp hN hP let y:=x+c obtain ⟨hh0,hx3,hx4,hb,⟨hm,hs0,ht0,hy⟩,hE0⟩:=hp y hN obtain ⟨hBx,-⟩:=hp x (Clock.same x) have hp := hP _ _ (Clock.same x) hN have hc := hp.mass.2 have he : (plain.body x:ℝ) ≀ 2*plain.P y := le_trans hBx hp.peek.1 have ht : 0 ?_,fun ΞΈ hΞΈ hΞΈ' => ?_⟩ Β· dsimp only at hc exact_mod_cast hc Β· obtain ⟨h1,h2⟩:=Finset.mem_Icc.mp hk have hu : Ξ² ≀ 4*y := hB.2 have hz : 0 ≀ Ξ² := le_trans (show 0 ≀ y/4 by linarith) hB.1 have ha : plain.t y^k ≀ plain.t y^ (3:β„•) := pow_le_pow_of_le_one ht.le hy h1 have hR : (H k 1* (2*plain.P y)^ (4:β„•))*C*(4*y)*plain.t y^ (3:β„•) ≀ Real.sqrt (gap y) := by rw [show (H k 1* (2*plain.P y)^ (4:β„•))*C*(4*y)*plain.t y^ (3:β„•)=H k 1*2^ (4:β„•)*C*4*y*(plain.P y)^ (4:β„•)*(plain.t y)^ (3:β„•) by ring] have he : k=3∨ k=4 := by omega rcases he with rfl|rfl Β· exact hx3 exact hx4 refine le_trans ?_ hR apply mul_le_mul _ ha (pow_nonneg ht.le _) _ Β· exact mul_le_mul (mul_le_mul_of_nonneg_right (hE k) hC.le) hu hz (mul_nonneg (hEO k) hC.le) exact mul_nonneg (mul_nonneg (hEO k) hC.le) (by linarith) have ha : LevelCost ΞΈ y ≀ plain.P y := (Real.rpow_le_rpow_of_exponent_le ht0 hΞΈ').trans_eq (Real.rpow_one _) have hrP : 0 < LevelCost ΞΈ y:=Real.rpow_pos_of_pos (wp _ _) _ apply le_trans _ hb; exact mul_le_mul_of_nonneg_right (mul_le_mul (hE 2) (mul_le_mul_of_nonneg_left ha (by norm_num)) (by positivity) (hEO 2)) (sq_nonneg _) variable {s : Survey G} {K : MapPrices} {q : Quote} {e : β„• β†’ β„• β†’ Exchange} {v : β„• β†’ β„•} variable {D : Rolls (s.paper q v)} {Θ : Protection D} /-- Addition to W issuance; preserves all other charges exactly. Estimate powers d of cover for receiving CRT at the current level chosen beforehand, not at R. -/ def Routed (e : β„• β†’ β„• β†’ Exchange) (d : β„• β†’ β„•) (V : Delays Θ) := βˆ€ j i, Adj j i β†’ βˆ€ x β‰₯ V.betaEntry j, Loan s q (e j i) x (x+G.slopeConstant*Real.log (D.L j).val) (d j) j (D.L j).val lemma Routed.ready (e) (d) (V : Delays Θ) : βˆƒ W, Boost V W ∧ Routed e d W := by have hx j i := Loan.prepare s q (e j i) (G.slopeConstant*Real.log (D.L j).val) (d j) j _ (D.L j).property choose x hx using fun i => eventually_atTop.mp ((hx i i).and (hx i (i-1))) let W : Delays Θ := { V with betaEntry := fun i => max (V.betaEntry i) (x i) } refine ⟨W, ⟨fun i => le_max_left ..,le_rfl,le_rfl,le_rfl⟩,fun j i hg u hh => ?_⟩ have ht := hx j u (le_trans (le_max_right ..) hh) rcases hg.cases_back with rfl|rfl Β· exact ht.1 exact ht.2 namespace Deployment variable {W : Delays Θ} {Y : Bar W} {I : Wait Y} {a : Levels G} {d : β„• β†’ β„•} def coverage {G : Gauge} {k : β„•} {c f : Side} (s : Survey G) (C : Exchange) (q : Quote) (j d) (H : Ratio c f) (P B : BudgetPoint) (T : β„• β†’ Atom G k) (weight Ξ΄ : ℝ) := let Οƒ:= (s.melt q j).width -- same d-cover cost as E/K; horizon assertion does not consume unknown true length moments let X (i : Site f Γ— β„•) := (T i.2).footprint i.1 -- certificate through true ORDER. Includes arbitrary path derivative moments all labels jointly (βˆ€ (o : Site f) i,P.supBounds o (X (o,i)) (fun U => (T i).unmasked U o) (price P (T i))) ∧ βˆ€ S : Site f Γ— β„• β†’ Support c, (βˆ€ i,Footage H C.radius B.B (X i) (S i)) β†’ βˆ€ p ∈ Set.Icc 0 C.extra, βˆ€ y : Site c, SumBudget (fun i => weight * (if y∈S i then Real.exp ((B.supportExponent + p)*coverNumber B.B (S i)+foundation s C j/4*coverNumber P.B (X i))* ((coverNumber P.B (X i):ℝ)+1)^d*Wages.toll P Οƒ (T i.2) else 0)) Ξ΄ end Deployment end YM.Next.Scheduling