File size: 5,483 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 | 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
|