Evaluation in Mathematica: Until no rules apply? Or until the expression

*To*: mathgroup at smc.vnet.net*Subject*: [mg82206] Evaluation in Mathematica: Until no rules apply? Or until the expression*From*: Szabolcs Horvát <szhorvat at gmail.com>*Date*: Sun, 14 Oct 2007 06:22:13 -0400 (EDT)

The documentation says: "As discussed in "Principles of Evaluation", Mathematica follows the principle that each expression is evaluated until no further definitions apply. This means that Mathematica must continue re-evaluating results until it gets an expression which remains unchanged through the evaluation procedure. " This is not very clear. Does Mathematica evaluate the expression until no rules apply? Or does it stop when application of a rule does not change the expression any more? A few examples: In[1]:= a := a a // Trace Out[2]= {} In[3]:= b[x] := b[x] b[x] // Trace Out[4]= {b[x], b[x]} In[5]:= c[p_] := c[p] c[x] // Trace During evaluation of In[5]:= $IterationLimit::itlim: Iteration limit of 4096 exceeded. >> Out[6]= {c[x],c[x],c[x],c[x],c[x], ... (and so forth) In[7]:= d[x /; True] := d[x] d[x] // Trace Out[8]= {d[x], d[x]} In[9]:= e[p_ /; p===x] := e[x] e[x] // Trace Out[10]= {e[x], {x===x, True}, e[x], {x===x, True}, e[x]} Could someone explain how Mathematica decides when to finish the evaluation of an expression? -- Szabolcs