File size: 11,144 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 | import OAI.Computability.PerfectCompleteness.Construction.OriginalOwnBucketSplit
import OAI.Computability.PerfectCompleteness.Decoding.OriginalCutCollision
namespace OAI
section
namespace PerfectCompleteness.OriginalCutBucketLaw
open RecursiveSpaces DescendantSpaces TreeSourceSpaces HierarchicalArrays
open OriginalWholeCutTape
open UniqueGamesTheorem.Foundations.Games
open scoped Classical
noncomputable section
attribute [local instance 2000] OriginalWholeCutLaw.valuesBelowFintype
section Regrouping
private def reorder (D U B F : Type*) :
D × ((U × B) × F) ≃ B × (D × (U × F)) where
toFun z := (z.2.1.2, (z.1, (z.2.1.1, z.2.2)))
invFun z := (z.2.1, ((z.2.2.1, z.1), z.2.2.2))
left_inv _ := rfl
right_inv _ := rfl
private theorem reorder_law {D U B F : Type*}
[Fintype D] [Fintype U] [Fintype B] [Fintype F]
(directions : FiniteDistribution D) (own : FiniteDistribution U)
(background : FiniteDistribution B) (fresh : FiniteDistribution F) :
(directions.product ((own.product background).product fresh)).pushforward (reorder D U B F) =
background.product (directions.product (own.product fresh)) := by
rw [← FiniteDistribution.transport_eq_pushforward]
apply FiniteDistribution.eq_of_weight_eq
intro z
change directions.weight z.2.1 *
((own.weight z.2.2.1 * background.weight z.1) * fresh.weight z.2.2.2) =
background.weight z.1 *
(directions.weight z.2.1 * (own.weight z.2.2.1 * fresh.weight z.2.2.2))
ring
private theorem map_middle {D R S F : Type*}
[Fintype D] [Fintype R] [Fintype S] [Fintype F]
(directions : FiniteDistribution D) (records : FiniteDistribution R)
(fresh : FiniteDistribution F) (read : R → S) :
(directions.product (records.product fresh)).pushforward
(fun z => (z.1, (read z.2.1, z.2.2))) =
directions.product ((records.pushforward read).product fresh) := by
have hinner : (records.product fresh).pushforward (fun z => (read z.1, z.2)) =
(records.pushforward read).product fresh := by
simpa only [id_eq, FiniteDistribution.pushforward_id] using
FiniteDistribution.product_pushforward records fresh read (id : F → F)
calc
_ = (directions.pushforward id).product
((records.product fresh).pushforward (fun z => (read z.1, z.2))) :=
FiniteDistribution.product_pushforward directions (records.product fresh) id
(fun z => (read z.1, z.2))
_ = _ := by rw [FiniteDistribution.pushforward_id, hinner]
private theorem read_product_of_split {D R U B F : Type*}
[Fintype D] [Fintype R] [Fintype U] [Fintype B] [Fintype F]
(directions : FiniteDistribution D) (records : FiniteDistribution R)
(fresh : FiniteDistribution F) (own : FiniteDistribution U)
(background : FiniteDistribution B) (split : R → U × B)
(hsplit : records.pushforward split = own.product background) :
(directions.product (records.product fresh)).pushforward
(fun z => ((split z.2.1).2, (z.1, ((split z.2.1).1, z.2.2)))) =
background.product (directions.product (own.product fresh)) := by
calc
_ = ((directions.product (records.product fresh)).pushforward
(fun z => (z.1, (split z.2.1, z.2.2)))).pushforward (reorder D U B F) :=
(FiniteDistribution.pushforward_comp _ _ _).symm
_ = (directions.product ((own.product background).product fresh)).pushforward
(reorder D U B F) := by
rw [map_middle, hsplit]
_ = _ := reorder_law directions own background fresh
end Regrouping
variable {branch : Nat → Nat} {n m k t : Nat}
abbrev Background (rows : Nat → Nat) (p : Path branch n (m + 1))
(slots : Slots branch n → Fin t → MixedSupport.Slot) :=
HierarchicalMatrixTable.Background (rows := rows) slots (WholeArrayInteriorExterior.upperNode p)
local instance backgroundFintype (rows : Nat → Nat) (p : Path branch n (m + 1))
(slots : Slots branch n → Fin t → MixedSupport.Slot) :
Fintype (Background rows p slots) := Fintype.ofFinite _
abbrev NativeSample (rows : Nat → Nat) (p : Path branch n (m + 1))
(slots : Slots branch n → Fin t → MixedSupport.Slot) :=
Background rows p slots ×
(BucketSampler.Direction (rows (m + 1)) ×
(OriginalOwnBucketSplit.BucketTape rows p slots × H (cutSlots p slots)))
def read (rows repeats : Nat → Nat) (p : Path branch n (m + 1))
(slots : Slots branch n → Fin t → MixedSupport.Slot)
(sample : BucketSampler.Direction (rows (m + 1)) ×
OriginalExtraCutComparison.Record rows repeats p slots) : NativeSample rows p slots :=
(HierarchicalMatrixTable.backgroundOf slots (WholeArrayInteriorExterior.upperNode p)
(OriginalCutCollision.oldArrays rows repeats p slots sample.2),
(sample.1,
(OriginalCutBucketReplacement.ownValues rows repeats p slots
(OriginalCutCollision.oldRecord rows repeats p slots sample.2).2.1, sample.2.2)))
def recordRead (rows repeats : Nat → Nat) (p : Path branch n (m + 1))
(slots : Slots branch n → Fin t → MixedSupport.Slot)
(record : OriginalWholeCut.Record rows repeats p slots) :
OriginalOwnBucketSplit.BucketTape rows p slots × Background rows p slots :=
((OriginalOwnBucketSplit.recordEquiv rows repeats p slots record).1,
HierarchicalMatrixTable.backgroundOf slots (WholeArrayInteriorExterior.upperNode p)
(OriginalWholeCut.reconstructRecord rows repeats p slots record))
@[simp] theorem oldRecord_numberRecord (rows repeats : Nat → Nat)
(p : Path branch n (m + 1)) (slots : Slots branch n → Fin t → MixedSupport.Slot)
(record : OriginalWholeCut.Record rows repeats p slots) (fresh : H (cutSlots p slots)) :
OriginalCutCollision.oldRecord rows repeats p slots
(OriginalWholeCutBridge.numberRecord rows repeats p slots record, fresh) = record :=
(NumberedUniformCut.numberRecordEquiv rows repeats p slots).symm_apply_apply record
theorem read_numberRecord (rows repeats : Nat → Nat) (p : Path branch n (m + 1))
(slots : Slots branch n → Fin t → MixedSupport.Slot)
(direction : BucketSampler.Direction (rows (m + 1)))
(record : OriginalWholeCut.Record rows repeats p slots) (fresh : H (cutSlots p slots)) :
read rows repeats p slots
(direction, (OriginalWholeCutBridge.numberRecord rows repeats p slots record, fresh)) =
((recordRead rows repeats p slots record).2,
(direction, ((recordRead rows repeats p slots record).1, fresh))) := by
unfold read OriginalCutCollision.oldArrays
simp only [oldRecord_numberRecord]
apply Prod.ext
· rfl
· apply Prod.ext
· rfl
· apply Prod.ext
· funext a
exact (OriginalOwnBucketSplit.recordEquiv_own rows repeats p slots record a).symm
· rfl
private theorem numbered_read_of_split (rows repeats : Nat → Nat)
(p : Path branch n (m + 1)) (slots : Slots branch n → Fin t → MixedSupport.Slot)
(directions : FiniteDistribution (BucketSampler.Direction (rows (m + 1))))
(records : FiniteDistribution (OriginalWholeCut.Record rows repeats p slots))
(fresh : FiniteDistribution (H (cutSlots p slots)))
(own : FiniteDistribution (OriginalOwnBucketSplit.BucketTape rows p slots))
(background : FiniteDistribution (Background rows p slots))
(hsplit : records.pushforward (recordRead rows repeats p slots) = own.product background) :
(directions.product ((records.pushforward
(OriginalWholeCutBridge.numberRecord rows repeats p slots)).product fresh)).pushforward
(read rows repeats p slots) =
background.product (directions.product (own.product fresh)) := by
calc
_ = (directions.product (records.product fresh)).pushforward
(fun z => read rows repeats p slots
(z.1, (OriginalWholeCutBridge.numberRecord rows repeats p slots z.2.1, z.2.2))) := by
rw [← map_middle directions records fresh
(OriginalWholeCutBridge.numberRecord rows repeats p slots),
FiniteDistribution.pushforward_comp]
_ = (directions.product (records.product fresh)).pushforward
(fun z => ((recordRead rows repeats p slots z.2.1).2,
(z.1, ((recordRead rows repeats p slots z.2.1).1, z.2.2)))) := by
apply congrArg (directions.product (records.product fresh)).pushforward
funext z
exact read_numberRecord rows repeats p slots z.1 z.2.1 z.2.2
_ = _ := read_product_of_split directions records fresh own background
(recordRead rows repeats p slots) hsplit
theorem reference_read_law (rows repeats : Nat → Nat)
(p : Path branch n (m + 1)) (slots : Slots branch n → Fin t → MixedSupport.Slot)
(directions : FiniteDistribution (BucketSampler.Direction (rows (m + 1)))) :
(directions.product (OriginalExtraCutComparison.referenceLaw rows repeats p slots)).pushforward
(read rows repeats p slots) =
(OriginalOwnBucketSplit.backgroundLaw rows repeats p slots).product
(directions.product
((FiniteDistribution.uniform (OriginalOwnBucketSplit.BucketTape rows p slots)).product
(FiniteDistribution.uniform (H (cutSlots p slots))))) := by
unfold OriginalExtraCutComparison.referenceLaw
rw [OriginalUniformCut.referenceLaw_uniform]
exact numbered_read_of_split rows repeats p slots directions
(FiniteDistribution.uniform (OriginalWholeCut.Record rows repeats p slots))
(FiniteDistribution.uniform (H (cutSlots p slots)))
(FiniteDistribution.uniform (OriginalOwnBucketSplit.BucketTape rows p slots))
(OriginalOwnBucketSplit.backgroundLaw rows repeats p slots)
(OriginalOwnBucketSplit.uniform_own_background rows repeats p slots)
theorem record_fresh_read_law (rows repeats : Nat → Nat)
(p : Path branch n (m + 1)) (chosen : Fin (branch m)) (q : Path branch m k)
(slots : Slots branch n → Fin t → MixedSupport.Slot)
(directions : FiniteDistribution (BucketSampler.Direction (rows (m + 1)))) :
(directions.product
(((OriginalWholeCutLaw.recordLaw rows repeats p chosen q slots).pushforward
(OriginalWholeCutBridge.numberRecord rows repeats p slots)).product
(RecursiveSampler.law F2 repeats (.step chosen q) (LeafDomain (cutSlots p slots))))).pushforward
(read rows repeats p slots) =
(OriginalOwnBucketSplit.actualBackgroundLaw rows repeats p chosen q slots).product
(directions.product
((BucketSampler.tapeLaw (rows (m + 1))
(RecursiveSampler.law F2 repeats (.step chosen q) (LeafDomain (cutSlots p slots)))).product
(RecursiveSampler.law F2 repeats (.step chosen q) (LeafDomain (cutSlots p slots))))) :=
numbered_read_of_split rows repeats p slots directions
(OriginalWholeCutLaw.recordLaw rows repeats p chosen q slots)
(RecursiveSampler.law F2 repeats (.step chosen q) (LeafDomain (cutSlots p slots)))
(BucketSampler.tapeLaw (rows (m + 1))
(RecursiveSampler.law F2 repeats (.step chosen q) (LeafDomain (cutSlots p slots))))
(OriginalOwnBucketSplit.actualBackgroundLaw rows repeats p chosen q slots)
(OriginalOwnBucketSplit.recordLaw_own_background rows repeats p chosen q slots)
end
end PerfectCompleteness.OriginalCutBucketLaw
end
end OAI
|