diff --git a/lib/grp.gi b/lib/grp.gi index e939bda830..f9f93651d7 100644 --- a/lib/grp.gi +++ b/lib/grp.gi @@ -4293,17 +4293,15 @@ InstallMethod( GroupWithGenerators, "generic method for collection", [ IsCollection ], function( gens ) -local G,fam,typ,id,typename; +local G,fam,typ,id; fam:=FamilyObj(gens); typ:=IsGroup and IsAttributeStoringRep and HasIsEmpty and HasGeneratorsOfMagmaWithInverses; - typename:="defaultGroupType"; if IsFinite(gens) then typ:=typ and IsFinitelyGeneratedGroup; - typename:="defaultFinitelyGeneratedGroupType"; if Length(gens)>0 and CanEasilyCompareElements(gens) then id:=One(gens[1]); @@ -4311,25 +4309,15 @@ local G,fam,typ,id,typename; typ:=typ and HasIsTrivial and IsNonTrivial; if Length(gens)<=1 then typ:=typ and IsCyclic; - typename:="defaultNontrivialCyclicGroupType"; - else - typename:="defaultFinitelyGeneratedNontrivialGroupType"; fi; else typ:=typ and IsTrivial and HasIsNonTrivial; - typename:="defaultTrivialGroupType"; fi; elif Length(gens)<=1 then typ:=typ and IsCyclic; - typename:="defaultCyclicGroupType"; fi; fi; - if not IsBound(fam!.(typename)) then - typ:=NewType(fam,typ); - fam!.(typename):=typ; - else - typ:=fam!.(typename); - fi; + typ:=NewType(fam,typ); G:=rec(); ObjectifyWithAttributes(G,typ,GeneratorsOfMagmaWithInverses,AsList(gens)); @@ -4341,43 +4329,31 @@ InstallMethod( GroupWithGenerators, "generic method for collection and identity element", IsCollsElms, [ IsCollection, IsMultiplicativeElementWithInverse ], function( gens, id ) -local G,fam,typ,typename; +local G,fam,typ; fam:=FamilyObj(gens); typ:=IsGroup and IsAttributeStoringRep and HasIsEmpty and HasGeneratorsOfMagmaWithInverses and HasOne; - typename:="defaultGroupWithOneType"; if IsFinite(gens) then typ:=typ and IsFinitelyGeneratedGroup; - typename:="defaultFinitelyGeneratedGroupWithOneType"; if Length(gens)>0 and CanEasilyCompareElements(gens) then if ForAny(gens,x->x<>id) then typ:=typ and HasIsTrivial and IsNonTrivial; if Length(gens)<=1 then typ:=typ and IsCyclic; - typename:="defaultNontrivialCyclicGroupWithOneType"; - else - typename:="defaultNontrivialGroupWithOneType"; fi; else typ:=typ and IsTrivial and HasIsNonTrivial; - typename:="defaultTrivialGroupWithOneType"; fi; elif Length(gens)<=1 then typ:=typ and IsCyclic; - typename:="defaultCyclicGroupWithOneType"; fi; fi; - if not IsBound(fam!.(typename)) then - typ:=NewType(fam,typ); - fam!.(typename):=typ; - else - typ:=fam!.(typename); - fi; + typ:=NewType(fam,typ); G:=rec(); ObjectifyWithAttributes(G,typ,GeneratorsOfMagmaWithInverses,AsList(gens), @@ -4393,15 +4369,10 @@ local G,fam,typ; fam:= CollectionsFamily( FamilyObj( id ) ); - if not IsBound(fam!.defaultFinitelyGeneratedTrivialGroupWithOneType) then - typ:=IsGroup and IsAttributeStoringRep - and HasGeneratorsOfMagmaWithInverses and HasOne and IsTrivial and - HasIsEmpty and HasIsNonTrivial; - typ:=NewType(fam,typ); - fam!.defaultTrivialGroupWithOneType:=typ; - else - typ:=fam!.defaultTrivialGroupWithOneType; - fi; + typ:=IsGroup and IsAttributeStoringRep + and HasGeneratorsOfMagmaWithInverses and HasOne and IsTrivial and + HasIsEmpty and HasIsNonTrivial; + typ:=NewType(fam,typ); G:= rec(); ObjectifyWithAttributes( G, typ, diff --git a/lib/grppc.gi b/lib/grppc.gi index d74d305d7c..66718bd8a3 100644 --- a/lib/grppc.gi +++ b/lib/grppc.gi @@ -347,7 +347,7 @@ InstallMethod( GroupWithGenerators, # override methods for `IsList' or `IsEmpty'. 10, function( gens ) -local G,fam,typ,id,pcgs,typename; +local G,fam,typ,id,pcgs; fam:=FamilyObj(gens); pcgs:=DefiningPcgs(ElementsFamily(fam)); @@ -357,7 +357,6 @@ local G,fam,typ,id,pcgs,typename; and HasIsEmpty and HasGeneratorsOfMagmaWithInverses and IsFinite and IsFinitelyGeneratedGroup and HasFamilyPcgs and HasHomePcgs and HasGeneralizedPcgs; - typename:="defaultFinitelyGeneratedGroupType"; # we can always compare to id cheaply id:=One(gens[1]); @@ -365,20 +364,11 @@ local G,fam,typ,id,pcgs,typename; typ:=typ and HasIsTrivial and IsNonTrivial; if Length(gens)<=1 then typ:=typ and IsCyclic; - typename:="defaultNontrivialCyclicGroupType"; - else - typename:="defaultFinitelyGeneratedNontrivialGroupType"; fi; else typ:=typ and IsTrivial and HasIsNonTrivial; - typename:="defaultTrivialGroupType"; - fi; - if not IsBound(fam!.(typename)) then - typ:=NewType(fam,typ); - fam!.(typename):=typ; - else - typ:=fam!.(typename); fi; + typ:=NewType(fam,typ); G:=rec(); ObjectifyWithAttributes(G,typ,GeneratorsOfMagmaWithInverses,AsList(gens), @@ -396,7 +386,7 @@ InstallOtherMethod( GroupWithGenerators, IsMultiplicativeElementWithInverseByPolycyclicCollector] , 0, function( gens, id ) -local G,fam,typ,pcgs,typename; +local G,fam,typ,pcgs; fam:=FamilyObj(gens); pcgs:=DefiningPcgs(ElementsFamily(fam)); @@ -406,27 +396,17 @@ local G,fam,typ,pcgs,typename; and HasIsEmpty and HasGeneratorsOfMagmaWithInverses and HasOne and IsFinite and IsFinitelyGeneratedGroup and HasFamilyPcgs and HasHomePcgs and HasGeneralizedPcgs; - typename:="defaultFinitelyGeneratedGroupWithOneType"; # we can always compare to id cheaply if ForAny(gens,x->x<>id) then typ:=typ and HasIsTrivial and IsNonTrivial; if Length(gens)<=1 then typ:=typ and IsCyclic; - typename:="defaultNontrivialCyclicGroupWithOneType"; - else - typename:="defaultFinitelyGeneratedNontrivialGroupWithOneType"; fi; else typ:=typ and IsTrivial and HasIsNonTrivial; - typename:="defaultTrivialGroupWithOneType"; - fi; - if not IsBound(fam!.(typename)) then - typ:=NewType(fam,typ); - fam!.(typename):=typ; - else - typ:=fam!.(typename); fi; + typ:=NewType(fam,typ); G:=rec(); ObjectifyWithAttributes(G,typ,GeneratorsOfMagmaWithInverses,AsList(gens), @@ -449,19 +429,14 @@ local G,fam,typ,pcgs; fam:= CollectionsFamily( FamilyObj( id ) ); - if not IsBound(fam!.defaultFinitelyGeneratedTrivialGroupWithOneType) then - # pc groups are always finite and gens is finite. - typ:=IsGroup and IsAttributeStoringRep - and HasGeneratorsOfMagmaWithInverses and HasOne - and IsFinite and IsFinitelyGeneratedGroup - and IsTrivial and HasIsNonTrivial - and HasIsEmpty and IsSolvableGroup - and HasFamilyPcgs and HasHomePcgs and HasGeneralizedPcgs; - typ:=NewType(fam,typ); - fam!.defaultTrivialGroupWithOneType:=typ; - else - typ:=fam!.defaultTrivialGroupWithOneType; - fi; + # pc groups are always finite and gens is finite. + typ:=IsGroup and IsAttributeStoringRep + and HasGeneratorsOfMagmaWithInverses and HasOne + and IsFinite and IsFinitelyGeneratedGroup + and IsTrivial and HasIsNonTrivial + and HasIsEmpty and IsSolvableGroup + and HasFamilyPcgs and HasHomePcgs and HasGeneralizedPcgs; + typ:=NewType(fam,typ); pcgs:=DefiningPcgs(ElementsFamily(fam)); diff --git a/lib/magma.gi b/lib/magma.gi index ed1f88f95d..19a6d2568c 100644 --- a/lib/magma.gi +++ b/lib/magma.gi @@ -654,14 +654,13 @@ InstallOtherMethod( MagmaWithOneByGenerators, #M MagmaWithInversesByGenerators( ) . . . . . . . . for a collection ## MakeMagmaWithInversesByFiniteGenerators:=function(family,gens) -local M,typ,id,typename,fam; +local M,typ,id,fam; fam:=FamilyObj(gens); typ:=IsMagmaWithInverses and IsAttributeStoringRep and HasGeneratorsOfMagmaWithInverses and HasIsEmpty; - typename:="defaultMagmaWithInversesByGeneratorsType"; if IsFinite(gens) then # typ:=typ and IsFinitelyGeneratedGroup; don't know whether group @@ -673,19 +672,12 @@ local M,typ,id,typename,fam; id:=One(gens[1]); if ForAny(gens,x->x<>id) then typ:=typ and HasIsTrivial and IsNonTrivial; - typename:="defaultNontrivialMagmaWithInversesByGeneratorsType"; else typ:=typ and IsTrivial and HasIsNonTrivial; - typename:="defaultTrivialMagmaWithInversesByGeneratorsType"; fi; fi; fi; - if not IsBound(fam!.(typename)) then - typ:=NewType(fam,typ); - fam!.(typename):=typ; - else - typ:=fam!.(typename); - fi; + typ:=NewType(fam,typ); M:=rec();