The master theorem in asymptotic form #
This module converts the explicit bounds of CslibFrontier.Foundations.Data.Nat.MasterTheorem into
real powers and Mathlib's Asymptotics.IsBigO and Asymptotics.IsTheta.
For upper bounds Nat.DivideConquerBound T a b n₀ T₀ f with b ≥ 2 and n₀ ≥ 1:
a > b ^ dwithf n = c n ^ d:T n ≤ (T₀ + c n₀ ^ d b ^ d / (a - b ^ d)) a n ^ log_b aforn ≠ 0, soT = O(n ^ log_b a).a = b ^ dwithf n = c n ^ d:T = O(n ^ d log n).a < b ^ dwithf n = c n ^ d:T = O(n ^ d).- General case 3 (regularity condition): if
fis monotone, not identically zero, and satisfiesa f(⌊n/b⌋) ≤ c f(n)for somec < 1and all sufficiently largen, thenT = O(f)(Nat.DivideConquerBound.isBigO_of_regular). Under monotonicity and∃ N, 0 < f N, regularity already impliesf(n) = Ω(n ^ (log_b a + log_b (1 / c))), so no separate polynomial-growth hypothesis is needed.
For lower bounds Nat.DivideConquerLower and matching recurrences Nat.DivideConquerEq, this
module proves the dual Ω bounds (rpow_isBigO, pow_mul_log_isBigO, isBigO_self) and matching
Θ bounds across all three cases:
- Case 1 (
a > b ^ d,1 ≤ Tmin,b ≤ n₀ + 1):T = Θ(n ^ log_b a)(isTheta_rpow). - Case 2 (
a = b ^ d,1 ≤ c):T = Θ(n ^ d log n)(isTheta_pow_mul_log). - Case 3 (general regularity):
T = Θ(f)(isTheta_of_regular), with polynomial specializationT = Θ(n ^ d)(isTheta_pow).
This complements Mathlib's Mathlib.Computability.AkraBazzi: Akra–Bazzi proves a more general Θ
bound for real-valued recurrences with smooth, polynomially growing driving functions, whereas the
statements here work directly on integer recurrences T : ℕ → ℕ with floor/ceiling division
n / b and cover non-polynomial regular driving functions (such as n log n, n ^ 2 log n, or
2 ^ n) as well as one-sided upper and lower inequalities.
The conversions to real powers and logarithms are Nat.pow_clog_le_mul_rpow_logb and
Nat.clog_le_two_mul_logb (CslibFrontier.Foundations.Data.Nat.LogTwoRpow).
Main results #
Nat.DivideConquerBound.le_mul_rpow: case 1 with a real power and an explicit constant.Nat.DivideConquerBound.isBigO_rpow,Nat.DivideConquerBound.isBigO_pow_mul_log,Nat.DivideConquerBound.isBigO_pow,Nat.DivideConquerBound.isBigO_of_regular: the three cases (including general regularity) asIsBigOstatements.Nat.DivideConquerLower.rpow_le_mul,Nat.DivideConquerLower.rpow_isBigO,Nat.DivideConquerLower.pow_mul_log_isBigO,Nat.DivideConquerLower.isBigO_self: matching lower bounds across all three cases.Nat.DivideConquerEq.isTheta_rpow,Nat.DivideConquerEq.isTheta_pow_mul_log,Nat.DivideConquerEq.isTheta_of_regular,Nat.DivideConquerEq.isTheta_pow: matchingIsThetabounds across all three cases.
References #
- Cormen, Leiserson, Rivest and Stein, Introduction to Algorithms, Theorem 4.1 (Section 4.5) and Section 4.6.2.
Master theorem, case 1, with a real power: if b ^ d < a and n ≠ 0, then
T n ≤ (T₀ + c n₀ ^ d b ^ d / (a - b ^ d)) a n ^ log_b a.
Master theorem, case 3 (general regularity condition): if f is monotone, not identically
zero, and satisfies a * f (n / b) ≤ c * f n for some c < 1 and all sufficiently large n,
then T = O(f).
Master theorem lower bound, case 1: T = Ω(n ^ log_b a).
Master theorem lower bound, case 3: T = Ω(f).
Master theorem, case 1 (Θ form): if b ^ d < a, b ≤ n₀ + 1, and 1 ≤ Tmin, then
T = Θ(n ^ log_b a).
Master theorem, case 3 (Θ form, general regularity condition): if f is monotone, not
identically zero, and satisfies a * f (n / b) ≤ c * f n for some c < 1 and all sufficiently
large n, then T = Θ(f).