Download data/lean/OAI/Combinatorics/ContingencyTables/Dense/DenseBooleanDraw.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 5.48 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Combinatorics/ContingencyTables/Dense/DenseBooleanDraw.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Combinatorics/ContingencyTables/Dense/DenseBooleanDraw.lean
-
curl -L -o DenseBooleanDraw.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Combinatorics/ContingencyTables/Dense/DenseBooleanDraw.lean
5.48 kB
| import OAI.Combinatorics.ContingencyTables.Dense.DenseBooleanTrial | |
| import OAI.Combinatorics.ContingencyTables.Dense.DenseBoundedRejection | |
| import OAI.Combinatorics.ContingencyTables.Machines.FiniteWordRejection | |
| import OAI.Combinatorics.ContingencyTables.Dense.DenseBitBudget | |
| namespace OAI | |
| /-! # A bounded unbiased Boolean-word dense table draw -/ | |
| namespace ContingencyTables.GridBoundary | |
| open scoped BigOperators Classical | |
| open ResidualMixture FirstSuccess FairBits | |
| noncomputable section | |
| variable {I J : Type*} [Fintype I] [Fintype J] [DecidableEq I] [DecidableEq J] | |
| variable {q : β} | |
| def denseDrawBits (R : Option I β β) (P : Option J β β) (d : β) | |
| (e : I Γ J β Fin q) (h : β) : β := | |
| (d ^ 4 * (h + 1)) * denseTrialBits R P d e h | |
| def denseBooleanDraw (R : Option I β β) (P : Option J β β) (d : β) | |
| (hd : 14 β€ d) (hR : β i, d ^ 12 β€ R i) (hP : β j, d ^ 12 β€ P j) | |
| (e : I Γ J β Fin q) (htotal : β i, R i = β j, P j) (h : β) | |
| (a : Grid (I := Fin q) (4 * d ^ 8)) (fallback : Table R P) | |
| (bits : Fin (denseDrawBits R P d e h) β Bool) : Table R P := | |
| wordRetry (fun word => trialSuccess R P d e htotal (denseBooleanTrial R P d hd hR hP e h a word)) | |
| fallback (d ^ 4 * (h + 1)) (gridWordEquiv (d ^ 4 * (h + 1)) (denseTrialBits R P d e h) bits) | |
| def denseBooleanDrawLaw (R : Option I β β) (P : Option J β β) (d : β) | |
| (hd : 14 β€ d) (hR : β i, d ^ 12 β€ R i) (hP : β j, d ^ 12 β€ P j) | |
| (e : I Γ J β Fin q) (htotal : β i, R i = β j, P j) (h : β) | |
| (a : Grid (I := Fin q) (4 * d ^ 8)) (fallback : Table R P) : RationalLaw (Table R P) := | |
| mapLaw (uniformLaw (Ξ± := Fin (denseDrawBits R P d e h) β Bool)) | |
| (denseBooleanDraw R P d hd hR hP e htotal h a fallback) | |
| theorem denseBooleanDrawLaw_eq (R : Option I β β) (P : Option J β β) | |
| (d : β) (hd : 14 β€ d) (hR : β i, d ^ 12 β€ R i) (hP : β j, d ^ 12 β€ P j) | |
| (hRmax : β i, R (some i) β€ R none) (hPmax : β j, P (some j) β€ P none) | |
| (hdimR : Fintype.card (Option I) β€ d) (hdimP : Fintype.card (Option J) β€ d) | |
| (hfree : Fintype.card (I Γ J) β€ d) (htotal : β i, R i = β j, P j) | |
| (e : I Γ J β Fin q) (h : β) (a : Grid (I := Fin q) (4 * d ^ 8)) (fallback : Table R P) : | |
| denseBooleanDrawLaw R P d hd hR hP e htotal h a fallback = | |
| denseBoundedLaw R P d hd hR hP hfree e htotal h a fallback := by | |
| unfold denseBooleanDrawLaw denseBooleanDraw | |
| change mapLaw (uniformLaw (Ξ± := Fin ((d^4*(h+1))*denseTrialBits R P d e h) β Bool)) | |
| (fun bits => wordRetry | |
| (fun word => trialSuccess R P d e htotal (denseBooleanTrial R P d hd hR hP e h a word)) | |
| fallback (d^4*(h+1)) (gridWordEquiv (d^4*(h+1)) (denseTrialBits R P d e h) bits)) = _ | |
| rw [β map_equiv (gridWordEquiv (d ^ 4 * (h + 1)) (denseTrialBits R P d e h)), uniform_equiv] | |
| change wordRetryLaw | |
| (fun word => trialSuccess R P d e htotal (denseBooleanTrial R P d hd hR hP e h a word)) | |
| fallback (d ^ 4 * (h + 1)) = _ | |
| rw [wordRetryLaw_eq, β retryLaw_map, | |
| denseBooleanTrialLaw_eq R P d hd hR hP hRmax hPmax hdimR hdimP hfree htotal e h a] | |
| rfl | |
| /-- The actual finite Boolean draw always has codomain the feasible tables | |
| and its law satisfies the desired dense approximation guarantee. -/ | |
| theorem denseBooleanDraw_variation (R : Option I β β) (P : Option J β β) | |
| (d : β) (hd : 14 β€ d) (hR : β i, d ^ 12 β€ R i) (hP : β j, d ^ 12 β€ P j) | |
| (hRmax : β i, R (some i) β€ R none) (hPmax : β j, P (some j) β€ P none) | |
| (hdimR : Fintype.card (Option I) β€ d) (hdimP : Fintype.card (Option J) β€ d) | |
| (hfree : Fintype.card (I Γ J) β€ d) (htotal : β i, R i = β j, P j) | |
| (e : I Γ J β Fin q) (hPL : PublishedInputs.FiniteBoxPrekopaLeindler q) | |
| (hCheeger : PublishedInputs.FiniteCheeger (Grid (I := Fin q) (4 * d ^ 8))) | |
| (h : β) (a : Grid (I := Fin q) (4 * d ^ 8)) (fallback : Table R P) : | |
| let _ : Nonempty (Table R P) := β¨fallbackβ© | |
| (variation (denseBooleanDrawLaw R P d hd hR hP e htotal h a fallback) | |
| (uniformLaw (Ξ± := Table R P)) : β) β€ (2 : β) ^ (-(h : β)) := by | |
| let : Nonempty (Table R P) := β¨fallbackβ© | |
| rw [denseBooleanDrawLaw_eq R P d hd hR hP hRmax hPmax hdimR hdimP hfree htotal e h a fallback] | |
| exact denseBoundedLaw_variation R P d hd hR hP hRmax hPmax hdimR hdimP hfree htotal | |
| e hPL hCheeger h a fallback | |
| omit [Fintype I] [Fintype J] [DecidableEq I] [DecidableEq J] in | |
| /-- The full Boolean source has polynomial length in the declared dense | |
| parameters. -/ | |
| theorem denseDrawBits_polynomial (R : Option I β β) (P : Option J β β) | |
| (d C b h : β) (e : I Γ J β Fin q) (hq : q β€ d) | |
| (hwidth : β p, integerWidth R P d p β€ C) (hb : Nat.clog 2 (C + 2) β€ b) : | |
| denseDrawBits R P d e h β€ 25 * (d + b + h + 1) ^ 62 := by | |
| have hoff : (β j : Fin q, offsetBitLength (integerWidth R P d (e.symm j)) h d) β€ | |
| d * (b + 1 + 4 * (h + d)) := by | |
| calc | |
| _ β€ β _j : Fin q, (b + 1 + 4 * (h + d)) := | |
| Finset.sum_le_sum (fun j _ => denseOffsetBits_upper _ C b h d (hwidth _) hb) | |
| _ = q * (b + 1 + 4 * (h + d)) := by simp | |
| _ β€ _ := Nat.mul_le_mul_right _ hq | |
| apply (show denseDrawBits R P d e h β€ denseRandomBitBudget d b h from ?_).trans | |
| (denseRandomBitBudget_polynomial d b h) | |
| unfold denseDrawBits denseTrialBits denseRandomBitBudget | |
| exact Nat.mul_le_mul_left _ (Nat.add_le_add_left hoff _) | |
| end | |
| end ContingencyTables.GridBoundary | |
| end OAI | |