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

library(clpb): Unexpected domain error #360

Open
triska opened this issue Oct 8, 2023 · 3 comments
Open

library(clpb): Unexpected domain error #360

triska opened this issue Oct 8, 2023 · 3 comments

Comments

@triska
Copy link

triska commented Oct 8, 2023

To reproduce this issue, please save the following example program as testing.pl:

:- use_module(library(clpb)).

permutation([], []).
permutation(List, [First|Perm]) :-
        select(First, List, Rest),
        permutation(Rest, Perm).

sat(_)  --> [].
sat(X*Y) --> [_], sat(X), sat(Y).
sat(X+Y) --> [_], sat(X), sat(Y).
sat(X#Y) --> [_], sat(X), sat(Y).
sat(card([0,1],[X,Y])) --> [_], sat(X), sat(Y).

vs_eqs(Vs, Eqs) :- phrase(vs_eqs(Vs), Eqs).

vs_eqs([]) --> [].
vs_eqs([V|Vs]) --> vs_eqs_(Vs, V), vs_eqs(Vs).

vs_eqs_([], _) --> [].
vs_eqs_([V|Vs], X) --> vs_eqs_(Vs, X), ( [X=V] ; [] ).

run(N) :-
        length(Ls, N),
        portray_clause(N),
        phrase(sat(Sat1), Ls),
        phrase(sat(Sat2), Ls),
        term_variables(Sat1-Sat2, Vs0),
        permutation(Vs0, Vs),
        vs_eqs(Vs, Eqs),
        findall(Vs, (sat(Sat1),sat(Sat2),maplist(call, Eqs),labeling(Vs)), Sols1),
        findall(Vs, (labeling(Vs),maplist(call,Eqs),sat(Sat1*Sat2)), Sols2),
        (   sort(Sols1, Sols), sort(Sols2, Sols) -> true
        ;   throw(neq-Sat1-Sat2-Eqs-Vs0-Vs-Sols1-Sols2)
        ),
        false.

run :- run(_).

And then do:

$ ./tpl -O0 testing.pl
Trealla Prolog (c) Infradig 2020-2023, v2.29.3
?- run.
0.
1.
   error(domain_error(clpb_variable,[_23,[_23,[_23|_24],_25],_25]),unknown([_23,[_23|_24],_25])-1), unexpected.
infradig added a commit that referenced this issue Oct 12, 2023
@triska
Copy link
Author

triska commented Oct 12, 2023

Very nice, thank you a lot! Let's continue with #366.

@triska triska closed this as completed Oct 12, 2023
@infradig infradig reopened this Oct 13, 2023
@infradig
Copy link
Contributor

Was fixed due to a typo, so not really. Re-opening this.

@triska
Copy link
Author

triska commented Oct 13, 2023

I now no longer get a domain error, so the specific instance of this issue seems resolved.

However, a different issue remains:

?- run.
0.
1.
   neq-_23*_24-(_25+_26)-[_23=_24,_25=_26]-[_23,_24,_25,_26]-[_23,_24,_25,_26]-[]-[[1,1,1,1]].

#369 may be a shorter example of this issue.

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

2 participants