import YM.Next.RANK.Incoming import YM.Next.RANK.Voucher /-! # This charge can be scheduled (in isolation) Freeze a pre/post catalogue *before* choosing the clock. This only checks Tally and determinant can in fact be paid in the numerical receipts in RPost when entrance of W and restart and upper rank equations etc available. More tests must be simultaneous, poses **no** Factory existence claim. Don't apply this to a lagging B-j clock then raise the receipts after without redoing upstream. -/ set_option autoImplicit false noncomputable section namespace YM.Next.Rank.Peak open Lattice Perch Filter Asymptotics Real RG RG.Supply Set Ship Station open scoped Topology BigOperators Classical variable {G : Gauge} {p : Sheet G} {w : Rolls p} {T : Protection w} {D : Delays T} (Z : Bar D) -- Cost of h stretch in sigma confined to s/2. Here j param fixed under InWindow, not chosen by this gate. def cardTest (O : HaarBudget G) (k m : ℕ) (b : ℝ) (d : Era) (s : ℝ) := Tally ((w.L k).val:ℝ) (preHat Z s) d m ∧ (benchCost Z b k s:ℝ)*Real.log (w.L k).val*G.slopeConstant ≤ preHat Z s/2 ∧ Station.ticket O (p.profile k) m ≤ amount Z m s theorem reserves (h : G.Simple) (k m : ℕ) (hm : 0 reserves Z h j _ (hm i) _ (hb i) (E j i) O) choose v hv using fun j => eventually_atTop.mp (he j) let W : Wait Z := { P with readyHere := fun j => max (P.readyHere j) (v j) } refine ⟨W,hL,fun j => ⟨(hs j).1.trans (le_max_left ..), (hs j).2⟩,fun j i hi s h => ?_⟩ exact ⟨hv j s ((le_max_right ..).trans h) i hi,(hP j i hi s ((le_max_left ..).trans h)).2⟩ variable {Z} lemma held_at (B : Wait Z) (a : Levels G) (h : Paid B a) {j k : ℕ} (hb : p.first ?_⟩,?_⟩ · by_contra! hj; rw [Nat.le_zero.mp hj,h.firstZero] at hk; omega · apply (hm i ?_ hb).trans hk.symm unfold width middle at ha; change k-B.window j s ≤ _; omega rw [ht]; unfold amount at T; rw [he] at T; exact T rw [he,← hp] at H refine ⟨hA,H,fun i hk hi => ?_⟩ have hv := (Stock.a_log a.S i); have he' := hA.permitted.scales i k hk (hi.trans (before ..)) le_rfl have hi' : a.S.scale k-a.S.scale i=(k-i:ℕ)*Real.log u := by have hb := congr_arg Real.log he' rw [Real.log_div (a.S.a_pos _).ne' (a.S.a_pos _).ne',Real.log_pow] at hb rw [hv,Stock.a_log] at hb; simp only [Real.log_exp] at hb; linarith only [hb] have H' : 0 ≤ Real.log u := (Real.log_pos hA.permitted.large).le have hz : k-i ≤ height a b k + surplus a k := by unfold width middle at hk; omega have ha := Gauge.slopeConstant_pos hg; refine ⟨?_,?_⟩ · have hy : (k-i:ℕ)*Real.log u*G.slopeConstant ≤ a.clock.hatBeta k/2 := by refine le_trans ?_ I; gcongr; exact_mod_cast hz dsimp only [Calendar.hatBeta] at hy ⊢; rw [← hi'] at hy; linarith only [hy] have ht : 0 ≤ a.S.scale k-a.S.scale i := hi' ▸ mul_nonneg (Nat.cast_nonneg _) H' exact add_le_add_right (mul_le_mul_of_nonneg_left (sub_nonneg.mp ht) ha.le) _ -- Allocation channel support, no changing Era or Paid at the stage after costs. end YM.Next.Rank.Peak