-
Notifications
You must be signed in to change notification settings - Fork 1
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
sld
resolution doesn't work in graphviz_swish.pl
#1
Comments
I think this is fixed in the following file (added .txt extension to stop GitHub complaining...) |
In my Prolog interpreter this works just fine. There are couple of issues in SWISH though. First of all,
It took me quite a while to find the cause of this error; it is due to this predicate:
Once it's removed
Do you remember what's the purpose of
|
Thanks Kacper, I forgot about predicate_property/2 being sandboxed. The purpose of that clause is to create a leaf in the SLD tree for built-in predicates. Please make sure to remove the whole clause with resolve(A,true) in the head.
Is there a way for me to try it out locally within SWISH? I tried editing graphviz_swish.pl locally and run a SWISH server on localhost, but that didn’t appear to have the desired effect.
Best wishes,
—Peter
… On 28 Dec 2016, at 02:19, Kacper Sokol ***@***.***> wrote:
In my Prolog interpreter this works just fine. There are couple of issues in SWISH though.
First of all, tell and told have to be commented out due to sandbox limitations, but this is fine.
Then I got an error message about predicate_property/2 being sandboxed as well; that's fine I commented it out.
Then I got the following error message:
Arguments are not sufficiently instantiated
Reachable from:
resolve(A,B)
prove_d(A,student_of(B,peter),C,D)
prove_d(student_of(A,peter),student_of(A,peter),0,5)
sld(student_of(A,peter),5,B)
sld(student_of(A,peter),B)
sld1(A)
swish_trace:swish_call(sld1(A))
'$swish wrapper'(sld1(A),B)
It took me quite a while to find the cause of this error; it is due to this predicate:
resolve(A,true):-
%predicate_property(A,built_in),!, % I commented this out because of sandboxing
call(A).
Once it's removed sld/2 seems to work fine and outputs:
L = 'digraph {node [shape=plaintext, fontname=Courier, fontsize=12]0 [label="?-student_of(_G6713,peter)"];1 [label=":-follows(_G6713,_G7000),\\nteaches(peter,_G7000)"];0 -> 1;2 [label=":-call((follows(_G6713,_G7000),teaches(peter,_G7000)))"];1 -> 2;3 [label=":-call((follows(_G6713,_G7000),teaches(peter,_G7000)))"];2 -> 3;4 [label=":-call((follows(_G6713,_G7000),teaches(peter,_G7000)))"];3 -> 4;5 [label=":-call((follows(_G6713,_G7000),teaches(peter,_G7000)))"];4 -> 5;6 [label=":-teaches(peter,computer_science)"];1 -> 6;7 [label=":-true"];6 -> 7;8 [label="Answer:\\nstudent_of(paul,peter)", shape=ellipse, style=dotted, fontsize=10];7 -> 8 [style=dotted, arrowhead=none];9 [label=":-teaches(peter,expert_systems)"];1 -> 9;10 [label=":-teaches(peter,ai_techniques)"];1 -> 10;11 [label=":-true"];10 -> 11;12 [label="Answer:\\nstudent_of(maria,peter)", shape=ellipse, style=dotted, fontsize=10];11 -> 12 [style=dotted, arrowhead=none];}',
Do you remember what's the purpose of resolve(A,true) predicate and why it causes troubles in SWISH?
Both SWISH and local Prolog interpreter behave the same when I use call/1.
?- call(student_of(B,peter)).
B = paul ;
B = maria ;
false.
—
You are receiving this because you were assigned.
Reply to this email directly, view it on GitHub, or mute the thread.
|
@flach I have implemented changes that we discussed above. To run it locally within SWISH you need to put the |
That’s what I did, but the changes aren’t coming through. I wonder whether there is another graphviz_swish.pl somewhere on my filesystem that is selected instead.
—P
… On 28 Dec 2016, at 12:36, Kacper Sokol ***@***.***> wrote:
@flach I have implemented changes that we discussed above.
To run it locally within SWISH you need to put the graphviz_swish.pl file in the swish/examples folder. Then you can view it at localhost:3050/example/graphviz_swish.pl. It should also work from the graphviz_intro notebook.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
|
Since the original file (
graphviz.pl
) uses programming with side effects (failure driven loop in particular) to write to a file, the modified version that passes string around fails.One idea to fix it is using
assertz
andretract
instead of file IO.The text was updated successfully, but these errors were encountered: