Imports
open Finsetopen scoped BigOperators

4.5. The Master Method - Exact Powers

This file proves the exact-power algebraic core of the Chapter 4 Master Theorem. For recurrences on exact powers, T(b^(i+1)) = a * T(b^i) + f(b^(i+1)), the normalized quantity T(b^i) / a^i unfolds into the initial value plus a finite sum of normalized forcing terms. The three Master-style exact-power criteria below then turn bounded, constant, or tail-dominated normalized forcing into the expected asymptotic conclusions.

Main result:

  • Theorem CLRS.Chapter04.h_formula: the normalized exact-power recurrence expansion.

  • Theorem CLRS.Chapter04.master_case1_geometric: bounded normalized forcing, obtained from a geometric upper bound, gives T(b^i) = Θ(a^i).

  • Theorem CLRS.Chapter04.master_case2_constant_forcing: constant normalized forcing gives T(b^i) = Θ((i+1)a^i).

  • Theorem CLRS.Chapter04.master_case3_tail_dominated: tail-dominated normalized forcing gives the third Master-style exact-power case.

Current gaps:

  • The extension from exact powers n = b^i to all natural input sizes is future work. That layer needs a monotone recurrence model and floor/ceiling sandwiching.

namespace CLRSnamespace Chapter04

Exact-power recurrences

Exact-power form of the CLRS Master Theorem recurrence.

structure ExactPowerRecurrence (a b : ) (f T : ) : Prop where step : i : , T (b ^ (i + 1)) = (a : ) * T (b ^ i) + f (b ^ (i + 1))

The normalized value T(b^i) / a^i.

noncomputable def normalizedValue (a b : ) (T : ) (i : ) : := T (b ^ i) / ((a : ) ^ i)

The normalized forcing term contributed at the step from i to i+1.

noncomputable def normalizedForcing (a b : ) (f : ) (i : ) : := f (b ^ (i + 1)) / ((a : ) ^ (i + 1))

Public theorem

Unroll the exact-power recurrence after dividing by a^i.

This is the algebraic spine of the Master Theorem proof: the remaining CLRS case analysis is a question about bounding the finite sum on the right-hand side.

lemma normalizedValue_eq_base_add_sum (a b : ) (f T : ) (h_rec : ExactPowerRecurrence a b f T) (ha_ne_zero : (a : ) 0) (i : ) : normalizedValue a b T i = normalizedValue a b T 0 + ( k range i, normalizedForcing a b f k) := private theorem isBigTheta_of_eventual_bounds {f g : } (hO : C : , 0 < C n₀ : , n, n n₀ |f n| C * |g n|) ( : c : , 0 < c n₀ : , n, n n₀ c * |g n| |f n|) : Chapter03.isBigTheta f g :=

If the normalized recurrence values are eventually within constant multiples of a nonnegative scale s, then the original exact-power recurrence is Θ(s(i)a^i).

private lemma geometric_sum_le_tsum_bound {r : } (hr_nonneg : 0 r) (hr_lt_one : r < 1) (i : ) : ( k range i, r ^ k) (1 - r)⁻¹ := calc ( k range i, r ^ k) ∑' k : , r ^ k := hsumm.sum_le_tsum (range i) (fun k _ => pow_nonneg hr_nonneg k) _ = (1 - r)⁻¹ := tsum_geometric_of_lt_one hr_nonneg hr_lt_one

Master case 1, exact-power form: if the normalized forcing terms are bounded by a convergent geometric sequence, then T(b^i) = Θ(a^i).

simpa using theta_of_normalized_by_scale a b T (fun _ : => (1 : )) ha_pos (fun _ => ) h_lower h_upper

Master case 2, exact-power form: if the normalized forcing terms are trapped between positive constants, then T(b^i) = Θ((i+1)a^i).

calc normalizedValue a b T i = normalizedValue a b T 0 + ( k range i, normalizedForcing a b f k) := h_formula_i _ normalizedValue a b T 0 + C * (i : ) := _ (normalizedValue a b T 0 + C) * ((i : ) + 1) :=

Master case 3, exact-power form: if the normalized recurrence value is eventually controlled by the last normalized forcing term, then the last term dominates the whole recurrence tree.

calc normalizedValue a b T i C * normalizedForcing a b f (i - 1) := htail i hi_n₀ hi_one _ = C * (if i = 0 then 1 else normalizedForcing a b f (i - 1)) :=
end Chapter04end CLRS