Download data/lean/OAI/Computability/VertexCover/Repetition/SelectedCompletionGame.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 16.8 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Computability/VertexCover/Repetition/SelectedCompletionGame.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Computability/VertexCover/Repetition/SelectedCompletionGame.lean
-
curl -L -o SelectedCompletionGame.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Computability/VertexCover/Repetition/SelectedCompletionGame.lean
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 | |