This is a minimal Prolog interpreter implemented in Rust. The implementation covers only a subset of Prolog features, is not intended to be fast, or optimal in any sense. It is a learning project that helped me to understand Prolog better.
The implementation is tested using 350+ unit tests, including running some code solutions for the "99 Prolog problems", and unit tests checking for ISO Prolog consistency. There are some differences from other Prolog implementations though, as described below.
In Prolog everything is a struct, so atom foo is the same as foo(), operation like 2 + 2 is +(2, 2), the "and" operator in a , b is ,(a, b) (don't be confused with the comma separating the arguments), etc.
Lists in Prolog are also structs, so [1, 2, 3] is represented as .(1, .(2, .(3, []))), where [] stands for an empty list. Prolog allows you to create dotted pairs (in lisp terms), for example [1 | 2] is represented as .(1, 2).
Prolog extensively uses pattern matching. When you ask a question, it searches its database if any of the recorded facts and rules that match the goals in the question. This is nicely explained in the Adventure in Prolog book by Dennis Merritt: