scryer-prolog icon indicating copy to clipboard operation
scryer-prolog copied to clipboard

Porting library(diadem) to Scryer Prolog

Open triska opened this issue 4 years ago • 4 comments

I am trying to port Ulrich Neumerkel's library(diadem) to Scryer Prolog for declarative debugging. The current state of the port is in the diadem branch at:

https://github.com/triska/scryer-prolog/tree/diadem

See specifically diadem.pl for the source.

So far, loading the library works:

?- use_module(library(diadem)).
   true.

However, trying the example from the source file, I get:

?- "caenum" = "caelum".?X.
caught: error(existence_error(procedure,limes/4),limes/4)

Why? limes/4 is defined in the file, so this should work. (Update: resolved by adding a meta_predicate/1 declaration)

Update:

The current state of the issue is:

?- "caenum" = "caelum".?X.
caught: error(existence_error(procedure,'$free_variable_set'/3),'$free_variable_set'/3)

@UWN: Could you please advise what is needed here, and what should be added to Scryer Prolog to emulate '$free_variable_set'/3 in a conforming system?

I see also that numbervars/4 is used by the library, should that be added to Scryer Prolog or is it possible to solve this differently?

triska avatar Feb 28 '21 11:02 triska

I'm pretty sure limes/4 can't be found because if/3 isn't declared as a meta-predicate.

mthom avatar Feb 28 '21 15:02 mthom

Ah yes, thank you a lot!

triska avatar Feb 28 '21 16:02 triska

I now get:

$ scryer-prolog -f diadem.pl
?- "caenum" = "caelum".?X.
thread 'main' panicked at 'Out of bounds access', src/machine/compile.rs:1666:41
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Update: The crash is now resolved.

triska avatar Dec 18 '23 22:12 triska

Thank you, I have updated the initial description with the current state of the issue:

?- "caenum" = "caelum".?X.
   error(existence_error(procedure,'$free_variable_set'/3),'$free_variable_set'/3).

triska avatar Dec 18 '23 22:12 triska