Download data/lean/OAI/Combinatorics/IndependentSets/Repetition/LocalSimulation.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 9.14 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Combinatorics/IndependentSets/Repetition/LocalSimulation.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Combinatorics/IndependentSets/Repetition/LocalSimulation.lean
-
curl -L -o LocalSimulation.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Combinatorics/IndependentSets/Repetition/LocalSimulation.lean
9.14 kB
| import Mathlib | |
| import OAI.Combinatorics.IndependentSets.Repetition.Scalar | |
| import OAI.Combinatorics.IndependentSets.Repetition.CoordinateCompletion | |
| namespace OAI | |
| noncomputable section | |
| namespace IndependentSetsGames.Foundations.Repetition | |
| section | |
| open scoped BigOperators | |
| open Games CorrelatedSampling | |
| variable {Qβ Qβ Aβ Aβ S : Type*} | |
| [Fintype Qβ] [Fintype Qβ] [Fintype Aβ] [Fintype Aβ] [Fintype S] | |
| [Nonempty Aβ] [Nonempty Aβ] [Nonempty S] | |
| [DecidableEq Qβ] [DecidableEq Qβ] [DecidableEq S] {n : Nat} | |
| theorem coordinate_probability_le_value_of_local_completion | |
| (G : Game Qβ Qβ Aβ Aβ) (j : Fin n) | |
| (strategy : Strategy (Fin n β Qβ) (Fin n β Qβ) (Fin n β Aβ) (Fin n β Aβ)) | |
| (Ο : FiniteDistribution ((Qβ Γ Qβ) Γ S)) | |
| (profileL : Qβ β FiniteDistribution S) (profileR : Qβ β FiniteDistribution S) | |
| (completionL : Qβ Γ S β FiniteDistribution (Fin n β Qβ)) | |
| (completionR : Qβ Γ S β FiniteDistribution (Fin n β Qβ)) | |
| (supportL : β q xs, (completionL q).weight xs β 0 β xs j = q.1) | |
| (supportR : β q ys, (completionR q).weight ys β 0 β ys j = q.1) | |
| (fallback : S) : | |
| (Ο.mixture (fun z => (completionL (z.1.1,z.2)).product | |
| (completionR (z.1.2,z.2)))).probability (G.coordinateWin strategy j) β€ | |
| G.value + | |
| (2 * Information.totalVariation Ο.weight | |
| (fun z => G.questions.weight z.1 * (profileL z.1.1).weight z.2) + | |
| 2 * Information.totalVariation Ο.weight | |
| (fun z => G.questions.weight z.1 * (profileR z.1.2).weight z.2)) := by | |
| let targetLaw := Ο.mixture (fun z => (completionL (z.1.1,z.2)).product (completionR (z.1.2,z.2))) | |
| let Ξ΄ := 2 * Information.totalVariation Ο.weight | |
| (fun z => G.questions.weight z.1 * (profileL z.1.1).weight z.2) + | |
| 2 * Information.totalVariation Ο.weight | |
| (fun z => G.questions.weight z.1 * (profileR z.1.2).weight z.2) | |
| change targetLaw.probability (G.coordinateWin strategy j) β€ G.value + Ξ΄ | |
| by_contra h | |
| have gap : 0 < targetLaw.probability (G.coordinateWin strategy j) - (G.value + Ξ΄) := | |
| sub_pos.mpr (lt_of_not_ge h) | |
| let Ξ· := (targetLaw.probability (G.coordinateWin strategy j) - (G.value + Ξ΄)) / 2 | |
| have hΞ· : 0 < Ξ· := by dsimp [Ξ·]; linarith | |
| obtain β¨N,hNβ© := samplerOutputLaw_arbitrarily_close Ο G.questions profileL profileR fallback Ξ· hΞ· | |
| let thresholds := sharedProfileThresholds profileL profileR | |
| let Ξ³ := traceSeedLaw (rectangleDistribution (Ξ± := S) thresholds) N | |
| let sL := samplerLocal thresholds profileL fallback N | |
| let sR := samplerLocal thresholds profileR fallback N | |
| have hvariation := CompletedSampling.coordinateOutputLaw_totalVariation_le | |
| G.questions Ξ³ j sL sR completionL completionR supportL supportR Ο | |
| have hclose : (CompletedSampling.coordinateOutputLaw G.questions Ξ³ j sL sR completionL completionR).totalVariation targetLaw β€ Ξ΄ + Ξ· := | |
| hvariation.trans hN | |
| have hsuccess := G.coordinate_probability_le_value_add_embedding_distance j targetLaw | |
| (CompletedSampling.seedLaw Ξ³ completionL completionR) | |
| (CompletedSampling.coordinateLeft j sL) (CompletedSampling.coordinateRight j sR) | |
| (CompletedSampling.coordinateLeft_preserves j sL) | |
| (CompletedSampling.coordinateRight_preserves j sR) strategy | |
| have hsym : targetLaw.totalVariation | |
| (G.localEmbeddingLaw (CompletedSampling.seedLaw Ξ³ completionL completionR) | |
| (CompletedSampling.coordinateLeft j sL) (CompletedSampling.coordinateRight j sR)) = | |
| (CompletedSampling.coordinateOutputLaw G.questions Ξ³ j sL sR completionL completionR).totalVariation targetLaw := by | |
| unfold FiniteDistribution.totalVariation | |
| congr 1 | |
| apply Finset.sum_congr rfl | |
| intro q _ | |
| exact abs_sub_comm _ _ | |
| rw [hsym] at hsuccess | |
| dsimp [Ξ·] at hclose | |
| linarith | |
| end | |
| open scoped BigOperators | |
| open Games | |
| variable {Qβ Qβ Aβ Aβ : Type*} | |
| [Fintype Qβ] [Fintype Qβ] [Fintype Aβ] [Fintype Aβ] | |
| [DecidableEq Qβ] [DecidableEq Qβ] {n : β} | |
| theorem selectedLabels_card (selected : Finset (Fin n)) : | |
| Fintype.card (SelectedLabels (Aβ := Aβ) (Aβ := Aβ) selected) = | |
| (Fintype.card Aβ * Fintype.card Aβ) ^ selected.card := by | |
| simp [SelectedLabels, Fintype.card_prod, mul_pow] | |
| theorem unusedCoordinates_card (selected : Finset (Fin n)) : | |
| Fintype.card {i : Fin n // i β selected} = n - selected.card := by | |
| classical | |
| simp | |
| theorem unusedCoordinates_card_real (selected : Finset (Fin n)) : | |
| (Fintype.card {i : Fin n // i β selected} : β) = (n : β) - selected.card := by | |
| have hs : selected.card β€ n := by simpa using Finset.card_le_univ selected | |
| rw [unusedCoordinates_card, Nat.cast_sub hs] | |
| theorem log_le_logTwo {x : β} (hx : 1 β€ x) : Real.log x β€ logTwo x := by | |
| have hlog : 0 β€ Real.log x := Real.log_nonneg hx | |
| have htwo : 0 < Real.log 2 := Real.log_pos (by norm_num) | |
| have htwo_le : Real.log 2 β€ 1 := by | |
| convert Real.log_le_sub_one_of_pos (by norm_num : (0 : β) < 2) using 1 | |
| norm_num | |
| unfold logTwo | |
| apply (le_div_iffβ htwo).2 | |
| simpa using mul_le_mul_of_nonneg_left htwo_le hlog | |
| theorem selectedLabels_log_le [Nonempty Aβ] [Nonempty Aβ] | |
| (selected : Finset (Fin n)) (ell : β) | |
| (hell : logTwo ((Fintype.card Aβ : β) * (Fintype.card Aβ : β)) β€ ell) : | |
| Real.log (Fintype.card (SelectedLabels (Aβ := Aβ) (Aβ := Aβ) selected) : β) β€ | |
| (selected.card : β) * ell := by | |
| have ha : (1 : β) β€ Fintype.card Aβ := by exact_mod_cast Fintype.card_pos (Ξ± := Aβ) | |
| have hb : (1 : β) β€ Fintype.card Aβ := by exact_mod_cast Fintype.card_pos (Ξ± := Aβ) | |
| have hab : (1 : β) β€ (Fintype.card Aβ : β) * (Fintype.card Aβ : β) := by nlinarith | |
| rw [selectedLabels_card, Nat.cast_pow, Nat.cast_mul, Real.log_pow] | |
| exact mul_le_mul_of_nonneg_left ((log_le_logTwo hab).trans hell) (Nat.cast_nonneg _) | |
| omit [DecidableEq Qβ] [DecidableEq Qβ] in | |
| theorem selectedInformationRadius_le [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) | |
| (ell : β) | |
| (hell : logTwo ((Fintype.card Aβ : β) * (Fintype.card Aβ : β)) β€ ell) : | |
| selectedInformationRadius G strategy selected β€ | |
| Real.sqrt (((n : β) - selected.card) * | |
| ((selected.card : β) * ell + logTwo (1 / G.selectedSuccess strategy selected))) := by | |
| have hprob : 1 β€ 1 / G.selectedSuccess strategy selected := by | |
| apply (le_div_iffβ positive).2 | |
| simpa using G.selectedSuccess_le_one strategy selected | |
| have hbudget := add_le_add (selectedLabels_log_le (Aβ := Aβ) (Aβ := Aβ) selected ell hell) | |
| (log_le_logTwo hprob) | |
| unfold selectedInformationRadius | |
| rw [β unusedCoordinates_card_real selected] | |
| apply Real.sqrt_le_sqrt | |
| exact mul_le_mul_of_nonneg_left hbudget (Nat.cast_nonneg _) | |
| theorem sqrt_budget_factor (a b : β) (ha : 0 < a) : | |
| Real.sqrt (a * b) = a * Real.sqrt (b / a) := by | |
| have he : a * b = a ^ 2 * (b / a) := by | |
| field_simp | |
| rw [he, Real.sqrt_mul (sq_nonneg a), Real.sqrt_sq (le_of_lt ha)] | |
| omit [DecidableEq Qβ] [DecidableEq Qβ] in | |
| theorem exists_coordinate_le_information_budget [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) | |
| (ell : β) | |
| (hell : logTwo ((Fintype.card Aβ : β) * (Fintype.card Aβ : β)) β€ ell) | |
| (hselected : selected.card < n) | |
| (error : {i : Fin n // i β selected} β β) | |
| (hsum : (β j, error j) β€ 15 * selectedInformationRadius G strategy selected) : | |
| β j : {i : Fin n // i β selected}, error j β€ 15 * Real.sqrt | |
| (((selected.card : β) * ell + logTwo (1 / G.selectedSuccess strategy selected)) / | |
| ((n : β) - selected.card)) := by | |
| classical | |
| have hcard : 0 < Fintype.card {i : Fin n // i β selected} := by | |
| rw [unusedCoordinates_card] | |
| exact Nat.sub_pos_of_lt hselected | |
| let : Nonempty {i : Fin n // i β selected} := Fintype.card_pos_iff.mp hcard | |
| have hden : 0 < (n : β) - selected.card := by | |
| rw [β unusedCoordinates_card_real selected] | |
| exact_mod_cast hcard | |
| have htotal := hsum.trans (mul_le_mul_of_nonneg_left | |
| (selectedInformationRadius_le G strategy selected positive ell hell) (by norm_num : (0 : β) β€ 15)) | |
| rw [sqrt_budget_factor _ _ hden] at htotal | |
| have havg : (β j, error j) β€ β _j : {i : Fin n // i β selected}, | |
| 15 * Real.sqrt | |
| (((selected.card : β) * ell + logTwo (1 / G.selectedSuccess strategy selected)) / | |
| ((n : β) - selected.card)) := by | |
| simpa only [Finset.sum_const, Finset.card_univ, nsmul_eq_mul, | |
| unusedCoordinates_card_real, mul_assoc, mul_left_comm] using htotal | |
| obtain β¨j, _, hjβ© := Finset.exists_le_of_sum_le Finset.univ_nonempty havg | |
| exact β¨j, hjβ© | |
| end IndependentSetsGames.Foundations.Repetition | |
| end | |
| end OAI | |