Download data/lean/OAI/Computability/VertexCover/Repetition/SelectedCompletion.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 13.5 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Computability/VertexCover/Repetition/SelectedCompletion.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Computability/VertexCover/Repetition/SelectedCompletion.lean
-
curl -L -o SelectedCompletion.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Computability/VertexCover/Repetition/SelectedCompletion.lean
13.5 kB
| import Mathlib | |
| import OAI.Computability.VertexCover.Repetition.Completion | |
| import OAI.Computability.VertexCover.Repetition.SelectedCommon | |
| import OAI.Computability.VertexCover.Repetition.SelectedLikelihood | |
| import OAI.Computability.VertexCover.Repetition.RevealFactorization | |
| 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 | |
| section LocalNormalization | |
| variable {I X Y : Type*} [Fintype I] [DecidableEq I] | |
| [Fintype X] [Fintype Y] | |
| def completionTupleEquiv : (I β X Γ Y) β ((I β X) Γ (I β Y)) where | |
| toFun u := (fun i => (u i).1, fun i => (u i).2) | |
| invFun z := fun i => (z.1 i, z.2 i) | |
| left_inv u := by funext i; rfl | |
| right_inv z := by cases z; rfl | |
| def updatedTableFallback (ΞΌ : FiniteDistribution X) (j : I) (x : X) : | |
| FiniteDistribution (I β X) := | |
| (FiniteDistribution.table (fun _ : I => ΞΌ)).pushforward | |
| (fun l => Function.update l j x) | |
| theorem updatedTableFallback_zero (ΞΌ : FiniteDistribution X) (j : I) (x : X) | |
| (l : I β X) (hne : l j β x) : | |
| (updatedTableFallback ΞΌ j x).weight l = 0 := by | |
| classical | |
| simp only [updatedTableFallback, FiniteDistribution.pushforward] | |
| apply Finset.sum_eq_zero | |
| intro t _ | |
| apply ite_eq_right | |
| intro h | |
| have he := congrFun h j | |
| exact hne (by simpa only [Function.update_self] using he.symm) | |
| theorem normalizeOr_weight_eq_zero_of_zero | |
| (w : X β β) (hw : β x, 0 β€ w x) (fallback : FiniteDistribution X) | |
| (x : X) (hraw : w x = 0) (hdefault : fallback.weight x = 0) : | |
| (normalizeOr w hw fallback).weight x = 0 := by | |
| classical | |
| unfold normalizeOr | |
| split | |
| Β· change normalizedWeight w x = 0 | |
| simp only [normalizedWeight, hraw, zero_div] | |
| Β· exact hdefault | |
| end LocalNormalization | |
| variable {Qβ Qβ Aβ Aβ : Type*} | |
| [Fintype Qβ] [Fintype Qβ] [Fintype Aβ] [Fintype Aβ] | |
| [DecidableEq Qβ] [DecidableEq Qβ] {n : Nat} | |
| def selectedLeftRaw (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) | |
| (x : Qβ) (l : {i : Fin n // i β selected} β Qβ) : β := | |
| (if l j = x then 1 else 0) * partialLeftFactor G.questions j s.2 l * | |
| selectedLocalTest strategy.1 selected (fun i => (s.1.1 i).1) s.1.2.1 l | |
| def selectedRightRaw (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) | |
| (y : Qβ) (r : {i : Fin n // i β selected} β Qβ) : β := | |
| (if r j = y then 1 else 0) * partialRightFactor G.questions j s.2 r * | |
| selectedLocalTest strategy.2 selected (fun i => (s.1.1 i).2) s.1.2.2 r | |
| omit [DecidableEq Qβ] in | |
| theorem selectedLeftRaw_nonnegative (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) | |
| (x : Qβ) (l : {i : Fin n // i β selected} β Qβ) : | |
| 0 β€ selectedLeftRaw G strategy selected j s x l := by | |
| apply mul_nonneg | |
| Β· apply mul_nonneg | |
| Β· split <;> norm_num | |
| Β· exact Finset.prod_nonneg (fun i _ => revealLeftFactor_nonnegative G.questions (s.2 i) (l i.1)) | |
| Β· exact selectedLocalTest_nonnegative _ _ _ _ _ | |
| omit [DecidableEq Qβ] in | |
| theorem selectedRightRaw_nonnegative (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) | |
| (y : Qβ) (r : {i : Fin n // i β selected} β Qβ) : | |
| 0 β€ selectedRightRaw G strategy selected j s y r := by | |
| apply mul_nonneg | |
| Β· apply mul_nonneg | |
| Β· split <;> norm_num | |
| Β· exact Finset.prod_nonneg (fun i _ => revealRightFactor_nonnegative G.questions (s.2 i) (r i.1)) | |
| Β· exact selectedLocalTest_nonnegative _ _ _ _ _ | |
| def selectedLeftCompletion (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) | |
| (x : Qβ) : FiniteDistribution ({i : Fin n // i β selected} β Qβ) := | |
| normalizeOr (selectedLeftRaw G strategy selected j s x) | |
| (selectedLeftRaw_nonnegative G strategy selected j s x) | |
| (updatedTableFallback (G.questions.pushforward Prod.fst) j x) | |
| def selectedRightCompletion (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) | |
| (y : Qβ) : FiniteDistribution ({i : Fin n // i β selected} β Qβ) := | |
| normalizeOr (selectedRightRaw G strategy selected j s y) | |
| (selectedRightRaw_nonnegative G strategy selected j s y) | |
| (updatedTableFallback (G.questions.pushforward Prod.snd) j y) | |
| omit [DecidableEq Qβ] in | |
| theorem selectedLeftCompletion_zero (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) | |
| (x : Qβ) (l : {i : Fin n // i β selected} β Qβ) (hne : l j β x) : | |
| (selectedLeftCompletion G strategy selected j s x).weight l = 0 := by | |
| apply normalizeOr_weight_eq_zero_of_zero | |
| Β· simp only [selectedLeftRaw, ite_eq_right hne, zero_mul] | |
| Β· exact updatedTableFallback_zero _ j x l hne | |
| omit [DecidableEq Qβ] in | |
| theorem selectedRightCompletion_zero (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) | |
| (y : Qβ) (r : {i : Fin n // i β selected} β Qβ) (hne : r j β y) : | |
| (selectedRightCompletion G strategy selected j s y).weight r = 0 := by | |
| apply normalizeOr_weight_eq_zero_of_zero | |
| Β· simp only [selectedRightRaw, ite_eq_right hne, zero_mul] | |
| Β· exact updatedTableFallback_zero _ j y r hne | |
| omit [DecidableEq Qβ] in | |
| theorem selectedLeftCompletion_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}) | |
| (s : SelectedCommonData (Qβ := Qβ) (Qβ := Qβ) (Aβ := Aβ) (Aβ := Aβ) selected j) | |
| (x : Qβ) (l : {i : Fin n // i β selected} β Qβ) | |
| (h : (selectedLeftCompletion G strategy selected j s x).weight l β 0) : l j = x := by | |
| by_contra hne | |
| exact h (selectedLeftCompletion_zero G strategy selected j s x l hne) | |
| omit [DecidableEq Qβ] in | |
| theorem selectedRightCompletion_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}) | |
| (s : SelectedCommonData (Qβ := Qβ) (Qβ := Qβ) (Aβ := Aβ) (Aβ := Aβ) selected j) | |
| (y : Qβ) (r : {i : Fin n // i β selected} β Qβ) | |
| (h : (selectedRightCompletion G strategy selected j s y).weight r β 0) : r j = y := by | |
| by_contra hne | |
| exact h (selectedRightCompletion_zero G strategy selected j s y r hne) | |
| def selectedCompletionScale (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β) : β := | |
| G.questions.weight xy * (β i : selected, G.questions.weight (s.1.1 i)) * | |
| (if selectedLabelAccepts G selected s.1.1 s.1.2 then 1 else 0) / | |
| G.selectedSuccess strategy selected | |
| theorem selected_completion_factorization (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β) | |
| (l : {i : Fin n // i β selected} β Qβ) | |
| (r : {i : Fin n // i β selected} β Qβ) : | |
| selectedCompletionScale G strategy selected j s xy * | |
| selectedLeftRaw G strategy selected j s xy.1 l * | |
| selectedRightRaw G strategy selected j s xy.2 r = | |
| if (l j, r j) = xy then | |
| partialRevealWeight G.questions j s.2 (fun i => (l i,r i)) * | |
| selectedOutsideLikelihood G strategy selected s.1 (fun i => (l i,r i)) | |
| else 0 := by | |
| rcases xy with β¨x,yβ© | |
| by_cases hl : l j = x <;> by_cases hr : r j = y | |
| Β· rw [ite_eq_left (Prod.ext hl hr), partialRevealWeight_factorization] | |
| cases hacc : selectedLabelAccepts G selected s.1.1 s.1.2 <;> | |
| simp [selectedOutsideLikelihood, selectedLikelihood_factorization, | |
| selectedCompletionScale, selectedLeftRaw, selectedRightRaw, hl, hr, hacc] ; ring | |
| Β· simp [selectedLeftRaw, selectedRightRaw, hl, hr, Prod.mk.injEq] | |
| Β· simp [selectedLeftRaw, selectedRightRaw, hl, hr, Prod.mk.injEq] | |
| Β· simp [selectedLeftRaw, selectedRightRaw, hl, hr, Prod.mk.injEq] | |
| theorem selectedCommonLaw_completion_row_mass (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) | |
| (xy : Qβ Γ Qβ) : | |
| (selectedCommonLaw G strategy selected positive j).weight (s,xy) = | |
| β lr : ({i : Fin n // i β selected} β Qβ) Γ | |
| ({i : Fin n // i β selected} β Qβ), | |
| selectedCompletionScale G strategy selected j s xy * | |
| selectedLeftRaw G strategy selected j s xy.1 lr.1 * | |
| selectedRightRaw G strategy selected j s xy.2 lr.2 := by | |
| classical | |
| change (β u, if u j = xy then partialRevealWeight G.questions j s.2 u * | |
| selectedOutsideLikelihood G strategy selected s.1 u else 0) = _ | |
| rw [β (completionTupleEquiv (I := {i : Fin n // i β selected}) | |
| (X := Qβ) (Y := Qβ)).sum_comp] | |
| apply Finset.sum_congr rfl | |
| intro u _ | |
| exact (selected_completion_factorization G strategy selected j s xy | |
| (fun i => (u i).1) (fun i => (u i).2)).symm | |
| theorem selected_completion_row_recombine (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) | |
| (xy : Qβ Γ Qβ) | |
| (l : {i : Fin n // i β selected} β Qβ) | |
| (r : {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 (l,r) = | |
| if (l j,r j) = xy then | |
| partialRevealWeight G.questions j s.2 (fun i => (l i,r i)) * | |
| selectedOutsideLikelihood G strategy selected s.1 (fun i => (l i,r i)) | |
| else 0 := by | |
| rw [selectedCommonLaw_completion_row_mass] | |
| calc | |
| _ = selectedCompletionScale G strategy selected j s xy * | |
| selectedLeftRaw G strategy selected j s xy.1 l * | |
| selectedRightRaw G strategy selected j s xy.2 r := | |
| factorized_completion_row | |
| (selectedLeftRaw G strategy selected j s xy.1) | |
| (selectedRightRaw G strategy selected j s xy.2) | |
| (selectedLeftRaw_nonnegative G strategy selected j s xy.1) | |
| (selectedRightRaw_nonnegative G strategy selected j s xy.2) | |
| (updatedTableFallback (G.questions.pushforward Prod.fst) j xy.1) | |
| (updatedTableFallback (G.questions.pushforward Prod.snd) j xy.2) | |
| (selectedCompletionScale G strategy selected j s xy) (l,r) | |
| _ = _ := selected_completion_factorization G strategy selected j s xy l r | |
| 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 | |