Logarithmic asymptotic cost bounds and halving recurrences #
This module extends CslibFrontier.Foundations.Analysis.Asymptotics.CostBound with logarithmic
Cslib.CostIsBigO rules (O(log₂ n)), bit-length / binary-logarithm big-O equivalences, general
halving-recurrence call-count bounds, and the positive-integer-witness characterization of
Asymptotics.IsBigO on eventually nonnegative sequences ℕ → ℝ.
Main results #
Cslib.isBigO_iff_exists_pos_nat: equivalence betweenf =O[atTop] gand positive-integer witnesses∃ c n₀ : ℕ, 0 < c ∧ 0 < n₀ ∧ ∀ n, n₀ ≤ n → f n ≤ c * g nfor eventually nonnegativef, g : ℕ → ℝ.Cslib.Nat.size_le_two_mul_logb,Cslib.Nat.size_isBigO_logb,Cslib.Nat.logb_isBigO_size,Cslib.Nat.log_isBigO_logb: asymptotic equivalence betweenNat.size,Nat.log 2, andReal.logb 2.Cslib.Nat.le_size_of_halving,Cslib.Nat.succ_le_size_of_halving: general halving recurrence bounds in terms ofNat.size.Cslib.CostIsBigO.of_le_add_mul_size,Cslib.CostIsBigO.of_le_add_mul_log,Cslib.CostIsBigO.of_le_add_mul_clog,Cslib.CostIsBigO.of_halving: logarithmicCslib.CostIsBigOconstructors matchingCslib.CostIsBigO.of_le_add_mul.
For eventually nonnegative sequences f, g : ℕ → ℝ, f =O[atTop] g holds iff there exist
positive natural numbers c and n₀ such that f n ≤ c * g n for all n ≥ n₀.
Binary bit-length Nat.size is O(log₂ n) along Filter.atTop.
Real binary logarithm Real.logb 2 is O(Nat.size) along Filter.atTop.
Integer floor binary logarithm Nat.log 2 is O(log₂ n) along Filter.atTop.
Early-stopping halving recurrence bound: if every positive w either stops (f w = 0) or
halves to a positive w' ≤ w / 2 with f w ≤ 1 + f w', then f w + 1 ≤ w.size for 0 < w.
Any cost bounded by an affine function of a halving recurrence f is O(log₂ (size x)).