The complete binary insertion sort on the actual machine #
The input array is preloaded and the base and length are in registers 0 and 5. These theorems explicitly start at PC 1, count all instructions of the sorting program and its halt, and make no claim to include a skipped loader.
One fixed program handles arbitrary representable arrays, including empty arrays and duplicates. Its observed heap is mathlib's insertion sort of the original words; the standard sortedness/permutation specification follows. Only the array interval and working registers 1–4 and 6 may change. A caller can choose any local-register bound at least seven and retain its higher source-visible registers. Compiler control and scratch registers are not mistakenly included in that preservation assertion.
Equations
Instances For
Ordinary named source for the same compiled program. The inner search finds a lower bound; the backward loop then moves real heap words.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The surface block associates sequential statements differently from the modular proof, but both produce literally the same machine instructions.
Sorting plus halt from a preloaded matching machine state. The private stack-pointer/older-stack frame and all source-visible observations refer to the same terminating target run.
The same actual halted run, now with the quadratic complexity bound.
Direct heap/result observations: standard insertion sort, unchanged array-external heap and I/O, and preserved caller registers above the seven algorithm registers. The displayed budget includes the actual halt.