File size: 15,624 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
import OAI.Computability.PerfectCompleteness.Machines.HierarchicalLowerMatrixInput
import OAI.Computability.PerfectCompleteness.Reduction.FixedRows

namespace OAI

section

namespace PerfectCompleteness.HierarchicalLowerInverse

noncomputable section

open scoped Classical
open TreeSourceSpaces HierarchicalArrays
open UniqueGamesTheorem.Foundations.Games
open UniqueGamesTheorem.Fourier.MatrixLevelBridge
open UniqueGamesTheorem.Appendix.RankLevelFilter

attribute [local instance] linearMapFintype

variable {branch rows : Nat → Nat} {n t : Nat}
  (slots : RecursiveSpaces.Slots branch n → Fin t → MixedSupport.Slot)
  (upper : Nodes branch n) (lowerLevel : Nat)
  (background : HierarchicalMatrixTable.Background (rows := rows) slots upper)

local instance lowerHFintype (d : HierarchicalFrozenTables.LowerNodes upper lowerLevel) :
    Fintype (HierarchicalDecoderTables.LowerH slots upper lowerLevel d) := Fintype.ofFinite _

abbrev Answer (d : HierarchicalFrozenTables.LowerNodes upper lowerLevel) :=
  HierarchicalDecoderTables.Answer slots upper lowerLevel d

local instance answerFintype (d : HierarchicalFrozenTables.LowerNodes upper lowerLevel) :
    Fintype (Answer slots upper lowerLevel d) :=
  HierarchicalAllDecoderTables.answerFintype slots upper lowerLevel d

local instance upperDualFintype : Fintype (HierarchicalAllDecoderTables.UpperAnswer slots upper) :=
  HierarchicalAllDecoderTables.upperDualFintype slots upper

def matrixTable {r : Nat}
    (d : HierarchicalFrozenTables.LowerNodes upper lowerLevel)
    (upperMatrix : HierarchicalMatrixTable.Matrix (rows := rows) slots upper)
    (A : ManyGoodRows.RowMap (Block rows upper) r)
    (table : HierarchicalAllDecoderTables.Input (rows := rows) slots upper lowerLevel r →
      Option (Answer slots upper lowerLevel d)) :
    HierarchicalLowerMatrixInput.Matrix (rows := rows) slots upper lowerLevel d →
      Option (Answer slots upper lowerLevel d) :=
  fun X => table (HierarchicalLowerMatrixInput.input slots upper lowerLevel
    background d upperMatrix A X)

variable (hbranch : ∀ k < n, 0 < branch k)

theorem matrixTable_tested {r s : Nat}
    (d : HierarchicalFrozenTables.LowerNodes upper lowerLevel)
    (upperMatrix : HierarchicalMatrixTable.Matrix (rows := rows) slots upper)
    (A : ManyGoodRows.RowMap (Block rows upper) r)
    (table : HierarchicalAllDecoderTables.Input (rows := rows) slots upper lowerLevel r →
      Option (Answer slots upper lowerLevel d))
    (hvalid : DecoderTableAdmissibility.Admissible
      (HierarchicalAllDecoderTables.RowValid slots upper lowerLevel hbranch r d s) table)
    (X : HierarchicalLowerMatrixInput.Matrix (rows := rows) slots upper lowerLevel d)
    (z : Answer slots upper lowerLevel d)
    (hz : matrixTable slots upper lowerLevel background d upperMatrix A table X = some z) :
    (LowerAffineSliceRank.testedGram
      (FunctionSpaceLowerRank.matrixForm
        (HierarchicalDecoderTables.LowerH slots upper lowerLevel d)
        (OddListExtraction.multiplicationForm
          (HierarchicalDecoderTables.LowerH slots upper lowerLevel d) z)) X).rank ≤ 1 := by
  have h := hvalid
    (HierarchicalLowerMatrixInput.input slots upper lowerLevel background d upperMatrix A X)
    z hz
  have ht := h.2.1
  simpa only [HierarchicalLowerMatrixInput.input_testedMatrix] using ht

theorem matrixTable_high_rank {r s : Nat}
    (d : HierarchicalFrozenTables.LowerNodes upper lowerLevel)
    (upperMatrix : HierarchicalMatrixTable.Matrix (rows := rows) slots upper)
    (A : ManyGoodRows.RowMap (Block rows upper) r)
    (table : HierarchicalAllDecoderTables.Input (rows := rows) slots upper lowerLevel r →
      Option (Answer slots upper lowerLevel d))
    (hvalid : DecoderTableAdmissibility.Admissible
      (HierarchicalAllDecoderTables.RowValid slots upper lowerLevel hbranch r d s) table)
    (X : HierarchicalLowerMatrixInput.Matrix (rows := rows) slots upper lowerLevel d)
    (z : Answer slots upper lowerLevel d)
    (hz : matrixTable slots upper lowerLevel background d upperMatrix A table X = some z) :
    s < Module.finrank F2 (LinearMap.range
      (FunctionSpaceLowerRank.matrixForm
        (HierarchicalDecoderTables.LowerH slots upper lowerLevel d)
        (OddListExtraction.multiplicationForm
          (HierarchicalDecoderTables.LowerH slots upper lowerLevel d) z))) := by
  rw [FunctionSpaceLowerRank.matrixForm_rank]
  exact (hvalid
    (HierarchicalLowerMatrixInput.input slots upper lowerLevel background d upperMatrix A X)
    z hz).2.2

theorem matrixTable_agreement_lt {r s m adviceRows : Nat}
    (d : HierarchicalFrozenTables.LowerNodes upper lowerLevel)
    (upperMatrix : HierarchicalMatrixTable.Matrix (rows := rows) slots upper)
    (A : ManyGoodRows.RowMap (Block rows upper) adviceRows)
    (table : HierarchicalAllDecoderTables.Input (rows := rows) slots upper lowerLevel adviceRows →
      Option (Answer slots upper lowerLevel d))
    (hvalid : DecoderTableAdmissibility.Admissible
      (HierarchicalAllDecoderTables.RowValid slots upper lowerLevel hbranch adviceRows d s) table)
    (ρ η : ℝ) (hm : 0 < m) (hρ : 0 < ρ) (hρ1 : ρ < 1)
    (hconstants : levelCutoffConstant r ρ + node (r + 1) < η)
    (hrows : 2 * m + r ≤ rows (Nodes.height (HierarchicalLeftDecoder.LowerNode upper lowerLevel d)))
    (herror : (2 : ℝ) ^ m / (2 : ℝ) ^ (s - 2 * r) +
      (2 : ℝ) ^ (2 * m) / (2 : ℝ) ^ (m * m) ≤ ρ) :
    PartialTableInverse.nonzeroAgreement
      (matrixTable slots upper lowerLevel background d upperMatrix A table) < η := by
  let f := matrixTable slots upper lowerLevel background d upperMatrix A table
  let form := fun z : Answer slots upper lowerLevel d =>
    FunctionSpaceLowerRank.matrixForm
      (HierarchicalDecoderTables.LowerH slots upper lowerLevel d)
      (OddListExtraction.multiplicationForm
        (HierarchicalDecoderTables.LowerH slots upper lowerLevel d) z)
  have tested : ∀ X z, f X = some z → (LowerAffineSliceRank.testedGram (form z) X).rank ≤ 1 :=
    fun X z hz => matrixTable_tested slots upper lowerLevel background hbranch
      d upperMatrix A table hvalid X z hz
  have high : ∀ X z, f X = some z → s < Module.finrank F2 (LinearMap.range (form z)) :=
    fun X z hz => matrixTable_high_rank slots upper lowerLevel background hbranch
      d upperMatrix A table hvalid X z hz
  have h := LowerAffineSliceRank.high_rank_agreement_lt f form tested r s ρ η
    hm hρ hρ1 hconstants hrows herror
  have herase : MatrixErasure.erase f (fun X => ∃ z, f X = some z ∧
      Module.finrank F2 (LinearMap.range (form z)) ≤ s) = f := by
    funext X
    apply MatrixErasure.erase_eq_of_not
    rintro ⟨z, hz, hrank⟩
    exact (not_le_of_gt (high X z hz)) hrank
  rw [herase] at h
  exact h

variable (σ : KeyStrategy.Strategy (TreeCanonical.locationCount branch n t))
  (useful : (bg : HierarchicalMatrixTable.Background (rows := rows) slots upper) →
    HierarchicalFrozenTables.QuotientMatrix slots upper lowerLevel bg → Prop)

include hbranch σ useful

theorem supported_matrixTable_agreement_lt {r s m adviceRows : Nat}
    (decoderDensity : ℝ) (hdecoderDensity : 0 < decoderDensity)
    (d : HierarchicalFrozenTables.LowerNodes upper lowerLevel)
    (upperMatrix : HierarchicalMatrixTable.Matrix (rows := rows) slots upper)
    (A : ManyGoodRows.RowMap (Block rows upper) adviceRows)
    (table : HierarchicalAllDecoderTables.Input (rows := rows) slots upper lowerLevel adviceRows →
      Option (Answer slots upper lowerLevel d))
    (hsupport : (HierarchicalAllDecoderTables.tableLaw slots upper lowerLevel hbranch σ useful
      adviceRows decoderDensity d s).weight table ≠ 0)
    (ρ η : ℝ) (hm : 0 < m) (hρ : 0 < ρ) (hρ1 : ρ < 1)
    (hconstants : levelCutoffConstant r ρ + node (r + 1) < η)
    (hrows : 2 * m + r ≤ rows (Nodes.height (HierarchicalLeftDecoder.LowerNode upper lowerLevel d)))
    (herror : (2 : ℝ) ^ m / (2 : ℝ) ^ (s - 2 * r) +
      (2 : ℝ) ^ (2 * m) / (2 : ℝ) ^ (m * m) ≤ ρ) :
    PartialTableInverse.nonzeroAgreement
      (matrixTable slots upper lowerLevel background d upperMatrix A table) < η := by
  exact matrixTable_agreement_lt slots upper lowerLevel background hbranch
    d upperMatrix A table
    (HierarchicalAllDecoderTables.supported_table_valid slots upper lowerLevel hbranch σ useful
      adviceRows decoderDensity hdecoderDensity d s table hsupport)
    ρ η hm hρ hρ1 hconstants hrows herror

theorem mean_matrixTable_agreement_le {r s m adviceRows : Nat}
    (decoderDensity : ℝ) (hdecoderDensity : 0 < decoderDensity)
    (d : HierarchicalFrozenTables.LowerNodes upper lowerLevel)
    (upperMatrix : HierarchicalMatrixTable.Matrix (rows := rows) slots upper)
    (A : ManyGoodRows.RowMap (Block rows upper) adviceRows)
    (ρ η : ℝ) (hm : 0 < m) (hρ : 0 < ρ) (hρ1 : ρ < 1)
    (hconstants : levelCutoffConstant r ρ + node (r + 1) < η)
    (hrows : 2 * m + r ≤ rows (Nodes.height (HierarchicalLeftDecoder.LowerNode upper lowerLevel d)))
    (herror : (2 : ℝ) ^ m / (2 : ℝ) ^ (s - 2 * r) +
      (2 : ℝ) ^ (2 * m) / (2 : ℝ) ^ (m * m) ≤ ρ) :
    (HierarchicalAllDecoderTables.tableLaw slots upper lowerLevel hbranch σ useful
      adviceRows decoderDensity d s).expectation
      (fun table => PartialTableInverse.nonzeroAgreement
        (matrixTable slots upper lowerLevel background d upperMatrix A table)) ≤ η := by
  apply DecoderTableAdmissibility.expectation_le_of_support
  intro table hsupport
  exact (supported_matrixTable_agreement_lt slots upper lowerLevel background hbranch
    σ useful decoderDensity hdecoderDensity d upperMatrix A table hsupport
    ρ η hm hρ hρ1 hconstants hrows herror).le

theorem supported_upper_matrixTable_agreement_lt {r s m adviceRows : Nat}
    (decoderDensity : ℝ) (hdecoderDensity : 0 < decoderDensity)
    (d : HierarchicalFrozenTables.LowerNodes upper lowerLevel)
    (upperMatrix : HierarchicalMatrixTable.Matrix (rows := rows) slots upper)
    (A : ManyGoodRows.RowMap (Block rows upper) adviceRows)
    (table : HierarchicalAllDecoderTables.Input (rows := rows) slots upper lowerLevel adviceRows →
      HierarchicalAllDecoderTables.UpperAnswer slots upper)
    (hsupport : (HierarchicalAllDecoderTables.upperTableLaw slots upper lowerLevel σ useful
      adviceRows decoderDensity).weight table ≠ 0)
    (ρ η : ℝ) (hm : 0 < m) (hρ : 0 < ρ) (hρ1 : ρ < 1)
    (hconstants : levelCutoffConstant r ρ + node (r + 1) < η)
    (hrows : 2 * m + r ≤ rows (Nodes.height (HierarchicalLeftDecoder.LowerNode upper lowerLevel d)))
    (herror : (2 : ℝ) ^ m / (2 : ℝ) ^ (s - 2 * r) +
      (2 : ℝ) ^ (2 * m) / (2 : ℝ) ^ (m * m) ≤ ρ) :
    PartialTableInverse.nonzeroAgreement
      (matrixTable slots upper lowerLevel background d upperMatrix A
        (HierarchicalAllDecoderTables.decodeTable slots upper lowerLevel hbranch adviceRows d s table)) < η := by
  exact matrixTable_agreement_lt slots upper lowerLevel background hbranch
    d upperMatrix A
    (HierarchicalAllDecoderTables.decodeTable slots upper lowerLevel hbranch adviceRows d s table)
    (HierarchicalAllDecoderTables.decoded_supported_table_valid slots upper lowerLevel hbranch
      σ useful adviceRows decoderDensity hdecoderDensity table hsupport d s)
    ρ η hm hρ hρ1 hconstants hrows herror

end
end PerfectCompleteness.HierarchicalLowerInverse

end

section

namespace PerfectCompleteness.HierarchicalFixedLowerInverse

noncomputable section

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

attribute [local instance] UniqueGamesTheorem.Appendix.RankLevelFilter.linearMapFintype

variable {δ : ℚ} (plan : FixedRows.Plan δ) (hδ : 0 < δ)
  {branch : Nat → Nat} {t : Nat}
  (slots : RecursiveSpaces.Slots branch plan.depth → Fin t → MixedSupport.Slot)
  (upper : Nodes branch plan.depth) (lowerLevel : Nat)
  (background : HierarchicalMatrixTable.Background
    (rows := FixedRows.rows plan) slots upper)

local instance lowerHFintype (d : HierarchicalFrozenTables.LowerNodes upper lowerLevel) :
    Fintype (HierarchicalDecoderTables.LowerH slots upper lowerLevel d) := Fintype.ofFinite _

local instance upperDualFintype : Fintype (HierarchicalAllDecoderTables.UpperAnswer slots upper) :=
  HierarchicalAllDecoderTables.upperDualFintype slots upper

variable (hbranch : ∀ k < plan.depth, 0 < branch k)
  (σ : KeyStrategy.Strategy (TreeCanonical.locationCount branch plan.depth t))
  (useful : (bg : HierarchicalMatrixTable.Background
      (rows := FixedRows.rows plan) slots upper) →
    HierarchicalFrozenTables.QuotientMatrix slots upper lowerLevel bg → Prop)

include hbranch σ useful

theorem supported_upper_matrixTable_agreement_lt {adviceRows : Nat}
    (decoderDensity : ℝ) (hdecoderDensity : 0 < decoderDensity)
    (d : HierarchicalFrozenTables.LowerNodes upper lowerLevel)
    (upperMatrix : HierarchicalMatrixTable.Matrix
      (rows := FixedRows.rows plan) slots upper)
    (A : ManyGoodRows.RowMap (Block (FixedRows.rows plan) upper) adviceRows)
    (table : HierarchicalAllDecoderTables.Input
      (rows := FixedRows.rows plan) slots upper lowerLevel adviceRows →
        HierarchicalAllDecoderTables.UpperAnswer slots upper)
    (hsupport : (HierarchicalAllDecoderTables.upperTableLaw slots upper lowerLevel σ useful
      adviceRows decoderDensity).weight table ≠ 0) :
    PartialTableInverse.nonzeroAgreement
      (HierarchicalLowerInverse.matrixTable slots upper lowerLevel background d upperMatrix A
        (HierarchicalAllDecoderTables.decodeTable slots upper lowerLevel hbranch adviceRows d
          (FixedRows.cutoff plan hδ) table)) <
      UpperParameterScalars.gamma (InitialParameters.useful δ) plan.density
        (InitialParameters.inverse δ) plan.order
        (FixedRows.rows plan (Nodes.height upper)) ^ 2 / 8 := by
  let lower := DescendingRows.lowerChoice (InitialParameters.useful_pos hδ)
    plan.density_pos (InitialParameters.inverse_pos hδ) plan.order
    (FixedRows.rows plan (Nodes.height upper))
  have hheight : Nodes.height (HierarchicalLeftDecoder.LowerNode upper lowerLevel d) =
      lowerLevel :=
    (RelativeDescendantProducts.relativeNode_height upper d.val.val).trans d.property
  have hproper : lowerLevel < Nodes.height upper := by
    rw [← hheight]
    exact (RelativeDescendantProducts.descendantIndex_below upper d.val).height_lt
  have hminimum : lower.minimumRows ≤ FixedRows.rows plan lowerLevel :=
    FixedRows.lower_row_requirement plan hδ hproper (Nodes.height_le upper)
  have hrows : 2 * lower.crossSize + lower.order ≤
      FixedRows.rows plan (Nodes.height (HierarchicalLeftDecoder.LowerNode upper lowerLevel d)) := by
    rw [hheight]
    exact lower.row_bound _ hminimum
  have hcutoff : lower.cutoff ≤ FixedRows.cutoff plan hδ := by
    simpa only [lower, FixedRows.rows, FixedRows.cutoff] using
      DescendingRows.tree_cutoff_le_common (InitialParameters.useful_pos hδ)
        plan.density_pos (InitialParameters.inverse_pos hδ) plan.order plan.depth
        plan.rootFirstRows (Nat.zero_lt_of_lt hproper) (Nodes.height_le upper)
  exact HierarchicalLowerInverse.supported_upper_matrixTable_agreement_lt
    (r := lower.order) (s := FixedRows.cutoff plan hδ) (m := lower.crossSize)
    slots upper lowerLevel background hbranch σ useful decoderDensity hdecoderDensity
    d upperMatrix A table hsupport lower.density _ lower.cross_pos lower.density_pos
    lower.density_lt_one lower.spectral hrows (lower.error_bound _ hcutoff).le

end
end PerfectCompleteness.HierarchicalFixedLowerInverse

end

end OAI