From 42b327337f6cf74428abb2a2206eb4b2fb06f7a0 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Wed, 29 Apr 2026 18:09:07 +0200 Subject: [PATCH 1/2] Reindent lib/local.gi and lib/lib_local.gi for readability Keep the contents unchanged apart from whitespace and line breaks. Co-authored-by: Codex --- lib/lib_local.gi | 488 ++++++++++++++++---------------- lib/local.gi | 705 +++++++++++++++++++++++++---------------------- 2 files changed, 632 insertions(+), 561 deletions(-) diff --git a/lib/lib_local.gi b/lib/lib_local.gi index b996de7..9119c98 100644 --- a/lib/lib_local.gi +++ b/lib/lib_local.gi @@ -2,165 +2,177 @@ ############################################################################ ## # LocalNearRing() - InstallMethod( LocalNearRing, +InstallMethod( LocalNearRing, "Local nearring", [ IsInt, IsInt, IsInt, IsInt, IsInt ], - function( k,l,m,n,w ) -local h, dio, G, P, P1, H, R, Li, t, gr, Pos, x, y, d, z, hom, f, const, constructor, u, B, A, k1, Or, a, g, Em, ma, mul, Nr; -h:=DirectoriesPackageLibrary("LocalNR", Concatenation("Endom/", String(k))); -if IsEmpty(h) then return false; -else -dio:=Filename(h,Concatenation("Endom", String(k),"_",String(l),"-",String(m),"_",String(n),".txt")); -G:=SmallGroup(k,l); -P1:=ReadAsFunction(dio)(); -P:=P1[w]; -H:=[]; -R:=[]; -Li:=AsSortedList(G); -t:=Size(P); -gr:=MinimalGeneratingSet(G); -Pos:=[]; -for x in gr do -Add(Pos,Position(Li,x)); -od; -for y in [1..t] do -d:=[]; -for z in Pos do -Add(d,Li[P[y][z]]); -od; -Add(H,d); -od; -hom:=[]; -for x in H do -d:=GroupHomomorphismByImagesNC(G,G,gr,x); -Add(hom,d); -od; -f:=function(x,y) return x*y;end; -const:=function(y) return function(x) return y^x; end;end; -constructor:=function(z) return function(u) return function(x,y) return u^(PreImage(z,y)*PreImage(z,x));end;end;end; -B:=Filtered(hom,x->IsInjective(x)); -A:=GroupByGenerators(B); -k1:=Position(OrbitLengths(A,G),Size(A)); -Or:=OrbitsDomain(A,G)[k1]; -a:=Or[1]; -g:=const(a); -Em:=MagmaWithOne(hom); -ma:=MappingByFunction(Em,G,g); -mul:=constructor(ma)(a); -Nr:=ExplicitMultiplicationNearRingNC(G, mul); -return Nr; -fi; -end); + function( k, l, m, n, w ) + local h, dio, G, P, P1, H, R, Li, t, gr, Pos, x, y, d, z, hom, + f, const, constructor, u, B, A, k1, Or, a, g, Em, ma, mul, + Nr; + + h := DirectoriesPackageLibrary( "LocalNR", Concatenation( "Endom/", String( k ) ) ); + if IsEmpty( h ) then + return false; + else + dio := Filename( h, Concatenation( "Endom", String( k ), "_", String( l ), "-", String( m ), "_", String( n ), ".txt" ) ); + G := SmallGroup( k, l ); + P1 := ReadAsFunction( dio )(); + P := P1[w]; + H := []; + R := []; + Li := AsSortedList( G ); + t := Size( P ); + gr := MinimalGeneratingSet( G ); + Pos := []; + for x in gr do + Add( Pos, Position( Li, x ) ); + od; + for y in [1..t] do + d := []; + for z in Pos do + Add( d, Li[P[y][z]] ); + od; + Add( H, d ); + od; + hom := []; + for x in H do + d := GroupHomomorphismByImagesNC( G, G, gr, x ); + Add( hom, d ); + od; + f := function( x, y ) return x * y; end; + const := function( y ) return function( x ) return y^x; end; end; + constructor := function( z ) return function( u ) return function( x, y ) return u^( PreImage( z, y ) * PreImage( z, x ) ); end; end; end; + B := Filtered( hom, x -> IsInjective( x ) ); + A := GroupByGenerators( B ); + k1 := Position( OrbitLengths( A, G ), Size( A ) ); + Or := OrbitsDomain( A, G )[k1]; + a := Or[1]; + g := const( a ); + Em := MagmaWithOne( hom ); + ma := MappingByFunction( Em, G, g ); + mul := constructor( ma )( a ); + Nr := ExplicitMultiplicationNearRingNC( G, mul ); + return Nr; + fi; + end ); ## ############################################################################ ## # AllLocalNearRings() - InstallMethod( AllLocalNearRings, +InstallMethod( AllLocalNearRings, "All local nearrings", [ IsInt, IsInt, IsInt, IsInt ], - function( k,l,m,n ) - local G, P1, w, h, H, s, t, Li, hom, En, R, gr, Pos, x, i, y, z, d, f, const, constructor, u, I, J, T, B, j, A, k1, Or, a, g, Em, ma, mul, Nr; - h:=DirectoriesPackageLibrary("LocalNR", Concatenation("Endom/", String(k))); -if IsEmpty(h) then return false; -else -w:=Filename(h,Concatenation("Endom", String(k),"_",String(l),"-",String(m),"_",String(n),".txt")); -G:=SmallGroup(k,l); -P1:=ReadAsFunction(w)(); -H:=[]; -s:=Size(P1); -t:=List(P1,Size);; -Li:=AsSortedList(G);; -hom:=[]; -En:=[]; -R:=[]; -gr:=MinimalGeneratingSet(G); -Pos:=[]; -for x in gr do -Add(Pos,Position(Li,x)); -od; -for i in [1..s] do -H[i]:=[]; -for y in [1..t[i]] do -d:=[]; -for z in Pos do -Add(d,Li[P1[i][y][z]]); -od; -Add(H[i],d); -od; -hom[i]:=[]; -for x in H[i] do -d:=GroupHomomorphismByImagesNC(G,G,gr,x); -Add(hom[i],d); -od; -od; -f:=function(x,y) return x*y;end; -const:=function(y) return function(x) return y^x; end;end; -constructor:=function(z) return function(u) return function(x,y) return -u^(PreImage(z,y)*PreImage(z,x));end;end;end; -s:=Size(hom); -I:=[1..s]; -repeat -J:=[]; -T:=[]; -B:=Filtered(hom[I[1]],x->IsInjective(x));; -for i in I do -if IsSubset(hom[i],B) then Add(J,i);fi; -od; -j:=Size(J); -A:=GroupByGenerators(B); -k1:=Position(OrbitLengths(A,G),Size(A)); -Or:=OrbitsDomain(A,G)[k1]; -a:=Or[1]; -g:=const(a); -for l in J do -Em:=MagmaWithOne(hom[l]); -ma:=MappingByFunction(Em,G,g); -mul:=constructor(ma)(a); -Nr:=ExplicitMultiplicationNearRingNC(G, mul); -Add(T,Nr); -od; -Add(R,T); -I:=Difference(I,J);; -until Size(I)=0; -R:=Concatenation(R);; -return R; -fi; -end); + function( k, l, m, n ) + local G, P1, w, h, H, s, t, Li, hom, En, R, gr, Pos, x, i, y, z, + d, f, const, constructor, u, I, J, T, B, j, A, k1, Or, a, + g, Em, ma, mul, Nr; + + h := DirectoriesPackageLibrary( "LocalNR", Concatenation( "Endom/", String( k ) ) ); + if IsEmpty( h ) then + return false; + else + w := Filename( h, Concatenation( "Endom", String( k ), "_", String( l ), "-", String( m ), "_", String( n ), ".txt" ) ); + G := SmallGroup( k, l ); + P1 := ReadAsFunction( w )(); + H := []; + s := Size( P1 ); + t := List( P1, Size );; + Li := AsSortedList( G );; + hom := []; + En := []; + R := []; + gr := MinimalGeneratingSet( G ); + Pos := []; + for x in gr do + Add( Pos, Position( Li, x ) ); + od; + for i in [1..s] do + H[i] := []; + for y in [1..t[i]] do + d := []; + for z in Pos do + Add( d, Li[P1[i][y][z]] ); + od; + Add( H[i], d ); + od; + hom[i] := []; + for x in H[i] do + d := GroupHomomorphismByImagesNC( G, G, gr, x ); + Add( hom[i], d ); + od; + od; + f := function( x, y ) return x * y; end; + const := function( y ) return function( x ) return y^x; end; end; + constructor := function( z ) return function( u ) return function( x, y ) return + u^( PreImage( z, y ) * PreImage( z, x ) ); end; end; end; + s := Size( hom ); + I := [1..s]; + repeat + J := []; + T := []; + B := Filtered( hom[I[1]], x -> IsInjective( x ) );; + for i in I do + if IsSubset( hom[i], B ) then + Add( J, i ); + fi; + od; + j := Size( J ); + A := GroupByGenerators( B ); + k1 := Position( OrbitLengths( A, G ), Size( A ) ); + Or := OrbitsDomain( A, G )[k1]; + a := Or[1]; + g := const( a ); + for l in J do + Em := MagmaWithOne( hom[l] ); + ma := MappingByFunction( Em, G, g ); + mul := constructor( ma )( a ); + Nr := ExplicitMultiplicationNearRingNC( G, mul ); + Add( T, Nr ); + od; + Add( R, T ); + I := Difference( I, J );; + until Size( I ) = 0; + R := Concatenation( R );; + return R; + fi; + end ); ## ############################################################################ ## # TheAdditiveGroupsOfLibraryOfLNRsOfOrder InstallGlobalFunction(TheAdditiveGroupsOfLibraryOfLNRsOfOrder, function(n) -local t,cont,i,h,j,f,g,r,us; -t:=DirectoriesPackageLibrary("LocalNR", Concatenation("Endom/", String(n))); -if IsEmpty(t) then Error("the order must be PrimePowerInt and 30 then -Add(g,i[2]); -fi; -od; -us:=Set(g,Int); -r:=[]; -for i in us do -Add(r,SmallGroup(n,i)); -od; -return r; -fi; - end); + local t, cont, i, h, j, f, g, r, us; + + t := DirectoriesPackageLibrary( "LocalNR", Concatenation( "Endom/", String( n ) ) ); + if IsEmpty( t ) then + Error( "the order must be PrimePowerInt and 3 0 then + Add( g, i[2] ); + fi; + od; + us := Set( g, Int ); + r := []; + for i in us do + Add( r, SmallGroup( n, i ) ); + od; + return r; + fi; +end ); ## @@ -168,85 +180,92 @@ fi; ## # IsAdditiveGroupOfLibraryOfLNRs InstallGlobalFunction(IsAdditiveGroupOfLibraryOfLNRs, function(G) -local s,t,cont,i,h,j,f,g,r,us,d,k; -s:=Size(G); -t:=DirectoriesPackageLibrary("LocalNR", Concatenation("Endom/", String(s))); -if IsEmpty(t) then Error("false"); -else -cont:=DirectoryContents(t[1]);; -Size(cont); -for i in cont do -RemoveCharacters(i, "Endom\.txt\.gz"); -od; -h:=[]; -for j in cont do -f:=SplitStringInternal(j, "_","-"); -Add(h,f); -od; -g:=[]; -for i in h do -if Size(i)>0 then -Add(g,i[2]); -fi; -od; -us:=Set(g,Int); -r:=[]; -for i in us do -Add(r,[s,i]); -od; -fi; -k:=Size(r); -d:=Filtered([1..k],x->IdGroup(G)=r[x]); -if Size(d)>0 then Print("true"); -else Print("false"); fi; -end); + local s, t, cont, i, h, j, f, g, r, us, d, k; + + s := Size( G ); + t := DirectoriesPackageLibrary( "LocalNR", Concatenation( "Endom/", String( s ) ) ); + if IsEmpty( t ) then + Error( "false" ); + else + cont := DirectoryContents( t[1] );; + Size( cont ); + for i in cont do + RemoveCharacters( i, "Endom\.txt\.gz" ); + od; + h := []; + for j in cont do + f := SplitStringInternal( j, "_", "-" ); + Add( h, f ); + od; + g := []; + for i in h do + if Size( i ) > 0 then + Add( g, i[2] ); + fi; + od; + us := Set( g, Int ); + r := []; + for i in us do + Add( r, [ s, i ] ); + od; + fi; + k := Size( r ); + d := Filtered( [1..k], x -> IdGroup( G ) = r[x] ); + if Size( d ) > 0 then + Print( "true" ); + else + Print( "false" ); + fi; +end ); ## ############################################################################ ## # TheLibraryOfLNRsOnGroup -InstallGlobalFunction(TheLibraryOfLNRsOnGroup, function(G) +InstallGlobalFunction(TheLibraryOfLNRsOnGroup, function(G) + + local s, t, cont, i, h, j, f, hj, g, r, ee, ww, b, w; -local s,t,cont,i,h,j,f,hj,g,r,ee,ww,b,w; -s:=Size(G); -t:=DirectoriesPackageLibrary("LocalNR", Concatenation("Endom/", String(s))); -if IsEmpty(t) then Error("false"); -else -cont:=DirectoryContents(t[1]); -Size(cont); -for i in cont do -RemoveCharacters(i, "Endom\.txt\.gz"); -od; -h:=[]; -for j in cont do -f:=SplitStringInternal(j, "_","-"); -Add(h,f); -od; -fi; -hj:=IdGroup(G); -g:=[]; -for i in h do -if Size(i)>0 and EvalString(i[2])=hj[2] then -Add(g,i); -fi; -od; -ww:=function(b,w) -if Int(b[3])=Int(w[3]) then -return Int(b[4]) < Int(w[4]); -else -return Int(b[3]) < Int(w[3]); -fi; -end; -Sort(g,ww); -ee:=[]; -for i in g do -if Size(i)>0 then -Add(ee,Concatenation("AllLocalNearRings(",i[1],",",i[2],",",i[3],",",i[4],")")); -fi; -od; -return ee; -end); + s := Size( G ); + t := DirectoriesPackageLibrary( "LocalNR", Concatenation( "Endom/", String( s ) ) ); + if IsEmpty( t ) then + Error( "false" ); + else + cont := DirectoryContents( t[1] ); + Size( cont ); + for i in cont do + RemoveCharacters( i, "Endom\.txt\.gz" ); + od; + h := []; + for j in cont do + f := SplitStringInternal( j, "_", "-" ); + Add( h, f ); + od; + fi; + hj := IdGroup( G ); + g := []; + for i in h do + if Size( i ) > 0 and EvalString( i[2] ) = hj[2] then + Add( g, i ); + fi; + od; + ww := function( b, w ) + if Int( b[3] ) = Int( w[3] ) then + return Int( b[4] ) < Int( w[4] ); + else + return Int( b[3] ) < Int( w[3] ); + fi; + end; + Sort( g, ww ); + ee := []; + for i in g do + if Size( i ) > 0 then + Add( ee, Concatenation( "AllLocalNearRings(", i[1], ",", i[2], ",", i[3], ",", i[4], ")" ) ); + fi; + od; + return ee; +end ); ## @@ -255,19 +274,24 @@ end); # InfoLocalNearRing InstallGlobalFunction(InfoLocalNearRing, function(G) -local R,s,T,i,K,t,h; -h:=DirectoriesPackageLibrary("LocalNR", "Endom/"); -t:=Filename(h,Concatenation("info", ".txt")); -R:=ReadAsFunction(t)(); -K:=IdGroup(G); -s:=Size(R); -T:=[]; -for i in [1..s] do -if R[i][1]=K[1] and R[i][2]=K[2] then -Add(T,Concatenation("AllLocalNearRings(",String(R[i][1]),",",String(R[i][2]),",",String(R[i][3]),",",String(R[i][4]),") (", String(R[i][5]), ")")); -fi; -od; -if Size(T)>1 then Print("The local nearrings are sorted by their multiplicative groups.\n", T); -elif Size(T)=1 then Print(T); -else return Error("group is not recognized in the library"); fi; -end); + local R, s, T, i, K, t, h; + + h := DirectoriesPackageLibrary( "LocalNR", "Endom/" ); + t := Filename( h, Concatenation( "info", ".txt" ) ); + R := ReadAsFunction( t )(); + K := IdGroup( G ); + s := Size( R ); + T := []; + for i in [1..s] do + if R[i][1] = K[1] and R[i][2] = K[2] then + Add( T, Concatenation( "AllLocalNearRings(", String( R[i][1] ), ",", String( R[i][2] ), ",", String( R[i][3] ), ",", String( R[i][4] ), ") (", String( R[i][5] ), ")" ) ); + fi; + od; + if Size( T ) > 1 then + Print( "The local nearrings are sorted by their multiplicative groups.\n", T ); + elif Size( T ) = 1 then + Print( T ); + else + return Error( "group is not recognized in the library" ); + fi; +end ); diff --git a/lib/local.gi b/lib/local.gi index cd40798..7d9277c 100644 --- a/lib/local.gi +++ b/lib/local.gi @@ -5,38 +5,41 @@ InstallMethod( IsMinimalNonAbelianGroup, "Is minimal non-abelian group", [ IsGroup ], - function( G ) - if IsAbelian(G) then - return false; - else - if ForAll( MaximalSubgroups(G), x->IsAbelian(x)) then - return true; - else return false; - fi; - fi; - end); + function( G ) + if IsAbelian( G ) then + return false; + else + if ForAll( MaximalSubgroups( G ), x -> IsAbelian( x ) ) then + return true; + else + return false; + fi; + fi; + end ); ## ############################################################################ ## # IsMetacyclicPGroup() -InstallMethod( IsMetacyclicPGroup, +InstallMethod( IsMetacyclicPGroup, "Is metacyclic p-group", [ IsPGroup ], - function(G) - local p; - p:=Factors(Size(G))[1]; - if p=2 then - if Maximum(List(List(MaximalSubgroups(G),MinimalGeneratingSet),Size))<=2 - then return true; - fi; - else - if Size(FactorGroup(G,Agemo(G,p)))<=p^2 then - return true; - fi; - fi; - return false; - end); + function( G ) + local p; + + p := Factors( Size( G ) )[1]; + if p = 2 then + if Maximum( List( List( MaximalSubgroups( G ), MinimalGeneratingSet ), Size ) ) <= 2 + then + return true; + fi; + else + if Size( FactorGroup( G, Agemo( G, p ) ) ) <= p^2 then + return true; + fi; + fi; + return false; + end ); ## ############################################################################ @@ -45,29 +48,30 @@ InstallMethod( IsMetacyclicPGroup, InstallMethod( EndoOrbitsOfGroup, "Compute endo-orbits of group", [ IsGroup ], - function(G) - local A, En, F, H, M, Or, T, x, y; -A:=AutomorphismGroup(G); -En:=Endomorphisms(G); -Or:=OrbitsDomain(A,G); -T:=[]; -for x in Or do -Add(T,Representative(x)); -od; -F:=[]; -repeat -M:=Filtered(T,x->Order(x)=Maximum(List(T,Order))); -x:=M[1]; -H:=[]; -for y in En do -Add(H,x^y); -H:=Unique(H); -od; -Add(F,[x,H]); -T:=Difference(T,H); -until Size(T)=0; -return F; - end); + function( G ) + local A, En, F, H, M, Or, T, x, y; + + A := AutomorphismGroup( G ); + En := Endomorphisms( G ); + Or := OrbitsDomain( A, G ); + T := []; + for x in Or do + Add( T, Representative( x ) ); + od; + F := []; + repeat + M := Filtered( T, x -> Order( x ) = Maximum( List( T, Order ) ) ); + x := M[1]; + H := []; + for y in En do + Add( H, x^y ); + H := Unique( H ); + od; + Add( F, [ x, H ] ); + T := Difference( T, H ); + until Size( T ) = 0; + return F; + end ); ## ############################################################################ @@ -75,19 +79,24 @@ return F; # IsEndoCyclicGroup() InstallMethod( IsEndoCyclicGroup, "Is endocyclic group", - [ IsGroup ], - function(G) - local F, h, i, t; - F:=EndoOrbitsOfGroup(G); - t:=Size(F); - h:=[]; - for i in [1..t] do - if Size(F[i][2])=Size(G) then Add(h,F[i][2]);fi; - od; - if Size(h)>0 then - return true; - else return false;fi; - end); + [ IsGroup ], + function( G ) + local F, h, i, t; + + F := EndoOrbitsOfGroup( G ); + t := Size( F ); + h := []; + for i in [1..t] do + if Size( F[i][2] ) = Size( G ) then + Add( h, F[i][2] ); + fi; + od; + if Size( h ) > 0 then + return true; + else + return false; + fi; + end ); ## ############################################################################ @@ -96,18 +105,19 @@ InstallMethod( IsEndoCyclicGroup, InstallMethod( UnitsOfNearRing, "Compute all units of nearring", true, - [ IsNearRing ], 0, - function(R) - local A, G, one, x; - one := Identity(R); - if one = fail then - return []; - else - G:=GroupReduct(R); - A:=AutomorphismGroup(G); - return Filtered(R,x->x^Size(A)=one); - fi; - end); + [ IsNearRing ], 0, + function( R ) + local A, G, one, x; + + one := Identity( R ); + if one = fail then + return []; + else + G := GroupReduct( R ); + A := AutomorphismGroup( G ); + return Filtered( R, x -> x^Size( A ) = one ); + fi; + end ); ## ############################################################################ @@ -116,23 +126,24 @@ InstallMethod( UnitsOfNearRing, InstallMethod( IsLocalNearRing, "Is local nearring", true, - [ IsNearRing ], - 0, - function( R ) - local L,one,U,V,x,y; - - one:=Identity(R); - U:=UnitsOfNearRing(R); - L:=Difference(R,U);; - V:=[]; - for x in L do - Add(V,one+x); - od; - if IsSubset(U,V) then - return true; - else return false; - fi; - end); + [ IsNearRing ], + 0, + function( R ) + local L, one, U, V, x, y; + + one := Identity( R ); + U := UnitsOfNearRing( R ); + L := Difference( R, U );; + V := []; + for x in L do + Add( V, one + x ); + od; + if IsSubset( U, V ) then + return true; + else + return false; + fi; + end ); ## ############################################################################ @@ -140,16 +151,18 @@ InstallMethod( IsLocalNearRing, # IsDistributiveElementOfNearRing() InstallMethod( IsDistributiveElementOfNearRing, "Is Distributive Element of Nearring", - [ IsNearRing, IsNearRingElement ], - 0, - function(R,r) - local map, x; - map:=MappingByFunction(R,R,x->x*r); - if IsAdditiveGroupHomomorphism(map) then - return true; - else return false; - fi; - end); + [ IsNearRing, IsNearRingElement ], + 0, + function( R, r ) + local map, x; + + map := MappingByFunction( R, R, x -> x * r ); + if IsAdditiveGroupHomomorphism( map ) then + return true; + else + return false; + fi; + end ); ## ############################################################################ @@ -157,23 +170,25 @@ InstallMethod( IsDistributiveElementOfNearRing, # IsLocalRing() InstallMethod( IsLocalRing, "Is local ring", - [ IsNearRing ], - 0, - function( R ) - local elm, G, mg, x, y; - - G:=GroupReduct(R); - mg:=MinimalGeneratingSet(G); - elm:=[]; - for x in mg do - Add(elm,AsNearRingElement(R,x)); - od; - if IsAbelian(G) and IsLocalNearRing(R) and - ForAll(elm,y->IsDistributiveElementOfNearRing(R,y)) - then return true; - else return false; - fi; - end); + [ IsNearRing ], + 0, + function( R ) + local elm, G, mg, x, y; + + G := GroupReduct( R ); + mg := MinimalGeneratingSet( G ); + elm := []; + for x in mg do + Add( elm, AsNearRingElement( R, x ) ); + od; + if IsAbelian( G ) and IsLocalNearRing( R ) and + ForAll( elm, y -> IsDistributiveElementOfNearRing( R, y ) ) + then + return true; + else + return false; + fi; + end ); ## ############################################################################ @@ -181,14 +196,14 @@ InstallMethod( IsLocalRing, # NearRingNonUnits() InstallMethod( NearRingNonUnits, "Compute nearring non-units", - [ IsNearRing ], - function(R) - if Identity(R)=fail then - return List(R); - else return - Difference(R,UnitsOfNearRing(R)); - fi; - end); + [ IsNearRing ], + function( R ) + if Identity( R ) = fail then + return List( R ); + else + return Difference( R, UnitsOfNearRing( R ) ); + fi; + end ); ## ############################################################################ @@ -196,17 +211,19 @@ InstallMethod( NearRingNonUnits, # GroupOfUnitsAsGroupOfAutomorphisms() InstallMethod( GroupOfUnitsAsGroupOfAutomorphisms, "Compute a group isomorphic to the group of units of a nearring", - [ IsNearRing ], - function(R) - local A, U; - if Identity(R)=fail then Error("no units exist"); - else - U:=UnitsOfNearRing(R);; - A:=AutomorphismsAssociatedWithNearRingUnits(R,U);; - A:=AsGroup(A);; - return A; - fi; - end); + [ IsNearRing ], + function( R ) + local A, U; + + if Identity( R ) = fail then + Error( "no units exist" ); + else + U := UnitsOfNearRing( R );; + A := AutomorphismsAssociatedWithNearRingUnits( R, U );; + A := AsGroup( A );; + return A; + fi; + end ); ## @@ -215,26 +232,27 @@ InstallMethod( GroupOfUnitsAsGroupOfAutomorphisms, # SubNearRingByGenerators() InstallMethod( SubNearRingByGenerators, "Compute subnearring by generators", - [ IsNearRing, IsNearRingElementCollection], - function(R,elm) - local a, b, c, G, M, N, S; - G:=GroupReduct(R); - S:=SemigroupByGenerators(elm); - repeat - M:=[]; - N:=[]; - for a in S do - Add(M,AsGroupReductElement(a)); - od; - M:=Subgroup(G,M); - for b in M do - Add(N,AsNearRingElement(R,b)); - od; - S:=SemigroupByGenerators(N); - until Size(M)=Size(S); - c:=SubNearRingBySubgroupNC(R,M); - return c; - end); + [ IsNearRing, IsNearRingElementCollection ], + function( R, elm ) + local a, b, c, G, M, N, S; + + G := GroupReduct( R ); + S := SemigroupByGenerators( elm ); + repeat + M := []; + N := []; + for a in S do + Add( M, AsGroupReductElement( a ) ); + od; + M := Subgroup( G, M ); + for b in M do + Add( N, AsNearRingElement( R, b ) ); + od; + S := SemigroupByGenerators( N ); + until Size( M ) = Size( S ); + c := SubNearRingBySubgroupNC( R, M ); + return c; + end ); ## ############################################################################ @@ -242,20 +260,22 @@ InstallMethod( SubNearRingByGenerators, # NonUnitsAsAdditiveSubgroup() InstallMethod( NonUnitsAsAdditiveSubgroup, "the additive subgroup of all non-units in local nearring", - [ IsNearRing ], - function(R) - local a, N, g, L; - if IsLocalNearRing(R) then - N:=NearRingNonUnits(R); - g:=[]; - for a in N do - Add(g,AsGroupReductElement(a)); - od; - L:=Subgroup(GroupReduct(R),g); - return L; - else return fail; - fi; - end); + [ IsNearRing ], + function( R ) + local a, N, g, L; + + if IsLocalNearRing( R ) then + N := NearRingNonUnits( R ); + g := []; + for a in N do + Add( g, AsGroupReductElement( a ) ); + od; + L := Subgroup( GroupReduct( R ), g ); + return L; + else + return fail; + fi; + end ); ## ############################################################################ @@ -263,16 +283,18 @@ InstallMethod( NonUnitsAsAdditiveSubgroup, # NonUnitsAsNearRingIdeal() InstallMethod( NonUnitsAsNearRingIdeal, "the maximal ideal in local nearring", - [ IsNearRing ], - function(R) - local N, S; - if IsLocalNearRing(R) then - N:=NonUnitsAsAdditiveSubgroup(R); - S:=NearRingIdealBySubgroupNC(R,N); - return S; - else return fail; - fi; - end); + [ IsNearRing ], + function( R ) + local N, S; + + if IsLocalNearRing( R ) then + N := NonUnitsAsAdditiveSubgroup( R ); + S := NearRingIdealBySubgroupNC( R, N ); + return S; + else + return fail; + fi; + end ); ## ############################################################################ @@ -280,15 +302,19 @@ InstallMethod( NonUnitsAsNearRingIdeal, # MultiplicativeSemigroupOfNearRing() InstallMethod( MultiplicativeSemigroupOfNearRing, "Multiplicative semigroup of nearring", - [ IsNearRing ], - function(R) - local a, u; - if Identity(R)=fail then a:=AsSemigroup(List(R)); -else u:=Identity(R);a:=AsSemigroup(List(R)); -Print("Semigroup with identity"," ",u,"\n"); -fi; -return a; - end); + [ IsNearRing ], + function( R ) + local a, u; + + if Identity( R ) = fail then + a := AsSemigroup( List( R ) ); + else + u := Identity( R ); + a := AsSemigroup( List( R ) ); + Print( "Semigroup with identity", " ", u, "\n" ); + fi; + return a; + end ); ## @@ -298,13 +324,14 @@ return a; InstallMethod( NonUnitsAsMultiplicativeSemigroup, "the multiplicative semigroup generated by all non-units", [ IsNearRing ], - function(R) - local M, n, S; - M:=MultiplicativeSemigroupOfNearRing(R); - n:=NearRingNonUnits(R); - S:=Subsemigroup(M,n); - return S; - end); + function( R ) + local M, n, S; + + M := MultiplicativeSemigroupOfNearRing( R ); + n := NearRingNonUnits( R ); + S := Subsemigroup( M, n ); + return S; + end ); ## ############################################################################ @@ -313,48 +340,53 @@ InstallMethod( NonUnitsAsMultiplicativeSemigroup, InstallMethod( IsOneGeneratedNearRing, "Is one generated nearring", [ IsNearRing ], - function(R) - local S, T, U, x; - S:=SubNearRings(R); - T:=[]; - for x in S do - if Size(x)) InstallMethod( AutomorphismsAssociatedWithNearRingUnits, - "Automorphisms associated with nearring units", + "Automorphisms associated with nearring units", [ IsNearRing, IsNearRingElementCollection ], - function(R,un) - local A, Aut, d, G, g, gen, m, mg, r, u, x; - G:=GroupReduct(R); - mg:=SmallGeneratingSet(G); - Aut:=AutomorphismGroup(G); - m:=Size(Aut); - if ForAll(un, u->u^m=Identity(R)) then - A:=[]; - for r in un do - gen:=[]; - for x in mg do - d:=AsGroupReductElement(r^(m-1)*AsNearRingElement(R,x)); - Add(gen,d); - od; - g:=GroupHomomorphismByImages(G,G,mg,gen); - Add(A,g); - od; - return A; - else return fail; - fi; - end); + function( R, un ) + local A, Aut, d, G, g, gen, m, mg, r, u, x; + + G := GroupReduct( R ); + mg := SmallGeneratingSet( G ); + Aut := AutomorphismGroup( G ); + m := Size( Aut ); + if ForAll( un, u -> u^m = Identity( R ) ) then + A := []; + for r in un do + gen := []; + for x in mg do + d := AsGroupReductElement( r^(m - 1) * AsNearRingElement( R, x ) ); + Add( gen, d ); + od; + g := GroupHomomorphismByImages( G, G, mg, gen ); + Add( A, g ); + od; + return A; + else + return fail; + fi; + end ); ## ############################################################################ @@ -362,23 +394,24 @@ InstallMethod( AutomorphismsAssociatedWithNearRingUnits, # EndomorphismsAssociatedWithNearRingElements() InstallMethod( EndomorphismsAssociatedWithNearRingElements, "Endomorphisms associated with nearring elements", - [ IsNearRing, IsNearRingElementCollection ], - function(R,elm) - local a, d, En, G, g, mg, x, y; - G:=GroupReduct(R); - mg:=MinimalGeneratingSet(G); - En:=[]; - for x in elm do - a:=[]; - for y in mg do - d:=AsGroupReductElement(x*AsNearRingElement(R,y)); - Add(a,d); - od; - g:=GroupHomomorphismByImages(G,G,mg,a); - Add(En,g); - od; - return En; - end); + [ IsNearRing, IsNearRingElementCollection ], + function( R, elm ) + local a, d, En, G, g, mg, x, y; + + G := GroupReduct( R ); + mg := MinimalGeneratingSet( G ); + En := []; + for x in elm do + a := []; + for y in mg do + d := AsGroupReductElement( x * AsNearRingElement( R, y ) ); + Add( a, d ); + od; + g := GroupHomomorphismByImages( G, G, mg, a ); + Add( En, g ); + od; + return En; + end ); ## ############################################################################ @@ -387,66 +420,73 @@ InstallMethod( EndomorphismsAssociatedWithNearRingElements, InstallMethod( SemidirectProductAssociatedWithNearRing, "Semidirect product associated with nearring", [ IsNearRing ], - function(R) - local A, S, G, Un; - if Identity(R)=fail then return fail; - else - G:=GroupReduct(R); - Un:=UnitsOfNearRing(R); - A:=AutomorphismsAssociatedWithNearRingUnits(R,Un); - A:=AsGroup(A); - S:=SemidirectProduct(A,G); - return S; - fi; - end); + function( R ) + local A, S, G, Un; + + if Identity( R ) = fail then + return fail; + else + G := GroupReduct( R ); + Un := UnitsOfNearRing( R ); + A := AutomorphismsAssociatedWithNearRingUnits( R, Un ); + A := AsGroup( A ); + S := SemidirectProduct( A, G ); + return S; + fi; + end ); ############################################################################ ## # IsCircleSubgroupOfNearRing -InstallMethod( IsCircleSubgroupOfNearRing, +InstallMethod( IsCircleSubgroupOfNearRing, "Is circle subgroup of nearring", [ IsNearRing, IsGroup ], - function( R, H) - local a, d, F, G, Un, x; - if Identity(R)=fail then Error("must be a nearring with one"); - else - Un:=UnitsOfNearRing(R); - F:=[]; - a:=AsGroupReductElement(One(R)); - for x in H do - d:=AsNearRingElement(R,a*x); - Add(F,d); - od; - fi; - if IsSubset(Un,F) and Size(Unique(ListX(F,F,\*)))=Size(F) then - return true; - else return false; - fi; - end); + function( R, H ) + local a, d, F, G, Un, x; + + if Identity( R ) = fail then + Error( "must be a nearring with one" ); + else + Un := UnitsOfNearRing( R ); + F := []; + a := AsGroupReductElement( One( R ) ); + for x in H do + d := AsNearRingElement( R, a * x ); + Add( F, d ); + od; + fi; + if IsSubset( Un, F ) and Size( Unique( ListX( F, F, \* ) ) ) = Size( F ) then + return true; + else + return false; + fi; + end ); ## ############################################################################ ## # FactorizedGroupAssociatedWithCircleSubgroupOfNearRing -InstallMethod(FactorizedGroupAssociatedWithCircleSubgroupOfNearRing, +InstallMethod( FactorizedGroupAssociatedWithCircleSubgroupOfNearRing, "Factorized group associated with circle subgroup of nearring", [ IsNearRing, IsGroup ], - function( R, H) - local A, a, S, d, F, x; - if IsCircleSubgroupOfNearRing(R, H)=true then - a:=AsGroupReductElement(One(R)); - F:=[]; - for x in H do - d:=AsNearRingElement(R,a*x); - Add(F,d); - od; - A:=AutomorphismsAssociatedWithNearRingUnits(R,F); - A:=AsGroup(A); - S:=SemidirectProduct(A,H); - return S; - else Error("the subgroup of nearring is not circle"); - fi; - end); + function( R, H ) + local A, a, S, d, F, x; + + if IsCircleSubgroupOfNearRing( R, H ) = true then + a := AsGroupReductElement( One( R ) ); + F := []; + for x in H do + d := AsNearRingElement( R, a * x ); + Add( F, d ); + od; + A := AutomorphismsAssociatedWithNearRingUnits( R, F ); + A := AsGroup( A ); + S := SemidirectProduct( A, H ); + return S; + else + Error( "the subgroup of nearring is not circle" ); + fi; + end ); ## ############################################################################ @@ -454,13 +494,14 @@ InstallMethod(FactorizedGroupAssociatedWithCircleSubgroupOfNearRing, # ConstantPartOfNearRing() InstallMethod( ConstantPartOfNearRing, "Constant part of nearring", - [ IsNearRing ], - function(R) - local g,Rc; - g:=EndomorphismsAssociatedWithNearRingElements(R,[Zero(R)])[1]; - Rc:=SubNearRingBySubgroupNC(R,Image(g)); - return Rc; - end); + [ IsNearRing ], + function( R ) + local g, Rc; + + g := EndomorphismsAssociatedWithNearRingElements( R, [ Zero( R ) ] )[1]; + Rc := SubNearRingBySubgroupNC( R, Image( g ) ); + return Rc; + end ); ## ############################################################################ @@ -468,13 +509,14 @@ InstallMethod( ConstantPartOfNearRing, # ZeroSymmetricPartOfNearRing() InstallMethod( ZeroSymmetricPartOfNearRing, "Zero-symmetric part of nearring", - [ IsNearRing ], - function(R) - local g,R0; - g:=EndomorphismsAssociatedWithNearRingElements(R,[Zero(R)])[1]; - R0:=SubNearRingBySubgroupNC(R,Kernel(g)); - return R0; - end); + [ IsNearRing ], + function( R ) + local g, R0; + + g := EndomorphismsAssociatedWithNearRingElements( R, [ Zero( R ) ] )[1]; + R0 := SubNearRingBySubgroupNC( R, Kernel( g ) ); + return R0; + end ); ############################################################################ ## @@ -500,11 +542,12 @@ InstallMethod(IsNearRingWithIdentity, true, [IsNearRing], 0, - function ( R ) - local id; - id := Identity( R ); - return ( id <> fail ); - end); + function ( R ) + local id; + + id := Identity( R ); + return ( id <> fail ); + end ); ## ############################################################################ @@ -512,19 +555,23 @@ InstallMethod(IsNearRingWithIdentity, # IsSubNearRing() InstallMethod( IsSubNearRing, "Is the subgroup of the additive group a subnearring", - [ IsNearRing, IsGroup], - function(R,H) - local a, G, M, S; - G:=GroupReduct(R); - M:=[]; - if IsSubgroup(G,H)=false then return false;fi; - for a in H do - Add(M,AsNearRingElement(R,a)); - od; - S:=SemigroupByGenerators(M); - if Size(H)=Size(S) then - return true;fi; - return false; - end); + [ IsNearRing, IsGroup], + function( R, H ) + local a, G, M, S; + + G := GroupReduct( R ); + M := []; + if IsSubgroup( G, H ) = false then + return false; + fi; + for a in H do + Add( M, AsNearRingElement( R, a ) ); + od; + S := SemigroupByGenerators( M ); + if Size( H ) = Size( S ) then + return true; + fi; + return false; + end ); ## From e578596d3edc3dbc54064bf5a8f4b08eeffa56a0 Mon Sep 17 00:00:00 2001 From: Olexandr Konovalov <5751387+olexandr-konovalov@users.noreply.github.com> Date: Fri, 1 May 2026 12:58:56 +0100 Subject: [PATCH 2/2] Apply suggestions from code review Thanks for James and Max! Co-authored-by: Max Horn --- lib/lib_local.gi | 20 +++++++------------- lib/local.gi | 3 +-- 2 files changed, 8 insertions(+), 15 deletions(-) diff --git a/lib/lib_local.gi b/lib/lib_local.gi index 9119c98..20d57ed 100644 --- a/lib/lib_local.gi +++ b/lib/lib_local.gi @@ -7,7 +7,7 @@ InstallMethod( LocalNearRing, [ IsInt, IsInt, IsInt, IsInt, IsInt ], function( k, l, m, n, w ) local h, dio, G, P, P1, H, R, Li, t, gr, Pos, x, y, d, z, hom, - f, const, constructor, u, B, A, k1, Or, a, g, Em, ma, mul, + const, constructor, u, B, A, k1, Or, a, g, Em, ma, mul, Nr; h := DirectoriesPackageLibrary( "LocalNR", Concatenation( "Endom/", String( k ) ) ); @@ -39,10 +39,9 @@ InstallMethod( LocalNearRing, d := GroupHomomorphismByImagesNC( G, G, gr, x ); Add( hom, d ); od; - f := function( x, y ) return x * y; end; - const := function( y ) return function( x ) return y^x; end; end; + const := y -> (x -> y^x); constructor := function( z ) return function( u ) return function( x, y ) return u^( PreImage( z, y ) * PreImage( z, x ) ); end; end; end; - B := Filtered( hom, x -> IsInjective( x ) ); + B := Filtered( hom, IsInjective ); A := GroupByGenerators( B ); k1 := Position( OrbitLengths( A, G ), Size( A ) ); Or := OrbitsDomain( A, G )[k1]; @@ -65,7 +64,7 @@ InstallMethod( AllLocalNearRings, [ IsInt, IsInt, IsInt, IsInt ], function( k, l, m, n ) local G, P1, w, h, H, s, t, Li, hom, En, R, gr, Pos, x, i, y, z, - d, f, const, constructor, u, I, J, T, B, j, A, k1, Or, a, + d, const, constructor, u, I, J, T, B, j, A, k1, Or, a, g, Em, ma, mul, Nr; h := DirectoriesPackageLibrary( "LocalNR", Concatenation( "Endom/", String( k ) ) ); @@ -102,7 +101,6 @@ InstallMethod( AllLocalNearRings, Add( hom[i], d ); od; od; - f := function( x, y ) return x * y; end; const := function( y ) return function( x ) return y^x; end; end; constructor := function( z ) return function( u ) return function( x, y ) return u^( PreImage( z, y ) * PreImage( z, x ) ); end; end; end; @@ -111,7 +109,7 @@ InstallMethod( AllLocalNearRings, repeat J := []; T := []; - B := Filtered( hom[I[1]], x -> IsInjective( x ) );; + B := Filtered( hom[I[1]], IsInjective ); for i in I do if IsSubset( hom[i], B ) then Add( J, i ); @@ -152,7 +150,7 @@ InstallGlobalFunction(TheAdditiveGroupsOfLibraryOfLNRsOfOrder, function(n) cont := DirectoryContents( t[1] );; Size( cont ); for i in cont do - RemoveCharacters( i, "Endom\.txt\.gz" ); + RemoveCharacters( i, "Endom.txt.gz" ); od; h := []; for j in cont do @@ -211,11 +209,7 @@ InstallGlobalFunction(IsAdditiveGroupOfLibraryOfLNRs, function(G) fi; k := Size( r ); d := Filtered( [1..k], x -> IdGroup( G ) = r[x] ); - if Size( d ) > 0 then - Print( "true" ); - else - Print( "false" ); - fi; + return Size( d ) > 0; end ); diff --git a/lib/local.gi b/lib/local.gi index 7d9277c..13460f6 100644 --- a/lib/local.gi +++ b/lib/local.gi @@ -64,8 +64,7 @@ InstallMethod( EndoOrbitsOfGroup, x := M[1]; H := []; for y in En do - Add( H, x^y ); - H := Unique( H ); + AddSet( H, x^y ); od; Add( F, [ x, H ] ); T := Difference( T, H );