trealla-prolog / trealla

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

clpz: incorrect #430

Closed UWN closed 9 months ago

UWN commented 10 months ago

?- 1#>1.
   true, unexpected, unsound.
   false. % expected, but not found
infradig commented 10 months ago

Currently Trealla uses a modified version of clpz.pl with the goal-expansion of phrase/3 commented out. If i enable the goal_expansion version then the above query gives the expected result, however other tests are failing (I guess that is a problem for me to look at). What I was wondering just now is why the predicate definition of phrase/3 differs from the goal_expansion definition?

infradig commented 10 months ago

@triska Ok, the fact that the goal_expansion version works is just coincidental. An unexpected failure that mimics a real result failure. Something very off here...

?- trace, 2#>1.
[user:3:cp0] EXIT trace
[user:4:cp0] CALL 2#>1
[clpz:5:cp0] EXIT 2#>1
[clpz:6:cp0] CALL 2#>=1+1
[clpz:7:cp0] EXIT 2#>=1+1
[clpz:8:cp0] CALL clpz_geq(2,1+1)
[clpz:9:cp0] EXIT clpz_geq(2,1+1)
[clpz:10:cp0] CALL clpz_geq_(2,1+1)
[clpz:11:cp0] FAIL clpz_geq_(2,1+1)

It seems clpzgeq/2 didn't get expanded...

?- clpz:listing(clpz_geq_/2).
   true.
?- clpz:listing(clpz_geq/2).
clpz_geq(A,B) :-
   clpz_geq_(A,B),reinforce(A),reinforce(B).
   true.
?- 

EDIT: I have a pretty good idea what's wrong with goal expansion, will look into it.

UWN commented 10 months ago

Now:


?- 1#>1.
   clpz:(_A in inf..sup), unexpected.
infradig commented 10 months ago

Yes, still being worked on.

On Fri, Dec 15, 2023 at 6:27 PM UWN @.***> wrote:

Now:

?- 1#>1. clpz:(_A in inf..sup), unexpected.

— Reply to this email directly, view it on GitHub https://github.com/trealla-prolog/trealla/issues/430#issuecomment-1857474795, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFNKSEWMPXKMJYBSU5O7DILYJQCYLAVCNFSM6AAAAABAUVLK7WVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNJXGQ3TINZZGU . You are receiving this because you commented.Message ID: @.***>

infradig commented 10 months ago

I feel i've woken up in bizarro world...

$ tpl 
?- use_module(library(clpz)).
   true.
?- 1#>1.
   true.
?- trace,1#>1.
[user:3:cp0] EXIT trace
[user:4:cp0] CALL 1>=1+1
[user:5:cp0] FAIL 1>=1+1
   false.
?- 1#>1.
   true.
?- trace,1#>1.
[user:3:cp0] EXIT trace
[user:4:cp0] CALL 1>=1+1
[user:5:cp0] FAIL 1>=1+1
   false.
?- 

And, it's a top-level problem it seems...

?- true,1#>1.
   false.
?- 
UWN commented 10 months ago

?- 1#>1.
   false.
?- findall(t,1#>1,Ts).
   Ts = [].
?- call(findall(t,1#>1,Ts)).
   Ts = "t", unexpected.
   Ts = []. % expected, but not found
UWN commented 10 months ago

?- G_0=(1#>1),G_0.
   G_0 = (1#>1), unexpected.
?- G_0=(1#>1),call(G_0).
   G_0 = (1#>1), unexpected.
infradig commented 10 months ago

Look like more goal expansion problems.

On Sat, 16 Dec 2023, 16:59 UWN, @.***> wrote:

?- G_0=(1#>1),G_0. G_0 = (1#>1), unexpected. ?- G_0=(1#>1),call(G_0). G_0 = (1#>1), unexpected.

— Reply to this email directly, view it on GitHub https://github.com/trealla-prolog/trealla/issues/430#issuecomment-1858743061, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFNKSEW5IQVNHJOHWIVVQ4LYJVBDNAVCNFSM6AAAAABAUVLK7WVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNJYG42DGMBWGE . You are receiving this because you commented.Message ID: @.***>

UWN commented 10 months ago

(So..., should this be a separate issue or not? You closed similar issues recently)

And if I am at it, there is Item#75, which you ignore, but it only leads to less coverage.

infradig commented 10 months ago

Leave it.

On Sat, Dec 16, 2023 at 5:10 PM UWN @.***> wrote:

(So..., should this be a separate issue or not? You closed similar issues recently)

And if I am at it, there is Item#75 http://www.complang.tuwien.ac.at/ulrich/trealla-prolog/Item#75, which you ignore, but it only leads to less coverage.

— Reply to this email directly, view it on GitHub https://github.com/trealla-prolog/trealla/issues/430#issuecomment-1858745364, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFNKSERAPFY5QPXJU6RSTWLYJVCOPAVCNFSM6AAAAABAUVLK7WVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNJYG42DKMZWGQ . You are receiving this because you commented.Message ID: @.***>

infradig commented 10 months ago

Actually, G_0=(1#>1),G_0 should not be subject to goal_expansion/2 right? as seems to be the case. The static definitions are the ones being used and not working.

On Sat, Dec 16, 2023 at 4:59 PM UWN @.***> wrote:

?- G_0=(1#>1),G_0. G_0 = (1#>1), unexpected. ?- G_0=(1#>1),call(G_0). G_0 = (1#>1), unexpected.

— Reply to this email directly, view it on GitHub https://github.com/trealla-prolog/trealla/issues/430#issuecomment-1858743061, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFNKSEW5IQVNHJOHWIVVQ4LYJVBDNAVCNFSM6AAAAABAUVLK7WVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNJYG42DGMBWGE . You are receiving this because you commented.Message ID: @.***>

UWN commented 10 months ago

Goal expansion is really out of scope.

And your case, I'd say that, if at all, it happens when G_0 is called. That is, before G_0=(1#>1),G_0 is transformed to G_0=(1#>1),call(G_0), and thus call(1#>1) will be executed. And in that moment, maybe, goal expansion is called.

infradig commented 10 months ago

I believe Scryer seems to do it in call. SWI doesn't do it and SICStus docs say call etc DO NOT do it.

On Sat, Dec 16, 2023 at 5:21 PM UWN @.***> wrote:

Goal expansion is really out of scope.

And your case, I'd say that, if at all, it happens when G_0 is called. That is, before G_0=(1#>1),G_0 is transformed to G_0=(1#>1),call(G_0), and thus call(1#>1) will be executed. And in that moment, maybe, goal expansion is called.

— Reply to this email directly, view it on GitHub https://github.com/trealla-prolog/trealla/issues/430#issuecomment-1858747822, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFNKSEXKBUPEUY6YAFQITK3YJVDYDAVCNFSM6AAAAABAUVLK7WVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNJYG42DOOBSGI . You are receiving this because you commented.Message ID: @.***>

infradig commented 10 months ago

Scryer also does it in negation, SWI doesn't. Don't know about SICStus.

On Sat, Dec 16, 2023 at 5:21 PM UWN @.***> wrote:

Goal expansion is really out of scope.

And your case, I'd say that, if at all, it happens when G_0 is called. That is, before G_0=(1#>1),G_0 is transformed to G_0=(1#>1),call(G_0), and thus call(1#>1) will be executed. And in that moment, maybe, goal expansion is called.

— Reply to this email directly, view it on GitHub https://github.com/trealla-prolog/trealla/issues/430#issuecomment-1858747822, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFNKSEXKBUPEUY6YAFQITK3YJVDYDAVCNFSM6AAAAABAUVLK7WVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNJYG42DOOBSGI . You are receiving this because you commented.Message ID: @.***>

UWN commented 10 months ago

Clearly uncharted territory. Strictly speaking, the expansion should not influence the meaning whatsoever.

infradig commented 10 months ago

This should be fixed now.

infradig commented 9 months ago

I think fixed.