In computer science, program derivation is the derivation of a program from its specification, by mathematical means.
To derive a program means to write a formal specification, which is usually non-executable, and then apply mathematically correct rules in order to obtain an executable program satisfying that specification. The program thus obtained is then correct by construction. Program and correctness proof are constructed together.
- the resulting proof is often long and cumbersome;
- no insight is given as to how the program was developed; it appears "like a rabbit out of a hat";
- should the program happen to be incorrect in some subtle way, the attempt to verify it is likely to be long and certain to be fruitless.
Program derivation tries to remedy these shortcomings by
- keeping proofs shorter, by development of appropriate mathematical notations;
- making design decisions through formal manipulation of the specification.
Terms that are roughly synonymous with program derivation are: transformational programming, algorithmics, deductive programming.
See also 
- Edsger W. Dijkstra, Wim H. J. Feijen, A Method of Programming, Addison-Wesley, 1988, 188 pages
- Edward Cohen, Programming in the 1990s, Springer-Verlag, 1990
- Anne Kaldewaij, Programming: The Derivation of Algorithms, Prentice-Hall, 1990, 216 pages
- David Gries, The Science of Programming, Springer-Verlag, 1981, 350 pages
- Eric C.R. Hehner, a Practical Theory of Programming, 2008, 235 pages
- A.J.M. van Gasteren. On the Shape of Mathematical Arguments. Lecture Notes in Computer Science #445, Springer-Verlag, 1990. Teaches how to write proofs with clarity and precision.