In the proof of the following Proposition, the authors consider a map $\pi$ and say it is injective. I don't understand why. Proposition: Let $A=\{a,b\}$, and let $X\subset a^*ba^*$. Then $X$ is commutatively equivalent to a prefix code $Y$ if and only if, for all $n\ge 1$, $$Card(X\cap A^{(n+1)})\le n,$$ with $A^{(n+1)}=1\cup A\cup \dots \cup A^n$.
In the proof they consider the map $\pi$ from $X\cap A^{(n+1)}$ to $\{0,1,\dots,n-1\}$ defined as $\pi(a^iba^j)=i$. They say that, since $Y$ is prefix, $\pi$ is injective. Why? I mean, taken $y,z\in X\cap A^{(n+1)}$, i.e. $y=a^iba^j,z=a^kba^\ell$, with $i+j,k+\ell\le n-1$, if $\pi(y)=\pi(z)$ why should $y$ be equal to $z$? Since $\pi(y)=\pi(z)$, it follows that $i=k$. Now, why should $j$ be equal to $\ell$? How should I use the 'prefixness' of $Y$?
Since $i = k$, you have $y =a^iba^j$ and $z= a^iba^\ell$. If $j < \ell$, then $y$ is a (strict) prefix of $z$, which is not possible, since $Y$ is a prefix code. A dual argument shows that $\ell < j$ is also impossible. Thus $j = \ell$.