Or maybe make a more explicit interface:

```
def change_index(expr, indexvar, linear_trafo, newindexvar=None): 
```

The call would then look like:

```
change_index(S, x, -x+4, y)
```

which replaces `x` by `y = -x +4`.