File size: 10,611 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
import OAI.Computability.PerfectCompleteness.Decoding.CleanDecoderRateLemmas
import OAI.Computability.PerfectCompleteness.Repetition.CleanPhysicalCanonicalQuery

namespace OAI

section

namespace PerfectCompleteness.CleanNativeReplay

noncomputable section

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

section Transport

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

private theorem transport_target_heq (rows repeats : Nat → Nat)
    (p : Path branch n (h + 1))
    (reference target other : Slots branch n → Fin t → MixedSupport.Slot)
    (clean : Fin (branch h) → Prop) (heq : target = other)
    (hs : ∀ s, CutSamplerKeyLocality.keptLeaf p clean s → reference s = target s)
    (hs' : ∀ s, CutSamplerKeyLocality.keptLeaf p clean s → reference s = other s)
    (tape : WholeCutReplay.Tape rows repeats p reference clean) :
    HEq (WholeCutReplayKeys.transportTape rows repeats p reference target clean hs tape)
      (WholeCutReplayKeys.transportTape rows repeats p reference other clean hs' tape) := by
  cases heq
  rfl

private theorem evaluateArrays_heq (rows repeats : Nat → Nat)
    (p : Path branch n (h + 1))
    (slots target : Slots branch n → Fin t → MixedSupport.Slot)
    (clean : Fin (branch h) → Prop) (hs : slots = target)
    (tape : WholeCutReplay.Tape rows repeats p slots clean)
    (other : WholeCutReplay.Tape rows repeats p target clean) (htape : HEq tape other) :
    HEq (WholeCutReplay.evaluateArrays rows repeats p slots clean tape)
      (WholeCutReplay.evaluateArrays rows repeats p target clean other) := by
  cases hs
  cases htape
  rfl

end Transport

variable {branch rows repeats : Nat → Nat} {n h t v m : Nat} [NeZero m]
  {upper : Nodes branch n} {d : HierarchicalFrozenTables.LowerNodes upper (h + 1)}
  (S : CleanDecoderRate.Setup branch rows repeats n h t v m upper d)

abbrev context (x : CleanDecoderRate.Sample S) := CleanDecoderPairLaw.context S x
abbrev leftOwn (x : CleanDecoderRate.Sample S) := CleanDecoderPairLaw.leftOwn S x
abbrev rightOwn (x : CleanDecoderRate.Sample S) := CleanDecoderPairLaw.rightOwn S x

abbrev leftSlots (x : CleanDecoderRate.Sample S) :=
  CleanPhysicalCanonicalQuery.leftSlots rows repeats (CleanDecoderRate.path S)
    S.outside S.clauses S.designated x

abbrev rightSlots (x : CleanDecoderRate.Sample S) :=
  CleanPhysicalCanonicalQuery.rightSlots rows repeats (CleanDecoderRate.path S)
    S.outside S.clauses S.designated x

abbrev leftTape (x : CleanDecoderRate.Sample S) :=
  CleanPhysicalReplay.leftTape rows repeats (CleanDecoderRate.path S)
    S.outside S.placeholder S.clauses S.designated x S.exterior

abbrev rightTape (x : CleanDecoderRate.Sample S) :=
  CleanPhysicalReplay.rightTape rows repeats (CleanDecoderRate.path S)
    S.outside S.placeholder S.clauses S.designated x S.exterior

theorem leftSlots_eq (x : CleanDecoderRate.Sample S) :
    CleanDecoderContext.leftSlots (context S x) (leftOwn S x) = leftSlots S x :=
  CleanRecordDecoderInput.leftSlots_eq rows repeats upper d S.cut S.outside S.placeholder
    S.clauses S.designated (CleanDecoderRate.observations S x) S.exterior x
    (CleanRecordDecoderInput.event_observe rows repeats upper d S.cut S.clauses S.designated x)

theorem rightSlots_eq (x : CleanDecoderRate.Sample S) :
    CleanDecoderContext.rightSlots (context S x) (rightOwn S x) = rightSlots S x :=
  CleanRecordDecoderInput.rightSlots_eq rows repeats upper d S.cut S.outside S.placeholder
    S.clauses S.designated (CleanDecoderRate.observations S x) S.exterior x
    (CleanRecordDecoderInput.event_observe rows repeats upper d S.cut S.clauses S.designated x)

theorem leftReplay_heq (x : CleanDecoderRate.Sample S) :
    HEq (CleanLeftDecoder.replay (CleanDecoderContext.leftExposed (context S x)) (leftOwn S x))
      (WholeCutReplay.erase rows repeats (CleanDecoderRate.path S) (leftSlots S x)
        (context S x).clean (leftTape S x)) := by
  let record := CleanDecoderRate.observations S x
  have hevent := CleanRecordDecoderInput.event_observe
    rows repeats upper d S.cut S.clauses S.designated x
  have hrecord := CleanPhysicalReplay.leftRecord_eq_erase
    rows repeats (CleanDecoderRate.path S) S.outside S.placeholder S.clauses S.designated
    record x hevent S.exterior
  have htransport := transport_target_heq rows repeats (CleanDecoderRate.path S)
    (CutSlotAssembly.fill (CleanDecoderRate.path S) S.outside
      (CleanRecordChildBlocks.leftRef rows S.clauses S.designated record))
    (CleanDecoderContext.leftSlots (context S x) (leftOwn S x)) (leftSlots S x)
    (context S x).clean (leftSlots_eq S x)
    (CleanEndpointSlots.leftSlots_kept_eq S.clauses S.designated (context S x).clean
      (context S x).visible (CleanDecoderRate.path S) S.outside (fun _ _ => 0) (leftOwn S x))
    (CutSlotAssembly.fill_kept_eq (CleanDecoderRate.path S) S.outside _ _ _
      (CleanPhysicalReplay.leftInside_nonclean rows repeats (CleanDecoderRate.path S)
        S.clauses S.designated record x hevent))
    (CleanPhysicalReplay.leftRecord rows repeats (CleanDecoderRate.path S)
      S.outside S.placeholder S.clauses S.designated record S.exterior)
  exact htransport.trans (heq_of_eq hrecord)

theorem rightReplay_heq (x : CleanDecoderRate.Sample S) :
    HEq (CleanRightDecoder.replay (context S x).clauses (context S x).designated
      (context S x).clean (context S x).visible (context S x).projected upper
      (CleanDecoderContext.lower (context S x)) (context S x).cut
      (CleanDecoderContext.lowerHeight upper d) (context S x).outside rows repeats
      (context S x).rightTape (rightOwn S x))
      (WholeCutReplay.erase rows repeats (CleanDecoderRate.path S) (rightSlots S x)
        (context S x).clean (rightTape S x)) := by
  let record := CleanDecoderRate.observations S x
  have hevent := CleanRecordDecoderInput.event_observe
    rows repeats upper d S.cut S.clauses S.designated x
  have hrecord := CleanPhysicalReplay.rightRecord_eq_erase
    rows repeats (CleanDecoderRate.path S) S.outside S.placeholder S.clauses S.designated
    record x hevent S.exterior
  have htransport := transport_target_heq rows repeats (CleanDecoderRate.path S)
    (CutSlotAssembly.fill (CleanDecoderRate.path S) S.outside
      (CleanRecordChildBlocks.rightRef rows S.clauses S.designated record))
    (CleanDecoderContext.rightSlots (context S x) (rightOwn S x)) (rightSlots S x)
    (context S x).clean (rightSlots_eq S x)
    (CleanEndpointSlots.rightSlots_kept_eq S.clauses S.designated (context S x).clean
      (context S x).visible (CleanDecoderRate.path S) S.outside (context S x).projected
      (fun _ _ => (S.clauses 0).variable 0) (rightOwn S x))
    (CutSlotAssembly.fill_kept_eq (CleanDecoderRate.path S) S.outside _ _ _
      (CleanPhysicalReplay.rightInside_nonclean rows repeats (CleanDecoderRate.path S)
        S.clauses S.designated record x hevent))
    (CleanPhysicalReplay.rightRecord rows repeats (CleanDecoderRate.path S)
      S.outside S.placeholder S.clauses S.designated record S.exterior)
  exact htransport.trans (heq_of_eq hrecord)

variable (cube : Nat) (hcube : 0 < cube)

theorem left_grouped_zero (x : CleanDecoderRate.Sample S)
    (hx : (CleanDecoderRate.rawLaw S cube hcube).weight x ≠ 0) :
    WholeCutZero.GroupedAtClean rows repeats (CleanDecoderRate.path S) (leftSlots S x)
      (context S x).clean (leftTape S x) :=
  CleanPhysicalReplay.leftTape_grouped_zero rows repeats (CleanDecoderRate.path S)
    S.outside S.placeholder S.clauses S.designated
    (fun _ => SourceOddLists.tupleLaw m t)
    (fun i => FiniteProduct.law
      (fun _ : {leaf : Slots branch h // leaf ≠ S.designated i} => SourceOddLists.tupleLaw m t))
    (fun _ => ProjectedCleanRate.projectionFlag cube hcube)
    (CleanDecoderRate.observations S x) x hx
    (CleanRecordDecoderInput.event_observe rows repeats upper d S.cut S.clauses S.designated x)
    S.exterior

theorem right_grouped_zero (x : CleanDecoderRate.Sample S)
    (hx : (CleanDecoderRate.rawLaw S cube hcube).weight x ≠ 0) :
    WholeCutZero.GroupedAtClean rows repeats (CleanDecoderRate.path S) (rightSlots S x)
      (context S x).clean (rightTape S x) :=
  CleanPhysicalReplay.rightTape_grouped_zero rows repeats (CleanDecoderRate.path S)
    S.outside S.placeholder S.clauses S.designated
    (fun _ => SourceOddLists.tupleLaw m t)
    (fun i => FiniteProduct.law
      (fun _ : {leaf : Slots branch h // leaf ≠ S.designated i} => SourceOddLists.tupleLaw m t))
    (fun _ => ProjectedCleanRate.projectionFlag cube hcube)
    (CleanDecoderRate.observations S x) x hx
    (CleanRecordDecoderInput.event_observe rows repeats upper d S.cut S.clauses S.designated x)
    S.exterior

theorem leftArrays_heq (x : CleanDecoderRate.Sample S)
    (hx : (CleanDecoderRate.rawLaw S cube hcube).weight x ≠ 0) :
    HEq (CleanLeftDecoder.arrays (CleanDecoderContext.leftExposed (context S x)) (leftOwn S x))
      (WholeCutSampler.evaluate rows repeats (CleanDecoderRate.path S) (leftSlots S x)
        (leftTape S x)) := by
  have h := evaluateArrays_heq rows repeats (CleanDecoderRate.path S)
    (CleanDecoderContext.leftSlots (context S x) (leftOwn S x)) (leftSlots S x)
    (context S x).clean (leftSlots_eq S x) _ _ (leftReplay_heq S x)
  exact h.trans (heq_of_eq (WholeCutReplay.evaluateArrays_erase_of_grouped_zero
    rows repeats (CleanDecoderRate.path S) (leftSlots S x) (context S x).clean
    (leftTape S x) (left_grouped_zero S cube hcube x hx)))

theorem rightArrays_heq (x : CleanDecoderRate.Sample S)
    (hx : (CleanDecoderRate.rawLaw S cube hcube).weight x ≠ 0) :
    HEq (CleanRightDecoder.arrays (context S x).clauses (context S x).designated
      (context S x).clean (context S x).visible (context S x).projected upper
      (CleanDecoderContext.lower (context S x)) (context S x).cut
      (CleanDecoderContext.lowerHeight upper d) (context S x).outside rows repeats
      (context S x).rightTape (rightOwn S x))
      (WholeCutSampler.evaluate rows repeats (CleanDecoderRate.path S) (rightSlots S x)
        (rightTape S x)) := by
  have h := evaluateArrays_heq rows repeats (CleanDecoderRate.path S)
    (CleanDecoderContext.rightSlots (context S x) (rightOwn S x)) (rightSlots S x)
    (context S x).clean (rightSlots_eq S x) _ _ (rightReplay_heq S x)
  exact h.trans (heq_of_eq (WholeCutReplay.evaluateArrays_erase_of_grouped_zero
    rows repeats (CleanDecoderRate.path S) (rightSlots S x) (context S x).clean
    (rightTape S x) (right_grouped_zero S cube hcube x hx)))

end
end PerfectCompleteness.CleanNativeReplay

end

end OAI