Log in

Counting and Generating Permutations in Regular Classes

  • Published:
Algorithmica Aims and scope Submit manuscript

Abstract

The signature of a permutation \(\sigma \) is a word \(\mathtt {sg}(\sigma )\subseteq \{\mathfrak {a},\mathfrak {d}\}^*\) with ith letter \(\mathfrak {d}\) when \(\sigma \) has a descent [i.e. \(\sigma (i)>\sigma (i+1)\)] and \(\mathfrak {a}\) when \(\sigma \) has an ascent [i.e. \(\sigma (i)<\sigma (i+1)\)]. The combinatorics of permutations with a prescribed signature is quite well explored. Here we introduce regular classes of permutations, the sets \(\varLambda (L)\) of permutations with signature in regular languages \(L\subseteq \{\mathfrak {a},\mathfrak {d}\}^*\). Given a regular class of permutations we (i) count the permutations of a given length within the class; (ii) compute a closed form formula for the exponential generating function; and (iii) sample uniformly at random the permutation of a given length. We first recall how (i) is solved in the literature for the case of a single signature. We then explain how to extend these methods to regular classes of permutations using language equations from automata theory. We give two methods to solve (ii) in terms of exponentials of matrices. For the third problem we provide both discrete and continuous recursive methods as well as an extension of Boltzmann sampling to uncountable union of sets parametrised by a variable ranging over an interval. Last but not least, a part of our contributions are based on a geometric interpretation of a subclass of regular timed languages (that is, recognised by timed automata specific to our problem).

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

Access this article

Subscribe and save

Springer+ Basic
EUR 32.99 /Month
  • Get 10 units per month
  • Download Article/Chapter or Ebook
  • 1 Unit = 1 Article or 1 Chapter
  • Cancel anytime
Subscribe now

Buy Now

Price includes VAT (Germany)

Instant access to the full article PDF.

Fig. 1
Fig. 2
Fig. 3
Fig. 4
Fig. 5

Similar content being viewed by others

Notes

  1. We refer the reader to [22] for definition of such data structure.

  2. In fact, one could also write language equations with letters added on the right; but, this would introduce inconsistency with timed language and volume equations of our previous work [1, 2] (used in Sect. 4) that can only be written with operations on the left.

  3. Order simplices, order and chain polytopes of signatures defined here are particular cases of Stanley’s order and chain polytopes of posets [31].

  4. Alternatively \(\mathtt {sg}(\varvec{\nu })\mathop {=}\limits ^{\tiny {\text {def}}}\mathtt {sg}(\Pi (\varvec{\nu }))\) (defined also when some coordinates are equal).

  5. Indeed, this example can be obtained from an example of [23] by taking only the even-length permutations. We discovered this by looking at the OEIS sequence A005981.

  6. We refer the reader to [3] for a standard approach of timed automata theory.

  7. A reader acquainted with timed automata would have noticed that the clock language \(\mathcal {L}(\mathfrak {a})\) (resp. \(\mathcal {L}(\mathfrak {d})\)) corresponds to a transition of a timed automaton where the guards \(x^\mathfrak {a}\le 1\) and \(x^\mathfrak {d}\le 1\) are satisfied and where \(x^\mathfrak {d}\) (resp. \(x^\mathfrak {a}\)) is reset.

  8. The unique permutation on the empty set has no signature and thus \(\mathfrak {S}_0\not \subseteq \varLambda (L)\) for any language L of signature.

  9. We used the computer algebra software Sage [30] and the simplification method of Sympy [33].

  10. In fact, simple binary search tree suffices starting with a tree of height \(O(\log n )\). Indeed deletion can be achieved at a cost of the height of the tree and without increasing it so that it remains bounded by \(O(\log n)\).

References

  1. Asarin, E., Basset, N., Degorre, A.: Entropy of regular timed languages. Inf. Comput. 241, 142–176 (2015)

    Article  MathSciNet  MATH  Google Scholar 

  2. Asarin, E., Basset, N., Degorre, A., Perrin, D.: Generating functions of timed languages. In: Rovan, B., Sassone, V., Widmayer, P., (eds.) Mathematical Foundations of Computer Science 2012—37th International Symposium, MFCS 2012, Bratislava, Slovakia, August 27–31, 2012. Proceedings, Volume 7464 of Lecture Notes in Computer Science, pp. 124–135. Springer (2012)

  3. Alur, R., Dill, D.L.: A theory of timed automata. Theor. Comput. Sci. 126(2), 183–235 (1994)

    Article  MathSciNet  MATH  Google Scholar 

  4. Basset, N.: Volumetry of timed languages and applications. Ph.D. thesis, Université Paris-Est (2013)

  5. Basset, N.: Counting and generating permutations using timed languages. In: Pardo, A., Viola, A., (eds.) LATIN 2014: Theoretical Informatics - 11th Latin American Symposium, Montevideo, Uruguay, March 31–April 4, 2014. Proceedings, Volume 8392 of Lecture Notes in Computer Science, pp. 502–513. Springer (2014)

  6. Bernardi, O., Giménez, O.: A linear algorithm for the random sampling from regular languages. Algorithmica 62(1–2), 130–145 (2012)

    Article  MathSciNet  MATH  Google Scholar 

  7. Bouyer, P., Petit, A.: A Kleene/Büchi-like theorem for clock languages. J. Automata Lang. Combinatorics 7(2), 167–186 (2002)

    MathSciNet  MATH  Google Scholar 

  8. Bodini, O., Ponty, Y.: Multi-dimensional Boltzmann sampling of languages. DMTCS Proc. 01, 49–64 (2010)

    MathSciNet  Google Scholar 

  9. Cai, J.: Computing Jordan normal forms exactly for commuting matrices in polynomial time. Int. J. Found. Comput. Sci. 5(3/4), 293–302 (1994)

    Article  MATH  Google Scholar 

  10. Cormen, T.H., Leiserson, C.E., Rivest, R.L., Stein, C.: Introduction to Algorithms, 3rd edn. MIT Press, Cambridge (2009)

    MATH  Google Scholar 

  11. De Bruijn, N.G.: Permutations with given ups and downs. Nieuw Archief voor Wiskunde 18(3), 61–65 (1970)

    MathSciNet  MATH  Google Scholar 

  12. Duchon, P., Flajolet, P., Louchard, G., Schaeffer, G.: Boltzmann samplers for the random generation of combinatorial structures. Combinatorics Prob. Comput. 13(4–5), 577–625 (2004)

    Article  MathSciNet  MATH  Google Scholar 

  13. Denise, A., Zimmermann, P.: Uniform random generation of decomposable structures using floating-point arithmetic. Theor. Comput. Sci. 218(2), 233–248 (1999)

    Article  MathSciNet  MATH  Google Scholar 

  14. Ehrenborg, R., Jung, J.: Descent pattern avoidance. Adv. Appl. Math. 49(3–5), 375–390 (2012)

    Article  MathSciNet  MATH  Google Scholar 

  15. Ehrenborg, R., Kitaev, S., Perry, P.: A spectral approach to consecutive pattern-avoiding permutations. J. Combinatorics 2(3), 305–353 (2011)

    Article  MathSciNet  MATH  Google Scholar 

  16. Elizalde, S., Noy, M.: Consecutive patterns in permutations. Adv. Appl. Math. 30(1), 110–125 (2003)

    Article  MathSciNet  MATH  Google Scholar 

  17. Flajolet, P., Sedgewick, R.: Analytic Combinatorics. Cambridge University Press, New York (2009)

    Book  MATH  Google Scholar 

  18. Flajolet, P., Zimmerman, P., Van Cutsem, B.: A calculus for the random generation of labelled combinatorial structures. Theor. Comput. Sci. 132(1), 1–35 (1994)

    Article  MathSciNet  MATH  Google Scholar 

  19. Hibi, T., Li, N.: Unimodular equivalence of order and chain polytopes. ar**v preprint ar**v:1208.4029, (2012)

  20. Kalorkoti, K.: Inverting polynomials and formal power series. SIAM J. Comput. 22(3), 552–559 (1993)

    Article  MathSciNet  MATH  Google Scholar 

  21. Kitaev, S.: Patterns in Permutations and Words. Springer, New York (2011)

    Book  MATH  Google Scholar 

  22. Lothaire, M.: Applied Combinatorics on Words (Encyclopedia of Mathematics and its Applications). Cambridge University Press, New York (2005)

    Book  MATH  Google Scholar 

  23. Luck, J.-M.: On the frequencies of patterns of rises and falls. Phys. A: Stat. Mech. Appl. 407, 252–275 (2014)

    Article  MathSciNet  Google Scholar 

  24. Marchal, P.: Permutations with a prescribed descent set. Preprint hal-00944244, https://hal.archives-ouvertes.fr/hal-00944244, (February 2014)

  25. Moler, C., Van Loan, C.: Nineteen dubious ways to compute the exponential of a matrix, 25 years later. SIAM Rev. 45(1), 3–49 (2003)

    Article  MathSciNet  MATH  Google Scholar 

  26. Nijenhuis, A., Wilf, H.S.: Combinatorial Algorithms for Computers and Calculators. Computer Science and Applied Mathematics. New York: Academic Press, 1978, 2nd ed., p. 1, (1978)

  27. Oudinet, J., Denise, A., Gaudel, M.-C.: A new dichotomic algorithm for the uniform random generation of words in regular languages. Theor. Comput. Sci. 502, 165–176 (2013)

    Article  MathSciNet  MATH  Google Scholar 

  28. Ouaknine, J., Pinto, J.S., Worrell, J.: The polyhedral escape problem is decidable. ar**v preprint ar**v:1507.03166, (2015)

  29. Pivoteau, C., Salvy, B., Soria, M.: Algorithms for combinatorial structures: well-founded systems and newton iterations. J. Combinatorial Theory Ser A 119(8), 1711–1773 (2012)

    Article  MathSciNet  MATH  Google Scholar 

  30. Stein, W.A. et al.: Sage Mathematics Software. The Sage Development Team, 2015. http://www.sagemath.org

  31. Stanley, R.P.: Two poset polytopes. Disc. Comput. Geometry 1(1), 9–23 (1986)

    Article  MathSciNet  MATH  Google Scholar 

  32. Stanley, R.P.: A survey of alternating permutations. In: Combinatorics and graphs, volume 531 of Contemporary Mathematics, pp. 165–196. American Mathematical Society, Providence, (2010)

  33. SymPy Development Team. SymPy: Python library for symbolic mathematics, (2014)

  34. Viennot, G.: Permutations ayant une forme donnée. Discrete Mathematics 26(3), 279–284 (1979)

    Article  MathSciNet  MATH  Google Scholar 

Download references

Acknowledgments

We thank Jean-Marc Luck and Philippe Marchal for fruitful discussions during the event ALEA 2014. In particular, we acknowledge Philippe Marchal for sharing the remark that, for the classical case of single signature, discrete recursive methods for sampling can be derived from discrete recursive equations on cardinalities.

We acknowledge James Worrell and Joël Ouaknine for sharing their knowledge on exponential polynomials and algebraic number theory needed in Sect. 4.4.2.

Last but not least, we acknowledge Eugène Asarin for his very helpful comments on preliminary versions of this work.

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Nicolas Basset.

Additional information

This research is supported in part by ERC Advanced Grant VERIWARE and was also supported by the ANR project EQINOCS (ANR-11-BS02-004).

Rights and permissions

Reprints and permissions

About this article

Check for updates. Verify currency and authenticity via CrossMark

Cite this article

Basset, N. Counting and Generating Permutations in Regular Classes. Algorithmica 76, 989–1034 (2016). https://doi.org/10.1007/s00453-016-0136-9

Download citation

  • Received:

  • Accepted:

  • Published:

  • Issue Date:

  • DOI: https://doi.org/10.1007/s00453-016-0136-9

Keywords

Navigation