Suppose

$$(1)\qquad (ab)^{k-1}=a^{k-1}b^{k-1}$$ $$(2)\qquad (ab)^{k}=a^{k}b^{k},$$ $$(3)\qquad (ab)^{k+1}=a^{k+1}b^{k+1}.$$

Using $(1)$ and $(2):$ $$\displaystyle\begin{aligned}

&(ab)^{k-1}=a^{k-1}b^{k-1}=a^{-1}a^kb^kb^{-1}=a^{-1}(ab)^kb^{-1}\\

&=a^{-1}(ab)(ab)\ldots (ab)b^{-1}=(ba)(ba)\ldots (ba)=(ba)^{k-1}.

\end{aligned}$$ Using $(2)$ and $(3):$ $(ab)^{k}=a^{k}b^{k}$ y $(ab)^{k+1}=a^{k+1}b^{k+1}:$

$$\displaystyle\begin{aligned}

&(ab)^{k}=a^{k}b^{k}=a^{-1}a^{k+1}b^{k+1}b^{-1}=a^{-1}(ab)^{k+1}b^{-1}\\

&=a^{-1}(ab)(ab)\ldots (ab)b^{-1}=(ba)(ba)\ldots (ba)=(ba)^{k}.

\end{aligned}$$ Using $(ab)^{k-1}=(ba)^{k-1}:$ $$\left \{ \begin{matrix} (ab)^k=(ab)^{k-1}(ab)\\ (ba)^k=(ba)^{k-1}(ba)=(ab)^{k-1}(ba)\end{matrix}\right.$$ and by the equality $(ab)^{k}=(ba)^{k},$ we have $(ab)^{k-1}(ab)=(ab)^{k-1}(ba).$

By the cancellation law: $ab=ba$ for all $a,b\in G.$

Please, show some work.Give an example to show that this result does not holds forsemi groups.