dk.brics.automaton icon indicating copy to clipboard operation
dk.brics.automaton copied to clipboard

Simplyfiyng BasicOperations intersection

Open pierlauro opened this issue 7 years ago • 3 comments

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.

pierlauro avatar Jul 11 '17 21:07 pierlauro

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?

amoeller avatar Jul 12 '17 06:07 amoeller

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.

pierlauro avatar Jul 12 '17 13:07 pierlauro

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.

amoeller avatar Jul 12 '17 14:07 amoeller