diff.pl
diff(x,1).
diff(C, 0) :-
atomic(C),
C \= x.
diff(F + G, DF + DG) :-
diff(F, DF),
diff(G, DG).
diff(F - G, DF - DG) :-
diff(F, DF),
diff(G, DG).
diff(F * G, DF * G + F * DG) :-
diff(F, DF),
diff(G, DG).
diff(F / G, (DF * G - F * DG) / (G * G)) :-
diff(F, DF),
diff(G, DG).