3 ms·
I always wanted to have clp, constraint logic solver facilities in regular languages. But I wanted all variables to be symbolic when used in clp context, and th
by rurban 11y ago
I always wanted to have clp, constraint logic solver facilities in regular languages.
But I wanted all variables to be symbolic when used in clp context, and then just assert and support for = with lhs functions needs to be added.
The trick is to find all symbolic variables involved by the compiler, but it's really trivial. cmbc does it e.g. for the C language. http://www.cprover.org/cbmc/ http://www.cprover.org/cbmc/
My plan is this:
http://perl11.org/cperl/perlcperl.html#clp http://perl11.org/cperl/perlcperl.html#clp
use clp;
sub fact(int $i=0) :int {
assert $i>=0; return $i ? fact($i-1) : 1 }
say fact(7); # => 5040
fact($_) = 5040; # solve it!
say $_; # => 7
Rosetta for example uses the typical simple LISP approach, by having to manually declare the symbols, which are being backtracked on. amb() is similar, expressing ambiguity. This goes back to 1963. http://community.schemewiki.org/?amb http://community.schemewiki.org/?amb