There are a couple of algorithms that do what you are asking. Karnaugh Maps and the Quine-McClusky Method are two that I can think of. Q-M is more suited to computer solutions I think. There doesn't seem to be a CPAN module that implements it though. Freshmeat has a project for it at http://freshmeat.net/projects/qmc/. Maybe you should shell out the simplification stage?