Imports
import Mathlib.Tactic
open Finsetopen scoped BigOperators

4.4. The Recursion-Tree Method

This file makes the finite-sum core of the CLRS recursion-tree method explicit.

Main results:

  • Theorem CLRS.Chapter04.recursion_tree_additive_unroll: an additive one-step recurrence is exactly the base value plus the sum of level costs.

  • Theorem CLRS.Chapter04.recursion_tree_additive_upper_envelope: if each level cost is bounded by an envelope, the whole tree is bounded by the sum of the envelope.

  • Theorem CLRS.Chapter04.recursion_tree_constant_level_cost: constant level costs give the usual linear closed form.

Current gaps:

  • This is the finite linearized core of the recursion-tree method. Branching recurrences such as T(n) = aT(n/b) + f(n) should instantiate it after grouping each depth of the recursion tree into one level-cost function.

namespace CLRSnamespace Chapter04

Unroll an additive recurrence into the sum of its level costs.

If every level cost is bounded by an envelope, then the unrolled recursion tree is bounded by the sum of that envelope.

If every level cost is at least an envelope, then the same unrolling gives a lower bound by the envelope sum.

Constant level costs collapse the recursion tree to the base value plus a linear term.

A bounded-cost recursion tree with at most level work per depth is bounded by the base bound plus level * n.

theorem recursion_tree_constant_upper_bound (T cost : ) {base level : } (hbase : T 0 base) (hcost : k, cost k level) (hstep : n, T (n + 1) = T n + cost n) : n : , T n base + level * (n : ) := calc T n T 0 + _k range n, level := hsum _ base + _k range n, level := _ = base + level * (n : ) :=
end Chapter04end CLRS