Logic programming in S9 scheme:
https://www.t3x.org/amk/index.html
You can just get the code without buying the book, learn with Simply Scheme or any other book and apply the functions from the code, the solvers are really easy to understand.