Hold @ t[t[1,1],2]/.t-> Times
Hold @ t[t[1,2],2]/.t-> Times
Hold[(1 1) 2]
Hold[2 2]

Why doesn't the second one give Hold[(1 2) 2]? It seems to have to do with 1 appearing in there.

Hold @ t[t[2,2],2]/.t-> Times gives Hold[(2 2) 2] but

Hold @ t[t[2,2],1]/.t-> Times gives Hold[2 2]

The result is the same if I do the replacement with :> or //. or using With or a global replacement rule (function).

Maybe the default value of Times, 1, is being used in these replacements? Can anyone explain this?


This is a specific case of a more general topic: Understanding evaluation and typesetting

It is not a bug, nothing is evaluated. Why then Times' "special" formatting is recognized for nested t[t[1,2],2] as it would have been evaluated?

It is because of special formatting rules defined for Times (any symbol in general). Also certain Attributes affect pattern-matching which is performed during formatting/typesetting (Format/MakeBoxes).


SetAttributes[h, Orderless]
Format[h[1, x__]] := Row[{x}]

Hold @ t[t[2, 1], 2] /. t -> h

% // FullForm


Of course for Times more rules are defined, it is only a small example to show the point.

Flatis an attribute that can be assigned to a symbol f to indicate that all expressions involving nested functions f should be flattened out. This property is accounted for in pattern matching.

Orderless [...]. This property is accounted for in pattern matching.


This is purely a formatting "issue": enter image description here

  • $\begingroup$ Can we consider this a bug still? $\endgroup$ – masterxilo Sep 22 '16 at 1:14
  • 1
    $\begingroup$ Isn't the FullForm unsurprisingly correct? That's what I go to, when the typeset form seems to vary from my expectation. $\endgroup$ – Michael E2 Sep 22 '16 at 1:37
  • 1
    $\begingroup$ @masterxilo. No $\endgroup$ – m_goldberg Sep 22 '16 at 3:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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