The replace command takes an expression A and replaces the variable X by the expression Y.
replace(x^2+1,x,y-1); 1+(-1+y)^2