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

max_depth/1 now incorrect #2053

Closed
UWN opened this issue Sep 27, 2023 · 3 comments
Closed

max_depth/1 now incorrect #2053

UWN opened this issue Sep 27, 2023 · 3 comments

Comments

@UWN
Copy link

UWN commented Sep 27, 2023

?- A = B*A, write_term(A,[max_depth(5)]).
   outputs("_601031* ..."), unexpected,  A = B*A.
@mthom
Copy link
Owner

mthom commented Sep 27, 2023

This happens because of the cyclicity of A, not the max_depth setting.

@UWN
Copy link
Author

UWN commented Sep 28, 2023

But in the context of max_depth being positive, there are simply no cycles. So what is expected is what SICStus or GNU produce:

% SICStus:
| ?- A = B*A, write_term(A,[max_depth(5)]), fail.
_1185*(_1185*(_1185*(_1185*(_1185* ...))))
% GNU:
| ?- A = B*A, write_term(A,[max_depth(5)]), fail.
_280*(_280*(_280*(_280*(_280* ...))))

@UWN
Copy link
Author

UWN commented Sep 28, 2023

One consequence of this is that the internal representation is leaked to the outside. Consider the equivalent1 query:

?- A=B*A1,A1=B*A, write_term(A,[max_depth(5)]).
_43*(_43* ...)   A = B*(B*A), A1 = B*(B*A1). % unexpected.

In both SICStus and GNU the very same text is written (in SICStus, the variable numbering is now different, so to get exactly the same result:

| ?- A=B*A1,A1=B*A, write_term(A,[variable_names(['B'=B]),max_depth(5)]).
B*(B*(B*(B*(B* ...))))

1 Strictly speaking, this equivalence only holds for **rational tree unification**, but that is the unification default here

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