This section proves the indexed version of CLRS BUILD-MAX-HEAP. The
main builder starts from the last internal-node layer and repeatedly calls the
fuelled MAX-HEAPIFY theorem from Section 6.2.
Main results:
Theorem ArrayMaxHeapFrom.of_half: every node from heapSize / 2
onward is a leaf, so that suffix is already a localized max-heap.
Theorem buildMaxHeapLoop_isMaxHeap: the bottom-up repeated
MAX-HEAPIFY loop returns a global indexed max-heap.
Theorem buildMaxHeapLoop_perm: the bottom-up loop preserves the input
multiset.
Theorem arrayBuildMaxHeap_isMaxHeap: the array-facing builder returns
an indexed max-heap over the whole list.
Theorem arrayBuildMaxHeap_perm: the builder preserves the multiset of
input elements.
Theorem arrayBuildMaxHeap_correct: the reader-facing correctness
theorem bundling heapness, permutation, and length preservation.
Remaining refinements:
This section proves the CLRS-style bottom-up heap construction used by the
in-place heapsort loop. Later work can connect it to a shared imperative
array semantics and cost model.
namespaceCLRSnamespaceChapter06
Bottom-up heap construction
Array-facing name for the older compact functional heap builder.
Every parent index from heapSize / 2 onward is a leaf. This is the
zero-based version of the CLRS observation that nodes after
⌊heap-size / 2⌋ are leaves.
Correctness of the bottom-up build loop. If the suffix of parent obligations
from count onward is already a localized heap, heapifying
count - 1, ..., 0 produces a global max-heap.
Reader-facing correctness theorem for CLRS BUILD-MAX-HEAP: the
bottom-up repeated-MAX-HEAPIFY builder returns an indexed max-heap over
the full array, preserves the input multiset, and preserves array length.