File size: 13,098 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 | import OAI.Computability.PerfectCompleteness.Decoding.FixedProjectionErrorLemmas
import OAI.Computability.PerfectCompleteness.Decoding.UpperCutTriangle
import OAI.Computability.PerfectCompleteness.Decoding.UpperScalarCutCalls
import OAI.Computability.PerfectCompleteness.Reduction.FixedStoppedError
import OAI.Computability.PerfectCompleteness.Sampling.CommonProductVariationLemmas
import OAI.Computability.PerfectCompleteness.Sampling.HierarchicalBackgroundVariation
namespace OAI
section
namespace PerfectCompleteness.FixedUpperPairError
open FixedParameters FixedRows DescendantSpaces
noncomputable section
variable {δ : ℚ} {hδ : 0 < δ} (params : Parameters δ hδ)
{root upper lower : Nat}
theorem lower_errors_lt (pref : Path (branch params) root (upper + 1))
(segment : Path (branch params) (upper + 1) (lower + 1))
(direction : BucketSampler.Direction (rows params.plan (upper + 1)))
(hroot : root ≤ params.plan.depth) :
let L : ℝ := ChildBlockCardinality.bound (branch params) lower
(sourceLength params.plan hδ)
(UpperScalarCutCalls.count (rows params.plan) (repeats params.plan)
root (upper + 1) (lower + 1)) (rows params.plan)
Real.sqrt ((1 + (projectionProbability params lower : ℝ) ^ 2 * (L - 1)) ^
branch params lower - 1) / 2 +
Real.sqrt (L ^ 2 / branch params lower) / 2 < 2 * params.accuracy := by
have hcalls := UpperScalarCutCalls.count_le_fixed_calls params.plan pref segment direction hroot
have hsparse := FixedProjectionError.sparse_error_lt params hcalls lower
have hhidden := FixedStoppedError.hidden_error_lt params hcalls lower
dsimp only
linarith
theorem three_errors_lt (pref : Path (branch params) root (upper + 1))
(segment : Path (branch params) (upper + 1) (lower + 1))
(direction : BucketSampler.Direction (rows params.plan (upper + 1)))
(hroot : root ≤ params.plan.depth) :
let L : ℝ := ChildBlockCardinality.bound (branch params) lower
(sourceLength params.plan hδ)
(UpperScalarCutCalls.count (rows params.plan) (repeats params.plan)
root (upper + 1) (lower + 1)) (rows params.plan)
Real.sqrt ((1 + (projectionProbability params lower : ℝ) ^ 2 * (L - 1)) ^
branch params lower - 1) / 2 +
Real.sqrt (L ^ 2 / branch params lower) / 2 +
Real.sqrt ((ChildBlockCardinality.bound (branch params) upper
(sourceLength params.plan hδ)
(OriginalCutCalls.count (rows params.plan) (repeats params.plan) root (upper + 1) + 1)
(rows params.plan) : ℝ) ^ 2 / branch params upper) / 2 <
3 * params.accuracy := by
have hlower := lower_errors_lt params pref segment direction hroot
have hupper := FixedStoppedError.collision_error_lt params hroot pref.height_le
dsimp only at hlower ⊢
linarith
end
end PerfectCompleteness.FixedUpperPairError
end
section
namespace PerfectCompleteness.FixedUpperCutTriangle
open FixedParameters FixedRows RecursiveSpaces DescendantSpaces
open TreeSourceSpaces HierarchicalArrays OriginalWholeCutTape WholeArrayInteriorExterior
open UniqueGamesTheorem.Foundations.Games
open UniqueGamesTheorem.Appendix.RankLevelFilter (linearMapFintype)
open scoped Classical
noncomputable section
attribute [local instance] linearMapFintype
variable {δ : ℚ} {hδ : 0 < δ} (params : Parameters δ hδ)
{root upper lower : Nat}
theorem rows_positive (height : Nat) : 0 < rows params.plan height :=
lt_of_lt_of_le Nat.zero_lt_one (params.plan.rows_pos (params.plan.depth - height))
variable (pref : Path (branch params) root (upper + 1))
(hcut : lower + 1 ≤ upper + 1)
(slots : Slots (branch params) root → Fin (sourceLength params.plan hδ) → MixedSupport.Slot)
local instance backgroundFintype :
Fintype (HierarchicalAgreementMean.Background (rows := rows params.plan) slots (upperNode pref)) :=
Fintype.ofFinite _
local instance rowSpaceFintype : Fintype (NodeEmbedding.RowSpace slots (upperNode pref)) :=
Fintype.ofFinite _
def upperReferenceLaw :
FiniteDistribution (HierarchicalAgreementMean.PairRecord (rows := rows params.plan) slots (upperNode pref)) :=
HierarchicalAgreementMean.referenceLaw slots (upperNode pref)
(OriginalOwnBucketSplit.backgroundLaw (rows params.plan) (repeats params.plan) pref slots)
(by simpa only [upperNode_height] using rows_positive params (upper + 1))
variable {Z : UpperCutTriangle.Prefix (branch params) upper lower → Fin (branch params lower) → Type*}
[∀ lowerPref child, Fintype (Z lowerPref child)]
(projected : (lowerPref : UpperCutTriangle.Prefix (branch params) upper lower) →
(child : Fin (branch params lower)) → Z lowerPref child →
Slots (branch params) lower → Fin (sourceLength params.plan hδ) → MixedSupport.Slot)
(projection : ∀ lowerPref child z s a, MixedSupport.Projection
(childSlots (cutSlots (pref.append (GeometricCutSplit.prefixPath hcut lowerPref)) slots) child s a)
(projected lowerPref child z s a))
(choiceLaw : (lowerPref : UpperCutTriangle.Prefix (branch params) upper lower) →
(child : Fin (branch params lower)) → FiniteDistribution (Z lowerPref child))
def modifiedPairLaw :
FiniteDistribution (HierarchicalAgreementMean.PairRecord (rows := rows params.plan) slots (upperNode pref)) :=
UpperCutTriangle.modifiedPairLaw (rows params.plan) (repeats params.plan) pref hcut slots
(fun k _ => branch_pos params k) (rows_positive params (upper + 1))
projected projection choiceLaw (projectionProbability params lower : ℝ)
(by exact_mod_cast (projectionProbability_bounds params lower).1.le)
(by exact_mod_cast (projectionProbability_bounds params lower).2.le)
def originalReferenceLaw :
FiniteDistribution (HierarchicalAgreementMean.PairRecord (rows := rows params.plan) slots (upperNode pref)) :=
HierarchicalAgreementMean.referenceLaw slots (upperNode pref)
((modifiedPairLaw params pref hcut slots projected projection choiceLaw).pushforward Prod.fst)
(by simpa only [upperNode_height] using rows_positive params (upper + 1))
theorem modified_reference_lt (hroot : root ≤ params.plan.depth) :
(modifiedPairLaw params pref hcut slots projected projection choiceLaw).totalVariation
(upperReferenceLaw params pref slots) < 3 * params.accuracy := by
have hcomparison := UpperCutTriangle.modified_reference_variation
(rows params.plan) (repeats params.plan) pref hcut slots
(fun k _ => branch_pos params k) (rows_positive params (upper + 1))
projected projection choiceLaw (projectionProbability params lower : ℝ)
(by exact_mod_cast (projectionProbability_bounds params lower).1.le)
(by exact_mod_cast (projectionProbability_bounds params lower).2.le)
let lowerPref : UpperCutTriangle.Prefix (branch params) upper lower :=
Classical.choice (GeometricCutSplit.prefix_nonempty hcut (fun k _ => branch_pos params k))
let direction : BucketSampler.Direction (rows params.plan (upper + 1)) :=
BucketUniform.coordinateDirection ⟨0, rows_positive params (upper + 1)⟩
have herror := FixedUpperPairError.three_errors_lt params pref
(GeometricCutSplit.prefixPath hcut lowerPref) direction hroot
simpa only [modifiedPairLaw, upperReferenceLaw] using hcomparison.trans_lt herror
theorem original_reference_lt (hroot : root ≤ params.plan.depth) :
(modifiedPairLaw params pref hcut slots projected projection choiceLaw).totalVariation
(originalReferenceLaw params pref hcut slots projected projection choiceLaw) <
6 * params.accuracy := by
have h := HierarchicalBackgroundVariation.original_background_variation slots (upperNode pref)
(modifiedPairLaw params pref hcut slots projected projection choiceLaw)
(OriginalOwnBucketSplit.backgroundLaw (rows params.plan) (repeats params.plan) pref slots)
(by simpa only [upperNode_height] using rows_positive params (upper + 1))
change (modifiedPairLaw params pref hcut slots projected projection choiceLaw).totalVariation
(originalReferenceLaw params pref hcut slots projected projection choiceLaw) ≤
2 * (modifiedPairLaw params pref hcut slots projected projection choiceLaw).totalVariation
(upperReferenceLaw params pref slots) at h
have hthree := modified_reference_lt params pref hcut slots projected projection choiceLaw hroot
linarith
theorem original_reference_le_ten (hroot : root ≤ params.plan.depth) :
(modifiedPairLaw params pref hcut slots projected projection choiceLaw).totalVariation
(originalReferenceLaw params pref hcut slots projected projection choiceLaw) ≤
10 * params.accuracy := by
have h := original_reference_lt params pref hcut slots projected projection choiceLaw hroot
have hpositive := params.accuracy_pos
linarith
end
end PerfectCompleteness.FixedUpperCutTriangle
end
section
namespace PerfectCompleteness.FixedUpperCutFamily
open FixedParameters FixedRows RecursiveSpaces DescendantSpaces
open TreeSourceSpaces HierarchicalArrays OriginalWholeCutTape WholeArrayInteriorExterior
open UniqueGamesTheorem.Foundations.Games
open UniqueGamesTheorem.Appendix.RankLevelFilter (linearMapFintype)
open scoped Classical
noncomputable section
attribute [local instance] linearMapFintype
variable {δ : ℚ} {hδ : 0 < δ} (params : Parameters δ hδ)
{root upper lower : Nat} {O : Type*} [Fintype O]
(pref : O → Path (branch params) root (upper + 1))
(hcut : lower + 1 ≤ upper + 1)
(slots : O → Slots (branch params) root → Fin (sourceLength params.plan hδ) → MixedSupport.Slot)
local instance backgroundFintype (o : O) :
Fintype (HierarchicalAgreementMean.Background (rows := rows params.plan) (slots o) (upperNode (pref o))) :=
Fintype.ofFinite _
local instance rowSpaceFintype (o : O) :
Fintype (NodeEmbedding.RowSpace (slots o) (upperNode (pref o))) := Fintype.ofFinite _
abbrev Record := Σ o : O,
HierarchicalAgreementMean.PairRecord (rows := rows params.plan) (slots o) (upperNode (pref o))
variable {Z : O → UpperCutTriangle.Prefix (branch params) upper lower → Fin (branch params lower) → Type*}
[∀ o lowerPref child, Fintype (Z o lowerPref child)]
(projected : (o : O) → (lowerPref : UpperCutTriangle.Prefix (branch params) upper lower) →
(child : Fin (branch params lower)) → Z o lowerPref child →
Slots (branch params) lower → Fin (sourceLength params.plan hδ) → MixedSupport.Slot)
(projection : ∀ o lowerPref child z s a, MixedSupport.Projection
(childSlots (cutSlots ((pref o).append (GeometricCutSplit.prefixPath hcut lowerPref)) (slots o)) child s a)
(projected o lowerPref child z s a))
(choiceLaw : (o : O) → (lowerPref : UpperCutTriangle.Prefix (branch params) upper lower) →
(child : Fin (branch params lower)) → FiniteDistribution (Z o lowerPref child))
def modifiedLaw (outerLaw : FiniteDistribution O) :
FiniteDistribution (Record params pref slots) :=
CompletionSoundness.sigmaLaw outerLaw (fun o =>
FixedUpperCutTriangle.modifiedPairLaw params (pref o) hcut (slots o)
(projected o) (projection o) (choiceLaw o))
def referenceLaw (outerLaw : FiniteDistribution O) :
FiniteDistribution (Record params pref slots) :=
CompletionSoundness.sigmaLaw outerLaw (fun o =>
FixedUpperCutTriangle.originalReferenceLaw params (pref o) hcut (slots o)
(projected o) (projection o) (choiceLaw o))
theorem totalVariation_le_six (outerLaw : FiniteDistribution O)
(hroot : root ≤ params.plan.depth) :
(modifiedLaw params pref hcut slots projected projection choiceLaw outerLaw).totalVariation
(referenceLaw params pref hcut slots projected projection choiceLaw outerLaw) ≤
6 * params.accuracy := by
have h := ConditionalVariation.observed_sigma_le_const outerLaw
(fun o => FixedUpperCutTriangle.modifiedPairLaw params (pref o) hcut (slots o)
(projected o) (projection o) (choiceLaw o))
(fun o => FixedUpperCutTriangle.originalReferenceLaw params (pref o) hcut (slots o)
(projected o) (projection o) (choiceLaw o))
(6 * params.accuracy)
(fun o => (FixedUpperCutTriangle.original_reference_lt params (pref o) hcut (slots o)
(projected o) (projection o) (choiceLaw o) hroot).le)
(id : Record params pref slots → Record params pref slots)
simpa only [modifiedLaw, referenceLaw, FiniteDistribution.pushforward_id] using h
theorem observed_totalVariation_le_ten {Γ : Type*} [Fintype Γ]
(outerLaw : FiniteDistribution O) (hroot : root ≤ params.plan.depth)
(observe : Record params pref slots → Γ) :
((modifiedLaw params pref hcut slots projected projection choiceLaw outerLaw).pushforward observe).totalVariation
((referenceLaw params pref hcut slots projected projection choiceLaw outerLaw).pushforward observe) ≤
10 * params.accuracy := by
have h := (DensityVariation.variation_pushforward_le _ _ observe).trans
(totalVariation_le_six params pref hcut slots projected projection choiceLaw outerLaw hroot)
have hpositive := params.accuracy_pos
linarith
end
end PerfectCompleteness.FixedUpperCutFamily
end
end OAI
|