# The following code is used in # "Rationality Problem for Algebraic Tori" # by Akinari Hoshi and Aiichi Yamasaki # Written by Aiichi Yamasaki LoadPackage("HAP"); CochainComplexMatrixGroup:= function(M,n) local IA,G,A,R,TR; IA:=RegularActionHomomorphism(TransposedMatrixGroup(M)); G:=Image(IA); A:=InverseGeneralMapping(IA); R:=ResolutionFiniteGroup(G,n); TR:=HomToIntegralModule(R,A); return TR; end; ChainComplexMatrixGroup:= function(M,n) local IA,G,A,R,TR; IA:=RegularActionHomomorphism(TransposedMatrixGroup(M)); G:=Image(IA); A:=InverseGeneralMapping(IA); R:=ResolutionFiniteGroup(G,n); TR:=TensorWithIntegralModule(R,A); return TR; end; CochainComplexRightCosets:= function(g,h,n) local gg,hg,og,gp,A,R,TR; gg:=GeneratorsOfGroup(g); hg:=SortedList(RightCosets(g,h)); og:=Length(hg); gp:=List(gg,x->PermutationMat(Permutation(x,hg,OnRight),og)); A:=GroupHomomorphismByImages(g,Group(gp),gg,gp); R:=ResolutionFiniteGroup(g,n); TR:=HomToIntegralModule(R,A); return TR; end; ChainComplexRightCosets:= function(g,h,n) local gg,hg,og,gp,A,R,TR; gg:=GeneratorsOfGroup(g); hg:=SortedList(RightCosets(g,h)); og:=Length(hg); gp:=List(gg,x->PermutationMat(Permutation(x,hg,OnRight),og)); A:=GroupHomomorphismByImages(g,Group(gp),gg,gp); R:=ResolutionFiniteGroup(g,n); TR:=TensorWithIntegralModule(R,A); return TR; end; TateCohomology:= function(g,n) local m,gg,i,s,r,TR; if n=0 then m:=Sum(g); s:=SmithNormalFormIntegerMat(m); r:=Rank(s); return List([1..r],x->s[x][x]); elif n>0 then TR:=CochainComplexMatrixGroup(g,n+1); return Cohomology(TR,n); elif n=-1 then m:=[]; gg:=GeneratorsOfGroup(g); if gg=[] then return []; else for i in gg do m:=Concatenation(m,i-Identity(g)); od; s:=SmithNormalFormIntegerMat(m); r:=Rank(s); r:=List([1..r],x->s[x][x]); return Filtered(r,x->x>1); fi; else TR:=ChainComplexMatrixGroup(g,-n); return Homology(TR,-n-1); fi; end;