General method for determining binary function

50 Views Asked by At

What is a general method for determining the simplest function $f(x,y)=z$ for a given set of values of $x$, $y$, and $z$. Simplicity being the fewest number of operations required in the function, notwithstanding other definitions of functional simplicity.

For example, given the binary values in the table below:

|  x   |  y   |  z   |
|------|------|------|
| 0000 | 0000 | 1101 |
| 0000 | 0001 | 1111 |
| 0001 | 0000 | 1110 |
| 0010 | 0000 | 1011 |
| 0100 | 0000 | 0001 |
| 0101 | 0001 | 0000 |
| 0101 | 0010 | 0110 |
| 1000 | 0000 | 0101 |
| 1000 | 0001 | 0111 |
| 1000 | 0010 | 0001 |
| 1101 | 0001 | 1000 |
| 1101 | 0010 | 1110 |

This function can be determined to be a solution: $f(x, y) = ( x ~XOR~ ( x << 1 ) ~XOR~ ( y << 1 )) ~AND~ F_{16}$

In one of the comments here, a function solver was suggested. While this seems like a good approach, and can generate a solution, the extensive polynomial function found by a solver is not as simple as the solution identified above.

When using base 2, as in this example, operations like mask, shift, rotation, parity, or other binary functions can be used to generate a simpler solution.

My trial-and-error method, started with collecting data at the 0's for each variable. Then I tried various function combinations on the input variables to get an intermediate value, then tried operations on that intermediate value against the known solution for the input variables. Also, a lot of staring at the numbers was involved. I think there must be a more general method, possibly involving truth tables of each bit combination, then mapping the truth table patterns to known functions. Perhaps image or pattern recognition of the resulting truth tables could be used to composite a solution.

So, the question again is, can we describe a process or method to consistently recover simple functions used to generate outputs given their inputs?