dk.brics.automaton
dk.brics.automaton copied to clipboard
Simplyfiyng BasicOperations intersection
Since due to De Morgan's law A ∩ B = (Ac ∪ Bc)c, the intersection operation can be simplified in order to avoid the quadratic algorithm.
The complement operations involve 'determinize', so this may not be a good idea. Do you have some experimental evidence that your suggestion is in fact faster in general?
You're right, I did not take in consideration the non-deterministic automatas.
Intersecting dozens of DFAs, I discovered that my solution is improving the performances (20% faster). Maybe the improvement I experienced is due to the characteristics of DFAs I am working with: they are very similar and the alphabet is not too big.
I will come back with an appropriate analysis after further experiments. Anyway, I think it's a good idea to let people choose the preferred method by adding a new method intersectionDeMorgan
.
Provided that further experiments are convinving: Let's add a static field intersection_de_morgan
(false by default) and a method setIntersectionDeMorgan
(like setMinimizeAlways
) to control which version to use.