Research regarding algorithm generation/discovery/heuristics Say I have a specification of preconditions and postconditions for a function. Is there a field of computer science that studies the automated generation of functions that satisfy those specifications?

For example:
Preconditions:


I is a list
Q is a binary relation specifying a total order on the
elements in I


Postcondition: 


O is a list
There exists a bimap B (and its complement B') such that

O[B[j]] = I[j], and
O[j] = I[B'[j]],
for every j, 0 &lt;= j &lt; n,

For every x, 0 &lt; x &lt; n, Q(O[x - 1], O[x]) is true.


The set of functions that satisfy this (I hope unambiguous) specification are the sorting algorithms. So, how do we get a computer to take this specification, and give us a sorting algorithm?
The phrase to look for is "program synthesis".  There's lots of literature in the programming literature on this topic; I suggest using Google Scholar to search through the literature and find relevant publications.

These days one hot approach is using "program sketching".  In program sketching, the programmer specifies a template for the code: partial code, with some holes left blank.  The tool then automatically tries to fill in those holes in a way that is consistent with the preconditions/postconditions, or is consistent with some provided test cases.  There's lot of literature on this topic.  For an introduction to this line of work, I'll suggest the following tutorial:

The Sketching Approach to Program Synthesis.  Armando Solar-Lezama.  Tutorial at PLDI 2012.