Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

setof/3 incorrect #233

Closed
UWN opened this issue Jul 2, 2023 · 18 comments
Closed

setof/3 incorrect #233

UWN opened this issue Jul 2, 2023 · 18 comments

Comments

@UWN
Copy link

UWN commented Jul 2, 2023

Item#42

@UWN
Copy link
Author

UWN commented Jul 4, 2023

This is important.

@infradig
Copy link
Contributor

infradig commented Jul 4, 2023 via email

@UWN
Copy link
Author

UWN commented Jul 4, 2023

Common? Apart from Scryer, I do not see another system with this problem.

@infradig
Copy link
Contributor

infradig commented Jul 4, 2023 via email

@UWN
Copy link
Author

UWN commented Jul 5, 2023

Thank you, I'm getting sloppy... . But at least I corrected my test cases.

@UWN
Copy link
Author

UWN commented Jul 5, 2023

Tau works with setof/3, but has a bug with handling underscore variables. tau-prolog/tau-prolog#354

@infradig
Copy link
Contributor

infradig commented Jul 5, 2023 via email

@infradig
Copy link
Contributor

infradig commented Jul 5, 2023 via email

@pmoura
Copy link

pmoura commented Jul 5, 2023

I added those two tests to the latest Logtalk git version: LogtalkDotOrg/logtalk3@cc74f95. I bit tricky to adapt given that order of solutions returned by bagof/3 is undefined per the ISO Prolog Core standard (not to mention having to use bagof/3 to collect all the solutions to the test goal so that variables are preserved).

@infradig
Copy link
Contributor

infradig commented Jul 5, 2023 via email

@UWN
Copy link
Author

UWN commented Jul 5, 2023

Now it's

?- L=[_,_,_], setof(t,member(E,L),_).
   L = [_A,_,_], E = _, unexpected, unsound.

These anonymous underscores in answers are all odd. Sometimes they appear, and sometimes they are named. It would be ideal to have no anonymous underscores in answers, similar to SICStus, Scryer.

@infradig
Copy link
Contributor

infradig commented Jul 5, 2023 via email

infradig added a commit that referenced this issue Jul 5, 2023
@pmoura
Copy link

pmoura commented Jul 5, 2023

$ logtalk_tester -p trealla
% Batch testing started @ 2023-07-05 23:05:17
%         Logtalk version: 3.68.0-b01
%         Trealla Prolog version: 2.21.16
%
% Documents/Logtalk/logtalk3/tests/prolog/predicates/setof_3
%         40 tests: 2 skipped, 38 passed, 0 failed (0 flaky)
%         completed tests from object tests in 1 second
%         clause coverage n/a
%
% Skipped tests
Documents/Logtalk/logtalk3/tests/prolog/predicates/setof_3/tests.lgt - eddbali_setof_3_25 @ tests
Documents/Logtalk/logtalk3/tests/prolog/predicates/setof_3/tests.lgt - lgt_setof_3_36 @ tests
%
% 1 test sets: 1 completed, 0 skipped, 0 broken, 0 timedout, 0 crashed
% 40 tests: 2 skipped, 38 passed, 0 failed (0 flaky)
%
% Batch testing ended @ 2023-07-05 23:05:19

@UWN
Copy link
Author

UWN commented Jul 6, 2023

?- L=[_,_,_], setof(t,member(E,L),_).
   L = [_A,_B,_C], E = _A
;  L = [_A,_B,_C], E = _B
;  L = [_A,_B,_C], E = _C.

It's all perfect, but why and when do you write these intermediary variables? In other words, why not the same as in

?- length(L,3), setof(t,member(E,L),_).
   L = [E,_A,_B]
;  L = [_A,E,_B]
;  L = [_A,_B,E].

(Could be, that you treat the underscores as kind-of-named variables)

@UWN UWN closed this as completed Jul 6, 2023
@infradig
Copy link
Contributor

infradig commented Jul 6, 2023 via email

@UWN
Copy link
Author

UWN commented Jul 6, 2023

?- length(L,3), setof(t,member(E,L),_),L=[_,_,_].
   L = [E,_A,_B]
;  L = [_A,E,_B]
;  L = [_A,_B,E].
?- length(L,3), L=[_,_,_],setof(t,member(E,L),_).
   L = [_A,_B,_C], E = _A
;  L = [_A,_B,_C], E = _B
;  L = [_A,_B,_C], E = _C.

What do you mean by the order the variables are bound?

@infradig
Copy link
Contributor

infradig commented Jul 6, 2023 via email

@UWN
Copy link
Author

UWN commented Jul 6, 2023

In the third case, there are three times two named variables which are unified. So in this situation, one has to state that E = A or A = E &ct. So it is inevitable to have two answer substitutions. But not for the first two cases. (The reason this interests me so much is my suspicion that this differences is somehow induced by the internal representation. So some things that should not be visible, become visible. After all, we have still #216 open.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants