Yes, I'm glad to see a comment on Prolog. I think of it as _the_ foundational programming language for solving such problems. It isn't so much that it's a back propagation language; it's just that, based on which variables are bound at a given point, it will go forward deductively, or backwards inductively.
Wasn’t Prolog invented to formalise these kinds of problems of making the inputs match what the desired output should be.
[1] https://en.wikipedia.org/wiki/Declarative_programming