0

As the title suggests, I am having an error I don't really know how to fix as I am quite new to prolog and was wondering if someone could point out a solution?

I wrote some code to find paths between certain points. Here is my code

edge(o,p1).
edge(p1,k).
edge(k,l).
edge(l,c).
edge(c,b).
edge(c,w).
edge(c,m).
edge(l,p2).


path(X,Y,Path) :- path(X,Y,[X],Q), reverse(Q,Path).


path(X,Y,Visited,[Y|Visited]) :- edge(X,Y).
path(X,Y,Visited,Path) :-
    edge(X,Z),
    Z \== Y,
    \+ member(Z,Visited),
    path(Z,Y,[Z|Visited],Path).

Error message I get when I try to compile: Arguments are not sufficiently Instantiated

Edit the errors: image here of error

  • No way this program produces this error, unless the query you did not show causes that error. – false Mar 09 '23 at 15:57
  • @false I promise its giving me that error otherwise I wouldn't be here haha. The only difference is for my edges, in my actual program there is full names, for example the 'c' here is actually 'Corridor' in my code. I get this error when i try and COMPILE not query – Elephants unite Mar 09 '23 at 15:58
  • What's the exact file name you are using? – false Mar 09 '23 at 16:07
  • @false the exact file is called pathfinding.pl I open terminal I use swipl, then [pathfinding]. to compile. which now works for some reason?? I get some other errors which i will edit into the post – Elephants unite Mar 09 '23 at 16:13
  • One possible reason could have been that you typed `[Pathfinding].` instead. That would produce that very error. – false Mar 09 '23 at 16:17
  • `?- path(edge, Path, A,B).` using [this definition](https://stackoverflow.com/q/30328433/772868) is a more generic definition. – false Mar 09 '23 at 16:19
  • The picture you show shows different errors. And there, it seems that you are using a lot of uppercase letters... – false Mar 09 '23 at 16:21
  • @false thank you for letting me know not to use uppercase, I didnt know it would effect it. I have now changed that and used `compile(pathfinding).` and i have used your query you suggested. After compiling I still have the syntax errors that are shown in the picture. And after using the query i get this error `undefined procedure: path/4 DWIM could not correct goal` I appreciate any and all the help youve already given! – Elephants unite Mar 09 '23 at 16:26
  • You need the definition given in the link above. – false Mar 09 '23 at 16:27
  • Follow the link, and paste the code there into your file instead of your definition of `path/4`. – false Mar 09 '23 at 16:30
  • Aaaah, the joys of teaching people about reproducible examples......... on the other hand, if the concept of a reproducible example is so hard to comprehend, what are we doing here? Feels like trying to squeeze out a spec from non-technical users, which is another most joyful experience. – TA_intern Mar 10 '23 at 06:41

0 Answers0