Deductive Composition of Programs
Logic can be used to construct programs by composition of subroutines from a library. We write axioms that describe what the subroutines do, then write a theorem about the goal of the program we want. Proving the theorem constructs a way to accomplish the goal by composition of function calls; these function calls can then be easily converted into a program.
We express what subroutines do with rules; in logic notation:
cartesian(p) ∧ cartesian(q)
→ distance(p, q, euclidist(p,q))
This expresses the axiom that if p and q are points in cartesian coordinates, then the distance between them is given by the function euclidist(p,q) . This axiom specifies the required inputs of the function euclidist, as well as what the function does.