Download data/lean/OAI/NumberTheory/Jacobsthal/Partitions/GoodSampleSelection.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 3.99 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/NumberTheory/Jacobsthal/Partitions/GoodSampleSelection.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/NumberTheory/Jacobsthal/Partitions/GoodSampleSelection.lean
-
curl -L -o GoodSampleSelection.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/NumberTheory/Jacobsthal/Partitions/GoodSampleSelection.lean
3.99 kB
| import OAI.NumberTheory.Jacobsthal.Paths.SampleWitnessAverage | |
| namespace OAI | |
| namespace Erdos970 | |
| open scoped _root_.Erdos970 | |
| section | |
| namespace ErdosInverseSampling | |
| attribute [local instance] Classical.propDecidable | |
| attribute [local instance] Classical.decEq | |
| theorem exists_reward_cost_sample {Ξ© : Type*} (S : Finset Ξ©) (hS : S.Nonempty) | |
| (reward cost : Ξ© β β) (gamma tau : β) (hg : 0 < gamma) (ht : 0 < tau) | |
| (hr : β s β S,reward s β€ 1) (hc : β s β S,0 β€ cost s) | |
| (hreward : gamma*(S.card : β) β€ β s β S,reward s) | |
| (hcost : (β s β S,cost s) β€ (gamma*tau/4)*(S.card : β)) : | |
| β s β S,gamma/2 β€ reward s β§ cost s β€ tau := by | |
| by_contra h | |
| push Not at h | |
| have hpoint (s : Ξ©) (hs : s β S) : reward s β€ gamma/2+cost s/tau := by | |
| by_cases hh : gamma/2 β€ reward s | |
| Β· have hct : tau < cost s := h s hs hh | |
| have hone : (1 : β) < cost s/tau := (lt_div_iffβ ht).mpr (by simpa using hct) | |
| linarith [hr s hs] | |
| Β· have hcn : 0 β€ cost s/tau := div_nonneg (hc s hs) ht.le | |
| linarith | |
| have hupper : (β s β S,reward s) β€ (S.card : β)*(gamma/2)+(β s β S,cost s)/tau := by | |
| calc | |
| _ β€ β s β S,(gamma/2+cost s/tau) := Finset.sum_le_sum hpoint | |
| _ = _ := by | |
| rw [Finset.sum_add_distrib] | |
| simp only [Finset.sum_const,nsmul_eq_mul,β Finset.sum_div] | |
| have hsmall : (β s β S,cost s)/tau β€ (gamma/4)*(S.card : β) := by | |
| apply (div_le_iffβ ht).mpr | |
| nlinarith only [hcost] | |
| have hN : (0 : β) < S.card := by exact_mod_cast Finset.card_pos.mpr hS | |
| have hpos : 0 < gamma*(S.card : β) := mul_pos hg hN | |
| nlinarith only [hreward,hupper,hsmall,hpos] | |
| theorem selectedFraction_le_one {Ξ± Ξ² : Type*} (A : Finset Ξ±) (U : Finset Ξ²) | |
| (witness : Ξ± β Ξ² β Prop) (h : β) (e : Sample U h) (hA : 0 < A.card) : | |
| selectedFraction A U witness h e β€ 1 := by | |
| have hAR : (0 : β) < A.card := by exact_mod_cast hA | |
| apply (div_le_iffβ hAR).mpr | |
| have hh : (selectedPairs A U witness h e).card β€ A.card := Finset.card_filter_le A _ | |
| simpa only [one_mul] using (Nat.cast_le.mpr hh : ((selectedPairs A U witness h e).card : β) β€ A.card) | |
| theorem exists_good_distinct_sample {Ξ± Ξ² : Type*} (A : Finset Ξ±) (U : Finset Ξ²) | |
| (witness : Ξ± β Ξ² β Prop) (h : β) (beta tau : β) (hb : 0 < beta) (hb1 : beta β€ 1) | |
| (ht : 0 < tau) (hA : 0 < A.card) (hU : 0 < U.card) | |
| (hdense : beta*(A.card : β)*(U.card : β) β€ ((witnessPairs A U witness).card : β)) | |
| (hsize : 4*(h : β)/beta β€ (U.card : β)) (cost : Sample U h β β) | |
| (hc : β e,0 β€ cost e) | |
| (hcost : sampleAverage U h cost β€ (((beta/2)*(beta/4)^h)*tau/4)) : | |
| β e : Sample U h,((beta/2)*(beta/4)^h)/2 β€ selectedFraction A U witness h e β§ cost e β€ tau := by | |
| let gamma := (beta/2)*(beta/4)^h | |
| have hg : 0 < gamma := by dsimp [gamma];positivity | |
| have hlen := sample_length_le U.card h beta hb hb1 hsize | |
| have hn : 0 < Fintype.card (Sample U h) := by rw [sample_card];exact Nat.descFactorial_pos.mpr hlen | |
| have hnR : (0 : β) < Fintype.card (Sample U h) := by exact_mod_cast hn | |
| have hreward := sample_incidence_average_lower A U witness h beta hb hb1 hA hU hdense hsize | |
| have hreward' : gamma*(Fintype.card (Sample U h) : β) β€ | |
| β e : Sample U h,selectedFraction A U witness h e := (le_div_iffβ hnR).mp hreward | |
| have hcost' : (β e : Sample U h,cost e) β€ (gamma*tau/4)*(Fintype.card (Sample U h) : β) := | |
| (div_le_iffβ hnR).mp hcost | |
| obtain β¨e,_he,her,hecβ© := exists_reward_cost_sample (Finset.univ : Finset (Sample U h)) | |
| (Finset.card_pos.mp (by simpa only [Finset.card_univ] using hn)) | |
| (selectedFraction A U witness h) cost gamma tau hg ht | |
| (fun e _ => selectedFraction_le_one A U witness h e hA) (fun e _ => hc e) | |
| (by simpa only [Finset.card_univ] using hreward') (by simpa only [Finset.card_univ] using hcost') | |
| exact β¨e,her,hecβ© | |
| end ErdosInverseSampling | |
| end | |
| end Erdos970 | |
| end OAI | |