Download data/lean/OAI/Probability/MatroidProphet/Residual/Probability.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 5.5 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Probability/MatroidProphet/Residual/Probability.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Probability/MatroidProphet/Residual/Probability.lean
-
curl -L -o Probability.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Probability/MatroidProphet/Residual/Probability.lean
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 | |
| | 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 | |