# substitution of ideal generators of a free algebra

I'm trying to map the generators of an ideal $I$ of a free $k$-algebra $A = k \{ x, y \}$ to a different free $k$-algebra $B = k \{ u, v \}$ (really I'm trying something more complicated, but the failure occurs in even this simplified example). I was attempting to do this via `subs`

by creating a dictionary taking $x$ to $u$ and $y$ to $v$, but this is not working.

```
sage: A.<x, y> = FreeAlgebra(QQ, 2)
sage: I = A*[x*y - y*x - 1]*A
sage: B.<u, v> = FreeAlgebra(QQ, 2)
sage: genMap = {'x':'u', 'y':'v'}
sage: I.gen(0).subs(genMap)
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-5-9d969fff6a4a> in <module>()
----> 1 I.gen(Integer(0)).subs(genMap)
sage/structure/element.pyx in sage.structure.element.Element.subs (build/cythonized/sage/structure/element.c:7572)()
/usr/lib/python2.7/dist-packages/sage/algebras/free_algebra_element.pyc in __call__(self, *x, **kwds)
176 for m, c in six.iteritems(self._monomial_coefficients):
177 if result is None:
--> 178 result = c*m(x)
179 else:
180 result += c*m(x)
sage/rings/rational.pyx in sage.rings.rational.Rational.__mul__ (build/cythonized/sage/rings/rational.c:21325)()
sage/structure/coerce.pyx in sage.structure.coerce.CoercionModel_cache_maps.bin_op (build/cythonized/sage/structure/coerce.c:10686)()
TypeError: unsupported operand parent(s) for *: 'Rational Field' and 'Free monoid on 2 generators (x, y)'
```

This error seems strange to me; is it not understanding elements of $\mathbb{Q}$ and $\{ x, y \}$ as elements of $\mathbb{Q} \{ x, y \}$? I also tried to do this via a homomorphism $A \to B$ but I could not get this to work, as it seems they are not fully implemented yet for free algebras, from what I could tell. Any help or alternatives would be very appreciated.

**EDIT**: I got a slight work-around, by converting the elements to strings, replacing the variables as characters, and the evaluating the string in the target. However, I feel like this is way more costly than a substitution would be, so I am still interested in a solution.