File size: 3,954 Bytes
4a56cd6 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 | import Mathlib
namespace OAI
/-!
# Arithmetic for the finite-tree obstruction
The parameter estimate and final rearrangement in `prop:finite-lower` hold
with the explicit absolute constant 34.
-/
namespace TreeEdit.BinaryLower.FiniteNumeric
lemma period_ratio_bound {k : β} (hk : 1 β€ k) :
2 * (k : β) * (4 * (k : β) ^ (10 * k)) / (k : β) ^ (20 * k)
β€ 8 / (k : β) ^ k := by
have hk0 : (0 : β) < k := by exact_mod_cast (show 0 < k by omega)
have hk1 : (1 : β) β€ k := by exact_mod_cast hk
have ha : 0 < (k : β) ^ (10 * k) := pow_pos hk0 _
have hb : 0 < (k : β) ^ k := pow_pos hk0 _
have hp : (k : β) * (k : β) ^ k β€ (k : β) ^ (10 * k) := by
calc
(k : β) * (k : β) ^ k = (k : β) ^ (k + 1) := by ring
_ β€ (k : β) ^ (10 * k) :=
pow_le_pow_rightβ hk1 (by omega)
have ht : (k : β) ^ (20 * k) = ((k : β) ^ (10 * k)) ^ 2 := by
rw [β pow_mul]
congr 1
omega
rw [ht]
have hs : 2 * (k : β) * (4 * (k : β) ^ (10 * k)) /
((k : β) ^ (10 * k)) ^ 2 = 8 * (k : β) / (k : β) ^ (10 * k) := by
field_simp
ring
rw [hs]
apply (div_le_div_iffβ ha hb).2
nlinarith
/-- The final line of `eq:finite-root-upper`, with an explicit constant. -/
theorem finite_root_bound {k : β} {M V : β} (hk : 1 β€ k) (hM : 0 β€ M)
(hV : V β€ 4 * M *
(2 * (k : β) * (4 * (k : β) ^ (10 * k)) / (k : β) ^ (20 * k) +
1 / (2 * (k : β) ^ k))) :
V β€ 34 * M / (k : β) ^ k := by
have hk0 : (0 : β) < k := by exact_mod_cast (show 0 < k by omega)
have hp : (k : β) ^ k β 0 := ne_of_gt (pow_pos hk0 _)
calc
V β€ 4 * M *
(2 * (k : β) * (4 * (k : β) ^ (10 * k)) / (k : β) ^ (20 * k) +
1 / (2 * (k : β) ^ k)) := hV
_ β€ 4 * M * (8 / (k : β) ^ k + 1 / (2 * (k : β) ^ k)) := by
apply mul_le_mul_of_nonneg_left _ (by positivity)
linarith [period_ratio_bound hk]
_ = 34 * M / (k : β) ^ k := by field_simp; ring
/-- Uniform root separation and the preceding upper displacement estimate
force the source's `(k/4)^k` lower distortion, with constant `1/34`. -/
theorem finite_distortion_bound {k : β} {M V D : β}
(hk : 1 β€ k) (hM : 0 < M) (hD : 0 < D)
(hlower : M / ((4 : β) ^ k * D) β€ V)
(hupper : V β€ 34 * M / (k : β) ^ k) :
((k : β) / 4) ^ k / 34 β€ D := by
have hk0 : (0 : β) < k := by exact_mod_cast (show 0 < k by omega)
have hp : 0 < (k : β) ^ k := pow_pos hk0 _
have hfour : 0 < (4 : β) ^ k := by positivity
have hcompare := hlower.trans hupper
have hcross := (div_le_div_iffβ (mul_pos hfour hD) hp).1 hcompare
have hcancel : (k : β) ^ k β€ 34 * (4 : β) ^ k * D := by
apply (mul_le_mul_iff_of_pos_left hM).1
nlinarith [hcross]
rw [div_pow, div_div]
apply (div_le_iffβ (mul_pos hfour (by norm_num : (0 : β) < 34))).2
nlinarith [hcancel]
/-- The source averaging length `J=4k^(10k)` lies within the row budget
`T=k^(20k)` already for every `kβ₯2`. -/
theorem averaging_length_le_rows {k : β} (hk : 2 β€ k) :
4 * k ^ (10 * k) β€ k ^ (20 * k) := by
have hfour : 4 β€ k ^ (10 * k) := by
calc
4 = 2 ^ 2 := by norm_num
_ β€ k ^ 2 := Nat.pow_le_pow_left hk 2
_ β€ k ^ (10 * k) := Nat.pow_le_pow_right (by omega) (by omega)
calc
4 * k ^ (10 * k) β€ k ^ (10 * k) * k ^ (10 * k) :=
Nat.mul_le_mul_right _ hfour
_ = k ^ (20 * k) := by rw [β pow_add]; congr 1; omega
/-- The bound on a sparse character period at any internal depth implies the
half-averaging-interval bound required by short-period detection. -/
theorem sparse_period_twice_le {k j r q : β} (hk : 1 β€ k)
(hj : j < k) (hr : r < k)
(hq : q β€ 2 * k ^ (5 * j + 5 * r)) :
2 * q β€ 4 * k ^ (10 * k) := by
have hp : k ^ (5 * j + 5 * r) β€ k ^ (10 * k) :=
Nat.pow_le_pow_right hk (by omega)
nlinarith
end TreeEdit.BinaryLower.FiniteNumeric
end OAI
|