File size: 7,931 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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
import OAI.Computability.PerfectCompleteness.Algebra.BucketMatrixResampling
import OAI.Computability.PerfectCompleteness.Decoding.CollisionAveragingLemmas
import OAI.Computability.PerfectCompleteness.Decoding.RepresentativeBucketCollisionLemmas
import OAI.Computability.PerfectCompleteness.Foundations.QuarterBalanceLemmas

namespace OAI


namespace PerfectCompleteness.BucketUsefulCollision

noncomputable section

open scoped Classical
open ClauseSupport MixedSupport
open UniqueGamesTheorem.Foundations.Games
open BucketSampler (F2 Direction Tape)

section Product

variable {H : Type*} {β„“ : Nat}

def fill (a : Direction β„“)
    (b : FiniteProductSplit.Others (Ξ© := fun _ : Direction β„“ => H) a)
    (h : H) : Tape β„“ H :=
  fun d => if hd : d = a then h else b ⟨d, hd⟩

@[simp] theorem fill_self (a : Direction β„“)
    (b : FiniteProductSplit.Others (Ξ© := fun _ : Direction β„“ => H) a)
    (h : H) : fill a b h a = h := by
  simp [fill]

theorem fill_update (a : Direction β„“)
    (b : FiniteProductSplit.Others (Ξ© := fun _ : Direction β„“ => H) a)
    (h h' : H) : Function.update (fill a b h) a h' = fill a b h' := by
  funext d
  by_cases hd : d = a
  Β· subst d
    simp [fill]
  Β· simp only [Function.update_of_ne hd, fill, dite_eq_right hd]

theorem fill_others (a : Direction β„“) (t : Tape β„“ H) :
    fill a (FiniteProductSplit.others a t) (t a) = t := by
  funext d
  by_cases hd : d = a
  Β· subst d
    simp [fill]
  Β· simp only [fill, dite_eq_right hd, FiniteProductSplit.others]

theorem fill_others_update (a : Direction β„“) (t : Tape β„“ H) (h : H) :
    fill a (FiniteProductSplit.others a t) h = Function.update t a h := by
  rw [← fill_update a (FiniteProductSplit.others a t) (t a) h, fill_others]

private theorem probability_eq_expectation {A : Type*} [Fintype A]
    (ΞΌ : FiniteDistribution A) (event : A β†’ Bool) :
    ΞΌ.probability event = ΞΌ.expectation (fun x => if event x then 1 else 0) := by
  simp only [FiniteDistribution.probability, FiniteDistribution.expectation,
    mul_ite, mul_one, mul_zero]

variable [Fintype H]

theorem probability_background_first (ΞΌ : FiniteDistribution H)
    (a : Direction β„“) (event : Tape β„“ H β†’ Bool) :
    (BucketSampler.tapeLaw β„“ ΞΌ).probability event =
      (FiniteProductSplit.otherLaw (fun _ : Direction β„“ => ΞΌ) a).expectation
        (fun b => ΞΌ.probability (fun h => event (fill a b h))) := by
  have h := FiniteProductSplit.expectation_background_first
    (fun _ : Direction β„“ => ΞΌ) a
    (fun h b => if event (fill a b h) then (1 : ℝ) else 0)
  simpa only [fill_others, ← probability_eq_expectation, BucketSampler.tapeLaw] using h

theorem probability_resampling (ΞΌ : FiniteDistribution H)
    (a : Direction β„“) (event : Tape β„“ H β†’ Tape β„“ H β†’ Bool) :
    ((BucketSampler.tapeLaw β„“ ΞΌ).product ΞΌ).probability
        (fun z => event z.1 (Function.update z.1 a z.2)) =
      (FiniteProductSplit.otherLaw (fun _ : Direction β„“ => ΞΌ) a).expectation
        (fun b => (ΞΌ.product ΞΌ).probability
          (fun z => event (fill a b z.1) (fill a b z.2))) := by
  have h := FiniteProductSplit.resampling_expectation
    (fun _ : Direction β„“ => ΞΌ) a
    (fun b h h' => if event (fill a b h) (fill a b h') then (1 : ℝ) else 0)
  simp only [fill_others] at h
  simpa only [fill_others_update, ← probability_eq_expectation, BucketSampler.tapeLaw] using h

end Product


variable {n β„“ : Nat} {Z : Type*}
  (slots : Fin n β†’ Slot) (V : Submodule F2 (Assignment slots β†’ F2))
  (other : Assignment slots β†’ Z) (Οƒ : KeyStrategy.Strategy n)
  (W : Submodule F2 V) (s : (V β§Έ W) β†’β‚—[F2] V)

theorem assembledMatrix_fill (a : Direction β„“)
    (b : FiniteProductSplit.Others (Ξ© := fun _ : Direction β„“ => V) a) (h : V) :
    BucketMatrixResampling.assembledMatrix V β„“ (fill a b h) =
      EvaluationMatrix.shift V
        (BucketMatrixResampling.assembledMatrix V β„“ (fill a b 0)) a.val h := by
  have he := BucketMatrixResampling.assembledMatrix_update V β„“ (fill a b 0) a h
  rw [fill_update] at he
  simpa only [fill_self, sub_zero] using he

variable [Fintype V] [Finite Z]

theorem collision_probability_lower_bound
    (hs : W.mkQ.comp s = LinearMap.id)
    (hW : RepresentativeMatrixTable.Determined slots V other W)
    (ΞΌ : FiniteDistribution V)
    (useful : (Module.Dual F2 (V β§Έ W) β†’β‚—[F2] (Fin β„“ β†’ F2)) β†’ Prop)
    (a : Direction β„“) :
    (BucketSampler.tapeLaw β„“ ΞΌ).probability
        (fun t => decide (CanonicalMatrixTable.Accepts slots V other Οƒ a.val
          (BucketMatrixResampling.assembledMatrix V β„“ t)) &&
          (RepresentativeMatrixTable.partialTable slots V other Οƒ W s useful
            (MatrixRowQuotient.projectMatrix W
              (BucketMatrixResampling.assembledMatrix V β„“ t))).isSome) ^ 2 / 2 ≀
      ((BucketSampler.tapeLaw β„“ ΞΌ).product ΞΌ).probability
        (fun z => TwoResponseCollision.collision
          (RepresentativeMatrixTable.partialTable slots V other Οƒ W s useful)
          (MatrixRowQuotient.projectMatrix W
            (BucketMatrixResampling.assembledMatrix V β„“ z.1),
          MatrixRowQuotient.projectMatrix W
            (BucketMatrixResampling.assembledMatrix V β„“ (Function.update z.1 a z.2)))) := by
  let f := RepresentativeMatrixTable.partialTable slots V other Οƒ W s useful
  let good : Tape β„“ V β†’ Bool := fun t =>
    decide (CanonicalMatrixTable.Accepts slots V other Οƒ a.val
      (BucketMatrixResampling.assembledMatrix V β„“ t)) &&
      (f (MatrixRowQuotient.projectMatrix W
        (BucketMatrixResampling.assembledMatrix V β„“ t))).isSome
  let collision : Tape β„“ V β†’ Tape β„“ V β†’ Bool := fun t t' =>
    TwoResponseCollision.collision f
      (MatrixRowQuotient.projectMatrix W (BucketMatrixResampling.assembledMatrix V β„“ t),
        MatrixRowQuotient.projectMatrix W (BucketMatrixResampling.assembledMatrix V β„“ t'))
  change (BucketSampler.tapeLaw β„“ ΞΌ).probability good ^ 2 / 2 ≀
    ((BucketSampler.tapeLaw β„“ ΞΌ).product ΞΌ).probability
      (fun z => collision z.1 (Function.update z.1 a z.2))
  rw [probability_background_first ΞΌ a good, probability_resampling ΞΌ a collision]
  apply CollisionAveraging.average_square_bound
  intro b
  have hgood : (fun h : V => good (fill a b h)) =
      TwoResponseCollision.goodDefined
        (RepresentativeBucketCollision.bucketTable slots V other Οƒ W s useful a.val
          (BucketMatrixResampling.assembledMatrix V β„“ (fill a b 0)))
        (RepresentativeBucketCollision.bucketAccepted slots V other Οƒ a.val
          (BucketMatrixResampling.assembledMatrix V β„“ (fill a b 0))) := by
    funext h
    dsimp only [good, f, TwoResponseCollision.goodDefined,
      RepresentativeBucketCollision.bucketTable, RepresentativeBucketCollision.bucketAccepted]
    simp only [assembledMatrix_fill slots V a b h]
  have htable (h : V) :
      f (MatrixRowQuotient.projectMatrix W
        (BucketMatrixResampling.assembledMatrix V β„“ (fill a b h))) =
      RepresentativeBucketCollision.bucketTable slots V other Οƒ W s useful a.val
        (BucketMatrixResampling.assembledMatrix V β„“ (fill a b 0)) h := by
    dsimp only [f, RepresentativeBucketCollision.bucketTable]
    rw [assembledMatrix_fill slots V a b h]
  have hcollision :
      (fun z : V Γ— V => collision (fill a b z.1) (fill a b z.2)) =
      TwoResponseCollision.collision
        (RepresentativeBucketCollision.bucketTable slots V other Οƒ W s useful a.val
          (BucketMatrixResampling.assembledMatrix V β„“ (fill a b 0))) := by
    exact congrArg (fun g : V β†’ Option ((Fin β„“ β†’ F2) Γ— Z) =>
      TwoResponseCollision.collision g) (funext htable)
  rw [hgood, hcollision]
  exact RepresentativeBucketCollision.collision_probability_lower_bound
    slots V other Οƒ W s hs hW ΞΌ useful a.val a.property
      (BucketMatrixResampling.assembledMatrix V β„“ (fill a b 0))

end
end PerfectCompleteness.BucketUsefulCollision

end OAI