1
votes

I am trying to use JPL to Pass a Query to SWI-Prolog(CLPFD) from Java. I get the Following Exception while running the program in Java.

Query is = Arithmetic_Expression#=X*Y+X+1,[Y, X] ins 0..100500,Arithmetic_Expression in 1..5/10/12. Exception in thread "main" jpl.PrologException: PrologException: error(syntax_error(operator_expected), string('Arithmetic_Expression#=X*Y+X+1,[Y, X] ins 0..100500,Arithmetic_Expression in 1..5/10/12. ', 21)) at jpl.Query.get1(Query.java:336) at jpl.Query.getSubstWithNameVars(Query.java:390) at jpl.Util.textToTerm(Util.java:163) at jpl.Query.(Query.java:198)

As you can see, My java Program is generating the Query as Union of Ranges from 1..5 / 10 / 12. But SWI-Prolog is taking it as 1..5/10/12. Not sure why is this happening? I guess this might be the reason for my error. Could anyone help me with this error?

I am appending / because in my Java Program on to Windows to generate the Query \ will be given as '\' and thus my Query is generated as 1..5/10/12.

Why is this propogating to SWI-Prolog?

1

1 Answers

1
votes

The position of the error is the 21st character, thus

Arithmetic_Expression#=X*Y+X+1,[Y, X] ins 0..100500,Arithmetic_Expression in 1..5/10/12.
123456789012345678901^^

Evidently, you have not stated use_module(library(clpfd)),

However, after that, the next error will be:

ERROR: Domain error: `clpfd_domain' expected, found `1..5/10/12'

Not clear what you mean by /10/20.In any case, I recommend you learn Prolog and clpfd first before using it from Java.