In article <firstname.lastname@example.org>, email@example.com (Mike
> Actually intersection is cross products of DFA's. This clearly
> works. Taking a cross product of NFA's is a bit nebulous
> because of e-transitions.
There's a straightforward way of doing this: let A and B be the two NFAs,
s a state in A, t a state in B, s -> eps -> s'. Then there should be an
eps transition from (s,t) to (s',t) in A x B; similarly for eps
transitions in B. It's straightforward to show that this is correct in
terms of the languages accepted. However, it has the problem that it does
not preserve the *multiplicity* of strings: if s is accepted by m
different paths in A and by n different paths in B, it may be accepted by
more than m * n different paths in
A x B. There is a way of avoiding this with a somewhat subtler
construction, but that would take us too far afield (for the curious, the
construction is described in <http://xxx.lanl.gov/ps/cmp-lg/9603001>).
> You could build NFA's without
> e-transitions, I think cross products of those would work as
> well. A DFA is O(2**n), and an NFA without e-transitions is
> O(n^2). So you may be talking at least O(n**4) complexity for
It follows from the above that intersection is O(|A|*|B|) for general NFAs.