File size: 4,725 Bytes
4a56cd6 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 | 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
|