To borrow part of a description from a similar but distinct question: there exist 2^(2^N) different functions which accept N binary inputs and return a 1 bit output. For the purposes of my question I am calling these N-input-gates.
I want to know if there exists a general algorithm which can always describe an optimal way to implement an N-input-gate using only a collection of N-input-gates with smaller N.
Such as: emulate such-and-such specific 7-input-gate (perhaps uniquely identified by a 128-bit string of outputs) using only a lot of 3-input-gates.
This might most commonly be approached in the real world by breaking N-input-gates into small messes of 2-input-gates (such as AND/OR/XNOR), for example.
But it would also be interesting if the algorithm could be general enough that a person could specify the size of the smaller gates to use.. or perhaps even an exact breakdown of which gates to use (say, "find optimal solution using only NAND or only NOR gates or only AND+NOT gates or only copies of the 3-input (01011101) gate").
Algorithm would obviously need to be able to express when no solution is possible (eg: cannot emulate AND gate using only NOT gates) and structure of algorithm might be dependent on what types of input mutations are allowed (can one output be duplicated into multiple new gates? Can a constant one or zero be fed into a gate somewhere? etc)
I'm asking because I'm curious in principle whether this angle of research has already been done, and it's hard to search for unless one already knows many clever and unique search terms to cut through the noise of ambiguous and overloaded terms. Trust me, "and", "gate", and "function" mean a zillion different things in various contexts. 😋
Also for my own sake I am creating a small logic simulation game based upon cellular automata and I'm curious about possible ways to automate some of the digital signal processing logic I can do within the system. EG if I know I want a specific (arbitrary) set of 16 output bits (EG: 1011011111101011) to come from a nibble of input bits and only have certain N-input-gate building blocks available to implement that, how can that most efficiently be done? Or can it be?