math / data /lean /OAI /Computability /PerfectCompleteness /Foundations /DependentPredictionDifferenceLemmas.lean
introvoyz045's picture
Migrated from GitHub
4a56cd6 verified
Raw History Blame Contribute Delete
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