Have you looked into prolog/datalog? You're dancing around many of the same ideas, including backwards execution, constraint programming, stratification, and finding possible values. Here's a relevant example of someone solving a problem like this in prolog:
https://mike.zwobble.org/2013/11/fun-with-prolog-write-an-al...