Abstract
Sorting is one of the fundamental operations in computer science, and many sequential and parallel algorithms have been proposed in the literature. Swap-based sorting algorithms are one category of sorting algorithms where elements are swapped repeatedly to achieve the desired order. Since these algorithms are widely used in practice, their (functional) correctness, i.e., proving sortedness and permutation properties, is of utmost importance. However, proving the permutation property using automated program verifiers is much more challenging as the formal definition of this property involves existential quantifiers. In this paper, we propose a generic pattern to verify the permutation property for any sequential and parallel swap-based sorting algorithm automatically. To demonstrate our approach, we use VerCors, a verification tool based on separation logic for concurrent and parallel programs, to verify the permutation property of bubble sort, selection sort, insertion sort, parallel odd-even transposition sort, quick sort, two in-place merge sorts and TimSort for any arbitrary size of input.
This work is supported by NWO grant 639.023.710 for the Mercedes project.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Notes
- 1.
A ghost variable is used for verification purposes and is not part of the program.
- 2.
- 3.
The keywords read and write can also be used instead of fractions in VerCors.
- 4.
We specify the type of \( Input \) as integers, but it can be other types as well.
- 5.
Note that depending on the algorithm, the new arrangement might be added to the chain after one swap or multiple swaps.
- 6.
A data race is a situation when two or more threads may access the same memory location simultaneously where at least one of them is a write.
- 7.
The head operation returns the first element of a sequence and tail returns a new sequence by eliminating the first element.
- 8.
The full proof of all properties in VerCors is available at https://github.com/Safari1991/Permutation.
- 9.
The full specifications of all case studies are available at https://github.com/Safari1991/Permutation.
- 10.
In the example, the middle element initially is in index 4, because right equals N.
- 11.
The verified sorting algorithms using Why3 are available at http://pauillac.inria.fr/~levy/why3/sorting.
- 12.
References
Ahrendt, W., Beckert, B., Bubel, R., Hähnle, R., Schmitt, P.H., Ulbrich, M.: Deductive Software Verification - The KeY Book, Lecture Notes in Computer Science, vol. 10001. Springer, Heidelberg (2016). https://doi.org/10.1007/978-3-319-49812-6
Amighi, A., Haack, C., Huisman, M., Hurlin, C.: Permission-based separation logic for multithreaded Java programs. LMCS 11(1), 1–66 (2015)
Beckert, B., Schiffl, J., Schmitt, P.H., Ulbrich, M.: Proving JDK’s dual pivot quicksort correct. In: Paskevich, A., Wies, T. (eds.) VSTTE 2017. LNCS, vol. 10712, pp. 35–48. Springer, Cham (2017). https://doi.org/10.1007/978-3-319-72308-2_3
Blom, S., Darabi, S., Huisman, M., Oortwijn, W.: The VerCors tool set: verification of parallel and concurrent software. In: Polikarpova, N., Schneider, S. (eds.) IFM 2017. LNCS, vol. 10510, pp. 102–110. Springer, Cham (2017). https://doi.org/10.1007/978-3-319-66845-1_7
Bornat, R., Calcagno, C., O’Hearn, P., Parkinson, M.: Permission accounting in separation logic. In: POPL, pp. 259–270 (2005)
Boyland, J.: Checking interference with fractional permissions. In: Cousot, R. (ed.) SAS 2003. LNCS, vol. 2694, pp. 55–72. Springer, Heidelberg (2003). https://doi.org/10.1007/3-540-44898-5_4
The Coq proof assistant. https://coq.inria.fr/
Dvořák, S., Durian, B.: Merging by decomposition revisited. Comput. J. 31(6), 553–556 (1988)
Filliâtre, J.C.: Deductive program verification. Ph.D. thesis, Université de Paris-Sud, vol. 11 (2011)
Filliâtre, J.C.: Deductive program verification with Why3 a tutorial (2013). https://www.lri.fr/~marche/DigiCosmeSchool/filliatre.html
Filliâtre, J.C., Magaud, N.: Certification of sorting algorithms in the Coq system. In: TPHOLs (1999). http://www-sop.inria.fr/croap/TPHOLs99/proceeding.html
Filliâtre, J.-C., Paskevich, A.: Why3—where programs meet provers. In: Felleisen, M., Gardner, P. (eds.) ESOP 2013. LNCS, vol. 7792, pp. 125–128. Springer, Heidelberg (2013). https://doi.org/10.1007/978-3-642-37036-6_8
de Gouw, S., Rot, J., de Boer, F.S., Bubel, R., Hähnle, R.: OpenJDK’s Java.utils.Collection.sort() is broken: the good, the bad and the worst case. In: Kroening, D., Păsăreanu, C.S. (eds.) CAV 2015. LNCS, vol. 9206, pp. 273–289. Springer, Cham (2015). https://doi.org/10.1007/978-3-319-21690-4_16
Govindaraju, N., Gray, J., Kumar, R., Manocha, D.: GPUTeraSort: high performance graphics co-processor sorting for large database management. In: Proceedings of the 2006 ACM SIGMOD International Conference on Management of Data, pp. 325–336 (2006)
Greb, A., Zachmann, G.: GPU-ABiSort: optimal parallel sorting on stream architectures. In: PDP, pp. 10-pp. IEEE (2006)
Habermann, A.: Parallel Neighbor Sort. Computer Science Report. Carnegie-Mellon University, Pittsburgh (1972)
Kim, P.-S., Kutzner, A.: Stable minimum storage merging by symmetric comparisons. In: Albers, S., Radzik, T. (eds.) ESA 2004. LNCS, vol. 3221, pp. 714–723. Springer, Heidelberg (2004). https://doi.org/10.1007/978-3-540-30140-0_63
Kipfer, P., Westermann, R.: Improved GPU sorting. GPU Gems 2, 733–746 (2005)
Merrill, D.G., Grimshaw, A.S.: Revisiting sorting for GPGPU stream architectures. In: PACT, pp. 545–546 (2010)
Peters, T.: Timsort (2002). https://bugs.python.org/file4451/timsort.txt
Satish, N., Harris, M., Garland, M.: Designing efficient sorting algorithms for manycore GPUs. In: PDP, pp. 1–10. IEEE (2009)
Schoolderman, M.: Verification of Goroutines using Why3. Master’s thesis, Institute for Computing and Information Sciences, RU Nijmegen (2016)
Sintorn, E., Assarsson, U.: Fast parallel GPU-sorting using a hybrid algorithm. J. Parallel Distrib. Comput. 68(10), 1381–1388 (2008)
Tafat, A., Marché, C.: Binary heaps formally verified in Why3. Research Report RR-7780, INRIA (October 2011). https://hal.inria.fr/inria-00636083
Tushkanova, E., Giorgetti, A., Kouchnarenko, O.: Specifying and proving a sorting algorithm. Technical Report, University of Franche-Comte (October 2009). https://hal.archives-ouvertes.fr/hal-00429040
Author information
Authors and Affiliations
Corresponding author
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2020 Springer Nature Switzerland AG
About this paper
Cite this paper
Safari, M., Huisman, M. (2020). A Generic Approach to the Verification of the Permutation Property of Sequential and Parallel Swap-Based Sorting Algorithms. In: Dongol, B., Troubitsyna, E. (eds) Integrated Formal Methods. IFM 2020. Lecture Notes in Computer Science(), vol 12546. Springer, Cham. https://doi.org/10.1007/978-3-030-63461-2_14
Download citation
DOI: https://doi.org/10.1007/978-3-030-63461-2_14
Published:
Publisher Name: Springer, Cham
Print ISBN: 978-3-030-63460-5
Online ISBN: 978-3-030-63461-2
eBook Packages: Computer ScienceComputer Science (R0)