1 | initial version |
It was quite some pain and looks pretty ugly, but this does the job, The interesting part is done in GAP but sadly most of the code is wasted for translation... Feel free to improve it (there is a lot to improve here)
#the variables we want to change
F.<a,b>= FreeGroup();
x=a;
gens=[a*b,b]
#make it compatible for translation into GAP
rank = len(gens)
xTietze= list(x.Tietze())
tgens=[list(word.Tietze()) for word in gens]
print 'x as Tietze: ', xTietze
#translate word and generators to GAP:
gap.eval('tWord := %s;; tgens:=%s;; rank:= %s;;' %(xTietze, tgens, rank))
gap.eval('G := FreeGroup(rank);; Ggens:=GeneratorsOfGroup(G);;')
gap.eval('word:=One(G);; for i in tWord do nextLetter:=Ggens[AbsInt(i)]; if i>0 then word:=word*nextLetter; else word:=word/nextLetter; fi; od;')
gap.eval('newGens:=[];; for tWord in tgens do newGen:=One(G);; for i in tWord do nextLetter:=Ggens[AbsInt(i)]; if i>0 then newGen:=newGen*nextLetter; else newGen:=newGen/nextLetter; fi; od; Add(newGens, newGen); od;')
print 'conversion of new base in GAP: ', gap('newGens')
gap.eval('H:=Subgroup(G,newGens);;')
print 'x after conversion in GAP: ', gap('word')
#change the base in GAP
gap.eval('hom:=EpimorphismFromFreeGroup(H);;')
print 'written with new basis'
gap.eval('newWord := PreImagesRepresentative(hom,word);')
#and translate new Tietze-word back to sage
newTietze=list(gap('TietzeWordAbstractWord(newWord);'))
print 'back in sage as Tietze: ', newTietze
2 | No.2 Revision |
It was quite some pain and looks pretty ugly, but this does the job, The interesting part is done in GAP but sadly most of the code is wasted for translation... Feel free to improve it (there is a lot to improve here)
#the variables we want to change
F.<a,b>= F.<a,b,c>= FreeGroup();
x=a;
gens=[a*b,b]
x=a*b/c;
gens=[a*b,b,b*c]
#make it compatible for translation into GAP
rank = len(gens)
xTietze= list(x.Tietze())
tgens=[list(word.Tietze()) for word in gens]
print 'x as Tietze: ', xTietze
#translate word and generators to GAP:
gap.eval('tWord := %s;; tgens:=%s;; rank:= %s;;' %(xTietze, tgens, rank))
gap.eval('G := FreeGroup(rank);; Ggens:=GeneratorsOfGroup(G);;')
gap.eval('word:=One(G);; for i in tWord do nextLetter:=Ggens[AbsInt(i)]; if i>0 then word:=word*nextLetter; else word:=word/nextLetter; fi; od;')
gap.eval('newGens:=[];; for tWord in tgens do newGen:=One(G);; for i in tWord do nextLetter:=Ggens[AbsInt(i)]; if i>0 then newGen:=newGen*nextLetter; else newGen:=newGen/nextLetter; fi; od; Add(newGens, newGen); od;')
print 'conversion of new base in GAP: ', gap('newGens')
gap.eval('H:=Subgroup(G,newGens);;')
print 'x after conversion in GAP: ', gap('word')
#change the base in GAP
gap.eval('hom:=EpimorphismFromFreeGroup(H);;')
print 'written with new basis'
gap.eval('newWord := PreImagesRepresentative(hom,word);')
#and translate new Tietze-word back to sage
newTietze=list(gap('TietzeWordAbstractWord(newWord);'))
print 'back in sage as Tietze: ', newTietze
3 | No.3 Revision |
It was quite some pain and looks pretty ugly, but this does the job, The interesting part is done in GAP but sadly most of the code is wasted for translation... Feel free to improve it (there is a lot to improve here)
#the variables we want to change
change (feel free to edit this block)
F.<a,b,c>= FreeGroup();
x=a*b/c;
gens=[a*b,b,b*c]
#make it compatible for translation into GAP
rank = len(gens)
xTietze= list(x.Tietze())
tgens=[list(word.Tietze()) for word in gens]
print 'x as Tietze: ', xTietze
#translate word and generators to GAP:
gap.eval('tWord := %s;; tgens:=%s;; rank:= %s;;' %(xTietze, tgens, rank))
gap.eval('G := FreeGroup(rank);; Ggens:=GeneratorsOfGroup(G);;')
gap.eval('word:=One(G);; for i in tWord do nextLetter:=Ggens[AbsInt(i)]; if i>0 then word:=word*nextLetter; else word:=word/nextLetter; fi; od;')
gap.eval('newGens:=[];; for tWord in tgens do newGen:=One(G);; for i in tWord do nextLetter:=Ggens[AbsInt(i)]; if i>0 then newGen:=newGen*nextLetter; else newGen:=newGen/nextLetter; fi; od; Add(newGens, newGen); od;')
print 'conversion of new base in GAP: ', gap('newGens')
gap.eval('H:=Subgroup(G,newGens);;')
print 'x after conversion in GAP: ', gap('word')
#change the base in GAP
gap.eval('hom:=EpimorphismFromFreeGroup(H);;')
print 'written with new basis'
gap.eval('newWord := PreImagesRepresentative(hom,word);')
#and translate new Tietze-word back to sage
newTietze=list(gap('TietzeWordAbstractWord(newWord);'))
print 'back in sage as Tietze: ', newTietze
4 | No.4 Revision |
It was quite some pain and looks pretty ugly, but this does the job, The interesting part is done in GAP but sadly most of the code is wasted for translation... Feel free to improve it (there is a lot to improve here)
#the variables we want to change (feel free to edit this block)
F.<a,b,c>= FreeGroup();
x=a*b/c;
gens=[a*b,b,b*c]
#make it compatible for translation into GAP
rank = len(gens)
xTietze= list(x.Tietze())
tgens=[list(word.Tietze()) for word in gens]
print 'x as Tietze: ', xTietze
#translate word and generators to GAP:
gap.eval('tWord := %s;; tgens:=%s;; rank:= %s;;' %(xTietze, tgens, rank))
gap.eval('G := FreeGroup(rank);; Ggens:=GeneratorsOfGroup(G);;')
gap.eval('word:=One(G);; for i in tWord do nextLetter:=Ggens[AbsInt(i)]; if i>0 then word:=word*nextLetter; else word:=word/nextLetter; fi; od;')
gap.eval('newGens:=[];; for tWord in tgens do newGen:=One(G);; for i in tWord do nextLetter:=Ggens[AbsInt(i)]; if i>0 then newGen:=newGen*nextLetter; else newGen:=newGen/nextLetter; fi; od; Add(newGens, newGen); od;')
print 'conversion of new base in GAP: ', gap('newGens')
gap.eval('H:=Subgroup(G,newGens);;')
print 'x after conversion in GAP: ', gap('word')
#change the base in GAP
gap.eval('hom:=EpimorphismFromFreeGroup(H);;')
print 'written with new basis'
gap.eval('newWord := PreImagesRepresentative(hom,word);')
#and translate new Tietze-word back to sage
newTietze=list(gap('TietzeWordAbstractWord(newWord);'))
newTietze=gap('TietzeWordAbstractWord(newWord);').sage()
print 'back in sage as Tietze: ', newTietze