Ordinary matrix multiplication: exact execution and allocation summary
ProvedCLRS.MatrixMultiplyAnalysis.summaryFor any natural dimension , including zero, let an initial heap represent
two nested integer matrices and . Input outer arrays and rows may alias.
The compiled matrix_multiply call terminates and returns the first unused
outer-array identifier of the initial heap. In the final heap it represents
The final heap preserves every previously allocated row, outer array, and
object. Its multiply_add increment is exactly , and every other clock
has increment zero. The next unused row identifier increases by ;
the finite result rows use the consecutive identifiers immediately after
the initially allocated default row. This summary concerns one actual finite
call and its exact resulting storage and source tick counts.
Platform namespace. The imported Chapter 4 source declarations live under CLRS in this upload to avoid collisions with independently published compiler versions. The immutable source reference retains the original declaration names.
Catalog organization (2026-10-11). This record was retired from the active Chapter 4 catalog to focus the presentation on three algorithms and four reusable recurrence results. Its mathematical statement and proof status are unchanged, and existing imports and links remain valid. The retained results are CLRS.Chapter4Publication.MatrixMultiply.correctness_and_running_time. Supporting lemmas needed by the retained results are included in their accepted proof files.
import Definitions.Def_CLRS_Chapter4_Algo2Lean import Definitions.Def_CLRS_Chapter4_Algo2LeanExamples_MatrixMultiply import Definitions.Def_CLRS_Chapter4_Algo2LeanExamples_MatrixMultiplyGenerated import Definitions.Def_CLRS_Chapter4_Algo2LeanExamples_MatrixMultiplyPoints import Definitions.Def_CLRS_Chapter4_Algo2LeanLib_MatrixHeap import Std set_option autoImplicit false set_option backward.isDefEq.respectTransparency false set_option backward.defeqAttrib.useBackward true namespace CLRS end CLRS open CLRS open MatrixMultiplyLibrary MatrixMultiplyLibrary.Algo2LeanGenerated open Algo2LeanCore Algo2LeanGenerated open Algo2LeanCore.MatrixHeap namespace CLRS.MatrixMultiplyAnalysis end CLRS.MatrixMultiplyAnalysis open CLRS.MatrixMultiplyAnalysis
theorem CLRS.MatrixMultiplyAnalysis.summary (h : Heap) (a b : CollectionRef) (av bv : Values) (n : Nat)
(va : Stored h a av) (vb : Stored h b bv) :
∃ after, matrix_multiply.Call h (a, b, n) after h.nextCollection ∧
Extends h after ∧ Stored after h.nextCollection (product av bv n) ∧
Heap.cost h after = costs n ∧ after.nextRef = h.nextRef + 1 + n ∧
RowReferences after h.nextCollection (h.nextRef + 1) n := by sorry