The area, you are working in is the set of polynomial: the
division in that ring ignores remainder: 1/x is 0 with remainder 1
which is ignored.
You seem to want to work in the field of rational functions:
in order to do so, define a ring with rational functions a coefficients:
Code:
ring r=(0,a),x,dp;
poly p=x;
subs(p,x,1/a); -> 1/(a)