% query: d([T1 $= der(u) $| der(mul(T1,T1)) $| der(plus(T1,T1)) $| der(T1)],[T2 $=MAX])
d(der(u),1).
d(der(plus(X,Y)),plus(DX,DY)) :- d(der(X),DX), d(der(Y),DY).
d(der(mul(X,Y)),plus(mul(X,DY),mul(Y,DX))) :- d(der(X),DX), d(der(Y),DY).
d(der(der(X)),DDX) :- d(der(X),DX), d(der(DX),DDX).

