Testing Seeye with tpl, swipl and scryer-prolog

Seeye is a very premature “Second eye” which is under development at http://eulersharp.sourceforge.net/2021/02seeye

------------------
Second eye - Seeye
------------------

Seeye performs controlled chaining with Euler path detection.

Controlled chaining is backward chaining for rules like 'CONC :- PREM' and
forward chaining for rules like 'PREM => CONC'. For the latter the conclusion
can be a conjunction and it can also be 'false' to declare an inference fuse.

Euler paths are roughly "don't step in your own steps" which is inspired by
what Leonhard Euler discovered in 1736 for the Königsberg Bridge Problem.
Seeye sees the rule 'PREM => CONC' as 'PREM and NOT(CONC) implies CONC'.

Run all the tests via
$ ./test tpl                # using Trealla ProLog and taking about 0.690 sec
$ ./test swipl              # using SWI Prolog and taking about     1.420 sec
$ ./test scryer-prolog      # using Scryer-Prolog and taking about 33.390 sec

So there is time to do something differently? I tried to avoid the (=>)/2 problem by using (-:)/2 instead. Its just the mirror of (:-)/2. I picked seeye.pl and graph.pl. Whats the license, is it possibly to modify your code and upload it on gist as I did below?

Here are benchmark results, my system and SWI-Prolog:

?- time((between(1,10000,_), retractall(path(_,_)), 
             retractall(goal), seeye, fail; true)).
% Up 745 ms, GC 5 ms, Threads 738 ms (Current 02/14/21 01:28:55)
Yes

?- time((between(1,10000,_), retractall(path(_,_)), 
             retractall(goal), seeye, fail; true)).
% 3,370,000 inferences, 0.775 CPU in 0.865 seconds (90% CPU, 4349218 Lips)
true.

How do you like the operator (-:)/2 ? With this operator (-:)/2 you could have backward chaining rules realized through SWI-Prolog Picat style match (=>)/2 used by “Second eye”!

Open source:

Seeye performs controlled chaining
https://\gist.github.com/jburse/6fb59e01e3e1017303afc513d93caaa1#file-seeye-pl

Traversing graph paths
https://\gist.github.com/jburse/6fb59e01e3e1017303afc513d93caaa1#file-graph-pl

I was actually introducing (-:)/2 in illegal instruction for retina test · Issue #132 · infradig/trealla (github.com) to give the reasoner a hint to do forward chaining (instead of the usual backward chaining for (:-)/2) because I couldn’t find another way to solve the dpe.pl test case (trying hard with tabling but was loosing). But then coming from a Notation3 world where you simply say PREM => CONC as well as in the coherent logic and the TPTP world, logical implication is represented by the operator (=>)/2. I found the new use in swipl HEAD => BODY really contradictory with the classical logic use BODY => HEAD i.e. PREM => CONC.

Your code uses non-portable syntax. In SWI-Prolog one can do:

SWI-Prolog (threaded, 64 bits, version 8.3.19)

?- op(1150,xfx,'-:').
true.

?- assertz(re(b,X) -: not_re(c,X)).
true.

Which is not accepted by gprolog for example:

GNU Prolog 1.4.5 (64 bits)

?- op(1150,xfx,'-:').

?- assertz(re(b,X) -: not_re(c,X)).
uncaught exception: error(syntax_error('user_input:1 
(char:35) , or ) expected'),read_term/3)

So there is a kind of syntax corona virus. Since (’-:’)/2 has high operator priority
in gnu prolog, and many other Prolog systems, only extra parenthesis do work

?- assertz((re(b,X) -: not_re(c,X))).
yes

It could be that the “illegal instruction” was in fact a syntax error. But I dont
know what syntax Trealla Prolog or even Scryer-Prolog support. Whether they
also act syntax corona virus spreaders and do not require the missing parenthesis.

One can also make a case that it makes difficult editing Prolog texts.
Lets look at this example:

:- op(1150,xfx,'-:').

foo(_) :-
    write('I am good.'), nl.
foo(_,_) :-
    write('I am bad.'), nl.

:- foo(one -: two).

Now if you make find replace ‘two’ into ‘two, tree’, guess what
happens when you re-run the code?

1 Like
$ swipl
Welcome to SWI-Prolog (threaded, 64 bits, version 8.3.19-2-gc2ef0f4e8)
SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software.
Please run ?- license. for legal details.

For online help and background, visit https://www.swi-prolog.org
For built-in help, use ?- help(Topic). or ?- apropos(Word).

?- op(1150,xfx,'-:').
true.

?- assertz(re(b,X) -: not_re(c,X)).
true.

?- X -: Y.
X = re(b, _4036),
Y = not_re(c, _4036).


$ tpl
Trealla Prolog (c) Infradig 2020, v1.6.17
?- op(1150,xfx,'-:').
true.
?- assertz(re(b,X) -: not_re(c,X)).
true.
?- X -: Y.
X = re(b,_2),
Y = not_re(c,_2).


$ scryer-prolog
?- op(1150,xfx,'-:').
   true.
?- assertz(re(b,X) -: not_re(c,X)).
caught: error(syntax_error(incomplete_reduction),read_term/3:1)
?- assertz((re(b,X) -: not_re(c,X))).
   true.
?- X -: Y.
   X = re(b,_A), Y = not_re(c,_A).

See also http://eulersharp.sourceforge.net/2021/02seeye/LICENSE

Ok, thanks for testing. I tested TauProlog, in the online sandbox, it also
rather sides scryer-prolog than Trealla Prolog, concerning the relaxation
of the Prolog syntax. I get for TauProlog:

/* Tau Prolog 0.3.0 (beta) */

?- op(1150,xfx,'-:').
true.

?- assertz(re(b,X) -: not_re(c,X)).
error parsing query: throw(error(syntax_error(', or ) expected'),[line(1),column(16),found(-:)]))

BTW: The behaviour doesn’t depend on the operator (-:)/2, happens
also for other operators such as (=>)/2 etc… when they have a high priority.

1 Like

Fair enough, am reverting to the original (-:)/2 notation.
Original in the sense of what we introduced in illegal instruction for retina test · Issue #132 · infradig/trealla (github.com)