/* Derivation Definition /
d(X,X,1) :- !. / d x dx = 1 /
d(C,X,0) :- atomic(C). / d c dx = 0 /
d(-U,X,-A) :- d(U,X,A). / d -u dx = - d u dx /
d(U+V,X,A+ :- d(U,X,A), d(V,X,. / d u+v dx = d u dx + d v dx /
d(U-V,X,A- :- d(U,X,A), d(V,X,. / d u-v dx = d u dx - d v dx /
d(CU,X,CA) :- atomic(C), C \= X, d(U,X,A), !. / d cu dx = cd u dx /
d(UV,X,BU+AV) :- d(U,X,A), d(V,X,. /* d uv dx = ud v dx + v*d u dx /
d(U/V,X,A) :- d(UV-1,X,A). /* d u/v dx = d (u*v)-1 dx /
d(UC,X,CUC-1W) :- atomic(C), C \= X, d(U,X,W). / d uc dx = cuc-1d u dx /
d(log(U),X,AU-1) :- d(U,X,A). /* d ln(u) dx = u-1 * d u dx */
/* Integral Definition /
i(0,X,0) :- !. / Int 0 dx = 0 /
i(X,X,(XX)/2) :- !. /* Int X dx = (X2)/2 /
i(C,X,CX) :- atomic(C). /* Int c dx = c*x /
i(-U,X,-A) :- i(U,X,A). / Int -U dx = - Int U dx /
i(U+V,X,A+ :- i(U,X,A), i(V,X,. / Int U+V dx = Int U dx + Int V dx /
i(U-V,X,A- :- i(U,X,A), i(V,X,. / Int U-V dx = Int U dx - Int V dx /
i(CU,X,CA) :- atomic(C), C \= X, i(U,X,A), !. / Int cU dx = c (Int U dx) /
i(XC,X,(XC+1)/(C+1)) :- atomic(C), !. / Int xc dx = xc+1/(c+1) /
i(U,V,UV-A) :- d(V,U,A), !. /* Int u dv = u*v - Int v du */
/* Simplification Rules /
s(+,X,0,X). / x + 0 = x /
s(+,0,X,X). / 0 + x = x /
s(+,X,Y,X+Y). / x + y = x + y /
s(+,X,Y,Z) :- integer(X), integer(Y), Z is X+Y. / x + y = z <- Calculate /
s(,,0,0). /* anything * 0 = 0 /
s(,0,,0). /* 0 * anything = 0 /
s(,1,X,X). /* 1 * x = x /
s(,X,1,X). /* x * 1 = x /
s(,X,Y,XY). / x * y = x * y /
s(,XY,W,XZ) :- integer(Y), integer(W), Z is YW.
s(,X,Y,Z) :- integer(X), integer(Y), Z is XY. / x * y = z <- Calculate */
/* Simplification Definition */
simp(E,E) :- atomic(E), !.
simp(E,F) :- E =.. [Op, La, Ra], simp(La,X), simp(Ra,Y), s(Op,X,Y,F).
Éste es el programa completo en la página en inglés de la wikipedia, aunque parte del código es superfluo, porque con los modos de uso la integración es redundante: sólo tienes que invertir las incógnitas en la derivación.