sym_num
Small Prolog interpreter in Elixir
I am creating a Prolog interpreter to learn Elixir. This is not practical. It is a toy program.
https://github.com/sasagawa888/Prolog
Example: (from PAIP, Peter Norvig)
?- assert(likes(kim,robin)).
true
?- assert(likes(sandy,lee)).
true
?- assert(likes(sandy,kim)).
true
?- assert(likes(robin,cats)).
true
?- assert((likes(sandy,X) :- likes(X,cats))).
true
?- assert((likes(kim,X) :- likes(X,lee),likes(X,kim))).
true
?- assert(likes(X,X)).
true
?- listing.
likes(kim,robin)
likes(sandy,lee)
likes(sandy,kim)
likes(robin,cats)
likes(sandy,X) :- likes(X,cats)
likes(kim,X) :- likes(X,lee)likes(X,kim)
likes(X,X)
true
?- likes(sandy,Who).
Who = lee;
Who = kim;
Who = robin;
Who = sandy;
Who = cats;
Who = sandy;
false
?-halt.
goodbye
First Post!
kip
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.
Most Liked
sym_num
I wrote a brief introduction.
https://medium.com/@kenichisasagawa/prolog-in-elixir-classical-ai-programming-language-2f959cb4fa87
patrickdm
Arigato gozaimashita Kenichi-san!
This interpreter inspired me to learn Prolog.
What a wonderful language, what a gift!
Thank you
![]()
P.S. for others unknowing and curious like me: The Power of Prolog
rvirding
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.
Last Post!
sym_num
Popular in Discussions
Other popular topics
Chat & Discussions>Discussions
Latest on Elixir Forum
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #elixirconf-us
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #security
- #hex









