Mapper:=function(word,arg) local i, u, v, w, prod, monoid; w:=ExtRepOfObj(word); prod:=[]; if IsMonoid(arg) then monoid:=arg; for i in [1..(Length(w)/2)] do u:=monoid.(w[2*i-1])^(w[2*i]); Add(prod, u); od; elif IsSemigroup(arg) then monoid:=arg; for i in [1..(Length(w)/2)] do u:=monoid.(w[2*i-1])^(w[2*i]); Add(prod, u); od; else for i in [1..(Length(w)/2)] do u:=arg[(w[2*i-1])]^(w[2*i]); Add(prod, u); od; fi; v:=Product(prod); return v; end; OrigamiMonoidIdemp:=function(monoid) local gens, mgens, rels, newrels, mrels, agens, bgens, arels, brels, abgens, bagens, doublegens, doublerels, w, free, left, right, abrels, barels, M, rws, freeaddrules, creatingrules, i, j, n, generatorMap, fgens, pos, gens0, mapped, commrels; # Step 0: Check if M is a finitely presented monoid if not IsFpMonoid(monoid) then Print("Not a monoid. \n"); return fail; fi; gens:=[]; for i in [1..Size(GeneratorsOfMonoid(monoid))] do Add(gens...