cfahlgren1/math / lean /OAI /Combinatorics /IndependentSets /Repetition /SelectedCompletionGame.lean
cfahlgren1's picture
download
raw
16.2 kB
import Mathlib
import OAI.Combinatorics.IndependentSets.Repetition.KernelSampling
import OAI.Combinatorics.IndependentSets.Repetition.RevealFactorization
namespace OAI
namespace IndependentSetsGames.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 G.selectedWins strategy selected (selectedQuestionTuple selected fixed u) <;>
cases 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 IndependentSetsGames.Foundations.Repetition
end OAI

Xet Storage Details

Size:
16.2 kB
·
Xet hash:
187d6f3f4dbdb6799cba66c99f95433d538f757ddf53770aba320c310e58a973

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.