File size: 4,968 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 | import OAI.Combinatorics.EditApproximation.Coarse.CoarseCompletePolynomial
import OAI.Combinatorics.EditApproximation.Refinement.ComputedCoarseIndexedWork
import OAI.Combinatorics.EditApproximation.Refinement.ComputedRetainedValues
namespace OAI
namespace EditApproximation
namespace BinaryFraction
open Filter
theorem computedCoarseBranching_polynomial (N : β) (hN : 0 < N)
(hell : 200 β€ inputSmallLog N) : (integerParameters N).B β€ (N + 2) ^ 4 := by
have h4 : 4 β€ (N + 2) ^ 2 := by nlinarith only [Nat.zero_le N]
calc
_ β€ 2 ^ inputHeight N := computed_coarse_B_upper N hN hell
_ β€ 4 * (N + 2) ^ 2 := two_pow_inputHeight_le N
_ β€ (N + 2) ^ 2 * (N + 2) ^ 2 := Nat.mul_le_mul_right _ h4
_ = _ := by rw [β pow_add]
/-- A deterministic bound holds for every pruning outcome, including the
outcomes outside the accuracy event. -/
theorem computedCoarseInitialArrayWork_polynomial (N B d : β) (x y : List β)
(hN : 0 < N) (hell : 200 β€ inputSmallLog N)
(hBdef : B = (integerParameters N).B)
(hddef : d = computedCoarseDepth N (coarseEntryWidth x y))
(hsize : coarseEntryWidth x y β€ N)
(draws : CoarseGuessIndex (coarseEntryWidth x y) β CoarseThresholdDraws B d) :
coarseInitialArrayWork B d (initialThresholdQ N) (initialLambda N) x y draws β€
(N + 2) ^ 19 := by
have hB : 2 β€ B := by
have h := computed_coarse_branching N hN hell
omega
have hBP : B β€ (N + 2) ^ 4 := by
rw [hBdef]
exact computedCoarseBranching_polynomial N hN hell
have hd : d = intervalTreeDepth B (coarseEntryWidth x y) := by
simp only [hddef, computedCoarseDepth, intervalTreeDepth, hBdef]
have heach (i : CoarseGuessIndex (coarseEntryWidth x y)) :
coarseActiveArrayWork (coarseGuess (coarseEntryWidth x y) i)
(initialThresholdQ N) (initialLambda N) (coarseEntryTree B d x y)
(draws i) (coarseGuess (coarseEntryWidth x y) i) β€ (N + 2) ^ 14 := by
have hk : coarseGuess (coarseEntryWidth x y) i β€ 2 * (N + 2) :=
(coarseGuess_le _ i).trans (by omega)
rcases hd with rfl
exact coarseActiveArrayWork_polynomial N B (coarseEntryWidth x y) _ _ _ _
hB hsize hBP hk _ _
have hclog : Nat.clog 2 (coarseEntryWidth x y) β€ inputHeight N :=
(Nat.clog_le_iff_le_pow (by decide : 1 < (2 : β))).mpr
(hsize.trans ((Nat.le_add_right N 2).trans (inputHeight_covers_length N)))
have hcount : Nat.clog 2 (coarseEntryWidth x y) + 1 β€ (N + 2) ^ 5 := by
have hh := computed_height_polynomial N
have hp : 1 β€ (N + 2) ^ 4 := one_le_powβ (by omega)
have hm := Nat.mul_le_mul_right ((N + 2) ^ 4) (show 2 β€ N + 2 by omega)
nlinarith only [hclog, hh, hp, hm]
unfold coarseInitialArrayWork
split_ifs
Β· exact Nat.zero_le _
Β· exact Nat.zero_le _
Β· calc
_ β€ β _i : CoarseGuessIndex (coarseEntryWidth x y), (N + 2) ^ 14 :=
Finset.sum_le_sum (fun i _ => heach i)
_ = (Nat.clog 2 (coarseEntryWidth x y) + 1) * (N + 2) ^ 14 := by
simp only [Finset.sum_const, Finset.card_univ, Fintype.card_fin, smul_eq_mul]
_ β€ (N + 2) ^ 5 * (N + 2) ^ 14 := Nat.mul_le_mul_right _ hcount
_ = _ := by rw [β pow_add]
/-- The counted indexed implementation has polynomial work on every draw. -/
theorem computedCoarseIndexedInitialWithWork_polynomial :
βαΆ N : β in atTop, β B d : β, β x y : List β,
B = (integerParameters N).B β d = computedCoarseDepth N (coarseEntryWidth x y) β
coarseEntryWidth x y β€ N β (β a β x ++ y, Nat.size a β€ inputHeight N ^ 3) β
β (hB : 0 < B) (hq : 0 < inputHeight N ^ 4) (hL : 0 < 64 * inputHeight N)
(draws : CoarseGuessIndex (coarseEntryWidth x y) β CoarseThresholdDraws B d),
(coarseIndexedInitialWithWork (inputHeight N ^ 4) (64 * inputHeight N) N
hB hq hL x y draws).2 β€ (N + 2) ^ 180 := by
filter_upwards [computedCoarseIndexedInitialWithWork_bound, eventually_ge_atTop 1,
inputSmallLog_tendsto.eventually (eventually_ge_atTop 200)] with N hwork hN hell
intro B d x y hBdef hddef hsize hsymbol hB hq hL draws
have hw := hwork B d x y hBdef hddef hsize hsymbol hB hq hL draws
have ha := computedCoarseInitialArrayWork_polynomial N B d x y (by omega) hell
hBdef hddef hsize draws
have hx : x.length + 1 β€ N + 2 := by
have h := (le_max_left x.length y.length).trans hsize
omega
have hp : N + 2 β€ (N + 2) ^ 19 := Nat.le_pow (by decide)
have hm := Nat.mul_le_mul_right ((N + 2) ^ 19) (show 2 β€ N + 2 by omega)
have hsum : coarseInitialArrayWork B d (initialThresholdQ N) (initialLambda N)
x y draws + x.length + 1 β€ (N + 2) ^ 20 := by
nlinarith only [ha, hx, hp, hm]
have hh := Nat.pow_le_pow_left (computed_height_polynomial N) 40
rw [β pow_mul] at hh
calc
_ β€ _ := hw
_ β€ (N + 2) ^ 160 * (N + 2) ^ 20 := Nat.mul_le_mul hh hsum
_ = _ := by rw [β pow_add]
end BinaryFraction
end EditApproximation
end OAI
|