I ll expand Firestand s answer on genetic programming.
There were ideas like yours already; they were almost all the times limited to some artificial environment though.
My friend wrote a system to automatically (using genetic programming) evolve programs for a CoreWars environment. These programs aren t long (tens-to-hundreds of assembly instructions), and the set of legal instructions is not very big, so the space of possible programs is much smaller than full-blown GUI applications for x86. At the beginning the bots were hardly fighting each other; but with each generation there were better and better fighters in the set.
You can read more about this concept in a research paper (PDF).
It wouldn t be very easy to apply this idea to x86, the set of instructions here is large and interactions between them are sometimes very complex. However you could theoretically build a virtual machine with a simplified instruction set and evolve programs for it. I have read about that somewhere, but I can t recall where.
Still, checking all possible combinations is not reasonable even for very very simple code. You really want to have some heuristic strategy, like genetic programming.
Your idea has yet another flaw. You assume that you can strictly specify all requirements for your programs, so that all requirements can be tested automatically. This is impossible or very close to impossible. Assuming that you want to find a program that adds two int32 numbers, to be really sure that program works correctly you have to check all possible inputs, so 2^64 possibilities. Try to imagine how many scenarios you would have to check if you were writing a financial program.
You could try to use an "intelligent" system to find correctness proofs for your programs... but because you re not limited to some subset of programs (you can generate simply anything that can be run on a processor), you cannot reason about all programs because of the Halting problem. Simply put, it is impossible to detect whether some programs work correctly without checking all possible inputs.