Compositional combinators and linearithmic bounds for Cslib.CostIsBigO #
Extends CslibFrontier.Foundations.Analysis.Asymptotics.CostBound (Cslib.CostIsBigO) with
constant, additive, scalar-multiple, and multiplicative composition combinators together with
ceiling-logarithm bounds (Nat.clog 2 n ≤ n, (Nat.clog 2 n : ℝ) ≤ (2 / Real.log 2) * Real.log n)
and linearithmic / quadratic comparison lemmas (n * Real.log n =O[atTop] n ^ 2).
Main results #
Cslib.CostIsBigO.const: bounded constant operation counts satisfyCostIsBigO.Cslib.CostIsBigO.add,Cslib.CostIsBigO.add_of_isBigO: sequential sum ofCostIsBigObounds.Cslib.CostIsBigO.const_mul,Cslib.CostIsBigO.mul: constant-multiple and product composition ofCostIsBigObounds.Cslib.CostIsBigO.clog_two_le_self,Cslib.CostIsBigO.cast_clog_two_le_mul_log: binary ceiling-logarithm bounds.Cslib.CostIsBigO.of_le_linear_add_mul_clog: operation counts bounded bya + b * size x + c * (size x * Nat.clog 2 (size x))areO(n * Real.log n).Cslib.CostIsBigO.isBigO_mul_log_sq:n * Real.log n =O[atTop] n ^ 2.
A cost uniformly bounded by a constant c : ℕ is O(1) along any filter l.
Sequential sum of two costs sharing the same asymptotic bound g.
Sequential sum of two costs whose respective bounds g₁, g₂ are each O(g).
Scaling an operation count by a constant c : ℕ preserves CostIsBigO.
Product of two CostIsBigO bounds yields a CostIsBigO bound for fun i ↦ g₁ i * g₂ i.
Any operation count bounded by a + b * size x + c * (size x * Nat.clog 2 (size x)) satisfies
Cslib.CostIsBigO atTop (fun n : ℕ ↦ (n : ℝ) * Real.log n) size cost.