File size: 15,913 Bytes
2f887db
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
import OAI.Computability.PerfectCompleteness.Decoding.CutProjectionAssembly
import OAI.Computability.PerfectCompleteness.Decoding.LowerCutPairLemmas
import OAI.Computability.PerfectCompleteness.Foundations.CutNativeForms
import OAI.Computability.PerfectCompleteness.Repetition.CleanPhysicalReplay
import OAI.Computability.PerfectCompleteness.Sampling.SourceChildMarkedLaw

namespace OAI

section

namespace PerfectCompleteness.LowerCutScalarProjection

open RecursiveSpaces DescendantSpaces TreeSourceSpaces HierarchicalArrays
open WholeArraySubtreeSplit WholeArrayInteriorExterior
open scoped Classical

noncomputable section

variable {branch : Nat → Nat} {n m t : Nat}

theorem scalarEquiv_HPullback :
    {n m : Nat} → (p : Path branch n (m + 1)) →
    (slots projected : Slots branch n → Fin t → MixedSupport.Slot) →
    (q : ∀ s k, MixedSupport.Projection (slots s k) (projected s k)) →
    (f : H (subtreeSlots p projected)) →
    LowerCutNodeCoordinates.scalarEquiv p slots
        (HPullback (fun s k => q (p.slotEmbedding s) k) f) =
      HPullback (ChildBlockProjection.nodeProjection q (upperNode p))
        (LowerCutNodeCoordinates.scalarEquiv p projected f)
  | _, _, .refl _, _, _, _, _ => rfl
  | _, _, .step i p, slots, projected, q, f =>
      scalarEquiv_HPullback p (childSlots slots i) (childSlots projected i)
        (fun s k => q (i, s) k) f

theorem projectionCast_apply
    {a b c d : Slots branch m → Fin t → MixedSupport.Slot}
    (hab : a = b) (hcd : c = d)
    (q : ∀ s k, MixedSupport.Projection (a s k) (c s k))
    (s : Slots branch m) (k : Fin t) :
    CutNativeForms.projectionCast hab hcd q s k =
      CutProjectionAssembly.castProjection
        (congrFun (congrFun hab s) k) (congrFun (congrFun hcd s) k) (q s k) := by
  cases hab
  cases hcd
  rfl

theorem projectionCast_fill (p : Path branch n (m + 1))
    (outside : Slots branch n → Fin t → MixedSupport.Slot)
    (left right : Slots branch (m + 1) → Fin t → MixedSupport.Slot)
    (q : ∀ s k, MixedSupport.Projection (left s k) (right s k)) :
    CutNativeForms.projectionCast
        (CleanPhysicalReplay.cutSlots_fill p outside left)
        (CleanPhysicalReplay.cutSlots_fill p outside right)
        (fun s k => CutProjectionAssembly.fillProjection p outside left right q
          (p.slotEmbedding s) k) = q := by
  funext s k
  rw [projectionCast_apply]
  exact CutProjectionAssembly.fillProjection_at_cut_cast p outside left right q s k

theorem inverse_spaceCast_HPullback
    {a b c d : Slots branch m → Fin t → MixedSupport.Slot}
    (hab : a = b) (hcd : c = d)
    (q : ∀ s k, MixedSupport.Projection (a s k) (c s k)) (f : H d) :
    CutNativeForms.spaceCast hab.symm
        (HPullback (CutNativeForms.projectionCast hab hcd q) f) =
      HPullback q (CutNativeForms.spaceCast hcd.symm f) := by
  cases hab
  cases hcd
  rfl

theorem fill_spaceCast_HPullback (p : Path branch n (m + 1))
    (outside : Slots branch n → Fin t → MixedSupport.Slot)
    (left right : Slots branch (m + 1) → Fin t → MixedSupport.Slot)
    (q : ∀ s k, MixedSupport.Projection (left s k) (right s k)) (f : H right) :
    CutNativeForms.spaceCast (CleanPhysicalReplay.cutSlots_fill p outside left).symm
        (HPullback q f) =
      HPullback
        (fun s k => CutProjectionAssembly.fillProjection p outside left right q
          (p.slotEmbedding s) k)
        (CutNativeForms.spaceCast
          (CleanPhysicalReplay.cutSlots_fill p outside right).symm f) := by
  have h := inverse_spaceCast_HPullback
    (CleanPhysicalReplay.cutSlots_fill p outside left)
    (CleanPhysicalReplay.cutSlots_fill p outside right)
    (fun s k => CutProjectionAssembly.fillProjection p outside left right q
      (p.slotEmbedding s) k) f
  rw [projectionCast_fill] at h
  exact h

theorem scalarEquiv_fill_HPullback (p : Path branch n (m + 1))
    (outside : Slots branch n → Fin t → MixedSupport.Slot)
    (left right : Slots branch (m + 1) → Fin t → MixedSupport.Slot)
    (q : ∀ s k, MixedSupport.Projection (left s k) (right s k)) (f : H right) :
    LowerCutNodeCoordinates.scalarEquiv p (CutSlotAssembly.fill p outside left)
        (CutNativeForms.spaceCast (CleanPhysicalReplay.cutSlots_fill p outside left).symm
          (HPullback q f)) =
      HPullback (ChildBlockProjection.nodeProjection
        (CutProjectionAssembly.fillProjection p outside left right q) (upperNode p))
        (LowerCutNodeCoordinates.scalarEquiv p (CutSlotAssembly.fill p outside right)
          (CutNativeForms.spaceCast
            (CleanPhysicalReplay.cutSlots_fill p outside right).symm f)) := by
  rw [fill_spaceCast_HPullback]
  exact scalarEquiv_HPullback p _ _ _ _

def nodeEquiv (slots : Slots branch n → Fin t → MixedSupport.Slot)
    {a b : Nodes branch n} (hab : a = b) :
    H (nodeSlots slots a) ≃ₗ[F2] H (nodeSlots slots b) := by
  rw [hab]

theorem nodeEquiv_HPullback
    (slots projected : Slots branch n → Fin t → MixedSupport.Slot)
    (q : ∀ s k, MixedSupport.Projection (slots s k) (projected s k))
    {a b : Nodes branch n} (hab : a = b) (f : H (nodeSlots projected a)) :
    nodeEquiv slots hab (HPullback (ChildBlockProjection.nodeProjection q a) f) =
      HPullback (ChildBlockProjection.nodeProjection q b) (nodeEquiv projected hab f) := by
  cases hab
  rfl

theorem spaceEquiv_HPullback (p : Path branch n (m + 1))
    (slots projected : Slots branch n → Fin t → MixedSupport.Slot)
    (upper : Nodes branch n) (level : Nat)
    (d : HierarchicalFrozenTables.LowerNodes upper level)
    (hnode : upperNode p = HierarchicalLeftDecoder.LowerNode upper level d)
    (q : ∀ s k, MixedSupport.Projection (slots s k) (projected s k))
    (f : H (subtreeSlots p projected)) :
    LowerCutDecoderForm.spaceEquiv p slots upper level d hnode
        (HPullback (fun s k => q (p.slotEmbedding s) k) f) =
      HPullback (ChildBlockProjection.nodeProjection q
        (HierarchicalLeftDecoder.LowerNode upper level d))
        (LowerCutDecoderForm.spaceEquiv p projected upper level d hnode f) := by
  change nodeEquiv slots hnode
      (LowerCutNodeCoordinates.scalarEquiv p slots
        (HPullback (fun s k => q (p.slotEmbedding s) k) f)) =
    HPullback (ChildBlockProjection.nodeProjection q
      (HierarchicalLeftDecoder.LowerNode upper level d))
      (nodeEquiv projected hnode (LowerCutNodeCoordinates.scalarEquiv p projected f))
  rw [scalarEquiv_HPullback, nodeEquiv_HPullback]

theorem spaceEquiv_fill_HPullback (p : Path branch n (m + 1))
    (outside : Slots branch n → Fin t → MixedSupport.Slot)
    (left right : Slots branch (m + 1) → Fin t → MixedSupport.Slot)
    (upper : Nodes branch n) (level : Nat)
    (d : HierarchicalFrozenTables.LowerNodes upper level)
    (hnode : upperNode p = HierarchicalLeftDecoder.LowerNode upper level d)
    (q : ∀ s k, MixedSupport.Projection (left s k) (right s k)) (f : H right) :
    LowerCutDecoderForm.spaceEquiv p (CutSlotAssembly.fill p outside left)
        upper level d hnode
        (CutNativeForms.spaceCast (CleanPhysicalReplay.cutSlots_fill p outside left).symm
          (HPullback q f)) =
      HPullback (ChildBlockProjection.nodeProjection
        (CutProjectionAssembly.fillProjection p outside left right q)
        (HierarchicalLeftDecoder.LowerNode upper level d))
        (LowerCutDecoderForm.spaceEquiv p (CutSlotAssembly.fill p outside right)
          upper level d hnode
          (CutNativeForms.spaceCast
            (CleanPhysicalReplay.cutSlots_fill p outside right).symm f)) := by
  rw [fill_spaceCast_HPullback]
  exact spaceEquiv_HPullback p _ _ upper level d hnode _ _

end
end PerfectCompleteness.LowerCutScalarProjection

end

section

namespace PerfectCompleteness.SourceQuestionLowerForms

noncomputable section

open scoped Classical
open RecursiveSpaces DescendantSpaces TreeSourceSpaces HierarchicalArrays
open UniqueGamesTheorem.Foundations.Games

section Casts

variable {branch : Nat → Nat} {height t : Nat} {C : Type*} [Fintype C]
  (rows : Nat → Nat)
  {source target : Slots branch (height + 1) → Fin t → MixedSupport.Slot}

def rawCast (h : source = target) :
    CutChildGrouping.Raw (C := C) source rows ≃ CutChildGrouping.Raw (C := C) target rows := by
  cases h
  exact Equiv.refl _

theorem rawCast_law (h : source = target) :
    (CutChildGrouping.rawLaw (C := C) source rows).pushforward (rawCast rows h) =
      CutChildGrouping.rawLaw (C := C) target rows := by
  cases h
  exact FiniteDistribution.pushforward_id _

theorem formCast_injective (h : source = target) :
    Function.Injective (CutNativeForms.formCast h) := by
  cases h
  exact Function.injective_id

theorem fullCollision_formCast (h : source = target)
    (F G : Option (ChildBilinearCollisionTransfer.ParentForm source)) :
    BilinearCollisionTransfer.fullCollision (F.map (CutNativeForms.formCast h))
        (G.map (CutNativeForms.formCast h)) =
      BilinearCollisionTransfer.fullCollision F G :=
  MultiplicationFormInjective.definedEqual_map_of_injective
    (CutNativeForms.formCast h) (formCast_injective h) F G

end Casts

variable {branch rows repeats : Nat → Nat} {n height t v m : Nat}
  (path : Path branch n (height + 1))
  (outside : Slots branch n → Fin t → MixedSupport.Slot)
  (placeholder : Slots branch (height + 1) → Fin t → MixedSupport.Slot)
  (clauses : Fin m → SourceClause.NormalizedClause v)

abbrev Questions := SourceChildMarkedLaw.Questions
  (branch := branch) (n := height) (t := t) (m := m)
abbrev Calls := Option (WholeCutCalls.Index rows repeats path)

def slots (q : Questions (branch := branch) (height := height) (t := t) (m := m)) :
    Slots branch n → Fin t → MixedSupport.Slot :=
  CutSlotAssembly.fill path outside (SourceChildMarkedLaw.questionSlots clauses q)

abbrev Raw (q : Questions (branch := branch) (height := height) (t := t) (m := m)) :=
  CutChildGrouping.Raw (C := Calls (rows := rows) (repeats := repeats) path)
    (SourceChildMarkedLaw.questionSlots clauses q) rows

abbrev Form (q : Questions (branch := branch) (height := height) (t := t) (m := m)) :=
  ChildBilinearCollisionTransfer.ParentForm (SourceChildMarkedLaw.questionSlots clauses q)

theorem cutSlots_eq (q : Questions (branch := branch) (height := height) (t := t) (m := m)) :
    WholeCutGrouping.cutSlots path (slots path outside clauses q) =
      SourceChildMarkedLaw.questionSlots clauses q :=
  CleanPhysicalReplay.cutSlots_fill path outside _

def rawAtCut (q : Questions (branch := branch) (height := height) (t := t) (m := m))
    (raw : Raw (rows := rows) (repeats := repeats) path clauses q) :
    LowerCutPair.Raw rows repeats path (slots path outside clauses q) :=
  rawCast rows (cutSlots_eq path outside clauses q).symm raw

theorem rawAtCut_law
    (q : Questions (branch := branch) (height := height) (t := t) (m := m)) :
    (CutChildGrouping.rawLaw (C := Calls (rows := rows) (repeats := repeats) path)
      (SourceChildMarkedLaw.questionSlots clauses q) rows).pushforward
        (rawAtCut (rows := rows) (repeats := repeats) path outside clauses q) =
      CutChildGrouping.rawLaw (C := Calls (rows := rows) (repeats := repeats) path)
        (WholeCutGrouping.cutSlots path (slots path outside clauses q)) rows :=
  rawCast_law rows (cutSlots_eq path outside clauses q).symm

variable (upper : Nodes branch n) (level : Nat)
  (d : HierarchicalFrozenTables.LowerNodes upper level)
  (hnode : WholeArrayInteriorExterior.upperNode path =
    HierarchicalLeftDecoder.LowerNode upper level d)
  (hbranch : ∀ k < n, 0 < branch k)
  {adviceRows : Nat} (A : ManyGoodRows.RowMap (Block rows upper) adviceRows)
  (exterior : CleanPhysicalReplay.Exterior rows repeats path outside placeholder)

abbrev UpperTable (q : Questions (branch := branch) (height := height) (t := t) (m := m)) :=
  HierarchicalAllDecoderTables.Input (rows := rows)
    (slots path outside clauses q) upper level adviceRows →
      HierarchicalAllDecoderTables.UpperAnswer (slots path outside clauses q) upper

variable (tables : (q : Questions (branch := branch) (height := height) (t := t) (m := m)) →
  UpperTable (rows := rows) path outside clauses upper level (adviceRows := adviceRows) q)
  (cutoff : Nat)

def first (q : Questions (branch := branch) (height := height) (t := t) (m := m))
    (raw : Raw (rows := rows) (repeats := repeats) path clauses q) : Option (Form clauses q) :=
  (LowerCutDecoderForm.first path (slots path outside clauses q) upper level d hnode hbranch A
    (tables q) cutoff
    (CleanPhysicalReplay.exteriorAt rows repeats path outside placeholder
      (SourceChildMarkedLaw.questionSlots clauses q) exterior)
    (rawAtCut path outside clauses q raw)).map
      (CutNativeForms.formCast (cutSlots_eq path outside clauses q))

def second (direction : BucketSampler.Direction (rows (height + 1)))
    (q : Questions (branch := branch) (height := height) (t := t) (m := m))
    (raw : Raw (rows := rows) (repeats := repeats) path clauses q) : Option (Form clauses q) :=
  (LowerCutDecoderForm.second path (slots path outside clauses q) upper level d hnode hbranch A
    (tables q) cutoff
    (CleanPhysicalReplay.exteriorAt rows repeats path outside placeholder
      (SourceChildMarkedLaw.questionSlots clauses q) exterior)
    direction (rawAtCut path outside clauses q raw)).map
      (CutNativeForms.formCast (cutSlots_eq path outside clauses q))

theorem fullCollision_probability
    (direction : BucketSampler.Direction (rows (height + 1)))
    (q : Questions (branch := branch) (height := height) (t := t) (m := m)) :
    (CutChildGrouping.rawLaw (C := Calls (rows := rows) (repeats := repeats) path)
      (SourceChildMarkedLaw.questionSlots clauses q) rows).probability
        (fun raw => BilinearCollisionTransfer.fullCollision
          (first path outside placeholder clauses upper level d hnode hbranch A exterior tables cutoff q raw)
          (second path outside placeholder clauses upper level d hnode hbranch A exterior tables cutoff
            direction q raw)) =
      (CutChildGrouping.rawLaw (C := Calls (rows := rows) (repeats := repeats) path)
        (WholeCutGrouping.cutSlots path (slots path outside clauses q)) rows).probability
        (fun raw => BilinearCollisionTransfer.fullCollision
          (LowerCutDecoderForm.first path (slots path outside clauses q) upper level d hnode hbranch A
            (tables q) cutoff (CleanPhysicalReplay.exteriorAt rows repeats path outside placeholder
              (SourceChildMarkedLaw.questionSlots clauses q) exterior) raw)
          (LowerCutDecoderForm.second path (slots path outside clauses q) upper level d hnode hbranch A
            (tables q) cutoff (CleanPhysicalReplay.exteriorAt rows repeats path outside placeholder
              (SourceChildMarkedLaw.questionSlots clauses q) exterior) direction raw)) := by
  have h := congrArg (fun μ : FiniteDistribution
      (CutChildGrouping.Raw (C := Calls (rows := rows) (repeats := repeats) path)
        (WholeCutGrouping.cutSlots path (slots path outside clauses q)) rows) => μ.probability
    (fun raw => BilinearCollisionTransfer.fullCollision
      (LowerCutDecoderForm.first path (slots path outside clauses q) upper level d hnode hbranch A
        (tables q) cutoff (CleanPhysicalReplay.exteriorAt rows repeats path outside placeholder
          (SourceChildMarkedLaw.questionSlots clauses q) exterior) raw)
      (LowerCutDecoderForm.second path (slots path outside clauses q) upper level d hnode hbranch A
        (tables q) cutoff (CleanPhysicalReplay.exteriorAt rows repeats path outside placeholder
          (SourceChildMarkedLaw.questionSlots clauses q) exterior) direction raw)))
    (rawAtCut_law (rows := rows) (repeats := repeats) path outside clauses q)
  rw [FiniteDistribution.probability_pushforward] at h
  simpa only [first, second, fullCollision_formCast] using h

end
end PerfectCompleteness.SourceQuestionLowerForms

end

end OAI