Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
skip to main content
article

All sorts of permutations (functional pearl)

Published: 04 September 2016 Publication History

Abstract

The combination of non-determinism and sorting is mostly associated with permutation sort, a sorting algorithm that is not very useful for sorting and has an awful running time. In this paper we look at the combination of non-determinism and sorting in a different light: given a sorting function, we apply it to a non-deterministic predicate to gain a function that enumerates permutations of the input list. We get to the bottom of necessary properties of the sorting algorithms and predicates in play as well as discuss variations of the modelled non-determinism. On top of that, we formulate and prove a theorem stating that no matter which sorting function we use, the corresponding permutation function enumerates all permutations of the input list. We use free theorems, which are derived from the type of a function alone, to prove the statement.

References

[1]
S. Antoy and M. Hanus. New Functional Logic Design Patterns. WFLP’11, pages 19–34. Springer LNCS 6816, 2011.
[2]
Nils Anders Danielsson, John Hughes, Patrik Jansson, and Jeremy Gibbons. Fast and Loose Reasoning is Morally Correct. POPL’06, pages 206–217. ACM, 2006.
[3]
Sebastian Fischer and Jan Christiansen. Curry mailing list, July 2009.
[4]
Michael Hanus. The Integration of Functions into Logic Programming: From Theory to Practice. Journal of Logic Programming, pages 583– 628, 1994.
[5]
Selmer M Johnson. Generation of Permutations by Adjacent Transposition. Mathematics of computation, pages 282–285, 1963.
[6]
Sheng Liang, Paul Hudak, and Mark Jones. Monad Transformers and Modular Interpreters. In Proceedings of the 22nd ACM SIGPLANSIGACT symposium on Principles of programming languages, pages 333–343. ACM, 1995.
[7]
Colin L Mallows. Patience Sorting. SIAM review, 1963.
[8]
George Pollard, Sebastian Fischer, Ganesh Sittampalam, and Ryan Ingram. Haskell mailing list, July 2009.
[9]
H. F. Trotter. Algorithm 115: Perm. Commun. ACM, pages 434–435, 1962.
[10]
Twan van Laarhoven et al. Haskell mailing list, December 2007.
[11]
Philip Wadler. Theorems for Free! FPCA’89, pages 347–359. ACM, 1989.

Cited By

View all
  • (2023)Equality Saturation Theory Exploration à la CarteProceedings of the ACM on Programming Languages10.1145/36228347:OOPSLA2(1034-1062)Online publication date: 16-Oct-2023
  • (2023)Pure strategy Nash equilibria for bargaining models of collective choiceInternational Journal of Game Theory10.1007/s00182-023-00882-z53:2(373-421)Online publication date: 27-Nov-2023

Recommendations

Comments

Information & Contributors

Information

Published In

cover image ACM SIGPLAN Notices
ACM SIGPLAN Notices  Volume 51, Issue 9
ICFP '16
September 2016
501 pages
ISSN:0362-1340
EISSN:1558-1160
DOI:10.1145/3022670
Issue’s Table of Contents
  • cover image ACM Conferences
    ICFP 2016: Proceedings of the 21st ACM SIGPLAN International Conference on Functional Programming
    September 2016
    501 pages
    ISBN:9781450342193
    DOI:10.1145/2951913
Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than the author(s) must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected].

Publisher

Association for Computing Machinery

New York, NY, United States

Publication History

Published: 04 September 2016
Published in SIGPLAN Volume 51, Issue 9

Check for updates

Author Tags

  1. Haskell
  2. free theorems
  3. monads
  4. non-determinism
  5. permutation
  6. sorting

Qualifiers

  • Article

Contributors

Other Metrics

Bibliometrics & Citations

Bibliometrics

Article Metrics

  • Downloads (Last 12 months)12
  • Downloads (Last 6 weeks)5
Reflects downloads up to 25 Feb 2025

Other Metrics

Citations

Cited By

View all
  • (2023)Equality Saturation Theory Exploration à la CarteProceedings of the ACM on Programming Languages10.1145/36228347:OOPSLA2(1034-1062)Online publication date: 16-Oct-2023
  • (2023)Pure strategy Nash equilibria for bargaining models of collective choiceInternational Journal of Game Theory10.1007/s00182-023-00882-z53:2(373-421)Online publication date: 27-Nov-2023

View Options

Login options

View options

PDF

View or Download as a PDF file.

PDF

eReader

View online with eReader.

eReader

Figures

Tables

Media

Share

Share

Share this Publication link

Share on social media