# What is are the symbolic simplification rules and when do they apply?

I know that the rules Simplify are obscure but maybe someone has an idea:

if I evaluate Simplify[f[g[x]], {Equal[f[g[x]], 3]}], I get 3. I suppose the transformation is Refine because Refine[f[g[x]], {Equal[f[g[x]], 3]}] is also 3.

However, Refine[f[g[x]], {Equal[f[g[x]], "something"]}] is f[g[x]] because it only applies to numerics. So far so good.

Simplify[f[g[x]], {Equal[f[g[x]], "something"]}], however, evaluates to "something" leading me to believe that there is another transformation being applied.

What is that transformation and when does it apply?

Here are some cases that confused me further:

• Simplify[f[g[x]], {Equal[f[g[x]], duh]}] -> f[g[x]].
• Simplify[f[g[x]], {Equal[f[g[x]], Minus[3]]}] -> -3, whereas
• Simplify[f[g[x]], {Equal[f[g[x]], List[3]]}] -> f[g[x]].

Here is the complexity trace for the last one:

Simplify[f[g[x]], {Equal[f[g[x]], List[5]]}, ComplexityFunction -> ((Print@{#, LeafCount@#}; LeafCount@#) &)]


->

{f[g[x]],3}
{g[x],2}
{x,1}
{x,1}
{g[x],2}
{g[x],2}
{g[x],2}
{f[g[x]],3}
{f[g[x]],3}
{f[g[x]],3}
{f[g[x]],3}
{f[g[x]],3}


It seems to not even consider the substituting List[5] for f[g[x]].

• I don't think I understand the comment. I know I can define a ComplexityFunction that favors certain outcomes (like in this case favoring f[g[x]] over "something" because it has fewer characters. My specific problem is that, irrespective of the ComplexityFunction, Simplify never seems to consider the substitution (since it never calls my custom ComplexityFunction with the substitution applied). My general problem is that I don't understand how Simplify decides which symbolic transformations to apply. – Holger Mar 31 '17 at 15:20