News for hackers. Stuff that matters.
Re:Interpreter for a simple Lisp, Written in Prolog by tom_mellior on Friday March 01, 2019 @02:55PM (#19284651)
> I was left wishing that there was a better way to express the logical constraints, which in any case can be converted to integer linear equations, while keeping the linear equations where needed and possible.

SWI-Prolog's clpfd library allows you to mix linear and non-linear integer constraints with "reified" versions that allow you to write implications and such. Silly example:

    ?- [A, B, C] ins 0..3, A #< B #==> C #= A * B, A #>= B #<==> C #\= B.
This means "for values A, B, C each in the range 0 to 3, if A is less than B, then C is equal to A * B, and A is greater than or equal to B if and only if C is different from B". Is this the kind of constraints you were thinking of?
Re:Interpreter for a simple Lisp, Written in Prolog by rscho on Friday March 01, 2019 @04:41PM (#19285545)
I read in several places (that I don't remember unfortunately) that prolog experts discouraged the use of SWI clpqr because it contained major mistakes. Does anyone know if it is still the case and if clpfd suffers from the same issues?
Re:Interpreter for a simple Lisp, Written in Prolog by tom_mellior on Friday March 01, 2019 @05:43PM (#19286054)
I doubt that, but it's hard to tell as this is kind of vague. CLP(FD) talks about integers, CLP(Q) and CLP(R) talk about rationals and reals, respectively. If you approximate rationals or reals with floating point, you will get into situations where you compute nonsense, so in that sense at least CLP(R) has issues, but that kind of issue would have nothing to do with CLP(FD).
Re:Interpreter for a simple Lisp, Written in Prolog by rscho on Friday March 01, 2019 @06:08PM (#19286202)
https://github.com/SWI-Prolog/packages-clpqr/issues/4

Also cited at https://www.metalevel.at/swissues

I also read it on SO, but can't find it. I do however remember that it was said that the SWI lib was ported from the SICSTUS one, and that mistakes were added in the process, and that it couldn't be recommended for that reason.

Re:Interpreter for a simple Lisp, Written in Prolog by 0db532a0 on Friday March 01, 2019 @07:28PM (#19286624)
Out of interest, do you know whether there are any problems with the SICStus version, and is there anything wrong with using SICStus over SWI?
Re:Interpreter for a simple Lisp, Written in Prolog by rscho on Saturday March 02, 2019 @02:23AM (#19288070)
It was stated that the SICSTUS version was correct, but I am no expert. To my knowledge, SICSTUS is the prolog Rolls-Royce, so there's certainly nothing wrong with that.
Re:Interpreter for a simple Lisp, Written in Prolog by 0db532a0 on Friday March 01, 2019 @07:25PM (#19286607)
Seems like I was looking for CLPQR with logical constraints, which doesn't seem to exist.
Re:Interpreter for a simple Lisp, Written in Prolog by rscho on Saturday March 02, 2019 @02:26AM (#19288080)
If you want to do constraints, I'd argue that ECLiPSE prolog is probably best. You can also use a variety of solvers from it.