import Mathlib import OAI.Combinatorics.KServer.AllocationSchedule namespace OAI /-! The actual rankwise caps used by the star construction: core flags and both endpoint trackers run for the full history, not only at output times. -/ noncomputable section open scoped BigOperators open Finset namespace KServer.TrackedCaps attribute [local instance] Classical.propDecidable Classical.decEq open RankTracking RankFunctions CoreFlags variable {Ω R : Type} [Fintype Ω] [Fintype R] {w : Ω → ℝ} def count (P : R → FilteredRanks w) (t : ℕ) (ω : Ω) : ℝ := ∑ r, if flag (P r) t ω then 1 else 0 def core (P : R → FilteredRanks w) (t : ℕ) (ω : Ω) : ℝ := ∑ r, if flag (P r) t ω then (P r).p t ω else 0 def flex (P : R → FilteredRanks w) (z : ℝ) (t : ℕ) (ω : Ω) : ℝ := ∑ r, if flag (P r) t ω then 0 else rank z ((P r).p t ω) def estimate (P : R → FilteredRanks w) (ξ a : ℝ) (t : ℕ) (ω : Ω) : ℝ := ∑ r, if flag (P r) t ω then 0 else FineCaps.interpolated ξ a (P r) t ω def cap (P : R → FilteredRanks w) (ξ a κ : ℝ) (t : ℕ) (ω : Ω) : ℝ := ∑ r,FineCaps.capTerm ξ a κ (P r) t ω lemma cap_eq (P : R → FilteredRanks w) (ξ a κ : ℝ) (t : ℕ) (ω : Ω) : cap P ξ a κ t ω=count P t ω+κ*estimate P ξ a t ω := by unfold cap count estimate rw [mul_sum,←sum_add_distrib] apply sum_congr rfl intro r _ unfold FineCaps.capTerm split_ifs <;> ring lemma count_nonneg (P : R → FilteredRanks w) (t : ℕ) (ω : Ω) : 0≤count P t ω := by exact sum_nonneg fun r _=>by split_ifs <;> norm_num lemma core_nonneg (P : R → FilteredRanks w) (t : ℕ) (ω : Ω) : 0≤core P t ω := by exact sum_nonneg fun r _=>by split_ifs; exact ((P r).range t ω).1; rfl lemma flex_nonneg (P : R → FilteredRanks w) {z : ℝ} (hz : z∈Set.Icc 0 (1/100:ℝ)) (t : ℕ) (ω : Ω) : 0≤flex P z t ω := by exact sum_nonneg fun r _=>by split_ifs; rfl; exact rank_nonneg hz _ lemma decomposition (P : R → FilteredRanks w) (z : ℝ) (t : ℕ) (ω : Ω) : (∑ r,rank z ((P r).p t ω))=count P t ω-(3+z)*core P t ω+flex P z t ω := by unfold count core flex rw [mul_sum,←sum_sub_distrib,←sum_add_distrib] apply sum_congr rfl intro r _ cases hf : flag (P r) t ω with | false => simp | true => have h:=core_upper (P r) hf have hp : (P r).p t ω≤pstar := by norm_num [pstar] at *; linarith simp only [ite_true,add_zero,rank,ite_eq_left hp] lemma domination (P : R → FilteredRanks w) {z : ℝ} (hz : z∈Set.Icc 0 (1/100:ℝ)) (t : ℕ) (ω : Ω) : count P t ω+flex P z t ω≤36*CoarseProcess.size P t ω := by unfold count flex CoarseProcess.size rw [←sum_add_distrib,mul_sum] apply sum_le_sum intro r _ cases hf : flag (P r) t ω with | false => simpa using CoarseScale.rank_size hz ((P r).range t ω).1 | true => have hp : (P r).p t ω ≤ sstar := by have h:=core_upper (P r) hf norm_num [sstar] at * linarith have h:=CompatibleBounds.sizeRank_below_cutoff hp simp only [ite_true,add_zero] linarith lemma flex_antitone (P : R → FilteredRanks w) (t : ℕ) (ω : Ω) : Antitone (fun z=>flex P z t ω) := by intro z z' h apply sum_le_sum intro r _ split_ifs · rfl · exact rank_parameter_antitone ((P r).range t ω).1 h lemma flex_slack (P : R → FilteredRanks w) {z z' : ℝ} (hz : z∈Set.Icc 0 (1/100:ℝ)) (hzz : z≤z') (t : ℕ) (ω : Ω) : (z'-z)/96*flex P z t ω≤flex P z t ω-flex P z' t ω := by unfold flex rw [mul_sum,←sum_sub_distrib] apply sum_le_sum intro r _ cases hf : flag (P r) t ω with | true => simp | false => simp only [Bool.false_eq_true,ite_false] have hp : pstar/4≤(P r).p t ω := by have h:=noncore_lower (P r) hf norm_num [pstar] at * linarith have h:=mul_le_mul_of_nonneg_left (parameterSlope_compare hz hp).1 (sub_nonneg.mpr hzz) rw [rank_parameter_affine z,rank_parameter_affine z'] rw [rank_parameter_affine z] at h nlinarith lemma estimate_error (P : R → FilteredRanks w) {ξ a z ε : ℝ} (hξ : 0<ξ) (ha : a∈Set.Icc 0 1) (hz : z∈Set.Icc 0 (1/100:ℝ)) (hza : z≤a/100) (hea : a/100-z≤ε) (t : ℕ) (ω : Ω) : |estimate P ξ a t ω-flex P z t ω|≤(ξ+ε)*flex P z t ω := by unfold estimate flex rw [←sum_sub_distrib,mul_sum] apply (abs_sum_le_sum_abs _ _).trans apply sum_le_sum intro r _ cases hf : flag (P r) t ω with | true => simp | false => simpa using FineCaps.noncore_interpolation_error hξ ha hz hza hea (P r) t ω hf lemma scaled_bounds (P : R → FilteredRanks w) {ξ a z z' ε l g b : ℝ} (hξ : 0<ξ) (ha : a∈Set.Icc 0 1) (hz : z∈Set.Icc 0 (1/100:ℝ)) (hza : z≤a/100) (hea : a/100-z≤ε) (hε : 0≤ε) (hl : 0key s ω) t) def sides (δ : ℝ) (P : J → R → FilteredRanks w) (key : ℕ → Ω → K) (t : ℕ) (ω : Ω) : Finset J := match mark δ P key t ω with | none=>∅ | some o=>(activeSet (vector cutoff δ P ω t)).erase o def coarseFlex (δ : ℝ) (P : R → FilteredRanks w) (t : ℕ) (ω : Ω) : ℝ := ∑ r,if CoreFlags.flag (P r) t ω then 0 else FineCaps.estimate δ 0 (P r) t ω def scale (δ : ℝ) (P : J → R → FilteredRanks w) (key : ℕ → Ω → K) (t : ℕ) (ω : Ω) : ℝ := match mark δ P key t ω with | none=>0 | some o=>coarseFlex δ (P o) t ω def sideFlags (δ : ℝ) (P : J → R → FilteredRanks w) (key : ℕ → Ω → K) (t : ℕ) (ω : Ω) : J → R → Bool := fun i r=>if i∈sides δ P key t ω then CoreFlags.flag (P i r) t ω else false def logs (δ : ℝ) (P : J → R → FilteredRanks w) (key : ℕ → Ω → K) (t : ℕ) (ω : Ω) : J → ℝ := fun i=>max 1 (weight δ (vector cutoff δ P ω) (fun s=>key s ω) t i) def input {cw ell : ℝ} (hcw : 0le_max_left _ _), fun ir=>(P ir.1 ir.2).p t ω, epoch (vector cutoff δ P ω) (fun s=>key s ω) t⟩ def proportion {cw ell : ℝ} (hcw : 0key s ω) (vector_nonneg cutoff δ P ω) (fun s=>vector_total hδ hδu P s ω (hs s ω)) (fun s i hi=>vector_floor hδ hδu P s ω i hi) t i lemma feasible {δ k cw : ℝ} (hδ : 0<δ) (hδu : δ≤1/1000) (hk : 1≤k) (hcw : 0((P ir.1 ir.2).range t ω).1 have hf : ∀ i∉d.data.active,∀ r,d.data.flags i r=false := by intro i hi r change i∉sides δ P key t ω at hi change sideFlags δ P key t ω i r=false simp only [sideFlags,ite_eq_right hi] have h:=CausalSide.run_feasible (input hcw hel δ P key b) (M:=5) t ω hb (scale_nonneg δ P key t ω) hM hW hp hf dsimp only [a,proportion,d] simpa only [show (8:ℝ)*5=40 by norm_num] using h lemma coarseFlex_adapted (δ : ℝ) (P : R → FilteredRanks w) (H : ℕ → Ω → ℕ) (hH : ∀ r t ω,(P r).history t ω=H t ω) (t : ℕ) (ω z : Ω) (he : H t ω=H t z) : coarseFlex δ P t ω=coarseFlex δ P t z := by apply sum_congr rfl intro r _ have hh:(P r).history t ω=(P r).history t z := by rw[hH,hH,he] rw [CoreFlags.flag_adapted (P r) t hh,TrackedCaps.endpoint_adapted (P r) δ 0 t hh] lemma input_adapted {cw ell : ℝ} (hcw : 0vector_adapted δ P H hH hr s ω z (StarSimplex.history_prefix H hr hs he) have hk:ScheduleCausality.PrefixEq t (fun s=>key s ω) (fun s=>key s z) := fun s hs=>hkey s ω z (StarSimplex.history_prefix H hr hs he) have hm:mark δ P key t ω=mark δ P key t z := congrArg EpochSchedule.dominant (ScheduleCausality.run_prefix _ _ _ _ t hx hk) have hA:sides δ P key t ω=sides δ P key t z := by simp only [sides,hm,hx t le_rfl] have hD:scale δ P key t ω=scale δ P key t z := by simp only [scale,hm] split · rfl · exact coarseFlex_adapted δ _ H (hH _) t ω z he have hf:sideFlags δ P key t ω=sideFlags δ P key t z := by funext i r have hh:(P i r).history t ω=(P i r).history t z := by rw[hH,hH,he] simp only [sideFlags,hA,CoreFlags.flag_adapted (P i r) t hh] have hh:logs δ P key t ω=logs δ P key t z := by funext i exact congrArg (fun h:J→ℝ=>max 1 (h i)) (ScheduleCausality.weight_prefix δ _ _ _ _ t hx hk) have hp:(fun ir:J×R=>(P ir.1 ir.2).p t ω)=(fun ir=>(P ir.1 ir.2).p t z) := by funext ir exact (P ir.1 ir.2).adapted t ω z (by rw[hH,hH,he]) unfold input SideFamilies.fromLog simp only [hA,hf,hD,hh,hp,hb t ω z he,ScheduleCausality.epoch_prefix _ _ _ _ t hx hk] lemma proportion_adapted {cw ell : ℝ} (hcw : 0simp | false=> simp only [Bool.false_eq_true,ite_false] have hp:pstar/4≤(P r).p t ω:=by have h:=noncore_lower (P r) hf norm_num [pstar] at * linarith have hg:parameterSlope ((P r).p t ω)≤rank z ((P r).p t ω):=(parameterSlope_compare hz hp).2 have hm:=mul_le_mul_of_nonneg_left hg hz.1 rw [rank_parameter_affine z] at hm ⊢ nlinarith lemma estimate_compare {δ:ℝ} (hδ:0<δ) (P:R→FilteredRanks w) (t:ℕ) (ω:Ω) : (1+δ)⁻¹*TrackedCaps.flex P 0 t ω≤coarseFlex δ P t ω ∧ coarseFlex δ P t ω≤(1+δ)*TrackedCaps.flex P 0 t ω := by constructor <;> unfold TrackedCaps.flex coarseFlex · rw [mul_sum] apply sum_le_sum intro r _ split_ifs · simp · exact (FineCaps.estimate_accuracy hδ (by norm_num) (P r) t ω).1 · rw [mul_sum] apply sum_le_sum intro r _ split_ifs · simp · exact (FineCaps.estimate_accuracy hδ (by norm_num) (P r) t ω).2 lemma compare {δ z:ℝ} (hδ:0<δ) (hδu:δ≤1/1000) (hz:z∈Set.Icc 0 (1/100:ℝ)) (P:R→FilteredRanks w) (t:ℕ) (ω:Ω) : (1/2:ℝ)*TrackedCaps.flex P z t ω≤coarseFlex δ P t ω ∧ coarseFlex δ P t ω≤2*TrackedCaps.flex P z t ω := by have h:=estimate_compare hδ P t ω have hb:=base_compare P hz t ω have hF:=TrackedCaps.flex_nonneg P hz t ω have hD:=coarseFlex_nonneg δ P t ω have hpos:0<1+δ:=by linarith have hh:=mul_le_mul_of_nonneg_left h.1 hpos.le rw [←mul_assoc,mul_inv_cancel₀ (ne_of_gt hpos),one_mul] at hh have hhalf:=mul_le_mul_of_nonneg_left hδu hD have hzF:=mul_le_mul_of_nonneg_right hz.2 hF have hbase:=mul_le_mul_of_nonneg_left hb.2 hpos.le have hδF:=mul_le_mul_of_nonneg_left hδu hF have hδz:=mul_le_mul_of_nonneg_left hzF hδ.le constructor <;> nlinarith only [h.2,hb.1,hbase,hhalf,hh,hzF,hδF,hδz] lemma zero_iff {δ z:ℝ} (hδ:0<δ) (hδu:δ≤1/1000) (hz:z∈Set.Icc 0 (1/100:ℝ)) (P:R→FilteredRanks w) (t:ℕ) (ω:Ω) : coarseFlex δ P t ω=0↔TrackedCaps.flex P z t ω=0 := by have h:=compare hδ hδu hz P t ω have hn:=coarseFlex_nonneg δ P t ω have hf:=TrackedCaps.flex_nonneg P hz t ω constructor <;> intro he <;> linarith end KServer.CoarseFineBridge end /-! One fixed absolute choice in the order required by §05; neither the separation ratio nor any finite input parameter enters these constants. -/ noncomputable section namespace KServer.LocalConstants def cb:ℝ:=1/100000000 def cg:ℝ:=cb/20 def ct:ℝ:=cb/1000000 def cw:ℝ:=cb/1000000000 def C:ℝ:=1000/ct def eb:ℝ:=cb/1000000 def lb:ℝ:=cb/100000000 def rho:ℝ:=lb/16 def dp:ℝ:=lb/(64*cb) def ds:ℝ:=1/1000 lemma positive : 0 nlinarith [he.1,he.2,h.1,h.2] · refine ⟨?_,?_,?_⟩ · constructor <;> nlinarith [he.1,he.2,h.1,h.2] · linarith [he.1] · linarith [he.2] lemma scalar_errors {k:ℝ} (hk:1≤k): 0 simp only [Bool.false_eq_true,ite_false,ite_true] <;> linarith [he.2.1,he.2.2.1] lemma flexCap_upper {k:ℝ} (hk:1≤k) (Q P:R→FilteredRanks w) (d:Bool) (t:ℕ) (ω:Ω) (hs:size Q t ω≤k) : flexCap k Q P d t ω≤2*TrackedCaps.flex P (z k Q t ω) t ω := by have he:=scalar_errors hk have hh:=dominant_bounds hk Q P t ω hs have hz:=(ranges hk Q t ω hs).1 have hf:=TrackedCaps.flex_nonneg P hz t ω have hb:eb/ell k≤1:=by apply (div_le_iff₀ (ell_pos hk)).mpr have hb:eb≤1:=by norm_num [eb,cb] linarith [ell_ge_one hk] have hu:(1+eb/ell k)*TrackedCaps.flex P (z k Q t ω) t ω≤2*TrackedCaps.flex P (z k Q t ω) t ω:=by have hm:=mul_le_mul_of_nonneg_right hb hf nlinarith apply le_trans _ (hh.2.trans hu) cases d with | true=>rfl | false=> unfold flexCap simp only [Bool.false_eq_true,ite_false,ite_true] exact mul_le_mul_of_nonneg_right (by linarith [he.2.1]) (estimate_nonneg (ranges hk Q t ω hs).2.1 P t ω) lemma cap_bounds {k:ℝ} (hk:1≤k) (Q P:R→FilteredRanks w) (d:Bool) (t:ℕ) (ω:Ω) (hs:size Q t ω≤k) : 0≤cap k Q P d t ω ∧ cap k Q P d t ω≤72*size P t ω := by have hn:=TrackedCaps.count_nonneg P t ω have hf:=flexCap_nonneg hk Q P d t ω hs have hu:=flexCap_upper hk Q P d t ω hs have hm:=TrackedCaps.domination P (ranges hk Q t ω hs).1 t ω dsimp [cap] constructor <;> linarith lemma inactive_cap {δ k:ℝ} (hδ:0<δ) (hδu:δ≤1/1000) (hk:1≤k) (Q P:R→FilteredRanks w) (d:Bool) (t:ℕ) (ω:Ω) (hs:size Q t ω≤k) (hi:¬0<(active cutoff δ P ω t).value) : cap k Q P d t ω=0 := by have ha:=(ranges hk Q t ω hs).2.1 have hp:0 linarith [hh.1,hh.2] end KServer.ActualCaps end /-! Binding the local numerical choices to the literal star processes. The only input relation is conservation/superadditivity of the parent's rank size. -/ noncomputable section open scoped BigOperators open Finset namespace KServer.ActualStar attribute [local instance] Classical.propDecidable Classical.decEq open RankTracking RankFunctions CoarseEpoch CoarseProcess StarProfile AllocationSchedule LocalConstants variable {Ω J R:Type} [Fintype Ω] [Fintype J] [Fintype R] {w:Ω→ℝ} def key (Q:R→FilteredRanks w) : ℕ→Ω→ℝ := parent cutoff dp Q def b (k:ℝ) (Q:R→FilteredRanks w) (t:ℕ) (ω:Ω):ℝ:= CoarseParameters.upperBeta k cutoff cb (ActualCaps.ell k) dp (key Q t ω) def β (k:ℝ) (P:R→FilteredRanks w) (t:ℕ) (ω:Ω):ℝ:=3+ActualCaps.z k P t ω def h (P:J→R→FilteredRanks w) (Q:R→FilteredRanks w) (t:ℕ) (ω:Ω) (i:J):ℝ:= weight ds (vector cutoff ds P ω) (fun s=>key Q s ω) t i def active (P:J→R→FilteredRanks w) (t:ℕ) (ω:Ω):Finset J:=activeSet (vector cutoff ds P ω t) def mark (P:J→R→FilteredRanks w) (Q:R→FilteredRanks w) (t:ℕ) (ω:Ω):Option J:= StarSide.mark ds P (key Q) t ω def α (k:ℝ) (P:J→R→FilteredRanks w) (Q:R→FilteredRanks w) : ℕ→Ω→J→ℝ:= StarSimplex.proportion (δ:=ds) (by norm_num [ds]) (by norm_num [ds]) C (ActualCaps.ell k) ct P (key Q) lemma h_nonneg (P:J→R→FilteredRanks w) (Q:R→FilteredRanks w) (t:ℕ) (ω:Ω) (i:J):0≤h P Q t ω i:= weight_nonneg ds _ _ (vector_nonneg cutoff ds P ω) t i lemma h_one (P:J→R→FilteredRanks w) (Q:R→FilteredRanks w) (t:ℕ) (ω:Ω) (i:J) (hi:mark P Q t ω≠some i):1≤h P Q t ω i:= weight_regular_one ds _ _ t i hi lemma h_upper {k:ℝ} (hk:1≤k) (P:J→R→FilteredRanks w) (Q:R→FilteredRanks w) (hs:∀ t ω,(∑ i,size (P i) t ω)≤k) (t:ℕ) (ω:Ω) (i:J): h P Q t ω i≤20002*ActualCaps.ell k:= weight_upper (by norm_num [ds]) (by norm_num [ds]) hk _ _ (vector_nonneg cutoff ds P ω) (fun s=>vector_total (by norm_num [ds]) (by norm_num [ds]) P s ω (hs s ω)) (fun s j hj=>vector_floor (by norm_num [ds]) (by norm_num [ds]) P s ω j hj) t i lemma beta_range {k:ℝ} (hk:1≤k) (P:R→FilteredRanks w) (t:ℕ) (ω:Ω) (hs:size P t ω≤k): 3≤β k P t ω ∧ β k P t ω≤4 := by have hr:=(ActualCaps.ranges hk P t ω hs).1 unfold β constructor <;> linarith [hr.1,hr.2] lemma b_range {k:ℝ} (hk:1≤k) (Q:R→FilteredRanks w) (t:ℕ) (ω:Ω) (hs:size Q t ω≤k): 3≤b k Q t ω ∧ b k Q t ω≤4 := by have hr:=ActualCaps.held_beta_bounds hk Q t ω hs exact ⟨hr.1,hr.2.trans (by norm_num)⟩ lemma b_error {k:ℝ} (hk:1≤k) (Q:R→FilteredRanks w) (t:ℕ) (ω:Ω): β k Q t ω≤b k Q t ω ∧ b k Q t ω-β k Q t ω≤4*cb*dp/ActualCaps.ell k := by have hh:=ActualParameters.held_error (δ:=dp) (cb:=cb) (by norm_num [dp,lb,cb]) hk (by norm_num [cb]) Q t ω dsimp only [β,ActualCaps.z,b,key,ActualCaps.ell] constructor <;> linarith [hh.1,hh.2] lemma parameter_gap {k:ℝ} (hk:1≤k) (P:J→R→FilteredRanks w) (Q:R→FilteredRanks w) (hs:∀ t ω,(∑ i,size (P i) t ω)≤ size Q t ω) (t:ℕ) (ω:Ω) (i:J) (hi:i∈active P t ω): cg*h P Q t ω i/ActualCaps.ell k≤β k (P i) t ω-β k Q t ω := by have hh:=ActualParameters.gap (δ:=ds) (cb:=cb) (by norm_num [ds]) (by norm_num [ds]) hk (by norm_num [cb]) P (key Q) (size Q) hs t ω i hi dsimp only [β,ActualCaps.z,ActualCaps.ell,h,cg] linarith only [hh] lemma α_mem (k:ℝ) (P:J→R→FilteredRanks w) (Q:R→FilteredRanks w) (t:ℕ) (ω:Ω): α k P Q t ω∈ChangingDomains.simplex (active P t ω):= StarSimplex.proportion_mem _ _ _ _ _ _ _ _ _ lemma α_feasible {k:ℝ} (hk:1≤k) (P:J→R→FilteredRanks w) (Q:R→FilteredRanks w) (hs:∀ t ω,(∑ i,size (P i) t ω)≤k) (t:ℕ) (ω:Ω) (i:J): (∑ j,TrackedCaps.core (P j) t ω)*α k P Q t ω i≤ (1+ct*h P Q t ω i/ActualCaps.ell k)*TrackedCaps.core (P i) t ω:= StarSimplex.feasible (δ:=ds) (by norm_num [ds]) (by norm_num [ds]) positive.2.2.2.2.1 positive.2.2.1 small.1 small.2.2.1 hk P (key Q) hs t ω i end KServer.ActualStar end /-! Scalar constant choices used when the genuine minimizer proportions are converted to allocations. All constants are the fixed absolute choices, not parameters fitted to the finite law. -/ noncomputable section namespace KServer.OutputConstants open LocalConstants lemma eta_nonneg {h ell:ℝ} (hh:0≤h) (hel:0TrackedCaps.core (P i) t ω def n (P:J→R→FilteredRanks w) (t:ℕ) (ω:Ω) : J→ℝ := fun i=>TrackedCaps.count (P i) t ω def S (P:J→R→FilteredRanks w) (t:ℕ) (ω:Ω):ℝ:=∑ i,B P t ω i def f (k:ℝ) (P:J→R→FilteredRanks w) (Q:R→FilteredRanks w) (t:ℕ) (ω:Ω) : J→ℝ := fun i=>TrackedCaps.flex (P i) (ActualCaps.z k Q t ω) t ω def fc (k:ℝ) (P:J→R→FilteredRanks w) (t:ℕ) (ω:Ω) : J→ℝ := fun i=>TrackedCaps.flex (P i) (ActualCaps.z k (P i) t ω) t ω def flexcap (k:ℝ) (P:J→R→FilteredRanks w) (Q:R→FilteredRanks w) (t:ℕ) (ω:Ω) : J→ℝ := fun i=>ActualCaps.flexCap k Q (P i) (decide (mark P Q t ω=some i)) t ω def d (k:ℝ) (P:J→R→FilteredRanks w) (Q:R→FilteredRanks w) (t:ℕ) (ω:Ω) : J→ℝ := fun i=>n P t ω i+flexcap k P Q t ω i def lower (k:ℝ) (P:R→FilteredRanks w) (t:ℕ) (ω:Ω):ℝ:= ∑ r,rank (ActualCaps.z k P t ω) ((P r).p t ω) def T (k:ℝ) (P:J→R→FilteredRanks w) (Q:R→FilteredRanks w) (t:ℕ) (ω:Ω):ℝ:= match mark P Q t ω with | none=>0 | some o=>f k P Q t ω o def e (k:ℝ) (P:J→R→FilteredRanks w) (Q:R→FilteredRanks w) (t:ℕ) (ω:Ω):ℝ:= match mark P Q t ω with | none=>0 | some o=>flexcap k P Q t ω o-f k P Q t ω o def D (P:J→R→FilteredRanks w) (Q:R→FilteredRanks w) : ℕ→Ω→ℝ:= StarSide.scale ds P (key Q) lemma S_nonneg (P:J→R→FilteredRanks w) (t:ℕ) (ω:Ω):0≤S P t ω:= sum_nonneg fun i _=>TrackedCaps.core_nonneg (P i) t ω lemma D_nonneg (P:J→R→FilteredRanks w) (Q:R→FilteredRanks w) (t:ℕ) (ω:Ω):0≤D P Q t ω:= StarSide.scale_nonneg ds P (key Q) t ω lemma mark_active (P:J→R→FilteredRanks w) (Q:R→FilteredRanks w) (t:ℕ) (ω:Ω) {o:J} (ho:mark P Q t ω=some o):o∈ActualStar.active P t ω:= marked_active _ _ (vector_nonneg cutoff ds P ω) t ho lemma inactive (P:J→R→FilteredRanks w) (t:ℕ) (ω:Ω) {i:J} (hi:i∉ActualStar.active P t ω):¬0<(CoarseProcess.active cutoff ds (P i) ω t).value:=by exact fun hh=>hi ((AllocationSchedule.mem_activeSet _ _).mpr hh) lemma inactive_lower (k:ℝ) (P:J→R→FilteredRanks w) (t:ℕ) (ω:Ω) {i:J} (hi:i∉ActualStar.active P t ω):lower k (P i) t ω=0:= inactive_lower_zero (by norm_num [ds]) (by norm_num [ds]) (P i) (inactive P t ω hi) _ lemma inactive_f (k:ℝ) (P:J→R→FilteredRanks w) (Q:R→FilteredRanks w) (t:ℕ) (ω:Ω) {i:J} (hi:i∉ActualStar.active P t ω):f k P Q t ω i=0:=by apply sum_eq_zero intro r _ rw [inactive_flag_false (by norm_num [ds]) (by norm_num [ds]) (P i) (inactive P t ω hi) r] simp only [Bool.false_eq_true,ite_false] exact rank_cutoff _ (inactive_rank_cutoff (by norm_num [ds]) (by norm_num [ds]) (P i) (inactive P t ω hi) r).le omit [Fintype J] in lemma lower_decomposition (k:ℝ) (P:J→R→FilteredRanks w) (t:ℕ) (ω:Ω) (i:J): lower k (P i) t ω=n P t ω i-β k (P i) t ω*B P t ω i+fc k P t ω i:= TrackedCaps.decomposition (P i) _ t ω lemma child_size (P:J→R→FilteredRanks w) (t:ℕ) (ω:Ω) (i:J): size (P i) t ω≤∑ j,size (P j) t ω:= single_le_sum (fun j _=>size_nonneg (P j) t ω) (mem_univ i) lemma lower_nonneg {k:ℝ} (hk:1≤k) (P:R→FilteredRanks w) (t:ℕ) (ω:Ω) (hs:size P t ω≤k): 0≤lower k P t ω:=sum_nonneg fun _ _=>rank_nonneg (ActualCaps.ranges hk P t ω hs).1 _ lemma d_bounds {k:ℝ} (hk:1≤k) (P:J→R→FilteredRanks w) (Q:R→FilteredRanks w) (t:ℕ) (ω:Ω) (hs:size Q t ω≤k) (i:J):0≤d k P Q t ω i ∧ d k P Q t ω i≤72*size (P i) t ω:= ActualCaps.cap_bounds hk Q (P i) _ t ω hs lemma inactive_d {k:ℝ} (hk:1≤k) (P:J→R→FilteredRanks w) (Q:R→FilteredRanks w) (t:ℕ) (ω:Ω) (hs:size Q t ω≤k) {i:J} (hi:i∉ActualStar.active P t ω):d k P Q t ω i=0:= ActualCaps.inactive_cap (by norm_num [ds]) (by norm_num [ds]) hk Q (P i) _ t ω hs (inactive P t ω hi) lemma regular_caps {k:ℝ} (hk:1≤k) (P:J→R→FilteredRanks w) (Q:R→FilteredRanks w) (hs:∀ t ω,(∑ i,size (P i) t ω)≤ size Q t ω) (t:ℕ) (ω:Ω) (hq:size Q t ω≤k) (i:J) (hi:i∈ActualStar.active P t ω) (ho:mark P Q t ω≠some i): fc k P t ω i≤flexcap k P Q t ω i ∧ flexcap k P Q t ω i≤f k P Q t ω i:=by have hg:=parameter_gap hk P Q hs t ω i hi have hh:=h_one P Q t ω i ho have hcg:0≤cg/ActualCaps.ell k:=div_nonneg positive.2.1.le (ActualCaps.ell_pos hk).le have hmul:=mul_le_mul_of_nonneg_left hh hcg have hgap:cg/ActualCaps.ell k≤ActualCaps.z k (P i) t ω-ActualCaps.z k Q t ω:=by dsimp only [β] at hg simp only [div_eq_mul_inv] at hg hmul ⊢ nlinarith only [hg,hmul] simpa only [fc,flexcap,f,decide_eq_false ho] using ActualCaps.regular_bounds hk Q (P i) t ω hq hgap lemma dominant_caps {k:ℝ} (hk:1≤k) (P:J→R→FilteredRanks w) (Q:R→FilteredRanks w) (t:ℕ) (ω:Ω) (hq:size Q t ω≤k) {o:J} (ho:mark P Q t ω=some o): f k P Q t ω o≤flexcap k P Q t ω o ∧ flexcap k P Q t ω o≤(1+eb/ActualCaps.ell k)*f k P Q t ω o:=by simpa only [f,flexcap,ho,decide_true] using ActualCaps.dominant_bounds hk Q (P o) t ω hq lemma T_nonneg {k:ℝ} (hk:1≤k) (P:J→R→FilteredRanks w) (Q:R→FilteredRanks w) (t:ℕ) (ω:Ω) (hq:size Q t ω≤k):0≤T k P Q t ω:=by unfold T split · rfl · exact TrackedCaps.flex_nonneg _ (ActualCaps.ranges hk Q t ω hq).1 t ω lemma e_bounds {k:ℝ} (hk:1≤k) (P:J→R→FilteredRanks w) (Q:R→FilteredRanks w) (t:ℕ) (ω:Ω) (hq:size Q t ω≤k):0≤e k P Q t ω ∧ e k P Q t ω≤eb/ActualCaps.ell k*T k P Q t ω:=by cases ho:mark P Q t ω with | none=>simp only [e,T,ho,mul_zero,le_refl,and_self] | some o=> have hh:=dominant_caps hk P Q t ω hq ho simp only [e,T,ho] constructor <;> nlinarith [hh.1,hh.2] lemma DT_compare {k:ℝ} (hk:1≤k) (P:J→R→FilteredRanks w) (Q:R→FilteredRanks w) (t:ℕ) (ω:Ω) (hq:size Q t ω≤k):T k P Q t ω/2≤D P Q t ω ∧ D P Q t ω≤2*T k P Q t ω:=by have hmark:StarSide.mark ds P (key Q) t ω=mark P Q t ω:=rfl cases ho:mark P Q t ω with | none=>simp only [D,StarSide.scale,hmark,ho,T,zero_div,mul_zero,le_refl,and_self] | some o=> have hh:=CoarseFineBridge.compare (δ:=ds) (by norm_num [ds]) (by norm_num [ds]) (ActualCaps.ranges hk Q t ω hq).1 (P o) t ω simp only [D,StarSide.scale,hmark,ho,T,f] constructor <;> linarith [hh.1,hh.2] end KServer.ActualOutput end end OAI