Counterintuitive result for FullSimplify of expressions with Re

In[1]:= FullSimplify[Re[x + y], {x, y} \[Element] Reals] 
Out[1]= x + y 
In[2]:= FullSimplify[-2 Re[x + y], {x, y} \[Element] Reals] 
Out[2]= -2 (x + y) 
In[3]:= FullSimplify[-Re[x + y], {x, y} \[Element] Reals] 
Out[3]= -Re[x + y] 

Why doesn’t the last one remove Re?

Based on LeafCount, -(x+y) is actually less simple than -Re[x + y]. With the 2 multiplier, the Re-free expression has smaller LeafCount.

In[1]:= LeafCount[-2 (x + y) ] 
Out[1]= 5 
In[2]:= LeafCount[-2 Re[x + y]] 
Out[2]= 6 
In[3]:= LeafCount[-Re[x + y]] 
Out[3]= 6 
In[4]:= LeafCount[-(x + y) ] 
Out[4]= 7

This is because -(x+y) turns into -x-y (= -1*x + -1*y), while -2(x+y) remains as is.

Make Re[] more expensive:

FullSimplify[-Re[x + y], {x, y} \[Element] Reals, 
 ComplexityFunction -> Function[{e}, If[MatchQ[e, _Re], 1, 0]]]

Arnoud +1 - this is exactly what I wanted to ask about - “how do we make it work” :wink:

Don’t you think that the result of calculations shouldn’t depend on aspects of the implementation and in particular,
FullSimplify[-Re[x + y], {x, y} ? Reals] returning -Re[x + y] should be considered as a bug and fixed?

A ComplexityFunction based on the StringLength of the expression (perhaps with heads reduced to a single character) might be a more intuitive measure of complexity.