Skip to content

Generating Functions and Singularities

October 9, 2023


Sharpening an analytic tool for regular languages

IEEE source for Book, Even, Ott photos

Ronald Book, Shimon Even, Sheila Greibach, and Gene Ott proved a fact that may escape attention nowadays. Everyone knows the equivalence of finite automata (of all major kinds) and regular expressions. But do you know that the regular expressions can be made unambiguous?

Today we explore consequences of this fact for analyzing automata via generating functions.

A regular expression {\alpha} is unambiguous if:

  1. wherever {\beta + \gamma} occurs inside {\alpha}, {L(\beta) \cap L(\gamma) = \emptyset};

  2. wherever {\beta \cdot \gamma} occurs inside {\alpha}, every string {z \in L(\beta \cdot \gamma)} can be written in exactly one way as {z = xy} with {x \in L(\beta)} and {y \in L(\gamma)};

  3. wherever {\beta^*} occurs inside {\alpha}, every {z \in L(\beta^*)} can be written in exactly one way as a concatenation of strings in {L(\beta)}.

The last clause entails in particular that the empty string cannot match {\beta} when {\beta^*} appears in {\alpha}. Since {\epsilon} is always in {L(\beta^*)}, it would have multiple “parses” if {\epsilon} matched {\beta}. The only parse we want to allow is that {\epsilon} is a concatenation of zero strings.

Is there an easy way to convert any given regular expression {\alpha} into one that is unambiguous? In senses that can be made precise in computational complexity terms, the answer is no. But we can get an equivalent unambiguous regular expression by different means.

DFAs Give Unambiguous Regexps

If we have a deterministic finite automaton {M = (Q,\Sigma,\delta,s,F)} where {F = \{q_1,q_2,\dots,q_k\}} has multiple final states, let {M_j} stand for the machine with the same code but only {q_j} as final state. Then

\displaystyle  L(M) = L(M_1) \cup L(M_2) \cup \cdots \cup L(M_k),

and moreover this union is disjoint: Because {M} is deterministic, every string {x \in L(M)} goes to exactly one of the final states {q_j}.

Hence to build an unambiguous regular expression for {M}, it suffices to build one when there is exactly one final state. First suppose that is the start state, which we number {1} and the other states {2,\dots,n}. Initialize the {n \times n} matrix {A} with {A[i,j] = c} if {M} has a transition on {c} from state {i} to state {j}; {A[i,j] = \emptyset} otherwise. The initial condition is that with {k=n}, every entry in the principal {k \times k} minor of {A} is an unambiguous regular expression. Now execute the following code:


   for (k = n; k > 2; k--)       //bypass and eliminate state k
      for (i = 1; i < k; i++)    //obviate incoming arc (i,c,k)
         for (j = 1; j < k; j++) //update transition from i to j
   
            A[i,j] = A[i,j] + A[i,k] A[k,k]* A[k,j];


The loop maintains three invariants:

  1. Computations on strings matching {A[i,j]} involve no intermediate states {< k}.

  2. All strings that take {M} from state {i} to state {j} without going through states {< k} match {A[i,j]}.

  3. {A[i,j]} is a {+} of zero or more terms having different leading characters.

If {A[i,k]} has multiple terms, we can distribute them over {A[k,k]^*\cdot A[k,j]} to preserve the second invariant. (For a binary alphabet this is not needed.) Now we verify that the regular expression {A[i,j]} remains unambiguous because:

  • The previous {A[i,j]} involved no intermediate states {< k+1}, so {k} and the character taking it there in {A[i,k]} are new.

  • {A[k,k]^*} is unambiguous because, by the second invariant, substrings matching {A[k,k]} can be uniquely parsed.

  • The {A[i,k]\cdot A[k,k]^*\cdot A[k,j]} concatenation is uniquely parsable at front and back, and does not match {\epsilon}, since {A[i,k]} and {A[k,j]} are unambiguous and do not match {\epsilon}.

On loop exit, the regular expression {A[1,1]^*} denotes {L(M)} and is unambiguous for the same reason argued for {A[k,k]^*} with {k \geq 2}. If the final state is not the start state, we can number it {2}, and then the answer is {A[1,1]^*\cdot A[1,2] \cdot A[2,2]^*}. This finishes the proof. {\Box}

The paper proves a stronger statement about preserving ambiguities. The above looks like a polynomial-time (indeed, cubic time) algorithm but is not—because the sizes of the {A[k,k]} parts in particular can compound with each step of {k}.

Generating Functions

Let us fix the binary alphabet {\Sigma = \{0,1\}}. Given any language {L} over {\Sigma}, we define the bivariate generating function

\displaystyle  f_L(x,y) = \sum_{i,j = 0}^{\infty} b_{i,j}x^i y^j,

where {b_{i,j} =} the number of strings of length {i+j} in {L} that have exactly {i} {0}s and {j} {1}s.


Note that if we identify {y = x}, then {g_L(x) = f_L(x,x)} is the more-familiar univariate generating function, whose coefficients {a_n} of {x^n} count the numbers of strings of length {n} in {L}. Philippe Flajolet and Bob Sedgewick wrote a whole free book titled Analytic Combinatorics in which these generating functions figure prominently. The main fact about {f_L(x,y)} is a simple extension of the well-known one about {g_L(x)}:

Theorem 1 If {L} is regular, then there are two polynomials {h(x,y)} and {d(x,y)} such that

\displaystyle  f_L(x,y) = \frac{h(x,y)}{d(x,y)}.

That is, the generating function of a regular language is a rational function. The converse does not hold, because there are regular and non-regular languages that have the same “census counts” {b_{i,j}.}

To prove this theorem, we start by simply associating to every regular expression {\alpha} over {\Sigma} the algebraic function {f_\alpha = f_\alpha(x,y)} given by the following recursive rules, in which the right-hand quantities are numerical:

  • {f_{\emptyset} = 0}

  • {f_{\epsilon} = 1}

  • {f_0 = x}, {f_1 = y}

  • {f_{\alpha+\beta} = f_\alpha + f_\beta}

  • {f_{\alpha\cdot\beta} = f_\alpha \cdot f_\beta}

  • {f_{\alpha^*} = \frac{1}{1 - f_\alpha} = 1 + f_\alpha + f_\alpha^2 + f_\alpha^3 + \cdots}

Clearly the function thus defined is rational. The observation that finishes the proof is:

If {\alpha} is unambiguous, then {f_\alpha} equals {f_L} where {L} is the language of {\alpha}.

That every regular language {L} has an unambiguous regular expression finishes the proof: The equality clearly holds in the base cases and for the {+} inductive case. The checks for the {\cdot} and {*} cases are straightforward from the definition of unambiguity for {\alpha}.

Machines and Invariant Denominators

Given any {n}-state DFA {M} that recognizes {L}, we can get {f_L} directly from {M}. Form the {n \times n} matrix {A_M} along lines of the regular expression matrix {A} above, but this time put an {x} for every 0-arc and a {y} for every {1}-arc. Make every other entry {0}. If {M} has more than one accepting state {t}, make a separate matrix for each such {q} and sum the results. Number the start state {s = 1} and {t = 2} (or {t=1} if {t} is the start state). Then run the same triple nested loop as before, but with the body

\displaystyle  A_M[i,j] = A_M[i,j] + \frac{A_M[i,k]\cdot A_M[k,j]}{1 - A_M[k,k]}.

The result is the generating function for the language {L_{s,t}} of strings processed from {s} to {t}. Adding them up gives {f_L}. The result {f_L} is invariant both under the ordering of states of {M} to eliminate and the choice of DFA {M} recognizing {L}—it need not be the canonical minimum one. If {M} is strongly connected, meaning that every state {p} can reach every other state {q} by some string (i.e., {L_{p,q} \neq \emptyset}), then there is a further notable invariant:

Theorem 2 If a DFA {M} is strongly connected then for all states {p} and {q}, the bivariate generating function of {L_{p,q}} is given by

\displaystyle  \frac{h_{p,q}(x,y)}{d(x,y)},

where {d(x,y) = \det(I - A_m)} and the numerator has no common divisor with {d(x,y)}.

The proof only requires analyzing the two-state case. If {M} is strongly connected, then all elimination sequences will leave a strongly connected two-state machine, meaning that both {\beta = \beta(x,y)} and {\eta = \eta(x,y)} are nonzero in the following diagram:



The generating functions shown for {L_{s,s}}, {L_{s,t}}, {L_{t,t}}, and {L_{t,s}} have the same denominator, and by {\beta,\eta \neq 0}, do not reduce further. Because {L_{s,s}} is the same whichever state of {M} is used as “{t},” we can “walk” the diagram to represent any {L_{p,q}} while preserving the denominator and the irreducibility. {\Box}

Thus {d(x,y)} is common to the whole host of DFAs defined from {M} by changing the start state and/or the set of final states. It is an invariant of the two-sorted graph {G_M = (V,E_0,E_1)}, whose edge sets of {0}-arcs and {1}-arcs each have out-degree {1}.

Singular Sets

The zeroes of the polynomial {d(x,y)} form an algebraic set and are singularities of the generating function. Adopting the looser nomenclature by which a “variety” is allowed to be algebraically reducible, we propose calling the zero set {S_M} the singular variety of {M}. It is really an invariant of the two-sorted graph {G_M}. Here are pictures for all automata of one or two nodes. The pictures are plotted in the real plane using the Desmos Graphing Calculator.




The line {x+y=1} is always present, simply because substituting {y = x-1} makes {A_M} into a stochastic matrix. The other parts of {S_M} hold the most interest.

What does {S_M} represent? Intuitively, it captures information about the cycle structure of {M}. Whether it captures enough information is perhaps doubted by the last example, whose {S_M} is the same as for the one-state machine. The full generating function {f_L} for {L = L_{s,s} = (1 + 00^*1)^*} is computed via

\displaystyle  \frac{1}{1 - \left(y + \frac{xy}{1-x}\right)} = \frac{1-x}{1 - x - y +xy - xy} = \frac{1-x}{1 - x - y}.


Some three-state automata exhibit other interesting behaviors. The two in the middle should be plotted in the complex plane.



Intersecting {S_M} with the line {x = y} gives the singular points of {g_L(x)}, which figure highly in analytical results collected in the book by Flajolet and Sedgewick and in some more recent references. We anticipate higher returns from analysis of {f_L(x,y)} by bringing in more techniques from algebraic geometry.

Open Problems

Have you seen this two-variable generating function for regular languages? What can be done with it?


[added note about why {x+y=1} is always present]

2023 NAE Meeting

September 27, 2023


With a memorial to William Wulf

Anita Jones will be attending the next 2023 National Academy of Engineering’s annual meeting in Washington DC. Kathryn and I will travel there this weekend. Here is a photo of her winning the Philip Hauge Abelson award in 2012, the top honor of the American Association for the Advancement of Science. (The JFIF original there is sharper; see this for why.)


Read more…

Four and More Colors of Mathematics

September 18, 2023


A memorial to Wolfgang Haken (1928–2022) and more in the AMS Notices

This month’s Notices of the American Mathematical Society for October 2023 has just been mailed to me.

This issue is special in several ways:

  1. It is large and thick with many pages;
  2. It has a lot of technical material on decision procedures;
  3. It has both a feature and a memorial for Wolfgang Haken, who passed away late last year.

Read more…

2023 NAE Meeting

September 12, 2023


One of the new members they will welcome

Telle Whitney has just been selected to be a new member of the National Academy of Engineering. I will see her at the next 2023 National Academy of Engineering’s annual meeting—where she will be admitted to the NAE.

Congrats to Telle on being selected to the join the NAE this year.

her website

Read more…

Happy Birthday 77

September 6, 2023


With brief musings on AI and the blog

Richard Lipton has turned 77 today. He and Kathryn are back in Manhattan after spending much of the summer in Harbor Springs, Michigan. The original for the photo at right was taken from the local newspaper there.

Today I am delighted to wish Dick a happy birthday and riff a little on “artificial existentialism.”
Read more…

Congrats to Three Colleagues

August 30, 2023


And a fourth

Composite crop of src1, src2, src3

Vinod Vaikuntanathan and Santosh Vempala and Virginia Williams have a common thread. No, it’s not that they all have a name that starts with a V. Yes, they all are at an institute that is of the form:

X Institute of Technology

But it is really that they all have made important contributions to theory. The Simons Foundation has selected them as winners of the 2023 awards in theory.

They are at the end of the overall list of winners for 2023. No, it’s not because they have names that start with V, V, and W. Yes, it’s because the winners in each field are grouped together and theory comes last.

The Winners

Here are the citations for the three in Theoretical Computer Science:

  • Vinod Vaikuntanathan, Massachusetts Institute of Technology: Vinod Vaikuntanathan’s research is in the foundations of cryptography and its applications to theoretical computer science at large. He is known for his work on fully homomorphic encryption, a powerful cryptographic primitive that enables complex computations on encrypted data, as well as lattice-based cryptography, which lays down a new mathematical foundation for cryptography in the post-quantum world. Recently, he has been interested in the interactions of cryptography with quantum computing, as well as with statistics and machine learning.

  • Santosh Vempala, Georgia Institute of Technology: Santosh Vempala has made fundamental advances in the theory of algorithms: for sampling high-dimensional distributions, computing the volume of a convex body, optimization over convex sets, randomized matrix approximation, as well as basic problems in machine learning. In many cases, these were the first polynomial-time algorithms and co-evolved with insights into high-dimensional geometry and probability. Recent highlights include proving that sufficiently sparse linear systems can be solved faster than matrix multiplication ({Ax=b}, the workhorse of modern computation); extending sampling methods to non-Euclidean (Riemannian) geometries to make them faster (leading to practical methods in very high dimension); pioneering techniques for algorithmic robust statistics (immune to adversarial corruptions); and developing a rigorous theory of computation and learning in the brain in a biologically plausible model (how does the mind emerge from neurons and synapses?). He continues to be puzzled by whether an unknown polytope can be learned in polytime from samples, whether its diameter is bounded by a polynomial in its description length, whether its volume can be computed in polytime without randomization, and whether the answers to these questions will be discovered by humans or by AI.

  • Virginia Williams, Massachusetts Institute of Technology: Virginia Vassilevska Williams’ research is broadly in theoretical computer science, and more specifically in designing algorithms for graphs and matrices, and uncovering formal relationships between seemingly very different computational problems. She is known for her work on fast matrix multiplication, both in co-developing the world’s fastest algorithm and in proving limitations on the known techniques for designing matrix multiplication algorithms. Williams is also one of the original founders and leaders of fine-grained complexity, a blossoming new branch of computational complexity.

One More Makes Four

The areas of the other winners are: Mathematics, Physics, Theoretical Physics in Life Sciences, and Astrophysics. One of the winners in plain-vanilla Physics is another old friend:

  • Aram Harrow, Massachusetts Institute of Technology: Aram Harrow studies quantum computing and information. He works to understand the capabilities of the quantum computers and quantum communication devices we will build in the future, and in the process, he creates connections to other areas of theoretical physics, mathematics and computer science. He has developed quantum algorithms for solving large systems of linear equations and hybrid classical-quantum algorithms for machine learning. Harrow has also contributed to the intersection of quantum information and many-body physics, with work on thermalization, random quantum dynamics, and the “monogamy” property of quantum entanglement.

src

We interacted with Aram through almost the entire year 2012 as we hosted an eightpart debate between him and Gil Kalai on the scalability of universal quantum computing.

In his own work, one of the things he is famous for is the HHL algorithm with Avinatan Hassidim and Seth Lloyd. We covered it in a 2019 post. This is mainly what the line that he “has developed quantum algorithms for solving large systems of linear equations” is referring to.

Now wait a second: this is just the same thing as solving {Ax=b}. The citation above for Vempala calls that—in its classical setting—“the workhorse of modern computation.” If that’s so, then what to call the quantum {Ax=b}? Note that the quantum {Ax=b} is only approximate, and comes with other caveats.

Should quantum {Ax=b} be called “the unicorn of modern computation?”

All kidding aside, we congratulate Aram on this award.

Open Problems

And our congrats to all the award winners in all areas.

The Distributed Prize

August 24, 2023


And a ‘new’ computing ‘blog’ with over 1,300 sizable ‘posts’ unearthed

Edsger Dijkstra contributed to many aspects of computing. His name is attached to Dijkstra’s Algorithm, of course, but his 1972 Turing Award citation does not mention it. His 1974 paper on self-stabilization of distributed programs won the Influential Paper Award awarded during the annual ACM Principles of Distributed Computing (PODC) conference in July 2002. The award was subsequently co-sponsored by the EATCS Symposium on Distributed Computing (DISC) and named for Dijkstra after he passed away a month later in 2002.

Today we recognize this year’s winners.
Read more…

Should These Quantities Be Linear?

August 4, 2023


Drastic proposals for revamping the chess rating system

Jeff Sonas is a statistician who runs a consulting firm. He also studies skill at chess. He has advised the International Chess Federation (FIDE) about the Elo rating system for over a quarter century. He and FIDE have just released a 19-page study and proposal for a massive overhaul of the system.

Today I ask whether larger scientific contexts support the proposal. Besides this, I advocate even more radical measures.
Read more…

TTIC Makes a Hire

July 22, 2023

Avrim Blum just announced that Shiry Ginosar has accepted his offer and will be joining TTIC as a tenure-track Assistant Professor starting this Fall 2024. Avrim is the chief academic officer for TTIC.

Shiry works in computer perception, including vision, audio, and other sensory modalities, as well as machine learning and AI more broadly. Her work focuses on artificial social intelligence, including social learning, Human-Human, and Human-AI interaction.

Welcome, Shiry!! Says Avrim.


Read more…

Two Other Tests of Time

July 20, 2023


Mihalis Yannakakis 70-Fest and the 2023 Gödel Prize

2020 AAAS election—congrats on that too

Mihalis Yannakakis is being honored with a 70th-birthday festival next month at Columbia University in Manhattan. It is organized by Xi Chen, Ilias Diakonikolas, Kousha Etessami, Christos Papadimitriou, Dimitris Paparas, and Rocco Servedio.

Today we congratulate him and consider this as one way to mark a “test of time.” Then we discuss another.

There is a free but required registration for the August 16–18 event. Here is the current all-star list of speakers and topics:



Our friend Vijay Vazirani leads off with a talk that will reference Mihalis’s ideas on linear programming and optimization problems. The fourth talk by Toniann Pitassi is on communication complexity. These lead us to think of a variation on the “test of time” idea.

We have just been discussing ACM STOC and IEEE FOCS “Test of Time” awards. We posted a note in 2021 when they were created, and sure enough, Mihalis was one of three judges on the initial panel.

A Second-Order Test of Time

The above awards are “first-order” in the sense of being direct honors for a paper. The papers are expected to have stimulated other important papers, which might later receive their own awards. Our idea for a second kind of test-of-time award inverts the time flow.

A prize for a paper that unambiguously led to papers that won prizes, without having won a prize itself.

Here is the paper—note it is singly authored:

And here are the papers it led to—winning the 2023 Gödel Prize no less:

The former paper also won the 2022 Test of Time 10-year award; the latter will be up for the first time next year. But Mihalis’s paper did not win in 2022 when it was eligible for the 30-year award with its four-year horizon rule; two other papers from the 1988 STOC did win. Nor does the paper seem to be mentioned or specifically implied in the citation for Mihalis’s 2005 Knuth Prize. Thus it seems to meet the eligibility condition for our prize.

The relevance condition is clear: The 2023 Gödel prize citation says that the five authors of the first paper

“made ingenious use of techniques from communication complexity (following a framework pioneered by Yannakakis) to show that any extended formulation for the TSP polytope has exponential size.”

The second paper is cited as “Building on these techniques, …” The Test of Time citation notes that the first paper “resolved a 25-year open problem”—namely one that was posed by Yannakakis as they say in their abstract. In our own post on this topic in 2012 we called Mihalis’s 1988 work “a famous paper.” Yet, again, it seems to be eligible for our no-prizes prize.

Open Problems

Is Mihalis’s 1988 paper really eligible for our prize, or has it already won a prize we haven’t found?

Again, we congratulate Mihalis warmly on his 70th birthday and we congratulate the winners of the 2023 Gödel Prize.

[fixed a spelling inconsistency]