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

Toplevel should use copy_term/3 to show residual goals #254

Closed
triska opened this issue Dec 6, 2019 · 1 comment
Closed

Toplevel should use copy_term/3 to show residual goals #254

triska opened this issue Dec 6, 2019 · 1 comment

Comments

@triska
Copy link
Contributor

triska commented Dec 6, 2019

Here are several interrelated issues resulting from the desire to correctly show residual goals on the toplevel.

Starting with clpz10.pl from https://www.metalevel.at/clpz/scryer/clpz10.pl and the following program:

:- use_module(clpz10).

puzzle([S,E,N,D] + [M,O,R,E] = [M,O,N,E,Y]) :-
        Vars = [S,E,N,D,M,O,R,Y],
        Vars ins 0..9,
        all_different(Vars),
                  S*1000 + E*100 + N*10 + D +
                  M*1000 + O*100 + R*10 + E #=
        M*10000 + O*1000 + N*100 + E*10 + Y,
        M #\= 0, S #\= 0.

I get:

?- puzzle(Ps).
Ps = ([9,_751,_1102,_1453]+[1,0,_2506,_751]=[1,0,_1102,_751,_2857]) ;
false.

However, these variables are involved in constraints, and I therefore expect to see residual constraints.

I can obtain them as a list Gs of goals with copy_term/3:

?- puzzle(Ps), copy_term(Ps, Copy, Gs).

In this example, Copy is a fresh copy of the term Ps, and I therefore expect the following query to succeed, although it currently unexpectedly fails:

?- puzzle(Ps), copy_term(Ps, Copy, Gs), Ps = Copy.
false.

In particular, the following should succeed, and the toplevel should use this to obtain the list Gs of residual goals:

?- puzzle(Ps), copy_term(Ps, Ps, Gs).

Currently, it unexpectedly fails, and the toplevel does not show the residual goals at all.

After this query has failed, the earlier query suddenly yields much more output, and the output also contains terms that are not residual goals, such as:

?- puzzle(Ps), copy_term(Ps, Copy, Gs).
..., clpz, u33, ...

Please see #253 for a crash that is also related to this.

@triska
Copy link
Contributor Author

triska commented Apr 6, 2020

This now works correctly, thank you a lot!

@triska triska closed this as completed Apr 6, 2020
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

1 participant