% Query: g(g,g,f)
f(0,true).
f(1,false).
f(s(X),Y):- f(X,Y).
if(true,X,Y,X).
if(false,X,Y,Y).
g(s(X),s(Y),Z):- f(X,T), if(T,s(X),s(Y),Z).
g(X,s(Y),Z):- g(s(s(Y)),Y,U), g(X,U,Z).