Download data/lean/OAI/Probability/MatroidProphet/Algorithm/Worst.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 4.73 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Probability/MatroidProphet/Algorithm/Worst.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Probability/MatroidProphet/Algorithm/Worst.lean
-
curl -L -o Worst.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Probability/MatroidProphet/Algorithm/Worst.lean
4.73 kB
| import OAI.Probability.MatroidProphet.Algorithm.Statistics | |
| import OAI.Probability.MatroidProphet.Algorithm.Mean | |
| import OAI.Probability.MatroidProphet.WeightedAccounting | |
| namespace OAI | |
| namespace MatroidProphet | |
| open Finset | |
| lemma cumulative_option_weight_bound {Ξ± : Type*} [DecidableEq Ξ±] | |
| (B : β) (hB : 2 β€ B) (A : Finset Ξ±) (level : Ξ± β Option β€) (analyzed : Finset β€) : | |
| (β i β analyzed, B ^ i * ((A.filter (fun e => β j, level e = some j β§ i β€ j)).card : β)) β€ | |
| 2 * β e β A, levelWeight B (level e) := by | |
| classical | |
| let P := A.filter (fun e => level e β none) | |
| have hfilter (i : β€) : P.filter (fun e => i β€ (level e).getD 0) = | |
| A.filter (fun e => β j, level e = some j β§ i β€ j) := by | |
| ext e | |
| cases he : level e <;> simp [P, he] | |
| have hsum : (β e β P, B ^ (level e).getD 0) = β e β A, levelWeight B (level e) := by | |
| unfold P | |
| rw [sum_filter] | |
| apply sum_congr rfl | |
| intro e he | |
| cases level e <;> simp [levelWeight] | |
| have hc := cumulative_weight_bound B hB P (fun e => (level e).getD 0) analyzed | |
| simpa only [hfilter, hsum] using hc | |
| namespace MainAlgorithm | |
| variable {n : β} | |
| noncomputable def mainWorstRounded (M : Matroid (Fin n)) (hE : M.E = Set.univ) | |
| (d : MainMasks n) (w : Fin n β Option β€) : β := by | |
| classical | |
| exact univ.inf' univ_nonempty (fun Ο : ArrivalOrder n => | |
| β e β selection M hE d w Ο, levelWeight weightBase (w e)) | |
| lemma mainWorstRounded_le (M : Matroid (Fin n)) (hE : M.E = Set.univ) | |
| (d : MainMasks n) (w : Fin n β Option β€) (Ο : ArrivalOrder n) : | |
| mainWorstRounded M hE d w β€ β e β selection M hE d w Ο, levelWeight weightBase (w e) := by | |
| classical | |
| exact inf'_le _ (mem_univ Ο) | |
| lemma mainWorstRounded_nonneg (M : Matroid (Fin n)) (hE : M.E = Set.univ) | |
| (d : MainMasks n) (w : Fin n β Option β€) : 0 β€ mainWorstRounded M hE d w := by | |
| classical | |
| apply le_inf' | |
| intro Ο hΟ | |
| apply sum_nonneg | |
| intro e he | |
| cases w e with | |
| | none => exact le_rfl | |
| | some i => exact (zpow_pos (by norm_num [weightBase]) i).le | |
| lemma weighted_trueLambda_le_selection (M : Matroid (Fin n)) (hE : M.E = Set.univ) | |
| (d : MainMasks n) (w : Fin n β Option β€) (analyzed : Finset β€) (Ο : ArrivalOrder n) : | |
| (1/2 : β) * β i β analyzed, weightBase ^ i * (trueLambda M hE d w i : β) β€ | |
| β e β selection M hE d w Ο, levelWeight weightBase (w e) := by | |
| have hc := cumulative_option_weight_bound weightBase (by norm_num [weightBase]) | |
| (selection M hE d w Ο) w analyzed | |
| have hr : (β i β analyzed, weightBase ^ i * (trueLambda M hE d w i : β)) β€ | |
| β i β analyzed, weightBase ^ i * | |
| (((selection M hE d w Ο).filter (fun e => β j, w e = some j β§ i β€ j)).card : β) := by | |
| apply sum_le_sum | |
| intro i hi | |
| apply mul_le_mul_of_nonneg_left _ (zpow_pos (by norm_num [weightBase]) i).le | |
| exact_mod_cast trueLambda_le_count M hE d w Ο i | |
| linarith | |
| lemma weighted_trueLambda_le_mainWorstRounded (M : Matroid (Fin n)) (hE : M.E = Set.univ) | |
| (d : MainMasks n) (w : Fin n β Option β€) (analyzed : Finset β€) : | |
| (1/2 : β) * β i β analyzed, weightBase ^ i * (trueLambda M hE d w i : β) β€ | |
| mainWorstRounded M hE d w := by | |
| classical | |
| apply le_inf' | |
| intro Ο hΟ | |
| exact weighted_trueLambda_le_selection M hE d w analyzed Ο | |
| lemma mainMean_sum {Ξ² : Type*} (d : MainMasks n) (I : Finset Ξ²) (f : Ξ² β MainMasks n β β) : | |
| mainMean d (fun d' => β i β I, f i d') = β i β I, mainMean d (f i) := by | |
| classical | |
| induction I using Finset.induction_on with | |
| | empty => simp only [sum_empty, mainMean_const] | |
| | @insert a I ha ih => simp only [sum_insert ha, mainMean_add, ih] | |
| lemma weighted_mean_trueLambda_le_mainWorstRounded (M : Matroid (Fin n)) (hE : M.E = Set.univ) | |
| (d : MainMasks n) (w : Fin n β Option β€) (analyzed : Finset β€) : | |
| (1/2 : β) * β i β analyzed, weightBase ^ i * mainMean d (fun d' => (trueLambda M hE d' w i : β)) β€ | |
| mainMean d (fun d' => mainWorstRounded M hE d' w) := by | |
| have hh := mainMean_mono d (fun d' _ => weighted_trueLambda_le_mainWorstRounded M hE d' w analyzed) | |
| simpa only [mainMean_mul, mainMean_sum] using hh | |
| lemma mainWorstRounded_le_hiddenWorstReward (M : Matroid (Fin n)) (hE : M.E = Set.univ) | |
| (r : Seed (mainSeedBits n)) (w : Weights n) (hw : β e, 0 β€ w e) : | |
| mainWorstRounded M hE (mainMasks r) (fun e => roundedLevel weightBase (w e)) β€ | |
| hiddenWorstReward (hidden M hE) w r := by | |
| classical | |
| apply le_inf' | |
| intro Ο hΟ | |
| exact (mainWorstRounded_le M hE (mainMasks r) _ Ο).trans | |
| (rounded_selection_le_hiddenReward M hE r w hw Ο) | |
| end MainAlgorithm | |
| end MatroidProphet | |
| end OAI | |