Download data/lean/OAI/Computability/BinPacking/Games/SelectedProfiles.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 46.8 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Computability/BinPacking/Games/SelectedProfiles.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Computability/BinPacking/Games/SelectedProfiles.lean
-
curl -L -o SelectedProfiles.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Computability/BinPacking/Games/SelectedProfiles.lean
46.8 kB
| import OAI.Computability.BinPacking.Games.ProfileCorrection | |
| import OAI.Computability.BinPacking.Games.QuestionMarginal | |
| namespace OAI | |
| noncomputable section | |
| namespace BinPackingGames.Foundations.Repetition | |
| section | |
| open scoped BigOperators | |
| variable {I T X Y : Type*} [Fintype I] [DecidableEq I] [Fintype T] | |
| [Fintype X] [Fintype Y] [DecidableEq X] [DecidableEq Y] | |
| def mergeAt {R : Type*} (j : I) (a : R) (rest : {i : I // i β j} β R) : I β R := | |
| fun i => if h : i = j then a else rest β¨i,hβ© | |
| omit [Fintype I] in | |
| @[simp] theorem mergeAt_self {R : Type*} (j : I) (a : R) (rest : {i : I // i β j} β R) : | |
| mergeAt j a rest j = a := by simp [mergeAt] | |
| omit [Fintype I] in | |
| @[simp] theorem mergeAt_other {R : Type*} (j : I) (a : R) | |
| (rest : {i : I // i β j} β R) (i : {i : I // i β j}) : | |
| mergeAt j a rest i.1 = rest i := by simp [mergeAt, i.property] | |
| def partialRevealWeight (ΞΌ : Games.FiniteDistribution (X Γ Y)) (j : I) | |
| (rest : {i : I // i β j} β X β Y) (u : I β X Γ Y) : β := | |
| ΞΌ.weight (u j) * β i : {i : I // i β j}, (revealLaw ΞΌ).weight (u i.1,rest i) | |
| theorem product_reveal_at (ΞΌ : Games.FiniteDistribution (X Γ Y)) (j : I) | |
| (r : X β Y) (rest : {i : I // i β j} β X β Y) (u : I β X Γ Y) : | |
| (β i, (revealLaw ΞΌ).weight (u i,mergeAt j r rest i)) = | |
| (if r = Sum.inl (u j).1 then partialRevealWeight ΞΌ j rest u / 2 else 0) + | |
| (if r = Sum.inr (u j).2 then partialRevealWeight ΞΌ j rest u / 2 else 0) := by | |
| rw [Fintype.prod_eq_mul_prod_subtype_ne _ j] | |
| simp only [mergeAt_self, mergeAt_other, revealLaw_weight] | |
| by_cases hl : r = Sum.inl (u j).1 <;> by_cases hr : r = Sum.inr (u j).2 <;> | |
| simp [hl, hr, partialRevealWeight, revealLaw_weight] <;> ring | |
| def partialRevealMarginal (ΞΌ : Games.FiniteDistribution (X Γ Y)) (j : I) | |
| (likelihood : T β (I β X Γ Y) β β) : | |
| (T Γ ({i : I // i β j} β X β Y)) Γ (X Γ Y) β β := by | |
| classical | |
| exact fun z => β u, if u j = z.2 then | |
| partialRevealWeight ΞΌ j z.1.2 u * likelihood z.1.1 u else 0 | |
| def fullRevealMarginal (ΞΌ : Games.FiniteDistribution (X Γ Y)) (j : I) | |
| (likelihood : T β (I β X Γ Y) β β) : | |
| (T Γ (I β X β Y)) Γ (X Γ Y) β β := by | |
| classical | |
| exact fun z => β u, if u j = z.2 then | |
| (β i, (revealLaw ΞΌ).weight (u i,z.1.2 i)) * likelihood z.1.1 u else 0 | |
| omit [Fintype T] in | |
| theorem fullRevealMarginal_merge (ΞΌ : Games.FiniteDistribution (X Γ Y)) (j : I) | |
| (likelihood : T β (I β X Γ Y) β β) (t : T) | |
| (rest : {i : I // i β j} β X β Y) (r : X β Y) (q : X Γ Y) : | |
| fullRevealMarginal ΞΌ j likelihood ((t,mergeAt j r rest),q) = | |
| maskedJoint (partialRevealMarginal ΞΌ j likelihood) (((t,rest),r),q) := by | |
| classical | |
| unfold fullRevealMarginal | |
| simp_rw [product_reveal_at] | |
| have hpoint (u : I β X Γ Y) : | |
| (if u j = q then | |
| ((if r = Sum.inl (u j).1 then partialRevealWeight ΞΌ j rest u / 2 else 0) + | |
| (if r = Sum.inr (u j).2 then partialRevealWeight ΞΌ j rest u / 2 else 0)) * | |
| likelihood t u else 0) = | |
| (if r = Sum.inl q.1 then | |
| (if u j = q then partialRevealWeight ΞΌ j rest u * likelihood t u else 0) / 2 else 0) + | |
| (if r = Sum.inr q.2 then | |
| (if u j = q then partialRevealWeight ΞΌ j rest u * likelihood t u else 0) / 2 else 0) := by | |
| by_cases hu : u j = q | |
| Β· rw [hu] | |
| by_cases hl : r = Sum.inl q.1 <;> by_cases hr : r = Sum.inr q.2 <;> | |
| simp [hl, hr] <;> ring | |
| Β· simp [hu] | |
| simp_rw [hpoint] | |
| simp [maskedJoint, partialRevealMarginal, Finset.sum_add_distrib, | |
| Finset.sum_ite_irrel, div_eq_mul_inv, Finset.sum_mul] | |
| def fullRevealModel (ΞΌ : Games.FiniteDistribution (X Γ Y)) (j : I) | |
| (likelihood : T β (I β X Γ Y) β β) : | |
| (T Γ (I β X β Y)) Γ (X Γ Y) β β := fun z => | |
| Information.firstMarginal (fullRevealMarginal ΞΌ j likelihood) z.1 * | |
| (revealProfile ΞΌ (z.1.2 j)).weight z.2 | |
| omit [Fintype T] in | |
| theorem fullRevealModel_merge (ΞΌ : Games.FiniteDistribution (X Γ Y)) (j : I) | |
| (likelihood : T β (I β X Γ Y) β β) (t : T) | |
| (rest : {i : I // i β j} β X β Y) (r : X β Y) (q : X Γ Y) : | |
| fullRevealModel ΞΌ j likelihood ((t,mergeAt j r rest),q) = | |
| maskedModel ΞΌ (partialRevealMarginal ΞΌ j likelihood) (((t,rest),r),q) := by | |
| simp only [fullRevealModel, Information.firstMarginal, fullRevealMarginal_merge, | |
| mergeAt_self, maskedModel] | |
| def revealSplitEquiv (j : I) : | |
| ((T Γ (I β X β Y)) Γ (X Γ Y)) β | |
| (((T Γ ({i : I // i β j} β X β Y)) Γ (X β Y)) Γ (X Γ Y)) where | |
| toFun z := (((z.1.1, fun i => z.1.2 i.1), z.1.2 j), z.2) | |
| invFun z := ((z.1.1.1, mergeAt j z.1.2 z.1.1.2), z.2) | |
| left_inv z := by | |
| apply Prod.ext | |
| Β· apply Prod.ext | |
| Β· rfl | |
| Β· funext i | |
| by_cases h : i = j <;> simp [mergeAt, h] | |
| Β· rfl | |
| right_inv z := by | |
| apply Prod.ext | |
| Β· apply Prod.ext | |
| Β· apply Prod.ext | |
| Β· rfl | |
| Β· funext i | |
| exact mergeAt_other j z.1.2 z.1.1.2 i | |
| Β· exact mergeAt_self j z.1.2 z.1.1.2 | |
| Β· rfl | |
| theorem totalVariation_comp_equiv {A B : Type*} [Fintype A] [Fintype B] | |
| (e : A β B) (p q : B β β) : | |
| Information.totalVariation (fun a => p (e a)) (fun a => q (e a)) = | |
| Information.totalVariation p q := by | |
| unfold Information.totalVariation | |
| congr 1 | |
| exact e.sum_comp (fun b => |p b - q b|) | |
| theorem fullReveal_totalVariation (ΞΌ : Games.FiniteDistribution (X Γ Y)) (j : I) | |
| (likelihood : T β (I β X Γ Y) β β) : | |
| Information.totalVariation (fullRevealMarginal ΞΌ j likelihood) (fullRevealModel ΞΌ j likelihood) = | |
| Information.totalVariation (maskedJoint (partialRevealMarginal ΞΌ j likelihood)) | |
| (maskedModel ΞΌ (partialRevealMarginal ΞΌ j likelihood)) := by | |
| calc | |
| _ = Information.totalVariation | |
| (fun z => fullRevealMarginal ΞΌ j likelihood ((revealSplitEquiv (T := T) j).symm z)) | |
| (fun z => fullRevealModel ΞΌ j likelihood ((revealSplitEquiv (T := T) j).symm z)) := | |
| (totalVariation_comp_equiv (revealSplitEquiv (T := T) j).symm _ _).symm | |
| _ = _ := by | |
| congr 1 <;> funext z | |
| Β· exact fullRevealMarginal_merge ΞΌ j likelihood z.1.1.1 z.1.1.2 z.1.2 z.2 | |
| Β· exact fullRevealModel_merge ΞΌ j likelihood z.1.1.1 z.1.1.2 z.1.2 z.2 | |
| theorem leftReveal_full_error (ΞΌ : Games.FiniteDistribution (X Γ Y)) (j : I) | |
| (likelihood : T β (I β X Γ Y) β β) : | |
| Information.totalVariation (partialRevealMarginal ΞΌ j likelihood) | |
| (leftRevealModel ΞΌ (partialRevealMarginal ΞΌ j likelihood)) β€ | |
| 2 * Information.totalVariation (fullRevealMarginal ΞΌ j likelihood) | |
| (fullRevealModel ΞΌ j likelihood) := by | |
| rw [fullReveal_totalVariation] | |
| exact leftRevealModel_totalVariation_le ΞΌ _ | |
| theorem rightReveal_full_error (ΞΌ : Games.FiniteDistribution (X Γ Y)) (j : I) | |
| (likelihood : T β (I β X Γ Y) β β) : | |
| Information.totalVariation (partialRevealMarginal ΞΌ j likelihood) | |
| (rightRevealModel ΞΌ (partialRevealMarginal ΞΌ j likelihood)) β€ | |
| 2 * Information.totalVariation (fullRevealMarginal ΞΌ j likelihood) | |
| (fullRevealModel ΞΌ j likelihood) := by | |
| rw [fullReveal_totalVariation] | |
| exact rightRevealModel_totalVariation_le ΞΌ _ | |
| end | |
| section | |
| open scoped BigOperators | |
| open Games Information | |
| 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 selectedSplit_question_probability (G : Game Qβ Qβ Aβ Aβ) | |
| (selected : Finset (Fin n)) | |
| (event : ((Fin n β Qβ) Γ (Fin n β Qβ)) β Bool) : | |
| (selectedSplitLaw G selected).probability | |
| (fun q => event (selectedQuestionTuple selected q.1 q.2)) = | |
| (G.repetition n).questions.probability event := by | |
| rw [selectedSplitLaw, β iid_coordinate_split, FiniteDistribution.probability_transport] | |
| change (G.questions.iid n).probability _ = | |
| ((G.questions.iid n).transport (Game.tupleQuestionEquiv n)).probability event | |
| rw [FiniteDistribution.probability_transport] | |
| apply congrArg (G.questions.iid n).probability | |
| funext q | |
| congr 1 | |
| apply Prod.ext <;> funext i <;> | |
| simp [selectedQuestionTuple, coordinateSplitEquiv, mergeCoordinates, Game.tupleQuestionEquiv] | |
| theorem selectedJoint_eventMass (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) : | |
| (β tv : SelectedInput Qβ Qβ selected Γ | |
| SelectedLabels (Aβ := Aβ) (Aβ := Aβ) selected, | |
| (selectedInputLaw G selected).weight tv.1 * | |
| β u, independentProduct | |
| (fun i => (selectedInputProfile G selected tv.1 i).weight) u * | |
| selectedLikelihood G strategy selected tv.1.1 tv.2 u * | |
| (if event (selectedQuestionTuple selected tv.1.1 u) then 1 else 0)) = | |
| (G.repetition n).questions.probability | |
| (fun q => G.selectedWins strategy selected q && event q) := by | |
| classical | |
| have hlabel (t : SelectedInput Qβ Qβ selected) : | |
| (β v, β u, independentProduct | |
| (fun i => (selectedInputProfile G selected t i).weight) u * | |
| selectedLikelihood G strategy selected t.1 v u * | |
| (if event (selectedQuestionTuple selected t.1 u) then 1 else 0)) = | |
| β u, independentProduct | |
| (fun i => (selectedInputProfile G selected t i).weight) u * | |
| (if G.selectedWins strategy selected (selectedQuestionTuple selected t.1 u) && | |
| event (selectedQuestionTuple selected t.1 u) then 1 else 0) := by | |
| rw [Finset.sum_comm] | |
| apply Finset.sum_congr rfl | |
| intro u _ | |
| rw [β Finset.sum_mul, β Finset.mul_sum, selectedLikelihood_sum] | |
| cases G.selectedWins strategy selected (selectedQuestionTuple selected t.1 u) <;> | |
| cases event (selectedQuestionTuple selected t.1 u) <;> simp | |
| rw [Fintype.sum_prod_type] | |
| simp_rw [β Finset.mul_sum, hlabel] | |
| rw [Fintype.sum_prod_type] | |
| simp only [selectedInputLaw, FiniteDistribution.product, FiniteDistribution.table, | |
| selectedInputProfile, independentProduct] | |
| simp_rw [mul_assoc, β Finset.mul_sum] | |
| have hforget (fixed : selected β Qβ Γ Qβ) := | |
| reveal_product_expectation G.questions | |
| (fun u : {i : Fin n // i β selected} β Qβ Γ Qβ => | |
| if G.selectedWins strategy selected (selectedQuestionTuple selected fixed u) && | |
| event (selectedQuestionTuple selected fixed u) then (1 : β) else 0) | |
| simp_rw [hforget] | |
| 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, Finset.mul_sum, mul_ite, mul_assoc] using h | |
| theorem selectedJointLaw_question_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) | |
| (event : ((Fin n β Qβ) Γ (Fin n β Qβ)) β Bool) : | |
| (selectedJointLaw G strategy selected positive).probability | |
| (fun z => event (selectedQuestionTuple selected z.1.1.1 z.2)) = | |
| ((G.repetition n).questions.condition (G.selectedWins strategy selected) positive).probability | |
| event := by | |
| classical | |
| erw [FiniteDistribution.probability_condition] | |
| change | |
| (β z : (SelectedInput Qβ Qβ selected Γ | |
| SelectedLabels (Aβ := Aβ) (Aβ := Aβ) selected) Γ | |
| ({i : Fin n // i β selected} β Qβ Γ Qβ), | |
| if event (selectedQuestionTuple selected z.1.1.1 z.2) | |
| then selectedJointWeight G strategy selected z else 0) = | |
| (G.repetition n).questions.probability | |
| (fun q => G.selectedWins strategy selected q && event q) / | |
| G.selectedSuccess strategy selected | |
| calc | |
| _ = (β tv : SelectedInput Qβ Qβ selected Γ | |
| SelectedLabels (Aβ := Aβ) (Aβ := Aβ) selected, | |
| (selectedInputLaw G selected).weight tv.1 * | |
| β u, independentProduct | |
| (fun i => (selectedInputProfile G selected tv.1 i).weight) u * | |
| selectedLikelihood G strategy selected tv.1.1 tv.2 u * | |
| (if event (selectedQuestionTuple selected tv.1.1 u) then 1 else 0)) / | |
| G.selectedSuccess strategy selected := by | |
| conv_lhs => rw [Fintype.sum_prod_type] | |
| simp only [div_eq_mul_inv, Finset.sum_mul, Finset.mul_sum] | |
| apply Finset.sum_congr rfl | |
| intro tv _ | |
| apply Finset.sum_congr rfl | |
| intro u _ | |
| cases event (selectedQuestionTuple selected tv.1.1 u) <;> | |
| simp [selectedJointWeight, div_eq_mul_inv, mul_assoc] | |
| _ = _ := by rw [selectedJoint_eventMass] | |
| theorem selectedJointLaw_questions_pushforward (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) : | |
| (selectedJointLaw G strategy selected positive).pushforward | |
| (fun z => selectedQuestionTuple selected z.1.1.1 z.2) = | |
| (G.repetition n).questions.condition (G.selectedWins strategy selected) positive := by | |
| classical | |
| apply FiniteDistribution.eq_of_weight_eq | |
| intro questions | |
| have h : | |
| ((selectedJointLaw G strategy selected positive).pushforward | |
| (fun z => selectedQuestionTuple selected z.1.1.1 z.2)).probability | |
| (fun q => decide (q = questions)) = | |
| ((G.repetition n).questions.condition (G.selectedWins strategy selected) positive).probability | |
| (fun q => decide (q = questions)) := by | |
| rw [FiniteDistribution.probability_pushforward] | |
| exact selectedJointLaw_question_probability G strategy selected positive | |
| (fun q => decide (q = questions)) | |
| simpa [FiniteDistribution.probability] using h | |
| end | |
| section | |
| open scoped BigOperators | |
| open Games Information | |
| variable {Qβ Qβ Aβ Aβ : Type*} | |
| [Fintype Qβ] [Fintype Qβ] [Fintype Aβ] [Fintype Aβ] | |
| [DecidableEq Qβ] [DecidableEq Qβ] {n : Nat} | |
| def selectedRawMarginal (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}) : | |
| (SelectedInput Qβ Qβ selected Γ SelectedLabels (Aβ := Aβ) (Aβ := Aβ) selected) Γ | |
| (Qβ Γ Qβ) β β := by | |
| classical | |
| exact fun z => β u, if u j = z.2 then selectedJointWeight G strategy selected (z.1,u) else 0 | |
| theorem selectedPosterior_eq_raw (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}) (tv) (q) : | |
| selectedSideWeight G strategy selected tv * coordinateMarginal | |
| (posteriorOrOriginal | |
| (independentProduct (fun i => (selectedInputProfile G selected tv.1 i).weight)) | |
| (selectedLikelihood G strategy selected tv.1.1 tv.2) | |
| (selectedSideMass G strategy selected tv)) j q = | |
| selectedRawMarginal G strategy selected j (tv,q) := by | |
| classical | |
| rw [selectedSideWeight] | |
| have h := weighted_coordinate_posterior_recombine | |
| (independentProduct (fun i => (selectedInputProfile G selected tv.1 i).weight)) | |
| (selectedLikelihood G strategy selected tv.1.1 tv.2) | |
| (independentProduct_isProbability _ | |
| (fun i => gameLaw_isProbability (selectedInputProfile G selected tv.1 i))) | |
| (selectedLikelihood_nonnegative G strategy selected tv.1.1 tv.2) | |
| (c := selectedSideMass G strategy selected tv) rfl | |
| ((selectedInputLaw G selected).weight tv.1) (G.selectedSuccess strategy selected) j q | |
| rw [h] | |
| simp only [Finset.mul_sum, selectedRawMarginal, selectedJointWeight] | |
| apply Finset.sum_congr rfl | |
| intro u _ | |
| by_cases hu : u j = q | |
| Β· simp only [ite_eq_left hu] | |
| ring | |
| Β· simp [hu] | |
| theorem selectedRawMarginal_firstMarginal (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}) (tv) : | |
| firstMarginal (selectedRawMarginal G strategy selected j) tv = | |
| selectedSideWeight G strategy selected tv := by | |
| classical | |
| simp only [firstMarginal, selectedRawMarginal] | |
| rw [Finset.sum_comm] | |
| simp only [Finset.sum_ite_eq, Finset.mem_univ, ite_true] | |
| exact selectedJointWeight_firstMarginal G strategy selected tv | |
| theorem selectedRawMarginal_isProbability (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}) : | |
| IsProbability (selectedRawMarginal G strategy selected j) := by | |
| classical | |
| constructor | |
| Β· intro z | |
| apply Finset.sum_nonneg | |
| intro u _ | |
| split | |
| Β· exact selectedJointWeight_nonnegative G strategy selected (z.1,u) | |
| Β· exact le_rfl | |
| Β· rw [Fintype.sum_prod_type] | |
| change (β tv, firstMarginal (selectedRawMarginal G strategy selected j) tv) = 1 | |
| simp_rw [selectedRawMarginal_firstMarginal, selectedSideWeight, div_eq_mul_inv] | |
| rw [β Finset.sum_mul, selectedSideMass_total, mul_inv_cancelβ positive.ne'] | |
| theorem selected_raw_information_bound [Nonempty Aβ] [Nonempty Aβ] | |
| (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}, totalVariation | |
| (selectedRawMarginal G strategy selected j) | |
| (fun z => selectedSideWeight G strategy selected z.1 * | |
| (selectedInputProfile G selected z.1.1 j).weight z.2)) β€ | |
| Real.sqrt ((Fintype.card {i : Fin n // i β selected} : β) * | |
| (Real.log (Fintype.card (SelectedLabels (Aβ := Aβ) (Aβ := Aβ) selected) : β) + | |
| Real.log (1 / G.selectedSuccess strategy selected))) := by | |
| have h := selected_information_bound G strategy selected positive | |
| simp_rw [selectedPosterior_eq_raw] at h | |
| exact h | |
| def selectedOutsideLikelihood (G : Game Qβ Qβ Aβ Aβ) | |
| (strategy : Strategy (Fin n β Qβ) (Fin n β Qβ) (Fin n β Aβ) (Fin n β Aβ)) | |
| (selected : Finset (Fin n)) | |
| (t : (selected β Qβ Γ Qβ) Γ SelectedLabels (Aβ := Aβ) (Aβ := Aβ) selected) | |
| (u : {i : Fin n // i β selected} β Qβ Γ Qβ) : β := | |
| (β i : selected, G.questions.weight (t.1 i)) * | |
| selectedLikelihood G strategy selected t.1 t.2 u / G.selectedSuccess strategy selected | |
| def selectedObservationEquiv (selected : Finset (Fin n)) : | |
| ((SelectedInput Qβ Qβ selected Γ SelectedLabels (Aβ := Aβ) (Aβ := Aβ) selected) Γ | |
| (Qβ Γ Qβ)) β | |
| ((((selected β Qβ Γ Qβ) Γ SelectedLabels (Aβ := Aβ) (Aβ := Aβ) selected) Γ | |
| ({i : Fin n // i β selected} β Qβ β Qβ)) Γ (Qβ Γ Qβ)) where | |
| toFun z := (((z.1.1.1,z.1.2),z.1.1.2),z.2) | |
| invFun z := (((z.1.1.1,z.1.2),z.1.1.2),z.2) | |
| left_inv _ := rfl | |
| right_inv _ := rfl | |
| theorem selectedRawMarginal_fullReveal (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}) (z) : | |
| selectedRawMarginal G strategy selected j | |
| ((selectedObservationEquiv (Qβ := Qβ) (Qβ := Qβ) (Aβ := Aβ) (Aβ := Aβ) selected).symm z) = | |
| fullRevealMarginal G.questions j (selectedOutsideLikelihood G strategy selected) z := by | |
| classical | |
| change selectedRawMarginal G strategy selected j | |
| (((z.1.1.1,z.1.2),z.1.1.2),z.2) = _ | |
| simp only [selectedRawMarginal, fullRevealMarginal] | |
| apply Finset.sum_congr rfl | |
| intro u _ | |
| by_cases hu : u j = z.2 | |
| Β· simp only [ite_eq_left hu, selectedJointWeight_factorization, selectedOutsideLikelihood] | |
| ring | |
| Β· simp [hu] | |
| theorem selectedRawReference_fullReveal (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}) (z) : | |
| (fun w => selectedSideWeight G strategy selected w.1 * | |
| (selectedInputProfile G selected w.1.1 j).weight w.2) | |
| ((selectedObservationEquiv (Qβ := Qβ) (Qβ := Qβ) (Aβ := Aβ) (Aβ := Aβ) selected).symm z) = | |
| fullRevealModel G.questions j (selectedOutsideLikelihood G strategy selected) z := by | |
| change selectedSideWeight G strategy selected ((z.1.1.1,z.1.2),z.1.1.2) * | |
| (revealProfile G.questions (z.1.2 j)).weight z.2 = _ | |
| rw [β selectedRawMarginal_firstMarginal G strategy selected j] | |
| unfold firstMarginal fullRevealModel | |
| congr 1 | |
| apply Finset.sum_congr rfl | |
| intro q _ | |
| exact selectedRawMarginal_fullReveal G strategy selected j (z.1,q) | |
| theorem selected_raw_error_eq_fullReveal (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}) : | |
| totalVariation (selectedRawMarginal G strategy selected j) | |
| (fun z => selectedSideWeight G strategy selected z.1 * | |
| (selectedInputProfile G selected z.1.1 j).weight z.2) = | |
| totalVariation (fullRevealMarginal G.questions j (selectedOutsideLikelihood G strategy selected)) | |
| (fullRevealModel G.questions j (selectedOutsideLikelihood G strategy selected)) := by | |
| rw [β totalVariation_comp_equiv | |
| (selectedObservationEquiv (Qβ := Qβ) (Qβ := Qβ) (Aβ := Aβ) (Aβ := Aβ) selected).symm] | |
| congr 1 <;> funext z | |
| Β· exact selectedRawMarginal_fullReveal G strategy selected j z | |
| Β· exact selectedRawReference_fullReveal G strategy selected j z | |
| theorem selected_fullReveal_information_bound [Nonempty Aβ] [Nonempty Aβ] | |
| (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}, | |
| totalVariation (fullRevealMarginal G.questions j (selectedOutsideLikelihood G strategy selected)) | |
| (fullRevealModel G.questions j (selectedOutsideLikelihood G strategy selected))) β€ | |
| Real.sqrt ((Fintype.card {i : Fin n // i β selected} : β) * | |
| (Real.log (Fintype.card (SelectedLabels (Aβ := Aβ) (Aβ := Aβ) selected) : β) + | |
| Real.log (1 / G.selectedSuccess strategy selected))) := by | |
| have h := selected_raw_information_bound G strategy selected positive | |
| simp_rw [selected_raw_error_eq_fullReveal] at h | |
| exact h | |
| def selectedInformationRadius (G : Game Qβ Qβ Aβ Aβ) | |
| (strategy : Strategy (Fin n β Qβ) (Fin n β Qβ) (Fin n β Aβ) (Fin n β Aβ)) | |
| (selected : Finset (Fin n)) : β := | |
| Real.sqrt ((Fintype.card {i : Fin n // i β selected} : β) * | |
| (Real.log (Fintype.card (SelectedLabels (Aβ := Aβ) (Aβ := Aβ) selected) : β) + | |
| Real.log (1 / G.selectedSuccess strategy selected))) | |
| theorem selected_leftReveal_error_sum [Nonempty Aβ] [Nonempty Aβ] | |
| (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}, | |
| totalVariation (partialRevealMarginal G.questions j (selectedOutsideLikelihood G strategy selected)) | |
| (leftRevealModel G.questions | |
| (partialRevealMarginal G.questions j (selectedOutsideLikelihood G strategy selected)))) β€ | |
| 2 * selectedInformationRadius G strategy selected := by | |
| calc | |
| _ β€ β j : {i : Fin n // i β selected}, | |
| 2 * totalVariation (fullRevealMarginal G.questions j (selectedOutsideLikelihood G strategy selected)) | |
| (fullRevealModel G.questions j (selectedOutsideLikelihood G strategy selected)) := by | |
| apply Finset.sum_le_sum | |
| intro j _ | |
| exact leftReveal_full_error G.questions j _ | |
| _ = 2 * β j : {i : Fin n // i β selected}, | |
| totalVariation (fullRevealMarginal G.questions j (selectedOutsideLikelihood G strategy selected)) | |
| (fullRevealModel G.questions j (selectedOutsideLikelihood G strategy selected)) := | |
| (Finset.mul_sum _ _ _).symm | |
| _ β€ _ := mul_le_mul_of_nonneg_left | |
| (selected_fullReveal_information_bound G strategy selected positive) (by norm_num) | |
| theorem selected_rightReveal_error_sum [Nonempty Aβ] [Nonempty Aβ] | |
| (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}, | |
| totalVariation (partialRevealMarginal G.questions j (selectedOutsideLikelihood G strategy selected)) | |
| (rightRevealModel G.questions | |
| (partialRevealMarginal G.questions j (selectedOutsideLikelihood G strategy selected)))) β€ | |
| 2 * selectedInformationRadius G strategy selected := by | |
| calc | |
| _ β€ β j : {i : Fin n // i β selected}, | |
| 2 * totalVariation (fullRevealMarginal G.questions j (selectedOutsideLikelihood G strategy selected)) | |
| (fullRevealModel G.questions j (selectedOutsideLikelihood G strategy selected)) := by | |
| apply Finset.sum_le_sum | |
| intro j _ | |
| exact rightReveal_full_error G.questions j _ | |
| _ = 2 * β j : {i : Fin n // i β selected}, | |
| totalVariation (fullRevealMarginal G.questions j (selectedOutsideLikelihood G strategy selected)) | |
| (fullRevealModel G.questions j (selectedOutsideLikelihood G strategy selected)) := | |
| (Finset.mul_sum _ _ _).symm | |
| _ β€ _ := mul_le_mul_of_nonneg_left | |
| (selected_fullReveal_information_bound G strategy selected positive) (by norm_num) | |
| end | |
| section | |
| open scoped BigOperators | |
| open Games | |
| variable {I X Y : Type*} [Fintype I] [DecidableEq I] | |
| [Fintype X] [Fintype Y] [DecidableEq X] [DecidableEq Y] | |
| def revealLeftFactor (ΞΌ : FiniteDistribution (X Γ Y)) (r : X β Y) (x : X) : β := | |
| match r with | |
| | Sum.inl u => if x = u then 1 else 0 | |
| | Sum.inr v => ΞΌ.weight (x,v) / 2 | |
| def revealRightFactor (ΞΌ : FiniteDistribution (X Γ Y)) (r : X β Y) (y : Y) : β := | |
| match r with | |
| | Sum.inl u => ΞΌ.weight (u,y) / 2 | |
| | Sum.inr v => if y = v then 1 else 0 | |
| omit [DecidableEq Y] in | |
| theorem revealLeftFactor_nonnegative (ΞΌ : FiniteDistribution (X Γ Y)) | |
| (r : X β Y) (x : X) : 0 β€ revealLeftFactor ΞΌ r x := by | |
| cases r with | |
| | inl u => simp only [revealLeftFactor]; split <;> norm_num | |
| | inr v => exact div_nonneg (ΞΌ.nonnegative _) (by norm_num) | |
| omit [DecidableEq X] in | |
| theorem revealRightFactor_nonnegative (ΞΌ : FiniteDistribution (X Γ Y)) | |
| (r : X β Y) (y : Y) : 0 β€ revealRightFactor ΞΌ r y := by | |
| cases r with | |
| | inl u => exact div_nonneg (ΞΌ.nonnegative _) (by norm_num) | |
| | inr v => simp only [revealRightFactor]; split <;> norm_num | |
| theorem revealLaw_factorization (ΞΌ : FiniteDistribution (X Γ Y)) | |
| (r : X β Y) (x : X) (y : Y) : | |
| (revealLaw ΞΌ).weight ((x,y),r) = | |
| revealLeftFactor ΞΌ r x * revealRightFactor ΞΌ r y := by | |
| rw [revealLaw_weight] | |
| cases r with | |
| | inl u => | |
| by_cases h : x = u | |
| Β· subst x; simp [revealLeftFactor, revealRightFactor] | |
| Β· simp [revealLeftFactor, revealRightFactor, h, Ne.symm h] | |
| | inr v => | |
| by_cases h : y = v | |
| Β· subst y; simp [revealLeftFactor, revealRightFactor] | |
| Β· simp [revealLeftFactor, revealRightFactor, h, Ne.symm h] | |
| def partialLeftFactor (ΞΌ : FiniteDistribution (X Γ Y)) (j : I) | |
| (rest : {i : I // i β j} β X β Y) (x : I β X) : β := | |
| β i, revealLeftFactor ΞΌ (rest i) (x i.1) | |
| def partialRightFactor (ΞΌ : FiniteDistribution (X Γ Y)) (j : I) | |
| (rest : {i : I // i β j} β X β Y) (y : I β Y) : β := | |
| β i, revealRightFactor ΞΌ (rest i) (y i.1) | |
| theorem partialRevealWeight_factorization (ΞΌ : FiniteDistribution (X Γ Y)) (j : I) | |
| (rest : {i : I // i β j} β X β Y) (u : I β X Γ Y) : | |
| partialRevealWeight ΞΌ j rest u = | |
| ΞΌ.weight (u j) * partialLeftFactor ΞΌ j rest (fun i => (u i).1) * | |
| partialRightFactor ΞΌ j rest (fun i => (u i).2) := by | |
| have hpoint (i : {i : I // i β j}) : | |
| (revealLaw ΞΌ).weight (u i.1,rest i) = | |
| revealLeftFactor ΞΌ (rest i) (u i.1).1 * revealRightFactor ΞΌ (rest i) (u i.1).2 := | |
| revealLaw_factorization ΞΌ (rest i) (u i.1).1 (u i.1).2 | |
| simp only [partialRevealWeight, partialLeftFactor, partialRightFactor, | |
| hpoint, Finset.prod_mul_distrib] | |
| ring | |
| end | |
| section | |
| open scoped BigOperators | |
| open Games Information | |
| theorem isProbability_comp_equiv {A B : Type*} [Fintype A] [Fintype B] | |
| (e : A β B) (p : B β β) (hp : IsProbability p) : | |
| IsProbability (fun a => p (e a)) := by | |
| constructor | |
| Β· intro a | |
| exact hp.1 _ | |
| Β· rw [e.sum_comp] | |
| exact hp.2 | |
| theorem partialRevealMarginal_isProbability | |
| {I T X Y : Type*} [Fintype I] [DecidableEq I] [Fintype T] | |
| [Fintype X] [Fintype Y] [DecidableEq X] [DecidableEq Y] | |
| (ΞΌ : FiniteDistribution (X Γ Y)) (j : I) | |
| (likelihood : T β (I β X Γ Y) β β) | |
| (hp : IsProbability (fullRevealMarginal ΞΌ j likelihood)) : | |
| IsProbability (partialRevealMarginal ΞΌ j likelihood) := by | |
| apply (maskedJoint_isProbability_iff _).mp | |
| have h := isProbability_comp_equiv (revealSplitEquiv (T := T) j).symm _ hp | |
| have he : (fun z => fullRevealMarginal ΞΌ j likelihood | |
| ((revealSplitEquiv (T := T) j).symm z)) = | |
| maskedJoint (partialRevealMarginal ΞΌ j likelihood) := by | |
| funext z | |
| exact fullRevealMarginal_merge ΞΌ j likelihood z.1.1.1 z.1.1.2 z.1.2 z.2 | |
| rw [he] at h | |
| exact h | |
| variable {Qβ Qβ Aβ Aβ : Type*} | |
| [Fintype Qβ] [Fintype Qβ] [Fintype Aβ] [Fintype Aβ] | |
| [DecidableEq Qβ] [DecidableEq Qβ] {n : Nat} | |
| abbrev SelectedCommonData (selected : Finset (Fin n)) | |
| (j : {i : Fin n // i β selected}) := | |
| ((selected β Qβ Γ Qβ) Γ SelectedLabels (Aβ := Aβ) (Aβ := Aβ) selected) Γ | |
| ({i : {i : Fin n // i β selected} // i β j} β Qβ β Qβ) | |
| theorem selected_fullReveal_isProbability (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}) : | |
| IsProbability (fullRevealMarginal G.questions j | |
| (selectedOutsideLikelihood G strategy selected)) := by | |
| have h := isProbability_comp_equiv | |
| (selectedObservationEquiv (Qβ := Qβ) (Qβ := Qβ) (Aβ := Aβ) (Aβ := Aβ) selected).symm | |
| _ (selectedRawMarginal_isProbability G strategy selected positive j) | |
| have he : (fun z => selectedRawMarginal G strategy selected j | |
| ((selectedObservationEquiv (Qβ := Qβ) (Qβ := Qβ) (Aβ := Aβ) (Aβ := Aβ) selected).symm z)) = | |
| fullRevealMarginal G.questions j (selectedOutsideLikelihood G strategy selected) := by | |
| funext z | |
| exact selectedRawMarginal_fullReveal G strategy selected j z | |
| rw [he] at h | |
| exact h | |
| def selectedCommonLaw (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 (SelectedCommonData (Qβ := Qβ) (Qβ := Qβ) | |
| (Aβ := Aβ) (Aβ := Aβ) selected j Γ (Qβ Γ Qβ)) := | |
| toGameLaw (partialRevealMarginal G.questions j (selectedOutsideLikelihood G strategy selected)) | |
| (partialRevealMarginal_isProbability G.questions j _ | |
| (selected_fullReveal_isProbability G strategy selected positive j)) | |
| end | |
| section | |
| open scoped BigOperators | |
| open Games Information | |
| variable {S X Y : Type*} [Fintype S] [Fintype X] [Fintype Y] | |
| theorem firstMarginal_totalVariation_le (r t : X Γ Y β β) : | |
| totalVariation (firstMarginal r) (firstMarginal t) β€ totalVariation r t := by | |
| unfold totalVariation firstMarginal | |
| simp_rw [β Finset.sum_sub_distrib] | |
| have h := Finset.sum_le_sum (s := Finset.univ) | |
| (fun x _ => Finset.abs_sum_le_sum_abs (fun y : Y => r (x,y)-t (x,y)) Finset.univ) | |
| rw [Fintype.sum_prod_type] | |
| linarith | |
| def leftCommonMarginal (p : S Γ (X Γ Y) β β) : X Γ S β β := | |
| fun z => β y, p (z.2,(z.1,y)) | |
| def leftCommonProfile (p : S Γ (X Γ Y) β β) (fallback : S β β) : X β S β β := | |
| conditionalKernel (leftCommonMarginal p) fallback | |
| def swapSeedLeft : (X Γ (S Γ Y)) β (S Γ (X Γ Y)) where | |
| toFun z := (z.2.1,(z.1,z.2.2)) | |
| invFun z := (z.2.1,(z.1,z.2.2)) | |
| left_inv _ := rfl | |
| right_inv _ := rfl | |
| theorem leftCommonMarginal_isProbability (p : S Γ (X Γ Y) β β) | |
| (hp : IsProbability p) : IsProbability (leftCommonMarginal p) := by | |
| exact ProfileCorrection.seedQuestionMarginal_isProbability | |
| (fun z => p (swapSeedLeft z)) (isProbability_comp_equiv swapSeedLeft p hp) | |
| theorem leftCommonProfile_isProbability (p : S Γ (X Γ Y) β β) (fallback : S β β) | |
| (hp : IsProbability p) (hf : IsProbability fallback) (x : X) : | |
| IsProbability (leftCommonProfile p fallback x) := | |
| conditionalKernel_isProbability _ _ (leftCommonMarginal_isProbability p hp) hf x | |
| theorem leftCommonProfile_error [DecidableEq X] [DecidableEq Y] | |
| (p : S Γ (X Γ Y) β β) (ΞΌ : FiniteDistribution (X Γ Y)) (fallback : S β β) | |
| (hp : IsProbability p) (hf : IsProbability fallback) : | |
| totalVariation p (fun z => ΞΌ.weight z.2 * leftCommonProfile p fallback z.2.1 z.1) β€ | |
| totalVariation p (leftRevealModel ΞΌ p) + totalVariation (secondMarginal p) ΞΌ.weight := by | |
| let e := swapSeedLeft (S := S) (X := X) (Y := Y) | |
| let p' : X Γ (S Γ Y) β β := fun z => p (e z) | |
| have h := ProfileCorrection.left_profile_correction p' ΞΌ.weight fallback | |
| (ΞΌ.pushforward Prod.snd).weight | |
| (isProbability_comp_equiv e p hp) (gameLaw_isProbability ΞΌ) hf | |
| (gameLaw_isProbability (ΞΌ.pushforward Prod.snd)) | |
| have hs : ProfileCorrection.seedQuestionMarginal p' = leftCommonMarginal p := rfl | |
| have hc : (fun z : X Γ (S Γ Y) => ProfileCorrection.seedQuestionMarginal p' (z.1,z.2.1) * | |
| conditionalKernel ΞΌ.weight (ΞΌ.pushforward Prod.snd).weight z.1 z.2.2) = | |
| fun z => leftRevealModel ΞΌ p (e z) := by | |
| funext z | |
| change (β y, p (z.2.1,(z.1,y))) * | |
| conditionalKernel ΞΌ.weight (ΞΌ.pushforward Prod.snd).weight z.1 z.2.2 = | |
| (β y, p (z.2.1,(z.1,y))) * | |
| (revealProfile ΞΌ (Sum.inl z.1)).weight (z.1,z.2.2) | |
| rw [revealProfile_inl_diagonal] | |
| have hd : (fun z : X Γ (S Γ Y) => ΞΌ.weight (z.1,z.2.2) * | |
| conditionalKernel (ProfileCorrection.seedQuestionMarginal p') fallback z.1 z.2.1) = | |
| fun z => ΞΌ.weight (e z).2 * leftCommonProfile p fallback (e z).2.1 (e z).1 := rfl | |
| rw [hc, hd] at h | |
| change totalVariation (fun z => p (e z)) _ β€ | |
| totalVariation (fun z => p (e z)) _ + _ at h | |
| rw [totalVariation_comp_equiv e p (leftRevealModel ΞΌ p)] at h | |
| rw [totalVariation_comp_equiv e p | |
| (fun z => ΞΌ.weight z.2 * leftCommonProfile p fallback z.2.1 z.1)] at h | |
| have hm : firstMarginal p' = firstMarginal (secondMarginal p) := by | |
| funext x | |
| simp only [firstMarginal, secondMarginal, Fintype.sum_prod_type, p', e, swapSeedLeft] | |
| exact Finset.sum_comm | |
| rw [hm] at h | |
| exact h.trans (add_le_add le_rfl (firstMarginal_totalVariation_le (secondMarginal p) ΞΌ.weight)) | |
| def swapQuestionEndpoints : (S Γ (Y Γ X)) β (S Γ (X Γ Y)) where | |
| toFun z := (z.1,(z.2.2,z.2.1)) | |
| invFun z := (z.1,(z.2.2,z.2.1)) | |
| left_inv _ := rfl | |
| right_inv _ := rfl | |
| def rightCommonMarginal (p : S Γ (X Γ Y) β β) : Y Γ S β β := | |
| fun z => β x, p (z.2,(x,z.1)) | |
| def rightCommonProfile (p : S Γ (X Γ Y) β β) (fallback : S β β) : Y β S β β := | |
| conditionalKernel (rightCommonMarginal p) fallback | |
| theorem rightCommonProfile_isProbability (p : S Γ (X Γ Y) β β) (fallback : S β β) | |
| (hp : IsProbability p) (hf : IsProbability fallback) (y : Y) : | |
| IsProbability (rightCommonProfile p fallback y) := | |
| leftCommonProfile_isProbability (fun z => p (swapQuestionEndpoints z)) fallback | |
| (isProbability_comp_equiv swapQuestionEndpoints p hp) hf y | |
| theorem swap_question_pushforward_snd (ΞΌ : FiniteDistribution (X Γ Y)) : | |
| ((ΞΌ.transport (Equiv.prodComm X Y)).pushforward Prod.snd) = ΞΌ.pushforward Prod.fst := by | |
| rw [FiniteDistribution.transport_eq_pushforward, FiniteDistribution.pushforward_comp] | |
| rfl | |
| omit [Fintype S] in | |
| theorem leftRevealModel_swap [DecidableEq X] [DecidableEq Y] | |
| (p : S Γ (X Γ Y) β β) (ΞΌ : FiniteDistribution (X Γ Y)) (z : S Γ (Y Γ X)) : | |
| leftRevealModel (ΞΌ.transport (Equiv.prodComm X Y)) | |
| (fun z => p (swapQuestionEndpoints z)) z = rightRevealModel ΞΌ p (swapQuestionEndpoints z) := by | |
| rcases z with β¨s,y,xβ© | |
| change (β x', p (s,(x',y))) * | |
| (revealProfile (ΞΌ.transport (Equiv.prodComm X Y)) (Sum.inl y)).weight (y,x) = | |
| (β x', p (s,(x',y))) * (revealProfile ΞΌ (Sum.inr y)).weight (x,y) | |
| rw [revealProfile_inl_diagonal, revealProfile_inr_diagonal, swap_question_pushforward_snd] | |
| theorem rightCommonProfile_error [DecidableEq X] [DecidableEq Y] | |
| (p : S Γ (X Γ Y) β β) (ΞΌ : FiniteDistribution (X Γ Y)) (fallback : S β β) | |
| (hp : IsProbability p) (hf : IsProbability fallback) : | |
| totalVariation p (fun z => ΞΌ.weight z.2 * rightCommonProfile p fallback z.2.2 z.1) β€ | |
| totalVariation p (rightRevealModel ΞΌ p) + totalVariation (secondMarginal p) ΞΌ.weight := by | |
| let e := swapQuestionEndpoints (S := S) (X := X) (Y := Y) | |
| let p' : S Γ (Y Γ X) β β := fun z => p (e z) | |
| let ΞΌ' := ΞΌ.transport (Equiv.prodComm X Y) | |
| have h := leftCommonProfile_error p' ΞΌ' fallback (isProbability_comp_equiv e p hp) hf | |
| have hc : leftRevealModel ΞΌ' p' = fun z => rightRevealModel ΞΌ p (e z) := by | |
| funext z | |
| exact leftRevealModel_swap p ΞΌ z | |
| have hd : (fun z : S Γ (Y Γ X) => ΞΌ'.weight z.2 * leftCommonProfile p' fallback z.2.1 z.1) = | |
| fun z => ΞΌ.weight (e z).2 * rightCommonProfile p fallback (e z).2.2 (e z).1 := rfl | |
| rw [hc, hd] at h | |
| change totalVariation (fun z => p (e z)) _ β€ | |
| totalVariation (fun z => p (e z)) _ + _ at h | |
| rw [totalVariation_comp_equiv e p (rightRevealModel ΞΌ p)] at h | |
| rw [totalVariation_comp_equiv e p | |
| (fun z => ΞΌ.weight z.2 * rightCommonProfile p fallback z.2.2 z.1)] at h | |
| have hm : totalVariation (secondMarginal p') ΞΌ'.weight = | |
| totalVariation (secondMarginal p) ΞΌ.weight := by | |
| change totalVariation (fun yx => secondMarginal p ((Equiv.prodComm Y X) yx)) | |
| (fun yx => ΞΌ.weight ((Equiv.prodComm Y X) yx)) = _ | |
| exact totalVariation_comp_equiv (Equiv.prodComm Y X) _ _ | |
| rw [hm] at h | |
| exact h | |
| end | |
| open scoped BigOperators | |
| open Games Information | |
| theorem finiteDistribution_nonempty {A : Type*} [Fintype A] (ΞΌ : FiniteDistribution A) : | |
| Nonempty A := by | |
| have hsum : (β a, ΞΌ.weight a) β 0 := by rw [ΞΌ.normalized]; norm_num | |
| obtain β¨a, _, _β© := Finset.exists_ne_zero_of_sum_ne_zero hsum | |
| exact β¨aβ© | |
| variable {Qβ Qβ Aβ Aβ : Type*} | |
| [Fintype Qβ] [Fintype Qβ] [Fintype Aβ] [Fintype Aβ] | |
| [DecidableEq Qβ] [DecidableEq Qβ] {n : Nat} | |
| def selectedProfileFallback (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 (SelectedCommonData (Qβ := Qβ) (Qβ := Qβ) | |
| (Aβ := Aβ) (Aβ := Aβ) selected j) := | |
| (selectedCommonLaw G strategy selected positive j).pushforward Prod.fst | |
| def selectedLeftProfile (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}) (x : Qβ) : | |
| FiniteDistribution (SelectedCommonData (Qβ := Qβ) (Qβ := Qβ) | |
| (Aβ := Aβ) (Aβ := Aβ) selected j) := | |
| toGameLaw | |
| (leftCommonProfile (selectedCommonLaw G strategy selected positive j).weight | |
| (selectedProfileFallback G strategy selected positive j).weight x) | |
| (leftCommonProfile_isProbability _ _ | |
| (gameLaw_isProbability (selectedCommonLaw G strategy selected positive j)) | |
| (gameLaw_isProbability (selectedProfileFallback G strategy selected positive j)) x) | |
| def selectedRightProfile (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}) (y : Qβ) : | |
| FiniteDistribution (SelectedCommonData (Qβ := Qβ) (Qβ := Qβ) | |
| (Aβ := Aβ) (Aβ := Aβ) selected j) := | |
| toGameLaw | |
| (rightCommonProfile (selectedCommonLaw G strategy selected positive j).weight | |
| (selectedProfileFallback G strategy selected positive j).weight y) | |
| (rightCommonProfile_isProbability _ _ | |
| (gameLaw_isProbability (selectedCommonLaw G strategy selected positive j)) | |
| (gameLaw_isProbability (selectedProfileFallback G strategy selected positive j)) y) | |
| def selectedLeftProfileError (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}) : β := | |
| totalVariation (selectedCommonLaw G strategy selected positive j).weight | |
| (fun z => G.questions.weight z.2 * (selectedLeftProfile G strategy selected positive j z.2.1).weight z.1) | |
| def selectedRightProfileError (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}) : β := | |
| totalVariation (selectedCommonLaw G strategy selected positive j).weight | |
| (fun z => G.questions.weight z.2 * (selectedRightProfile G strategy selected positive j z.2.2).weight z.1) | |
| theorem selectedLeftProfileError_le (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}) : | |
| selectedLeftProfileError G strategy selected positive j β€ | |
| totalVariation (partialRevealMarginal G.questions j (selectedOutsideLikelihood G strategy selected)) | |
| (leftRevealModel G.questions | |
| (partialRevealMarginal G.questions j (selectedOutsideLikelihood G strategy selected))) + | |
| totalVariation (secondMarginal (selectedCommonLaw G strategy selected positive j).weight) | |
| G.questions.weight := | |
| leftCommonProfile_error _ G.questions _ | |
| (gameLaw_isProbability (selectedCommonLaw G strategy selected positive j)) | |
| (gameLaw_isProbability (selectedProfileFallback G strategy selected positive j)) | |
| theorem selectedRightProfileError_le (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}) : | |
| selectedRightProfileError G strategy selected positive j β€ | |
| totalVariation (partialRevealMarginal G.questions j (selectedOutsideLikelihood G strategy selected)) | |
| (rightRevealModel G.questions | |
| (partialRevealMarginal G.questions j (selectedOutsideLikelihood G strategy selected))) + | |
| totalVariation (secondMarginal (selectedCommonLaw G strategy selected positive j).weight) | |
| G.questions.weight := | |
| rightCommonProfile_error _ G.questions _ | |
| (gameLaw_isProbability (selectedCommonLaw G strategy selected positive j)) | |
| (gameLaw_isProbability (selectedProfileFallback G strategy selected positive j)) | |
| def selectedSamplingTarget (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 ((Qβ Γ Qβ) Γ SelectedCommonData (Qβ := Qβ) (Qβ := Qβ) | |
| (Aβ := Aβ) (Aβ := Aβ) selected j) := | |
| (selectedCommonLaw G strategy selected positive j).transport (Equiv.prodComm _ _) | |
| theorem selectedSamplingTarget_left_error (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}) : | |
| totalVariation (selectedSamplingTarget G strategy selected positive j).weight | |
| (fun z => G.questions.weight z.1 * (selectedLeftProfile G strategy selected positive j z.1.1).weight z.2) = | |
| selectedLeftProfileError G strategy selected positive j := by | |
| exact totalVariation_comp_equiv | |
| (Equiv.prodComm (Qβ Γ Qβ) (SelectedCommonData (Qβ := Qβ) (Qβ := Qβ) | |
| (Aβ := Aβ) (Aβ := Aβ) selected j)) | |
| (selectedCommonLaw G strategy selected positive j).weight | |
| (fun z => G.questions.weight z.2 * (selectedLeftProfile G strategy selected positive j z.2.1).weight z.1) | |
| theorem selectedSamplingTarget_right_error (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}) : | |
| totalVariation (selectedSamplingTarget G strategy selected positive j).weight | |
| (fun z => G.questions.weight z.1 * (selectedRightProfile G strategy selected positive j z.1.2).weight z.2) = | |
| selectedRightProfileError G strategy selected positive j := by | |
| exact totalVariation_comp_equiv | |
| (Equiv.prodComm (Qβ Γ Qβ) (SelectedCommonData (Qβ := Qβ) (Qβ := Qβ) | |
| (Aβ := Aβ) (Aβ := Aβ) selected j)) | |
| (selectedCommonLaw G strategy selected positive j).weight | |
| (fun z => G.questions.weight z.2 * (selectedRightProfile G strategy selected positive j z.2.2).weight z.1) | |
| end BinPackingGames.Foundations.Repetition | |
| end | |
| end OAI | |