Merge Sort: Correctness and Upper Bound #
Proofs that mergeSort is a correct comparison sort and uses at most n * ⌈log₂ n⌉ queries.
eval_mergeSort identifies the query program with List.mergeSort: evaluating against any
oracle produces the same list as List.mergeSort with the comparator induced by the oracle.
Correctness properties (permutation, sortedness) transfer directly from the List.mergeSort
API. The query bound is proved by equational reasoning on FreeM.countQueries, which has no
List counterpart.
Evaluation #
Evaluating the query-based merge agrees with List.merge using the relation supplied
by the oracle.
Evaluating query-based merge sort agrees with List.mergeSort using the relation
supplied by the oracle.
This is the essential correctness statement: it identifies the query program as the
merge sort operation, so correctness properties (permutation, sortedness, stability)
transfer directly from the List.mergeSort API rather than being restated here.