elems:=proc(g::{specfunc(anything, permgroup), set}) > local > n, g0, G, last_in, element, rep, id, ptr, i, j, s, elt, prev,elmts,flag, > G_s,last_in_s, element_s, rep_s, id_s, ptr_s, elt_s, prev_s; > > flag:=0; > if g::function and op(2, g)::'set'('disjcyc') then > n := op(1, g); > G := map(convert, op(2, g), 'permlist', n) > elif (g::function and op(2, g)::set(equation)) or > (op(1,g)::posint and (g minus {op(1,g)})::set(equation)) then > flag := 1; n := op(1, g); > if g::function then g0:=op(2, g) > else g0:=g minus {g[1]}; > end if; > G := map(convert, map(rhs, g0), 'permlist', n) > elif g::'set'('disjcyc') then > if g = {[]} or g = {} then n := 1 > else n := max(op(map(op, map(op, g)))) > end if; > G := map(convert, g, 'permlist', n) > else error "Input error." > end if; > > if flag=0 then > for i to nops(G) do > G_s[i]:=convert([96+i],bytes); > print(G[i],`be defined as`,G_s[i]); > end do; > else > for i in g0 do j := 1; > while G[j]<>convert(i, 'permlist', n) do j:=j+1;end do; > G_s[j]:=convert(op(1,i),string); > print(G[j],`be defined as`,G_s[j]); > end do; > end if; > > if g::function then userinfo(2, 'group',`calculating elements of group`, g) > else userinfo(2, 'group',`calculating elements of group generated by`, g) > end if; > > > userinfo(2, 'group', `using Dimino's algorithm`); > > id := [seq(s, s = 1 .. n)]; id_s:=""; > if G = {} then G := {id} end if; > userinfo(3, 'group',`adding first generator and its powers`); > > element := table(); element_s := table(); > last_in := id; last_in_s := id_s; > elt := G[1]; elt_s := G_s[1]; > > while elt <> id do > element[last_in] := [elt,last_in_s]; element_s[last_in_s] := elt; > last_in := elt; last_in_s := elt_s; > > if assigned(element[last_in]) and (not assigned(element_s[last_in_s])) then > last_in_s :=element[last_in][2]; > end if; > > elt := [seq(G[1][s], s = elt)]; > > if elt = id then elt_s := id_s; > else elt_s := cat(elt_s,G_s[1]); > end if; > end do; > G_s[[]] := cat(last_in_s,G_s[1]); > for i from 2 to nops(G) do > element[last_in] := NULL; element_s[last_in_s] :=NULL; > > userinfo(3, 'group', `treating generator number`, i); > > if not assigned(element[G[i]]) then > > userinfo(3, 'group', `generator not in subgroup`); > userinfo(3, 'group', `adding coset generated by`,G[i]); > > prev := last_in; prev_s := last_in_s; > element[last_in] := [G[i],last_in_s]; > element_s[last_in_s] := G[i]; > last_in := G[i]; last_in_s := G_s[i]; > ptr := id; ptr_s := id_s; > while ptr <> prev do > element[last_in] := > [[seq(G[i][s], s = element[ptr][1])],last_in_s]; > element_s[last_in_s] := > [seq(G[i][s], s = element[ptr][1])]; > last_in := element[last_in][1]; > ptr := element[ptr][1]; last_in_s := cat(element[ptr][2],G_s[i]); > > if assigned(element[last_in]) and (not assigned(element_s[last_in_s])) then > last_in_s :=element[last_in][2]; > end if; > > ptr_s := element[ptr][2]; > end do; > rep := element[prev][1]; > if not assigned(element[rep]) then > rep_s := last_in_s;#??? > else rep_s := element[rep][2]; > end if; > do > for j to i do > elt := [seq(G[j][s], s = rep)]; > if elt = id then elt_s := id_s; > else elt_s := cat(rep_s,G_s[j]); > end if; > element[last_in] := NULL; element_s[last_in_s] := NULL; > if not assigned(element[elt]) then > userinfo(3, 'group',`adding coset generated by`, elt); > > element[last_in] := [elt,last_in_s]; > element_s[last_in_s] := elt; > last_in := elt; last_in_s := elt_s; > > if assigned(element[last_in]) and (not assigned(element_s[last_in_s])) > then last_in_s :=element[last_in][2]; > end if; > > ptr := id; ptr_s := id_s; > while ptr <> prev do > element[last_in] := [[seq(elt[s], s = element[ptr][1])], > last_in_s]; > element_s[last_in_s] := [seq(elt[s], s = element[ptr][1])]; > last_in := element[last_in][1]; > last_in_s := cat(element[element[ptr][1]][2],elt_s); > > if assigned(element[last_in]) and > (not assigned(element_s[last_in_s])) then > last_in_s :=element[last_in][2]; > end if; > > ptr := element[ptr][1]; ptr_s := element[ptr][2]; > > end do; > end if; > > end do; > ptr := id; ptr_s := id_s; > while ptr <> element[prev][1] and rep <> NULL do > if element[rep]=NULL then rep := NULL; > else rep := element[rep][1]; end if; > > ptr := element[ptr][1]; > > > if rep = NULL then rep_s := NULL; > elif element[rep]=NULL then rep_s := ""; > elif rep = id then rep_s := id_s; > else rep_s := element[rep][2]; > end if; > > > if ptr = NULL then ptr_s := NULL; > elif element[ptr]=NULL then ptr_s := ""; > elif ptr = id then ptr_s := id_s; > else ptr_s := element[ptr][2]; > end if; > > end do; > if rep = NULL then break end if > end do; > > else userinfo(3, 'group',`generator already in subgroup`) > end if; > > end do; > userinfo(2, 'group',`converting to disjoint cycle notation`); > > element[last_in] := [[],last_in_s]; element_s[last_in_s] := NULL; > element[id][2] := G_s[[]];#Unit > for i in indices(element) do elmts[convert(op(i), 'disjcyc')] := element[op(i)][2];end do; > elmts; > end proc: