math / data /lean /OAI /Computability /PerfectCompleteness /Foundations /DependentPredictionDifferenceLemmas.lean
Download data/lean/OAI/Computability/PerfectCompleteness/Foundations/DependentPredictionDifferenceLemmas.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 10.6 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Computability/PerfectCompleteness/Foundations/DependentPredictionDifferenceLemmas.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Computability/PerfectCompleteness/Foundations/DependentPredictionDifferenceLemmas.lean
-
curl -L -o DependentPredictionDifferenceLemmas.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Computability/PerfectCompleteness/Foundations/DependentPredictionDifferenceLemmas.lean
10.6 kB
| import OAI.Computability.PerfectCompleteness.Foundations.TupleIndexEmitterLemmas | |
| import OAI.Computability.PerfectCompleteness.Reduction.CompletionSoundness | |
| import OAI.Computability.UniqueGames.Games.FinishBoundsLemmas | |
| namespace OAI | |
| namespace PerfectCompleteness.DependentPredictionDifference | |
| noncomputable section | |
| open scoped Classical | |
| open UniqueGamesTheorem.Foundations.Games | |
| variable {O : Type*} | |
| abbrev Sample (Ξ© A : O β Type*) := (o : O) Γ (Ξ© o Γ A o) | |
| abbrev Observation (P A : O β Type*) := (o : O) Γ (P o Γ A o) | |
| variable [Fintype O] {Ξ© P A : O β Type*} | |
| [β o, Fintype (Ξ© o)] [β o, Fintype (P o)] [β o, Fintype (A o)] | |
| def law (outer : FiniteDistribution O) | |
| (original : β o, FiniteDistribution (Ξ© o)) | |
| (advice : β o, FiniteDistribution (A o)) : FiniteDistribution (Sample Ξ© A) := | |
| CompletionSoundness.sigmaLaw outer (fun o => (original o).product (advice o)) | |
| def observe (p : β o, Ξ© o β P o) (x : Sample Ξ© A) : Observation P A := | |
| β¨x.1, (p x.1 x.2.1, x.2.2)β© | |
| theorem original_usefulness_predicts | |
| (outer : FiniteDistribution O) | |
| (original : β o, FiniteDistribution (Ξ© o)) | |
| (advice : β o, FiniteDistribution (A o)) | |
| (p : β o, Ξ© o β P o) (lower : β o, Ξ© o β Bool) | |
| (I : Observation P A β Bool) (prediction : Sample Ξ© A β Bool) (ΞΊ : β) | |
| (hmarked : β o z a, I β¨o, (z, a)β© = true β | |
| UsefulMark.useful (original o) (p o) (lower o) ΞΊ z = true) | |
| (hprediction : β o x a, lower o x = true β I β¨o, (p o x, a)β© = true β | |
| prediction β¨o, (x, a)β© = true) : | |
| ΞΊ * (law outer original advice).probability (fun x => I (observe p x)) β€ | |
| (law outer original advice).probability prediction := by | |
| unfold law | |
| rw [CompletionSoundness.sigmaLaw_probability, CompletionSoundness.sigmaLaw_probability, | |
| β SmallBiasSlice.expectation_const_mul] | |
| apply SmallBias.expectation_mono | |
| intro o | |
| exact UsefulAdvice.independent_advice_predicts (original o) (advice o) (p o) (lower o) ΞΊ | |
| (fun z => I β¨o, zβ©) (fun x => prediction β¨o, xβ©) (hmarked o) (hprediction o) | |
| theorem of_original_usefulness {Ξ : Type*} [Fintype Ξ] | |
| (outer : FiniteDistribution O) | |
| (original : β o, FiniteDistribution (Ξ© o)) | |
| (advice : β o, FiniteDistribution (A o)) | |
| (reference : FiniteDistribution Ξ) | |
| (p : β o, Ξ© o β P o) (referenceObserve : Ξ β Observation P A) | |
| (lower : β o, Ξ© o β Bool) | |
| (I J : Observation P A β Bool) (prediction : Sample Ξ© A β Bool) | |
| (ΞΊ Ο qβ v : β) (hΞΊ : 0 β€ ΞΊ) (hΟ : 0 β€ Ο) (hΟ1 : Ο β€ 1) | |
| (hqβ : 0 β€ qβ) (hv : 0 β€ v) (hsmall : v β€ Ο * qβ / 16) | |
| (hmarked : β o z a, I β¨o, (z, a)β© = true β | |
| UsefulMark.useful (original o) (p o) (lower o) ΞΊ z = true) | |
| (hprediction : β o x a, lower o x = true β I β¨o, (p o x, a)β© = true β | |
| prediction β¨o, (x, a)β© = true) | |
| (hvariation : ((law outer original advice).pushforward (observe p)).totalVariation | |
| (reference.pushforward referenceObserve) β€ v) | |
| (hmass : qβ β€ reference.probability (fun x => J (referenceObserve x))) | |
| (hdensity : Ο * reference.probability (fun x => J (referenceObserve x)) β€ | |
| reference.probability (fun x => I (referenceObserve x))) : | |
| ΞΊ * Ο * qβ / 4 β€ (law outer original advice).probability prediction - | |
| (ΞΊ * Ο / 4) * (law outer original advice).probability (fun x => J (observe p x)) := by | |
| apply PredictionDifference.of_observed_variation | |
| (law outer original advice) reference (observe p) referenceObserve I J prediction | |
| ΞΊ Ο qβ v hΞΊ hΟ hΟ1 hqβ hv hsmall hvariation hmass hdensity | |
| exact original_usefulness_predicts outer original advice p lower I prediction ΞΊ | |
| hmarked hprediction | |
| end | |
| end PerfectCompleteness.DependentPredictionDifference | |
| namespace PerfectCompleteness.LegalEnumeration | |
| open scoped Classical | |
| open UniqueGamesTheorem.Foundations.Games CompletionSoundness | |
| noncomputable section | |
| section Reindex | |
| variable {E E' Qβ Qβ Qβ' Qβ' : Type*} | |
| {L : Qβ β Type*} {R : Qβ β Type*} | |
| {L' : Qβ' β Type*} {R' : Qβ' β Type*} | |
| [Fintype E] [Fintype E'] | |
| (G : LegalProjectionGame E Qβ Qβ L R) | |
| (ee : E β E') (el : Qβ β Qβ') (er : Qβ β Qβ') | |
| (al : β x, L x β L' (el x)) (ar : β y, R y β R' (er y)) | |
| def reindex : LegalProjectionGame E' Qβ' Qβ' L' R' where | |
| occurrences := G.occurrences.transport ee | |
| left i := el (G.left (ee.symm i)) | |
| right i := er (G.right (ee.symm i)) | |
| projection i a := ar (G.right (ee.symm i)) | |
| (G.projection (ee.symm i) ((al (G.left (ee.symm i))).symm a)) | |
| def strategies : LegalStrategy L R β LegalStrategy L' R' := | |
| (el.piCongr al).prodCongr (er.piCongr ar) | |
| theorem reindex_wins (s : LegalStrategy L R) (e : E) : | |
| (reindex G ee el er al ar).wins (strategies el er al ar s) (ee e) = G.wins s e := by | |
| simp only [LegalProjectionGame.wins, reindex] | |
| apply decide_eq_decide.mpr | |
| change ar (G.right (ee.symm (ee e))) | |
| (G.projection (ee.symm (ee e)) | |
| ((al (G.left (ee.symm (ee e)))).symm | |
| ((el.piCongr al) s.1 (el (G.left (ee.symm (ee e))))))) = | |
| (er.piCongr ar) s.2 (er (G.right (ee.symm (ee e)))) β | |
| G.projection e (s.1 (G.left e)) = s.2 (G.right e) | |
| rw [ee.symm_apply_apply e] | |
| rw [Equiv.piCongr_apply_apply, Equiv.piCongr_apply_apply, Equiv.symm_apply_apply] | |
| exact (ar (G.right e)).injective.eq_iff | |
| theorem reindex_success (s : LegalStrategy L R) : | |
| (reindex G ee el er al ar).success (strategies el er al ar s) = G.success s := by | |
| unfold LegalProjectionGame.success | |
| change (G.occurrences.transport ee).probability _ = _ | |
| rw [FiniteDistribution.probability_transport] | |
| congr 1 | |
| funext e | |
| exact reindex_wins G ee el er al ar s e | |
| section Fibers | |
| variable [β x, Fintype (L x)] [β x, Fintype (L' x)] | |
| theorem reindex_fiber_card (i : E') | |
| (b : R' ((reindex G ee el er al ar).right i)) : | |
| Fintype.card {a : L' ((reindex G ee el er al ar).left i) // | |
| (reindex G ee el er al ar).projection i a = b} = | |
| Fintype.card {a : L (G.left (ee.symm i)) // | |
| G.projection (ee.symm i) a = (ar (G.right (ee.symm i))).symm b} := by | |
| apply Fintype.card_congr | |
| apply (al (G.left (ee.symm i))).symm.subtypeEquiv | |
| intro a | |
| change ar (G.right (ee.symm i)) | |
| (G.projection (ee.symm i) ((al (G.left (ee.symm i))).symm a)) = b β _ | |
| constructor | |
| Β· intro h | |
| have h' := congrArg (ar (G.right (ee.symm i))).symm h | |
| simpa only [Equiv.symm_apply_apply] using h' | |
| Β· intro h | |
| have h' := congrArg (ar (G.right (ee.symm i))) h | |
| exact h'.trans ((ar (G.right (ee.symm i))).apply_symm_apply b) | |
| theorem reindex_at_most_two | |
| (hsmall : β e b, Fintype.card {a : L (G.left e) // G.projection e a = b} β€ 2) | |
| (i : E') (b : R' ((reindex G ee el er al ar).right i)) : | |
| Fintype.card {a : L' ((reindex G ee el er al ar).left i) // | |
| (reindex G ee el er al ar).projection i a = b} β€ 2 := by | |
| rw [reindex_fiber_card] | |
| exact hsmall _ _ | |
| end Fibers | |
| variable [Fintype Qβ] [Fintype Qβ] [Fintype Qβ'] [Fintype Qβ'] | |
| [β x, Fintype (L x)] [β y, Fintype (R y)] | |
| [β x, Fintype (L' x)] [β y, Fintype (R' y)] | |
| [β x, Nonempty (L x)] [β y, Nonempty (R y)] | |
| [β x, Nonempty (L' x)] [β y, Nonempty (R' y)] | |
| theorem reindex_value : (reindex G ee el er al ar).value = G.value := by | |
| apply le_antisymm | |
| Β· obtain β¨s, hsβ© := (reindex G ee el er al ar).exists_optimal_strategy | |
| have h := reindex_success G ee el er al ar ((strategies el er al ar).symm s) | |
| rw [Equiv.apply_symm_apply] at h | |
| rw [β hs, h] | |
| exact G.success_le_value _ | |
| Β· obtain β¨s, hsβ© := G.exists_optimal_strategy | |
| rw [β hs, β reindex_success G ee el er al ar s] | |
| exact (reindex G ee el er al ar).success_le_value _ | |
| end Reindex | |
| variable {E Qβ Qβ : Type*} [Fintype E] [Fintype Qβ] [Fintype Qβ] | |
| {L : Qβ β Type*} {R : Qβ β Type*} | |
| abbrev NumberedLabels (P : Qβ β Type*) (i : Fin (Fintype.card Qβ)) := | |
| P ((Fintype.equivFin Qβ).symm i) | |
| def numberedLabelEquiv (P : Qβ β Type*) (x : Qβ) : | |
| P x β NumberedLabels P (Fintype.equivFin Qβ x) := | |
| Equiv.cast (congrArg P ((Fintype.equivFin Qβ).symm_apply_apply x).symm) | |
| def numbered (G : LegalProjectionGame E Qβ Qβ L R) : | |
| LegalProjectionGame (Fin (Fintype.card E)) | |
| (Fin (Fintype.card Qβ)) (Fin (Fintype.card Qβ)) | |
| (NumberedLabels L) (NumberedLabels R) := | |
| reindex G (Fintype.equivFin E) (Fintype.equivFin Qβ) (Fintype.equivFin Qβ) | |
| (numberedLabelEquiv L) (numberedLabelEquiv R) | |
| theorem numbered_at_most_two [β x, Fintype (L x)] | |
| (G : LegalProjectionGame E Qβ Qβ L R) | |
| (hsmall : β e b, Fintype.card {a : L (G.left e) // G.projection e a = b} β€ 2) | |
| (i : Fin (Fintype.card E)) (b : NumberedLabels R ((numbered G).right i)) : | |
| Fintype.card {a : NumberedLabels L ((numbered G).left i) // | |
| (numbered G).projection i a = b} β€ 2 := | |
| reindex_at_most_two G (Fintype.equivFin E) (Fintype.equivFin Qβ) (Fintype.equivFin Qβ) | |
| (numberedLabelEquiv L) (numberedLabelEquiv R) hsmall i b | |
| theorem numbered_value [β x, Fintype (L x)] [β y, Fintype (R y)] | |
| [β x, Nonempty (L x)] [β y, Nonempty (R y)] | |
| (G : LegalProjectionGame E Qβ Qβ L R) : (numbered G).value = G.value := | |
| reindex_value G (Fintype.equivFin E) (Fintype.equivFin Qβ) (Fintype.equivFin Qβ) | |
| (numberedLabelEquiv L) (numberedLabelEquiv R) | |
| end | |
| end PerfectCompleteness.LegalEnumeration | |
| namespace PerfectCompleteness.SigmaObservation | |
| open UniqueGamesTheorem.Foundations.Games CompletionSoundness | |
| noncomputable section | |
| theorem eq_of_probability_eq {X : Type*} [Fintype X] | |
| (ΞΌ Ξ½ : FiniteDistribution X) | |
| (h : β event : X β Bool, ΞΌ.probability event = Ξ½.probability event) : ΞΌ = Ξ½ := by | |
| classical | |
| apply FiniteDistribution.eq_of_weight_eq | |
| intro x | |
| simpa [FiniteDistribution.probability] using h (fun y => decide (y = x)) | |
| theorem pushforward_fiber {S : Type*} [Fintype S] {X Y : S β Type*} | |
| [β s, Fintype (X s)] [β s, Fintype (Y s)] | |
| (ΞΌ : FiniteDistribution S) (P : (s : S) β FiniteDistribution (X s)) | |
| (f : (s : S) β X s β Y s) : | |
| (sigmaLaw ΞΌ P).pushforward (fun x => (β¨x.1, f x.1 x.2β© : Ξ£ s, Y s)) = | |
| sigmaLaw ΞΌ (fun s => (P s).pushforward (f s)) := by | |
| apply eq_of_probability_eq | |
| intro event | |
| rw [FiniteDistribution.probability_pushforward, sigmaLaw_probability, sigmaLaw_probability] | |
| apply FiniteDistribution.expectation_congr | |
| intro s | |
| rw [FiniteDistribution.probability_pushforward] | |
| end | |
| end PerfectCompleteness.SigmaObservation | |
| end OAI | |