File size: 2,475 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
import OAI.Combinatorics.ContingencyTables.Dense.DenseBooleanStep
import OAI.Combinatorics.ContingencyTables.Dense.DenseFiniteWalk
import OAI.Combinatorics.ContingencyTables.Machines.FiniteWordWalk

namespace OAI

/-! # The dense bin draw as one bounded unbiased Boolean word -/

namespace ContingencyTables.GridBoundary

open scoped BigOperators Classical
open ResidualMixture FirstSuccess FairBits

noncomputable section

def gridWordEquiv (n k : β„•) : (Fin (n * k) β†’ Bool) ≃ (Fin n β†’ Fin k β†’ Bool) :=
  (Equiv.arrowCongr finProdFinEquiv.symm (Equiv.refl Bool)).trans (Equiv.curry _ _ _)

variable {I J : Type*} [Fintype I] [Fintype J] [DecidableEq I] [DecidableEq J]
variable {q : β„•}

def denseBooleanWalk (R : Option I β†’ β„•) (P : Option J β†’ β„•) (d : β„•)
    (e : I Γ— J ≃ Fin q) (a : Grid (I := Fin q) (4 * d ^ 8)) (n : β„•)
    (bits : Fin (n * denseStepBits d) β†’ Bool) : Grid (I := Fin q) (4 * d ^ 8) :=
  wordWalk (denseBitStep R P d e) a n (gridWordEquiv n (denseStepBits d) bits)

def denseBooleanWalkLaw (R : Option I β†’ β„•) (P : Option J β†’ β„•) (d : β„•)
    (e : I Γ— J ≃ Fin q) (a : Grid (I := Fin q) (4 * d ^ 8)) (n : β„•) :
    RationalLaw (Grid (I := Fin q) (4 * d ^ 8)) :=
  mapLaw (uniformLaw (Ξ± := Fin (n * denseStepBits d) β†’ Bool)) (denseBooleanWalk R P d e a n)

/-- Exactly n*(q_bin+8d^5) unbiased bits give the rational n-step law. -/
theorem denseBooleanWalkLaw_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) (a : Grid (I := Fin q) (4 * d ^ 8)) (n : β„•) :
    denseBooleanWalkLaw R P d e a n = rationalWalkLaw R P d hd hfree e n a := by
  have hk : (fun s => mapLaw (uniformLaw (Ξ± := Fin (denseStepBits d) β†’ Bool)) (denseBitStep R P d e s)) =
      finiteDenseStepLaw R P d e := funext (denseBitStepLaw_eq_finite R P d e)
  unfold denseBooleanWalkLaw denseBooleanWalk
  rw [← map_equiv (gridWordEquiv n (denseStepBits d)), uniform_equiv]
  change wordWalkLaw (denseBitStep R P d e) a n = _
  rw [wordWalkLaw_eq, hk]
  exact finiteDenseWalkLaw_eq R P d hd hR hP hRmax hPmax hdimR hdimP hfree htotal e a n

end

end ContingencyTables.GridBoundary

end OAI