Download data/lean/OAI/NumberTheory/Ostmann/Arithmetic/ArithmeticGoodPatternRate.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 4.84 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/NumberTheory/Ostmann/Arithmetic/ArithmeticGoodPatternRate.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/NumberTheory/Ostmann/Arithmetic/ArithmeticGoodPatternRate.lean
-
curl -L -o ArithmeticGoodPatternRate.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/NumberTheory/Ostmann/Arithmetic/ArithmeticGoodPatternRate.lean
4.84 kB
| import OAI.NumberTheory.Ostmann.Arithmetic.ArithmeticPatternErrorRate | |
| namespace OAI | |
| /-! # Full equality-pattern and frequency sums in the good-matching estimate -/ | |
| namespace Ostmann | |
| open Filter | |
| open scoped Classical BigOperators | |
| /-- The signed gain can be chosen before the local quartet tolerance. This | |
| amount absorbs every original pattern and paired-frequency count. -/ | |
| def goodPatternGain (n : β) (Cprior Cfreq gain : β) : β := | |
| 2 * (((4 * n * 2 ^ n) ^ 2 + 4 * n * 2 ^ n : β) : β) * Cprior + | |
| (2 * (2 ^ (n + 1) - 1 : β) : β) * Cfreq + gain | |
| theorem arithmetic_good_pattern_rate (n k : β) (hk : 0 < k) | |
| (Cprior Cfreq gain : β) (hCprior : 1 β€ Cprior) (hCfreq : 0 β€ Cfreq) : | |
| βαΆ L : β in atTop, let m := spectatorBulkCount k L | |
| β S : Finset β€, (S.card : β) β€ Real.exp (Cfreq * m) β | |
| let _ := sampleSetoidFintype (Bool Γ MovingSampleIndex n) | |
| β R : Setoid (Bool Γ MovingSampleIndex n) β FrequencyTree (S Γ S) n β β, | |
| (β s t, βR s tβ β€ | |
| ((2 : β) ^ Fintype.card (Quotient s) * | |
| (Real.exp (Cprior * L)) ^ (4 * n * 2 ^ n - Fintype.card (Quotient s))) * | |
| (Real.exp (-goodPatternGain n Cprior Cfreq gain * m) + | |
| Real.exp (-Real.exp ((125 / 100000 : β) * L)) + | |
| 4 * Real.exp (-Real.exp ((2 / 1000 : β) * L)))) β | |
| ββ s, β t, R s tβ β€ Real.exp (-gain * m) + | |
| 5 * Real.exp (-Real.exp ((12 / 10000 : β) * L)) := by | |
| filter_upwards [movingPattern_five_errors_rate n k hk Cprior Cfreq hCprior hCfreq, | |
| eventually_ge_atTop (4 : β)] with L herrors hL | |
| dsimp only | |
| intro S hS R hR | |
| let _ := sampleSetoidFintype (Bool Γ MovingSampleIndex n) | |
| let m := spectatorBulkCount k L | |
| let A : β := (((4 * n * 2 ^ n) ^ 2 + 4 * n * 2 ^ n : β) : β) * Cprior | |
| let B : β := (2 * (2 ^ (n + 1) - 1 : β) : β) * Cfreq | |
| let cost := (2 : β) ^ ((4 * n * 2 ^ n) ^ 2) * | |
| (max 2 (Real.exp (Cprior * L))) ^ (4 * n * 2 ^ n) | |
| let err := Real.exp (-Real.exp ((125 / 100000 : β) * L)) + | |
| 4 * Real.exp (-Real.exp ((2 / 1000 : β) * L)) | |
| have hA : 0 β€ A := by dsimp only [A]; positivity | |
| have hB : 0 β€ B := by dsimp only [B]; positivity | |
| have hL0 : 0 β€ L := by linarith | |
| have hkpow : (1 : β) β€ (k : β) ^ 4 := one_le_powβ (by exact_mod_cast hk) | |
| have hLL : L β€ (k : β) ^ 4 * L := by nlinarith only [hkpow, hL0] | |
| have hhalf := spectatorBulkCount_half k L (show 4 β€ (k : β) ^ 4 * L by linarith) | |
| have hLm : L β€ 2 * (m : β) := by dsimp only [m]; linarith | |
| have hcost : cost β€ Real.exp (2 * A * m) := by | |
| apply (movingPattern_total_cost_le_exp n Cprior L hCprior (by linarith)).trans | |
| apply Real.exp_le_exp.mpr | |
| change A * L β€ 2 * A * m | |
| nlinarith only [hLm, hA] | |
| have hcard : (Fintype.card (FrequencyTree (S Γ S) n) : β) β€ Real.exp (B * m) := by | |
| rw [pairedFrequencyTree_card, Nat.cast_pow] | |
| exact frequency_history_pair_card_bound S n Cfreq m hS | |
| have hgain : cost * (Fintype.card (FrequencyTree (S Γ S) n) : β) * | |
| Real.exp (-goodPatternGain n Cprior Cfreq gain * m) β€ Real.exp (-gain * m) := by | |
| apply (mul_le_mul_of_nonneg_right | |
| (mul_le_mul hcost hcard (Nat.cast_nonneg _) (Real.exp_nonneg _)) (Real.exp_nonneg _)).trans_eq | |
| rw [β Real.exp_add, β Real.exp_add] | |
| congr 1 | |
| dsimp only [goodPatternGain, A, B] | |
| ring | |
| have hsum : ββ s, β t, R s tβ β€ | |
| cost * (Fintype.card (FrequencyTree (S Γ S) n) : β) * | |
| (Real.exp (-goodPatternGain n Cprior Cfreq gain * m) + err) := by | |
| have hs (s : Setoid (Bool Γ MovingSampleIndex n)) : | |
| ββ t, R s tβ β€ | |
| ((Fintype.card (FrequencyTree (S Γ S) n) : β) * | |
| (Real.exp (-goodPatternGain n Cprior Cfreq gain * m) + err)) * | |
| ((2 : β) ^ Fintype.card (Quotient s) * | |
| (Real.exp (Cprior * L)) ^ (4 * n * 2 ^ n - Fintype.card (Quotient s))) := by | |
| apply (norm_sum_le_of_le _ (fun t _ => hR s t)).trans_eq | |
| rw [Finset.sum_const, Finset.card_univ, nsmul_eq_mul] | |
| dsimp only [err] | |
| ring | |
| have hh := movingPattern_error_sum_le n (Real.exp (Cprior * L)) | |
| ((Fintype.card (FrequencyTree (S Γ S) n) : β) * | |
| (Real.exp (-goodPatternGain n Cprior Cfreq gain * m) + err)) | |
| (Real.exp_nonneg _) (by dsimp only [err]; positivity) (fun s => β t, R s t) hs | |
| exact hh.trans_eq (by dsimp only [cost]; ring) | |
| have he : cost * (Fintype.card (FrequencyTree (S Γ S) n) : β) * err β€ | |
| 5 * Real.exp (-Real.exp ((12 / 10000 : β) * L)) := herrors S hS | |
| calc | |
| _ β€ _ := hsum | |
| _ = cost * (Fintype.card (FrequencyTree (S Γ S) n) : β) * | |
| Real.exp (-goodPatternGain n Cprior Cfreq gain * m) + | |
| cost * (Fintype.card (FrequencyTree (S Γ S) n) : β) * err := by ring | |
| _ β€ _ := add_le_add hgain he | |
| end Ostmann | |
| end OAI | |