This super exciting (for me). I’ve been re-reading Prolog with the idea of either implementing a Prolog-like DSL, or maybe an interpreter. I’ve only got as far as starting to research how to write a Horne clause theorem solver (really, just started), So this is going to be a great project for me to follow.
Of tangential relevance because it’s not Elixir, but Erlog might be worth looking at. While it seems not to have been worked on for a few years, it has good pedigree (@rvirding). I also recall that @zkessin had some interest in Prolog on the Beam.
Beyond exploration, I can see a possible use case (actually considered doing it some time ago): As a triage frontend for a Prolog database running something like SWI Prolog.
Erlog is pretty cool, but could use some love. If I evere were to be in a position to sponsor someone to work on open source it would be on my list of things to work on (Not happening anytime soon) but I would love to chat about it
Likewise. Maybe sometime in the future I will have time and resource to revisit it. The application I was looking at had no business model and would probably have required public funding - unlikely as things stand right now.
Yes, I haven’t worked on Erlog for a while but it is has not died. It has reached a certain level and I have left it there. It does implement a proper subset of standard prolog but of course it could be extended. The next step could be a rework of the interpreter maybe compiling the code a bit to improve speed.
Doing an elixir front-end to it would be relatively simple as the interface and internal data structures are quite straight forward. It is just that no one has asked for one yet.
There was a fork where someone else reworked the database to handle large tables but it used ETS and it wasn’t possible to make the database behave exactly as the prolog standard. Which was one of my requirements. There is a simple ETS interface which could be extended with more features.
I appreciate the talent of Jose.
Elixir has given modern syntax to the capabilities of Erlang.
If great talent gives Prolog modern syntax, Prolog may come back.
Nice! I love Prolog and considered the same idea a few years ago. Recent months have seen me learning Mercury too, I have just about finished wrapping the SDL2 media library with it so I can write games in Mercury.
Creating a clean Prolog in Elixir is my kind of mad idea. I’ll check out the git pages and have a look!
Bidirectional calculation is now possible.
It is a small interpreter of about 1000 lines.
Everyone, please enjoy remodeling as you like.
It is BSD license.
Example:
mix prolog
Compiling 1 file (.ex)
Prolog in Elixir
?- assert(append([], Xs, Xs)).
true
?- assert((append([X | Ls], Ys, [X | Zs]) :- append(Ls, Ys, Zs))).
true
?- append(X,Y,[1,2,3]).
Y = [1,2,3]
X = [];
Y = [2,3]
X = [1];
Y = [3]
X = [1,2];
Y = []
X = [1,2,3];
false
Try looking at FCP (Flat Concurrent Prolog) which is really interesting. Or Parlog or Strand for that matter. We once did an implementation of Erlang in Strand but found that were something that wouldn’t work properly.