math / data /lean /OAI /Combinatorics /ContingencyTables /Dense /DenseBooleanDraw.lean
introvoyz045's picture
Migrated from GitHub
4a56cd6 verified
Raw History Blame Contribute Delete
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