arXiv++ Combinatorics

Browse math.CO papers from arXiv

context-free grammar

38 papers tagged with this keyword
2026-07-19
The Grammatical Calculus
We give an introduction to the grammatical calculus, which originated from the umbral calculus of Rota. Context-free grammars arise in computer science. Differential operators can be viewed as the production rules of context-free grammars. By the properties of differential operators, we may perform the grammatical calculus on a rigorous basis, for the purposes of deriving combinatorial identities and computing generating functions. A grammatical labeling serves as a bridge between a combinatorial structure and the grammar. A grammar may be instrumental in constructing a bijection between two combinatorial structures sharing the same grammar. Such a bijection is called a grammar assisted bijection. Many combinatorial structures admit recursive constructions that are context-free in some sense, such as those corresponding to the Eulerian polynomials, Bell polynomials, the Ramanujan polynomials and the Narayana polynomials.
2026-05-21
Combinatorics and Asymptotics of Positive Systems of Linear Catalytic Equations
We provide a complete combinatorial and asymptotic analysis of positive linear systems of equations in one catalytic variable that appear in several combinatorial problems such as in lattice path counting or stack-sortable permutation counting. We show that the corresponding generating functions satisfy a positive polynomial system of equations (which is associated to a context-free grammar). Furthermore we prove a universal asymptotic behaviour.
2026-04-27
$q$-Derivative Grammar
The concept of context-free grammar in Combinatorics was first introduced by Chen in 1993. In 1996, Dumont significantly extended the theory of context-free grammars to a variety of other combinatorial models. Substantial progress in this direction has been achieved over the last decade. In this paper, we introduce a $q$-analogue of context-free grammars, which we call the $q$-derivative grammar. We establish the basic framework of $q$-grammars and develop the $q$-grammar calculus for computing $q$-exponential generating functions associated with $q$-grammars. Concrete $q$-grammars are constructed to study $q$-Eulerian, $q$-Roselle and $q$-André polynomials, including their generating functions and recurrences. This work extends the grammatical method to the $q$-setting and opens up new research directions.
2026-01-04
From Historical Puzzles to Grammatical Constraints: Circular Partitions, Generalized Run-Length Encodings, and Polynomial-Time Decidability
Motivated by a historical combinatorial problem that resembles the well-known Josephus problem, we investigate circular partition algorithms and formulate problems in deterministic finite automata with practical algorithms. The historical problem involves arranging individuals on a circle and eliminating every k-th person until a desired group remains. We analyze both removal and non-removal approaches to circular partitioning, establishing conditions for balanced partitions and providing explicit algorithms. We introduce generalized run-length encodings over partitioned alphabets to capture alternating letter patterns, computing their cardinalities using Stirling numbers of the second kind. Connecting these combinatorial structures to formal language theory, we formulate an existence problem: given a context-free grammar over a dictionary and block-pattern constraints on letters, does a valid sentence exist? We prove decidability in polynomial time by showing block languages are regular and applying standard parsing techniques. Complete algorithms with complexity analysis are provided and validated through implementation on both historical and synthetic instances.
Triangular Arrays using context-free grammar
In this work, the grammar of Hao \[ G=\{\, u\rightarrow u^{b_1+b_2+1} v^{a_1+a_2},\quad v\rightarrow u^{b_2}v^{a_2+1} \,\}, \] together with the correspondence between grammars and Combinatorial Differential Equations, is employed to obtain an interpretation of any triangular array of the form \[ T(n,k)=(a_2 n + a_1 k + a_0)\,T(n-1,k) + (b_2 n + b_1 k + b_0)\,T(n-1,k-1). \] Explicit formulas and structural properties are then derived through Analytic Differential Equations. In particular, the $r$-Whitney--Eulerian numbers and the cases where $b_2n+b_1k+b_0=1$ are obtained explicitly. Applications include new interpretation formulas for the $r$-Eulerian numbers with generating function for a special case. Keywords: triangular recurrence, formal grammar, Combinatorial operators, differential equations,$r$-Eulerian, combinatorial interpretation, $r$-Whitney--Eulerian.
2024-05-08
On vector parking functions and q-analogue
In 2000, it was demonstrated that the set of $x$-parking functions of length $n$, where $x$=($a,b,...,b$) $\in \mathbbm{N}^n$, is equivalent to the set of rooted multicolored forests on [$n$]=\{1,...,$n$\}. In 2020, Yue Cai and Catherine H. Yan systematically investigated the properties of rational parking functions. Subsequently, a series of Context-free grammars possessing the requisite property were introduced by William Y.C. Chen and Harold R.L. Yang in 2021. %An Abelian-type identity is derived from a comparable methodology and grammatical framework. %Leveraging a comparable methodology and grammatical framework, an Abelian-type identity is derived herein. In this paper, I discuss generalized parking functions in terms of grammars. The primary result is to obtain the q-analogue about the number of '1's in certain vector parking functions with the assistance of grammars.
2024-04-15
A $q$-analog of the Stirling-Eulerian Polynomials
In 1974, Carlitz and Scoville introduced the Stirling-Eulerian polynomial $A_n(x,y|α,β)$ as the enumerator of permutations by descents, ascents, left-to-right maxima and right-to-left maxima. Recently, Ji considered a refinement of $A_n(x,y|α,β)$, denoted $P_n(u_1,u_2,u_3,u_4|α,β)$, which is the enumerator of permutations by valleys, peaks, double ascents, double descents, left-to-right maxima and right-to-left maxima. Using Chen's context-free grammar calculus, Ji proved a formula for the generating function of $P_n(u_1,u_2,u_3,u_4|α,β)$, generalizing the work of Carlitz and Scoville. Ji's formula has many nice consequences, one of which is an intriguing $γ$-positivity expansion for $A_n(x,y|α,β)$. In this paper, we prove a $q$-analog of Ji's formula by using Gessel's $q$-compositional formula and provide a combinatorial approach to her $γ$-positivity expansion of $A_n(x,y|α,β)$.
2024-03-22 v2
Stable multivariate Narayana polynomials and labeled plane trees
In this paper, we introduce stable multivariate generalizations of Narayana polynomials of type A and type B. We give an insertion algorithm for labeled plane trees and introduce the notion of improper edges. Our polynomials are multivariate generating polynomials of labeled plane trees and can be generated by a grammatical labeling based on a context-free grammar. Our proof of real stability uses a characterization of stable-preserving linear operators due to Borcea and Brändén. In particular, we get an alternative multivariate stable refinement of the second-order Eulerian polynomials, which is different from the one given by Haglund and Visontai.
2023-12-05
Differential operators, grammars and Young tableaux
In algebraic combinatorics and formal calculation, context-free grammar is defined by a formal derivative based on a set of substitution rules. In this paper, we investigate this issue from three related viewpoints. Firstly, we introduce a differential operator method. As one of the applications, we deduce a new grammar for the Narayana polynomials. Secondly, we investigate the normal ordered grammars associated with the Eulerian polynomials. Thirdly, motivated by the theory of differential posets, we introduce a box sorting algorithm which leads to a bijection between the terms in the expansion of $(cD)^nc$ and a kind of ordered weak set partitions, where $c$ is a smooth function in the indeterminate $x$ and $D$ is the derivative with respect to $x$. Using a map from ordered weak set partitions to standard Young tableaux, we find an expansion of $(cD)^nc$ in terms of standard Young tableaux. Combining this with the theory of context-free grammars, we provide a unified interpretations for the Ramanujan polynomials, André polynomials, left peak polynomials, interior peak polynomials, Eulerian polynomials of types $A$ and $B$, $1/2$-Eulerian polynomials, second-order Eulerian polynomials, and Narayana polynomials of types $A$ and $B$ in terms of standard Young tableaux. Along the same lines, we present an expansion of the powers of $c^kD$ in terms of standard Young tableaux, where $k$ is a positive integer. In particular, we provide four interpretations for the second-order Eulerian polynomials. All of the above apply to the theory of formal differential operator rings.
2022-10-22 v2
A Grammatical Calculus for Peaks and Runs of Permutations
Published • View PublicationBIB
We develop a nonstandard approach to exploring polynomials associated with peaks and runs of permutations. With the aid of a context-free grammar, or a set of substitution rules, one can perform a symbolic calculus, and the computation often becomes rather simple. From a grammar it follows at once a system of ordinary differential equations for the generating functions. Utilizing a certain constant property, it is even possible to deduce a single equation for each generating function. To bring the grammar to a combinatorial setting, we find a labeling scheme for up-down runs of a permutation, which can be regarded as a refined property, or the differentiability in a certain sense, in contrast to the usual counting argument for the recurrence relation. The labeling scheme also exhibits how the substitution rules arise in the construction of the combinatorial structures. Consequently, polynomials on peaks and runs can be dealt with in two ways, combinatorially or grammatically. The grammar also serves as a guideline to build a bijection between permutations and increasing trees that maps the number of up-down runs to the number of nonroot vertices of even degree. This correspondence can be adapted to left peaks and exterior peaks, and the key step of the construction is called the reflection principle.
2022-04-04 v3
The Dumont Ansatz for the Eulerian Polynomials, Peak Polynomials and Derivative Polynomials
Published • View PublicationBIB
We observe that three context-free grammars of Dumont can be brought to a common ground, via the idea of transformations of grammars, proposed by Ma-Ma-Yeh. Then we develop a unified perspective to investigate several combinatorial objects in connection with the bivariate Eulerian polynomials. We call this approach the Dumont ansatz. As applications, we provide grammatical treatments, in the spirit of the symbolic method, of relations on the Springer numbers, the Euler numbers, the three kinds of peak polynomials, an identity of Petersen, and the two kinds of derivative polynomials, introduced by Knuth-Buckholtz and Carlitz-Scoville, and later by Hoffman in a broader context. We obtain a convolution formula on the left peak polynomials, leading to the Gessel formula. In this framework, we are led to the combinatorial interpretations of the derivative polynomials due to Josuat-Vergès.
2022-02-17 v2
RePair Grammars are the Smallest Grammars for Fibonacci Words
Grammar-based compression is a loss-less data compression scheme that represents a given string $w$ by a context-free grammar that generates only $w$. While computing the smallest grammar which generates a given string $w$ is NP-hard in general, a number of polynomial-time grammar-based compressors which work well in practice have been proposed. RePair, proposed by Larsson and Moffat in 1999, is a grammar-based compressor which recursively replaces all possible occurrences of a most frequently occurring bigrams in the string. Since there can be multiple choices of the most frequent bigrams to replace, different implementations of RePair can result in different grammars. In this paper, we show that the smallest grammars generating the Fibonacci words $F_k$ can be completely characterized by RePair, where $F_k$ denotes the $k$-th Fibonacci word. Namely, all grammars for $F_k$ generated by any implementation of RePair are the smallest grammars for $F_k$, and no other grammars can be the smallest for $F_k$. To the best of our knowledge, Fibonacci words are the first non-trivial infinite family of strings for which RePair is optimal.
2021-06-16 v3
A Context-free Grammar for the $e$-Positivity of the Trivariate Second-order Eulerian Polynomials
Published • View PublicationBIB
Ma-Ma-Yeh made a beautiful observation that a transformation of the grammar of Dumont instantly leads to the $γ$-positivity of the Eulerian polynomials. We notice that the transformed grammar bears a striking resemblance to the grammar for 0-1-2 increasing trees also due to Dumont. The appearance of the factor of two fits perfectly in a grammatical labeling of 0-1-2 increasing plane trees. Furthermore, the grammatical calculus is instrumental to the computation of the generating functions. This approach can be adapted to study the $e$-positivity of the trivariate second-order Eulerian polynomials first introduced by Dumont in the contexts of ternary trees and Stirling permutations, and independently defined by Janson, in connection with the joint distribution of the numbers of ascents, descents and plateaux over Stirling permutations.
2020-09-18
Enumerating Restricted Dyck Paths with Context-Free Grammars
The number of Dyck paths of semilength $n$ is famously $C_n$, the $n$th Catalan number. This fact follows after noticing that every Dyck path can be uniquely parsed according to a context-free grammar. In a recent paper, Zeilberger showed that many restricted sets of Dyck paths satisfy different, more complicated grammars, and from this derived various generating function identities. We take this further, highlighting some combinatorial results about Dyck paths obtained via grammatical proof and generalizing some of Zeilberger's grammars to infinite families.
2020-05-14
Plateaux on generalized Stirling permutations and partial $γ$-positivity
We prove that the enumerative polynomials of generalized Stirling permutations by the statistics of plateaux, descents and ascents are partial $γ$-positive. Specialization of our result to the Jacobi-Stirling permutations confirms a recent partial $γ$-positivity conjecture due to Ma, Yeh and the second named author. Our partial $γ$-positivity expansion, as well as a combinatorial interpretation for the corresponding $γ$-coefficients, are obtained via the machine of context-free grammars and a group action on generalized Stirling permutations. Besides, we also provide an alternative approach to the partial $γ$-positivity from the stability of certain multivariate polynomials.
2020-02-19 v3
Comparing consecutive letter counts in multiple context-free languages
Published • View PublicationBIB
Context-free grammars are not able to model cross-serial dependencies in natural languages. To overcome this issue, Seki et al. introduced a generalization called $m$-multiple context-free grammars ($m$-MCFGs), which deal with $m$-tuples of strings. We show that $m$-MCFGs are capable of comparing the number of consecutive occurrences of at most $2m$ different letters. In particular, the language $\{a_1^{n_1} a_2^{n_2} \dots a_{k}^{n_{2m+1}} \mid n_1 \geq n_2 \geq \dots \geq n_{2m+1} \geq 0\}$ is $(m+1)$-multiple context-free, but not $m$-multiple context-free.
LinearFold: linear-time approximate RNA folding by 5'-to-3' dynamic programming and beam search
Published in Bioinformatics, Volume 35, Issue 14, July 2019, Pages i295--i304 • View PublicationBIB
Motivation: Predicting the secondary structure of an RNA sequence is useful in many applications. Existing algorithms (based on dynamic programming) suffer from a major limitation: their runtimes scale cubically with the RNA length, and this slowness limits their use in genome-wide applications. Results: We present a novel alternative $O(n^3)$-time dynamic programming algorithm for RNA folding that is amenable to heuristics that make it run in $O(n)$ time and $O(n)$ space, while producing a high-quality approximation to the optimal solution. Inspired by incremental parsing for context-free grammars in computational linguistics, our alternative dynamic programming algorithm scans the sequence in a left-to-right (5'-to-3') direction rather than in a bottom-up fashion, which allows us to employ the effective beam pruning heuristic. Our work, though inexact, is the first RNA folding algorithm to achieve linear runtime (and linear space) without imposing constraints on the output structure. Surprisingly, our approximate search results in even higher overall accuracy on a diverse database of sequences with known structures. More interestingly, it leads to significantly more accurate predictions on the longest sequence families in that database (16S and 23S Ribosomal RNAs), as well as improved accuracies for long-range base pairs (500+ nucleotides apart), both of which are well known to be challenging for the current models. Availability: Our source code is available at https://github.com/LinearFold/LinearFold, and our webserver is at http://linearfold.org (sequence limit: 100,000nt).
2019-04-25 v3
The alternating run polynomials of permutations
In this paper, we first consider a generalization of the David-Barton identity which relate the alternating run polynomials to Eulerian polynomials. By using context-free grammars, we then present a combinatorial interpretation of a family of q-alternating run polynomials. Furthermore, we introduce the definition of semi-gamma-positive polynomial and we show the semi-gamma-positivity of the alternating run polynomials of dual Stirling permutations. A connection between the up-down run polynomials of permutations and the alternating run polynomials of dual Stirling permutations is established.
2018-10-05
A Context-free Grammar for the Ramanujan-Shor Polynomials
Published • View PublicationBIB
Ramanujan defined the polynomials $ψ_{k}(r,x)$ in his study of power series inversion. Berndt, Evans and Wilson obtained a recurrence relation for $ψ_{k}(r,x)$. In a different context, Shor introduced the polynomials $Q(i,j,k)$ related to improper edges of a rooted tree, leading to a refinement of Cayley's formula. He also proved a recurrence relation and raised the question of finding a combinatorial proof. Zeng realized that the polynomials of Ramanujan coincide with the polynomials of Shor, and that the recurrence relation of Shor coincides with the recurrence relation of Berndt, Evans and Wilson. So we call these polynomials the Ramanujan-Shor polynomials, and call the recurrence relation the Berndt-Evans-Wilson-Shor recursion. A combinatorial proof of this recursion was obtained by Chen and Guo, and a simpler proof was recently given by Guo. From another perspective, Dumont and Ramamonjisoa found a context-free grammar $G$ to generate the number of rooted trees on $n$ vertices with $k$ improper edges. Based on the grammar $G$, we find a grammar $H$ for the Ramanujan-Shor polynomials. This leads to a formal calculus for the Ramanujan-Shor polynomials. In particular, we obtain a grammatical derivation of the Berndt-Evans-Wilson-Shor recursion. We also provide a grammatical approach to the Abel identities and a grammatical explanation of the Lacasse identity.
2018-09-20
Joint Distributions of Permutation Statistics and the Parabolic Cylinder Functions
Published • View PublicationBIB
In this paper, we introduce a context-free grammar $G\colon x \rightarrow xy,\, y \rightarrow zu,\, z \rightarrow zw,\, w \rightarrow xv,\, u \rightarrow xyz^{-1}v,\, v \rightarrow x^{-1}zwu$ over the variable set $V=\{x,y,z,w,u,v\}$. We use this grammar to study joint distributions of several permutation statistics related to descents, rises, peaks and valleys. By considering the pattern of an exterior peak, we introduce the exterior peaks of pattern 132 and of pattern 231. Similarly, peaks can also be classified according to their patterns. Let $D$ be the formal derivative operator with respect to the grammar $G$. By using a grammatical labeling, we show that $D^n(z)$ is the generating function of the number of permutations on $[n]=\{1,2,\ldots,n\}$ with given numbers of exterior peaks of pattern 132 and of pattern 231, and proper double descents. By solving a cylinder differential equation, we obtain an explicit formula of the generating function of $D^n(z)$, which can be viewed as a unification of the results of Elizalde-Noy, Barry, Basset, Fu and Gessel. Specializations lead to the joint distributions of certain consecutive patterns in permutations, as studied by Elizalde-Noy and Kitaev. By a different labeling with respect to the same grammar $G$, we derive the joint distribution of peaks of pattern 132 and of pattern 231, double descents and double rises, with the generating function also expressed by the parabolic cylinder functions. This formula serves as a refinement of the work of Carlitz-Scoville. Furthermore, we obtain the joint distribution of exterior peaks of pattern 132 and of pattern 231 over alternating permutations.