<p>Every context-free language has either polynomial growth or exponential growth. In the notation of the question poser:</p>
<ul>
<li>Either there is a polynomial <span class="math-container">$p$</span> so that <span class="math-container">$w_n\le p(n)$</span> for all <span class="math-container">$n$</span></li>
<li>Or there exists a <span class="math-container">$c&gt;1$</span>, so that <span class="math-container">$w_n\ge c^n$</span> for infinitely many <span class="math-container">$n$</span>.</li>
</ul>
<p>This has been shown for instance in:</p>
<blockquote>
<p>Roberto Incitti:<br />
&quot;The growth function of context-free languages&quot;<br />
Theoretical Computer Science 255 (2001), Pages 601-605</p>
<p>Martin R. Bridson, Robert H. Gilman:<br />
&quot;Context-Free Languages of Sub-exponential Growth&quot;<br />
Journal of Computer and System Sciences 64 (2002), Pages 308-310</p>
</blockquote>
<p>And for a given context-free grammar, one can decide in polynomial time whether the generated language has polynomial or exponential growth:</p>
<blockquote>
<p>Pawel Gawrychowski, Dalia Krieger, Narad Rampersad, Jeffrey Shallit:<br />
&quot;Finding the Growth Rate of a Regular or Context-Free Language in Polynomial Time.<br />
International Journal of Foundations of Computer Science 21 (2010), Pages 597-618</p>
</blockquote>

CC BY-SA 4.0
2018-11-14T16:59:56.850Z
Very interesting connection: The term growth rate is a well known one in group theory and heavily studied. However virtually free groups have exponential growth rate and we know by Muller and Schupp (1983) that word problems of virtually free groups are deterministic context-free. Do you know if there is further work about the growth rate of deterministic context-free languages?
dtell
CC BY-SA 4.0
2018-11-14T12:24:19.460Z
2018-11-14T13:00:46.170Z
2020-06-17T09:38:08.363Z
Gamow
<p>Denote by <span class="math-container">$w_n$</span> the number of words of length <span class="math-container">$n$</span> in a (possibly ambiguous) context-free language.</p>

<blockquote>
  <p>What is known about <span class="math-container">$w_n$</span>?</p>
</blockquote>

<p>I'm sure this has been studied a lot, but I couldn't find anything at all on it.</p>

CC BY-SA 4.0
2018-11-14T15:15:57.930Z
There is a quasi-polynomial time randoimized algorithm to approximate $w_n$ to within a $(1+\epsilon)$ approximation. https://www.sciencedirect.com/science/article/pii/S0890540197926213
Chandra Chekuri
CC BY-SA 4.0
2018-11-14T19:10:01.727Z
For unambiguous CFLs, the classic [Chomsky–Schützenberger enumeration theorem](https://en.wikipedia.org/wiki/Chomsky%E2%80%93Sch%C3%BCtzenberger_enumeration_theorem) should be of interest.
Martin Berger
<fl.formal-languages><context-free>
Number of words of length n in a context-free language
domotorp
# Number of words of length n in a context-free language

(Asked by: username_0 on 2018-11-14)

Denote by $w\_n$ the number of words of length $n$ in a (possibly ambiguous) context-free language.

> What is known about $w\_n$?

I'm sure this has been studied a lot, but I couldn't find anything at all on it.

**Tags:** fl.formal-languages, context-free

> **Comments:**
> **username_1**: There is a quasi-polynomial time randoimized algorithm to approximate $w_n$ to within a $(1+\epsilon)$ approximation. https://www.sciencedirect.com/science/article/pii/S0890540197926213  
> **username_2**: For unambiguous CFLs, the classic [Chomsky–Schützenberger enumeration theorem](https://en.wikipedia.org/wiki/Chomsky%E2%80%93Sch%C3%BCtzenberger_enumeration_theorem) should be of interest.  

---

## 1 answers

### Answer by username_3 on 2018-11-14. Score: 27 | Accepted answer

Every context-free language has either polynomial growth or exponential growth. In the notation of the question poser:

* Either there is a polynomial $p$ so that $w\_n\le p(n)$ for all $n$
* Or there exists a $c>1$, so that $w\_n\ge c^n$ for infinitely many $n$.

This has been shown for instance in:

> Roberto Incitti:  
> "The growth function of context-free languages"  
> Theoretical Computer Science 255 (2001), Pages 601-605
>
> Martin R. Bridson, Robert H. Gilman:  
> "Context-Free Languages of Sub-exponential Growth"  
> Journal of Computer and System Sciences 64 (2002), Pages 308-310

And for a given context-free grammar, one can decide in polynomial time whether the generated language has polynomial or exponential growth:

> Pawel Gawrychowski, Dalia Krieger, Narad Rampersad, Jeffrey Shallit:  
> "Finding the Growth Rate of a Regular or Context-Free Language in Polynomial Time.  
> International Journal of Foundations of Computer Science 21 (2010), Pages 597-618

> **Comments:**
> **username_4**: Very interesting connection: The term growth rate is a well known one in group theory and heavily studied. However virtually free groups have exponential growth rate and we know by Muller and Schupp (1983) that word problems of virtually free groups are deterministic context-free. Do you know if there is further work about the growth rate of deterministic context-free languages?  

---

