# Return to Answer

 2 amended mistake edited Mar 29 at 18:07 MannyC 31811 silver badge77 bronze badges The problem is not that Times is a built-in symbol. It is a consequence ofAs explained in another answer it stems from the Flat attributeevaluation of the Times. In this particular example, for in the purposeLHS of pattern matching Times[a, b] is considered the same as Times[Times[a,b]], hence the rule replaces x with Times[a,b] rather than. My previous explanation Sequence[a,b](see edit) was wrong and misleading. Having said that, one way to make it work is to simply replace the Head In:= a b /. Times -> (g[##, 0] &)  Out:= g[a, b, 0] If you have more complicated replacement rules you can always replace Times with a new symbol e.g. newTimes, make it Orderless if needed and then apply the rules to newTimes. The problem is not that Times is a built-in symbol. It is a consequence of the Flat attribute of Times. In this particular example, for the purpose of pattern matching Times[a, b] is considered the same as Times[Times[a,b]], hence the rule replaces x with Times[a,b] rather than Sequence[a,b]. Having said that, one way to make it work is to simply replace the Head In:= a b /. Times -> (g[##, 0] &)  Out:= g[a, b, 0] If you have more complicated replacement rules you can always replace Times with a new symbol e.g. newTimes, make it Orderless if needed and then apply the rules to newTimes. The problem is not that Times is a built-in symbol. As explained in another answer it stems from the evaluation of the Times in the LHS of the rule. My previous explanation (see edit) was wrong and misleading. Having said that, one way to make it work is to simply replace the Head In:= a b /. Times -> (g[##, 0] &)  Out:= g[a, b, 0] If you have more complicated replacement rules you can always replace Times with a new symbol e.g. newTimes, make it Orderless if needed and then apply the rules to newTimes. 1 answered Mar 29 at 13:35 MannyC 31811 silver badge77 bronze badges The problem is not that Times is a built-in symbol. It is a consequence of the Flat attribute of Times. In this particular example, for the purpose of pattern matching Times[a, b] is considered the same as Times[Times[a,b]], hence the rule replaces x with Times[a,b] rather than Sequence[a,b]. Having said that, one way to make it work is to simply replace the Head In:= a b /. Times -> (g[##, 0] &)  Out:= g[a, b, 0] If you have more complicated replacement rules you can always replace Times with a new symbol e.g. newTimes, make it Orderless if needed and then apply the rules to newTimes.