diff --git a/lib/lib_local.gi b/lib/lib_local.gi index 20d57ed..143d46a 100644 --- a/lib/lib_local.gi +++ b/lib/lib_local.gi @@ -23,24 +23,14 @@ InstallMethod( LocalNearRing, Li := AsSortedList( G ); t := Size( P ); gr := MinimalGeneratingSet( G ); - Pos := []; - for x in gr do - Add( Pos, Position( Li, x ) ); - od; + Pos := List( gr, x -> Position( Li, x ) ); for y in [1..t] do - d := []; - for z in Pos do - Add( d, Li[P[y][z]] ); - od; + d := List( Pos, z -> Li[P[y][z]] ); Add( H, d ); od; - hom := []; - for x in H do - d := GroupHomomorphismByImagesNC( G, G, gr, x ); - Add( hom, d ); - od; + hom := List( H, x -> GroupHomomorphismByImagesNC( G, G, gr, x ) ); 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; + constructor := { z, u } -> { x, y } -> u^( PreImage( z, y ) * PreImage( z, x ) ); B := Filtered( hom, IsInjective ); A := GroupByGenerators( B ); k1 := Position( OrbitLengths( A, G ), Size( A ) ); @@ -49,7 +39,7 @@ InstallMethod( LocalNearRing, g := const( a ); Em := MagmaWithOne( hom ); ma := MappingByFunction( Em, G, g ); - mul := constructor( ma )( a ); + mul := constructor( ma, a ); Nr := ExplicitMultiplicationNearRingNC( G, mul ); return Nr; fi; @@ -76,34 +66,23 @@ InstallMethod( AllLocalNearRings, P1 := ReadAsFunction( w )(); H := []; s := Size( P1 ); - t := List( P1, Size );; - Li := AsSortedList( G );; + 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; + Pos := List( gr, x -> Position( Li, x ) ); 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; + d := List( Pos, z -> Li[P1[i][y][z]] ); Add( H[i], d ); od; - hom[i] := []; - for x in H[i] do - d := GroupHomomorphismByImagesNC( G, G, gr, x ); - Add( hom[i], d ); - od; + hom[i] := List( H[i], x -> GroupHomomorphismByImagesNC( G, G, gr, x ) ); od; - 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; + const := y -> (x -> y^x); + constructor := { z, u } -> { x, y } -> u^( PreImage( z, y ) * PreImage( z, x ) ); s := Size( hom ); I := [1..s]; repeat @@ -124,14 +103,14 @@ InstallMethod( AllLocalNearRings, for l in J do Em := MagmaWithOne( hom[l] ); ma := MappingByFunction( Em, G, g ); - mul := constructor( ma )( a ); + mul := constructor( ma, a ); Nr := ExplicitMultiplicationNearRingNC( G, mul ); Add( T, Nr ); od; Add( R, T ); - I := Difference( I, J );; + I := Difference( I, J ); until Size( I ) = 0; - R := Concatenation( R );; + R := Concatenation( R ); return R; fi; end ); @@ -147,7 +126,7 @@ InstallGlobalFunction(TheAdditiveGroupsOfLibraryOfLNRsOfOrder, function(n) if IsEmpty( t ) then Error( "the order must be PrimePowerInt and 3 B:=LocalNearRing(16,10,8,2,7);; #! gap> M:=MultiplicativeSemigroupOfNearRing(B); -#! Semigroup with identity (f1) #! #! gap> Size(M); #! 16 diff --git a/lib/local.gi b/lib/local.gi index 13460f6..3a9fa9c 100644 --- a/lib/local.gi +++ b/lib/local.gi @@ -6,15 +6,7 @@ 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; + return not IsAbelian( G ) and ForAll( MaximalSubgroups( G ), IsAbelian ); end ); ## @@ -54,18 +46,12 @@ InstallMethod( EndoOrbitsOfGroup, A := AutomorphismGroup( G ); En := Endomorphisms( G ); Or := OrbitsDomain( A, G ); - T := []; - for x in Or do - Add( T, Representative( x ) ); - od; + T := List( Or, Representative ); F := []; repeat M := Filtered( T, x -> Order( x ) = Maximum( List( T, Order ) ) ); x := M[1]; - H := []; - for y in En do - AddSet( H, x^y ); - od; + H := Set( En, y -> x^y ); Add( F, [ x, H ] ); T := Difference( T, H ); until Size( T ) = 0; @@ -90,11 +76,7 @@ InstallMethod( IsEndoCyclicGroup, Add( h, F[i][2] ); fi; od; - if Size( h ) > 0 then - return true; - else - return false; - fi; + return Size( h ) > 0; end ); ## @@ -103,17 +85,16 @@ InstallMethod( IsEndoCyclicGroup, # UnitsOfNearRing() InstallMethod( UnitsOfNearRing, "Compute all units of nearring", - true, [ IsNearRing ], 0, function( R ) local A, G, one, x; - one := Identity( R ); - if one = fail then + if not IsNearRingWithIdentity( R ) then return []; else G := GroupReduct( R ); A := AutomorphismGroup( G ); + one := Identity( R ); return Filtered( R, x -> x^Size( A ) = one ); fi; end ); @@ -124,7 +105,6 @@ InstallMethod( UnitsOfNearRing, # IsLocalNearRing() InstallMethod( IsLocalNearRing, "Is local nearring", - true, [ IsNearRing ], 0, function( R ) @@ -133,15 +113,8 @@ InstallMethod( IsLocalNearRing, 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; + V := List( L, x -> one + x ); + return IsSubset( U, V ); end ); ## @@ -153,14 +126,10 @@ InstallMethod( IsDistributiveElementOfNearRing, [ IsNearRing, IsNearRingElement ], 0, function( R, r ) - local map, x; + local map; map := MappingByFunction( R, R, x -> x * r ); - if IsAdditiveGroupHomomorphism( map ) then - return true; - else - return false; - fi; + return IsAdditiveGroupHomomorphism( map ); end ); ## @@ -176,17 +145,9 @@ InstallMethod( IsLocalRing, 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; + elm := List( mg, x -> AsNearRingElement( R, x ) ); + return IsAbelian( G ) and IsLocalNearRing( R ) and + ForAll( elm, y -> IsDistributiveElementOfNearRing( R, y ) ); end ); ## @@ -197,7 +158,7 @@ InstallMethod( NearRingNonUnits, "Compute nearring non-units", [ IsNearRing ], function( R ) - if Identity( R ) = fail then + if not IsNearRingWithIdentity( R ) then return List( R ); else return Difference( R, UnitsOfNearRing( R ) ); @@ -214,7 +175,7 @@ InstallMethod( GroupOfUnitsAsGroupOfAutomorphisms, function( R ) local A, U; - if Identity( R ) = fail then + if not IsNearRingWithIdentity( R ) then Error( "no units exist" ); else U := UnitsOfNearRing( R );; @@ -238,15 +199,9 @@ InstallMethod( SubNearRingByGenerators, G := GroupReduct( R ); S := SemigroupByGenerators( elm ); repeat - M := []; - N := []; - for a in S do - Add( M, AsGroupReductElement( a ) ); - od; + M := List( S, AsGroupReductElement ); M := Subgroup( G, M ); - for b in M do - Add( N, AsNearRingElement( R, b ) ); - od; + N := List( M, b -> AsNearRingElement( R, b ) ); S := SemigroupByGenerators( N ); until Size( M ) = Size( S ); c := SubNearRingBySubgroupNC( R, M ); @@ -265,10 +220,7 @@ InstallMethod( NonUnitsAsAdditiveSubgroup, if IsLocalNearRing( R ) then N := NearRingNonUnits( R ); - g := []; - for a in N do - Add( g, AsGroupReductElement( a ) ); - od; + g := List( N, AsGroupReductElement ); L := Subgroup( GroupReduct( R ), g ); return L; else @@ -303,16 +255,7 @@ 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; + return AsSemigroup( List( R ) ); end ); @@ -343,18 +286,9 @@ InstallMethod( IsOneGeneratedNearRing, local S, T, U, x; S := SubNearRings( R ); - T := []; - for x in S do - if Size( x ) < Size( R ) then - Add( T, x ); - fi; - od; + T := Filtered( S, x -> Size( x ) < Size( R ) ); U := Union( T ); - if Size( U ) < Size( R ) then - return true; - else - return false; - fi; + return Size( U ) < Size( R ); end ); ############################################################################ @@ -373,11 +307,7 @@ InstallMethod( AutomorphismsAssociatedWithNearRingUnits, 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; + gen := List( mg, x -> AsGroupReductElement( r^(m - 1) * AsNearRingElement( R, x ) ) ); g := GroupHomomorphismByImages( G, G, mg, gen ); Add( A, g ); od; @@ -401,11 +331,7 @@ InstallMethod( EndomorphismsAssociatedWithNearRingElements, 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; + a := List( mg, y -> AsGroupReductElement( x * AsNearRingElement( R, y ) ) ); g := GroupHomomorphismByImages( G, G, mg, a ); Add( En, g ); od; @@ -422,7 +348,7 @@ InstallMethod( SemidirectProductAssociatedWithNearRing, function( R ) local A, S, G, Un; - if Identity( R ) = fail then + if not IsNearRingWithIdentity( R ) then return fail; else G := GroupReduct( R ); @@ -443,22 +369,14 @@ InstallMethod( IsCircleSubgroupOfNearRing, function( R, H ) local a, d, F, G, Un, x; - if Identity( R ) = fail then + if not IsNearRingWithIdentity( R ) 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; + F := List( H, x -> AsNearRingElement( R, a * x ) ); fi; + return IsSubset( Un, F ) and Size( Unique( ListX( F, F, \* ) ) ) = Size( F ); end ); ## @@ -471,13 +389,9 @@ InstallMethod( FactorizedGroupAssociatedWithCircleSubgroupOfNearRing, function( R, H ) local A, a, S, d, F, x; - if IsCircleSubgroupOfNearRing( R, H ) = true then + if IsCircleSubgroupOfNearRing( R, H ) then a := AsGroupReductElement( One( R ) ); - F := []; - for x in H do - d := AsNearRingElement( R, a * x ); - Add( F, d ); - od; + F := List( H, x -> AsNearRingElement( R, a * x ) ); A := AutomorphismsAssociatedWithNearRingUnits( R, F ); A := AsGroup( A ); S := SemidirectProduct( A, H ); @@ -524,7 +438,6 @@ InstallMethod( ZeroSymmetricPartOfNearRing, InstallMethod( IsSemiDistributiveNearRing, "test all elements", - true, [IsNearRing], 1, # faster in the moment function ( nr ) @@ -538,14 +451,10 @@ InstallMethod( # IsNearRingWithIdentity() InstallMethod(IsNearRingWithIdentity, "Is nearring with identity", - true, [IsNearRing], 0, function ( R ) - local id; - - id := Identity( R ); - return ( id <> fail ); + return Identity( R ) <> fail; end ); ## @@ -559,18 +468,10 @@ InstallMethod( IsSubNearRing, 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; + M := List( H, a -> AsNearRingElement( R, a ) ); S := SemigroupByGenerators( M ); - if Size( H ) = Size( S ) then - return true; - fi; - return false; + return Size( H ) = Size( S ); end ); - -## diff --git a/tst/localnr02.tst b/tst/localnr02.tst index 8459204..3e03ee4 100644 --- a/tst/localnr02.tst +++ b/tst/localnr02.tst @@ -128,7 +128,6 @@ gap> Size(I); # doc/_Chapter_Functions.xml:299-306 gap> B:=LocalNearRing(16,10,8,2,7);; gap> M:=MultiplicativeSemigroupOfNearRing(B); -Semigroup with identity (f1) gap> Size(M); 16