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).
Similar content being viewed by others
Notes
We refer the reader to [22] for definition of such data structure.
Order simplices, order and chain polytopes of signatures defined here are particular cases of Stanley’s order and chain polytopes of posets [31].
Alternatively \(\mathtt {sg}(\varvec{\nu })\mathop {=}\limits ^{\tiny {\text {def}}}\mathtt {sg}(\Pi (\varvec{\nu }))\) (defined also when some coordinates are equal).
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.
We refer the reader to [3] for a standard approach of timed automata theory.
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.
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.
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
Asarin, E., Basset, N., Degorre, A.: Entropy of regular timed languages. Inf. Comput. 241, 142–176 (2015)
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)
Alur, R., Dill, D.L.: A theory of timed automata. Theor. Comput. Sci. 126(2), 183–235 (1994)
Basset, N.: Volumetry of timed languages and applications. Ph.D. thesis, Université Paris-Est (2013)
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)
Bernardi, O., Giménez, O.: A linear algorithm for the random sampling from regular languages. Algorithmica 62(1–2), 130–145 (2012)
Bouyer, P., Petit, A.: A Kleene/Büchi-like theorem for clock languages. J. Automata Lang. Combinatorics 7(2), 167–186 (2002)
Bodini, O., Ponty, Y.: Multi-dimensional Boltzmann sampling of languages. DMTCS Proc. 01, 49–64 (2010)
Cai, J.: Computing Jordan normal forms exactly for commuting matrices in polynomial time. Int. J. Found. Comput. Sci. 5(3/4), 293–302 (1994)
Cormen, T.H., Leiserson, C.E., Rivest, R.L., Stein, C.: Introduction to Algorithms, 3rd edn. MIT Press, Cambridge (2009)
De Bruijn, N.G.: Permutations with given ups and downs. Nieuw Archief voor Wiskunde 18(3), 61–65 (1970)
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)
Denise, A., Zimmermann, P.: Uniform random generation of decomposable structures using floating-point arithmetic. Theor. Comput. Sci. 218(2), 233–248 (1999)
Ehrenborg, R., Jung, J.: Descent pattern avoidance. Adv. Appl. Math. 49(3–5), 375–390 (2012)
Ehrenborg, R., Kitaev, S., Perry, P.: A spectral approach to consecutive pattern-avoiding permutations. J. Combinatorics 2(3), 305–353 (2011)
Elizalde, S., Noy, M.: Consecutive patterns in permutations. Adv. Appl. Math. 30(1), 110–125 (2003)
Flajolet, P., Sedgewick, R.: Analytic Combinatorics. Cambridge University Press, New York (2009)
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)
Hibi, T., Li, N.: Unimodular equivalence of order and chain polytopes. ar**v preprint ar**v:1208.4029, (2012)
Kalorkoti, K.: Inverting polynomials and formal power series. SIAM J. Comput. 22(3), 552–559 (1993)
Kitaev, S.: Patterns in Permutations and Words. Springer, New York (2011)
Lothaire, M.: Applied Combinatorics on Words (Encyclopedia of Mathematics and its Applications). Cambridge University Press, New York (2005)
Luck, J.-M.: On the frequencies of patterns of rises and falls. Phys. A: Stat. Mech. Appl. 407, 252–275 (2014)
Marchal, P.: Permutations with a prescribed descent set. Preprint hal-00944244, https://hal.archives-ouvertes.fr/hal-00944244, (February 2014)
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)
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)
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)
Ouaknine, J., Pinto, J.S., Worrell, J.: The polyhedral escape problem is decidable. ar**v preprint ar**v:1507.03166, (2015)
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)
Stein, W.A. et al.: Sage Mathematics Software. The Sage Development Team, 2015. http://www.sagemath.org
Stanley, R.P.: Two poset polytopes. Disc. Comput. Geometry 1(1), 9–23 (1986)
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)
SymPy Development Team. SymPy: Python library for symbolic mathematics, (2014)
Viennot, G.: Permutations ayant une forme donnée. Discrete Mathematics 26(3), 279–284 (1979)
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
Corresponding author
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
About this article
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
Received:
Accepted:
Published:
Issue Date:
DOI: https://doi.org/10.1007/s00453-016-0136-9