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

sld resolution doesn't work in graphviz_swish.pl #1

Open
So-Cool opened this issue Dec 22, 2016 · 5 comments
Open

sld resolution doesn't work in graphviz_swish.pl #1

So-Cool opened this issue Dec 22, 2016 · 5 comments
Assignees

Comments

@So-Cool
Copy link
Member

So-Cool commented Dec 22, 2016

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 and retract instead of file IO.

@flach
Copy link
Contributor

flach commented Dec 27, 2016

I think this is fixed in the following file (added .txt extension to stop GitHub complaining...)

graphviz_swish.pl.txt

@So-Cool
Copy link
Member Author

So-Cool commented Dec 28, 2016

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.

@flach
Copy link
Contributor

flach commented Dec 28, 2016 via email

@So-Cool
Copy link
Member Author

So-Cool commented Dec 28, 2016

@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.

@flach
Copy link
Contributor

flach commented Dec 28, 2016 via email

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