math / data /lean /OAI /Probability /MatroidProphet /Residual /Probability.lean
introvoyz045's picture
Migrated from GitHub
4a56cd6 verified
Raw History Blame Contribute Delete
5.5 kB
import OAI.Probability.MatroidProphet.ProductRestriction
import OAI.Probability.MatroidProphet.Residual.Constants
namespace OAI
namespace MatroidProphet
open Finset
variable {Ξ± : Type*} [DecidableEq Ξ±]
lemma bitsExpectation_contains (q : Ξ± β†’ ℝ) (V R : Finset Ξ±) (hR : R βŠ† V) :
bitsExpectation q V (fun S => if R βŠ† S then 1 else 0) = ∏ e ∈ R, q e := by
induction V using Finset.induction_on generalizing R with
| empty =>
have h : R = βˆ… := Finset.subset_empty.mp hR
subst R
simp
| @insert e V he ih =>
rw [bitsExpectation_insert q V e he]
by_cases heR : e ∈ R
Β· have hRV : R.erase e βŠ† V := by
intro x hx
have hm := hR (mem_of_mem_erase hx)
rcases mem_insert.mp hm with rfl | hm
Β· exact (notMem_erase _ _ hx).elim
Β· exact hm
have hzero : bitsExpectation q V (fun S => if R βŠ† S then 1 else 0) = 0 := by
conv_rhs => rw [← bitsExpectation_const q V 0]
apply bitsExpectation_congr
intro S hS
have hn : Β¬ R βŠ† S := fun hh => he (hS (hh heR))
simp [hn]
have hyes : bitsExpectation q V (fun S => if R βŠ† insert e S then 1 else 0) =
bitsExpectation q V (fun S => if R.erase e βŠ† S then 1 else 0) := by
apply bitsExpectation_congr
intro S hS
have hiff : R βŠ† insert e S ↔ R.erase e βŠ† S := by
constructor
Β· intro h x hx
exact (mem_insert.mp (h (mem_of_mem_erase hx))).resolve_left (ne_of_mem_erase hx)
Β· intro h x hx
by_cases hxe : x = e
Β· simp [hxe]
· exact mem_insert_of_mem (h (mem_erase.mpr ⟨hxe, hx⟩))
simp only [hiff]
rw [hzero, hyes, ih _ hRV]
simpa using (mul_prod_erase R q heR)
Β· have hRV : R βŠ† V := by
intro x hx
exact (mem_insert.mp (hR hx)).resolve_left (fun h => heR (h β–Έ hx))
have hyes : bitsExpectation q V (fun S => if R βŠ† insert e S then 1 else 0) =
bitsExpectation q V (fun S => if R βŠ† S then 1 else 0) := by
apply bitsExpectation_congr
intro S hS
have hiff : R βŠ† insert e S ↔ R βŠ† S := by
constructor
Β· intro h x hx
exact (mem_insert.mp (h hx)).resolve_left (fun h => heR (h β–Έ hx))
Β· exact fun h => h.trans (subset_insert e S)
simp only [hiff]
rw [hyes, ih _ hRV]
ring
lemma bitsExpectation_mul_const (q : Ξ± β†’ ℝ) (V : Finset Ξ±) (c : ℝ) (f : Finset Ξ± β†’ ℝ) :
bitsExpectation q V (fun S => c * f S) = c * bitsExpectation q V f := by
simp only [bitsExpectation, mul_sum]
apply sum_congr rfl
intro S hS
ring
lemma bitsExpectation_contains_le_half_pow (q : Ξ± β†’ ℝ)
(hq0 : βˆ€ e, 0 ≀ q e) (hqhalf : βˆ€ e, q e ≀ 1 / 2)
(V R : Finset Ξ±) (hR : R βŠ† V) :
bitsExpectation q V (fun S => if R βŠ† S then 1 else 0) ≀ (1 / 2 : ℝ) ^ R.card := by
rw [bitsExpectation_contains q V R hR]
simpa using prod_le_prodβ‚€ (fun e _ => hq0 e) (fun e _ => hqhalf e)
noncomputable def residualBad (F : Finset (Finset Ξ±)) (t : ℝ) (S : Finset Ξ±) : Prop :=
βˆƒ R ∈ F, t < (R.card : ℝ) ∧ R βŠ† S
noncomputable def residualBadIndicator (F : Finset (Finset Ξ±)) (t : ℝ) (S : Finset Ξ±) : ℝ := by
classical
exact if residualBad F t S then 1 else 0
lemma residualBad_indicator_le (F : Finset (Finset Ξ±)) (t : ℝ) (S : Finset Ξ±) :
residualBadIndicator F t S ≀
βˆ‘ R ∈ F, if t < (R.card : ℝ) then (if R βŠ† S then (1 : ℝ) else 0) else 0 := by
classical
unfold residualBadIndicator
split_ifs with hb
· obtain ⟨R, hRF, hRt, hRS⟩ := hb
have h := single_le_sum (f := fun R : Finset Ξ± =>
if t < (R.card : ℝ) then (if R βŠ† S then (1 : ℝ) else 0) else 0)
(fun R _ => by split_ifs <;> norm_num) hRF
simpa [hRt, hRS] using h
Β· exact sum_nonneg (fun R _ => by split_ifs <;> norm_num)
lemma bitsExpectation_residualBad_le (q : Ξ± β†’ ℝ)
(hq0 : βˆ€ e, 0 ≀ q e) (hqhalf : βˆ€ e, q e ≀ 1 / 2)
(V : Finset Ξ±) (F : Finset (Finset Ξ±)) (hF : βˆ€ R ∈ F, R βŠ† V) (t : ℝ) :
bitsExpectation q V (fun S => residualBadIndicator F t S) ≀
(F.card : ℝ) * Real.exp (-t * Real.log 2) := by
classical
have hq1 : βˆ€ e, q e ≀ 1 := fun e => (hqhalf e).trans (by norm_num)
calc
_ ≀ bitsExpectation q V (fun S => βˆ‘ R ∈ F,
if t < (R.card : ℝ) then (if R βŠ† S then (1 : ℝ) else 0) else 0) :=
bitsExpectation_mono q hq0 hq1 V (fun S _ => residualBad_indicator_le F t S)
_ = βˆ‘ R ∈ F, bitsExpectation q V (fun S =>
if t < (R.card : ℝ) then (if R βŠ† S then (1 : ℝ) else 0) else 0) := bitsExpectation_sum q V F _
_ ≀ βˆ‘ _R ∈ F, Real.exp (-t * Real.log 2) := by
apply sum_le_sum
intro R hRF
by_cases hRt : t < (R.card : ℝ)
Β· simp only [hRt, ite_true]
apply (bitsExpectation_contains_le_half_pow q hq0 hqhalf V R (hF R hRF)).trans
have heq : (1 / 2 : ℝ) ^ R.card = Real.exp (-(R.card : ℝ) * Real.log 2) := by
rw [neg_mul, Real.exp_neg, Real.exp_nat_mul, Real.exp_log (by norm_num)]
simp
rw [heq]
apply Real.exp_le_exp.mpr
have hlog : 0 ≀ Real.log 2 := Real.log_nonneg (by norm_num)
exact mul_le_mul_of_nonneg_right (by linarith) hlog
Β· simp only [hRt, ite_false, bitsExpectation_const]
exact Real.exp_nonneg _
_ = _ := by simp
end MatroidProphet
end OAI