Maybe is a trivial question, but I don't know how to handle it. 


***Setting:*** Let $S$ be a semigroup (i.e. has an associative operation with neutral element $e$) and let $(A,+)$ be a commutative group (with neutral element $0$). 


A semigroup extension of $S$ with $A$ is any operation on $S \times A$, of the form 


$(s,a)(s',a') = (s s' , a+a'+ \lambda(s,s')$ 


where $\lambda: S \times S \rightarrow A$ is a function such that $S \times A$ with the mentioned operation is a semigroup with neutral element $(e,0)$. Obviously, the operation is encoded by the function $\lambda$, which satisfies certain equations. 


***Problem***: Describe the class of functions $\lambda$ with the property: there is an injective morphism of semigroups from $S$ to $S \times A$ (with the semigroup extension operation induced by $\lambda$). Is there an elegant way to describe this class? 


***Motivation:*** I am puzzled by the following two examples, I cannot put the finger on the essential difference between those. 


Let $X$ and $Y$ be topological, locally convex, real vector spaces of dual 
variables $x \in X$ and $y \in Y$, with the duality product 
$\langle \cdot , \cdot \rangle : X \times Y \rightarrow \mathbb{R}$. 


The spaces $X, Y$ have topologies compatible with the duality 
product, in the sense that for any continuous linear functional on $X$ 
there is an $y \in Y$ which puts the functional into the form $x \mapsto \langle x,y\rangle$ (respectively any continuous linear functional on $Y$ has the form $y \mapsto \langle x,y\rangle$, for a $x \in X$). 


***Example 1:*** (Heisenberg group) Let $S = X \times Y$ with the operation of addition of pairs of vectors and let $A = \mathbb{R}$ with addition. We may define a Heisenberg group over the pair $(X,Y)$ as $H(X,Y) = S \times A$ with the operation 


$(x,y,a)(x',y',b) = (x+x', y+y', a+a'+ \langle x, y'\rangle - \langle x', y \rangle)$


There is no injective morphism from $(X\times Y, +)$ to $H(X,Y)$. 


***Example 2:*** Let this time $S = (X \times Y)^{\*}$, the free semigroup generated by $X \times Y$, i.e. the collection of all finite words with letters from $X \times Y$, together with the empty word $e$, with the operation of concatenation of words. 


Let $A$ be the set of bi-affine real functions on $X \times Y$, i.e. the collection of all functions $a: X \times Y \rightarrow \mathbb{R}$ which are affine and continuous in each argument. $A$ is a commutative group with the addition of real valued functions operation. 


We define the function $\lambda: S \times S \rightarrow A$ by: 


* $\lambda(e, c)(x,y) = \lambda(c,e)(x,y)=0$ for any $c \in S$ and any $(x,y) \in X \times Y$.
* if $c, h \in S$ are words $c = (x\_{1},y\_{1})...(x\_{n}, y\_{n})$ and 
$h = (u\_{1},v\_{1})...(u\_{m}, v\_{m})$, with $m,n \geq 1$, then


$\lambda(c,h)(x,y) = \langle u\_{1} - x , y\_{n} - y \rangle$ 
for any $(x,y) \in X \times Y$. 


This $\lambda$ induces a semigroup extension operation on $S \times A$ and there is an injective morphism $F: S \rightarrow S \times A$, with the expression $F(c) = (c, E(c))$. Here, for any $c = (x\_{1},y\_{1})...(x\_{n}, y\_{n})$ 
the expression $E(c)(x,y)$ is the well known circular sum associated to the "discrete cycle" $(x\_{1},y\_{1})...(x\_{n}, y\_{n})(x,y)$, namely: 


$E(c)(x,y) = \langle x\_{1},y\rangle + \langle x,y\_{n}\rangle - \langle x,y \rangle + \sum\_{k=1}^{n-1}\langle x\_{k+1}, y\_{k}\rangle - \sum\_{k=1}^{n} \langle x\_{k},y\_{k} \rangle $


dear to convex analysis. 



When a semigroup extension $S \times A$ of a semigroup $S$ with a commutative group $A$ contains a copy of $S$?
First of all I would not call what you write a semidirect product. It will be such in your setting precisely when the natural maps to $S$ splits, in which case it will actually be isomorphic to a direct product.


More precisely, you are viewing $A$ here as a trivial module over $\mathbb ZS$. Then $\lambda$ is a 2-cocycle and you want it to be equivalent in $H^2(S,A)$ with the trivial cocycle.


