File size: 5,130 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
import OAI.Computability.PerfectCompleteness.Construction.HiddenBucketBias
import OAI.Computability.PerfectCompleteness.Reduction.PreliminaryAveraging
import OAI.Computability.PerfectCompleteness.Sampling.StoppedUsefulPairLaw

namespace OAI

section

namespace PerfectCompleteness.StoppedBucketUsefulProbability

noncomputable section

open scoped Classical
open RecursiveSpaces DescendantSpaces TreeSourceSpaces HierarchicalArrays
open OriginalWholeCutTape WholeArrayInteriorExterior
open UniqueGamesTheorem.Foundations.Games
open UniqueGamesTheorem.Appendix.RankLevelFilter (linearMapFintype)

attribute [local instance] linearMapFintype

private theorem probability_product_fst {A B : Type*} [Fintype A] [Fintype B]
    (μ : FiniteDistribution A) (ν : FiniteDistribution B) (event : A → Bool) :
    (μ.product ν).probability (fun z => event z.1) = μ.probability event := by
  have h := FiniteDistribution.probability_pushforward (μ.product ν) Prod.fst event
  rw [HiddenBucketBias.product_fst] at h
  exact h.symm

variable {branch : Nat → Nat} {N j i t : Nat}
  (rows repeats : Nat → Nat) (p : Path branch N (j + 1))
  (chosen : Fin (branch j)) (q : Path branch j i)
  (native right : Slots branch N → Fin t → MixedSupport.Slot)
  (projection : ∀ s a, MixedSupport.Projection (native s a) (right s a))

local instance rowSpaceFintype : Fintype (NodeEmbedding.RowSpace native (upperNode p)) :=
  Fintype.ofFinite _

local instance backgroundFintype :
    Fintype (HierarchicalMatrixTable.Background (rows := rows) native (upperNode p)) :=
  Fintype.ofFinite _

variable (hrows : 0 < rows (j + 1)) (lowerLevel : Nat) {Ω : Type*} [Fintype Ω]
  (original : FiniteDistribution Ω) (arrays : Ω → Arrays native rows)
  (lowerEvent : Ω → Bool) (κ : ℝ)
  (σ : KeyStrategy.Strategy (TreeCanonical.locationCount branch N t))

theorem usefulEvent_observe
    (sample : StoppedUsefulPairLaw.Sample rows repeats p chosen q right) :
    HierarchicalUsefulCollision.usefulEvent native (upperNode p) lowerLevel
        original arrays lowerEvent κ σ
        (StoppedUsefulPairLaw.background rows repeats p chosen q native right projection)
        (StoppedUsefulPairLaw.observe rows repeats p chosen q native right projection sample) =
      HierarchicalUsefulCollision.usefulAccepted native (upperNode p) lowerLevel
        original arrays lowerEvent κ σ
        (StoppedUsefulPairLaw.background rows repeats p chosen q native right projection
          (StoppedUsefulPairLaw.readout rows repeats p chosen q native right projection sample.2.1).1)
        (CutNodeRows.directionEquiv rows p sample.1)
        (CutNodeRows.bucketTapeEquiv rows p native
          (StoppedUsefulPairLaw.readout rows repeats p chosen q native right projection sample.2.1).2) :=
  rfl

theorem useful_probability_eq :
    (HierarchicalUsefulCollision.law native (upperNode p)
      (StoppedUsefulPairLaw.externalLaw rows repeats p chosen q right)
      (StoppedUsefulPairLaw.scalarLaw rows repeats p chosen q native right projection)
      (by simpa only [upperNode_height] using hrows)).probability
        (HierarchicalUsefulCollision.usefulEvent native (upperNode p) lowerLevel
          original arrays lowerEvent κ σ
          (StoppedUsefulPairLaw.background rows repeats p chosen q native right projection)) =
      (StoppedUsefulPairLaw.directionLaw rows j hrows).expectation (fun a =>
        (WholeArraySampler.tapeLaw rows repeats (p.append (.step chosen q)) right).probability
          (fun tape => HierarchicalUsefulCollision.usefulAccepted native (upperNode p) lowerLevel
            original arrays lowerEvent κ σ
            (StoppedUsefulPairLaw.background rows repeats p chosen q native right projection
              (StoppedUsefulPairLaw.readout rows repeats p chosen q native right projection tape).1)
            (CutNodeRows.directionEquiv rows p a)
            (CutNodeRows.bucketTapeEquiv rows p native
              (StoppedUsefulPairLaw.readout rows repeats p chosen q native right projection tape).2))) := by
  rw [← StoppedUsefulPairLaw.observe_law rows repeats p chosen q native right projection hrows,
    FiniteDistribution.probability_pushforward]
  simp_rw [usefulEvent_observe]
  rw [StoppedUsefulPairLaw.actualLaw, PreliminaryAveraging.probability_product]
  apply FiniteDistribution.expectation_congr
  intro a
  exact probability_product_fst
    (WholeArraySampler.tapeLaw rows repeats (p.append (.step chosen q)) right)
    (RecursiveSampler.law F2 repeats (.step chosen q) (LeafDomain (cutSlots p right)))
    (fun tape => HierarchicalUsefulCollision.usefulAccepted native (upperNode p) lowerLevel
      original arrays lowerEvent κ σ
      (StoppedUsefulPairLaw.background rows repeats p chosen q native right projection
        (StoppedUsefulPairLaw.readout rows repeats p chosen q native right projection tape).1)
      (CutNodeRows.directionEquiv rows p a)
      (CutNodeRows.bucketTapeEquiv rows p native
        (StoppedUsefulPairLaw.readout rows repeats p chosen q native right projection tape).2))

end
end PerfectCompleteness.StoppedBucketUsefulProbability

end

end OAI