Skolem functions
This is an advanced functionality that allows to use user-defined Skolem functions in the assignments and in the conditions of the rules.
A Skolem function is a function that takes as input a number of parameters and generates marked nulls. For Skolem functions the following two assumptions hold:
-
Within a program Skolem functions are range disjoint. This means that different Skolem function will never generate the same marked null, even if applied to the same input parameters.
-
A Skolem function is deterministic. This means that in two subsequent applications within the same programs, if the input parameters coincide, the generated marked null will be the same.
b(1,2).
a(X,Y,Z) :- b(X,Y),Z=#f(X,Y).
c(K) :- b(X,Y),K=#f(X,Y).
d(K) :- b(X,Y),K=#g(X,Y).
@output("a").
@output("c").
@output("d").
The expected output is:
a(1,2,z2). c(z2). d(z1).
c(1,2,3).
d(2,3,4).
w(Y,J) :- c(X,Y,Z),J=#f(Y,Z).
v(X,J) :- d(X,Y,Z),J=#f(X,Y).
q(X,Z) :- v(X,Y),w(Z,Y).
f(J,X,X) :- q(X,X), J=#f1(X,X).
@output("f").
The expected output is:
f(z2,2,2).
a("a","b","c").
a("a","b","d").
a("a","c","d").
a("a","c","e").
q(J,X) :- a(W,V,X),J=#sk(W,V).
@output("q").
The expected output is:
q(z1,"c"). q(z1,"d"). q(z2,"d"). q(z2,"e").
sequelOf(0,2,"a").
sequelOf(5,3,"a").
followOn(1,2,"a").
followOn(2,2,"a").
sequelSynt(X,J) :- sequelOf(X,Y,Z), J = #f(Y,Z).
q(X,W) :- sequelSynt(X,J), followOn(W,Y,Z), J= #f(Y,Z).
@output("q").
The expected output is:
q(0,1). q(0,2).
a(1,2,3,4).
a(2,3,4,5).
a(2,3,6,5).
a(4,3,6,5).
a(X,Y,Z,K) :- a(X,C,Z,K), Y = #f1(K).
b(X,Y,Z,K,Q) :- a(X,Y,Z,K), Y = #f1(K), Q=#f2(X).
@output("b").
The expected output is:
b(1,z1,3,4,z3). b(2,z2,4,5,z4). b(2,z2,6,5,z4). b(4,z2,6,5,z5).