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

Feature request , add period to the operator stoppers #1297

Closed
Jean-Luc-Picard-2021 opened this issue Feb 25, 2022 · 7 comments
Closed

Feature request , add period to the operator stoppers #1297

Jean-Luc-Picard-2021 opened this issue Feb 25, 2022 · 7 comments

Comments

@Jean-Luc-Picard-2021
Copy link

Jean-Luc-Picard-2021 commented Feb 25, 2022

Contrary to what I expected, Scryer Prolog already implements
a stopper strategy for operators. For example I get on -b rebis-dev:

$ target/release/scryer-prolog --version
"v0.8.123-892-gd92d8bc"
$ target/release/scryer-prolog
?- current_op(X,Y,+).
   X = 500, Y = yfx
;  X = 200, Y = fy
;  false.
?- current_op(X,Y,-).
   X = 500, Y = yfx
;  X = 200, Y = fy
;  false.
?- [user].
foo(+,-,-).
^D

The latest input line is accepted. I do not have to write foo((+),(-),(-)).
I guess this works because prefix parsing stops before comma ','
and right parenthesis ')'? Not sure how Scryer Prolog implements.

In my opinion prefix parsing should also stop before the period '.'.
So that we can read TPTP Syntax directly from within Scryer Prolog.
Currently it doesn't work as expected:

?- op(200,fy,!).
   true.
?- [user].
foo :- !.
caught: error(syntax_error(incomplete_reduction),read_term/3:2)

This is related to this ticket:
#1289

@Jean-Luc-Picard-2021
Copy link
Author

Jean-Luc-Picard-2021 commented Feb 25, 2022

It is clear that UWN downvotes this feature request, because
UWN opposes a living standard Prolog. Scryer Prolog already implements
living standard, since it accepts for example foo(+,-,-) and current_op(X,Y,+).

Why stop half way, and implement living standard Prolog only 50%.
SWI-Prolog is much better off, it has a larger stopper set. And therefore
can read TPTP Syntax. Scryer Prolog on the other hand has only implemented

the strategy of the living standard half way.

@UWN
Copy link

UWN commented Feb 25, 2022

Not sure what Scryer Prolog implements.

Scryer implements ISO syntax in which foo(+,-,-). is valid syntax. See 6.3.3.1.

@Jean-Luc-Picard-2021
Copy link
Author

Jean-Luc-Picard-2021 commented Feb 25, 2022

I don't have the ISO standard on my Hard Disk right now, have a new
computer with a clean Hard Disk. What does 6.3.3.1 say?

And why would foo(+,-,-) valid syntax be relevant, it neither explains
an implementation, and I am asking for foo :- ! valid syntax.

By "what" Scryer Prolog implements, I am not refering to what
spec it uses, rather "how" it implements. I have edited the phrasing.

@Jean-Luc-Picard-2021
Copy link
Author

BTW: Living standard Prolog is probably the correct name to address
the issue. For example TauProlog shows also more flexibility, already
for the ')' stopper:

/* Tau Prolog 0.3.2 (beta) */
?- op(200,fy,!).
true.
?- X = foo(!).
X = foo(!)
?- X = (foo :- !).
X = (foo:-!).

Scryer Prolog also fails this living standard Prolog test:

$ target/release/scryer-prolog
?- op(200,fy,!).
   true.
?- X = foo(!).
   X = foo(!).
?- X = (foo :- !).
caught: error(syntax_error(incomplete_reduction),read_term/3:1)

@triska
Copy link
Contributor

triska commented Feb 25, 2022

Tau Prolog should be stricter in such cases so that we can also use it to reliably detect portable syntax, there is an existing issue for this: tau-prolog/tau-prolog#286

@Jean-Luc-Picard-2021
Copy link
Author

Jean-Luc-Picard-2021 commented Feb 25, 2022

I don't think Tau Prolog should change anything. It will break TPTP Syntax, like here:

Cannot consult file
#1289

So its not a bug. The ISO core standard is inflexible. Its better to implement
a living standard Prolog, than strictly follow ISO core standard, because there
are a lot of legacy Prolog texts, that need to be also supported.

You have to publish a legacy to ISO converter on your Scryer Prolog website,
if you want to use legay Prolog texts. But I nowehere find such a converter
utility. Scryer Prolog leaves their users alone. On the other hand Tau Prolog

can use legacy Prolog texts directly. This is a plus and thumbs up

for TauProlog that it doesn't follow such inflexibility.

@Jean-Luc-Picard-2021
Copy link
Author

Ok I found a way to convert legacy Prolog text into Scryer Prolog
format. The steps are relatively simple:

  1. Consult the Prolog text in SWI-Prolog

  2. Call listing/[0,1] in SWI-Prolog

SWI-Prolog puts an additional parenthesis around operators, even
when they were not there during input. So for example I get now:

?- listing(prove2/_).
prove2(?[X]:Fml, UnExp, Lits, FreeV, VarLim) :-
    VarLim>0,
    (!),
    copy_term((X, Fml, FreeV),
              (X1, Fml1, FreeV)),
    append(UnExp, [?[X]:Fml], UnExp1),
    VarLim2 is VarLim+ -1,
    prove2(Fml1,
           UnExp1,
           Lits,
           [X1|FreeV],
           VarLim2)

The SWI-Prolog output seems to have sufficient quality so that
I can run it with Scryer Prolog, redoing my benchmarks gives me:

?- time((between(1,10,_), test(time, seq), fail; true)).
   % CPU time: 0.435s
   true.
?- time((between(1,10,_), test(time, tap), fail; true)).
   % CPU time: 0.197s
   true.

Thanks to this automatic conversion, I am now willingly to test more
TPTP stuff. Like for example to test also leanTap= and leanSeq= as
I did for SWI-Prolog WASM.

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