External Implementations

It declares an external implementation defined in Java or Python. The syntax varies according to the annotation depending on the language used.

For Java the syntax is as follows:

@implement("functionName", "java", "fully qualified name", "staticMethodName").

To use the Java implement, you must import the jar that contains the implementation you want to invoke. You can import the jar file by using eclipse, right-click on the project, then follow Build Path → Configure Build Path, and then click "Add external JARs", and add the file. Where the first parameter is the name of the Skolem function, the second is the language name, the third is the fully qualified name of the imported jar (for example: com.package1.className), and the last parameter is the name of the static method.

For Python the syntax is as follows:

@implement("functionName", "python", "/absolute_path_to_python_module", "functionName").

In this case, the third parameter isn’t the fully qualified name, but the absolute path (for example: /Users/…​/pythonModule).

Example
b(#T,2).
c(#F,2).
a(Y,Z) :- b(X1,Z),c(X2,Z),Y=f(X1,X2).

@output("a").
@implement("f","python","../thirdparty/userDefinedFunctions/testPy","transform").

This example invokes the function transform of the module testPy.py with parameter X1 and X2.

Example
b(1,2).
c(3,2).
a(Y,Z) :- b(X1,Z),c(X2,Z),Y=f(X1,X2).

@output("a").
@implement("f","java","com.package1.package2.Test","transform").

This example invokes the method transform of the class Test.java, in com.package1.package2, with parameters X1 and X2.