XSB Prolog meta-interpreter issue with clpr constraints

71 views Asked by At

I am running XSB Prolog on my Mac (El Capitan 10.11.2): XSB Version 3.6. (Gazpatcho) of April 22, 2015 [i386-apple-darwin15.2.0 64 bits; mode: optimal; engine: slg-wam; scheduling: local] [Build date: 2016-01-17]

I am using the clpr package and want to write a little meta-interpreter:

:- [clpr].
try((G1,G2)):- !, try(G1), try(G2).
try((G1; G2)):- !, try(G1); try (G2).
try(true):- !.
try({X}):- !, {X}.
try(G):- clause(G, Body), try(Body).

However, try({X=1+2}) does not work -- it does not match the fourth clause, and descends into the fifth clause.

Any idea why?

2

There are 2 answers

0
Vijay Saraswat On

Hmm, it seems that if a load the file containing the code with load_dyn(test) the code works. (It does not work if i just consult the file, i.e. load it with [test].

0
Paulo Moura On

This is indeed strange. If you reconsult your code twice, then you get the expected result:

XSB Version 3.6. (Gazpatcho) of April 22, 2015
[i386-apple-darwin15.3.0 64 bits; mode: optimal; engine: slg-wam; scheduling: local]
[Build date: 2016-02-07]

| ?- reconsult(xsbb).
[xsbb loaded]
[clpr loaded]
[dump loaded, cpu time used: 0.0010 seconds]
[itf loaded]
[geler loaded]
[class loaded]

yes
| ?- reconsult(xsbb).
[xsbb loaded]
[clpr loaded, cpu time used: 0.0010 seconds]
[dump loaded]
[itf loaded]
++Warning[XSB]: [Runtime/P]  replacing previous verify_attribute_handler for module itf
[geler loaded]
++Warning[XSB]: [Runtime/P]  replacing previous verify_attribute_handler for module geler
[class loaded]
++Warning[XSB]: [Runtime/P]  replacing previous verify_attribute_handler for module class
++Warning[XSB]: [Runtime/P]  replacing previous constraint_portray_hook for module clpr

yes
| ?- try({X=1+2}).

X = 3.0000

yes