#### QUESTION

Here is the example:

```
Simplify[x + y, x + y == a]
Simplify[x + y, x + y == 5]
```

Mathematica 9 output:

```
x+y
5
```

I expect the complexity of `a`

to be lower than complexity of `Plus[x,y]`

, and the result of the first line should be `a`

.

Even if I specify `ComplexityFunction`

explicitly:

```
Simplify[x + y, x + y == a, ComplexityFunction -> LeafCount]
```

I still get `x+y`

as a result. It's however obvious that `LeafCount[x+y]`

is greater than `LeafCount[a]`

.

Why does Simplify ignore `x+y==a`

but uses `x+y==5`

? How can I define the former assumption in a right way?

#### ANSWER

We can see from the examples in the comments to the question that `Simplify`

(and `FullSimplify`

which builds on it) doesn't try all permutations of substitutions. That's probably justified in general to keep the computational effort from exploding, but in your example it leads to the quirky behavior that the **variable names** affect the result of the simplification.

For example, you get

```
Clear[a, z];
Simplify[x + y, x + y == a]
(* ==> x + y *)
Simplify[x + y, x + y == z]
(* ==> z *)
```

The only difference is that the last assumption uses a variable name that comes lexically *after* the names which you would like to replace.

I think the reason for this is that *Mathematica* tries substitutions in sums only in a specific sequence dictated by the alphabetical order of the variables it encounters.

My heuristic conclusion from this would be that assumptions in which you would like variables to be substituted by new names should have the *new* names chosen such that they come lexically after the "old" names.

If this doesn't work for you, the best alternative would be to do the elimination explicitly using `Eliminate`

.