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

Problem with if->then & cut #650

Open
infradig opened this issue Dec 26, 2024 · 3 comments
Open

Problem with if->then & cut #650

infradig opened this issue Dec 26, 2024 · 3 comments

Comments

@infradig
Copy link
Contributor

This is ok...

$ scryer-prolog
?- [user]. main :- (true;true), writeln(X), (true->!;!), fail. main:-writeln(oops). end_of_file.
% Warning: singleton variables X at line 0 of user
?- main.
_16515
   false.

~/trealla (devel) $ tpl
?- [user]. main :- (true;true), writeln(X), (true->!;!), fail. main:-writeln(oops). end_of_file.
   true.
?- main.
_0
   false.
?- 

but...

$ scryer-prolog
?- [user]. a(1). a(2). main :- a(X), writeln(X), (true->!;!), fail. main:-writeln(oops). end_of_file.
?- main.
1
   false.
?- 
~/trealla (devel) $ tpl
?- [user]. a(1). a(2). main :- a(X), writeln(X), (true->!;!), fail. main:-writeln(oops). end_of_file.
   true.
?- main.
1
oops
   true.
@flexoron
Copy link

Variant of 'This is ok...' from above:

$ scryer-prolog -f
?- [user]. main :- (true;true), write(X), (!->true;!), fail. main:-write(oops). end_of_file.
% Warning: singleton variables X at line 0 of user
?- main.
_78   false.
?- halt.

% This seems not ok...
$ tpl
?- [user]. main :- (true;true), write(X), (!->true;!), fail. main:-write(oops). end_of_file.
   true.
?- main.
_0_0oops   true.
?- 

As you say the problem is within 'if' and 'then' but not with the 'else' cut

?- [user]. main :- (true;true), write(X), ((\+!)->true;!), fail. main:-write(oops). end_of_file.
Warning: overwriting 'main'/0
   true.
?- main.
_0   false.

@infradig
Copy link
Contributor Author

Scryer is wrong here...

$ scryer-prolog -f
?- [user]. main :- (true;true), write(X), (!->true;!), fail. main:-write(oops). end_of_file.
% Warning: singleton variables X at line 0 of user
?- main.
_78   false.
?- halt.

and Trealla right. The if is cut-proof.

@flexoron
Copy link

Learning never stops.
Another dissent on the issue:

$ scryer-prolog -f
?- [user]. a(1). a(2). main :- (a(X);b(X)), write(X), nl, (true -> !;!), fail. main:-write(oops). b(3).  end_of_file.
?- main.
1
   false.
?- halt.

$ tpl
?- [user]. a(1). a(2). main :- (a(X);b(X)), write(X), nl, (true -> !;!), fail. main:-write(oops). b(3).  end_of_file.
   true.
?- main.
1
3 % Scryer does not print b(X).
   false.
?- halt. 

$ tpl
?- [user]. a(1). a(2). main :- (a(X);b(X)), write(X), nl, (true -> !;!), fail. main:-write(oops). b(3). b(4).  end_of_file.
   true.
?- main.
1
3
oops   true. % a second b/1 restores the 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