math / data /lean /OAI /LinearAlgebra /MatrixFields /Parameters /JointOrdinaryPopulationSelection.lean
Download data/lean/OAI/LinearAlgebra/MatrixFields/Parameters/JointOrdinaryPopulationSelection.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 14.8 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/LinearAlgebra/MatrixFields/Parameters/JointOrdinaryPopulationSelection.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/LinearAlgebra/MatrixFields/Parameters/JointOrdinaryPopulationSelection.lean
-
curl -L -o JointOrdinaryPopulationSelection.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/LinearAlgebra/MatrixFields/Parameters/JointOrdinaryPopulationSelection.lean
14.8 kB
| import Mathlib | |
| import OAI.LinearAlgebra.MatrixFields.Entropy.GroupBranchLaws | |
| import OAI.LinearAlgebra.MatrixFields.Entropy.JointAmbientEntropy | |
| namespace OAI | |
| namespace MatrixAllFields | |
| open scoped BigOperators Topology Polynomial | |
| section | |
| namespace MatrixMultiplication.JointCapacityAlgebra | |
| open scoped BigOperators | |
| theorem total_sub_max_degrees (A X Y Z : β) : | |
| A - max (A - X) (max (A - Y) (A - Z)) = min X (min Y Z) := by | |
| simp only [max_def, min_def] | |
| split_ifs <;> linarith | |
| theorem weighted_joint_capacity {H : Type*} [Fintype H] | |
| (mass entropy : H β β) (capacity : H β Fin 3 β β) : | |
| (β h, mass h * entropy h) - | |
| max (β h, mass h * (entropy h - capacity h 0)) | |
| (max (β h, mass h * (entropy h - capacity h 1)) | |
| (β h, mass h * (entropy h - capacity h 2))) = | |
| min (β h, mass h * capacity h 0) | |
| (min (β h, mass h * capacity h 1) (β h, mass h * capacity h 2)) := by | |
| simp_rw [mul_sub, Finset.sum_sub_distrib] | |
| exact total_sub_max_degrees _ _ _ _ | |
| end MatrixMultiplication.JointCapacityAlgebra | |
| noncomputable section | |
| namespace MatrixMultiplication.JointOrdinaryPopulationSelection | |
| open MatrixMultiplication.Foundation JointPopulation JointPopulationRates Filter | |
| open scoped BigOperators Topology | |
| attribute [local instance] Classical.propDecidable | |
| variable {Hist : Type*} [Fintype Hist] [DecidableEq Hist] | |
| def entropyRate (mass : Hist β β) (p : Hist β FiniteLaw Shape) : β := | |
| β h, mass h * finiteEntropy (p h).mass | |
| def sideDegreeRate (mass : Hist β β) (p : Hist β FiniteLaw Shape) (s : Fin 3) : β := | |
| β h, mass h * (finiteEntropy (p h).mass - finiteEntropy (sideMass (p h).mass s)) | |
| def degreeRate (mass : Hist β β) (p : Hist β FiniteLaw Shape) : β := | |
| max (sideDegreeRate mass p 0) (max (sideDegreeRate mass p 1) (sideDegreeRate mass p 2)) | |
| def sideCapacity (mass : Hist β β) (p : Hist β FiniteLaw Shape) (s : Fin 3) : β := | |
| β h, mass h * finiteEntropy (sideMass (p h).mass s) | |
| omit [DecidableEq Hist] in | |
| theorem entropyRate_sub_degreeRate_eq (mass : Hist β β) (p : Hist β FiniteLaw Shape) : | |
| entropyRate mass p - degreeRate mass p = | |
| min (sideCapacity mass p 0) (min (sideCapacity mass p 1) (sideCapacity mass p 2)) := by | |
| exact JointCapacityAlgebra.weighted_joint_capacity mass | |
| (fun h => finiteEntropy (p h).mass) (fun h s => finiteEntropy (sideMass (p h).mass s)) | |
| theorem sideMass_entropy_le (p : FiniteLaw Shape) (s : Fin 3) : | |
| finiteEntropy (sideMass p.mass s) β€ finiteEntropy p.mass := by | |
| simpa only [finiteEntropy, FiniteLaw.map_mass, sideMass] using | |
| p.map_entropy_le (shapeSide s) | |
| omit [DecidableEq Hist] in | |
| theorem sideDegreeRate_nonneg (mass : Hist β β) (p : Hist β FiniteLaw Shape) | |
| (hmass : β h, 0 β€ mass h) (s : Fin 3) : 0 β€ sideDegreeRate mass p s := by | |
| exact Finset.sum_nonneg fun h _ => | |
| mul_nonneg (hmass h) (sub_nonneg.mpr (sideMass_entropy_le (p h) s)) | |
| omit [DecidableEq Hist] in | |
| theorem degreeRate_nonneg (mass : Hist β β) (p : Hist β FiniteLaw Shape) | |
| (hmass : β h, 0 β€ mass h) : 0 β€ degreeRate mass p := | |
| (sideDegreeRate_nonneg mass p hmass 0).trans (le_max_left _ _) | |
| omit [DecidableEq Hist] in | |
| theorem sideDegreeRate_le (mass : Hist β β) (p : Hist β FiniteLaw Shape) (s : Fin 3) : | |
| sideDegreeRate mass p s β€ degreeRate mass p := by | |
| unfold degreeRate | |
| fin_cases s | |
| Β· exact le_max_left _ _ | |
| Β· exact (le_max_left _ _).trans (le_max_right _ _) | |
| Β· exact (le_max_right _ _).trans (le_max_right _ _) | |
| def uniformDegree (counts : Hist β Shape β β) (sum : Hist β β) : β := | |
| Finset.univ.sup (fun e : Target counts => | |
| (JointAmbientDegree.neighbors counts sum (triple counts e)).card) | |
| theorem ordinary_neighbors_eq (counts : Hist β Shape β β) (sum : Hist β β) | |
| (e : JointCoarseHashing.Triple (Position counts)) : | |
| JointOrdinarySelection.neighbors (ambientSet counts sum) e = | |
| JointAmbientDegree.neighbors counts sum e := by | |
| ext neighbor | |
| rw [JointOrdinarySelection.mem_neighbors, JointAmbientDegree.neighbors, | |
| Finset.mem_filter] | |
| simp only [JointCoarseHashing.SharesSide, eq_comm] | |
| theorem neighbors_card_le_uniformDegree (counts : Hist β Shape β β) | |
| (sum : Hist β β) (e : Target counts) : | |
| (JointOrdinarySelection.neighbors (ambientSet counts sum) (triple counts e)).card β€ | |
| uniformDegree counts sum := by | |
| rw [ordinary_neighbors_eq] | |
| exact Finset.le_sup | |
| (f := fun e : Target counts => | |
| (JointAmbientDegree.neighbors counts sum (triple counts e)).card) | |
| (Finset.mem_univ e) | |
| theorem uniformDegree_attained (counts : Hist β Shape β β) (sum : Hist β β) : | |
| β e : Target counts, | |
| (JointAmbientDegree.neighbors counts sum (triple counts e)).card = | |
| uniformDegree counts sum := by | |
| let : Nonempty (Target counts) := target_nonempty counts | |
| obtain β¨e, _, heβ© := Finset.sup_mem_of_nonempty | |
| (s := Finset.univ) | |
| (f := fun e : Target counts => | |
| (JointAmbientDegree.neighbors counts sum (triple counts e)).card) | |
| Finset.univ_nonempty | |
| exact β¨e, heβ© | |
| theorem uniformDegree_log_upper_of_all_targets | |
| (counts : β β Hist β Shape β β) (sum : Hist β β) (B : β) | |
| (hbound : βαΆ N in atTop, β e : Target (counts N), | |
| Real.log ((JointAmbientDegree.neighbors (counts N) sum (triple (counts N) e)).card : β) / | |
| (N : β) β€ B) : | |
| βαΆ N in atTop, Real.log (uniformDegree (counts N) sum : β) / (N : β) β€ B := by | |
| filter_upwards [hbound] with N hN | |
| obtain β¨e, heβ© := uniformDegree_attained (counts N) sum | |
| rw [β he] | |
| exact hN e | |
| omit [DecidableEq Hist] in | |
| theorem tendsto_sum_gibbsExponent | |
| (counts : β β Hist β Shape β β) (mass : Hist β β) | |
| (p : Hist β FiniteLaw Shape) (u v w : Hist β Fin 17 β β) | |
| (hcounts : β h a, Tendsto (fun N : β => (counts N h a : β) / (N : β)) | |
| atTop (π (mass h * (p h).mass a))) (s : Fin 3) : | |
| Tendsto (fun N => (β h, JointAmbientDegree.classExponent (counts N) s | |
| (triple (counts N) (canonicalTarget (counts N))) h | |
| (JointAmbientEntropy.gibbsCap (counts N) h (p h) (u h) (v h) (w h))) / (N : β)) | |
| atTop (π (sideDegreeRate mass p s)) := by | |
| have hsize (h : Hist) := tendsto_total_div_of_coordinate_rates | |
| (fun N => counts N h) (mass h) (p h).mass (p h).total (hcounts h) | |
| have hcap (h : Hist) := JointAmbientEntropy.tendsto_classScale_mul_gibbsCap | |
| counts h (p h) (mass h) (u h) (v h) (w h) (hcounts h) | |
| have hside (h : Hist) := tendsto_weighted_target_side_entropy counts | |
| (fun N => canonicalTarget (counts N)) mass (fun h => (p h).mass) | |
| (fun h => (p h).total) hcounts h s | |
| have h := JointAmbientRateLimit.tendsto_sum_classExponent_div_nat counts s | |
| (fun N h => JointAmbientEntropy.gibbsCap (counts N) h (p h) (u h) (v h) (w h)) | |
| mass (fun h => mass h * finiteEntropy (p h).mass) | |
| (fun h => mass h * finiteEntropy (sideMass (p h).mass s)) hsize | |
| (fun h => by | |
| simpa only [JointAmbientEntropy.classScale, Positions, Fintype.card_fin] using hcap h) | |
| (fun h => by | |
| simpa only [Positions, Fintype.card_fin] using hside h) | |
| simpa only [sideDegreeRate, mul_sub] using h | |
| theorem uniformDegree_log_upper_of_word_support | |
| (counts : β β Hist β Shape β β) (sum : Hist β β) (mass : Hist β β) | |
| (p : Hist β FiniteLaw Shape) (u v w : Hist β Fin 17 β β) (c : Hist β β) | |
| (hmass : β h, 0 β€ mass h) | |
| (hsupport : βαΆ N in atTop, β h word, | |
| JointAmbientDegree.localAllowed (counts N) sum h word β | |
| β i, 0 < (p h).mass (word i)) | |
| (hlog : β h a, 0 < (p h).mass a β Real.log ((p h).mass a) = | |
| u h (shapeSide 0 a) + v h (shapeSide 1 a) + w h (shapeSide 2 a) - c h) | |
| (hcounts : β h a, Tendsto (fun N : β => (counts N h a : β) / (N : β)) | |
| atTop (π (mass h * (p h).mass a))) | |
| (Ξ· : β) (hΞ· : 0 < Ξ·) : | |
| βαΆ N in atTop, Real.log (uniformDegree (counts N) sum : β) / (N : β) β€ | |
| degreeRate mass p + Ξ· := by | |
| apply uniformDegree_log_upper_of_all_targets counts sum | |
| apply JointAmbientRateLimit.eventually_all_target_degree_upper counts sum | |
| (fun N h => JointAmbientEntropy.gibbsCap (counts N) h (p h) (u h) (v h) (w h)) | |
| (sideDegreeRate mass p) (degreeRate mass p) (degreeRate_nonneg mass p hmass) | |
| _ (tendsto_sum_gibbsExponent counts mass p u v w hcounts) | |
| (sideDegreeRate_le mass p) Ξ· hΞ· | |
| filter_upwards [hsupport] with N hN | |
| intro h word hw | |
| exact JointAmbientEntropy.localAllowed_entropy_le_of_word_support | |
| (counts N) sum h word (p h) (u h) (v h) (w h) (c h) | |
| (hN h word hw) (hlog h) hw | |
| theorem uniformDegree_log_upper | |
| (counts : β β Hist β Shape β β) (sum : Hist β β) (mass : Hist β β) | |
| (p : Hist β FiniteLaw Shape) (u v w : Hist β Fin 17 β β) (c : Hist β β) | |
| (hmass : β h, 0 β€ mass h) | |
| (hsupport : β h (a : Shape), | |
| a.1.val + a.2.1.val + a.2.2.val = sum h β 0 < (p h).mass a) | |
| (hlog : β h a, 0 < (p h).mass a β Real.log ((p h).mass a) = | |
| u h (shapeSide 0 a) + v h (shapeSide 1 a) + w h (shapeSide 2 a) - c h) | |
| (hcounts : β h a, Tendsto (fun N : β => (counts N h a : β) / (N : β)) | |
| atTop (π (mass h * (p h).mass a))) | |
| (Ξ· : β) (hΞ· : 0 < Ξ·) : | |
| βαΆ N in atTop, Real.log (uniformDegree (counts N) sum : β) / (N : β) β€ | |
| degreeRate mass p + Ξ· := | |
| uniformDegree_log_upper_of_word_support counts sum mass p u v w c hmass | |
| (Eventually.of_forall fun _ h word hw i => hsupport h (word i) (hw.1 i)) | |
| hlog hcounts Ξ· hΞ· | |
| def selectionHashRate (mass : Hist β β) (p : Hist β FiniteLaw Shape) (Ξ΅ : β) : β := | |
| degreeRate mass p + Ξ΅ / 2 | |
| theorem eventually_exists_selection_of_word_support | |
| (counts : β β Hist β Shape β β) (sum : Hist β β) (mass : Hist β β) | |
| (p : Hist β FiniteLaw Shape) (u v w : Hist β Fin 17 β β) (c : Hist β β) | |
| (hmass : β h, 0 β€ mass h) | |
| (hcountSupport : β N h a, 0 < counts N h a β | |
| a.1.val + a.2.1.val + a.2.2.val = sum h) | |
| (hsupport : βαΆ N in atTop, β h word, | |
| JointAmbientDegree.localAllowed (counts N) sum h word β | |
| β i, 0 < (p h).mass (word i)) | |
| (hlog : β h a, 0 < (p h).mass a β Real.log ((p h).mass a) = | |
| u h (shapeSide 0 a) + v h (shapeSide 1 a) + w h (shapeSide 2 a) - c h) | |
| (hcounts : β h a, Tendsto (fun N : β => (counts N h a : β) / (N : β)) | |
| atTop (π (mass h * (p h).mass a))) | |
| {Ξ΅ : β} (hΞ΅ : 0 < Ξ΅) : | |
| βαΆ N in atTop, | |
| β (s : JointCoarseHashing.Sample (Position (counts N)) | |
| (JointOrdinarySelection.hashLevel (selectionHashRate mass p Ξ΅) N)) | |
| (G : Finset (Target (counts N))), | |
| G.card = βReal.exp ((N : β) * (entropyRate mass p - degreeRate mass p - Ξ΅))ββ β§ | |
| (β e β G, JointOrdinarySelection.Good | |
| (JointOrdinarySelection.hashLevel (selectionHashRate mass p Ξ΅) N) | |
| (JointOrdinarySelection.hashSet (selectionHashRate mass p Ξ΅) N) | |
| (ambientSet (counts N) sum) (triple (counts N) e) s) β§ | |
| (G : Set (Target (counts N))).Pairwise (fun e f => | |
| Β¬ JointCoarseHashing.SharesSide (triple (counts N) e) (triple (counts N) f)) := by | |
| have hD : 0 β€ degreeRate mass p := degreeRate_nonneg mass p hmass | |
| have hH : 0 β€ selectionHashRate mass p Ξ΅ := by unfold selectionHashRate; linarith | |
| have hgap : degreeRate mass p < selectionHashRate mass p Ξ΅ := by | |
| unfold selectionHashRate | |
| linarith | |
| have htarget (N : β) (e : Target (counts N)) : | |
| triple (counts N) e β ambientSet (counts N) sum := by | |
| apply targetSet_subset_ambient (counts N) sum (hcountSupport N) | |
| exact Finset.mem_image.mpr β¨e, Finset.mem_univ _, rflβ© | |
| have hpos : βαΆ N in atTop, 0 < Fintype.card (Target (counts N)) := | |
| Eventually.of_forall fun N => Fintype.card_pos_iff.mpr (target_nonempty (counts N)) | |
| have htargetRate : Tendsto (fun N : β => | |
| Real.log (Fintype.card (Target (counts N)) : β) / (N : β)) | |
| atTop (π (entropyRate mass p)) := | |
| tendsto_log_target_card_div_of_coordinate_rates counts mass | |
| (fun h => (p h).mass) hmass (fun h => (p h).total) hcounts | |
| have hselection := JointOrdinarySelection.eventually_exists_selection | |
| (fun N => ambientSet (counts N) sum) | |
| (fun N (position : Position (counts N)) => sum position.1) | |
| (fun N => triple (counts N)) (fun N => triple_injective (counts N)) | |
| (fun N f hf => (Finset.mem_filter.mp hf).2.1) htarget | |
| (fun N => uniformDegree (counts N) sum) | |
| (fun N e => neighbors_card_le_uniformDegree (counts N) sum e) | |
| hH hgap (uniformDegree_log_upper_of_word_support counts sum mass p u v w c | |
| hmass hsupport hlog hcounts) | |
| hpos htargetRate (show 0 < Ξ΅ / 2 by linarith) | |
| have heq : entropyRate mass p - selectionHashRate mass p Ξ΅ - Ξ΅ / 2 = | |
| entropyRate mass p - degreeRate mass p - Ξ΅ := by unfold selectionHashRate; ring | |
| simpa only [heq] using hselection | |
| theorem eventually_exists_selection | |
| (counts : β β Hist β Shape β β) (sum : Hist β β) (mass : Hist β β) | |
| (p : Hist β FiniteLaw Shape) (u v w : Hist β Fin 17 β β) (c : Hist β β) | |
| (hmass : β h, 0 β€ mass h) | |
| (hcountSupport : β N h a, 0 < counts N h a β | |
| a.1.val + a.2.1.val + a.2.2.val = sum h) | |
| (hsupport : β h (a : Shape), | |
| a.1.val + a.2.1.val + a.2.2.val = sum h β 0 < (p h).mass a) | |
| (hlog : β h a, 0 < (p h).mass a β Real.log ((p h).mass a) = | |
| u h (shapeSide 0 a) + v h (shapeSide 1 a) + w h (shapeSide 2 a) - c h) | |
| (hcounts : β h a, Tendsto (fun N : β => (counts N h a : β) / (N : β)) | |
| atTop (π (mass h * (p h).mass a))) | |
| {Ξ΅ : β} (hΞ΅ : 0 < Ξ΅) : | |
| βαΆ N in atTop, | |
| β (s : JointCoarseHashing.Sample (Position (counts N)) | |
| (JointOrdinarySelection.hashLevel (selectionHashRate mass p Ξ΅) N)) | |
| (G : Finset (Target (counts N))), | |
| G.card = βReal.exp ((N : β) * (entropyRate mass p - degreeRate mass p - Ξ΅))ββ β§ | |
| (β e β G, JointOrdinarySelection.Good | |
| (JointOrdinarySelection.hashLevel (selectionHashRate mass p Ξ΅) N) | |
| (JointOrdinarySelection.hashSet (selectionHashRate mass p Ξ΅) N) | |
| (ambientSet (counts N) sum) (triple (counts N) e) s) β§ | |
| (G : Set (Target (counts N))).Pairwise (fun e f => | |
| Β¬ JointCoarseHashing.SharesSide (triple (counts N) e) (triple (counts N) f)) := | |
| eventually_exists_selection_of_word_support counts sum mass p u v w c | |
| hmass hcountSupport | |
| (Eventually.of_forall fun _ h word hw i => hsupport h (word i) (hw.1 i)) | |
| hlog hcounts hΞ΅ | |
| end MatrixMultiplication.JointOrdinaryPopulationSelection | |
| end | |
| end | |
| end MatrixAllFields | |
| end OAI | |