File size: 14,851 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 | import OAI.Computability.PerfectCompleteness.Construction.SourceChildKernelLemmas
import OAI.Computability.PerfectCompleteness.Decoding.CleanDecoderOddLists
import OAI.Computability.PerfectCompleteness.Decoding.CleanDecoderSeedLawLemmas
import OAI.Computability.PerfectCompleteness.Machines.CleanRecordDecoderInput
import OAI.Computability.PerfectCompleteness.Sampling.RecordSeedSamplingLemmas
namespace OAI
section
namespace PerfectCompleteness.CleanDecoderRate
noncomputable section
open scoped BigOperators Classical
open RecursiveSpaces DescendantSpaces TreeSourceSpaces HierarchicalArrays
open UniqueGamesTheorem.Foundations.Games
abbrev F2 := ZMod 2
structure Setup (branch rows repeats : Nat → Nat) (n h t v m : Nat) [NeZero m]
(upper : Nodes branch n) (d : HierarchicalFrozenTables.LowerNodes upper (h + 1)) where
clauses : Fin m → SourceClause.NormalizedClause v
designated : Fin (branch h) → Slots branch h
cut : OwnInputReference.Cut upper (HierarchicalLeftDecoder.LowerNode upper (h + 1) d)
outside : Slots branch n → Fin t → MixedSupport.Slot
placeholder : Slots branch (h + 1) → Fin t → MixedSupport.Slot
exterior : CleanPhysicalReplay.Exterior rows repeats
(CleanRecordDecoderInput.path upper d cut) outside placeholder
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 : Setup branch rows repeats n h t v m upper d)
abbrev path := CleanRecordDecoderInput.path upper d S.cut
abbrev Calls := WholeCutCalls.Index rows repeats (path S)
abbrev Record := CleanRecordDecoderInput.Record (t := t) rows repeats upper d S.cut
S.clauses S.designated
abbrev Sample := CleanRecordDecoderInput.Sample (t := t) rows repeats upper d S.cut
S.clauses S.designated
def context (record : Record S) :=
CleanRecordDecoderInput.exposed rows repeats upper d S.cut S.outside S.placeholder
S.clauses S.designated record S.exterior
abbrev Seed (record : Record S) := CleanDecoderSeedLaw.Seed (context S record)
instance seedFintype (record : Record S) : Fintype (Seed S record) :=
CleanDecoderSeedLaw.seedFintype (context S record)
abbrev observations (x : Sample S) : Record S :=
CleanRecordDecoderInput.observe rows repeats upper d S.cut S.clauses S.designated x
abbrev sources (record : Record S) (x : Sample S) :=
CleanRecordDecoderInput.sources rows repeats upper d S.cut S.clauses S.designated record x
def rawLaw (cube : Nat) (hcube : 0 < cube) : FiniteDistribution (Sample S) :=
SourceChildKernel.originalLaw (C := Calls S) (t := t) rows S.clauses S.designated
(fun _ => ProjectedCleanRate.projectionFlag cube hcube)
variable (σ : KeyStrategy.Strategy (TreeCanonical.locationCount branch n t))
(useful : (record : Record S) →
CleanLeftDecoder.Useful (CleanDecoderContext.leftExposed (context S record)) upper (h + 1))
(r : Nat) (ρ : ℝ) (A : ManyGoodRows.RowMap (Block rows upper) r)
(W : Submodule F2 (OwnInputReference.UpperVector rows upper))
(a : OwnInputReference.LowerVector rows (HierarchicalLeftDecoder.LowerNode upper (h + 1) d))
(threshold : ℝ)
def kernel (record : Record S) : FiniteDistribution (Seed S record) :=
CleanDecoderSeedLaw.seedLaw (context S record) σ (useful record) r ρ A W a threshold
def law (cube : Nat) (hcube : 0 < cube) :
FiniteDistribution (Σ x : Sample S, Seed S (observations S x)) :=
RecordSeedSampling.freshLaw (rawLaw S cube hcube) (observations S)
(kernel S σ useful r ρ A W a threshold)
variable (hbranch : ∀ k < n, 0 < branch k)
def agrees (s : Nat) (x : Sample S) (seed : Seed S (observations S x)) : Bool :=
decide
(OddListExtraction.formRank
(H (CleanDecoderOddLists.leftNative (context S (observations S x))
(CleanDecoderOddLists.leftQuestions (context S (observations S x))
(sources S (observations S x) x))))
(CleanDecoderContext.leftForm (context S (observations S x)) hbranch seed.1
(CleanDecoderOddLists.leftQuestions (context S (observations S x))
(sources S (observations S x) x))) ≤ s ∧
seed.2 (CleanDecoderOddLists.rightQuestions (context S (observations S x))
(sources S (observations S x) x)) =
CleanDecoderOddLists.target (context S (observations S x)) seed.1
(sources S (observations S x) x))
theorem bound {s L cube : Nat} [NeZero s] (hcube : 0 < cube) (hρ : 0 < ρ)
(repetition : ∀ k, ((SourceOddLists.game s S.clauses t).repetition k).value ≤
(RepetitionRate.halfRate L : ℝ) ^ k) :
(law S σ useful r ρ A W a threshold cube hcube).probability
(fun z => agrees S hbranch s z.1 z.2) ≤
(1 - ProjectedCleanRate.coefficient L branch h t (Fintype.card (Calls S)) rows /
(cube : ℝ) ^ 2) ^ (branch h) := by
unfold law
apply RecordSeedSampling.probability_le_of_supported_tables
intro table htable
let strategies := fun record : Record S =>
CleanDecoderOddLists.strategy (context S record) hbranch (Nat.pos_of_neZero s)
(table record).1 (table record).2
apply SourceChildKernelRate.bound_from_repetition rows S.clauses S.designated
hcube repetition _ strategies
intro record x hevent heventSeed
have hrecord : observations S x = record := by
apply of_decide_eq_true
exact (CleanRecordObservation.event_eq rows S.clauses S.designated record x).symm.trans hevent
subst record
have hseed := RecordSeedSampling.supported_row
(kernel S σ useful r ρ A W a threshold) table htable (observations S x)
have hleft := CleanDecoderSeedLaw.supported_left (context S (observations S x))
σ (useful (observations S x)) r ρ A W a threshold
(table (observations S x)) hseed
have hagrees : agrees S hbranch s x (table (observations S x)) = true :=
(Bool.and_eq_true_iff.mp heventSeed).2
have hactual := of_decide_eq_true hagrees
simp only [OccurrenceGame.wins, IndexedRepetition.game, SourceOddLists.game,
OddListGame.game, OccurrenceGame.ofProjection, strategies,
CleanDecoderOddLists.strategy, decide_eq_true_eq]
intro i
exact CleanDecoderOddLists.responses_accept (context S (observations S x)) hbranch
σ (useful (observations S x)) (Nat.pos_of_neZero s) r ρ hρ A
(table (observations S x)).1 hleft (table (observations S x)).2
(sources S (observations S x) x) hactual.2 hactual.1 i
theorem amplified_bound {s L cube : Nat} [NeZero s]
(γ : ℚ) (hγ : 0 < γ) (hγ1 : γ ≤ 1)
(ht : t = SourceOddLists.repetitionLength γ s hγ hγ1)
(hcube : 0 < cube) (hρ : 0 < ρ)
(gap : SourceAmplification.ClauseGap S.clauses γ)
(hL : 0 < L) (alphabet : SourceOddLists.alphabetLog s t ≤ L) :
(law S σ useful r ρ A W a threshold cube hcube).probability
(fun z => agrees S hbranch s z.1 z.2) ≤
(1 - ProjectedCleanRate.coefficient L branch h t (Fintype.card (Calls S)) rows /
(cube : ℝ) ^ 2) ^ (branch h) := by
apply bound S σ useful r ρ A W a threshold hbranch hcube hρ
subst t
exact SourceOddLists.repetition_halfRate S.clauses γ hγ hγ1 gap hL alphabet
end
end PerfectCompleteness.CleanDecoderRate
end
section
namespace PerfectCompleteness.CleanDecoderPairLaw
noncomputable section
open scoped Classical
open TreeSourceSpaces HierarchicalArrays
open UniqueGamesTheorem.Foundations.Games
abbrev F2 := ZMod 2
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) :=
CleanDecoderRate.context S (CleanDecoderRate.observations S x)
abbrev occurrences (x : CleanDecoderRate.Sample S) :=
CleanDecoderRate.sources S (CleanDecoderRate.observations S x) x
abbrev leftOwn (x : CleanDecoderRate.Sample S) :=
CleanDecoderOddLists.leftQuestions (context S x) (occurrences S x)
abbrev rightOwn (x : CleanDecoderRate.Sample S) :=
CleanDecoderOddLists.rightQuestions (context S x) (occurrences S x)
abbrev LeftAnswer (x : CleanDecoderRate.Sample S) :=
CleanDecoderSeedLaw.LeftAnswer (context S x) (leftOwn S x)
abbrev RightAnswer (x : CleanDecoderRate.Sample S) :=
CleanDecoderSeedLaw.RightAnswer (context S x) (rightOwn S x)
instance leftAnswerFintype (x : CleanDecoderRate.Sample S) : Fintype (LeftAnswer S x) :=
CleanLeftDecoder.upperAnswerFintype
(CleanDecoderContext.leftExposed (context S x)) upper (leftOwn S x)
instance rightAnswerFintype (x : CleanDecoderRate.Sample S) : Fintype (RightAnswer S x) :=
RightDecoder.scalarFintype (CleanDecoderContext.rightSlots (context S x) (rightOwn S x)) upper
abbrev Pair (x : CleanDecoderRate.Sample S) := LeftAnswer S x × RightAnswer S x
instance pairFintype (x : CleanDecoderRate.Sample S) : Fintype (Pair S x) :=
inferInstanceAs (Fintype (LeftAnswer S x × RightAnswer S x))
def read (x : CleanDecoderRate.Sample S)
(seed : CleanDecoderRate.Seed S (CleanDecoderRate.observations S x)) : Pair S x :=
(seed.1 (leftOwn S x), seed.2 (rightOwn S x))
def readSample
(z : Σ x : CleanDecoderRate.Sample S, CleanDecoderRate.Seed S (CleanDecoderRate.observations S x)) :
Σ x : CleanDecoderRate.Sample S, Pair S x :=
⟨z.1, read S z.1 z.2⟩
variable (σ : KeyStrategy.Strategy (TreeCanonical.locationCount branch n t))
(useful : (record : CleanDecoderRate.Record S) →
CleanLeftDecoder.Useful (CleanDecoderContext.leftExposed (CleanDecoderRate.context S record))
upper (h + 1))
(r : Nat) (ρ : ℝ) (A : ManyGoodRows.RowMap (Block rows upper) r)
(W : Submodule F2 (OwnInputReference.UpperVector rows upper))
(a : OwnInputReference.LowerVector rows (HierarchicalLeftDecoder.LowerNode upper (h + 1) d))
(threshold : ℝ)
def pairKernel (x : CleanDecoderRate.Sample S) : FiniteDistribution (Pair S x) :=
(CleanDecoderSeedLaw.leftKernel (context S x) σ (useful (CleanDecoderRate.observations S x))
r ρ A (leftOwn S x)).product
(CleanDecoderSeedLaw.rightKernel (context S x) σ W a threshold (rightOwn S x))
def pairLaw (cube : Nat) (hcube : 0 < cube) :
FiniteDistribution (Σ x : CleanDecoderRate.Sample S, Pair S x) :=
CompletionSoundness.sigmaLaw (CleanDecoderRate.rawLaw S cube hcube)
(pairKernel S σ useful r ρ A W a threshold)
theorem read_law (x : CleanDecoderRate.Sample S) :
(CleanDecoderRate.kernel S σ useful r ρ A W a threshold
(CleanDecoderRate.observations S x)).pushforward (read S x) =
pairKernel S σ useful r ρ A W a threshold x :=
CleanDecoderSeedLaw.read_law (context S x) σ (useful (CleanDecoderRate.observations S x))
r ρ A W a threshold (leftOwn S x) (rightOwn S x)
theorem probability_read (cube : Nat) (hcube : 0 < cube)
(event : (x : CleanDecoderRate.Sample S) → Pair S x → Bool) :
(pairLaw S σ useful r ρ A W a threshold cube hcube).probability
(fun z => event z.1 z.2) =
(CleanDecoderRate.law S σ useful r ρ A W a threshold cube hcube).probability
(fun z => event z.1 (read S z.1 z.2)) := by
rw [pairLaw, CleanDecoderRate.law, RecordSeedSampling.freshLaw,
CompletionSoundness.sigmaLaw_probability, CompletionSoundness.sigmaLaw_probability]
apply FiniteDistribution.expectation_congr
intro x
exact (CleanDecoderSeedLaw.probability_read (context S x) σ
(useful (CleanDecoderRate.observations S x)) r ρ A W a threshold
(leftOwn S x) (rightOwn S x) (fun left right => event x (left, right))).symm
theorem law_pushforward (cube : Nat) (hcube : 0 < cube) :
(CleanDecoderRate.law S σ useful r ρ A W a threshold cube hcube).pushforward (readSample S) =
pairLaw S σ useful r ρ A W a threshold cube hcube := by
apply FiniteDistribution.eq_of_weight_eq
intro answer
rw [FiniteDistribution.weight_eq_probability_singleton,
FiniteDistribution.weight_eq_probability_singleton, FiniteDistribution.probability_pushforward]
have readProbability := probability_read S σ useful r ρ A W a threshold cube hcube
(fun sample pair =>
decide ((⟨sample, pair⟩ : Σ x : CleanDecoderRate.Sample S, Pair S x) = answer))
simp only [Sigma.eta] at readProbability
convert readProbability.symm using 1
congr 1
variable (hbranch : ∀ k < n, 0 < branch k)
def pairAgrees (s : Nat) (x : CleanDecoderRate.Sample S) (answer : Pair S x) : Bool :=
decide
(OddListExtraction.formRank
(H (CleanDecoderOddLists.leftNative (context S x) (leftOwn S x)))
(CleanLeftDecoder.form (CleanDecoderContext.leftExposed (context S x)) upper (h + 1)
hbranch d (leftOwn S x) answer.1) ≤ s ∧
answer.2 = DecoderSourcePullback.upperTarget
(CleanDecoderOddLists.fullProjection (context S x) (occurrences S x)) upper answer.1)
@[simp] theorem pairAgrees_read (s : Nat) (x : CleanDecoderRate.Sample S)
(seed : CleanDecoderRate.Seed S (CleanDecoderRate.observations S x)) :
pairAgrees S hbranch s x (read S x seed) = CleanDecoderRate.agrees S hbranch s x seed := rfl
theorem pair_probability_eq (s cube : Nat) (hcube : 0 < cube) :
(pairLaw S σ useful r ρ A W a threshold cube hcube).probability
(fun z => pairAgrees S hbranch s z.1 z.2) =
(CleanDecoderRate.law S σ useful r ρ A W a threshold cube hcube).probability
(fun z => CleanDecoderRate.agrees S hbranch s z.1 z.2) := by
exact probability_read S σ useful r ρ A W a threshold cube hcube (pairAgrees S hbranch s)
theorem bound {s L cube : Nat} [NeZero s] (hcube : 0 < cube) (hρ : 0 < ρ)
(repetition : ∀ k, ((SourceOddLists.game s S.clauses t).repetition k).value ≤
(RepetitionRate.halfRate L : ℝ) ^ k) :
(pairLaw S σ useful r ρ A W a threshold cube hcube).probability
(fun z => pairAgrees S hbranch s z.1 z.2) ≤
(1 - ProjectedCleanRate.coefficient L branch h t
(Fintype.card (CleanDecoderRate.Calls S)) rows / (cube : ℝ) ^ 2) ^ (branch h) := by
rw [pair_probability_eq]
exact CleanDecoderRate.bound S σ useful r ρ A W a threshold hbranch hcube hρ repetition
theorem amplified_bound {s L cube : Nat} [NeZero s]
(γ : ℚ) (hγ : 0 < γ) (hγ1 : γ ≤ 1)
(ht : t = SourceOddLists.repetitionLength γ s hγ hγ1)
(hcube : 0 < cube) (hρ : 0 < ρ)
(gap : SourceAmplification.ClauseGap S.clauses γ)
(hL : 0 < L) (alphabet : SourceOddLists.alphabetLog s t ≤ L) :
(pairLaw S σ useful r ρ A W a threshold cube hcube).probability
(fun z => pairAgrees S hbranch s z.1 z.2) ≤
(1 - ProjectedCleanRate.coefficient L branch h t
(Fintype.card (CleanDecoderRate.Calls S)) rows / (cube : ℝ) ^ 2) ^ (branch h) := by
rw [pair_probability_eq]
exact CleanDecoderRate.amplified_bound S σ useful r ρ A W a threshold hbranch
γ hγ hγ1 ht hcube hρ gap hL alphabet
end
end PerfectCompleteness.CleanDecoderPairLaw
end
end OAI
|