Documentation

Complexity.Computability.Ram.Array.MergeSort.Time

Time analysis of the existing recursive merge sort #

The functional proof supplies the intermediate array assertions at each call. This independent induction adds the actual setup, call, merge/copy and guard counts using TimeBound. There is no unused fuel to subtract or thread. The recurrence and final budget are unchanged from the original contract.

theorem Ram.Source.Array.MergeSort.recursive_timeBound {w control heapLimit selfFn : ℕ} {functions : Program} (hw : 2 ≤ w) (lookup : functions[selfFn]? = some (function selfFn)) (xs : List (Word w)) :
TimeBound control functions heapLimit (Nat.clog 2 xs.length) (function selfFn).body ((recursionSpec heapLimit selfFn w).pre xs) fun (x : State w) => budget xs.length

The existing body budget bounds every completed execution. Recursive functional contracts supply states and termination, not cost hypotheses; the time induction supplies the two child bounds independently.