dogweather
Elixir for rules - as an alternative to Prolog or CLIPS?
I’ve been scratching out an idea in Prolog. But I’m wondering how Elixir’s functional paradigm would handle this kind of knowledge base. Has anyone done similar work?
At first glance, these look like multi-headed functions:
/*
* Crimes within the jurisdiction of the International Criminal Court.
*
* https://world.public.law/rome_statute/article_5_crimes_within_the_jurisdiction_of_the_court
*/
crime(genocide).
crime(war_crime).
crime(crime_against_humanity).
crime(crime_of_aggression).
/*
* A first, simple attempt at Protected Persons under
* the Geneva Conventions of 1949.
*/
protected_by_geneva_convention(P) :- civilian(P).
protected_by_geneva_convention(P) :- prisoner_of_war(P).
protected_by_geneva_convention(P) :- medical_personnel(P).
protected_by_geneva_convention(P) :- religious_personnel(P).
/*
* D = Defendant
* V = Victim
*/
/*
* Genocide
* https://world.public.law/rome_statute/article_6_genocide
*/
criminal_liability(genocide, Statute, D, V) :-
elements(Statute, D, V).
/*
* War crimes
* https://world.public.law/rome_statute/article_8_war_crimes
*/
criminal_liability(war_crime, Statute, D, V) :-
protected_by_geneva_convention(V),
international_conflict(D, V),
elements(Statute, D, V).
elements(article_8_2_a_i, D, V) :-
act(D, killed, V).
elements(article_8_2_a_ii, D, V) :-
act(D, tortured, V).
Most Liked
al2o3cr
That similarity isn’t an accident:
- Elixir’s multi-headed functions with pattern-matching are a direct translation of the Erlang features
- Erlang specifically cites Prolog’s syntax as inspiration, though with imperative semantics
- Erlang’s earliest prehistory is as a Prolog program (way back in 1986) - see the history in the introduction to Joe Armstrong’s thesis
2
al2o3cr
Also check out this thread:
1
Popular in Questions
Background
Let’s assume I have a typical GenServer that receives messages as requests, does some operation in a DB and returns responses....
New
Hi there, I'm working through my first release with elixir/phoenix. I've built a release with distillery and found that it crashes when I...
New
This should be a simple problem but I just can’t seem to figure it out. I have a standalone Elixir app that won’t find the database.
Dep...
New
Could someone help me? I'm making my first elixir program, number guessing game. I can't figure out how to convert the user's guess from ...
New
Hi all,
I've just started learning Elixir and Phoenix Framework, so please pardon my n00bness at this stage.
I'm trying to use Postg...
New
Hi,
I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New
Can someone explain the settings of pool_size of Ecto in config file? and what is the recommend size?
Thanks
New
To my knowledge, put_in, Map.update etc. all have the one limitation of not automatically creating intermediate keys when needed (for exa...
New
I have a super simple question about elixir - how would I take a file like this
foo bar baz
and output a new file that enumerates th...
New
Other popular topics
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New
TL;DR: I’ve just released an implementation of Microsoft’s IDE-independent Language Server Protocol for Elixir. It adds language support ...
New
Hello!
tl;dr Announcing Oban, an Ecto based job processing library with a focus on reliability and historical observability.
After spen...
New
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New
This post is a wiki (feel free to hit the edit button near the bottom right of this post to add your own changes!)
This post collects co...
New
Hi, this is for people who, like me, have had some friction using .html.heex templates in VSCode.
The solution seems to be, in a hyphena...
New
None of the current solutions worked well for me, so I went ahead and built a user management system from scratch.
This project took far...
New
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
Original source of discussion: This topic on the Pragmatic Programmers' Functional Web Development with Elixir, OTP, and Phoenix forum.
...
New
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New







