Imports
import CLRSLean.Chapter_04.Section_04_1_Maximum_Subarray
import CLRSLean.Chapter_04.Section_04_2_Strassen_Algorithm
import CLRSLean.Chapter_04.Section_04_3_Substitution_Method
import CLRSLean.Chapter_04.Section_04_4_Recursion_Tree_Method
import CLRSLean.Chapter_04.Section_04_5_Master_Theorem
import CLRSLean.Chapter_04.Section_04_6_Master_Theorem_All_InputChapter 4. Divide-and-Conquer
Chapter 4 has several good Lean targets. The current first pass contains both an algorithmic specification for the maximum-subarray problem and the recurrence proof infrastructure used by later divide-and-conquer analyses. Sections 4.3 and 4.4 provide the proof-method infrastructure used by the Master-method file and by future divide-and-conquer runtime proofs.
-
Section 4.1 - The maximum-subarray problem:
provedfor the current functional correctness model. The file proves that the candidate enumerator contains exactly the nonempty contiguous subarrays, and thatmaxSubarrayreturns a candidate with maximum sum. It also proves thatmaxCrossingSubarrayreturns a maximum-sum candidate among all candidates crossing a split. Finally,subarray_append_left_or_right_or_crossingandsubarray_append_optimal_of_casesprovide the proof interface for the recursive combine step, andmaxSubarrayDivideStep_correctproves the executable combine step itself. The recursive layer is captured bymaxSubarrayDivideTree_correctfor explicit split trees andmaxSubarrayDivideFuel_correctfor a fuelled midpoint splitter. The remaining refinement target is runtime/RAM-cost analysis. -
Section 4.2 - Strassen's algorithm for matrix multiplication:
provedfor 2 by 2 block algebra. The file provesCLRS.Chapter04.strassen2x2_correct: Strassen's seven products reconstruct ordinary 2 by 2 block matrix multiplication over an arbitrary ring. -
Section 4.3 - The substitution method:
provedfor one-step recurrence bounds. The file proves upper-bound, lower-bound, sandwich, linear, and geometric substitution templates. -
Section 4.4 - The recursion-tree method:
provedfor additive finite level expansions. The file proves exact unrolling into level-cost sums and envelope bounds for the resulting finite sums. -
Section 4.5 - The master method:
provedfor exact-power recurrences. The file proves the normalized recurrence expansion and three Master-style exact-power criteria for bounded, constant, and tail-dominated normalized forcing. -
Section 4.6 - Proof of the master theorem:
partial. The file proves floor/ceiling all-input recurrence interfaces, extracts exact-power recurrences from those models, and proves a compiler-clean transfer bridge from exact-powerO,Ω, andΘbounds to all natural inputs under monotone cost and explicit power-sandwich hypotheses. It also proves the adjacent-powerNat.loginterval and a directallInput_bigTheta_of_powerSteptheorem that discharges those sandwich hypotheses from monotone comparison scales with eventual one-step control. The discretecriticalPowerScaleandcriticalPowerLogScaleandtailDominatedScalewrappers now turn exact-powerT(b^i) = Θ(a^i),T(b^i) = Θ((i+1)a^i), and tail-dominated bounds into all-input bounds, and Section 4.6 packages the floor/ceiling recurrence forms of exact-power Master cases 1, 2, and 3 for these discrete scales. It also proves the natural-exponent comparison layer fora = b^p, exposing case-1 results asΘ(n^p)and case-2 results asΘ((⌊log_b n⌋+1)n^p). A real-log bridgeCLRS.Chapter04.criticalPowerScale_isBigTheta_realLogScalenow connects the discrete scalea^(⌊log_b n⌋)to the textbook scalen^(log_b a)for alla ≥ 1andb > 1, and the named exact/floor/ceiling case-1 wrappers now expose CLRS-facingΘ(n^(log_b a))bounds directly. A second bridge proves the discrete case-2 scale isΘ(n^(log_b a) log n), and the named exact/floor/ ceiling case-2 wrappers expose that textbook scale directly. The remaining Master gap is a textbook-facing case-3 comparison scale.
namespace CLRSnamespace Chapter04end Chapter04end CLRS