4 ms·
FWIW, http://adsabs.harvard.edu/abs/2008arXiv0802.2869G http://adsabs.harvard.edu/abs/2008arXiv0802.2869G says: "Similarly [to complement], when constructing a
by dalke 10y ago
FWIW, http://adsabs.harvard.edu/abs/2008arXiv0802.2869G http://adsabs.harvard.edu/abs/2008arXiv0802.2869G says: "Similarly [to complement], when constructing a regular expression defining the intersection of a fixed and an arbitrary number of regular expressions, an exponential and double exponential size increase, respectively, can in worst-case not be avoided."
I found the 'greenery' project, which says, at https://qntm.org/greenery https://qntm.org/greenery :
> Elementary automata theory tells us that the intersection of any two regular languages is a regular language, but carrying out this operation on actual regular expressions to generate a third regular expression afterwards is much harder than doing so for the other operations under which the regular languages are closed (concatenation, alternation, Kleene star closure).
The developer has code, which lets you do:
>>> from greenery.lego import parse
>>> print(parse("(ab{0,3})*") & parse("(abba)*"))
(ab{2}a)*
>>> print(parse("((ss*)t*)") & parse("((ss*)+(tt*))"))
s+t+
I have no other experience with the code, but it was nice to know that such a package exists.
The author also wrote that it was "the most algorithmically complex thing I've ever implemented."