The WAM: A Tutorial Reconstruction states that a query, p(Z, h(Z,W), f(W)), needs to be flattened using the following principles:
That being said, the query flattened form is:
X3=h(X2, X5), X4=f(X5), X1=p(X2, X3, X4);
I am lost with the definition of external variable, consider the following:
p(Z, h(Y, a(K, C), b(W)), f(W)).
Is Y an external variable? How should be the flattened form for this? From my understanding this would be the construction:
X1 = p(X2, X3, X4)
X2 = Z
X3 = h(X5, X6, X7)
X4 = f(X8)
X5 = Y
X6 = a(X7, X8)
X7 = K
X8 = C
X9 = b(X5)
But I am not sure, starting at X4 I got confused, should I have assigned the h inner values first?