I'm using JPL and launch some queries to Swi-Prolog. The program works fine with all queries, but one.
This query is not working:
assert(like(X, Y) :- element(I, [1, 2, 3], X), element(I, [2, 3, 4], Y) ).
Exception in thread "main" jpl.PrologException: PrologException: error(uninstantiation_error(element(_3, '.'(2, '.'(3, '.'(4, []))), _4)), context(:(system, /(assert, 2)), '2-nd argument'))
If I put the query in a .pl fle (without assert, obvisously) and run it with consult, works fine! But if I type the query in console mode, return the same error like JPL. So, where is the problem?
You are very near to get the illumination. It will not work neither on console ! Then you will try to change the syntax. Understanding the Prolog operator model, try
?- assert((like(X, Y) :- element(I, [1, 2, 3], X), element(I, [2, 3, 4], Y))).
and it will work!
Your problem was the precedence of operator (:-)/2 WRT operator (,)/2.