title: Prolog expression simplification
body: <p>I am new to Prolog, having to write a symbolic differentiation tool for Calculus class. I have it working in such a way that:</p>
  
  <pre><code>?- diff(ln(x^3),D).
  D = 1*3*x^(3-1) / x^3 ;
  </code></pre>
  
  <p>and:</p>
  
  <pre><code>?- diff(x*x*x*x,D).
  D = x*x*x*1+x*(x*x*1+x*(x*1+x*1)).
  </code></pre>
  
  <p>Works, however, I would prefer to have it as:</p>
  
  <pre><code>D = 3x^(-2) / x^3;
  </code></pre>
  
  <p>and:</p>
  
  <pre><code>D = 4x^(3);
  </code></pre>
  
  <p>Is there a simple way to simplify these mathematical expressions. Thanks!</p>