https://savannah.gnu.org/forum/forum.php?forum_id=9203
In fact it's a better prolog, picat, which also allows pretty straightforward statements, like loops, and has solver support.
https://savannah.gnu.org/forum/forum.php?forum_id=9203
In fact it's a better prolog, picat, which also allows pretty straightforward statements, like loops, and has solver support.
1) personally I think Prolog is much more broadly applicable in all kinds of apps rather than just type inference, policy languages, games; but with the recent rise of Datalog as actual query and inference language (and not just in academic database literature), it seems Prolog's time has finally come
writing prolog is mostly about writing in the most natural and readable syntax possible. using haskell-like types put me off.
It's a biig discussion and I'm not the one to make the argument for CLP, but, for example, in straight-up Prolog arithmetic is implemented using the is/2 predicate, which looks a bit like this:
A is 1 + 2.
Where A is the result of the addition of 1 and 2. In CLP on the other hand, particularly in the CLP library for reasoning over integers, CLP(FD), the addition above looks like this: X #= 1+2.
Note that here, "#=/2" ("equals") is a constraint, so the statement above is true, iff the expression on the left-hand side of the #= is equal to the right-hand side of it. Which lets you do things like this: ?- 3 #= Y+2.
Y = 1.
Where trying to do the same thing with is/2 will give you an error (because Y is not sufficiently instantiated). And because of how constraint programming works, you can also do arithmetic with ranges, like so: ?- X #= A + B, A in 1..3, B in 4..6.
X in 5..9,
A+B#=X,
A in 1..3,
B in 4..6.
In fact, what comes out the other end of the query above (the bit after the query prompt, "?") is a set of new constraints, where the result of adding A in [1,3] and B in [4,6] is a number, X, in [5,9].You can find more information in the CLP(FD) library documentation, here:
http://www.swi-prolog.org/man/clpfd.html
Or, if Markus Triska (the author of the library) is around, he can probably elucidate its use a bit better than I can :)