I don’t know anything specific, but what you are looking for are terms such as “specialized compiler”, “specialization of the program”, “assembly of the semantic direction” and “partial evaluation”. Try them with and without the "Prolog" in your request; The functional programming community has also done a lot of research in this area.
Note that Prolog completes Turing, so no approach would be perfect. Subsets of Prolog are known, such as Datalog, but they do not have I / O. I believe that Datalog is described in "Art of Prolog" by Sterling and Shapiro. (Datalog still contains variables, although it's good enough for simple stream-based input / output.)
If this does not work, consider cstheory .
source share