Let $FM\_2=\langle a,b\rangle$ be the free monoid of rank 2. If we add a formal inverse to the word $aba$, we get the free group $F\_2$ (because both $a$ and $b$ will have inverses). 


**Question:** For which other words $w=w(a,b)$, adding a formal inverse to $w$ turns the free monoid into the free group? 


I need a complete description, not just examples.


 **Update question:** The same question for $FM\_k$, the free monoid of rank $k\ge 3$. 


 **Edit**  I moved my answer from here to the answer box below. 



Adding a formal inverse of an element to a free monoid
OK, I will move my partial answer here as an answer to my question. If anybody can improve that answer, it would be good. 


 **A possible solution.**  I think I found a solution but it is not very explicit, so a more explicit description is welcome. Let $w$ be a word. Let $S\_0=\{w\}$ . We shall construct sets of words $S\_n$, $n=0,1,2,...$ by induction. Suppose $S$ is already constructed. If $S\_n$ contains two words $u,v$ of the form $pu', v'p$, then we replace these pair of words ($u$ and $v$ may be the same) by the three words $p, u', v'$. Also if we have a pair of words $p, pu$ or $p,up$, then we replace it by $p,u$. This way we get a new set $S\_{n+1}$. If we cannot do any changes, the process terminates. Clearly the process eventually terminates because the lengths of the words can only get smaller.


 **Claim.**  Inverting $w$ gives us a group iff the last set $S\_n$ contains all the generators. 


 **Proof.**  It is clear that if $S\_n$ contains all generators, then the result is a group. Assume that a generator $x\_1$ is not in the set. Then $x\_1$ is either not the first letter of any word in $S\_n$ or not the last letter of any of these words (otherwise $S\_n$ is not the terminal set of words). Suppose the former holds (WLOG). Let $S\_n=\{u\_1,...,u\_k\}$. Then adding inverse to $w$ implies adding inverses to $u\_1,...,u\_k$. Hence the resulting monoid is a quotient of the following monoid:
$$G\_t=\langle x\_1,...,x\_n, t\_1,...,t\_k\mid u\_it\_i=1, t\_iu\_i=1, i=1,...,k\rangle.$$ Moreover it is clear that $G\_t$ is in fact islomorphic to the monoid obtained by adding the inverse to $w$. Now the fact that $S\_n$ is terminal set means that the presentation of $G\_t$ is ``complete" (i.e. confluent and terminating because there are no overlaps, see any book on string rewriting). Now suppose that $x\_1$ has an inverse. Then $x\_1v=1$ in $G\_t$ for some $v$. But this relation cannot be deduced by applying the defining relations of $G\_t$ from left to right since $x\_1$ is not the first letter of any word in $S\_n$, a contradiction.


