File size: 5,177 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 108 109 110 111 112 113 114 115 116 117 118 119 | import OAI.Probability.MatroidProphet.Information
import OAI.Probability.MatroidProphet.Constants
import Mathlib.Analysis.SpecialFunctions.Log.Base
import Mathlib.MeasureTheory.Function.Floor
import Mathlib.MeasureTheory.Function.SpecialFunctions.Basic
namespace OAI
namespace MatroidProphet
open MeasureTheory
instance levelMeasurableSpace : MeasurableSpace (Option β€) := β€
instance levelMeasurableSingletonClass : MeasurableSingletonClass (Option β€) :=
β¨fun _ => trivialβ©
noncomputable def roundedLevel (B x : β) : Option β€ :=
if 0 < x then some βReal.logb B xβ else none
noncomputable def levelWeight (B : β) : Option β€ β β
| none => 0
| some i => B ^ i
noncomputable def roundedWeight (B x : β) : β := levelWeight B (roundedLevel B x)
theorem measurable_roundedLevel (B : β) : Measurable (roundedLevel B) := by
unfold roundedLevel
apply Measurable.ite (measurableSet_lt measurable_const measurable_id)
Β· exact (measurable_of_countable (some : β€ β Option β€)).comp
(Int.measurable_floor.comp (Real.measurable_log.div_const _))
Β· exact measurable_const
lemma roundedWeight_nonneg {B : β} (hB : 0 < B) (x : β) :
0 β€ roundedWeight B x := by
unfold roundedWeight roundedLevel
split_ifs <;> simp only [levelWeight]
Β· exact (zpow_pos hB _).le
Β· exact le_rfl
lemma roundedWeight_le {B : β} (hB : 1 < B) {x : β} (hx : 0 β€ x) :
roundedWeight B x β€ x := by
by_cases hpos : 0 < x
Β· unfold roundedWeight roundedLevel
rw [ite_eq_left hpos, levelWeight]
have h := (Real.le_logb_iff_rpow_le hB hpos).mp (Int.floor_le (Real.logb B x))
simpa only [Real.rpow_intCast] using h
Β· have hz : x = 0 := le_antisymm (le_of_not_gt hpos) hx
simp [hz, roundedWeight, roundedLevel, levelWeight]
lemma le_base_mul_roundedWeight {B : β} (hB : 1 < B) {x : β} (hx : 0 β€ x) :
x β€ B * roundedWeight B x := by
by_cases hpos : 0 < x
Β· unfold roundedWeight roundedLevel
rw [ite_eq_left hpos, levelWeight]
have h := (Real.logb_lt_iff_lt_rpow hB hpos).mp (Int.lt_floor_add_one (Real.logb B x))
rw [β Int.cast_one, β Int.cast_add, Real.rpow_intCast,
zpow_add_oneβ (ne_of_gt (zero_lt_one.trans hB))] at h
simpa only [mul_comm] using h.le
Β· have hz : x = 0 := le_antisymm (le_of_not_gt hpos) hx
simp [hz, roundedWeight, roundedLevel, levelWeight]
noncomputable def discreteOnlineRule {K : Type*} [Countable K] [MeasurableSpace K]
[MeasurableSingletonClass K] {n bits : β}
(key : β β K) (hkey : Measurable key)
(choose : (k : Fin n) β Seed bits β (Fin n β K) β
(Fin (k.val + 1) β Fin n Γ K) β Bool) : OnlineRule n bits where
decide k r s hist := choose k r (fun e => key (s e))
(fun j => ((hist j).1, key (hist j).2))
measurable_decide k := by
have hc : Measurable (fun x : Seed bits Γ ((Fin n β K) Γ
(Fin (k.val + 1) β Fin n Γ K)) => choose k x.1 x.2.1 x.2.2) :=
measurable_of_countable _
have hs : Measurable (fun x : Seed bits Γ (Weights n Γ History n k) =>
fun e => key (x.2.1 e)) := by
apply Measurable.of_eval
intro e
exact hkey.comp ((measurable_pi_apply e).comp (measurable_fst.comp measurable_snd))
have hh : Measurable (fun x : Seed bits Γ (Weights n Γ History n k) =>
fun j => ((x.2.2 j).1, key (x.2.2 j).2)) := by
apply Measurable.of_eval
intro j
have hj : Measurable (fun x : Seed bits Γ (Weights n Γ History n k) => x.2.2 j) :=
(measurable_pi_apply j).comp (measurable_snd.comp measurable_snd)
exact (measurable_fst.comp hj).prodMk (hkey.comp (measurable_snd.comp hj))
exact hc.comp (measurable_fst.prodMk (hs.prodMk hh))
lemma optimum_le_of_independent_bound {n : β} (M : Matroid (Fin n)) (w : Weights n)
(c : β) (hc : 0 β€ c)
(hbound : β I : Finset (Fin n), M.Indep (I : Set (Fin n)) β (β e β I, w e) β€ c) :
optimum M w β€ c := by
classical
apply Finset.sup'_le
intro I hI
by_cases hi : M.Indep (I : Set (Fin n))
Β· simpa only [ite_eq_left hi] using hbound I hi
Β· simpa only [ite_eq_right hi] using hc
theorem optimum_mono {n : β} (M : Matroid (Fin n)) (v w : Weights n)
(hvw : β e, v e β€ w e) : optimum M v β€ optimum M w := by
apply optimum_le_of_independent_bound M v _ (optimum_nonneg M w)
intro I hI
exact (Finset.sum_le_sum (fun e _ => hvw e)).trans (sum_le_optimum M w I hI)
theorem optimum_rounding_bound {n : β} (M : Matroid (Fin n)) (B : β) (hB : 1 < B)
(w : Weights n) (hw : β e, 0 β€ w e) :
optimum M w β€ B * optimum M (fun e => roundedWeight B (w e)) := by
apply optimum_le_of_independent_bound M w _
(mul_nonneg (zero_lt_one.trans hB).le (optimum_nonneg M _))
intro I hI
calc
(β e β I, w e) β€ β e β I, B * roundedWeight B (w e) :=
Finset.sum_le_sum (fun e _ => le_base_mul_roundedWeight hB (hw e))
_ = B * β e β I, roundedWeight B (w e) := (Finset.mul_sum ..).symm
_ β€ B * optimum M (fun e => roundedWeight B (w e)) :=
mul_le_mul_of_nonneg_left (sum_le_optimum M _ I hI) (zero_lt_one.trans hB).le
end MatroidProphet
end OAI
|