I've recently learned about Prolog and Logic programming which I find pretty cool, but the compiler is currently like magic to me and I want to know how they work.

After a little bit of research I discovered that logical compilers are based on Warrens Abstract Machine (WAM). I've tried to find some information on WAM, but the Wikipedia page only describes what it is and not how it works and the book Warrens Abstract Machine: A Tutorial Reconstruction doesn't read very well for me.

Could I please have basic explanation of how WAM works?


1 Answer 1


This may be a question that's too broad to cover here.

The WAM covers a lot of Prolog-specific capabilities (e.g. unification, nondeterminism, the cut) that other abstract machines do not, and its design is also quite subtle in its details (e.g. garbage collection on backtracking is designed into the machine). There is a reason why the WAM Book is 130 pages long: it is complicated and hard to understand!

Still, the WAM Book is the best explanation that I'm aware of, and there may be no substitute for going through that, working through the exercises, hand-compiling small examples of your own, and possibly even implementing parts of the WAM in a suitable language.

I'm going to suggest that you try with it again, and ask specific questions here if you get stuck on something.

But if that doesn't sound like something that you want to do right now, you may want to go through a less complicated abstract machine first, such as the SECD machine. The WAM was, after all, influenced by abstract machines that came before it, and that is assumed knowledge.

  • 1
    $\begingroup$ I recommend the CEK machine as a good starting point as well, if you are interested in abstract machines in general. $\endgroup$
    – Labbekak
    Jul 31, 2020 at 21:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.