OAI/Combinatorics/KServer/RankProportions.lean
122 declarations, 0 contain sorry, 0 declared as axioms
- def
OAI.KServer.RankTracking.heldline 12Source documentation
Reference reset policy run on every input step.
def held (test : ℝ → ℝ → Prop) [DecidableRel test] (p : ℕ → Ω → ℝ) : ℕ → Ω → ℝ | 0, ω => p 0 ω | t+1, ω => if test (p (t+1) ω) (held test p t ω) then p (t+1) ω else held test p t ω omit [Fintype Ω] in
- lemma
OAI.KServer.RankTracking.held_rangeline 17 - lemma
OAI.KServer.RankTracking.held_adaptedline 24 - def
OAI.KServer.RankTracking.potentialline 36Source documentation
Exact bounded affine potential used in the manuscript.
def potential (p r : ℝ) : ℝ := p*(1-p)+(p-r)^2
- lemma
OAI.KServer.RankTracking.potential_affineline 37 - lemma
OAI.KServer.RankTracking.potential_boundsline 38 - lemma
OAI.KServer.RankTracking.slope_absline 48 - def
OAI.KServer.RankTracking.creditline 51 - lemma
OAI.KServer.RankTracking.credit_stepline 55 - lemma
OAI.KServer.RankTracking.expected_credit_stepline 64 - theorem
OAI.KServer.RankTracking.reset_credit_boundline 88Source documentation
Signed filtering is retained at every step, before the reset decision.
theorem reset_credit_bound (test : ℝ → ℝ → Prop) [DecidableRel test] {w : Ω → ℝ} (hw : ∀ ω, 0 ≤ w ω) (hw1 : ∑ ω, w ω=1) (R : FilteredRanks w) (N : ℕ) : (∑ t ∈ Finset.range N, avg w (credit test R.p t)) ≤ (∑ t ∈ Finset.range N, avg w (fun ω => |R.p (t+1) ω-R.before (t+1) ω|))+1 := by …Mentions: OAI.KServer.RankTracking.FilteredRanks, OAI.KServer.RankTracking.avg, OAI.KServer.RankTracking.credit
- lemma
OAI.KServer.RankTracking.sqrt_factor_gap_oneline 108Source documentation
Source's scalar factor-loss constant, including zero endpoints.
lemma sqrt_factor_gap_one {a b ξ : ℝ} (ha : 0 ≤ a) (hb : 0 ≤ b) (hξ : 0 < ξ) (hξh : ξ < 1/2) (hfail : (1+ξ)*b ≤ a) : (ξ/5)*(a-b) ≤ (Real.sqrt a-Real.sqrt b)^2 := by … - lemma
OAI.KServer.RankTracking.sqrt_factor_gapline 138 - def
OAI.KServer.RankTracking.factorTestline 151 - instance
OAI.KServer.RankTracking.(instance at line 154)line 154 - lemma
OAI.KServer.RankTracking.factor_held_accurateline 157 - lemma
OAI.KServer.RankTracking.factor_movement_creditline 180 - theorem
OAI.KServer.RankTracking.multiplicative_rank_trackingline 206Source documentation
Actual causal multiplicative held estimates, with horizon-independent additive initialization allowance and the source's C/xi drift dependence.
theorem multiplicative_rank_tracking {w : Ω → ℝ} (hw : ∀ ω, 0 ≤ w ω) (hw1 : ∑ ω, w ω=1) (R : FilteredRanks w) (f : ℝ → ℝ) {ξ K : ℝ} (hξ : 0 < ξ) (hξh : ξ < 1/2) (hK : 0 ≤ K) (hf : ∀ p ∈ Set.Icc (0:ℝ) 1, 0 ≤ f p) (hlip : ∀ p ∈ Set.Icc (0:ℝ) 1, ∀ r ∈ Set.Icc (0:ℝ) 1, |Real.sqrt (f p)-Real.sqrt (f r)| ≤ K*|p-r|) : ∃ estimate : ℕ → Ω → ℝ, (∀ t, Adapted (R.history t) (estimate t)) ∧ (∀ t ω, (1+ξ)⁻¹*f (R.p t ω) ≤ estimate t ω ∧ estimate t ω ≤ (1+ξ)*f (R.p t ω)) ∧ ∀ N, (∑ t ∈ Finset.range N, avg w (fun ω => |estimate (t+1) ω-estimate t ω|)) ≤ (5*K^2/ξ)*((∑ t ∈ Finset.range N, avg w (fun ω => |R.p (t+1) ω-R.before (t+1) ω|))+1) := by …Mentions: OAI.KServer.RankTracking.FilteredRanks, OAI.KServer.RankTracking.Adapted, OAI.KServer.RankTracking.avg
- def
OAI.KServer.RankTracking.absoluteTestline 231 - instance
OAI.KServer.RankTracking.(instance at line 232)line 232 - def
OAI.KServer.RankTracking.resetIndicatorline 234 - theorem
OAI.KServer.RankTracking.absolute_rank_trackingline 239Source documentation
The absolute tracker used for all core flags. Its cost is the actual number of reference refreshes, not the variation of the raw posteriors.
theorem absolute_rank_tracking {w : Ω → ℝ} (hw : ∀ ω, 0 ≤ w ω) (hw1 : ∑ ω, w ω=1) (R : FilteredRanks w) {δ : ℝ} (hδ : 0 < δ) : (∀ t ω, |R.p t ω-held (absoluteTest δ) R.p t ω| ≤ δ) ∧ ∀ N, (∑ t ∈ Finset.range N, avg w (resetIndicator (absoluteTest δ) R.p t)) ≤ (δ^2)⁻¹*((∑ t ∈ Finset.range N, avg w (fun ω => |R.p (t+1) ω-R.before (t+1) ω|))+1) := by …Mentions: OAI.KServer.RankTracking.FilteredRanks, OAI.KServer.RankTracking.held, OAI.KServer.RankTracking.absoluteTest, OAI.KServer.RankTracking.avg, OAI.KServer.RankTracking.resetIndicator
- lemma
OAI.KServer.RankTracking.held_variation_stepline 273Source documentation
Causal hold-or-reset rules never increase total scalar input variation. The deviation from the held reference pays for any waiting interval.
lemma held_variation_step (test : ℝ → ℝ → Prop) [DecidableRel test] (p : ℕ → Ω → ℝ) (t : ℕ) (ω : Ω) : |held test p (t+1) ω-held test p t ω|+|p (t+1) ω-held test p (t+1) ω| ≤ |p (t+1) ω-p t ω|+|p t ω-held test p t ω| := by …Mentions: OAI.KServer.RankTracking.held
- theorem
OAI.KServer.RankTracking.held_variationline 282 - lemma
OAI.KServer.RankTracking.factor_change_chargeline 295 - def
OAI.KServer.CoreFlags.toleranceline 315Source documentation
§03: the literal absolute reference tolerance p*/8, p*=1/24.
def tolerance : ℝ := (1/24)/8
- lemma
OAI.KServer.CoreFlags.tolerance_posline 316 - def
OAI.KServer.CoreFlags.flagline 317 - def
OAI.KServer.CoreFlags.changeline 320 - lemma
OAI.KServer.CoreFlags.flag_accuracyline 323 - lemma
OAI.KServer.CoreFlags.core_upperline 333 - lemma
OAI.KServer.CoreFlags.noncore_lowerline 340 - lemma
OAI.KServer.CoreFlags.small_is_coreline 348 - lemma
OAI.KServer.CoreFlags.change_le_resetline 354 - theorem
OAI.KServer.CoreFlags.core_change_budgetline 364Source documentation
The exact number of changed flags is charged to the fixed absolute trackers. No raw posterior total variation is charged.
theorem core_change_budget {J : Type} [Fintype J] (hw : ∀ ω, 0 ≤ w ω) (hw1 : ∑ ω, w ω=1) (R : J → FilteredRanks w) (N : ℕ) : (∑ t ∈ range N, avg w (fun ω => ∑ j, change (R j) t ω)) ≤ (tolerance^2)⁻¹ * ((∑ t ∈ range N, avg w (fun ω => ∑ j, |(R j).p (t+1) ω-(R j).before (t+1) ω|)) + Fintype.card J) := by …Mentions: OAI.KServer.CoreFlags.change, OAI.KServer.CoreFlags.tolerance
- lemma
OAI.KServer.CoreFlags.flag_adaptedline 388 - lemma
OAI.KServer.CoreFlags.flagged_mass_changeline 395Source documentation
Changing core flags after inspecting new posteriors costs at most one per changed flag, since each rank remains in [0,1].
lemma flagged_mass_change {J : Type} [Fintype J] (p : J → ℝ) (hp : ∀ j, p j ∈ Set.Icc 0 1) (K K' : J → Bool) : |(∑ j, if K' j then p j else 0) - (∑ j, if K j then p j else 0)| ≤ ∑ j, if K' j = K j then (0:ℝ) else 1 := by … - def
OAI.KServer.RankFunctions.pstarline 417 - def
OAI.KServer.RankFunctions.sstarline 418 - def
OAI.KServer.RankFunctions.Aline 420 - def
OAI.KServer.RankFunctions.Bline 421 - def
OAI.KServer.RankFunctions.middleline 422 - def
OAI.KServer.RankFunctions.rankline 425 - def
OAI.KServer.RankFunctions.slopeline 429 - lemma
OAI.KServer.RankFunctions.middle_literalline 433 - lemma
OAI.KServer.RankFunctions.derivative_ite_leline 440Source documentation
C¹ gluing at a scalar threshold, applied twice to the rank formula.
lemma derivative_ite_le {f g f' g' : ℝ → ℝ} {c : ℝ} (hf : ∀ x, HasDerivAt f (f' x) x) (hg : ∀ x, HasDerivAt g (g' x) x) (he : f c = g c) (hd : f' c = g' c) (x : ℝ) : HasDerivAt (fun p => if p ≤ c then f p else g p) (if x ≤ c then f' x else g' x) x := by … - lemma
OAI.KServer.RankFunctions.middle_derivativeline 476 - lemma
OAI.KServer.RankFunctions.rank_derivativeline 483 - lemma
OAI.KServer.RankFunctions.coefficientsline 497 - lemma
OAI.KServer.RankFunctions.middle_slope_monotoneline 502 - lemma
OAI.KServer.RankFunctions.slope_monotoneline 513 - lemma
OAI.KServer.RankFunctions.rank_convexline 540 - lemma
OAI.KServer.RankFunctions.rank_antitoneline 547 - lemma
OAI.KServer.RankFunctions.rank_zeroline 559 - lemma
OAI.KServer.RankFunctions.rank_cutoffline 561 - lemma
OAI.KServer.RankFunctions.rank_posline 569 - lemma
OAI.KServer.RankFunctions.rank_nonnegline 584 - lemma
OAI.KServer.RankFunctions.rank_rangeline 590 - def
OAI.KServer.RankFunctions.parameterSlopeline 595Source documentation
Minus the derivative in beta, exactly as defined after eq:explicit-rank.
def parameterSlope (p : ℝ) : ℝ := …
- lemma
OAI.KServer.RankFunctions.rank_parameter_affineline 599 - lemma
OAI.KServer.RankFunctions.parameterSlope_nonnegline 604 - lemma
OAI.KServer.RankFunctions.rank_parameter_antitoneline 612 - lemma
OAI.KServer.RankFunctions.parameterSlope_compareline 619 - lemma
OAI.KServer.RankFunctions.sqrt_slope_boundline 645 - lemma
OAI.KServer.RankFunctions.sqrt_right_derivativeline 686 - lemma
OAI.KServer.RankFunctions.sqrt_rank_lipschitzline 698 - def
OAI.KServer.RankFunctions.sizeRankline 724Source documentation
The broader size function, literally as in §03.
def sizeRank (p : ℝ) : ℝ := (max (3 / 4 - p) 0)^2 / (3 / 4)^2
- lemma
OAI.KServer.RankFunctions.sizeRank_pieceline 726 - lemma
OAI.KServer.RankFunctions.sizeRank_derivativeline 732 - lemma
OAI.KServer.RankFunctions.sizeRank_convexline 746 - lemma
OAI.KServer.RankFunctions.sizeRank_zeroline 752 - lemma
OAI.KServer.RankFunctions.sizeRank_oneline 753 - lemma
OAI.KServer.RankFunctions.sizeRank_nonnegline 754 - lemma
OAI.KServer.RankFunctions.sizeRank_le_complementline 756 - lemma
OAI.KServer.RankFunctions.sqrt_sizeRankline 764 - lemma
OAI.KServer.RankFunctions.sqrt_sizeRank_lipschitzline 770 - def
OAI.KServer.FineCaps.estimateline 790 - lemma
OAI.KServer.FineCaps.estimate_rangeline 793 - lemma
OAI.KServer.FineCaps.estimate_accuracyline 797 - lemma
OAI.KServer.FineCaps.relative_absoluteline 803 - lemma
OAI.KServer.FineCaps.estimate_absoluteline 818 - lemma
OAI.KServer.FineCaps.interpolate_rankline 824 - def
OAI.KServer.FineCaps.interpolatedline 829 - lemma
OAI.KServer.FineCaps.interpolated_rangeline 832 - lemma
OAI.KServer.FineCaps.interpolated_accuracyline 843 - lemma
OAI.KServer.FineCaps.noncore_interpolation_errorline 864Source documentation
§03 flex-estimate error, including exact zero at the common cutoff.
lemma noncore_interpolation_error {ξ 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 ≤ ε) (R : FilteredRanks w) (t : ℕ) (ω : Ω) (hf : flag R t ω=false) : |interpolated ξ a R t ω-rank z (R.p t ω)| ≤ (ξ+ε)*rank z (R.p t ω) := by …Mentions: OAI.KServer.FineCaps.interpolated
- lemma
OAI.KServer.FineCaps.cap_scalingline 893Source documentation
Deterministic scaling of an accurately tracked flex term. Parameters here are already normalized by ell: l=lambda_b/ell, e=error/ell, g=gamma/ell, b=epsilon_b/ell. All zero-flex cases are included.
lemma cap_scaling {F E Fc l e g b : ℝ} (hF : 0 ≤ F) (hE : |E-F| ≤ e*F) (he : 0 ≤ e) (hl : 0 < l) (hls : l ≤ 1/4) (hel : e ≤ l/4) (hg : 4*l ≤ g) (hb : 4*l ≤ b) (hfc : Fc ≤ (1-g)*F) : (Fc ≤ (1-l)*E ∧ (1-l)*E ≤ F) ∧ (F ≤ (1+l)*E ∧ (1+l)*E ≤ (1+b)*F) := by … - lemma
OAI.KServer.FineCaps.estimate_variation_budgetline 919Source documentation
The concrete endpoint tracker, not a separately postulated estimate.
lemma estimate_variation_budget (hw : ∀ ω, 0 ≤ w ω) (hw1 : ∑ ω, w ω=1) {ξ z : ℝ} (hξ : 0 < ξ) (hξh : ξ < 1/2) (hz : z ∈ Set.Icc 0 (1/100 : ℝ)) (R : FilteredRanks w) (N : ℕ) : (∑ t ∈ range N, avg w (fun ω => |estimate ξ z R (t+1) ω-estimate ξ z R t ω|)) ≤ (80/ξ)*((∑ t ∈ range N, avg w (fun ω => |R.p (t+1) ω-R.before (t+1) ω|))+1) := by …Mentions: OAI.KServer.FineCaps.estimate
- lemma
OAI.KServer.FineCaps.interpolated_variationline 941 - def
OAI.KServer.FineCaps.capTermline 959Source documentation
One rank's core-plus-scaled-flex contribution to the actual cap.
def capTerm (ξ a κ : ℝ) (R : FilteredRanks w) (t : ℕ) (ω : Ω) : ℝ := …
- lemma
OAI.KServer.FineCaps.capTerm_rangeline 962 - lemma
OAI.KServer.FineCaps.capTerm_variationline 970 - def
OAI.KServer.FineCaps.fineVariationline 998Source documentation
Fine changes can be selected pathwise; wholesale changes are excluded only when the interpolation and scale parameters are actually held fixed.
def fineVariation (ξ : ℝ) (a κ : ℕ → Ω → ℝ) (wholesale : ℕ → Ω → Bool) (R : FilteredRanks w) (t : ℕ) (ω : Ω) : ℝ := … - lemma
OAI.KServer.FineCaps.fineVariation_stepline 1003 - lemma
OAI.KServer.FineCaps.all_endpoint_budgetline 1020 - theorem
OAI.KServer.FineCaps.fine_cap_budgetline 1043Source documentation
§03 fine-cap budget. The right side has one uniform initialization term per rank, not one per coarse epoch. Arbitrary pathwise nonwholesale selection is valid only after the all-step filtering credits have been accounted for.
theorem fine_cap_budget {J : Type} [Fintype J] (hw : ∀ ω, 0 ≤ w ω) (hw1 : ∑ ω, w ω=1) {ξ : ℝ} (hξ : 0 < ξ) (hξh : ξ < 1/2) (a κ : J → ℕ → Ω → ℝ) (wholesale : J → ℕ → Ω → Bool) (ha : ∀ j t ω, a j t ω ∈ Set.Icc 0 1) (hκ : ∀ j t ω, κ j t ω ∈ Set.Icc 0 2) (hhold : ∀ j t ω, wholesale j t ω=false → a j (t+1) ω=a j t ω ∧ κ j (t+1) ω=κ j t ω) (R : J → FilteredRanks w) (N : ℕ) : (∑ t ∈ range N, avg w (fun ω => ∑ j, fineVariation ξ (a j) (κ j) (wholesale j) (R j) t ω)) ≤ 2*(160/ξ+(tolerance^2)⁻¹)*((∑ t ∈ range N, avg w (fun ω => ∑ j, |(R j).p (t+1) ω-(R j).before (t+1) ω|))+Fintype.card J) := by …Mentions: OAI.KServer.FineCaps.fineVariation
- lemma
OAI.KServer.RankOrder.convex_tangentline 1094 - lemma
OAI.KServer.RankOrder.convex_sum_of_prefixline 1108 - def
OAI.KServer.RankOrder.extendline 1136 - lemma
OAI.KServer.RankOrder.extend_finline 1139 - lemma
OAI.KServer.RankOrder.sum_outsideline 1142 - lemma
OAI.KServer.RankOrder.sum_rank_indicatorsline 1149 - lemma
OAI.KServer.RankOrder.outside_card_boundline 1158 - lemma
OAI.KServer.RankOrder.rank_prefixline 1165Source documentation
Pool rank probabilities, then sort them. Every prefix is bounded below by the corresponding parent rank prefix. Dependence between ranks is arbitrary.
lemma rank_prefix {Ω : Type*} [Fintype Ω] {n : ℕ} (B : Ω → Finset (Fin n)) (w : Ω → ℝ) (hw : ∀ ω, 0 ≤ w ω) (σ : Equiv.Perm (Fin n)) (m : ℕ) (hm : m ≤ n) : (∑ j ∈ range m, ∑ ω, w ω * (if (B ω).card ≤ j then (1 : ℝ) else 0)) ≤ ∑ j ∈ range m, extend (fun i => ∑ ω, w ω * (if σ i ∈ B ω then (0 : ℝ) else 1)) j := by …Mentions: OAI.KServer.RankOrder.extend
- lemma
OAI.KServer.RankOrder.rank_totalline 1194 - lemma
OAI.KServer.RankOrder.convex_rank_sumline 1211Source documentation
The convex superadditivity comparison for an arbitrary joint distribution of integer rank indicators. Padding of parent ranks is automatic.
lemma convex_rank_sum {Ω : Type*} [Fintype Ω] {n : ℕ} (B : Ω → Finset (Fin n)) (w : Ω → ℝ) (hw : ∀ ω, 0 ≤ w ω) {f : ℝ → ℝ} (hf : ConvexOn ℝ Set.univ f) (hd : ∀ x, DifferentiableAt ℝ f x) : (∑ i : Fin n, f (∑ ω, w ω * (if i ∈ B ω then (0 : ℝ) else 1))) ≤ ∑ j : Fin n, f (∑ ω, w ω * (if (B ω).card ≤ j.val then (1 : ℝ) else 0)) := by … - lemma
OAI.KServer.RankOrder.convex_rank_sum_typeline 1239 - lemma
OAI.KServer.RankOrder.sum_belowline 1256 - def
OAI.KServer.RankOrder.countRankline 1268Source documentation
Source integer ranks: rank a (with zero-based index) is P(N ≤ a). The probability law is joint, without independent-child assumptions.
def countRank {Ω : Type*} [Fintype Ω] (w : Ω → ℝ) (N : Ω → ℕ) (a : ℕ) : ℝ := … - lemma
OAI.KServer.RankOrder.countRank_rangeline 1271 - lemma
OAI.KServer.RankOrder.countRank_expectedline 1281 - lemma
OAI.KServer.RankOrder.convex_count_superadditivityline 1302 - def
OAI.KServer.CompatibleBounds.Lline 1368Source documentation
The two actual lower-bound sums on a conditional count distribution.
def L {Ω : Type*} [Fintype Ω] (k : ℕ) (w : Ω → ℝ) (N : Ω → ℕ) (z : ℝ) : ℝ := … - def
OAI.KServer.CompatibleBounds.Mline 1370 - theorem
OAI.KServer.CompatibleBounds.compatible_boundsline 1374Source documentation
Lemma superadditivity, with arbitrary dependence and empty child sets.
theorem compatible_bounds {Ω I : Type*} [Fintype Ω] [Fintype I] (w : Ω → ℝ) (hw : ∀ ω, 0 ≤ w ω) (hws : ∑ ω, w ω = 1) {k : ℕ} (N : Ω → I → ℕ) (hN : ∀ ω, ∑ i, N ω i ≤ k) {z : ℝ} (hz : z ∈ Set.Icc 0 (1 / 100 : ℝ)) : (∑ i, L k w (fun ω => N ω i) z) ≤ L k w (fun ω => ∑ i, N ω i) z ∧ (∑ i, M k w (fun ω => N ω i)) ≤ M k w (fun ω => ∑ i, N ω i) ∧ M k w (fun ω => ∑ i, N ω i) ≤ ∑ ω, w ω * (∑ i, N ω i) := by …Mentions: OAI.KServer.CompatibleBounds.L, OAI.KServer.CompatibleBounds.M
- lemma
OAI.KServer.CompatibleBounds.sizeRank_antitoneline 1390 - lemma
OAI.KServer.CompatibleBounds.sizeRank_at_cutoffline 1395 - lemma
OAI.KServer.CompatibleBounds.sizeRank_below_cutoffline 1397 - lemma
OAI.KServer.CompatibleBounds.rank_size_dominationline 1401 - lemma
OAI.KServer.CompatibleBounds.core_decompositionline 1412Source documentation
Exact core/flex decomposition for one child's ranks; indexing zero-based changes no values because countRank a is the source rank a+1.
lemma core_decomposition {k : ℕ} (p : Fin k → ℝ) (K : Finset (Fin k)) (z : ℝ) (hK : ∀ a ∈ K, p a ≤ pstar) : (∑ a, rank z (p a)) = K.card - (3 + z) * (∑ a ∈ K, p a) + ∑ a ∈ univ \ K, rank z (p a) := by … - lemma
OAI.KServer.CompatibleBounds.core_flex_dominationline 1427 - lemma
OAI.KServer.CompatibleBounds.flex_parameter_slackline 1444