In calculate if two arbitrary regular expressions have any overlapping solutions (assuming it's possible).
For example these two regular expressions can be shown to have no intersections by brute force because the two solution sets are calculable because it's finite.
^1(11){0,1000}$ ∩ ^(11){0,1000}$ = {}
{1,111, ..., ..111} ∩ {11,1111, ..., ...11} = {}
{} = {}
But replacing the {0,1000}
by *
remove the possibility for a brute force solution, so a smarter algorithm must be created.
^1(11)*$ ∩ ^(11)*$ = {}
{1,^1(11)*$} ∩ {^(11)*$} = {}
{1,^1(11)*$} ∩ {11,^11(11)*$} = {}
{1,111,^111(11)*$} ∩ {11,^(11)*$} = {}
.....
In another similar question one answer was to calculate the intersection regex. Is that possible to do? If so how would one write an algorithm to do such a thing?
I think this problem might be domain of the halting problem.
EDIT:
I've used the accepted solution to create the DFAs for the example problem. It's fairly easy to see how you can use a BFS or DFS on the graph of states for M_3
to determine if a final state from M_3
is reachable.