cfahlgren1's picture
download
raw
3.99 kB
import OAI.Combinatorics.EditApproximation.Geometry.BalancedWidths
import OAI.Combinatorics.EditApproximation.Geometry.Parameters
import OAI.Combinatorics.EditApproximation.Definitions
namespace OAI
/-!
# Depth of the computed interval tree
The branching factor is the power of two prescribed by the algorithm.
Ceiling logarithms count physical levels, including empty intervals.
-/
namespace EditApproximation
open Finset
theorem intervalTreeDepth_capacity (M nx : ℕ) (hM : 2 ≤ M) :
nx ≤ M ^ intervalTreeDepth M nx :=
(le_max_right 1 nx).trans (Nat.le_pow_clog hM (max 1 nx))
theorem intervalTreeDepth_power_le (M nx : ℕ) (hM : 2 ≤ M) :
M ^ intervalTreeDepth M nx ≤ M * max 1 nx := by
by_cases hx : max 1 nx = 1
· have hz : Nat.clog M 1 = 0 := by
apply Nat.eq_zero_of_le_zero
exact (Nat.clog_le_iff_le_pow hM).2 (by simp)
simpa only [intervalTreeDepth, hx, hz, pow_zero, mul_one] using
(by omega : 1 ≤ M)
· have hx1 : 1 < max 1 nx := by omega
have hdepth := Nat.clog_pos hM hx1
have hpred := Nat.pow_pred_clog_lt_self hM hx1
unfold intervalTreeDepth
rw [← Nat.succ_pred_eq_of_pos hdepth,
pow_succ]
nlinarith
theorem computed_branching_bounds (N : ℕ) (hN : 0 < N)
(hell : 200 ≤ inputSmallLog N) :
2 ≤ (integerParameters N).M ∧
inputSmallLog N ≤ 50 * (heightExponent N / 20) ∧
heightExponent N / 20 ≤ inputHeight N := by
have hlogs := inputSmallLog_bounds N hN
have hquot := Nat.mod_lt (heightExponent N) (by decide : 0 < 20)
have hsplit := Nat.mod_add_div (heightExponent N) 20
have hk : 1 ≤ heightExponent N / 20 := by omega
have hpow : 2 ≤ 2 ^ (heightExponent N / 20) := by
simpa using pow_le_pow_right₀ (by decide : 1 ≤ (2 : ℕ)) hk
have hexp : heightExponent N ≤ inputHeight N := by
exact (Nat.lt_pow_self (by decide : 1 < 2)).le
exact ⟨hpow, by omega, (Nat.div_le_self _ _).trans hexp⟩
theorem computed_tree_depth_bound (N nx : ℕ) (hN : 0 < N) (hnx : nx ≤ N)
(hell : 200 ≤ inputSmallLog N) :
intervalTreeDepth (integerParameters N).M nx * inputSmallLog N ≤ 100 * inputHeight N := by
let k := heightExponent N / 20
have hbranch := computed_branching_bounds N hN hell
have hbound : max 1 nx ≤ 2 ^ inputHeight N := by
apply max_le Nat.one_le_two_pow
exact hnx.trans ((Nat.le_add_right N 2).trans (inputHeight_covers_length N))
have hlog : Nat.clog 2 (max 1 nx) ≤ inputHeight N :=
(Nat.clog_le_iff_le_pow (by decide : 1 < 2)).2 hbound
have hdepth : intervalTreeDepth (integerParameters N).M nx =
(Nat.clog 2 (max 1 nx) + (k - 1)) / k := by
exact Nat.clog_pow_left 2 k (max 1 nx)
have hproduct := Nat.div_mul_le_self (Nat.clog 2 (max 1 nx) + (k - 1)) k
rw [← hdepth] at hproduct
have hscale := Nat.mul_le_mul_left
(intervalTreeDepth (integerParameters N).M nx) hbranch.2.1
change intervalTreeDepth (integerParameters N).M nx * inputSmallLog N ≤
intervalTreeDepth (integerParameters N).M nx * (50 * k) at hscale
have hkH : k ≤ inputHeight N := hbranch.2.2
have hsub : k - 1 ≤ k := Nat.sub_le _ _
nlinarith
theorem computed_source_leaf_width (N nx : ℕ) (hN : 0 < N)
(hell : 200 ≤ inputSmallLog N)
(node : TreeLayer (integerParameters N).M
(intervalTreeDepth (integerParameters N).M nx)) :
(sourceIntervalAt (integerParameters N).M nx _ node).hi -
(sourceIntervalAt (integerParameters N).M nx _ node).lo ≤ 1 := by
have hM := (computed_branching_bounds N hN hell).1
exact sourceIntervalAt_leaf_width _ _ _ (by omega)
(intervalTreeDepth_capacity _ _ hM) node
theorem intervalTreeDepth_node_count (M nx : ℕ) (hM : 2 ≤ M) :
(∑ d ∈ range (intervalTreeDepth M nx + 1), Fintype.card (TreeLayer M d)) ≤
2 * M * max 1 nx := by
have hnodes := complete_tree_node_count M (intervalTreeDepth M nx) hM
have hcapacity := intervalTreeDepth_power_le M nx hM
nlinarith
end EditApproximation
end OAI

Xet Storage Details

Size:
3.99 kB
·
Xet hash:
83f7ee316e037c13d3ff128a77947e9381666a06ec92866cce0d3bdfef8f3d07

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.