Download data/lean/OAI/LinearAlgebra/MatrixMultiplication/JointExtraction/MaskedRates.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 7.63 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/LinearAlgebra/MatrixMultiplication/JointExtraction/MaskedRates.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/LinearAlgebra/MatrixMultiplication/JointExtraction/MaskedRates.lean
-
curl -L -o MaskedRates.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/LinearAlgebra/MatrixMultiplication/JointExtraction/MaskedRates.lean
7.63 kB
| import OAI.LinearAlgebra.MatrixMultiplication.JointExtraction.MaskedAssignment | |
| import OAI.LinearAlgebra.MatrixMultiplication.JointExtraction.OrdinarySelection | |
| namespace OAI | |
| /-! Joint tensor extraction, compatibility and entropy estimates. -/ | |
| noncomputable section | |
| namespace MatrixMultiplication.JointMaskedRates | |
| open Filter JointCoarseHashing JointExtractionRates JointMaskedSelection | |
| open JointOrdinarySelection (hashLevel hashSet) | |
| open scoped Topology | |
| attribute [local instance] Classical.propDecidable | |
| def errorBound (degree : β β β) (B p : β) (H : β) (N : β) : β := | |
| (degree N : β) / (hashModulus H N : β) * | |
| (1 + (B : β) * ((N : β) + 1) ^ p * (N : β)) | |
| theorem polynomialFactor_le (B p N : β) : | |
| 1 + (B : β) * ((N : β) + 1) ^ p * (N : β) β€ | |
| ((B : β) + 1) * ((N : β) + 1) ^ (p + 1) := by | |
| have hN : (0 : β) β€ N := Nat.cast_nonneg _ | |
| have hx : (0 : β) β€ (N : β) + 1 := by linarith | |
| have hpower : (1 : β) β€ ((N : β) + 1) ^ (p + 1) := | |
| one_le_powβ (by linarith : (1 : β) β€ (N : β) + 1) | |
| calc | |
| _ β€ 1 + (B : β) * ((N : β) + 1) ^ p * ((N : β) + 1) := | |
| add_le_add le_rfl (mul_le_mul_of_nonneg_left (by linarith) | |
| (mul_nonneg (Nat.cast_nonneg _) (pow_nonneg hx _))) | |
| _ = 1 + (B : β) * ((N : β) + 1) ^ (p + 1) := by rw [pow_succ]; ring | |
| _ β€ ((N : β) + 1) ^ (p + 1) + (B : β) * ((N : β) + 1) ^ (p + 1) := | |
| add_le_add hpower le_rfl | |
| _ = _ := by ring | |
| theorem eventually_errorBound_le_half (degree : β β β) (B p : β) | |
| {D H : β} (hH : 0 β€ H) (hgap : D < H) | |
| (hdegreeRate : β Ξ· : β, 0 < Ξ· β | |
| βαΆ N in atTop, Real.log (degree N : β) / (N : β) β€ D + Ξ·) : | |
| βαΆ N in atTop, errorBound degree B p H N β€ 1 / 2 := by | |
| let c : β := (H - D) / 2 | |
| have hc : 0 < c := by dsimp [c]; linarith | |
| have hclt : c < H - D := by dsimp [c]; linarith | |
| have hratio := eventually_degree_div_hashModulus_le_exp hH hdegreeRate hclt | |
| apply eventually_error_le_half ((B : β) + 1) (p + 1) hc | |
| filter_upwards [hratio] with N hN | |
| have hx : (0 : β) β€ (N : β) + 1 := add_nonneg (Nat.cast_nonneg N) zero_le_one | |
| have hfactor : 0 β€ 1 + (B : β) * ((N : β) + 1) ^ p * (N : β) := | |
| add_nonneg zero_le_one | |
| (mul_nonneg (mul_nonneg (Nat.cast_nonneg _) (pow_nonneg hx _)) (Nat.cast_nonneg _)) | |
| calc | |
| errorBound degree B p H N β€ Real.exp (-c * (N : β)) * | |
| (1 + (B : β) * ((N : β) + 1) ^ p * (N : β)) := | |
| mul_le_mul_of_nonneg_right hN hfactor | |
| _ β€ Real.exp (-c * (N : β)) * (((B : β) + 1) * ((N : β) + 1) ^ (p + 1)) := | |
| mul_le_mul_of_nonneg_left (polynomialFactor_le B p N) (Real.exp_pos _).le | |
| _ = ((B : β) + 1) * (((N : β) + 1) ^ (p + 1) * Real.exp (-c * (N : β))) := by ring | |
| theorem count_error_le_envelope {P E O V : Type*} (d : OrbitData P E O V) | |
| (e : E) (degree B p N M : β) | |
| (heligibility : (d.eligibilityCompetitors e).card β€ degree) | |
| (horbits : (d.orbits e).card β€ B * (N + 1) ^ p) : | |
| ((d.eligibilityCompetitors e).card : β) / (M : β) + | |
| ((d.orbits e).card : β) * (N : β) * ((degree : β) / (M : β)) β€ | |
| (degree : β) / (M : β) * (1 + (B : β) * ((N : β) + 1) ^ p * (N : β)) := by | |
| have hdegreeR : ((d.eligibilityCompetitors e).card : β) β€ (degree : β) := by | |
| exact_mod_cast heligibility | |
| have horbitsR : ((d.orbits e).card : β) β€ (B : β) * ((N : β) + 1) ^ p := by | |
| exact_mod_cast horbits | |
| have hratio : (0 : β) β€ (degree : β) / (M : β) := | |
| div_nonneg (Nat.cast_nonneg _) (Nat.cast_nonneg _) | |
| calc | |
| _ β€ (degree : β) / (M : β) + | |
| ((B : β) * ((N : β) + 1) ^ p) * (N : β) * ((degree : β) / (M : β)) := | |
| add_le_add (div_le_div_of_nonneg_right hdegreeR (Nat.cast_nonneg _)) | |
| (mul_le_mul_of_nonneg_right | |
| (mul_le_mul_of_nonneg_right horbitsR (Nat.cast_nonneg _)) hratio) | |
| _ = _ := by ring | |
| theorem eventually_exists_selection | |
| {P E O V : β β Type*} [β N, Fintype (P N)] [β N, Fintype (E N)] | |
| (d : β N, OrbitData (P N) (E N) (O N) (V N)) | |
| (hinj : β N, Function.Injective (d N).coarse) | |
| (degree : β β β) (B p : β) | |
| (heligibility : β N e, ((d N).eligibilityCompetitors e).card β€ degree N) | |
| (hdegree : β N e, β o β (d N).orbits e, β v β (d N).passing e o, | |
| ((d N).competitors e o v).card β€ degree N) | |
| (horbits : β N e, ((d N).orbits e).card β€ B * (N + 1) ^ p) | |
| {A D H Cβ : β} (hH : 0 β€ H) (hgap : D < H) | |
| (hdegreeRate : β Ξ· : β, 0 < Ξ· β | |
| βαΆ N in atTop, Real.log (degree N : β) / (N : β) β€ D + Ξ·) | |
| (hdet : βαΆ N in atTop, β e, β o β (d N).orbits e, | |
| JointLossCounts.deterministicLossFraction ((d N).full e o) ((d N).passing e o) β€ | |
| Cβ / (N : β)) | |
| (hpos : βαΆ N in atTop, 0 < Fintype.card (E N)) | |
| (hE : Tendsto (fun N => Real.log (Fintype.card (E N) : β) / (N : β)) atTop (π A)) | |
| {Ξ΅ : β} (hΞ΅ : 0 < Ξ΅) : | |
| βαΆ N in atTop, β (s : Sample (P N) (hashLevel H N)) (G : Finset (E N)), | |
| G.card = βReal.exp ((N : β) * (A - H - Ξ΅))ββ β§ | |
| (β e β G, (d N).Good (hashLevel H N) (hashSet H N) (N : β) e s) β§ | |
| (β e β G, β f β G, e β f β ((d N).coarse e).1 β ((d N).coarse f).1) β§ | |
| β e β G, β o β (d N).orbits e, | |
| JointLossCounts.missingFraction ((d N).full e o) ((d N).passing e o) | |
| ((d N).variableBad (hashLevel H N) (hashSet H N) e o) s β€ (Cβ + 1) / (N : β) := by | |
| classical | |
| have huniform := eventually_errorBound_le_half degree B p hH hgap hdegreeRate | |
| have hsmall : βαΆ N in atTop, β e, | |
| (((d N).eligibilityCompetitors e).card : β) / (hashModulus H N : β) + | |
| (((d N).orbits e).card : β) * (N : β) * | |
| ((degree N : β) / (hashModulus H N : β)) β€ 1 / 2 := by | |
| filter_upwards [huniform] with N hN e | |
| exact (count_error_le_envelope (d N) e (degree N) B p N (hashModulus H N) | |
| (heligibility N e) (horbits N e)).trans hN | |
| have hpositive : βαΆ N : β in atTop, (0 : β) < N := by | |
| filter_upwards [eventually_gt_atTop (0 : β)] with N hN | |
| exact_mod_cast hN | |
| let good := fun N (s : Sample (P N) (hashLevel H N)) (e : E N) => | |
| (d N).Good (hashLevel H N) (hashSet H N) (N : β) e s | |
| have hinc : βαΆ N in atTop, β e, | |
| (((JointAPFree.modularSet (hashModulus H N)).card : β) / | |
| (hashModulus H N : β) ^ 2 / 2) * | |
| (Fintype.card (Sample (P N) (hashLevel H N)) : β) β€ | |
| (goodIncidence (good N) e : β) := by | |
| filter_upwards [hsmall, hpositive] with N hN hNpos e | |
| rw [show goodIncidence (good N) e = | |
| ((d N).goodEvent (hashLevel H N) (hashSet H N) (N : β) e).card from | |
| (d N).goodIncidence_eq _ _ _ _] | |
| exact (d N).goodEvent_card_lower (hashLevel H N) (hashSet H N) (N : β) hNpos e | |
| (degree N) (hdegree N e) (hN e) | |
| have hyield := eventually_exists_many_good_explicit good hH hpos hinc hE hΞ΅ | |
| have hselection := eventually_exists_good_subfamily good | |
| (fun N => βReal.exp ((N : β) * (A - H - Ξ΅))ββ) hyield | |
| filter_upwards [hselection, hdet] with N hN hdetN | |
| obtain β¨s, G, hcard, hgoodβ© := hN | |
| refine β¨s, G, hcard, hgood, ?_, ?_β© | |
| Β· intro e he f hf hne | |
| exact (d N).good_no_shared_x (hashLevel H N) (hashSet H N) (N : β) f e s | |
| (hgood f hf) (hgood e he) (fun h => hne ((hinj N) h)) | |
| Β· intro e he o ho | |
| exact (d N).good_missingFraction_le (hashLevel H N) (hashSet H N) Cβ (N : β) e s | |
| (hgood e he) (hdetN e) o ho | |
| end MatrixMultiplication.JointMaskedRates | |
| end | |
| end OAI | |