I'd like to define a boolean function (with n inputs and m outputs) in a tabular form. I'd like to find an optimal boolean expression which implements the function. Optimal here means that, implementing it in hardware would require as few possible gates (with maybe each gate having different costs)
I'm sure VHDL/Verilog synthesizers do this optimization frequently, and I basically need it for the same reason. Is there some kind of Karnaugh solver? Alternatively, is it possible to specify the problem as a classic optimization problem (SAT, integer programming)? I'd like to implement it in Python so I'm primarily looking for a package which does this already.
The algorithms to find the optimal solution have exponential complexity, so generally the available tools look for a good implementation rather than the optimal implementation. I'm not sure how stringent your requirements are, or how big your functions are.
One algorithm for logic optimization is Quine-McCluskey. There is a python implementation. However, that only covers the single output case.
$ ./qm.py -o 1,2,3
1X X1
$ ./qm.py -o 1,2
10 01
$ ./qm.py -o 0,15
1111 0000
$ ./qm.py -o 0,8,15
1111 X000
For multiple outputs, the simplest strategy is to implement each one separately. There may be some duplicated terms between them which can be readily shared; structuring the logic to maximize sharing is more difficult.