Word collection in a two-step nilpotent group (source code)

= Word collection in a two-step nilpotent group

In a two-generated <two-step nilpotent group>, use $c=[x,y]=x^{-1}y^{-1}xy$. Centrality of $c$ gives $yx=xyc^{-1}$, so every word collects to $x^ay^bc^r$. The multiplication of these collected expressions is $(a,b,r)(a',b',r')=(a+a',b+b',r+r'-a'b)$. Relations on the central commutator can reduce $r$ modulo its order. To turn collection into a <word problem for a group> algorithm, one must also prove the independence of the remaining coordinates, for example by constructing a group with that cocycle multiplication.