Skip to main content

A Generic Approach to the Verification of the Permutation Property of Sequential and Parallel Swap-Based Sorting Algorithms

  • Conference paper
  • First Online:
Integrated Formal Methods (IFM 2020)

Part of the book series: Lecture Notes in Computer Science ((LNPSE,volume 12546))

Included in the following conference series:

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.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 39.99
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 54.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Notes

  1. 1.

    A ghost variable is used for verification purposes and is not part of the program.

  2. 2.

    See https://utwente.nl/vercors.

  3. 3.

    The keywords read and write can also be used instead of fractions in VerCors.

  4. 4.

    We specify the type of \( Input \) as integers, but it can be other types as well.

  5. 5.

    Note that depending on the algorithm, the new arrangement might be added to the chain after one swap or multiple swaps.

  6. 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. 7.

    The head operation returns the first element of a sequence and tail returns a new sequence by eliminating the first element.

  8. 8.

    The full proof of all properties in VerCors is available at https://github.com/Safari1991/Permutation.

  9. 9.

    The full specifications of all case studies are available at https://github.com/Safari1991/Permutation.

  10. 10.

    In the example, the middle element initially is in index 4, because right equals N.

  11. 11.

    The verified sorting algorithms using Why3 are available at http://pauillac.inria.fr/~levy/why3/sorting.

  12. 12.

    See http://why3.lri.fr/stdlib/array.html.

References

  1. 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

  2. Amighi, A., Haack, C., Huisman, M., Hurlin, C.: Permission-based separation logic for multithreaded Java programs. LMCS 11(1), 1–66 (2015)

    MathSciNet  MATH  Google Scholar 

  3. 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

    Chapter  Google Scholar 

  4. 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

    Chapter  Google Scholar 

  5. Bornat, R., Calcagno, C., O’Hearn, P., Parkinson, M.: Permission accounting in separation logic. In: POPL, pp. 259–270 (2005)

    Google Scholar 

  6. 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

    Chapter  Google Scholar 

  7. The Coq proof assistant. https://coq.inria.fr/

  8. Dvořák, S., Durian, B.: Merging by decomposition revisited. Comput. J. 31(6), 553–556 (1988)

    Article  MathSciNet  Google Scholar 

  9. Filliâtre, J.C.: Deductive program verification. Ph.D. thesis, Université de Paris-Sud, vol. 11 (2011)

    Google Scholar 

  10. Filliâtre, J.C.: Deductive program verification with Why3 a tutorial (2013). https://www.lri.fr/~marche/DigiCosmeSchool/filliatre.html

  11. 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

  12. 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

    Chapter  Google Scholar 

  13. 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

    Chapter  Google Scholar 

  14. 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)

    Google Scholar 

  15. Greb, A., Zachmann, G.: GPU-ABiSort: optimal parallel sorting on stream architectures. In: PDP, pp. 10-pp. IEEE (2006)

    Google Scholar 

  16. Habermann, A.: Parallel Neighbor Sort. Computer Science Report. Carnegie-Mellon University, Pittsburgh (1972)

    Google Scholar 

  17. 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

    Chapter  Google Scholar 

  18. Kipfer, P., Westermann, R.: Improved GPU sorting. GPU Gems 2, 733–746 (2005)

    Google Scholar 

  19. Merrill, D.G., Grimshaw, A.S.: Revisiting sorting for GPGPU stream architectures. In: PACT, pp. 545–546 (2010)

    Google Scholar 

  20. Peters, T.: Timsort (2002). https://bugs.python.org/file4451/timsort.txt

  21. Satish, N., Harris, M., Garland, M.: Designing efficient sorting algorithms for manycore GPUs. In: PDP, pp. 1–10. IEEE (2009)

    Google Scholar 

  22. Schoolderman, M.: Verification of Goroutines using Why3. Master’s thesis, Institute for Computing and Information Sciences, RU Nijmegen (2016)

    Google Scholar 

  23. Sintorn, E., Assarsson, U.: Fast parallel GPU-sorting using a hybrid algorithm. J. Parallel Distrib. Comput. 68(10), 1381–1388 (2008)

    Article  Google Scholar 

  24. Tafat, A., Marché, C.: Binary heaps formally verified in Why3. Research Report RR-7780, INRIA (October 2011). https://hal.inria.fr/inria-00636083

  25. 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

Download references

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Mohsen Safari .

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2020 Springer Nature Switzerland AG

About this paper

Check for updates. Verify currency and authenticity via CrossMark

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)

Publish with us

Policies and ethics