Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplyfiyng BasicOperations intersection #5

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

pierlauro
Copy link

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.

Since due to De Morgan's law **A ∩ B = (A<sup>c</sup> ∪ B<sup>c</sup>)<sup>c</sup>**, the intersection operation can be simplified in order to avoid the quadratic algorithm.
@amoeller
Copy link
Member

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?

@pierlauro
Copy link
Author

pierlauro commented Jul 12, 2017

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.

@amoeller
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants