<p>In fact, this roundtrip conversion is used in the proof of the Star Height Lemma, and this in turn has lots of implications in the area of descriptional complexity of regular expressions. And here it comes...</p>
<p>The star height of a regular language <span class="math-container">$L$</span> is defined as the minimum star height among all regular expressions (using operations concatenation, union and Kleene star) describing <span class="math-container">$L$</span>. Simple examples such as <span class="math-container">$(a(a(a(ab)^*b)^*b)^*b)^*$</span> show that the star height of a regular expression can be linear in its size, and there seem to be no obvious simplification that would yield a regular expression of lower height. Perhaps somewhat non-intuitively, we can always get away with a star height which is logarithmic in the minimum regular expression length.</p>
<p>The star height lemma can be used, for example, to show that regular expressions extended with a shuffle (interleaving) operator are doubly exponentially more succinct than ordinary regular expressions. Or that converting an NFA into a planar NFA will necessarily incur at least a quadratic size blow-up in the worst case (the upper bound is exponential).</p>
<p><strong>Star Height Lemma:</strong> Let <span class="math-container">$L$</span> be a regular language, let <span class="math-container">$h(L)$</span> denote its star height, and let <span class="math-container">$\mathrm{alph}(L)$</span> denote the minimum size (alphabetic width) of a regular expression for <span class="math-container">$L$</span>. Then <span class="math-container">$h(L) = O(\log (\mathrm{alph}(L)))$</span>.</p>
<p>The Star Height Lemma is proved by observing that if we convert a regular expression into an NFA using Thompson's construction, the resulting NFA is a series-parallel when viewed as an undirected graph. This graph has treewidth 2, and tree-depth logarithmic in its size. This can be used to find an elimination ordering such that converting back to a regular expression using state elimination yields a regular expression of logarithmic star height (and polynomial size, which yet does not matter for the lemma).</p>
<p><strong>References:</strong></p>
<ul>
<li><p>Hermann Gruber and Markus Holzer. Finite Automata, Digraph Connectivity, and Regular Expression Size. In Luca Aceto, Ivan Damgård, Leslie Ann Goldberg, Magnús M. Halldórsson, Anna Ingólfsdóttir, and Igor Walukiewicz, editors, 35th International Colloquium on Automata, Languages and Programming (ICALP 2008), Reykjavik, Iceland, volume 5126 of Lecture Notes in Computer Science, pages 39-50. Springer, July 2008.</p>
</li>
<li><p>Hermann Gruber, Markus Holzer, and Martin Kutrib. Descriptional Complexity of Regular Languages. In Jean-Eric Pin, editor, Handbook of Automata Theory. Volume I: Theoretical Foundations, pages 411-458. European Mathematical Society Press, 2021.</p>
</li>
</ul>

CC BY-SA 4.0
2024-02-02T02:12:17.580Z
Exciting and unexpected! Thanks!
TomKern
CC BY-SA 4.0
2024-02-01T12:46:41.097Z
2024-02-02T09:45:07.343Z
2024-02-02T09:45:07.343Z
Hermann Gruber
<p>Consider the following recursive algorithm for converting a regular expression into a transition diagram for an NFA with epsilon-edges (freely, optionally traversible edges), one start state and one accept state:</p>
<ul>
<li>To convert the concatenation of <span class="math-container">$R_1$</span> and <span class="math-container">$R_2$</span>, draw the NFAs for both regular expressions, then draw an epsilon-edge from the accept state of the NFA for <span class="math-container">$R_1$</span> to the start state of the NFA for <span class="math-container">$R_2$</span>.</li>
<li>To convert the union of <span class="math-container">$R_1$</span> and <span class="math-container">$R_2$</span>, take the union of both graphs. Create and designate a new start state and accept state, then draw epsilon-edges from the new start state to the old start states and from the old accept states to the new accept state.</li>
<li>To convert the Kleene star of <span class="math-container">$R_1$</span>, draw an epsilon-edge from the accept state of the NFA for <span class="math-container">$R_1$</span> to the start state, then designate the start state as also being the accept state.</li>
</ul>
<p>For this and similar algorithms, the resulting NFA feels like it has some kind of hierarchical structure to it, with subexpressions of the regular expression corresponding to subgraphs of the NFA that are connected only in particular ways.</p>
<p>That makes me wonder: is there some utility in converting an NFA to a regular expression and then converting back to transform an NFA into an equivalent NFA whose transition diagram (although much bigger) had this nice structure?</p>
<p>More generally, is there some nontrivial property <span class="math-container">$P$</span> of transition diagrams that holds for the results of this (or maybe a similar) translation algorithm? I chose the particular algorithm above because the resulting graphs are always planar, but I don't know of any utility in having such a planar representation of a regular language. Is there some such property <span class="math-container">$P$</span> that is useful (perhaps for an algebraic decomposition)?</p>

CC BY-SA 4.0
2024-01-22T13:39:03.240Z
I don't understand the question. DFA and REGEXP are equivalent as far as expressive power: both recognize precisely the class of the regular languages.
Aryeh
CC BY-SA 4.0
2024-01-22T14:25:26.300Z
Ah, here I'm using 'DFA' in a sense where two DFAs are equal if their transition diagrams are graph-isomorphic. I.e. there's some permutation of states that takes the start state, transition function, and accept states of one to the other. Certainly if we're just considering equivalence in terms of language accepted this question isn't interesting.
TomKern
CC BY-SA 4.0
2024-01-22T15:00:59.043Z
How do you turn a regular expression to a DFA? The construction I know goes through an NFA, and isn't very nice. Regardless this question is quite sensitive to the particular algorithm.
Command Master
CC BY-SA 4.0
2024-01-22T21:19:50.267Z
Good point. For some reason I figured since you can do the construction recursively on the regular expression producing NFAs that are mostly DFAs, but have epsilon-edges (freely, optionally traversable edges), you could then easily remove the epsilon-edges to get a DFA. But the process of removing epsilon-edges gives you an NFA not a DFA. I suppose there's still an interesting nugget in this question which is 'is there value in turning a DFA into an untangled NFA?', but this not nearly as exciting.
TomKern
CC BY-SA 4.0
2024-01-23T07:52:25.603Z
The question is not answerable.  You have to define what you mean by "the naive recursive algorithm".  There are multiple algorithms; and there are variations on some of the exact details.  I encourage you to [edit] the question to clarify that point, and to address the issues raised in the prior comments.
D.W.
CC BY-SA 4.0
2024-01-24T20:13:45.700Z
I think the question is a bit imprecise, but I think there is some meaning to it. The recursive algorithm described in the question is reminiscent of Thompson's construction (https://en.wikipedia.org/wiki/Thompson%27s_construction) and I agree that it looks like the resulting automata have some structure, that looks a bit like being series-parallel (https://en.wikipedia.org/wiki/Series%E2%80%93parallel_graph). I agree that it could be the case that there'd be some use to converting any NFA to an automata of this form by converting it to a regexp and back. That said, I don't have an example...
Antoine Amarilli 'a3nm'
<fl.formal-languages><automata-theory><regular-language><regular-expressions>
Is it useful to "untangle" an NFA by converting to a regular expression and back
TomKern
# Is it useful to "untangle" an NFA by converting to a regular expression and back

(Asked by: username_0 on 2024-01-22)

Consider the following recursive algorithm for converting a regular expression into a transition diagram for an NFA with epsilon-edges (freely, optionally traversible edges), one start state and one accept state:

* To convert the concatenation of $R\_1$ and $R\_2$, draw the NFAs for both regular expressions, then draw an epsilon-edge from the accept state of the NFA for $R\_1$ to the start state of the NFA for $R\_2$.
* To convert the union of $R\_1$ and $R\_2$, take the union of both graphs. Create and designate a new start state and accept state, then draw epsilon-edges from the new start state to the old start states and from the old accept states to the new accept state.
* To convert the Kleene star of $R\_1$, draw an epsilon-edge from the accept state of the NFA for $R\_1$ to the start state, then designate the start state as also being the accept state.

For this and similar algorithms, the resulting NFA feels like it has some kind of hierarchical structure to it, with subexpressions of the regular expression corresponding to subgraphs of the NFA that are connected only in particular ways.

That makes me wonder: is there some utility in converting an NFA to a regular expression and then converting back to transform an NFA into an equivalent NFA whose transition diagram (although much bigger) had this nice structure?

More generally, is there some nontrivial property $P$ of transition diagrams that holds for the results of this (or maybe a similar) translation algorithm? I chose the particular algorithm above because the resulting graphs are always planar, but I don't know of any utility in having such a planar representation of a regular language. Is there some such property $P$ that is useful (perhaps for an algebraic decomposition)?

**Tags:** fl.formal-languages, automata-theory, regular-language, regular-expressions
> **Comments:**
> **username_1**: I don't understand the question. DFA and REGEXP are equivalent as far as expressive power: both recognize precisely the class of the regular languages.  
> **username_0**: Ah, here I'm using 'DFA' in a sense where two DFAs are equal if their transition diagrams are graph-isomorphic. I.e. there's some permutation of states that takes the start state, transition function, and accept states of one to the other. Certainly if we're just considering equivalence in terms of language accepted this question isn't interesting.  
> **username_2**: How do you turn a regular expression to a DFA? The construction I know goes through an NFA, and isn't very nice. Regardless this question is quite sensitive to the particular algorithm.  
> **username_0**: Good point. For some reason I figured since you can do the construction recursively on the regular expression producing NFAs that are mostly DFAs, but have epsilon-edges (freely, optionally traversable edges), you could then easily remove the epsilon-edges to get a DFA. But the process of removing epsilon-edges gives you an NFA not a DFA. I suppose there's still an interesting nugget in this question which is 'is there value in turning a DFA into an untangled NFA?', but this not nearly as exciting.  
> **username_3**: The question is not answerable.  You have to define what you mean by "the naive recursive algorithm".  There are multiple algorithms; and there are variations on some of the exact details.  I encourage you to [edit] the question to clarify that point, and to address the issues raised in the prior comments.  
> **username_4**: I think the question is a bit imprecise, but I think there is some meaning to it. The recursive algorithm described in the question is reminiscent of Thompson's construction (https://en.wikipedia.org/wiki/Thompson%27s_construction) and I agree that it looks like the resulting automata have some structure, that looks a bit like being series-parallel (https://en.wikipedia.org/wiki/Series%E2%80%93parallel_graph). I agree that it could be the case that there'd be some use to converting any NFA to an automata of this form by converting it to a regexp and back. That said, I don't have an example...  

---

## 1 answers

### Answer by username_5 on 2024-02-01. Score: 3

In fact, this roundtrip conversion is used in the proof of the Star Height Lemma, and this in turn has lots of implications in the area of descriptional complexity of regular expressions. And here it comes...

The star height of a regular language $L$ is defined as the minimum star height among all regular expressions (using operations concatenation, union and Kleene star) describing $L$. Simple examples such as $(a(a(a(ab)^\*b)^\*b)^\*b)^\*$ show that the star height of a regular expression can be linear in its size, and there seem to be no obvious simplification that would yield a regular expression of lower height. Perhaps somewhat non-intuitively, we can always get away with a star height which is logarithmic in the minimum regular expression length.

The star height lemma can be used, for example, to show that regular expressions extended with a shuffle (interleaving) operator are doubly exponentially more succinct than ordinary regular expressions. Or that converting an NFA into a planar NFA will necessarily incur at least a quadratic size blow-up in the worst case (the upper bound is exponential).

**Star Height Lemma:** Let $L$ be a regular language, let $h(L)$ denote its star height, and let $\mathrm{alph}(L)$ denote the minimum size (alphabetic width) of a regular expression for $L$. Then $h(L) = O(\log (\mathrm{alph}(L)))$.

The Star Height Lemma is proved by observing that if we convert a regular expression into an NFA using Thompson's construction, the resulting NFA is a series-parallel when viewed as an undirected graph. This graph has treewidth 2, and tree-depth logarithmic in its size. This can be used to find an elimination ordering such that converting back to a regular expression using state elimination yields a regular expression of logarithmic star height (and polynomial size, which yet does not matter for the lemma).

**References:**

* Hermann Gruber and Markus Holzer. Finite Automata, Digraph Connectivity, and Regular Expression Size. In Luca Aceto, Ivan Damgård, Leslie Ann Goldberg, Magnús M. Halldórsson, Anna Ingólfsdóttir, and Igor Walukiewicz, editors, 35th International Colloquium on Automata, Languages and Programming (ICALP 2008), Reykjavik, Iceland, volume 5126 of Lecture Notes in Computer Science, pages 39-50. Springer, July 2008.
* Hermann Gruber, Markus Holzer, and Martin Kutrib. Descriptional Complexity of Regular Languages. In Jean-Eric Pin, editor, Handbook of Automata Theory. Volume I: Theoretical Foundations, pages 411-458. European Mathematical Society Press, 2021.

> **Comments:**
> **username_0**: Exciting and unexpected! Thanks!  

---

