import Mathlib import OAI.Computability.VertexCover.Repetition.CompletedSampling import OAI.Computability.VertexCover.Repetition.GameConditioning namespace OAI section section section section section section section section section section section section section section section section section section section section section section section section section section section section section section section namespace UniqueGames.Foundations.Repetition open scoped BigOperators open Games CorrelatedSampling noncomputable section variable {Q₁ Q₂ A₁ A₂ S : Type*} [Fintype Q₁] [Fintype Q₂] [Fintype A₁] [Fintype A₂] [Fintype S] [Nonempty A₁] [Nonempty A₂] [Nonempty S] [DecidableEq Q₁] [DecidableEq Q₂] [DecidableEq S] {n : Nat} theorem coordinate_probability_le_value_of_local_completion (G : Game Q₁ Q₂ A₁ A₂) (j : Fin n) (strategy : Strategy (Fin n → Q₁) (Fin n → Q₂) (Fin n → A₁) (Fin n → A₂)) (σ : FiniteDistribution ((Q₁ × Q₂) × S)) (profileL : Q₁ → FiniteDistribution S) (profileR : Q₂ → FiniteDistribution S) (completionL : Q₁ × S → FiniteDistribution (Fin n → Q₁)) (completionR : Q₂ × S → FiniteDistribution (Fin n → Q₂)) (supportL : ∀ q xs, (completionL q).weight xs ≠ 0 → xs j = q.1) (supportR : ∀ q ys, (completionR q).weight ys ≠ 0 → ys j = q.1) (fallback : S) : (σ.mixture (fun z => (completionL (z.1.1,z.2)).product (completionR (z.1.2,z.2)))).probability (G.coordinateWin strategy j) ≤ G.value + (2 * Information.totalVariation σ.weight (fun z => G.questions.weight z.1 * (profileL z.1.1).weight z.2) + 2 * Information.totalVariation σ.weight (fun z => G.questions.weight z.1 * (profileR z.1.2).weight z.2)) := by let targetLaw := σ.mixture (fun z => (completionL (z.1.1,z.2)).product (completionR (z.1.2,z.2))) let δ := 2 * Information.totalVariation σ.weight (fun z => G.questions.weight z.1 * (profileL z.1.1).weight z.2) + 2 * Information.totalVariation σ.weight (fun z => G.questions.weight z.1 * (profileR z.1.2).weight z.2) change targetLaw.probability (G.coordinateWin strategy j) ≤ G.value + δ by_contra h have gap : 0 < targetLaw.probability (G.coordinateWin strategy j) - (G.value + δ) := sub_pos.mpr (lt_of_not_ge h) let η := (targetLaw.probability (G.coordinateWin strategy j) - (G.value + δ)) / 2 have hη : 0 < η := by dsimp [η]; linarith obtain ⟨N,hN⟩ := samplerOutputLaw_arbitrarily_close σ G.questions profileL profileR fallback η hη let thresholds := sharedProfileThresholds profileL profileR let γ := traceSeedLaw (rectangleDistribution (α := S) thresholds) N let sL := samplerLocal thresholds profileL fallback N let sR := samplerLocal thresholds profileR fallback N have hvariation := CompletedSampling.coordinateOutputLaw_totalVariation_le G.questions γ j sL sR completionL completionR supportL supportR σ have hclose : (CompletedSampling.coordinateOutputLaw G.questions γ j sL sR completionL completionR).totalVariation targetLaw ≤ δ + η := hvariation.trans hN have hsuccess := G.coordinate_probability_le_value_add_embedding_distance j targetLaw (CompletedSampling.seedLaw γ completionL completionR) (CompletedSampling.coordinateLeft j sL) (CompletedSampling.coordinateRight j sR) (CompletedSampling.coordinateLeft_preserves j sL) (CompletedSampling.coordinateRight_preserves j sR) strategy have hsym : targetLaw.totalVariation (G.localEmbeddingLaw (CompletedSampling.seedLaw γ completionL completionR) (CompletedSampling.coordinateLeft j sL) (CompletedSampling.coordinateRight j sR)) = (CompletedSampling.coordinateOutputLaw G.questions γ j sL sR completionL completionR).totalVariation targetLaw := by unfold FiniteDistribution.totalVariation congr 1 apply Finset.sum_congr rfl intro q _ exact abs_sub_comm _ _ rw [hsym] at hsuccess dsimp [η] at hclose linarith end end UniqueGames.Foundations.Repetition end end end end end end end end end end end end end end end end end end end end end end end end end end end end end end end end OAI