From b7467799337fc048c16c18970a645fd100943f97 Mon Sep 17 00:00:00 2001 From: Alexander Hulpke Date: Mon, 23 Apr 2018 14:17:21 -0600 Subject: [PATCH] Avoid the `triv` variable and setting properties to false. --- lib/grp.gi | 38 +++++++++----------------------------- lib/grppc.gi | 20 +++++++------------- lib/magma.gi | 23 +++++++---------------- 3 files changed, 23 insertions(+), 58 deletions(-) diff --git a/lib/grp.gi b/lib/grp.gi index 0c2f60d035..9c19042752 100644 --- a/lib/grp.gi +++ b/lib/grp.gi @@ -4301,12 +4301,10 @@ InstallMethod( GroupWithGenerators, "generic method for collection", [ IsCollection ], function( gens ) -local G,fam,typ,id,triv,typename; +local G,fam,typ,id,typename; fam:=FamilyObj(gens); - triv:=fail; # might not find out - typ:=IsGroup and IsAttributeStoringRep and HasIsEmpty and HasGeneratorsOfMagmaWithInverses; typename:="defaultGroupType"; @@ -4318,8 +4316,7 @@ local G,fam,typ,id,triv,typename; if Length(gens)>0 and CanEasilyCompareElements(gens) then id:=One(gens[1]); if ForAny(gens,x->x<>id) then - typ:=typ and HasIsTrivial and HasIsNonTrivial; - triv:=false; + typ:=typ and HasIsTrivial and IsNonTrivial; if Length(gens)<=1 then typ:=typ and IsCyclic; typename:="defaultFinitelyGeneratedNontrivialCyclicGroupType"; @@ -4327,8 +4324,7 @@ local G,fam,typ,id,triv,typename; typename:="defaultFinitelyGeneratedNontrivialGroupType"; fi; else - typ:=typ and HasIsTrivial and HasIsNonTrivial; - triv:=true; + typ:=typ and IsTrivial and HasIsNonTrivial; typename:="defaultFinitelyGeneratedTrivialGroupType"; fi; elif Length(gens)<=1 then @@ -4344,14 +4340,7 @@ local G,fam,typ,id,triv,typename; fi; G:=rec(); - if triv=fail then - ObjectifyWithAttributes(G,typ,GeneratorsOfMagmaWithInverses,AsList(gens), - IsEmpty,false); - else - ObjectifyWithAttributes(G,typ,GeneratorsOfMagmaWithInverses,AsList(gens), - IsEmpty,false,IsTrivial,triv, - IsNonTrivial,not triv); - fi; + ObjectifyWithAttributes(G,typ,GeneratorsOfMagmaWithInverses,AsList(gens)); return G; end ); @@ -4360,10 +4349,9 @@ InstallMethod( GroupWithGenerators, "generic method for collection and identity element", IsCollsElms, [ IsCollection, IsMultiplicativeElementWithInverse ], function( gens, id ) -local G,fam,typ,triv,typename; +local G,fam,typ,typename; fam:=FamilyObj(gens); - triv:=fail; # might not find out typ:=IsGroup and IsAttributeStoringRep and HasIsEmpty and HasGeneratorsOfMagmaWithInverses and HasOne; @@ -4375,8 +4363,7 @@ local G,fam,typ,triv,typename; if Length(gens)>0 and CanEasilyCompareElements(gens) then if ForAny(gens,x->x<>id) then - typ:=typ and HasIsTrivial and HasIsNonTrivial; - triv:=false; + typ:=typ and HasIsTrivial and IsNonTrivial; if Length(gens)<=1 then typ:=typ and IsCyclic; typename:="defaultFinitelyGeneratedNontrivialCyclicGroupWithOneType"; @@ -4384,8 +4371,7 @@ local G,fam,typ,triv,typename; typename:="defaultFinitelyGeneratedNontrivialGroupWithOneType"; fi; else - typ:=typ and HasIsTrivial and HasIsNonTrivial; - triv:=true; + typ:=typ and IsTrivial and HasIsNonTrivial; typename:="defaultFinitelyGeneratedTrivialGroupWithOneType"; fi; elif Length(gens)<=1 then @@ -4402,14 +4388,8 @@ local G,fam,typ,triv,typename; fi; G:=rec(); - if triv=fail then - ObjectifyWithAttributes(G,typ,GeneratorsOfMagmaWithInverses,AsList(gens), - IsEmpty,false,One,id); - else - ObjectifyWithAttributes(G,typ,GeneratorsOfMagmaWithInverses,AsList(gens), - IsEmpty,false,One,id, - IsTrivial,triv,IsNonTrivial,not triv); - fi; + ObjectifyWithAttributes(G,typ,GeneratorsOfMagmaWithInverses,AsList(gens), + One,id); return G; end ); diff --git a/lib/grppc.gi b/lib/grppc.gi index 002a5f8ef7..c8ae3d5359 100644 --- a/lib/grppc.gi +++ b/lib/grppc.gi @@ -346,7 +346,7 @@ InstallMethod( GroupWithGenerators, # override methods for `IsList' or `IsEmpty'. 10, function( gens ) -local G,fam,typ,id,triv,pcgs,typename; +local G,fam,typ,id,pcgs,typename; fam:=FamilyObj(gens); pcgs:=DefiningPcgs(ElementsFamily(fam)); @@ -355,14 +355,13 @@ local G,fam,typ,id,triv,pcgs,typename; typ:=IsGroup and IsAttributeStoringRep and HasIsEmpty and HasGeneratorsOfMagmaWithInverses and IsFinite and IsFinitelyGeneratedGroup - and HasIsTrivial and HasIsNonTrivial and HasFamilyPcgs and HasHomePcgs and HasGeneralizedPcgs; typename:="defaultFinitelyGeneratedGroupType"; # we can always compare to id cheaply id:=One(gens[1]); if ForAny(gens,x->x<>id) then - triv:=false; + typ:=typ and HasIsTrivial and IsNonTrivial; if Length(gens)<=1 then typ:=typ and IsCyclic; typename:="defaultFinitelyGeneratedNontrivialCyclicGroupType"; @@ -370,7 +369,7 @@ local G,fam,typ,id,triv,pcgs,typename; typename:="defaultFinitelyGeneratedNontrivialGroupType"; fi; else - triv:=true; + typ:=typ and IsTrivial and HasIsNonTrivial; typename:="defaultFinitelyGeneratedTrivialGroupType"; fi; if not IsBound(fam!.(typename)) then @@ -382,8 +381,6 @@ local G,fam,typ,id,triv,pcgs,typename; G:=rec(); ObjectifyWithAttributes(G,typ,GeneratorsOfMagmaWithInverses,AsList(gens), - IsEmpty,false,IsTrivial,triv, - IsNonTrivial,not triv, FamilyPcgs,pcgs,HomePcgs,pcgs,GeneralizedPcgs,pcgs); SetGroupOfPcgs (pcgs, G); @@ -398,7 +395,7 @@ InstallOtherMethod( GroupWithGenerators, IsMultiplicativeElementWithInverseByPolycyclicCollector] , 0, function( gens, id ) -local G,fam,typ,triv,pcgs,typename; +local G,fam,typ,pcgs,typename; fam:=FamilyObj(gens); pcgs:=DefiningPcgs(ElementsFamily(fam)); @@ -407,13 +404,12 @@ local G,fam,typ,triv,pcgs,typename; typ:=IsGroup and IsAttributeStoringRep and HasIsEmpty and HasGeneratorsOfMagmaWithInverses and HasOne and IsFinite and IsFinitelyGeneratedGroup - and HasIsTrivial and HasIsNonTrivial and HasFamilyPcgs and HasHomePcgs and HasGeneralizedPcgs; typename:="defaultFinitelyGeneratedGroupWithOneType"; # we can always compare to id cheaply if ForAny(gens,x->x<>id) then - triv:=false; + typ:=typ and HasIsTrivial and IsNonTrivial; if Length(gens)<=1 then typ:=typ and IsCyclic; typename:="defaultFinitelyGeneratedNontrivialCyclicGroupWithOneType"; @@ -421,7 +417,7 @@ local G,fam,typ,triv,pcgs,typename; typename:="defaultFinitelyGeneratedNontrivialGroupWithOneType"; fi; else - triv:=true; + typ:=typ and IsTrivial and HasIsNonTrivial; typename:="defaultFinitelyGeneratedTrivialGroupWithOneType"; fi; if not IsBound(fam!.(typename)) then @@ -433,8 +429,7 @@ local G,fam,typ,triv,pcgs,typename; G:=rec(); ObjectifyWithAttributes(G,typ,GeneratorsOfMagmaWithInverses,AsList(gens), - IsEmpty,false,One,id, - IsTrivial,triv,IsNonTrivial,not triv, + One,id, FamilyPcgs,pcgs,HomePcgs,pcgs,GeneralizedPcgs,pcgs); SetGroupOfPcgs (pcgs, G); @@ -473,7 +468,6 @@ local G,fam,typ,pcgs; ObjectifyWithAttributes( G, typ, GeneratorsOfMagmaWithInverses, empty, One, id, - IsEmpty,false, IsNonTrivial,false, FamilyPcgs,pcgs,HomePcgs,pcgs,GeneralizedPcgs,pcgs); SetGroupOfPcgs (pcgs, G); diff --git a/lib/magma.gi b/lib/magma.gi index 3dad92a88f..9eea81eace 100644 --- a/lib/magma.gi +++ b/lib/magma.gi @@ -654,10 +654,9 @@ InstallOtherMethod( MagmaWithOneByGenerators, #M MagmaWithInversesByGenerators( ) . . . . . . . . for a collection ## MakeMagmaWithInversesByFiniteGenerators:=function(family,gens) -local M,triv,typ,id,typename,fam; +local M,typ,id,typename,fam; fam:=FamilyObj(gens); - triv:=fail; # might not find out typ:=IsMagmaWithInverses and IsAttributeStoringRep and HasGeneratorsOfMagmaWithInverses @@ -673,12 +672,10 @@ local M,triv,typ,id,typename,fam; if Length(gens)>0 and CanEasilyCompareElements(gens) then id:=One(gens[1]); if ForAny(gens,x->x<>id) then - typ:=typ and HasIsTrivial and HasIsNonTrivial; - triv:=false; + typ:=typ and HasIsTrivial and IsNonTrivial; typename:="defaultNontrivialMagmaWithInversesByGeneratorsType"; else - typ:=typ and HasIsTrivial and HasIsNonTrivial; - triv:=true; + typ:=typ and IsTrivial and HasIsNonTrivial; typename:="defaultTrivialMagmaWithInversesByGeneratorsType"; fi; fi; @@ -691,16 +688,10 @@ local M,triv,typ,id,typename,fam; fi; M:=rec(); - if triv=fail then - ObjectifyWithAttributes( M,typ, - GeneratorsOfMagmaWithInverses, AsList( gens ), - IsEmpty,false); - else - ObjectifyWithAttributes( M,typ, - GeneratorsOfMagmaWithInverses, AsList( gens ), - IsEmpty,false,IsTrivial,triv, - IsNonTrivial,not triv); - fi; + + ObjectifyWithAttributes( M,typ, + GeneratorsOfMagmaWithInverses, AsList( gens )); + if HasIsAssociative( M ) and IsAssociative( M ) then SetIsFinitelyGeneratedGroup( M, true ); fi;