English

Derivation and Verification of Array Sorting by Merging, and its Certification in Dafny

Logic in Computer Science 2025-09-03 v1 Data Structures and Algorithms

Abstract

We provide full certifications of two versions of merge sort of arrays in the verification-aware programming language Dafny. We start by considering schemas for applying the divide-and-conquer or partition method of solution to specifications given by pre- and post-conditions involving linear arrays. We then derive the merge sort and merging algorithms as instances of these schemas, thereby arriving at a fully recursive formulation. Further, the analysis of the tree of subproblems arising from the partition facilitates the design of loop invariants that allow to derive a fully iterative version (sometimes called bottom-up merge sort) that does not employ a stack. We show how the use of the provided schemas conveniently conducts the formalization and actual verification in Dafny. The whole method is also applicable to deriving variants of quicksort, which we sketch.

Keywords

Cite

@article{arxiv.2509.01758,
  title  = {Derivation and Verification of Array Sorting by Merging, and its Certification in Dafny},
  author = {Juan Pablo Carbonell and José E. Solsona and Nora Szasz and Álvaro Tasistro},
  journal= {arXiv preprint arXiv:2509.01758},
  year   = {2025}
}
R2 v1 2026-07-01T05:16:12.063Z