math / data /lean /OAI /Computability /VertexCover /Repetition /SelectedCompletionGame.lean
introvoyz045's picture
Migrated from GitHub
4a56cd6 verified
Raw History Blame Contribute Delete
16.8 kB
import Mathlib
import OAI.Computability.VertexCover.Repetition.SelectedJointGame
import OAI.Computability.VertexCover.Games.KernelSampling
import OAI.Computability.VertexCover.Repetition.DistributionMaps
import OAI.Computability.VertexCover.Repetition.SelectedCompletion
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
noncomputable section
theorem partialRevealWeight_forget
{I X Y : Type*} [Fintype I] [DecidableEq I]
[Fintype X] [Fintype Y] [DecidableEq X] [DecidableEq Y]
(ΞΌ : FiniteDistribution (X Γ— Y)) (j : I) (u : I β†’ X Γ— Y) :
(βˆ‘ rest : {i : I // i β‰  j} β†’ X βŠ• Y, partialRevealWeight ΞΌ j rest u) =
∏ i, μ.weight (u i) := by
have h := reveal_product_forget ΞΌ (fun i : {i : I // i β‰  j} => u i.1)
simp_rw [reveal_product_factorization] at h
simp only [partialRevealWeight, ← Finset.mul_sum]
rw [h]
exact (Fintype.prod_eq_mul_prod_subtype_ne (fun i => ΞΌ.weight (u i)) j).symm
theorem partialReveal_event_forget
{I X Y : Type*} [Fintype I] [DecidableEq I]
[Fintype X] [Fintype Y] [DecidableEq X] [DecidableEq Y]
(ΞΌ : FiniteDistribution (X Γ— Y)) (j : I) (f : (I β†’ X Γ— Y) β†’ ℝ) :
(βˆ‘ rest : {i : I // i β‰  j} β†’ X βŠ• Y,
βˆ‘ u : I β†’ X Γ— Y, partialRevealWeight ΞΌ j rest u * f u) =
βˆ‘ u, (∏ i, ΞΌ.weight (u i)) * f u := by
rw [Finset.sum_comm]
apply Finset.sum_congr rfl
intro u _
rw [← Finset.sum_mul, partialRevealWeight_forget]
variable {Q₁ Qβ‚‚ A₁ Aβ‚‚ : Type*}
[Fintype Q₁] [Fintype Qβ‚‚] [Fintype A₁] [Fintype Aβ‚‚]
[DecidableEq Q₁] [DecidableEq Qβ‚‚] {n : Nat}
omit [DecidableEq Q₁] [DecidableEq Qβ‚‚] in
theorem selectedOutsideLikelihood_event_sum (G : Game Q₁ Qβ‚‚ A₁ Aβ‚‚)
(strategy : Strategy (Fin n β†’ Q₁) (Fin n β†’ Qβ‚‚) (Fin n β†’ A₁) (Fin n β†’ Aβ‚‚))
(selected : Finset (Fin n))
(event : ((Fin n β†’ Q₁) Γ— (Fin n β†’ Qβ‚‚)) β†’ Bool) :
(βˆ‘ t : (selected β†’ Q₁ Γ— Qβ‚‚) Γ— SelectedLabels (A₁ := A₁) (Aβ‚‚ := Aβ‚‚) selected,
βˆ‘ u : {i : Fin n // i βˆ‰ selected} β†’ Q₁ Γ— Qβ‚‚,
(∏ i, G.questions.weight (u i)) * selectedOutsideLikelihood G strategy selected t u *
(if event (selectedQuestionTuple selected t.1 u) then 1 else 0)) =
(G.repetition n).questions.probability
(fun q => G.selectedWins strategy selected q && event q) /
G.selectedSuccess strategy selected := by
classical
have hlabel (fixed : selected β†’ Q₁ Γ— Qβ‚‚)
(u : {i : Fin n // i βˆ‰ selected} β†’ Q₁ Γ— Qβ‚‚) :
(βˆ‘ label : SelectedLabels (A₁ := A₁) (Aβ‚‚ := Aβ‚‚) selected,
(∏ i, G.questions.weight (u i)) *
selectedOutsideLikelihood G strategy selected (fixed,label) u *
(if event (selectedQuestionTuple selected fixed u) then 1 else 0)) =
((∏ i : selected, G.questions.weight (fixed i)) * (∏ i, G.questions.weight (u i)) *
(if G.selectedWins strategy selected (selectedQuestionTuple selected fixed u) &&
event (selectedQuestionTuple selected fixed u) then 1 else 0)) /
G.selectedSuccess strategy selected := by
calc
_ = (∏ i, G.questions.weight (u i)) *
(∏ i : selected, G.questions.weight (fixed i)) *
(βˆ‘ label, selectedLikelihood G strategy selected fixed label u) *
(if event (selectedQuestionTuple selected fixed u) then 1 else 0) /
G.selectedSuccess strategy selected := by
simp only [selectedOutsideLikelihood, div_eq_mul_inv, Finset.mul_sum, Finset.sum_mul]
apply Finset.sum_congr rfl
intro label _
ring
_ = _ := by
rw [selectedLikelihood_sum]
cases hw : G.selectedWins strategy selected (selectedQuestionTuple selected fixed u) <;>
cases he : event (selectedQuestionTuple selected fixed u) <;> simp [] ; ring
calc
_ = βˆ‘ fixed : selected β†’ Q₁ Γ— Qβ‚‚,
βˆ‘ u : {i : Fin n // i βˆ‰ selected} β†’ Q₁ Γ— Qβ‚‚,
βˆ‘ label : SelectedLabels (A₁ := A₁) (Aβ‚‚ := Aβ‚‚) selected,
(∏ i, G.questions.weight (u i)) *
selectedOutsideLikelihood G strategy selected (fixed,label) u *
(if event (selectedQuestionTuple selected fixed u) then 1 else 0) := by
rw [Fintype.sum_prod_type]
apply Finset.sum_congr rfl
intro fixed _
rw [Finset.sum_comm]
_ = (βˆ‘ fixed : selected β†’ Q₁ Γ— Qβ‚‚,
βˆ‘ u : {i : Fin n // i βˆ‰ selected} β†’ Q₁ Γ— Qβ‚‚,
(∏ i : selected, G.questions.weight (fixed i)) * (∏ i, G.questions.weight (u i)) *
(if G.selectedWins strategy selected (selectedQuestionTuple selected fixed u) &&
event (selectedQuestionTuple selected fixed u) then 1 else 0)) /
G.selectedSuccess strategy selected := by
simp_rw [hlabel]
simp only [div_eq_mul_inv, Finset.sum_mul]
_ = _ := by
congr 1
have h := selectedSplit_question_probability G selected
(fun q => G.selectedWins strategy selected q && event q)
simpa [selectedSplitLaw, FiniteDistribution.probability, FiniteDistribution.product,
FiniteDistribution.table, Fintype.sum_prod_type, mul_ite] using h
theorem selected_partial_event_total (G : Game Q₁ Qβ‚‚ A₁ Aβ‚‚)
(strategy : Strategy (Fin n β†’ Q₁) (Fin n β†’ Qβ‚‚) (Fin n β†’ A₁) (Fin n β†’ Aβ‚‚))
(selected : Finset (Fin n)) (j : {i : Fin n // i βˆ‰ selected})
(event : ((Fin n β†’ Q₁) Γ— (Fin n β†’ Qβ‚‚)) β†’ Bool) :
(βˆ‘ s : SelectedCommonData (Q₁ := Q₁) (Qβ‚‚ := Qβ‚‚) (A₁ := A₁) (Aβ‚‚ := Aβ‚‚) selected j,
βˆ‘ u : {i : Fin n // i βˆ‰ selected} β†’ Q₁ Γ— Qβ‚‚,
partialRevealWeight G.questions j s.2 u *
selectedOutsideLikelihood G strategy selected s.1 u *
(if event (selectedQuestionTuple selected s.1.1 u) then 1 else 0)) =
(G.repetition n).questions.probability
(fun q => G.selectedWins strategy selected q && event q) /
G.selectedSuccess strategy selected := by
have hrest (t : (selected β†’ Q₁ Γ— Qβ‚‚) Γ— SelectedLabels (A₁ := A₁) (Aβ‚‚ := Aβ‚‚) selected) :=
partialReveal_event_forget G.questions j
(fun u => selectedOutsideLikelihood G strategy selected t u *
(if event (selectedQuestionTuple selected t.1 u) then 1 else 0))
simp only [← mul_assoc] at hrest
rw [Fintype.sum_prod_type]
simp_rw [hrest]
exact selectedOutsideLikelihood_event_sum G strategy selected event
def selectedFullLeftCompletion (G : Game Q₁ Qβ‚‚ A₁ Aβ‚‚)
(strategy : Strategy (Fin n β†’ Q₁) (Fin n β†’ Qβ‚‚) (Fin n β†’ A₁) (Fin n β†’ Aβ‚‚))
(selected : Finset (Fin n)) (j : {i : Fin n // i βˆ‰ selected})
(q : Q₁ Γ— SelectedCommonData (Q₁ := Q₁) (Qβ‚‚ := Qβ‚‚) (A₁ := A₁) (Aβ‚‚ := Aβ‚‚) selected j) :
FiniteDistribution (Fin n β†’ Q₁) :=
(selectedLeftCompletion G strategy selected j q.2 q.1).pushforward
(mergeCoordinates selected (fun i => (q.2.1.1 i).1))
def selectedFullRightCompletion (G : Game Q₁ Qβ‚‚ A₁ Aβ‚‚)
(strategy : Strategy (Fin n β†’ Q₁) (Fin n β†’ Qβ‚‚) (Fin n β†’ A₁) (Fin n β†’ Aβ‚‚))
(selected : Finset (Fin n)) (j : {i : Fin n // i βˆ‰ selected})
(q : Qβ‚‚ Γ— SelectedCommonData (Q₁ := Q₁) (Qβ‚‚ := Qβ‚‚) (A₁ := A₁) (Aβ‚‚ := Aβ‚‚) selected j) :
FiniteDistribution (Fin n β†’ Qβ‚‚) :=
(selectedRightCompletion G strategy selected j q.2 q.1).pushforward
(mergeCoordinates selected (fun i => (q.2.1.1 i).2))
omit [DecidableEq Qβ‚‚] in
theorem selectedFullLeftCompletion_support (G : Game Q₁ Qβ‚‚ A₁ Aβ‚‚)
(strategy : Strategy (Fin n β†’ Q₁) (Fin n β†’ Qβ‚‚) (Fin n β†’ A₁) (Fin n β†’ Aβ‚‚))
(selected : Finset (Fin n)) (j : {i : Fin n // i βˆ‰ selected})
(q : Q₁ Γ— SelectedCommonData (Q₁ := Q₁) (Qβ‚‚ := Qβ‚‚) (A₁ := A₁) (Aβ‚‚ := Aβ‚‚) selected j)
(l : Fin n β†’ Q₁) (h : (selectedFullLeftCompletion G strategy selected j q).weight l β‰  0) :
l j.1 = q.1 := by
classical
by_contra hne
apply h
simp only [selectedFullLeftCompletion, FiniteDistribution.pushforward]
apply Finset.sum_eq_zero
intro t _
split
Β· rename_i he
apply selectedLeftCompletion_zero
intro ht
apply hne
have hcoord := congrFun he j.1
simpa [mergeCoordinates, j.property, ht] using hcoord.symm
Β· rfl
omit [DecidableEq Q₁] in
theorem selectedFullRightCompletion_support (G : Game Q₁ Qβ‚‚ A₁ Aβ‚‚)
(strategy : Strategy (Fin n β†’ Q₁) (Fin n β†’ Qβ‚‚) (Fin n β†’ A₁) (Fin n β†’ Aβ‚‚))
(selected : Finset (Fin n)) (j : {i : Fin n // i βˆ‰ selected})
(q : Qβ‚‚ Γ— SelectedCommonData (Q₁ := Q₁) (Qβ‚‚ := Qβ‚‚) (A₁ := A₁) (Aβ‚‚ := Aβ‚‚) selected j)
(r : Fin n β†’ Qβ‚‚) (h : (selectedFullRightCompletion G strategy selected j q).weight r β‰  0) :
r j.1 = q.1 := by
classical
by_contra hne
apply h
simp only [selectedFullRightCompletion, FiniteDistribution.pushforward]
apply Finset.sum_eq_zero
intro t _
split
Β· rename_i he
apply selectedRightCompletion_zero
intro ht
apply hne
have hcoord := congrFun he j.1
simpa [mergeCoordinates, j.property, ht] using hcoord.symm
Β· rfl
theorem selected_full_completion_probability (G : Game Q₁ Qβ‚‚ A₁ Aβ‚‚)
(strategy : Strategy (Fin n β†’ Q₁) (Fin n β†’ Qβ‚‚) (Fin n β†’ A₁) (Fin n β†’ Aβ‚‚))
(selected : Finset (Fin n)) (j : {i : Fin n // i βˆ‰ selected})
(s : SelectedCommonData (Q₁ := Q₁) (Qβ‚‚ := Qβ‚‚) (A₁ := A₁) (Aβ‚‚ := Aβ‚‚) selected j)
(xy : Q₁ Γ— Qβ‚‚) (event : ((Fin n β†’ Q₁) Γ— (Fin n β†’ Qβ‚‚)) β†’ Bool) :
((selectedFullLeftCompletion G strategy selected j (xy.1,s)).product
(selectedFullRightCompletion G strategy selected j (xy.2,s))).probability event =
βˆ‘ lr : ({i : Fin n // i βˆ‰ selected} β†’ Q₁) Γ— ({i : Fin n // i βˆ‰ selected} β†’ Qβ‚‚),
((selectedLeftCompletion G strategy selected j s xy.1).product
(selectedRightCompletion G strategy selected j s xy.2)).weight lr *
(if event (selectedQuestionTuple selected s.1.1 (fun i => (lr.1 i,lr.2 i)))
then 1 else 0) := by
rw [selectedFullLeftCompletion, selectedFullRightCompletion,
← FiniteDistribution.product_pushforward, FiniteDistribution.probability_pushforward]
unfold FiniteDistribution.probability
apply Finset.sum_congr rfl
intro lr _
have he : selectedQuestionTuple selected s.1.1 (fun i => (lr.1 i,lr.2 i)) =
(mergeCoordinates selected (fun i => (s.1.1 i).1) lr.1,
mergeCoordinates selected (fun i => (s.1.1 i).2) lr.2) :=
Prod.ext (selectedQuestionTuple_left selected s.1.1 _)
(selectedQuestionTuple_right selected s.1.1 _)
rw [he]
cases hevent : event (mergeCoordinates selected (fun i => (s.1.1 i).1) lr.1,
mergeCoordinates selected (fun i => (s.1.1 i).2) lr.2) <;> simp [hevent]
theorem selected_completion_event_row (G : Game Q₁ Qβ‚‚ A₁ Aβ‚‚)
(strategy : Strategy (Fin n β†’ Q₁) (Fin n β†’ Qβ‚‚) (Fin n β†’ A₁) (Fin n β†’ Aβ‚‚))
(selected : Finset (Fin n)) (positive : 0 < G.selectedSuccess strategy selected)
(j : {i : Fin n // i βˆ‰ selected})
(s : SelectedCommonData (Q₁ := Q₁) (Qβ‚‚ := Qβ‚‚) (A₁ := A₁) (Aβ‚‚ := Aβ‚‚) selected j)
(event : ((Fin n β†’ Q₁) Γ— (Fin n β†’ Qβ‚‚)) β†’ Bool) :
(βˆ‘ xy : Q₁ Γ— Qβ‚‚, (selectedCommonLaw G strategy selected positive j).weight (s,xy) *
((selectedFullLeftCompletion G strategy selected j (xy.1,s)).product
(selectedFullRightCompletion G strategy selected j (xy.2,s))).probability event) =
βˆ‘ u : {i : Fin n // i βˆ‰ selected} β†’ Q₁ Γ— Qβ‚‚,
partialRevealWeight G.questions j s.2 u *
selectedOutsideLikelihood G strategy selected s.1 u *
(if event (selectedQuestionTuple selected s.1.1 u) then 1 else 0) := by
classical
have hpoint (xy : Q₁ Γ— Qβ‚‚)
(lr : ({i : Fin n // i βˆ‰ selected} β†’ Q₁) Γ— ({i : Fin n // i βˆ‰ selected} β†’ Qβ‚‚)) :
(selectedCommonLaw G strategy selected positive j).weight (s,xy) *
((selectedLeftCompletion G strategy selected j s xy.1).product
(selectedRightCompletion G strategy selected j s xy.2)).weight lr =
if (lr.1 j,lr.2 j) = xy then
partialRevealWeight G.questions j s.2 (fun i => (lr.1 i,lr.2 i)) *
selectedOutsideLikelihood G strategy selected s.1 (fun i => (lr.1 i,lr.2 i)) else 0 :=
selected_completion_row_recombine G strategy selected positive j s xy lr.1 lr.2
simp_rw [selected_full_completion_probability, Finset.mul_sum, ← mul_assoc,
hpoint]
have hsum (xy : Q₁ Γ— Qβ‚‚) :
(βˆ‘ lr : ({i : Fin n // i βˆ‰ selected} β†’ Q₁) Γ— ({i : Fin n // i βˆ‰ selected} β†’ Qβ‚‚),
(if (lr.1 j,lr.2 j) = xy then
partialRevealWeight G.questions j s.2 (fun i => (lr.1 i,lr.2 i)) *
selectedOutsideLikelihood G strategy selected s.1 (fun i => (lr.1 i,lr.2 i)) else 0) *
(if event (selectedQuestionTuple selected s.1.1 (fun i => (lr.1 i,lr.2 i))) then 1 else 0)) =
βˆ‘ u : {i : Fin n // i βˆ‰ selected} β†’ Q₁ Γ— Qβ‚‚,
(if u j = xy then partialRevealWeight G.questions j s.2 u *
selectedOutsideLikelihood G strategy selected s.1 u else 0) *
(if event (selectedQuestionTuple selected s.1.1 u) then 1 else 0) := by
exact ((completionTupleEquiv (I := {i : Fin n // i βˆ‰ selected})
(X := Q₁) (Y := Qβ‚‚)).sum_comp _).symm
simp_rw [hsum]
rw [Finset.sum_comm]
apply Finset.sum_congr rfl
intro u _
rw [← Finset.sum_mul]
simp
def selectedFullCompletionMixture (G : Game Q₁ Qβ‚‚ A₁ Aβ‚‚)
(strategy : Strategy (Fin n β†’ Q₁) (Fin n β†’ Qβ‚‚) (Fin n β†’ A₁) (Fin n β†’ Aβ‚‚))
(selected : Finset (Fin n)) (positive : 0 < G.selectedSuccess strategy selected)
(j : {i : Fin n // i βˆ‰ selected}) :
FiniteDistribution ((Fin n β†’ Q₁) Γ— (Fin n β†’ Qβ‚‚)) :=
((selectedCommonLaw G strategy selected positive j).transport (Equiv.prodComm _ _)).mixture
(fun z => (selectedFullLeftCompletion G strategy selected j (z.1.1,z.2)).product
(selectedFullRightCompletion G strategy selected j (z.1.2,z.2)))
theorem selectedFullCompletionMixture_probability (G : Game Q₁ Qβ‚‚ A₁ Aβ‚‚)
(strategy : Strategy (Fin n β†’ Q₁) (Fin n β†’ Qβ‚‚) (Fin n β†’ A₁) (Fin n β†’ Aβ‚‚))
(selected : Finset (Fin n)) (positive : 0 < G.selectedSuccess strategy selected)
(j : {i : Fin n // i βˆ‰ selected})
(event : ((Fin n β†’ Q₁) Γ— (Fin n β†’ Qβ‚‚)) β†’ Bool) :
(selectedFullCompletionMixture G strategy selected positive j).probability event =
((G.repetition n).questions.condition (G.selectedWins strategy selected) positive).probability event := by
erw [FiniteDistribution.probability_condition]
rw [selectedFullCompletionMixture, FiniteDistribution.probability_mixture]
simp only [FiniteDistribution.transport]
rw [Fintype.sum_prod_type, Finset.sum_comm]
calc
_ = βˆ‘ s : SelectedCommonData (Q₁ := Q₁) (Qβ‚‚ := Qβ‚‚) (A₁ := A₁) (Aβ‚‚ := Aβ‚‚) selected j,
βˆ‘ u : {i : Fin n // i βˆ‰ selected} β†’ Q₁ Γ— Qβ‚‚,
partialRevealWeight G.questions j s.2 u *
selectedOutsideLikelihood G strategy selected s.1 u *
(if event (selectedQuestionTuple selected s.1.1 u) then 1 else 0) := by
apply Finset.sum_congr rfl
intro s _
exact selected_completion_event_row G strategy selected positive j s event
_ = _ := selected_partial_event_total G strategy selected j event
theorem selectedFullCompletionMixture_eq_conditionedQuestions (G : Game Q₁ Qβ‚‚ A₁ Aβ‚‚)
(strategy : Strategy (Fin n β†’ Q₁) (Fin n β†’ Qβ‚‚) (Fin n β†’ A₁) (Fin n β†’ Aβ‚‚))
(selected : Finset (Fin n)) (positive : 0 < G.selectedSuccess strategy selected)
(j : {i : Fin n // i βˆ‰ selected}) :
selectedFullCompletionMixture G strategy selected positive j =
(G.repetition n).questions.condition (G.selectedWins strategy selected) positive := by
classical
apply FiniteDistribution.eq_of_weight_eq
intro q
rw [FiniteDistribution.weight_eq_probability_singleton,
FiniteDistribution.weight_eq_probability_singleton]
exact selectedFullCompletionMixture_probability G strategy selected positive j _
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