I am trying to define some rules for CenterDot. One thing I don't understand is that if I define

SetAttributes[CenterDot, Flat]
CenterDot[var_] := var

CenterDot[x] will induce infinite recursion. I have tried to use Trace, but could not find why there was a recursion. I am expecting CenterDot[x] being evaluated to x.

  • 1
    $\begingroup$ It seems to depend on the order of definitions, compare these two: f1[x_] := x; SetAttributes[f1, Flat] and SetAttributes[f2, Flat]; f2[x_] := x. Only f2 is affected. $\endgroup$
    – Szabolcs
    Oct 27, 2020 at 21:43

1 Answer 1


This is age-old behavior (likely back to ~Mathematica 1.0). Perhaps at that time in the 1990s it would be solidly considered a bug, but by 2020 it's been the behavior for so long that I think it's unlikely to be changed.

I have two suggestions for working around the behavior:

In[1]:= ClearAll[f];
SetAttributes[f, Flat];
Verbatim[f][x_] := x

In[4]:= f[1]

Out[4]= 1

In[5]:= ClearAll[f2]
SetAttributes[f2, {OneIdentity, Flat}];
f2[x_] := x

In[8]:= f2[1]

Out[8]= 1
  • $\begingroup$ I wonder why it never got fixed. Anybody relying on this behavior? $\endgroup$
    – atbug
    Oct 27, 2020 at 22:33
  • $\begingroup$ I think in 2020 that’s a factor. Maybe not explicitly relying on this behavior, but worrying about any unintended downstream effects from the change. $\endgroup$
    – ktm
    Oct 27, 2020 at 23:37

Not the answer you're looking for? Browse other questions tagged or ask your own question.