I have encountered the following behaviour for complex
terms. A simple example:<br>
<br>
Fact: input(1) <br>
Rule: result(plus(N,N)) <-- input(N) <br>
<br>
Query1: result(X) ? <br>
Query2: result(2) ? <br>
<br>
Query 1 succeeds and leads to the correct result of 2
for the variable X. <br>
<br>
Query 2 fails. The perform method of the plus function
throws an UnsupportedOperationException because the
parameter is a VariableTerm which does not support the
resolve method. <br>
<br>
However, the variable N ought to be resolved with the
input value of 1 and lead to the result 2 (the output
of the complex term), so that query 2 succeeds? <br>
<br>
According to the implementation, a rule
result(N,plus(N,N) ß input(N) and a query result(1,2)
works fine. <br>
<br>
<br>
Here is the sample code:<br>
<br>
Predicate input = new SimplePredicate("input", new
Class [] { Integer.class }); <br>
<br>
Predicate result = new SimplePredicate("result", new
Class [] {Integer.class }); <br>
<br>
<br>
Rule compute = lfs.rule(
lfs.prereq(input, lfs.variable("N",Integer.class)),
// -->
lfs.fact(result, lfs.cplx(IntArithmetic.PLUS,
lfs.variable("N",Integer.class), lfs.variable("N",
Integer.class)))); <br>
<br>
I have turned this into a test case "TestComplexTerm"
and added it to the test cases (test.mandarax.reference).