diff --git a/init.g b/init.g index 3f47841..704fa74 100644 --- a/init.g +++ b/init.g @@ -6,6 +6,23 @@ ## ############################################################################# +# introducing globally the NC versions of PreImages* function for +# compatibility with older GAP version which do not provide them +if not IsBound( PreImagesNC ) then + BindGlobal( "PreImagesNC", PreImages ); +fi; +if not IsBound( PreImagesElmNC ) then + BindGlobal( "PreImagesElmNC", PreImagesElm ); +fi; +if not IsBound( PreImagesSetNC ) then + BindGlobal( "PreImagesSetNC", PreImagesSet ); +fi; +if not IsBound( PreImagesRepresentativeNC ) then + BindGlobal( "PreImagesRepresentativeNC", PreImagesRepresentative ); +fi; + +############################################################################# + ReadPackage( "rcwa", "lib/rcwamap.gd" ); ReadPackage( "rcwa", "lib/rcwamono.gd" ); ReadPackage( "rcwa", "lib/rcwagrp.gd" ); diff --git a/lib/perlist.gi b/lib/perlist.gi index bcecb2e..68c59bd 100644 --- a/lib/perlist.gi +++ b/lib/perlist.gi @@ -92,9 +92,9 @@ InstallOtherMethod( Permuted, * (Int((preperiod_bound-1)/period_bound)+1); else preperiod_bound := 0; fi; preperiod_img := List([0..preperiod_bound-1], - n->Sum(perlist{PreImagesElm(f,n)+1})); + n->Sum(perlist{PreImagesElmNC(f,n)+1})); period_img := List([preperiod_bound..preperiod_bound+period_bound-1], - n->Sum(perlist{PreImagesElm(f,n)+1})); + n->Sum(perlist{PreImagesElmNC(f,n)+1})); perlist_img := PeriodicList(preperiod_img,period_img); CompressPeriodicList(perlist_img); diff --git a/lib/rcwagrp.gd b/lib/rcwagrp.gd index d81c4b2..834abf0 100644 --- a/lib/rcwagrp.gd +++ b/lib/rcwagrp.gd @@ -813,7 +813,7 @@ DeclareOperation( "EpimorphismFromFpGroup", ## #O PreImagesRepresentatives( , ) . . . . several representatives ## -## This is an analogon to `PreImagesRepresentative', which returns a list +## This is an analogue to `PreImagesRepresentative', which returns a list ## of possibly several representatives if computing these is not harder than ## computing just one representative. ## diff --git a/lib/rcwagrp.gi b/lib/rcwagrp.gi index 6a42ff2..05a895e 100644 --- a/lib/rcwagrp.gi +++ b/lib/rcwagrp.gi @@ -2456,8 +2456,8 @@ InstallMethod( IsomorphismRcwaGroup, g->IsIdenticalObj(f,g)))); gens := List([1..Length(gensF)], i->Image(embs[embnrs[i]], - PreImagesRepresentative(embsF[embnrs[i]], - gensF[i]))); + PreImagesRepresentativeNC(embsF[embnrs[i]], + gensF[i]))); img := Group(gens); SetSize(img,infinity); SetIsTame(img,false); SetFreeProductInfo(img,info); @@ -4166,7 +4166,7 @@ InstallMethod( \in, then return true; fi; Info(InfoRCWA,2,"\\in: trying to factor into gen's ..."); phi := EpimorphismFromFreeGroup(G); - return PreImagesRepresentative(phi,g) <> fail; + return PreImagesRepresentativeNC(phi,g) <> fail; end ); ############################################################################# @@ -4259,7 +4259,7 @@ InstallMethod( \in, fi; Info(InfoRCWA,2," is wild -- trying to factor into gen's ..."); phi := EpimorphismFromFreeGroup(G); - return PreImagesRepresentative(phi,g) <> fail; + return PreImagesRepresentativeNC(phi,g) <> fail; else if Modulus(G) mod Modulus(g) <> 0 then Info(InfoRCWA,2,"Mod() does not divide Mod()."); @@ -4296,7 +4296,7 @@ InstallMethod( \in, Info(InfoRCWA,2,"on RespectedPartition()."); phi := EpimorphismFromFreeGroup(H); - h := PreImagesRepresentative(phi,h:NoStabChain); + h := PreImagesRepresentativeNC(phi,h:NoStabChain); if h = fail then return false; fi; h := Product(List(LetterRepAssocWord(h), id->gens[AbsInt(id)]^SignInt(id))); @@ -4392,7 +4392,7 @@ InstallMethod( \in, fi; Info(InfoRCWA,2," is wild -- trying to factor into gen's ..."); phi := EpimorphismFromFreeGroup(G); - return PreImagesRepresentative(phi,g) <> fail; + return PreImagesRepresentativeNC(phi,g) <> fail; else if Modulus(G) mod Modulus(g) <> 0 then Info(InfoRCWA,2,"Mod() does not divide Mod()."); @@ -4423,7 +4423,7 @@ InstallMethod( \in, then return true; fi; Info(InfoRCWA,2,"Trying to factor into gen's ..."); phi := EpimorphismFromFreeGroup(G); # is tame -> this - return PreImagesRepresentative(phi,g) <> fail; # could be improved. + return PreImagesRepresentativeNC(phi,g) <> fail; # could be improved. fi; end ); @@ -6802,9 +6802,9 @@ InstallMethod( PreImagesRepresentatives, ############################################################################# ## -#M PreImagesRepresentative( , ) +#M PreImagesRepresentativeNC( , ) ## -InstallMethod( PreImagesRepresentative, +InstallMethod( PreImagesRepresentativeNC, "for hom's from free groups to rcwa- or perm.-groups (RCWA)", ReturnTrue, [ IsGroupHomomorphism, IsObject ], SUM_FLAGS, @@ -6831,7 +6831,7 @@ InstallMethod( Factorization, [ IsRcwaGroup, IsRcwaMapping ], 0, function ( G, g ) - return PreImagesRepresentative(EpimorphismFromFreeGroup(G),g); + return PreImagesRepresentativeNC(EpimorphismFromFreeGroup(G),g); end ); ############################################################################# diff --git a/lib/rcwamap.gi b/lib/rcwamap.gi index 5c6a5f6..12b815b 100644 --- a/lib/rcwamap.gi +++ b/lib/rcwamap.gi @@ -5754,11 +5754,11 @@ InstallMethod( PreImageElm, ############################################################################# ## -#M PreImagesElm( , ) . . . . . for an rcwa mapping and a ring element +#M PreImagesElmNC( , ) . . . . for an rcwa mapping and a ring element ## ## Returns the preimages of under the rcwa mapping . ## -InstallMethod( PreImagesElm, +InstallMethod( PreImagesElmNC, "for an rcwa mapping and a ring element (RCWA)", ReturnTrue, [ IsRcwaMappingInStandardRep, IsRingElement ], 0, @@ -5788,9 +5788,9 @@ InstallMethod( PreImagesElm, ############################################################################# ## -#M PreImagesElm( , ) . . . . for an rcwa mapping of Z and an integer +#M PreImagesElmNC( , ) . . . for an rcwa mapping of Z and an integer ## -InstallMethod( PreImagesElm, +InstallMethod( PreImagesElmNC, "for an rcwa mapping of Z and an integer (RCWA)", ReturnTrue, [ IsRcwaMappingOfZInSparseRep, IsInt ], 0, @@ -5818,12 +5818,12 @@ InstallMethod( PreImagesElm, ############################################################################# ## -#M PreImagesRepresentative( , ) . . for rcwa mapping and ring element +#M PreImagesRepresentativeNC( , ) . for rcwa mapping and ring element ## ## Returns a representative of the set of preimages of the integer under ## the rcwa mapping . ## -InstallMethod( PreImagesRepresentative, +InstallMethod( PreImagesRepresentativeNC, "for an rcwa mapping and a ring element (RCWA)", ReturnTrue, [ IsRcwaMappingInStandardRep, IsRingElement ], 0, @@ -5847,9 +5847,9 @@ InstallMethod( PreImagesRepresentative, ############################################################################# ## -#M PreImagesRepresentative( , ) . . for rcwa mapping of Z and integer +#M PreImagesRepresentativeNC( , ) . for rcwa mapping of Z and integer ## -InstallMethod( PreImagesRepresentative, +InstallMethod( PreImagesRepresentativeNC, "for an rcwa mapping of Z and an integer (RCWA)", ReturnTrue, [ IsRcwaMappingOfZInSparseRep, IsInt ], 0, @@ -5871,12 +5871,12 @@ InstallMethod( PreImagesRepresentative, ############################################################################# ## -#M PreImagesSet( , ) . . for an rcwa mapping and its underlying ring +#M PreImagesSetNC( , ) . for an rcwa mapping and its underlying ring ## ## Returns the source of the rcwa mapping . ## For technical purposes, only. ## -InstallMethod( PreImagesSet, +InstallMethod( PreImagesSetNC, "for an rcwa mapping and its underlying ring (RCWA)", true, [ IsRcwaMapping, IsRing ], 0, @@ -5887,26 +5887,26 @@ InstallMethod( PreImagesSet, ############################################################################# ## -#M PreImagesSet( , ) . . . . . . for an rcwa mapping and a finite set +#M PreImagesSetNC( , ) . . . . . for an rcwa mapping and a finite set ## ## Returns the preimage of the finite set under the rcwa mapping . ## -InstallMethod( PreImagesSet, +InstallMethod( PreImagesSetNC, "for an rcwa mapping and a finite set (RCWA)", true, [ IsRcwaMapping, IsList ], 0, function ( f, l ) - return Union( List( Set( l ), n -> PreImagesElm( f, n ) ) ); + return Union( List( Set( l ), n -> PreImagesElmNC( f, n ) ) ); end ); ############################################################################# ## -#M PreImagesSet( , ) . for an rcwa mapping and a residue class union +#M PreImagesSetNC( , ) for an rcwa mapping and a residue class union ## ## Returns the preimage of the residue class union under the ## rcwa mapping . ## -InstallMethod( PreImagesSet, +InstallMethod( PreImagesSetNC, "for an rcwa mapping and a residue class union (RCWA)", ReturnTrue, [ IsRcwaMapping, IsResidueClassUnion ], 0, @@ -5920,13 +5920,13 @@ InstallMethod( PreImagesSet, premod := Modulus(f) * Divisor(f) * Modulus(S); preres := Filtered( AllResidues( R, premod ), n -> n^f in rump ); parts := [ ResidueClassUnion( R, premod, preres ) ]; - Append( parts, List( IncludedElements(S), n -> PreImagesElm( f, n ) ) ); + Append( parts, List( IncludedElements(S), n -> PreImagesElmNC( f, n ) ) ); preimage := Union( parts ); excluded := ExcludedElements(S); for n in excluded do - pre := PreImagesElm( f, n ); + pre := PreImagesElmNC( f, n ); im := ImagesSet( f, pre ); - pre2 := PreImagesSet( f, Difference( im, excluded ) ); + pre2 := PreImagesSetNC( f, Difference( im, excluded ) ); diff := Difference( pre, pre2 ); if not IsEmpty( diff ) then preimage := Difference( preimage, diff ); fi; @@ -5936,9 +5936,9 @@ InstallMethod( PreImagesSet, ############################################################################# ## -#M PreImagesSet( , ) . for rcwa mapping of Z and residue class union +#M PreImagesSetNC( , ) for rcwa mapping of Z and residue class union ## -InstallMethod( PreImagesSet, +InstallMethod( PreImagesSetNC, "for an rcwa mapping of Z and a residue class union (RCWA)", ReturnTrue, [ IsRcwaMappingOfZInSparseRep, IsResidueClassUnionOfZ ], 0, @@ -5966,12 +5966,12 @@ InstallMethod( PreImagesSet, ############################################################################# ## -#M PreImagesSet( , ) . . . . as above, but with fixed representatives +#M PreImagesSetNC( , ) . . . as above, but with fixed representatives ## ## Returns the preimage of the union of residue classes of Z with fixed ## representatives under the rcwa mapping . ## -InstallMethod( PreImagesSet, +InstallMethod( PreImagesSetNC, Concatenation("for an rcwa mapping of Z and a union of ", "residue classes with fixed rep's (RCWA)"), ReturnTrue, @@ -5989,8 +5989,8 @@ InstallMethod( PreImagesSet, cls := AsListOfClasses(U); cls := List([1..l],i->RepresentativeStabilizingRefinement(cls[i],k[i])); cls := Flat(List(cls,cl->AsListOfClasses(cl))); - rep := List(cls,cl->PreImagesElm(f,Classes(cl)[1][2])); - cls := List(cls,cl->PreImagesSet(f,AsOrdinaryUnionOfResidueClasses(cl))); + rep := List(cls,cl->PreImagesElmNC(f,Classes(cl)[1][2])); + cls := List(cls,cl->PreImagesSetNC(f,AsOrdinaryUnionOfResidueClasses(cl))); clm := AllResidueClassesModulo(Integers,m); cls := List(cls,cl1->List(clm,cl2->Intersection(cl1,cl2))); cls := List(cls,list->Filtered(list,cl->cl<>[])); @@ -6249,7 +6249,7 @@ InstallGlobalFunction( InjectiveAsMappingFrom, imcl := cl^f; overlap := Intersection(im,imcl); im := Union(im,imcl); - pre := Difference(pre,Intersection(PreImagesSet(f,overlap),cl)); + pre := Difference(pre,Intersection(PreImagesSetNC(f,overlap),cl)); od; return pre; end ); @@ -8338,9 +8338,9 @@ InstallMethod( Sources, adj := TransitionGraph(f,Modulus(f)).adjacencies; comps := List(STRONGLY_CONNECTED_COMPONENTS_DIGRAPH(adj), comp->ResidueClassUnion(Source(f),Modulus(f),res{comp})); - sources := Filtered(comps,comp -> IsSubset(comp,PreImagesSet(f,comp)) - and IsSubset(comp^f,comp) - and comp^f <> comp); + sources := Filtered(comps,comp -> IsSubset(comp,PreImagesSetNC(f,comp)) + and IsSubset(comp^f,comp) + and comp^f <> comp); return sources; end ); @@ -8359,9 +8359,9 @@ InstallMethod( Sinks, adj := TransitionGraph(f,Modulus(f)).adjacencies; comps := List(STRONGLY_CONNECTED_COMPONENTS_DIGRAPH(adj), comp->ResidueClassUnion(Source(f),Modulus(f),res{comp})); - sinks := Filtered(comps,comp -> IsSubset(PreImagesSet(f,comp),comp) - and IsSubset(comp,comp^f) - and comp <> comp^f); + sinks := Filtered(comps,comp -> IsSubset(PreImagesSetNC(f,comp),comp) + and IsSubset(comp,comp^f) + and comp <> comp^f); return sinks; end );