trealla-prolog / trealla

A compact, efficient Prolog interpreter written in plain-old C.
MIT License
268 stars 13 forks source link

getting answers that are just a variable #571

Closed josd closed 2 months ago

josd commented 2 months ago

https://github.com/josd/cigol/blob/main/cases/graph.pl is giving

$ tpl -g run,halt graph.pl
'https://josd.github.io/cigol#path'('http://example.org/#angers','http://example.org/#nantes').
_0.
_0.
_0.

instead of

$ scryer-prolog -g run,halt graph.pl
'https://josd.github.io/cigol#path'('http://example.org/#angers','http://example.org/#nantes').
'https://josd.github.io/cigol#path'('http://example.org/#paris','http://example.org/#nantes').
'https://josd.github.io/cigol#path'('http://example.org/#chartres','http://example.org/#nantes').
'https://josd.github.io/cigol#path'('http://example.org/#lemans','http://example.org/#nantes').
josd commented 2 months ago

this is with

$ tpl -v
Trealla Prolog (c) Infradig 2020-2023, v2.54.6
josd commented 2 months ago

(maybe also update to 2024 :))

infradig commented 2 months ago

A problem with TCO here:

'https://josd.github.io/cigol#path'(A,C) :-
    'https://josd.github.io/cigol#oneway'(A,B),
    'https://josd.github.io/cigol#path'(B,C).

for now either -O0 or change to:

'https://josd.github.io/cigol#path'(A,C) :-
    'https://josd.github.io/cigol#oneway'(A,B),
    'https://josd.github.io/cigol#path'(B,C), true.

I'll look into it further soon.

josd commented 2 months ago

Thx and with the added true now we get https://github.com/josd/cigol/blob/main/cases/output/graph-trealla.pl

josd commented 2 months ago

It now works fine with the fix https://github.com/trealla-prolog/trealla/commit/3763b0ce2a91ed8ca811fc8c66ef0b862096590d Thx

josd commented 2 months ago

The issue is back using v2.55.4, this time for the https://github.com/josd/cigol/blob/main/cases/control.pl case where we get https://github.com/josd/cigol/commit/12f93953291a8e5119463704e27950dccfce785d

josd commented 2 months ago

Thanks for the fix and now it works fine 👍

josd commented 2 months ago

the cases in this issue are now moved to https://github.com/eyereasoner/see/tree/main/cases