TYPES 2004: Types for Proofs and Programs pp 82-97

# Formalising Bitonic Sort in Type Theory

• Ana Bove
• Thierry Coquand
Conference paper
Part of the Lecture Notes in Computer Science book series (LNCS, volume 3839)

## Abstract

We discuss two complete formalisations of bitonic sort in constructive type theory. Bitonic sort is one of the fastest sorting algorithms where the sequence of comparisons is not data-dependent. In addition, it is a general recursive algorithm. In the formalisation we face two main problems: only structural recursion is allowed in type theory, and a formal proof of the correctness of the algorithm needs to consider quite a number of cases. In our first formalisation we define bitonic sort over dependently-typed binary trees with information in the leaves and we make use of the 0-1-principle to prove that the algorithm sorts inputs of arbitrary types. In our second formalisation we use notions from linear orders, lattice theory and monoids. The correctness proof is directly performed for any ordered set and not only for Boolean values.

## Keywords

Distributive Lattice Linear Order Binary Tree Type Theory Algorithm Sort
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.

## References

1. 1.
2. 2.
3. 3.
Batcher, K.E.: Sorting networks and their applications. In: Spring Joint Computer Conference, AFIPS Proc., vol. 32, pp. 307–314 (1968)Google Scholar
4. 4.
Birkhoff, G.: Lattice theory. Amer. Math. Soc., Providence (1967)
5. 5.
Bove, A.: Formalising bitonic sort using dependent types. Technical Report, Chalmers University of Technology (October 2004), Available on the WWW: www.cs.chalmers.se/~bove/Papers/dt_bit_sort.ps.gz
6. 6.
Coquand, T., Huet, G.: The Calculus of Constructions. Information and Computation 76, 95–120 (1988)
7. 7.
Couturier, R.: Formal engenieering of the bitonic sort using pvs. In: 2nd. Irish Workshop on Formal Method, Cork, Ireland (1998)Google Scholar
8. 8.
Day, N.A., Launchbury, J., Lewis, J.: Logical abstractions in haskell. In: Proceedings of the 1999 Haskell Workshop, Technical Report UU-CS-1999-28 (October 1999)Google Scholar
9. 9.
10. 10.
Haiyan, Q.: Testing and Proving in Dependent Type Theory. PhD thesis, Department of Computing Science, Chalmers University of Technology (2003)Google Scholar
11. 11.
Horn, A., Tarski, A.: Measures in Boolean algebras. Trans. Amer. Math. Soc. (64), 467–497 (1948)Google Scholar
12. 12.
Peyton Jones, S. (ed.): Haskell 1998 Language and Libraries The Revised Report. Cambridge University Press, Cambridge (2003)Google Scholar
13. 13.
14. 14.
Martin-Löf, P.: Intuitionistic Type Theory. Bibliopolis, Napoli (1984)
15. 15.
Reynolds, J.C.: Types, abstraction and parametric polymorphism. In: Mason, R.E.A. (ed.) Information Processing 1983, Proceedings of the 9th IFIP World Computer Congress, Paris, France, pp. 513–523. North-Holland, Amsterdam (1983)Google Scholar
16. 16.
Rota, G.: The valuation ring of a distributive lattice. In: Proceedings of the University of Houston Lattice Theory Conference, Houston, Tex., pp. 574–628 (1973)Google Scholar
17. 17.
Rushby, J.: The pvs verification system (1998), www.csl.sri.com/pvs.html